Commit 61afe9d3 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen Committed by Leandro T. C. Melo

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/32Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
parent 0bf18d00
......@@ -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"
......@@ -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);
......
......@@ -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);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment