aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor
diff options
context:
space:
mode:
authorArtem Sokolovskii <artem.sokolovskii@qt.io>2024-01-03 14:56:54 +0100
committerhjk <hjk@qt.io>2024-01-26 09:19:25 +0000
commite1f7469afb32efa51d665c9211767b214cd93573 (patch)
tree2b37fe4a75fe7ade15d3362e3bc74bf2a84c185c /src/plugins/texteditor
parent78a909390cc7f3617aa03633691c1987c4895a5b (diff)
ClangFormat: Replace checks widget with editor
The existing approach utilizing the widget poses maintenance challenges, primarily due to the dynamic nature of clang-format settings across versions. The widget necessitates regeneration for each new version, and compatibility issues arise when users have different clang-format versions on their devices. The updated solution adopts an Editor integrated with a yaml language server, offering the ability to highlight and provide code completion for the .clang-format file. This resolves the widget regeneration issue and ensures compatibility with various clang-format versions. - Replaced the checks widget with an editor - Introduced a line for yaml language server schema in .clang-format files to enable autocompletion. ToDo: Enhance schema accessibility without relying on this line. - Added Ctrl+Space shortcut for autocompletion - Added Ctrl+S shortcut for saving - Eliminated outdated logic related to the checks widget - Fixed copying and removal of clang-format settings Change-Id: I2e3fbf19abe2f4df031f6ba5faffd47e07274346 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r--src/plugins/texteditor/codestyleselectorwidget.cpp1
-rw-r--r--src/plugins/texteditor/icodestylepreferences.cpp2
-rw-r--r--src/plugins/texteditor/icodestylepreferences.h3
-rw-r--r--src/plugins/texteditor/textdocument.cpp2
4 files changed, 8 insertions, 0 deletions
diff --git a/src/plugins/texteditor/codestyleselectorwidget.cpp b/src/plugins/texteditor/codestyleselectorwidget.cpp
index a219be271a..ddeea0a74e 100644
--- a/src/plugins/texteditor/codestyleselectorwidget.cpp
+++ b/src/plugins/texteditor/codestyleselectorwidget.cpp
@@ -165,6 +165,7 @@ void CodeStyleSelectorWidget::slotCopyClicked()
ICodeStylePreferences *copy = codeStylePool->cloneCodeStyle(currentPreferences);
if (copy) {
copy->setDisplayName(newName);
+ emit m_codeStyle->aboutToBeCopied(currentPreferences, copy);
m_codeStyle->setCurrentDelegate(copy);
}
}
diff --git a/src/plugins/texteditor/icodestylepreferences.cpp b/src/plugins/texteditor/icodestylepreferences.cpp
index d7547d430e..82a478e697 100644
--- a/src/plugins/texteditor/icodestylepreferences.cpp
+++ b/src/plugins/texteditor/icodestylepreferences.cpp
@@ -241,6 +241,8 @@ void ICodeStylePreferences::fromMap(const Store &map)
void ICodeStylePreferences::codeStyleRemoved(ICodeStylePreferences *preferences)
{
if (currentDelegate() == preferences) {
+ emit aboutToBeRemoved(preferences);
+
CodeStylePool *pool = delegatingPool();
QList<ICodeStylePreferences *> codeStyles = pool->codeStyles();
const int idx = codeStyles.indexOf(preferences);
diff --git a/src/plugins/texteditor/icodestylepreferences.h b/src/plugins/texteditor/icodestylepreferences.h
index 7239411b5c..451ac669cc 100644
--- a/src/plugins/texteditor/icodestylepreferences.h
+++ b/src/plugins/texteditor/icodestylepreferences.h
@@ -80,6 +80,9 @@ signals:
void currentDelegateChanged(TextEditor::ICodeStylePreferences *currentDelegate);
void currentPreferencesChanged(TextEditor::ICodeStylePreferences *currentPreferences);
void displayNameChanged(const QString &newName);
+ void aboutToBeRemoved(TextEditor::ICodeStylePreferences *preferences);
+ void aboutToBeCopied(TextEditor::ICodeStylePreferences *current,
+ TextEditor::ICodeStylePreferences *target);
private:
void codeStyleRemoved(ICodeStylePreferences *preferences);
diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp
index 025720a9d3..5ea17e1097 100644
--- a/src/plugins/texteditor/textdocument.cpp
+++ b/src/plugins/texteditor/textdocument.cpp
@@ -292,6 +292,8 @@ TextDocument *TextDocument::currentTextDocument()
TextDocument *TextDocument::textDocumentForFilePath(const Utils::FilePath &filePath)
{
+ if (filePath.isEmpty())
+ return nullptr;
return qobject_cast<TextDocument *>(DocumentModel::documentForFilePath(filePath));
}