From 8d48b3a03e2a01e68bba06a3a0c66f97cb552cf0 Mon Sep 17 00:00:00 2001
From: Leandro Melo <leandro.melo@nokia.com>
Date: Mon, 11 Oct 2010 12:40:09 +0200
Subject: [PATCH] Generic highlighter: Don't nag about the missing definition
 if info bar was once closed.

Reviewed-by: con
---
 .../texteditor/generichighlighter/manager.cpp |  6 ------
 .../texteditor/generichighlighter/manager.h   |  1 -
 src/plugins/texteditor/plaintexteditor.cpp    | 19 ++++++++++++++++++-
 src/plugins/texteditor/plaintexteditor.h      |  4 ++++
 .../texteditor/plaintexteditorfactory.cpp     |  6 ++++--
 5 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/src/plugins/texteditor/generichighlighter/manager.cpp b/src/plugins/texteditor/generichighlighter/manager.cpp
index a0c03556ae3..09a1a49ddae 100644
--- a/src/plugins/texteditor/generichighlighter/manager.cpp
+++ b/src/plugins/texteditor/generichighlighter/manager.cpp
@@ -410,12 +410,6 @@ bool Manager::isDownloadingDefinitions() const
     return m_downloadingDefinitions;
 }
 
-void Manager::showGenericHighlighterOptions() const
-{
-    Core::ICore::instance()->showOptionsDialog(Constants::TEXT_EDITOR_SETTINGS_CATEGORY,
-                                               Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS);
-}
-
 void Manager::clear()
 {
     m_idByName.clear();
diff --git a/src/plugins/texteditor/generichighlighter/manager.h b/src/plugins/texteditor/generichighlighter/manager.h
index a880f056f9f..8ed80100b78 100644
--- a/src/plugins/texteditor/generichighlighter/manager.h
+++ b/src/plugins/texteditor/generichighlighter/manager.h
@@ -82,7 +82,6 @@ public:
 
 public slots:
     void registerMimeTypes();
-    void showGenericHighlighterOptions() const;
 
 private slots:
     void registerMimeType(int index) const;
diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp
index 81b30c9e322..5d169aae71d 100644
--- a/src/plugins/texteditor/plaintexteditor.cpp
+++ b/src/plugins/texteditor/plaintexteditor.cpp
@@ -62,7 +62,8 @@ PlainTextEditorEditable::PlainTextEditorEditable(PlainTextEditor *editor)
 
 PlainTextEditor::PlainTextEditor(QWidget *parent)
   : BaseTextEditor(parent),
-  m_isMissingSyntaxDefinition(false)
+  m_isMissingSyntaxDefinition(false),
+  m_ignoreMissingSyntaxDefinition(false)
 {
     setRevisionsVisible(true);
     setMarksVisible(true);
@@ -225,6 +226,11 @@ bool PlainTextEditor::isMissingSyntaxDefinition() const
     return m_isMissingSyntaxDefinition;
 }
 
+bool PlainTextEditor::ignoreMissingSyntaxDefinition() const
+{
+    return m_ignoreMissingSyntaxDefinition;
+}
+
 QString PlainTextEditor::findDefinitionId(const Core::MimeType &mimeType,
                                           bool considerParents) const
 {
@@ -246,3 +252,14 @@ void PlainTextEditor::indentBlock(QTextDocument *doc, QTextBlock block, QChar ty
 {
     m_indenter->indentBlock(doc, block, typedChar, tabSettings());
 }
+
+void PlainTextEditor::acceptMissingSyntaxDefinitionInfo()
+{
+    Core::ICore::instance()->showOptionsDialog(Constants::TEXT_EDITOR_SETTINGS_CATEGORY,
+                                               Constants::TEXT_EDITOR_HIGHLIGHTER_SETTINGS);
+}
+
+void PlainTextEditor::ignoreMissingSyntaxDefinitionInfo()
+{
+    m_ignoreMissingSyntaxDefinition = true;
+}
diff --git a/src/plugins/texteditor/plaintexteditor.h b/src/plugins/texteditor/plaintexteditor.h
index 2d8a2309ccc..7d7917ff9f3 100644
--- a/src/plugins/texteditor/plaintexteditor.h
+++ b/src/plugins/texteditor/plaintexteditor.h
@@ -72,6 +72,7 @@ public:
 
     void configure(const Core::MimeType &mimeType);
     bool isMissingSyntaxDefinition() const;
+    bool ignoreMissingSyntaxDefinition() const;
 
 public slots:
     virtual void unCommentSelection();
@@ -80,6 +81,8 @@ public slots:
 
 private slots:
     void configure();
+    void acceptMissingSyntaxDefinitionInfo();
+    void ignoreMissingSyntaxDefinitionInfo();
 
 signals:
     void configured(Core::IEditor *editor);
@@ -92,6 +95,7 @@ private:
     QString findDefinitionId(const Core::MimeType &mimeType, bool considerParents) const;
 
     bool m_isMissingSyntaxDefinition;
+    bool m_ignoreMissingSyntaxDefinition;
     Utils::CommentDefinition m_commentDefinition;
     QScopedPointer<Indenter> m_indenter;
 };
diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp
index a26f3bd2df9..d45014a61f3 100644
--- a/src/plugins/texteditor/plaintexteditorfactory.cpp
+++ b/src/plugins/texteditor/plaintexteditorfactory.cpp
@@ -94,14 +94,16 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
     if (editorEditable) {
         PlainTextEditor *textEditor = static_cast<PlainTextEditor *>(editorEditable->editor());
         if (textEditor->isMissingSyntaxDefinition() &&
+            !textEditor->ignoreMissingSyntaxDefinition() &&
             TextEditorSettings::instance()->highlighterSettings().alertWhenNoDefinition()) {
             Core::EditorManager::instance()->showEditorInfoBar(
                 Constants::INFO_SYNTAX_DEFINITION,
                 tr("A highlight definition was not found for this file. "
                    "Would you like to try to find one?"),
                 tr("Show highlighter options"),
-                Manager::instance(),
-                SLOT(showGenericHighlighterOptions()));
+                textEditor,
+                SLOT(acceptMissingSyntaxDefinitionInfo()),
+                SLOT(ignoreMissingSyntaxDefinitionInfo()));
             return;
         }
     }
-- 
GitLab