Commit 662d362e authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.designModeWidget: adding a context for the navigator

Adding a context for the navigator + some cleanup
parent 3cc491f4
......@@ -34,6 +34,7 @@
#include "qmldesignerconstants.h"
#include "designmodewidget.h"
#include "formeditorwidget.h"
#include "navigatorwidget.h"
namespace QmlDesigner {
namespace Internal {
......@@ -63,6 +64,18 @@ QString FormEditorContext::contextHelpId() const
return qobject_cast<FormEditorWidget *>(m_widget)->contextHelpId();
}
NavigatorContext::NavigatorContext(QWidget *widget)
: IContext(widget)
{
setWidget(widget);
setContext(Core::Context(Constants::C_QMLNAVIGATOR, Constants::C_QT_QUICK_TOOLS_MENU));
}
QString NavigatorContext::contextHelpId() const
{
return qobject_cast<NavigatorWidget *>(m_widget)->contextHelpId();
}
}
}
......@@ -55,6 +55,13 @@ public:
QString contextHelpId() const;
};
class NavigatorContext : public Core::IContext
{
public:
NavigatorContext(QWidget *widget);
QString contextHelpId() const;
};
}
}
......
......@@ -308,7 +308,7 @@ void DesignModeWidget::showEditor(Core::IEditor *editor)
newDocument->setNodeInstanceView(m_nodeInstanceView.data());
newDocument->setAllPropertiesBox(m_allPropertiesBox.data());
newDocument->setNavigator(m_navigator.data());
newDocument->setNavigator(m_navigatorView.data());
newDocument->setStatesEditorView(m_statesEditorView.data());
newDocument->setItemLibraryView(m_itemLibraryView.data());
newDocument->setFormEditorView(m_formEditorView.data());
......@@ -666,7 +666,7 @@ void DesignModeWidget::setup()
m_nodeInstanceView = new NodeInstanceView(this);
connect(m_nodeInstanceView.data(), SIGNAL(qmlPuppetCrashed()), this, SLOT(qmlPuppetCrashed()));
// Sidebar takes ownership
m_navigator = new NavigatorView;
m_navigatorView = new NavigatorView;
m_allPropertiesBox = new AllPropertiesBox;
m_itemLibraryView = new ItemLibraryView(this);
......@@ -683,7 +683,7 @@ void DesignModeWidget::setup()
m_warningWidget = new DocumentWarningWidget(this);
m_warningWidget->setVisible(false);
Core::SideBarItem *navigatorItem = new Core::SideBarItem(m_navigator->widget(), QLatin1String(SB_NAVIGATOR));
Core::SideBarItem *navigatorItem = new NavigatorSideBarItem(m_navigatorView->widget(), QLatin1String(SB_NAVIGATOR));
Core::SideBarItem *libraryItem = new ItemLibrarySideBarItem(m_itemLibraryView->widget(), QLatin1String(SB_LIBRARY));
Core::SideBarItem *propertiesItem = new Core::SideBarItem(m_allPropertiesBox.data(), QLatin1String(SB_PROPERTIES));
......@@ -730,8 +730,11 @@ void DesignModeWidget::setup()
//### we now own these here
rightLayout->addWidget(m_statesEditorView->widget());
FormEditorContext *context = new FormEditorContext(m_formEditorView->widget());
Core::ICore::instance()->addContextObject(context);
FormEditorContext *formEditorContext = new FormEditorContext(m_formEditorView->widget());
Core::ICore::instance()->addContextObject(formEditorContext);
NavigatorContext *navigatorContext = new NavigatorContext(m_navigatorView->widget());
Core::ICore::instance()->addContextObject(navigatorContext);
// editor and output panes
m_outputPlaceholderSplitter->addWidget(m_formEditorView->widget());
......
......@@ -181,7 +181,7 @@ private:
QAction *m_toggleRightSidebarAction;
QWeakPointer<ItemLibraryView> m_itemLibraryView;
QWeakPointer<NavigatorView> m_navigator;
QWeakPointer<NavigatorView> m_navigatorView;
QWeakPointer<AllPropertiesBox> m_allPropertiesBox;
QWeakPointer<StatesEditorView> m_statesEditorView;
QWeakPointer<FormEditorView> m_formEditorView;
......
......@@ -40,7 +40,8 @@ const char * const DELETE = "QmlDesigner.Delete";
// context
const char * const C_QMLDESIGNER = "QmlDesigner::QmlDesignerMain";
const char * const C_QMLFORMEDITOR = "QmlDesigner::FormEditor";
const char * const C_QMLFORMEDITOR = "QmlDesigner::FormEditor";
const char * const C_QMLNAVIGATOR = "QmlDesigner::Navigator";
// special context for preview menu, shared b/w designer and text editor
const char * const C_QT_QUICK_TOOLS_MENU = "QmlDesigner::ToolsMenu";
......
......@@ -168,6 +168,7 @@ void BauhausPlugin::createDesignModeWidget()
creatorCore->addContextObject(m_context);
Core::Context qmlDesignerMainContext(Constants::C_QMLDESIGNER);
Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR);
Core::Context qmlDesignerNavigatorContext(Constants::C_QMLNAVIGATOR);
// Revert to saved
actionManager->registerAction(m_revertToSavedAction,
......@@ -201,27 +202,38 @@ void BauhausPlugin::createDesignModeWidget()
Core::Command *command;
command = actionManager->registerAction(m_mainWidget->deleteAction(),
QmlDesigner::Constants::DELETE, qmlDesignerFormEditorContext);
command = actionManager->registerAction(m_mainWidget->deleteAction(),
QmlDesigner::Constants::DELETE, qmlDesignerNavigatorContext);
command->setDefaultKeySequence(QKeySequence::Delete);
command->setAttribute(Core::Command::CA_Hide); // don't show delete in other modes
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
command = actionManager->registerAction(m_mainWidget->cutAction(),
Core::Constants::CUT, qmlDesignerFormEditorContext);
command = actionManager->registerAction(m_mainWidget->cutAction(),
Core::Constants::CUT, qmlDesignerNavigatorContext);
command->setDefaultKeySequence(QKeySequence::Cut);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
command = actionManager->registerAction(m_mainWidget->copyAction(),
Core::Constants::COPY, qmlDesignerFormEditorContext);
command = actionManager->registerAction(m_mainWidget->copyAction(),
Core::Constants::COPY, qmlDesignerNavigatorContext);
command->setDefaultKeySequence(QKeySequence::Copy);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
command = actionManager->registerAction(m_mainWidget->pasteAction(),
Core::Constants::PASTE, qmlDesignerFormEditorContext);
command = actionManager->registerAction(m_mainWidget->pasteAction(),
Core::Constants::PASTE, qmlDesignerNavigatorContext);
command->setDefaultKeySequence(QKeySequence::Paste);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
command = actionManager->registerAction(m_mainWidget->selectAllAction(),
Core::Constants::SELECTALL, qmlDesignerFormEditorContext);
command = actionManager->registerAction(m_mainWidget->selectAllAction(),
Core::Constants::SELECTALL, qmlDesignerNavigatorContext);
command->setDefaultKeySequence(QKeySequence::SelectAll);
editMenu->addAction(command, Core::Constants::G_EDIT_SELECTALL);
......
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