Brought back checkboxes: format while typing, format on save.
Brought back format while typing feature.
Global checkboxes will be hidden in project settings,
and visible for global.
Change-Id: I193cf9e13b10de22091edb5fe04aef957dd74586
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
- Added a possibility to disable ClangFormat plugin
- Removed unneeded properties from clangformatsettings
Change-Id: If71f46670e4fd3d2dac6d18c97df5a811504ed5e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Override checkbox allows use clangFormat settings
from widget even if there is .clang-format file in
file's folder or parent folder.
It works for global settings and for project settings.
Change-Id: I03152f4b0e1b62b3ac038024e76cc9082fa37ec3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
- Indenter uses .clang-format file from a dir of
editing file or from a parent dir. If there is no
such file then indenter starts to use file from a dir
with the name current CodeStyle settings.
- Test fixed
ToDo: Add file absentness processing in case of import
Change-Id: If09ef0c598899856b948c214e524bcfd5dad76e2
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Now there are changeable and unchangeable settings,
as it works for usual codestyle settings.
They save parallel with codestyle settings but in another dir.
In general, the behavior became similar to usual codestyle settings.
ToDo: Make indenter use this settings instead standard one and
instead project settings when "override" checkbox is checked.
Change-Id: I639dbda296932bf9b967a11f1cc4fda120415ed9
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
- Fixed behavior "Formatting mode" combobox settings isn't
saved after pressing "Ok" button when no one project is
open. Now it works as expected, settings save after press
"Ok" button.
- Added additional applying interface for ICodeStylePreferenceFactory
which allows pass-through apply call from dialog to the editor.
Note: it doesn't work with read-only code style profiles
Change-Id: If4f0c85e3105550db4ffd9860e94b678f0d9b386
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Added synchronization between ClangFormat codestyle settings and
CppEditors codestyle settings. All changes which will be done in
ClangFormat settings tab settings tabs will be automatically
retranslated to CppEditor codestyle settings tabs and vice versa.
Change-Id: I408d726c12552856e3c1b72d3ba09b77fff83321
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
- Fixed behavior when saved data from file doesn't load
in the first opening of the code style options
Change-Id: I1c72845cbf8119f9eb402a2f40bcc816c5590c25
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
- Move logic work with clang-format file to
additional class to make clangformatconfigwidget
responsible only for work with ui elements.
- Fix functionality: when new BasedOnStyle was
chosen all fields were empty or set in default,
now it fills with the corresponding value.
Change-Id: I2ee42a502e87da761274d293a7f0a38fda98804d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
There was no proper separation of responsibilities between these
plugins. In particular, CppTools had lots of editor-related
functionality, so it's not clear why it was separated out in the first
place.
In fact, for a lot of code, it seemed quite arbitrary where it was put
(just one example: switchHeaderSource() was in CppTools, wheras
switchDeclarationDefinition() was in CppEditor).
Merging the plugins will enable us to get rid of various convoluted
pseudo-abstractions that were only introduced to keep up the artificial
separation.
Change-Id: Iafc3bce625b4794f6d4aa03df6cddc7f2d26716a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Saves some code on the user side.
Change-Id: I32cd220b6e533f5497a1865f9c34ab9db4cfda79
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.
Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Qt 6 API will move away from it.
Use QVector for API and some std container for internal things.
Change-Id: Iff14d48a47d5ac52ade875d9c8c84ad8a4f577d8
Reviewed-by: hjk <hjk@qt.io>
Do not allow ClangFormat plugin to format on file save
when the Beautifier has the same checkbox selected.
Change-Id: I655d77a888cc444ccb02c4e72f11a93b3ab9bbd5
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Initialize them only once and only show/hide widgets later on.
Change-Id: I5ebad504709e34aeb6ce5bf1ead7d8e2ee0b2056
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
- 'Default' values remain so after save/load
- the language is fixed to C++
- the project settings are shown correctly
- fix parsing configuration file
- do not trigger slots when we fill the table
Change-Id: I91b477721b5084803324cd38d0cfeb9d5650dd9f
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Use QComboBox, QLineEdit and QPlainTextEdit to edit
different option types.
Show changes in the preview without pressing 'Apply' button.
The clangformatchecks.ui file is generated with the python
script that is a part of this commit.
Change-Id: If5ff0acab6edd74f2e087e31fbd3ad1b9f847030
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This is the first step without strings change.
The next step is I201dbccb8b1f1738451f760af34cf588afb5f4d5.
Change-Id: Ic0ce6a5ab3e74303a71a7c0bd8188d0284a241eb
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
The call to show() was lost at some point, let's restore it.
Change-Id: I83f551d26e6c4f658426b1196ff3a0935aea7047
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Let's use by default the configuration that clang-format picks itself
for the source file. The Qt Creator configuration will now only
override the default one with global or project settings and can be
turned off with the checkbox.
This behavior is clearer than always picking some configuration
which Qt Creator prefers best.
Change-Id: If5ed3d67eb6b4b47a6d0fd5259f7efbb608914d1
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Include it only where used.
Resolves many "unused static variable" warnings.
Change-Id: Ie1e578d9b9511f963e359d87f7740b4981975dbd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Allows the user to see how the current style applies to
the code snippet. The action is triggered by the 'Apply' button.
Change-Id: I820d989519cfdfb6e617ed6e8e9e5751be6619ea
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Do not save the configuration which contains errors.
Change-Id: I050b22f7e589e5c39909fe1f611e56ead03d49ee
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
The similar implementation to the one in Beautifier plugin
with the difference that the clangformat indenter logic is used
and only modified chunks are formatted.
That means that all code which was not touched will stay in the
initial condition.
Change-Id: I47b11eb99852454ed0031ef6cfc6dbed1ecd390d
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
With the extra option "Format while typing" checked try to format
text before the current position without breaking the current input.
To accomplish that we make proper choices which replacements to apply.
The advantage of this change is to decrease the need to manually
format code which is just written.
Some minor bugs are fixed during the testing of this change.
Change-Id: Ibed569042e6c46a881e7a83b1882cf2bb23b3626
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Ctrl+I with the new check will reformat the selected code or
the current line instead.
Change-Id: Ia5a72c4a09621034d0dfe463f669fe1ca36b0b5f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
The actual apply() method was never called for the widget.
Change-Id: Idff194a36591db437cbe5695377005ed5a0b25d4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
It makes sense to unify the indenter creation by replacing
the CppCodeStylePreferencesFactory instead of removing it.
We are reusing the same options page but with different
kind of settings.
With this change wizards will no more be confused by missing
factory and will create the proper indenter.
Fixes: QTCREATORBUG-21516
Change-Id: I38964d5fa1f2257617c66a1441db723d239a3237
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Existing Clang Format settings may not follow the
project/global pattern but can be expected to be used
for the indentation/formatting.
So let's proceed with UI for global/project settings
but use global settings only if there's no configuration
found for the current file.
Change-Id: I87c25ab3feb7e2e3deb0290848088657783cf972
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
It is unlikely that this name changes but let's follow good
coding practices.
Change-Id: I12adbf155f26b1b3a02d07092fcc113e0c5157e6
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
And remove UI for default code style settings because
it does not affect anything when ClangFormat plugin is
enabled.
Change-Id: Ie348b7d2691b09ea2b4868da987f2a27347ea0f3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
What's new:
1. New LibFormat option is used to prevent lines shrink,
which allows to drop most of tricks used before for that purpose.
2. Cached UTF-8 source code is used to improve performance
3. Improved error handling.
4. Slightly improved UI.
Change-Id: I4605200fa103167369a40650b2e1ad2c61e8133b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This is the new experimental plugin based on LibFormat.
It replaces the default indenter for CppEditorDocument
and applies clang-format after the CR or the set of 'electric'
characters.
Uses the global .clang-format kept in QtC settings or
the one for current project. Both can be configured.
For indentation some style modifications and code manipulations
are done to prevent line shrinking when it's not expected.
Manual indentation uses unmodified style from .clang-format file.
Change-Id: I6279b805e418e1804b553efa615f5c843f395a58
Reviewed-by: Marco Bubke <marco.bubke@qt.io>