Commit Graph

203 Commits

Author SHA1 Message Date
Eike Ziller
78c4cf9884 Fix wrong color of line/column label
Fix up of a8aa4bbb31. That introduced a
non-QToolBar widget that should be styled like a tool bar, so use a
StyledBar instead of plain widget.

Task-number: QTCREATORBUG-20916
Change-Id: Ifd899fac136ef4e3310cd5d2b9cd9f0cd2de1376
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2018-08-09 15:04:29 +00:00
Orgad Shaneh
5b95d91294 TextEditor: Fix crash
Happens when closing an editor while tooltip processing is in progress.

Change-Id: I023f62ab6ba1e8b1bbe207da08c1e526fb99430a
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-06-26 08:05:26 +00:00
David Schulz
cdcac66c78 TextEditor: Do not paint invisible search results
Painting search results outside of the visible area of
the text editor widget can become costly, so avoid it.

Task-number: QTCREATORBUG-20599
Change-Id: I3e65e40c4bb40c3e7b1ccd1337dee1208bd22d28
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-06-20 04:50:29 +00:00
Eike Ziller
8623a93998 Fix that bookmarks couldn't be added to .pro files with mouse
The area with the marks was not showing up.
This patch reverses the logic for showing the marks area to opt-out.
Almost all editors were opting in for it already. The AndroidManifest
editor, VCS base editor, and widget designer text editor opt out now.

Task-number: QTCREATORBUG-20339
Change-Id: Iccb6d0256618f7ef70e8921847ce2fd46fd660c0
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-06-19 07:59:17 +00:00
David Schulz
3e618cbf76 Editor: fix continuosly repainting partially visible annotations
Task-number: QTCREATORBUG-20422
Change-Id: Id171d8cb3022dd6e345e55fdf029c445bc42c382
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-05-29 04:50:12 +00:00
Jarek Kobus
df50dd7353 HighlightScrollBar: Always show the current line
Also when the scrollbar handle occupies the whole scrollbar area.

Change-Id: I124950e3f0898f853a187ea393731ddb0800aa99
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-05-17 05:57:50 +00:00
Jarek Kobus
80beedfa49 Refactor the highlight scrollbar painting
Scale the highlight on the handle according to the number of lines
visible on screen. In case when document has huge amount of lines
and only couple of lines are visible on screen, this
generates a nice magnification effect.

Change-Id: I43d7cce859cbc14da77272685a6f8d2350b41bb7
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-05-04 11:49:55 +00:00
Eike Ziller
a8aa4bbb31 More improvements of text editor tool bar
Make line/column label always visible, and move context drop down to the
right, so it vanishes first. Reduce the minimum size and stretch of the
outline drop down, so the context drop down doesn't vanish too early
either.

Task-number: QTCREATORBUG-15218
Task-number: QTCREATORBUG-19386
Change-Id: Ie2ced1cb62a27a0129438f5605d5711bfac50cd0
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-04-25 07:10:52 +00:00
Eike Ziller
ce84f64d1b TextEditor: Fix some static analyzer warnings
Use nullptr, do explicit double/float/int conversions, use constFirst.

Change-Id: I269718ade5c54ac613357f59c774e2f47e18a9df
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-04-24 07:46:49 +00:00
Orgad Shaneh
7d3a79c696 Utils: Purge asConst
Replace by qAsConst.

Change-Id: I3301366f73c066c86f08df7188d70dc3b613c55c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-04-09 09:04:00 +00:00
Eike Ziller
454e9ee5ca Add Context Help to text editor context menu
For this make the default context menu for the text editor extensible
and add the context help item from the help plugin, which now has an
optional dependency on the text editor to ensure correct loading order
if both are present.

Task-number: QTCREATORBUG-55
Change-Id: I378a491ba3700e65fc262bdb10c8ead5ad62cb33
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-03-29 08:26:24 +00:00
Eike Ziller
5e6305f346 TextEditor: Fix default context menu
Text editor implementations that did not do anything special with
invoking their context menu, including our plain text editor, only had
Qt's default context menu, without Qt Creator's clipboard history and
BOM actions.

Make the default actions in our custom context menu more similar to Qt's
default actions by adding Undo, Redo and Select All, and not hiding
disabled actions, and use that by default in all text editor
implementations.

Change-Id: Idd5fb276dcd652223d96536dacde8110f9eb576f
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-03-22 07:57:34 +00:00
Ivan Donchevskii
08d1274ccc CppTools: Remove processEvents call from follow symbol
processEvents is a bad way of dealing with asynchronous
requests. Use QFutureWatcher for that purpose.

Change-Id: I3839cb9db80a6d391f6af1178e96986a325b7b99
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-03-19 13:37:46 +00:00
Eike Ziller
0b10ecc718 Merge remote-tracking branch 'origin/4.6'
Conflicts:
	src/plugins/cmakeprojectmanager/cmakeproject.h
	src/plugins/debugger/debuggerplugin.cpp
	src/plugins/ios/iosrunfactories.cpp
	src/plugins/nim/project/nimproject.h
	src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
	src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp
	src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp
	src/plugins/qmlprojectmanager/qmlproject.h
	src/plugins/qnx/qnxrunconfigurationfactory.cpp
	src/plugins/qtsupport/exampleslistmodel.cpp
	src/plugins/winrt/winrtrunfactories.cpp

Change-Id: Ib029fdbaa65270426332f5edd6e90264be5fb539
2018-03-13 11:25:38 +01:00
Eike Ziller
e693c9a02e Fix issue with snippet variables not behaving correctly on Gnome
Directly after triggering the snippet completion, a funny input method
event is sent that doesn't contain any data. This still results in a
even more funny contentsChanged signal from QPlainTextEdit which made
our text editor think that the document has changed somewhere else. In
which case we close the snippet variable input.
So ignore funny input method events.

Task-number: QTCREATORBUG-19571
Change-Id: I3958e8736b1b3e3dea5225356ee4cd173d6beaa0
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-03-05 09:49:20 +00:00
Eike Ziller
7c3cfa166d Merge remote-tracking branch 'origin/4.6'
Conflicts:
	src/plugins/coreplugin/helpmanager.cpp

Change-Id: I2feb60ec0afb2f22f75dc137a01c3fa217b299d8
2018-02-23 10:56:52 +01:00
David Schulz
dc358dc841 TextEditor: update scrollbar after adding annotation between lines
Emit documentSizeChanged after resizing the block boundaries because of
an annotation between lines.

Task-number: QTCREATORBUG-19790
Change-Id: If468ec003a43f37fdcb182344992e4094b269c92
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-02-22 13:40:04 +00:00
David Schulz
464a9ad9ab Editor: Fix block for offset calculation
Take block bounding rects into account, when calculating the row count
or the center visible line.

Change-Id: If933828867df25920eeb56359e9a42a8b95d9c6d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-02-15 09:51:46 +00:00
David Schulz
b4a1798618 TextEditor: add document content completer
Add completion based on words of the document. This provides basic
assistance for programming languages without a code model.

Task-number: QTCREATORBUG-13869
Change-Id: I3a9c59c741dfd6895442fc0524cfd1bd3b2b0111
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-02-14 13:38:22 +00:00
Eike Ziller
c7bb8305d7 Add overlooked Goto Document Start/End shortcut settings
Change-Id: I2f60e2607660cea98aebb1057226010ea4837156
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2018-02-13 13:29:27 +00:00
Nikolai Kosjar
f75983b0aa TextEditor: Modernize texteditor.{cpp,h}
Apply some clazy and modernize fixes from clang tidy: mostly use of
nullptr and removal of type duplication.

Change-Id: Ibd9ee8f9b8a836a40d6f9be0b95acc91513a1a01
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-02-07 11:36:53 +00:00
Eike Ziller
049b761242 Fix inconsistency between tool tip and context help
For the tool tip it moves the position to the start of the word before
passing it to the hoverhandler. That wasn't the case if the user
requests context help, which lead to the strange situation that the tool
tip showed help, but context help at the same position did not (e.g. on
QApplication::topLevelWidgets() with the cursor between the
parentheses).

Related to QTCREATORBUG-15959

Change-Id: I2b9918ea235869c2ddeeba6e749958c10a47d259
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-01-29 09:51:23 +00:00
Nikolai Kosjar
4db7fd064f TextEditor: Avoid running hover handlers for same request
...in case the current run is not yet finished.

Change-Id: Id78db576ad8fad10af6b21c73e5b47b49d58d26b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-22 12:33:12 +00:00
Nikolai Kosjar
9fd9bd25ab TextEditor: Let BaseHoverHandler handle help id callbacks
...to support asynchronous hover handlers like ClangHoverHandler.

Change-Id: I8dc7189db37ec3a923cf493b8957c59ec9be447c
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-01-19 13:58:07 +00:00
Nikolai Kosjar
0a4073ef90 TextEditor: Return hover handler priority by callback
...to get rid of the asynchronous code path.

Change-Id: I56377510440631b0be712333b2a4018717c86389
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-01-19 13:57:57 +00:00
Nikolai Kosjar
dd06a4188d Core: Return context help id by callback
...to support asynchronous providers.

Change-Id: I483489c74e7886d5bc2bf00b65540c3d2c7afee0
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-01-18 13:54:02 +00:00
David Schulz
8cecd73d2b Editor: show text mark icon while dragging
Change-Id: Ib8c3cbb6e298c3af5e159b18cb474f9b2baa1a83
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-01-12 09:20:06 +00:00
David Schulz
30d733a2e1 Editor: initialize block count after duplicate
Task-number: QTCREATORBUG-19550
Change-Id: I0f93823ca919a269b07412103715a0fe0a8adeb8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-01-08 13:57:43 +00:00
Jarek Kobus
990da15c1e Refactor HighlightScrollBar
Rename it into HighlightScrollBarController.
Don't derive it anymore from QScrollBar.
Make it based on QObject and decorate
the existing instance of QAbstractScrollArea as needed.

Fix the highlight of the shared scrollbar of the SideBySideDiffEditor.
Both left and right diff editors have their own
HighlightScrollBarController and their own separate overlays, but both
overlays are created as children of the same right editor instance.

Synchronize also the cursor between left and right editors.
Make highlight current line working.

Make the overlay transparent for mouse events - this fixes
issues on macOS when scolling over invisible scrollbar.

Change-Id: Iab05c360173e09d8748658c59785da86438a7189
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-12 08:17:58 +00:00
Eike Ziller
508a9bdb24 Move line/column label functionality into single place
Create a LineColumnLabel class that aggregates the functionality that
was before spread through the editor widget and factory classes.

Change-Id: I6ba316174b2f690a0b146bdd606c6f8ed985ec20
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-07 12:49:26 +00:00
Eike Ziller
9687593bce Rename LineColumnLabel
It is not only used for line and column.

Change-Id: I544244dbca0b9f084e45ff2d7e4f28f79d2cae09
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-07 12:49:15 +00:00
Eike Ziller
a2739f55ed Merge remote-tracking branch 'origin/4.5'
Change-Id: Ic7c16091268083c0426cf29f0691a7ee458f2bd9
2017-12-07 09:16:01 +01:00
David Schulz
d0bf2a4528 TextEditor: fix animate navigation within file
The calculation based on visible lines is not working as
expected when we have collapsed blocks. Using QPlainTextEdit
functions to get the correct target scroll bar value.

Task-number: QTCREATORBUG-19327
Change-Id: I0393fc94ba2a11caeaa77d6d87bc69c6c7de1bb7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-12-01 07:58:43 +00:00
Ivan Donchevskii
8efb598e60 TextEditor: move Link class to separate header in Utils
Link is a common class and is used across the plugins.

Change-Id: Id92e47e1b8604316ca8b970804e57abaf404ec28
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-11-27 13:57:02 +00:00
David Schulz
c815d456ed TextEditor: Add option to display annotation between lines
Task-number: QTCREATORBUG-19181
Change-Id: I9b3957c678c08ca2f3ddf9cfa5ff272241547471
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-11-22 10:08:01 +00:00
David Schulz
2d437325b8 TextEditor: Restructure TextEditorWidget::extraAreaPaintEvent
Change-Id: I832168226bfe254f0540ca1a947bf16170494549
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-10-26 08:32:55 +00:00
Eike Ziller
7f626b1182 Merge remote-tracking branch 'origin/4.5'
Change-Id: Iceaa4ca40b5318744bde8a76c6d3ccca08df71bb
2017-10-25 16:07:21 +02:00
Eike Ziller
1a1681bbcc TextEditor: Work around linguist issues
lupdate has issues with resolving non-trivial uses of "using namespace"
(QTBUG-64007)
Move "using namespace" directive to a place where it is better handled
by lupdate.
Also use TextEditorWidget instead of *Private as the context.

Change-Id: I7d3bb8e1bc493196e47085827be31f97e0dce7b8
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-10-25 07:13:45 +00:00
Robert Loehning
289dbab200 TextEditor: Initialize PaintEventData::rightMargin
Change-Id: I64690e594cf20f073ba348f5896a8cf9da5260b8
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-10-23 13:35:40 +00:00
David Schulz
0c0c10b167 TextEditor: Fix block for visible row calculation
Take into account that a block can contain multiple visible rows.

Change-Id: Ifedeb113b3c1a6a374fa9418106e612c56559cba
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-23 10:58:18 +00:00
David Schulz
b1a3c0bba4 TextEditor: Restructure TextEditorWidget::paintEvent
Splitting the paintEvent method into various sub routines to increase
the maintainability.

Change-Id: I4aa7a52aa6e20279654784b55f92053d6ede00be
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-10-23 10:58:08 +00:00
David Schulz
72c283afc8 TextEditor: Add data container for editor widget paint event
The container is used to initialize and group data that
is relevant during a paint event.

This conatiner will be used in follow up patches as an argument
to subroutines.

Change-Id: I00c8bafff526e2d90776e7ea75621fc5e4c2981f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-10-20 06:17:27 +00:00
David Schulz
ae68aa5610 TextEditor: Update position of annotations outside event rectangle
Change-Id: Ie7d3db989b48a605fad4642c339940d67e505e1e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-17 11:48:39 +00:00
Christian Stenger
13717262a1 TextEditor: Fix determination of maximum width
Width is not zero-based.

Task-number: QTCREATORBUG-19091
Change-Id: I32134727bed204f6bb10748cd067a775f673b89b
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-10-17 11:46:10 +00:00
David Schulz
79bdd7e14f TextEditor: Fix update loop for annotations
Task-number: QTCREATORBUG-19091
Change-Id: I5f699747df10e25d412b2eec4620c3b51ad628e3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-16 09:54:33 +00:00
David Schulz
4a3765d64c TextEditor: Use visual whitespace format for line wrap arrow
Change-Id: Ifbf31010171ea4fd762457337ed56f60c19d5b4c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-10 09:09:16 +00:00
David Schulz
c2686fd9ae TextEditor: Fix annotation rectangle caching
The rectangle of an annotation is cached after it was painted. If just a
part of an editor was updated all annotations were removed but only
redrawn annotations were added to the cache again.

This behavior is replaced by removing annotations that are not visible
and those which got redrawn. So annotations that are still visible but
were not redrawn are kept in the cache.

Change-Id: I9246f1347b8f795284fb4fc9aabe11f251d16c25
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-09 12:31:33 +00:00
David Schulz
26d0b536ca TextEditor: cleanup annotation rect cache after mark is removed
Change-Id: I8a0ab2df9d310da6025325ab3114eeadabfd4fb1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-09 12:31:24 +00:00
David Schulz
5fb310828e TextEditor: reduce annotation painting artifacts
Request an update covering the complete annotation
rectangle if it is not part of the event rectangle
and Correctly calculate the position for the gradients.

Task-number: QTCREATORBUG-18855
Change-Id: I68b61459e6fd94949baebba25f965226f9d5e441
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-09 12:10:44 +00:00
David Schulz
cf624f92bd TextEditor: Optimize line annotation painting
Paint an annotation only if the event rectangle
contains the block for that specific annotation

Change-Id: I5f992f916da25268dd2c9e6b4703701934c8551d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-09 12:10:20 +00:00