summaryrefslogtreecommitdiff
path: root/src/plugins/designer
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-05-06 12:48:44 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2011-05-12 20:10:02 +0200
commit882e34ee284731f9edb3a89c23fb7a0897c8da3a (patch)
treeeb7e4018f1acc36b03ae071e0c435eb56dd064f6 /src/plugins/designer
parent46c09e77cd73cfb54ef328799a287bf37191fc01 (diff)
downloadqt-creator-882e34ee284731f9edb3a89c23fb7a0897c8da3a.tar.gz
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
Diffstat (limited to 'src/plugins/designer')
-rw-r--r--src/plugins/designer/formeditorfactory.cpp24
-rw-r--r--src/plugins/designer/formeditorfactory.h1
2 files changed, 10 insertions, 15 deletions
diff --git a/src/plugins/designer/formeditorfactory.cpp b/src/plugins/designer/formeditorfactory.cpp
index c023a1830b..6d5c5b97fc 100644
--- a/src/plugins/designer/formeditorfactory.cpp
+++ b/src/plugins/designer/formeditorfactory.cpp
@@ -39,6 +39,7 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
+#include <coreplugin/infobar.h>
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/modemanager.h>
@@ -58,8 +59,6 @@ FormEditorFactory::FormEditorFactory()
Core::FileIconProvider *iconProvider = Core::FileIconProvider::instance();
iconProvider->registerIconOverlayForSuffix(QIcon(QLatin1String(":/formeditor/images/qt_ui.png")),
QLatin1String("ui"));
- connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
- SLOT(updateEditorInfoBar(Core::IEditor*)));
}
QString FormEditorFactory::id() const
@@ -75,7 +74,15 @@ QString FormEditorFactory::displayName() const
Core::IFile *FormEditorFactory::open(const QString &fileName)
{
Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id());
- return iface ? iface->file() : 0;
+ if (!iface)
+ return 0;
+ if (qobject_cast<FormWindowEditor *>(iface)) {
+ Core::InfoBarEntry info(Constants::INFO_READ_ONLY,
+ tr("This file can only be edited in <b>Design</b> mode."));
+ info.setCustomButtonInfo(tr("Switch mode"), this, SLOT(designerModeClicked()));
+ iface->file()->infoBar()->addInfo(info);
+ }
+ return iface->file();
}
Core::IEditor *FormEditorFactory::createEditor(QWidget *parent)
@@ -89,17 +96,6 @@ QStringList FormEditorFactory::mimeTypes() const
return m_mimeTypes;
}
-void FormEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
-{
- if (qobject_cast<FormWindowEditor *>(editor)) {
- Core::EditorManager::instance()->showEditorInfoBar(Constants::INFO_READ_ONLY,
- tr("This file can only be edited in <b>Design</b> mode."),
- tr("Switch mode"), this, SLOT(designerModeClicked()));
- } else {
- Core::EditorManager::instance()->hideEditorInfoBar(Constants::INFO_READ_ONLY);
- }
-}
-
void FormEditorFactory::designerModeClicked()
{
Core::ICore::instance()->modeManager()->activateMode(QLatin1String(Core::Constants::MODE_DESIGN));
diff --git a/src/plugins/designer/formeditorfactory.h b/src/plugins/designer/formeditorfactory.h
index 1ade6519ee..6141e3ab9a 100644
--- a/src/plugins/designer/formeditorfactory.h
+++ b/src/plugins/designer/formeditorfactory.h
@@ -61,7 +61,6 @@ public:
private slots:
void designerModeClicked();
- void updateEditorInfoBar(Core::IEditor *editor);
private:
const QStringList m_mimeTypes;