Commit Graph

325 Commits

Author SHA1 Message Date
Friedemann Kleint
2bc4d82d31 Fix crash opening UI files
Add a null check, amending
aaa1376576.

Fixes: QTCREATORBUG-24241
Change-Id: I63e76b9d2dd10034b637f8f3cac5001b15b35d30
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-06-25 05:26:14 +00:00
Christian Stenger
d47f8eaff2 TextEditor: Utils: Do not use invalid regular expressions
Having a search inside a document and switching the find options
to use regular expressions may end up in lots of warnings
regarding using an invalid expression for a match call.
Check beforehand to avoid this.

Change-Id: Ia929090ae3910ff3fa87b57a5718293d2b6ccd04
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-06-22 09:19:59 +00:00
Eike Ziller
7c5ed6f7d9 Move InfoBar to Utils
The only reason it was required to be in Core plugin, was its use of Id,
which now is available in Utils.

Change-Id: I66ce863c24924e6448d339b3422538a7fe167336
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-06-18 06:39:54 +00:00
David Schulz
aaa1376576 Editor: Allow setting the optional action mask per editor
Instead of just enable actions that were disabled from the beginning you
can no disable optional actions.

Change-Id: I986b8a72523a8aeec9f4ccf76cd4921018ffc003
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-06-17 09:47:44 +00:00
David Schulz
5f91985931 Editor: enable optional actions per editor
Use an additional action mask to enable actions like find usage and
rename symbol per editor instance.

Change-Id: Iabee1820d0f3c156ad30ba760bfce9f6181045e6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-17 07:51:35 +00:00
Christian Stenger
29e60f0741 TextEditor: Replace QRegExp by QRegularExpression
Task-number: QTCREATORBUG-24098
Change-Id: Id407154bd7d05bf5bbf07a804959e87452225c70
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-06-16 07:40:18 +00:00
David Schulz
3559af69db TextEditor: move rename symbol action to text editor
Task-number: QTCREATORBUG-21578
Change-Id: I9a873dcd38bacb2287c45973b6be0091c3eb9480
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-05-12 04:28:19 +00:00
The Qt Project
86a3b94902 Merge "Merge remote-tracking branch 'origin/4.12'" 2020-04-24 11:59:18 +00:00
Eike Ziller
d79febdde9 Merge remote-tracking branch 'origin/4.12'
Conflicts:
	src/plugins/cmakeprojectmanager/cmakekitinformation.cpp

Change-Id: I90ef0063ed24e23bcb3d73fff086f50324faa1e2
2020-04-24 13:58:05 +02:00
Christian Stenger
0655ddbd65 TextEditor: Display cursor position
Change-Id: Ie5fd13ee80dcf14b6e6c8c0e220f5e00e654dde2
Reviewed-by: Federico Guerinoni <guerinoni.federico@gmail.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-04-24 10:38:40 +00:00
Friedemann Kleint
6cfe092301 Fix printing source code
After qtbase/4a240bb67e72b34c80af448e0a74846609fa6975,
the scaling of the margins changed.

Fixes: QTBUG-81121
Change-Id: I6987fe8e25da1771dd2bcd36fff8558fefd3dee0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-04-24 08:23:05 +00:00
David Schulz
5b15e7e415 Core: move CodecSelector dialog to Core
Task-number: QTCREATORBUG-23835
Change-Id: I824ae9650c244fffc064ade718fc788fc2908ada
Reviewed-by: hjk <hjk@qt.io>
2020-04-15 16:41:57 +00:00
Viacheslav Tertychnyi
4880694df4 TextEditor: Improve column selection
Add the possibility to more efficient column selection for large
documents using keyboard shortcuts Alt+Shift+PageUp/PageDown/Home/End.

Change-Id: Iaa2d9aeee587f1317dd82d7fef0b01fd5f5f7a55
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-04-02 13:09:43 +00:00
Eike Ziller
bac32dc740 Merge remote-tracking branch 'origin/4.12'
Conflicts:
	src/plugins/coreplugin/dialogs/shortcutsettings.cpp

Change-Id: I1f21845350bb69268ca51bc77167a8244adce22a
2020-03-26 15:26:27 +01:00
David Schulz
b06ad16160 TextEditor: Make accidentally activating a link more difficult again
Only follow links under cursor if control was already activated when
pressing the mouse button. This amends
11eea3aae0 which just checks if control is
pressed after releasing the mouse button.

Change-Id: I90d23dd3e5ff63aac7812fad889ad9fb7c052b56
Fixes: QTCREATORBUG-23745
Reviewed-by: Alexis Murzeau <amubtdx@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-03-25 09:13:59 +00:00
Eike Ziller
d0589d7f6e Highlighter: Fix typo
Change-Id: I491f7c58733a333a5cdcf2ebae67f9d4bff1eeef
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-03-24 12:49:43 +00:00
Eike Ziller
ba4a604d68 Editors: Fix top/bottom split with cursor visible at end of document
It did not center on the text cursor.

- Fix lastVisibleBlockNumber() to return the last block if the editor is
scrolled to the bottom (and there potentially is no block located at the
very bottom edge of the editor widget).
- Fix comparison of block numbers (0-based) with line numbers (1-based)

Change-Id: I21405443bea3533e393a7cf320ded6d47f647949
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-03-16 14:48:36 +00:00
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