Commit Graph

308 Commits

Author SHA1 Message Date
Friedemann Kleint
b8ad0fdae9 Fix QPainterPath-related compilation errors in Qt 5.15
Some include of QPainterPath was removed in Qt, causing errors like:

easingpane\easinggraph.cpp(258): error C2079: 'path' uses undefined class 'QPainterPath'
easingpane\easinggraph.cpp(275): error C2027: use of undefined type 'QPainterPath'
easingpane\easinggraph.cpp(305): error C2664: 'void QPainter::drawPath(const QPainterPath &)': cannot convert argument 1 from 'int'
to 'const QPainterPath &'
easingpane\easinggraph.cpp(305): note: Reason: cannot convert from 'int' to 'const QPainterPath'
easingpane\easinggraph.cpp(305): note: use of undefined type 'QPainterPath'
...

Add the missing include statements.

Change-Id: I4f3383cbcec891a52480a683c9c76ed5deee2b2a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-03-12 09:47:02 +00:00
Eike Ziller
d2759075de TextEditor: Do not overwrite existing indenters
In 6959618d7b a default indenter was set
on all text editor factories.
Unfortunately some editors, like the C++ editor, set their indenter in
the text document constructor, which would then be overridden by this
default indenter.
For now remove the default indenter again until this is better thought
through.

Partially reverts 6959618d7b.

Change-Id: I8f32e92438883edb6be853fa838b75297347a937
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-03-05 07:14:40 +00:00
Eike Ziller
6959618d7b TextEditor: Use simple text indentation as default
Simple indentation based on the previous line was already available in
the NormalIndenter class. Merge that up the hierarchy chain into
TextIndenter which is the base for other text-based indenters, and make
that the default indenter for text editor factories.

Text editor factories that don't have a special indenter get at least
basic indentation support for free that way.

Change-Id: Ib977a990f10a99bead82bc8a8348c02a106665f1
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-03-04 06:55:37 +00:00
Eike Ziller
956fd44c3e TextEditor: Improve splitting top/bottom
If the text cursor is visible, but in the bottom area of the editor, it
would be no longer visible after splitting. That makes the probable
"area of interest" vanish from sight.

Check that condition (visible before, but would not be visible
afterwards), and if that is the case center the text cursor in both
resulting editors.

Change-Id: I8c8dccd2d9db439c82d0aca34b8ef99fa97aa48e
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-02-27 14:25:58 +00:00
Eike Ziller
56d2dab5fe Merge remote-tracking branch 'origin/4.11' into 4.12
Change-Id: I7e526857a4d9e63838f76d5e3fbb0db7287d5617
2020-02-27 09:35:11 +01:00
Eike Ziller
c912ee6862 TextEditor: Fix scrolling state after splitting
And when restoring editors in other ways (like from a session).

When splitting, the new editor was always scrolling to make the text
cursor visible, even if it wasn't visible in the original.

1. open editor with long contents
2. scroll away from the text cursor, so the line isn't visible
3. split and wonder

or 3. close and re-open Qt Creator, and restore the session

Our code already does set the state of the new editor to the old one,
but that state was destroyed by QPlainTextEdit::showEvent, which scrolls
on first show if text was added to the document.
So, wrap the showEvent with save/restoreState on first show.

Change-Id: I95e0b4e963ebb33d13ce020affaf7fc7f94c9257
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-02-26 14:12:01 +00:00
David Schulz
af52b65d6a Editor: Fix self recursive update
The update rect should be identical to the calculated line rect when
repainting the current line highlight. And the offset must not be
calculated into the line rect since we just want to repaint the complete
viewport width.

Fixes: QTCREATORBUG-23647
Change-Id: I0656f0fee4823c8ff55c70b2a4cd69f0183e141d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-02-26 08:09:54 +00:00
Eike Ziller
fa59e02f89 Merge remote-tracking branch 'origin/4.11' into 4.12
Change-Id: I8cc80483cdb10309bf73aba5cfab52c1d90e1bbc
2020-02-26 08:14:47 +01:00
David Schulz
63e9c4c31a Editor: Prevent setting negative position in block selection
Fixes: QTCREATORBUG-23622
Change-Id: I0f041a772869695e7d460effd4b0d58f94ce55ec
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-25 09:49:06 +00:00
David Schulz
aee78bd58d Editor: do not split on nbsp in rewrap paragraph
Change-Id: I443400056f647a58a98d9bb6a221b10852470ba2
Fixes: QTCREATORBUG-23643
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-02-20 12:45:28 +00:00
David Schulz
909cb3859b Editor: update proposal widget after editor contents changed
Also when text is removed via shortcuts.

Fixes: QTCREATORBUG-15038
Change-Id: I1c78b9306594fbf13378a55b27be18769de141a6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-18 12:03:07 +00:00
Eike Ziller
d43f1662d0 Make TextEditor setup more flexible
So far it was only possible to combine TextEditorFactory, BaseTextEditor
and TextEditorWidget directly.
That TextEditorWidget is also directly a QPlainTextEdit made it
impossible to "decorate" the text editor widget with something else
without a lot of effort.

Make it possible to create a text editor factory that returns an
arbitrary widget, as long as it can be "cast" to a TextEditorWidget with
either qobject_cast or Aggregation::query. That way the TextEditorWidget
instance can be attached to the editor widget via Aggregation.

Adapt other code that accesses TextEditorWidget from editors
accordingly. Introduce a common method how to do that.

Change-Id: I72b8721f3a8a8d8281c39af75253e9c80cbe1250
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-02-12 10:28:31 +00:00
David Schulz
67aef33dd0 Editor: reapply font settings after palette changes
Change-Id: I99368b03e093794656cf7a69aa9ef75032c430eb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-02-11 13:21:33 +00:00
hjk
9c934ed44c TextEditor: De-QObject-ify TextEditorActionHandler
Change-Id: I8c4919b89ce35d421edd4a21a650d5e0df4a7ead
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-02-10 13:54:39 +00:00
David Schulz
4ebf6981db Editor: Update viewport margin if extra area width differs
Change-Id: I305bde817f70ac4b84054d04170700ef10f090cd
Fixes: QTCREATORBUG-23238
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-10 13:40:32 +00:00
David Schulz
ce40e13e3a Editor: replace static functions with lambdas
Change-Id: I6e7c74b70e6752bbf8b030d6110a71bd5e3240c5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-10 07:13:02 +00:00
David Schulz
a1e408622a Editor: reuse already collected viewport rect
Change-Id: I974837e112030b61234a8d9614ed77d834b60bd5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-10 07:12:15 +00:00
hjk
c65b02f1fa TextEditor/Vcs: Remove use of QObject parent for editor factories
Change-Id: I1b3d8b49649401c7bb03c0415f886530416afa2c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-07 14:19:37 +00:00
hjk
f8e4d61fc3 TextEditor: Handle TextEditorActionHandler ownership
... in TextEditorFactory explicitly. Plan is to remove the QObject
inheritance of the factory, so it can't serve as a parent anymore.

Change-Id: I7bad358b5d150c695befc7ad4afcf7c2be7fd248
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-02-05 14:21:44 +00:00
hjk
80e7e70889 TextEditor: Remove unused TextEditorFactory::setEditorActionHandlers
... overload.

Change-Id: I0bab88e1b3c40b7c34cda578209e9d150c2d56b4
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-02-05 14:21:35 +00:00
hjk
d7ae3b79f8 Core: Make IEditorFactory::createEditor use a function object
Also, replace or remove unneeded Q_OBJECTs, and make base
setters and adders protected.

Change-Id: I212257ef53984d8852dc8c478537199fc9483486
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-02-05 11:41:29 +00:00
David Schulz
59318b2789 TextEditor: Add toolbar widgets only after a valid toolbar action
We can't just add widgets after the first action of the toolbar.
The first action might not have a widget and will assert for that reason
in Qt.

Change-Id: Ib69c7d6d91bd56f25023aaebf961fef15cdcf008
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-01-29 12:43:54 +00:00
hjk
56febd062c TextEditor: Fix warning about using nullptr to initialize flags
Change-Id: I1c219954423cfc935966e6cc8b57f3962627ab0c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-01-28 08:17:35 +00:00
David Schulz
4070d6a289 Editor: add formatter support
Change-Id: I65590273b2541e08a39970cd9bb4739a5634b2f7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-01-22 06:00:11 +00:00
Alessandro Portale
24a25eed14 Use isEmpty() instead of count() or size()
Change-Id: I0a89d2808c6d041da0dc41ea5aea58e6e8759bb4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-01-20 20:56:57 +00:00
David Schulz
67ea1e1f84 Editor: Also fix DeleteStartOfWord for camel case deactivated
this amends 5a4bfb2460

Change-Id: Ibd635e47e8ed90cb26f7a2ba233582ab540618ca
Fixes: QTCREATORBUG-12377
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-01-15 06:55:48 +00:00
David Schulz
5a4bfb2460 Editor: fix deleteEndOfWord and deleteStartOfWord
If the cursor is positioned at a word boundary the action behaves
incorrect. Copy the behavior of QWidgetTextControlPrivate::keyPressEvent
which feels more natural.

Fixes: QTCREATORBUG-8977
Fixes: QTCREATORBUG-7056
Change-Id: I9dc0102023bb6234dcfa82619a976c723bc37a05
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-01-14 12:42:55 +00:00
David Schulz
372014b843 Editor: Rename format -> autoIndent
Renaming the auto indent function triggered by Ctrl+I to make room
for a real format action.

Change-Id: If5731353311030d66a20f1093a7fdd300703ebbc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-01-09 07:41:05 +00:00
David Schulz
67db5cb2de Editor: Use optional for text mark color
instead of an additional hasColor member

Change-Id: I658401bb91374b10420e070625cf61049cb3cc64
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-01-07 19:02:12 +00:00
Nikolai Kosjar
548e798885 TextEditor: Fix typo in a TextDocumentLayout function
Change-Id: I17153d9bfe9820f3ccc88f54bce1d494a522be33
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-12-18 10:15:50 +00:00
Eike Ziller
e16876df0c Merge remote-tracking branch 'origin/4.11'
Change-Id: Ieb0bb1ebab9a5efb42d15bbeac2cd4c46a6de962
2019-12-18 09:14:14 +01:00
Eike Ziller
6d4223c5d6 Do not show line ending option in read-only editors
This avoids showing the option for example in git log or blame views.
The user also should not be able to actually change the line ending
style of read-only editors.

Fixes: QTCREATORBUG-23276
Change-Id: Ifa5cc9f663539928b4d5422b020e348b439684fa
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Marius Sincovici <smaryus@gmail.com>
2019-12-18 06:42:10 +00:00
David Schulz
11eea3aae0 TextEditor: skip update link on mouse press events
The link is updated on the release anyway. Reset the press state of
the link now after a mouse move event.

Fixes: QTCREATORBUG-21848
Change-Id: Ice7a9873b1635a1b59ba7b8f2a266bf14e28c112
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-11-28 14:04:56 +00:00
Eike Ziller
4e6142c932 Merge remote-tracking branch 'origin/4.11'
Conflicts:
	src/plugins/autotest/testresultspane.cpp
	src/plugins/cmakeprojectmanager/cmaketool.cpp

Change-Id: Iade695ac9cab8bf3e3a1abd6e2c71f4a19132ac0
2019-11-21 22:18:35 +02:00
Volodymyr Samokhatko
264185245d EditorManager: add GotoLastEdit action
Done-with: Guillem Miguel <guillemmr@hotmail.com>
Done-with: Andre Hartmann <aha_1980@gmx.de>
Change-Id: I5059ea4ba8e9aa115cf4d0a90b80a4606779039a
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-11-20 08:21:36 +00:00
Andre Hartmann
1d357f6b33 TextEditor: Make TextEditorLinkLabel elideable
And use that in the Include and Type Hierarchy
panels to allow resizing the panels smaller.

Fixes: QTCREATORBUG-23197
Change-Id: Ia4b39e610c7a4be4df564dc69573f4748d7634a5
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-11-12 09:00:16 +00:00
Eike Ziller
646c7860cb Merge remote-tracking branch 'origin/4.11'
Conflicts:
	src/plugins/genericprojectmanager/genericprojectplugin.cpp
	src/plugins/projectexplorer/environmentaspect.cpp
	src/plugins/projectexplorer/environmentaspect.h
	src/plugins/projectexplorer/environmentaspectwidget.cpp

Change-Id: Id21d62cf14419febd1e06c9b429fcdf4501c0eaf
2019-11-11 12:58:11 +01:00
David Schulz
cb908779a9 Editor: always paint complete line when painting current line highlight
If the paint event rect does not contain the complete line, request an
update with the full line width also for editable editors. This fixes
current line highlight issues in the commit reword editor.

Change-Id: I6b93230a47bdd61248c1aa9631208606cbbae7c8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-11-07 09:59:05 +00:00
David Schulz
30587e6dce LanguageClient: Do not add hover handler twice to editor
Check whether an editor already contains the hover handler before adding
to the list of handlers. Also remove the handler when a document is
deactivated for a specific client.

Change-Id: Iec1d3a0fd1dc3f02c8dd50b8968ff063efe2508a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-11-06 12:40:23 +00:00
Eike Ziller
177f14b115 TextEditor: Do not change the text format for tool tips
We should not force the tool tip text to HTML when help content is
available or when adding the F1 icon.
Instead add help content and F1 icon into the tool tip layout.

Change-Id: Ibe2d4fa2fb81bcda4e5aeb0d7d86dbf63fcf3ce6
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-11-06 09:43:20 +00:00
David Schulz
2c112a51c3 Highlighter: update all editors after downloading additional definitions
Instead of just the editor with the info bar that was triggering the
download action or none editor if the action was triggered from the
settings dialog.

Change-Id: I4158eeb7fdb0a763d082c6d801b400e8635c7f38
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-11-04 13:45:19 +00:00
David Schulz
5ece12d4ea Highlighter: clarify 'Update Definitions' action
by renaming it to Download Definitions and adding a tooltip stating that it
collects all definitions that are missing or were updated after the release and
downloads it to the ksyntax highlighting user folder.
Also adding a separate reload definitions button in the settings behind
the user path.

Change-Id: I059cc98e33147cae910fa4fdb35631d1dca81448
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-11-04 13:23:58 +00:00
Andre Hartmann
b292c30a13 Core: Make InfoBar::GlobalSuppressionMode an enum class
Change-Id: I859a727196a887f7699a667fbe07e1bfead4cb2b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-09-12 06:45:06 +00:00
Sona Kurazyan
82bcf4e9f5 Remove usages of deprecated APIs
Replaced:
  QPalette::ColorRole::Background -> QPalette::ColorRole::Window
  QPalette::ColorRole::Foreground -> QPalette::ColorRole::WindowText
  Qt::ItemDataRole::TextColorRole -> Qt::ItemDataRole::ForegroundRole
  QFontMetrics::width() -> QFontMetrics::horizontalAdvance()

Task-number: QTBUG-76491
Change-Id: I1302e6b569e725daa6f7be1428ffe055657fc644
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-09-03 09:15:30 +00:00
David Schulz
587dc52119 Editor: accept common text edit short cut override events
see QWidgetTextControl::processEvent and
QInputControl::isCommonTextEditShortcut. This will break assigning
shortcuts to for example Shift+a.

Change-Id: I4f97c27a47e2a7a44bf06b3ca949a6de74d4bb64
Fixes: QTCREATORBUG-22854
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-08-29 08:12:48 +00:00
Marius Sincovici
a96ed0d4a0 Add option to configure file line ending for an open document
Add into the text editor toolbar a combo box which allows to change
the line endings for an open document.
The supported line endings are LF and CRLF.

Change-Id: I029ba7867e0087b162edba7aba1bd1d1e966fd69
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-08-07 20:07:16 +00:00
Andre Hartmann
839f45faa9 FancyLineEdit: Add camel case navigation
Use it for search and replace functions as well as for Locator.

The camel case navigation can be switched on / off with
the existing menu Options > Text Editor > Behavior >
Enable Build-in camel case navigation.

Fixes: QTCREATORBUG-21140
Change-Id: I3f2dcafff231366b3c8f08c14514dd8940cca2a0
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-08-02 06:40:56 +00:00
hjk
251287f0d3 Avoid warning on empty expressions
For some reason, Q_UNUSED includes already a semicolon, adding one
on the user side creates an additional empty statement.

Change-Id: I9c5e8fac381345a60792cb75e2938fd53958d3b0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-23 11:55:59 +00:00
David Schulz
09b9aa98a8 TextEditor: fix low contrast of hovered folding markers
When using the 'windowsvista' style the folding markers are blue when
hovered. This color is almost invisible on the default folding range
background color. Use the tested folding markers of the fusion style,
because it is already used when device pixel ratio != 1.0

Change-Id: I23659cce71a2eb101692597a1d256d43f6426920
Fixes: QTCREATORBUG-21702
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-06-18 11:45:26 +00:00
Joel Smith
e846b8717a TextEditor: Type over punctuation that can be auto completed
This restores a feature of older Qt Creator versions: typing "over"
closing punctuation.  For instance, if my cursor is at | and I have
something like this:

    if (statement|)

... and I type the ) character, older versions of Qt Creator would not
end up with )).  With newer versions of Qt Creator, this behavior is
limited to the case where an autocompletion has just happened (i.e. if I
typed the opening ( character, the closing ) is auto inserted and
highlighted - and if I type it myself, it won't add a second one).

Task-number: QTCREATORBUG-16946
Change-Id: I45af3ac139d5e7c76e5f0a8a9d66762f9209a525
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-05-27 14:09:12 +00:00