PlainTextEditor: Use info suppression for syntax highlighting

Remove specific setting for warning suppression and use the global one

Change-Id: I1fe2b749d960283b8414cc5db5a5a7e9f20e7740
Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
Orgad Shaneh
2012-11-13 23:19:26 +02:00
committed by Orgad Shaneh
parent 28b9f0f3d6
commit 384b024c2e
9 changed files with 13 additions and 67 deletions

View File

@@ -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<PlainTextEditor *>(editor);
@@ -92,25 +96,18 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
return;
PlainTextEditorWidget *textEditor = static_cast<PlainTextEditorWidget *>(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);
}
}