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:
Oswald Buddenhagen
2011-05-06 12:48:44 +02:00
parent 46c09e77cd
commit 882e34ee28
21 changed files with 446 additions and 217 deletions

View File

@@ -41,6 +41,7 @@
#include <extensionsystem/pluginspec.h>
#include <coreplugin/icore.h>
#include <coreplugin/infobar.h>
#include <coreplugin/editormanager/editormanager.h>
#include <QtCore/QFileInfo>
@@ -121,16 +122,15 @@ Core::IFile *QmlJSEditorFactory::open(const QString &fileName)
Core::IEditor *QmlJSEditorFactory::createEditor(QWidget *parent)
{
static bool listenerInitialized = false;
if (!listenerInitialized) {
listenerInitialized = true;
if (isNaggingAboutExperimentalDesignerEnabled()) {
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
SLOT(updateEditorInfoBar(Core::IEditor*)));
}
}
QmlJSEditor::QmlJSTextEditorWidget *rc = new QmlJSEditor::QmlJSTextEditorWidget(parent);
QmlJSEditorPlugin::instance()->initializeEditor(rc);
if (isNaggingAboutExperimentalDesignerEnabled()) {
Core::InfoBarEntry info(QMLDESIGNER_INFO_BAR,
tr("Do you want to enable the experimental Qt Quick Designer?"));
info.setCustomButtonInfo(tr("Enable Qt Quick Designer"), this, SLOT(activateQmlDesigner()));
info.setCancelButtonInfo(this, SLOT(neverAskAgainAboutQmlDesigner()));
rc->file()->infoBar()->addInfo(info);
}
return rc->editor();
}
@@ -139,19 +139,6 @@ QStringList QmlJSEditorFactory::mimeTypes() const
return m_mimeTypes;
}
void QmlJSEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
{
if (qobject_cast<QmlJSEditorEditable *>(editor)) {
Core::EditorManager::instance()->showEditorInfoBar(QMLDESIGNER_INFO_BAR,
tr("Do you want to enable the experimental Qt Quick Designer?"),
tr("Enable Qt Quick Designer"), this,
SLOT(activateQmlDesigner()),
SLOT(neverAskAgainAboutQmlDesigner()));
} else {
Core::EditorManager::instance()->hideEditorInfoBar(QMLDESIGNER_INFO_BAR);
}
}
void QmlJSEditorFactory::activateQmlDesigner()
{
QString menu;
@@ -178,9 +165,9 @@ void QmlJSEditorFactory::activateQmlDesigner()
pm->writeSettings();
QMessageBox::information(Core::ICore::instance()->mainWindow(), tr("Please restart Qt Creator"),
tr("Please restart Qt Creator to make the change effective."));
disconnect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(updateEditorInfoBar(Core::IEditor*)));
Core::EditorManager::instance()->hideEditorInfoBar(QMLDESIGNER_INFO_BAR);
foreach (Core::IEditor *editor, Core::EditorManager::instance()->openedEditors())
if (qobject_cast<QmlJSEditorEditable *>(editor))
editor->file()->infoBar()->removeInfo(QMLDESIGNER_INFO_BAR);
neverAskAgainAboutQmlDesigner();
return;
}