diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index 5a8603271df..79e85f09ec6 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -74,8 +74,6 @@ public: SyntaxHighlighter *m_highlighter; bool m_fileIsReadOnly; - bool m_hasHighlightWarning; - int m_autoSaveRevision; }; @@ -83,7 +81,6 @@ BaseTextDocumentPrivate::BaseTextDocumentPrivate(BaseTextDocument *q) : m_document(new QTextDocument(q)), m_highlighter(0), m_fileIsReadOnly(false), - m_hasHighlightWarning(false), m_autoSaveRevision(-1) { } @@ -493,14 +490,4 @@ void BaseTextDocument::ensureFinalNewLine(QTextCursor& cursor) } } -bool BaseTextDocument::hasHighlightWarning() const -{ - return d->m_hasHighlightWarning; -} - -void BaseTextDocument::setHighlightWarning(bool has) -{ - d->m_hasHighlightWarning = has; -} - } // namespace TextEditor diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h index 3b3fe6e1c92..5204da2a674 100644 --- a/src/plugins/texteditor/basetextdocument.h +++ b/src/plugins/texteditor/basetextdocument.h @@ -98,9 +98,6 @@ public: bool reload(QString *errorString, QTextCodec *codec); void cleanWhitespace(const QTextCursor &cursor); - bool hasHighlightWarning() const; - void setHighlightWarning(bool has); - signals: void titleChanged(QString title); diff --git a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp index 86ab65f4fd3..49761b0a5eb 100644 --- a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp +++ b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp @@ -103,7 +103,6 @@ namespace { static const QLatin1String kDefinitionFilesPath("UserDefinitionFilesPath"); static const QLatin1String kFallbackDefinitionFilesPath("FallbackDefinitionFilesPath"); -static const QLatin1String kAlertWhenDefinitionIsNotFound("AlertWhenDefinitionsIsNotFound"); static const QLatin1String kUseFallbackLocation("UseFallbackLocation"); static const QLatin1String kIgnoredFilesPatterns("IgnoredFilesPatterns"); static const QLatin1String kGroupPostfix("HighlighterSettings"); @@ -121,7 +120,7 @@ using namespace TextEditor; using namespace Internal; HighlighterSettings::HighlighterSettings() : - m_alertWhenNoDefinition(true), m_useFallbackLocation(true) + m_useFallbackLocation(true) {} void HighlighterSettings::toSettings(const QString &category, QSettings *s) const @@ -130,7 +129,6 @@ void HighlighterSettings::toSettings(const QString &category, QSettings *s) cons s->beginGroup(group); s->setValue(kDefinitionFilesPath, m_definitionFilesPath); s->setValue(kFallbackDefinitionFilesPath, m_fallbackDefinitionFilesPath); - s->setValue(kAlertWhenDefinitionIsNotFound, m_alertWhenNoDefinition); s->setValue(kUseFallbackLocation, m_useFallbackLocation); s->setValue(kIgnoredFilesPatterns, ignoredFilesPatterns()); s->endGroup(); @@ -155,7 +153,6 @@ void HighlighterSettings::fromSettings(const QString &category, QSettings *s) m_fallbackDefinitionFilesPath = s->value(kFallbackDefinitionFilesPath).toString(); m_useFallbackLocation = s->value(kUseFallbackLocation, true).toBool(); } - m_alertWhenNoDefinition = s->value(kAlertWhenDefinitionIsNotFound, true).toBool(); if (!s->contains(kIgnoredFilesPatterns)) assignDefaultIgnoredPatterns(); else @@ -207,7 +204,6 @@ bool HighlighterSettings::equals(const HighlighterSettings &highlighterSettings) { return m_definitionFilesPath == highlighterSettings.m_definitionFilesPath && m_fallbackDefinitionFilesPath == highlighterSettings.m_fallbackDefinitionFilesPath && - m_alertWhenNoDefinition == highlighterSettings.m_alertWhenNoDefinition && m_useFallbackLocation == highlighterSettings.m_useFallbackLocation && m_ignoredFiles == highlighterSettings.m_ignoredFiles; } diff --git a/src/plugins/texteditor/generichighlighter/highlightersettings.h b/src/plugins/texteditor/generichighlighter/highlightersettings.h index bcf01f78c29..9a2f5bdefee 100644 --- a/src/plugins/texteditor/generichighlighter/highlightersettings.h +++ b/src/plugins/texteditor/generichighlighter/highlightersettings.h @@ -55,9 +55,6 @@ public: void setFallbackDefinitionFilesPath(const QString &path){ m_fallbackDefinitionFilesPath = path;} const QString &fallbackDefinitionFilesPath() const { return m_fallbackDefinitionFilesPath; } - void setAlertWhenNoDefinition(const bool alert) { m_alertWhenNoDefinition = alert; } - bool alertWhenNoDefinition() const { return m_alertWhenNoDefinition; } - void setUseFallbackLocation(const bool use) { m_useFallbackLocation = use; } bool useFallbackLocation() const { return m_useFallbackLocation; } @@ -74,7 +71,6 @@ private: void setExpressionsFromList(const QStringList &patterns); QStringList listFromExpressions() const; - bool m_alertWhenNoDefinition; bool m_useFallbackLocation; QString m_definitionFilesPath; QString m_fallbackDefinitionFilesPath; diff --git a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp index 3f093a78849..49b1f6046b9 100644 --- a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp +++ b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp @@ -106,7 +106,6 @@ QWidget *HighlighterSettingsPage::createPage(QWidget *parent) if (m_d->m_searchKeywords.isEmpty()) { QTextStream(&m_d->m_searchKeywords) << m_d->m_page->definitionFilesGroupBox->title() << m_d->m_page->locationLabel->text() - << m_d->m_page->alertWhenNoDefinition->text() << m_d->m_page->useFallbackLocation->text() << m_d->m_page->ignoreLabel->text(); } @@ -165,7 +164,6 @@ void HighlighterSettingsPage::settingsFromUI() m_d->m_settings.setDefinitionFilesPath(m_d->m_page->definitionFilesPath->path()); m_d->m_settings.setFallbackDefinitionFilesPath(m_d->m_page->fallbackDefinitionFilesPath->path()); - m_d->m_settings.setAlertWhenNoDefinition(m_d->m_page->alertWhenNoDefinition->isChecked()); m_d->m_settings.setUseFallbackLocation(m_d->m_page->useFallbackLocation->isChecked()); m_d->m_settings.setIgnoredFilesPatterns(m_d->m_page->ignoreEdit->text()); m_d->m_settings.toSettings(m_d->m_settingsPrefix, Core::ICore::settings()); @@ -176,7 +174,6 @@ void HighlighterSettingsPage::settingsToUI() m_d->ensureInitialized(); m_d->m_page->definitionFilesPath->setPath(m_d->m_settings.definitionFilesPath()); m_d->m_page->fallbackDefinitionFilesPath->setPath(m_d->m_settings.fallbackDefinitionFilesPath()); - m_d->m_page->alertWhenNoDefinition->setChecked(m_d->m_settings.alertWhenNoDefinition()); m_d->m_page->useFallbackLocation->setChecked(m_d->m_settings.useFallbackLocation()); m_d->m_page->ignoreEdit->setText(m_d->m_settings.ignoredFilesPatterns()); @@ -254,8 +251,6 @@ bool HighlighterSettingsPage::settingsChanged() const if (m_d->m_settings.fallbackDefinitionFilesPath() != m_d->m_page->fallbackDefinitionFilesPath->path()) return true; - if (m_d->m_settings.alertWhenNoDefinition() != m_d->m_page->alertWhenNoDefinition->isChecked()) - return true; if (m_d->m_settings.useFallbackLocation() != m_d->m_page->useFallbackLocation->isChecked()) return true; if (m_d->m_settings.ignoredFilesPatterns() != m_d->m_page->ignoreEdit->text()) diff --git a/src/plugins/texteditor/generichighlighter/highlightersettingspage.ui b/src/plugins/texteditor/generichighlighter/highlightersettingspage.ui index 4e270c068d8..f81412ec7d6 100644 --- a/src/plugins/texteditor/generichighlighter/highlightersettingspage.ui +++ b/src/plugins/texteditor/generichighlighter/highlightersettingspage.ui @@ -106,13 +106,6 @@ Behavior - - - - Alert when a highlight definition is not found - - - @@ -158,7 +151,6 @@ - alertWhenNoDefinition ignoreEdit diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp index 4adb6e8bac6..64770e81c05 100644 --- a/src/plugins/texteditor/plaintexteditor.cpp +++ b/src/plugins/texteditor/plaintexteditor.cpp @@ -65,8 +65,7 @@ PlainTextEditor::PlainTextEditor(PlainTextEditorWidget *editor) PlainTextEditorWidget::PlainTextEditorWidget(QWidget *parent) : BaseTextEditorWidget(parent), - m_isMissingSyntaxDefinition(false), - m_ignoreMissingSyntaxDefinition(false) + m_isMissingSyntaxDefinition(false) { setRevisionsVisible(true); setMarksVisible(true); @@ -196,11 +195,6 @@ bool PlainTextEditorWidget::isMissingSyntaxDefinition() const return m_isMissingSyntaxDefinition; } -bool PlainTextEditorWidget::ignoreMissingSyntaxDefinition() const -{ - return m_ignoreMissingSyntaxDefinition; -} - QString PlainTextEditorWidget::findDefinitionId(const Core::MimeType &mimeType, bool considerParents) const { @@ -224,9 +218,4 @@ void PlainTextEditorWidget::acceptMissingSyntaxDefinitionInfo() Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS); } -void PlainTextEditorWidget::ignoreMissingSyntaxDefinitionInfo() -{ - m_ignoreMissingSyntaxDefinition = true; -} - } // namespace TextEditor diff --git a/src/plugins/texteditor/plaintexteditor.h b/src/plugins/texteditor/plaintexteditor.h index ac4c53ccfe0..624708f878e 100644 --- a/src/plugins/texteditor/plaintexteditor.h +++ b/src/plugins/texteditor/plaintexteditor.h @@ -65,7 +65,6 @@ public: void configure(const QString& mimeType); void configure(const Core::MimeType &mimeType); bool isMissingSyntaxDefinition() const; - bool ignoreMissingSyntaxDefinition() const; public slots: virtual void unCommentSelection(); @@ -75,7 +74,6 @@ public slots: private slots: void configure(); void acceptMissingSyntaxDefinitionInfo(); - void ignoreMissingSyntaxDefinitionInfo(); signals: void configured(Core::IEditor *editor); @@ -87,7 +85,6 @@ private: QString findDefinitionId(const Core::MimeType &mimeType, bool considerParents) const; bool m_isMissingSyntaxDefinition; - bool m_ignoreMissingSyntaxDefinition; Utils::CommentDefinition m_commentDefinition; }; diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index 32d73f64dfa..ce71a05d5c4 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -83,6 +83,10 @@ Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent) return rc->editor(); } +/*! + * Test if syntax highlighter is available (or unneeded) for \a editor. + * If not found, show a warning with a link to the relevant settings page. + */ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor) { PlainTextEditor *editorEditable = qobject_cast(editor); @@ -92,25 +96,18 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor) return; PlainTextEditorWidget *textEditor = static_cast(editorEditable->editorWidget()); Core::Id infoSyntaxDefinition(Constants::INFO_SYNTAX_DEFINITION); - if (textEditor->isMissingSyntaxDefinition() && - !textEditor->ignoreMissingSyntaxDefinition() && - TextEditorSettings::instance()->highlighterSettings().alertWhenNoDefinition()) { - if (file->hasHighlightWarning()) - return; + Core::InfoBar *infoBar = file->infoBar(); + if (!textEditor->isMissingSyntaxDefinition()) { + infoBar->removeInfo(infoSyntaxDefinition); + } else if (infoBar->canInfoBeAdded(infoSyntaxDefinition)) { Core::InfoBarEntry info(infoSyntaxDefinition, tr("A highlight definition was not found for this file. " - "Would you like to try to find one?")); + "Would you like to try to find one?"), + Core::InfoBarEntry::GlobalSuppressionEnabled); info.setCustomButtonInfo(tr("Show highlighter options..."), textEditor, SLOT(acceptMissingSyntaxDefinitionInfo())); - info.setCancelButtonInfo(textEditor, SLOT(ignoreMissingSyntaxDefinitionInfo())); - file->infoBar()->addInfo(info); - file->setHighlightWarning(true); - return; + infoBar->addInfo(info); } - if (!file->hasHighlightWarning()) - return; - file->infoBar()->removeInfo(infoSyntaxDefinition); - file->setHighlightWarning(false); } }