Commit 3124db00 authored by Lasse Holmstedt's avatar Lasse Holmstedt

Refactored toolbar interface

parent a6a04985
...@@ -183,13 +183,11 @@ void EditorToolBar::closeView() ...@@ -183,13 +183,11 @@ void EditorToolBar::closeView()
emit closeClicked(); emit closeClicked();
} }
void EditorToolBar::addEditor(IEditor *editor, ToolbarCreationFlags flags) void EditorToolBar::addEditor(IEditor *editor)
{ {
connect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus())); connect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus()));
QWidget *toolBar = editor->toolBar(); QWidget *toolBar = editor->toolBar();
m_ignoreEditorToolbar = flags & FlagsIgnoreIEditorToolBar;
if (toolBar && !m_ignoreEditorToolbar) if (toolBar && !m_ignoreEditorToolbar)
addCenterToolBar(toolBar); addCenterToolBar(toolBar);
...@@ -215,6 +213,10 @@ void EditorToolBar::updateToolBar(QWidget *toolBar) ...@@ -215,6 +213,10 @@ void EditorToolBar::updateToolBar(QWidget *toolBar)
m_activeToolBar = toolBar; m_activeToolBar = toolBar;
} }
void EditorToolBar::setToolbarCreationFlags(ToolbarCreationFlags flags)
{
m_ignoreEditorToolbar = flags & FlagsIgnoreIEditorToolBar;
}
void EditorToolBar::setCurrentEditor(IEditor *editor) void EditorToolBar::setCurrentEditor(IEditor *editor)
{ {
......
...@@ -61,15 +61,18 @@ public: ...@@ -61,15 +61,18 @@ public:
enum ToolbarCreationFlags { FlagsNone = 0, FlagsIgnoreIEditorToolBar = 1 }; enum ToolbarCreationFlags { FlagsNone = 0, FlagsIgnoreIEditorToolBar = 1 };
/** /**
* Adds an editor to listen to state changes so that the editor can be updated accordingly. * Adds an editor whose state is listened to, so that the toolbar can be kept up to date
* with regards to locked status and tooltips.
*/ */
void addEditor(IEditor *editor, ToolbarCreationFlags flags = FlagsNone); void addEditor(IEditor *editor);
/** /**
* Sets the editor and adds its custom toolbar to the widget. * Sets the editor and adds its custom toolbar to the widget.
*/ */
void setCurrentEditor(IEditor *editor); void setCurrentEditor(IEditor *editor);
void setToolbarCreationFlags(ToolbarCreationFlags flags);
/** /**
* Adds a toolbar to the widget and sets invisible by default. * Adds a toolbar to the widget and sets invisible by default.
*/ */
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "formeditorw.h" #include "formeditorw.h"
#include "formwindoweditor.h" #include "formwindoweditor.h"
#include "designerconstants.h" #include "designerconstants.h"
#include "faketoolbar.h"
#include "settingsmanager.h" #include "settingsmanager.h"
#include "settingspage.h" #include "settingspage.h"
#include "editorwidget.h" #include "editorwidget.h"
...@@ -42,6 +41,7 @@ ...@@ -42,6 +41,7 @@
#include "resourcehandler.h" #include "resourcehandler.h"
#include <widgethost.h> #include <widgethost.h>
#include <coreplugin/designmodetoolbar.h>
#include <coreplugin/modemanager.h> #include <coreplugin/modemanager.h>
#include <coreplugin/designmode.h> #include <coreplugin/designmode.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
...@@ -154,7 +154,9 @@ FormEditorW::FormEditorW() : ...@@ -154,7 +154,9 @@ FormEditorW::FormEditorW() :
m_context(0), m_context(0),
m_modeWidget(0), m_modeWidget(0),
m_editorWidget(0), m_editorWidget(0),
m_designMode(0) m_designMode(0),
m_editorToolBar(0),
m_toolBar(0)
{ {
if (Designer::Constants::Internal::debug) if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
...@@ -310,14 +312,19 @@ void FormEditorW::fullInit() ...@@ -310,14 +312,19 @@ void FormEditorW::fullInit()
m_editorWidget->restoreSettings(settings); m_editorWidget->restoreSettings(settings);
settings->endGroup(); settings->endGroup();
m_editorToolBar = createEditorToolBar();
m_toolBar = Core::EditorManager::createToolBar();
m_toolBar->setToolbarCreationFlags(Core::EditorToolBar::FlagsIgnoreIEditorToolBar);
m_toolBar->setNavigationVisible(false);
m_toolBar->addCenterToolBar(m_editorToolBar);
m_designMode = ExtensionSystem::PluginManager::instance()->getObject<Core::DesignMode>(); m_designMode = ExtensionSystem::PluginManager::instance()->getObject<Core::DesignMode>();
m_modeWidget = new QWidget; m_modeWidget = new QWidget;
m_modeWidget->setObjectName(QLatin1String("DesignerModeWidget")); m_modeWidget->setObjectName(QLatin1String("DesignerModeWidget"));
QVBoxLayout *layout = new QVBoxLayout; QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(0); layout->setMargin(0);
layout->setSpacing(0); layout->setSpacing(0);
layout->addWidget(m_toolBar);
layout->addWidget(new FakeToolBar(createEditorToolBar()));
layout->addWidget(m_editorWidget); layout->addWidget(m_editorWidget);
m_modeWidget->setLayout(layout); m_modeWidget->setLayout(layout);
...@@ -676,6 +683,9 @@ EditorData FormEditorW::createEditor(QWidget *parent) ...@@ -676,6 +683,9 @@ EditorData FormEditorW::createEditor(QWidget *parent)
connect(data.formWindowEditor->file(), SIGNAL(changed()), connect(data.formWindowEditor->file(), SIGNAL(changed()),
resourceHandler, SLOT(updateResources())); resourceHandler, SLOT(updateResources()));
m_editorWidget->add(data); m_editorWidget->add(data);
m_toolBar->addEditor(xmlEditor->editableInterface());
return data; return data;
} }
......
...@@ -61,6 +61,7 @@ class ICore; ...@@ -61,6 +61,7 @@ class ICore;
class IEditor; class IEditor;
class Command; class Command;
class DesignMode; class DesignMode;
class EditorToolBar;
} }
namespace Designer { namespace Designer {
...@@ -192,6 +193,9 @@ private: ...@@ -192,6 +193,9 @@ private:
EditorWidget *m_editorWidget; EditorWidget *m_editorWidget;
Core::DesignMode *m_designMode; Core::DesignMode *m_designMode;
QWidget *m_editorToolBar;
Core::EditorToolBar *m_toolBar;
QMap<Core::Command *, QAction *> m_commandToDesignerAction; QMap<Core::Command *, QAction *> m_commandToDesignerAction;
}; };
......
...@@ -297,7 +297,8 @@ void DocumentWidget::setup() ...@@ -297,7 +297,8 @@ void DocumentWidget::setup()
m_designToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored); m_designToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored);
m_fakeToolBar->addEditor(textEditor(), Core::EditorToolBar::FlagsIgnoreIEditorToolBar); m_fakeToolBar->setToolbarCreationFlags(Core::EditorToolBar::FlagsIgnoreIEditorToolBar);
m_fakeToolBar->addEditor(textEditor());
m_fakeToolBar->addCenterToolBar(m_designToolBar); m_fakeToolBar->addCenterToolBar(m_designToolBar);
m_fakeToolBar->setNavigationVisible(false); m_fakeToolBar->setNavigationVisible(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