forked from qt-creator/qt-creator
rewrite editor info bar handling
the info about the bars is now stored in the IFile, not in the EditorView. this is somewhat more expensive for the bars which identically apply to all editors of one type, but fixes consistency issues between views. additionally, it is now possible to set several simultaneous info bars per file, which ensures that no information is lost. Co-authored-by: mae
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/infobar.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
@@ -56,9 +57,6 @@ PlainTextEditorFactory::PlainTextEditorFactory(QObject *parent)
|
||||
TextEditorActionHandler::UnCommentSelection |
|
||||
TextEditorActionHandler::UnCollapseAll);
|
||||
m_mimeTypes << QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT);
|
||||
|
||||
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
|
||||
this, SLOT(updateEditorInfoBar(Core::IEditor*)));
|
||||
}
|
||||
|
||||
PlainTextEditorFactory::~PlainTextEditorFactory()
|
||||
@@ -88,6 +86,7 @@ Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent)
|
||||
TextEditorPlugin::instance()->initializeEditor(rc);
|
||||
connect(rc, SIGNAL(configured(Core::IEditor*)),
|
||||
this, SLOT(updateEditorInfoBar(Core::IEditor*)));
|
||||
updateEditorInfoBar(rc->editor());
|
||||
return rc->editor();
|
||||
}
|
||||
|
||||
@@ -99,18 +98,17 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *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"),
|
||||
textEditor,
|
||||
SLOT(acceptMissingSyntaxDefinitionInfo()),
|
||||
SLOT(ignoreMissingSyntaxDefinitionInfo()));
|
||||
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);
|
||||
return;
|
||||
}
|
||||
editor->file()->infoBar()->removeInfo(Constants::INFO_SYNTAX_DEFINITION);
|
||||
}
|
||||
Core::EditorManager::instance()->hideEditorInfoBar(Constants::INFO_SYNTAX_DEFINITION);
|
||||
}
|
||||
|
||||
void PlainTextEditorFactory::addMimeType(const QString &type)
|
||||
|
Reference in New Issue
Block a user