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 <leandro.melo@nokia.com>
This commit is contained in:
Oswald Buddenhagen
2011-05-20 11:27:07 +02:00
committed by Leandro T. C. Melo
parent 0bf18d008b
commit 61afe9d365
3 changed files with 27 additions and 2 deletions

View File

@@ -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<PlainTextEditor *>(editor);
if (editorEditable) {
BaseTextDocument *file = qobject_cast<BaseTextDocument *>(editor->file());
if (!file)
return;
PlainTextEditorWidget *textEditor = static_cast<PlainTextEditorWidget *>(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);
}
}