diff options
author | David Schulz <david.schulz@qt.io> | 2019-11-04 10:03:27 +0100 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2019-11-04 13:23:58 +0000 |
commit | 5ece12d4ea9291f1063b9c7ec71fb9764537cfdb (patch) | |
tree | e4a021e02dd1cd239aaabe54c7d41d0d18bc2734 | |
parent | 9a567a48dd0ddc555ca1f614b0b1c87f54b37029 (diff) | |
download | qt-creator-5ece12d4ea9291f1063b9c7ec71fb9764537cfdb.tar.gz |
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>
-rw-r--r-- | src/plugins/texteditor/highlighter.cpp | 15 | ||||
-rw-r--r-- | src/plugins/texteditor/highlighter.h | 3 | ||||
-rw-r--r-- | src/plugins/texteditor/highlightersettingspage.cpp | 9 | ||||
-rw-r--r-- | src/plugins/texteditor/highlightersettingspage.ui | 17 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditor.cpp | 6 |
5 files changed, 40 insertions, 10 deletions
diff --git a/src/plugins/texteditor/highlighter.cpp b/src/plugins/texteditor/highlighter.cpp index 1a12d96882..09f9b88ff9 100644 --- a/src/plugins/texteditor/highlighter.cpp +++ b/src/plugins/texteditor/highlighter.cpp @@ -29,7 +29,9 @@ #include "textdocumentlayout.h" #include "tabsettings.h" #include "texteditorsettings.h" +#include "texteditor.h" +#include <coreplugin/editormanager/documentmodel.h> #include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> #include <utils/mimetypes/mimedatabase.h> @@ -250,7 +252,7 @@ void Highlighter::addCustomHighlighterPath(const Utils::FilePath &path) highlightRepository()->addCustomSearchPath(path.toString()); } -void Highlighter::updateDefinitions(std::function<void()> callback) { +void Highlighter::downloadDefinitions(std::function<void()> callback) { auto downloader = new KSyntaxHighlighting::DefinitionDownloader(highlightRepository()); connect(downloader, &KSyntaxHighlighting::DefinitionDownloader::done, @@ -271,6 +273,17 @@ void Highlighter::updateDefinitions(std::function<void()> callback) { downloader->start(); } +void Highlighter::reload() +{ + highlightRepository()->reload(); + for (auto editor : Core::DocumentModel::editorsForOpenedDocuments()) { + if (auto textEditor = qobject_cast<BaseTextEditor *>(editor)) { + if (qobject_cast<Highlighter *>(textEditor->textDocument()->syntaxHighlighter())) + textEditor->editorWidget()->configureGenericHighlighter(); + } + } +} + void Highlighter::handleShutdown() { delete highlightRepository(); diff --git a/src/plugins/texteditor/highlighter.h b/src/plugins/texteditor/highlighter.h index e0ddc8132d..0a23009c23 100644 --- a/src/plugins/texteditor/highlighter.h +++ b/src/plugins/texteditor/highlighter.h @@ -58,7 +58,8 @@ public: static void clearDefintionForDocumentCache(); static void addCustomHighlighterPath(const Utils::FilePath &path); - static void updateDefinitions(std::function<void()> callback = nullptr); + static void downloadDefinitions(std::function<void()> callback = nullptr); + static void reload(); static void handleShutdown(); diff --git a/src/plugins/texteditor/highlightersettingspage.cpp b/src/plugins/texteditor/highlightersettingspage.cpp index 86a1a7fdbf..20cfa591ea 100644 --- a/src/plugins/texteditor/highlightersettingspage.cpp +++ b/src/plugins/texteditor/highlightersettingspage.cpp @@ -104,14 +104,17 @@ QWidget *HighlighterSettingsPage::widget() m_d->m_page->setupUi(m_d->m_widget); m_d->m_page->definitionFilesPath->setExpectedKind(Utils::PathChooser::ExistingDirectory); m_d->m_page->definitionFilesPath->setHistoryCompleter(QLatin1String("TextEditor.Highlighter.History")); - connect(m_d->m_page->updateDefinitions, + connect(m_d->m_page->downloadDefinitions, &QPushButton::pressed, [label = QPointer<QLabel>(m_d->m_page->updateStatus)]() { - Highlighter::updateDefinitions([label](){ + Highlighter::downloadDefinitions([label](){ if (label) - label->setText(tr("Update finished")); + label->setText(tr("Download finished")); }); }); + connect(m_d->m_page->reloadDefinitions, &QPushButton::pressed, []() { + Highlighter::reload(); + }); connect(m_d->m_page->resetCache, &QPushButton::clicked, []() { Highlighter::clearDefintionForDocumentCache(); }); diff --git a/src/plugins/texteditor/highlightersettingspage.ui b/src/plugins/texteditor/highlightersettingspage.ui index 7b1e6c9e0d..5bd32a8a87 100644 --- a/src/plugins/texteditor/highlightersettingspage.ui +++ b/src/plugins/texteditor/highlightersettingspage.ui @@ -64,9 +64,12 @@ <item> <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> - <widget class="QPushButton" name="updateDefinitions"> + <widget class="QPushButton" name="downloadDefinitions"> + <property name="toolTip"> + <string>Download missing and update existing syntax definition files.</string> + </property> <property name="text"> - <string>Update Definitions</string> + <string>Download Definitions</string> </property> </widget> </item> @@ -108,6 +111,16 @@ </item> </layout> </item> + <item> + <widget class="QPushButton" name="reloadDefinitions"> + <property name="toolTip"> + <string>Reload externally modified definition files.</string> + </property> + <property name="text"> + <string>Reload Definitions</string> + </property> + </widget> + </item> </layout> </item> <item> diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 1419b045c2..b03cef1de3 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -3100,11 +3100,11 @@ void TextEditorWidgetPrivate::updateSyntaxInfoBar(const Highlighter::Definitions && !TextEditorSettings::highlighterSettings().isIgnoredFilePattern(fileName)) { InfoBarEntry info(missing, BaseTextEditor::tr("A highlight definition was not found for this file. " - "Would you like to update highlight definition files?"), + "Would you like to download additional highlight definition files?"), InfoBarEntry::GlobalSuppression::Enabled); - info.setCustomButtonInfo(BaseTextEditor::tr("Update Definitions"), [missing, this]() { + info.setCustomButtonInfo(BaseTextEditor::tr("Download Definitions"), [missing, this]() { m_document->infoBar()->removeInfo(missing); - Highlighter::updateDefinitions([widget = QPointer<TextEditorWidget>(q)]() { + Highlighter::downloadDefinitions([widget = QPointer<TextEditorWidget>(q)]() { if (widget) widget->configureGenericHighlighter(); }); |