From 61afe9d36582665822baefe2c87f5975e05036da Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 20 May 2011 11:27:07 +0200 Subject: [PATCH] don't stack up "no highlighting information" info bars don't try to add another bar one if there is one already Task-number: QTCREATORBUG-4951 Change-Id: Ia7282a5ee96d3b6b08b3f66c3bc162b1c4a5a015 Reviewed-on: http://codereview.qt.nokia.com/32 Reviewed-by: Leandro T. C. Melo --- src/plugins/texteditor/basetextdocument.cpp | 12 ++++++++++++ src/plugins/texteditor/basetextdocument.h | 3 +++ src/plugins/texteditor/plaintexteditorfactory.cpp | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index 7c5b599138..df0e64a956 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -228,6 +228,7 @@ public: bool m_fileIsReadOnly; bool m_hasDecodingError; + bool m_hasHighlightWarning; QByteArray m_decodingErrorSample; static const int kChunkSize; @@ -245,6 +246,7 @@ BaseTextDocumentPrivate::BaseTextDocumentPrivate(BaseTextDocument *q) : m_fileHasUtf8Bom(false), m_fileIsReadOnly(false), m_hasDecodingError(false), + m_hasHighlightWarning(false), m_autoSaveRevision(-1) { } @@ -716,6 +718,16 @@ void BaseTextDocument::documentClosing() } } +bool BaseTextDocument::hasHighlightWarning() const +{ + return d->m_hasHighlightWarning; +} + +void BaseTextDocument::setHighlightWarning(bool has) +{ + d->m_hasHighlightWarning = has; +} + } // namespace TextEditor #include "basetextdocument.moc" diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h index 481baae76c..22d6e92fff 100644 --- a/src/plugins/texteditor/basetextdocument.h +++ b/src/plugins/texteditor/basetextdocument.h @@ -103,6 +103,9 @@ 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/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index accf655425..9ee3160bd0 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -32,6 +32,7 @@ #include "plaintexteditor.h" #include "plaintexteditorfactory.h" +#include "basetextdocument.h" #include "texteditorconstants.h" #include "texteditorplugin.h" #include "texteditoractionhandler.h" @@ -94,20 +95,29 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor) { PlainTextEditor *editorEditable = qobject_cast(editor); if (editorEditable) { + BaseTextDocument *file = qobject_cast(editor->file()); + if (!file) + return; PlainTextEditorWidget *textEditor = static_cast(editorEditable->editorWidget()); if (textEditor->isMissingSyntaxDefinition() && !textEditor->ignoreMissingSyntaxDefinition() && TextEditorSettings::instance()->highlighterSettings().alertWhenNoDefinition()) { + if (file->hasHighlightWarning()) + return; Core::InfoBarEntry info(Constants::INFO_SYNTAX_DEFINITION, tr("A highlight definition was not found for this file. " "Would you like to try to find one?")); info.setCustomButtonInfo(tr("Show highlighter options"), textEditor, SLOT(acceptMissingSyntaxDefinitionInfo())); info.setCancelButtonInfo(textEditor, SLOT(ignoreMissingSyntaxDefinitionInfo())); - editor->file()->infoBar()->addInfo(info); + file->infoBar()->addInfo(info); + file->setHighlightWarning(true); return; } - editor->file()->infoBar()->removeInfo(Constants::INFO_SYNTAX_DEFINITION); + if (!file->hasHighlightWarning()) + return; + file->infoBar()->removeInfo(Constants::INFO_SYNTAX_DEFINITION); + file->setHighlightWarning(false); } } -- 2.11.0