aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@nokia.com>2010-11-17 12:59:08 +0100
committerThomas Hartmann <Thomas.Hartmann@nokia.com>2010-11-17 12:59:28 +0100
commit71d98970cf7d1b008d24f0a067084a6c4d010d7e (patch)
tree7ef3707bcd7c1e89b3e81507e83f1953c80fe681
parent9f824f416594aba1548c6e5e245cbfc97591325b (diff)
QmlDesigner: adding a distinguished context for the form editor
Since Actions like copy/paste and delete interfiere with controls like LineEdit, I added a special context for the form editor. Now copy/paste/delete on the Qml items are only registered for the form editor context and copying the contens of a LineEdit will not lead to copy an item instead, anymore. Reviewed-by: Kai Koehne
-rw-r--r--src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp15
-rw-r--r--src/plugins/qmldesigner/components/formeditor/formeditorwidget.h1
-rw-r--r--src/plugins/qmldesigner/designmodecontext.cpp30
-rw-r--r--src/plugins/qmldesigner/designmodecontext.h19
-rw-r--r--src/plugins/qmldesigner/designmodewidget.cpp4
-rw-r--r--src/plugins/qmldesigner/qmldesignerconstants.h3
-rw-r--r--src/plugins/qmldesigner/qmldesignerplugin.cpp39
7 files changed, 90 insertions, 21 deletions
diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp
index 6c125bc5d4b..81d6e04bc96 100644
--- a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp
+++ b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.cpp
@@ -261,6 +261,21 @@ void FormEditorWidget::setFeedbackNode(const QmlItemNode &node)
m_graphicsView->setFeedbackNode(node);
}
+QString FormEditorWidget::contextHelpId() const
+{
+ if (!m_formEditorView)
+ return QString();
+
+ QList<ModelNode> nodes = m_formEditorView->selectedModelNodes();
+ QString helpId;
+ if (!nodes.isEmpty()) {
+ helpId = nodes.first().type();
+ helpId.replace("Qt/", "QML.");
+ }
+
+ return helpId;
+}
+
}
diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h
index ec68e351b17..2e6f359077f 100644
--- a/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h
+++ b/src/plugins/qmldesigner/components/formeditor/formeditorwidget.h
@@ -68,6 +68,7 @@ public:
void setFeedbackNode(const QmlItemNode &node);
+ QString contextHelpId() const;
protected:
void enterEvent(QEvent *event);
diff --git a/src/plugins/qmldesigner/designmodecontext.cpp b/src/plugins/qmldesigner/designmodecontext.cpp
index 74f794e6fba..468e1b32bef 100644
--- a/src/plugins/qmldesigner/designmodecontext.cpp
+++ b/src/plugins/qmldesigner/designmodecontext.cpp
@@ -30,6 +30,7 @@
#include "designmodecontext.h"
#include "qmldesignerconstants.h"
#include "designmodewidget.h"
+#include "formeditorwidget.h"
#include <QWidget>
@@ -39,7 +40,7 @@ namespace Internal {
DesignModeContext::DesignModeContext(DesignModeWidget *widget)
: IContext(widget),
m_widget(widget),
- m_context(Constants::C_FORMEDITOR, Constants::C_QT_QUICK_TOOLS_MENU)
+ m_context(Constants::C_QMLDESIGNER, Constants::C_QT_QUICK_TOOLS_MENU)
{
}
@@ -62,6 +63,33 @@ QString DesignModeContext::contextHelpId() const
return m_widget->contextHelpId();
}
+
+FormEditorContext::FormEditorContext(FormEditorWidget *widget)
+ : IContext(widget),
+ m_widget(widget),
+ m_context(Constants::C_QMLFORMEDITOR, Constants::C_QT_QUICK_TOOLS_MENU)
+{
+}
+
+FormEditorContext::~FormEditorContext()
+{
+}
+
+Core::Context FormEditorContext::context() const
+{
+ return m_context;
+}
+
+QWidget *FormEditorContext::widget()
+{
+ return m_widget;
+}
+
+QString FormEditorContext::contextHelpId() const
+{
+ return m_widget->contextHelpId();
+}
+
}
}
diff --git a/src/plugins/qmldesigner/designmodecontext.h b/src/plugins/qmldesigner/designmodecontext.h
index cf0ddd43421..691b1b3e8f0 100644
--- a/src/plugins/qmldesigner/designmodecontext.h
+++ b/src/plugins/qmldesigner/designmodecontext.h
@@ -38,6 +38,9 @@ class QWidget;
QT_END_NAMESPACE
namespace QmlDesigner {
+
+class FormEditorWidget;
+
namespace Internal {
class DesignModeWidget;
@@ -61,6 +64,22 @@ private:
const Core::Context m_context;
};
+class FormEditorContext : public Core::IContext
+{
+public:
+ FormEditorContext(FormEditorWidget *widget);
+ ~FormEditorContext();
+
+ Core::Context context() const;
+ QWidget *widget();
+
+ QString contextHelpId() const;
+
+private:
+ FormEditorWidget *m_widget;
+ const Core::Context m_context;
+};
+
}
}
diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp
index 6826e4324d6..8128eb0f9bc 100644
--- a/src/plugins/qmldesigner/designmodewidget.cpp
+++ b/src/plugins/qmldesigner/designmodewidget.cpp
@@ -30,6 +30,7 @@
#include "designmodewidget.h"
#include "qmldesignerconstants.h"
#include "styledoutputpaneplaceholder.h"
+#include "designmodecontext.h"
#include <model.h>
#include <rewriterview.h>
@@ -685,6 +686,9 @@ void DesignModeWidget::setup()
//### we now own these here
rightLayout->addWidget(m_statesEditorWidget.data());
+ FormEditorContext *context = new FormEditorContext(m_formEditorView->widget());
+ Core::ICore::instance()->addContextObject(context);
+
// editor and output panes
m_outputPlaceholderSplitter->addWidget(m_formEditorView->widget());
m_outputPlaceholderSplitter->addWidget(m_outputPanePlaceholder);
diff --git a/src/plugins/qmldesigner/qmldesignerconstants.h b/src/plugins/qmldesigner/qmldesignerconstants.h
index 90dca941fed..a480b437491 100644
--- a/src/plugins/qmldesigner/qmldesignerconstants.h
+++ b/src/plugins/qmldesigner/qmldesignerconstants.h
@@ -37,7 +37,8 @@ const char * const DELETE = "QmlDesigner.Delete";
// context
const char * const C_DESIGN_MODE = "QmlDesigner::DesignMode";
-const char * const C_FORMEDITOR = "QmlDesigner::QmlFormEditor";
+const char * const C_QMLDESIGNER = "QmlDesigner::QmlDesignerMain";
+const char * const C_QMLFORMEDITOR = "QmlDesigner::FormEditor";
// special context for preview menu, shared b/w designer and text editor
const char * const C_QT_QUICK_TOOLS_MENU = "QmlDesigner::ToolsMenu";
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp
index 34ca0f40203..1b63e224791 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.cpp
+++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp
@@ -117,7 +117,7 @@ bool BauhausPlugin::initialize(const QStringList & /*arguments*/, QString *error
{
Core::ICore *core = Core::ICore::instance();
- const Core::Context switchContext(QmlDesigner::Constants::C_FORMEDITOR,
+ const Core::Context switchContext(QmlDesigner::Constants::C_QMLDESIGNER,
QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
Core::ActionManager *am = core->actionManager();
@@ -162,85 +162,86 @@ void BauhausPlugin::createDesignModeWidget()
m_context = new DesignModeContext(m_mainWidget);
creatorCore->addContextObject(m_context);
- Core::Context formEditorContext(Constants::C_FORMEDITOR);
+ Core::Context qmlDesignerMainContext(Constants::C_QMLDESIGNER);
+ Core::Context qmlDesignerFormEditorContext(Constants::C_QMLFORMEDITOR);
// Revert to saved
actionManager->registerAction(m_revertToSavedAction,
- Core::Constants::REVERTTOSAVED, formEditorContext);
+ Core::Constants::REVERTTOSAVED, qmlDesignerMainContext);
connect(m_revertToSavedAction, SIGNAL(triggered()), m_editorManager, SLOT(revertToSaved()));
//Save
- actionManager->registerAction(m_saveAction, Core::Constants::SAVE, formEditorContext);
+ actionManager->registerAction(m_saveAction, Core::Constants::SAVE, qmlDesignerMainContext);
connect(m_saveAction, SIGNAL(triggered()), m_editorManager, SLOT(saveFile()));
//Save As
- actionManager->registerAction(m_saveAsAction, Core::Constants::SAVEAS, formEditorContext);
+ actionManager->registerAction(m_saveAsAction, Core::Constants::SAVEAS, qmlDesignerMainContext);
connect(m_saveAsAction, SIGNAL(triggered()), m_editorManager, SLOT(saveFileAs()));
//Close Editor
- actionManager->registerAction(m_closeCurrentEditorAction, Core::Constants::CLOSE, formEditorContext);
+ actionManager->registerAction(m_closeCurrentEditorAction, Core::Constants::CLOSE, qmlDesignerMainContext);
connect(m_closeCurrentEditorAction, SIGNAL(triggered()), m_editorManager, SLOT(closeEditor()));
//Close All
- actionManager->registerAction(m_closeAllEditorsAction, Core::Constants::CLOSEALL, formEditorContext);
+ actionManager->registerAction(m_closeAllEditorsAction, Core::Constants::CLOSEALL, qmlDesignerMainContext);
connect(m_closeAllEditorsAction, SIGNAL(triggered()), m_editorManager, SLOT(closeAllEditors()));
//Close All Others Action
- actionManager->registerAction(m_closeOtherEditorsAction, Core::Constants::CLOSEOTHERS, formEditorContext);
+ actionManager->registerAction(m_closeOtherEditorsAction, Core::Constants::CLOSEOTHERS, qmlDesignerMainContext);
connect(m_closeOtherEditorsAction, SIGNAL(triggered()), m_editorManager, SLOT(closeOtherEditors()));
// Undo / Redo
- actionManager->registerAction(m_mainWidget->undoAction(), Core::Constants::UNDO, formEditorContext);
- actionManager->registerAction(m_mainWidget->redoAction(), Core::Constants::REDO, formEditorContext);
+ actionManager->registerAction(m_mainWidget->undoAction(), Core::Constants::UNDO, qmlDesignerMainContext);
+ actionManager->registerAction(m_mainWidget->redoAction(), Core::Constants::REDO, qmlDesignerMainContext);
Core::Command *command;
command = actionManager->registerAction(m_mainWidget->deleteAction(),
- QmlDesigner::Constants::DELETE, formEditorContext);
+ QmlDesigner::Constants::DELETE, qmlDesignerFormEditorContext);
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, formEditorContext);
+ Core::Constants::CUT, qmlDesignerFormEditorContext);
command->setDefaultKeySequence(QKeySequence::Cut);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
command = actionManager->registerAction(m_mainWidget->copyAction(),
- Core::Constants::COPY, formEditorContext);
+ Core::Constants::COPY, qmlDesignerFormEditorContext);
command->setDefaultKeySequence(QKeySequence::Copy);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
command = actionManager->registerAction(m_mainWidget->pasteAction(),
- Core::Constants::PASTE, formEditorContext);
+ Core::Constants::PASTE, qmlDesignerFormEditorContext);
command->setDefaultKeySequence(QKeySequence::Paste);
editMenu->addAction(command, Core::Constants::G_EDIT_COPYPASTE);
command = actionManager->registerAction(m_mainWidget->selectAllAction(),
- Core::Constants::SELECTALL, formEditorContext);
+ Core::Constants::SELECTALL, qmlDesignerFormEditorContext);
command->setDefaultKeySequence(QKeySequence::SelectAll);
editMenu->addAction(command, Core::Constants::G_EDIT_SELECTALL);
Core::ActionContainer *viewsMenu = actionManager->actionContainer(Core::Constants::M_WINDOW_VIEWS);
command = actionManager->registerAction(m_mainWidget->toggleLeftSidebarAction(),
- Constants::TOGGLE_LEFT_SIDEBAR, formEditorContext);
+ Constants::TOGGLE_LEFT_SIDEBAR, qmlDesignerMainContext);
command->setAttribute(Core::Command::CA_Hide);
command->setDefaultKeySequence(QKeySequence("Ctrl+Alt+0"));
viewsMenu->addAction(command);
command = actionManager->registerAction(m_mainWidget->toggleRightSidebarAction(),
- Constants::TOGGLE_RIGHT_SIDEBAR, formEditorContext);
+ Constants::TOGGLE_RIGHT_SIDEBAR, qmlDesignerMainContext);
command->setAttribute(Core::Command::CA_Hide);
command->setDefaultKeySequence(QKeySequence("Ctrl+Alt+Shift+0"));
viewsMenu->addAction(command);
command = actionManager->registerAction(m_mainWidget->restoreDefaultViewAction(),
- Constants::RESTORE_DEFAULT_VIEW, formEditorContext);
+ Constants::RESTORE_DEFAULT_VIEW, qmlDesignerMainContext);
command->setAttribute(Core::Command::CA_Hide);
viewsMenu->addAction(command);
command = actionManager->registerAction(m_mainWidget->hideSidebarsAction(),
- Core::Constants::TOGGLE_SIDEBAR, formEditorContext);
+ Core::Constants::TOGGLE_SIDEBAR, qmlDesignerMainContext);
#ifdef Q_OS_MACX
// add second shortcut to trigger delete