forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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();
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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();
|
||||
});
|
||||
|
@@ -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>
|
||||
|
@@ -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();
|
||||
});
|
||||
|
Reference in New Issue
Block a user