Commit 5e87539d authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner: enable F2 to go into a component

Change-Id: I23b298b184a9a17e19206db6086fce073b12a592
Reviewed-on: http://codereview.qt.nokia.com/1876

Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 02cd2c71
......@@ -56,6 +56,7 @@
#include <nodelistproperty.h>
#include <variantproperty.h>
#include <rewritingexception.h>
#include <model/modelnodecontextmenu.h>
#include <utils/fileutils.h>
......@@ -451,6 +452,19 @@ void DesignDocumentController::changeCurrentModelTo(const ModelNode &componentNo
m_d->componentView->setComponentNode(componentNode);
}
void DesignDocumentController::goIntoComponent()
{
if (!m_d->model)
return;
QList<ModelNode> selectedNodes;
if (m_d->formEditorView)
selectedNodes = m_d->formEditorView->selectedModelNodes();
if (selectedNodes.count() == 1)
ModelNodeAction::goIntoComponent(selectedNodes.first());
}
void DesignDocumentController::loadCurrentModel()
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
......
......@@ -126,6 +126,7 @@ public slots:
void redo();
void activeQtVersionChanged();
void changeCurrentModelTo(const ModelNode &node);
void goIntoComponent();
#ifdef ENABLE_TEXT_VIEW
void showText();
......
......@@ -237,7 +237,7 @@ void ModelNodeContextMenu::execute(const QPoint &pos, bool selectionMenuBool)
if (singleSelected) {
enterComponent = modelNodeIsComponent(currentSingleNode);
}
menu->addAction(createModelNodeAction(tr("Go into Component"), editMenu, QList<ModelNode>() << currentSingleNode, ModelNodeAction::EnterComponent, enterComponent));
menu->addAction(createModelNodeAction(tr("Go into Component"), editMenu, QList<ModelNode>() << currentSingleNode, ModelNodeAction::GoIntoComponent, enterComponent));
menu->exec(pos);
menu->deleteLater();
......@@ -271,6 +271,17 @@ ModelNodeAction::ModelNodeAction( const QString & text, QObject *parent, QmlMode
connect(this, SIGNAL(triggered(bool)), this, SLOT(actionTriggered(bool)));
}
void ModelNodeAction::goIntoComponent(const ModelNode &modelNode)
{
if (modelNode.isValid() && modelNodeIsComponent(modelNode)) {
if (isFileComponent(modelNode))
openFileForComponent(modelNode);
else
openInlineComponent(modelNode);
}
}
void ModelNodeAction::actionTriggered(bool b)
{
switch (m_type) {
......@@ -289,7 +300,7 @@ void ModelNodeAction::actionTriggered(bool b)
case ModelNodeAction::ModelNodeVisibility: setVisible(b); break;
case ModelNodeAction::ResetSize: resetSize(); break;
case ModelNodeAction::ResetPosition: resetPosition(); break;
case ModelNodeAction::EnterComponent: enterComponent(); break;
case ModelNodeAction::GoIntoComponent: goIntoComponent(); break;
case ModelNodeAction::SetId: setId(); break;
case ModelNodeAction::ResetZ: resetZ(); break;
}
......@@ -427,15 +438,9 @@ void ModelNodeAction::resetPosition()
}
}
void ModelNodeAction::enterComponent()
void ModelNodeAction::goIntoComponent()
{
const ModelNode node = m_modelNodeList.first();
if (node.isValid()) {
if (isFileComponent(node))
openFileForComponent(node);
else
openInlineComponent(node);
}
goIntoComponent(m_modelNodeList.first());
}
void ModelNodeAction::setId()
......
......@@ -62,7 +62,7 @@ public:
ModelNodeVisibility,
ResetSize,
ResetPosition,
EnterComponent,
GoIntoComponent,
SetId,
ResetZ
};
......@@ -70,6 +70,8 @@ public:
ModelNodeAction( const QString & text, QObject *parent, QmlModelView *view, const QList<ModelNode> &modelNodeList, ModelNodeActionType type);
static void goIntoComponent(const ModelNode &modelNode);
public slots:
void actionTriggered(bool);
......@@ -89,7 +91,7 @@ private:
void setVisible(bool);
void resetSize();
void resetPosition();
void enterComponent();
void goIntoComponent();
void setId();
void resetZ();
......
......@@ -212,7 +212,9 @@ DesignModeWidget::DesignModeWidget(QWidget *parent) :
m_hideSidebarsAction = new QAction(tr("Toggle Full Screen"), this);
connect(m_hideSidebarsAction, SIGNAL(triggered()), this, SLOT(toggleSidebars()));
m_restoreDefaultViewAction = new QAction(tr("&Restore Default View"), this);
m_goIntoComponentAction = new QAction(tr("&Go into Component"), this);
connect(m_restoreDefaultViewAction, SIGNAL(triggered()), SLOT(restoreDefaultView()));
connect(m_goIntoComponentAction, SIGNAL(triggered()), SLOT(goIntoComponent()));
m_toggleLeftSidebarAction = new QAction(tr("Toggle &Left Sidebar"), this);
connect(m_toggleLeftSidebarAction, SIGNAL(triggered()), SLOT(toggleLeftSidebar()));
m_toggleRightSidebarAction = new QAction(tr("Toggle &Right Sidebar"), this);
......@@ -410,6 +412,11 @@ QAction *DesignModeWidget::restoreDefaultViewAction() const
return m_restoreDefaultViewAction;
}
QAction *DesignModeWidget::goIntoComponentAction() const
{
return m_goIntoComponentAction;
}
void DesignModeWidget::readSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
......@@ -500,6 +507,11 @@ void DesignModeWidget::redoAvailable(bool isAvailable)
}
}
void DesignModeWidget::goIntoComponent()
{
if (m_currentDesignDocumentController)
m_currentDesignDocumentController->goIntoComponent();
}
void DesignModeWidget::enable()
{
......
......@@ -125,6 +125,7 @@ public:
QAction *toggleLeftSidebarAction() const;
QAction *toggleRightSidebarAction() const;
QAction *restoreDefaultViewAction() const;
QAction *goIntoComponentAction() const;
void readSettings();
void saveSettings();
......@@ -147,6 +148,7 @@ private slots:
void restoreDefaultView();
void undoAvailable(bool isAvailable);
void redoAvailable(bool isAvailable);
void goIntoComponent();
void enable();
void disable(const QList<RewriterView::Error> &errors);
......@@ -183,6 +185,7 @@ private:
QAction *m_restoreDefaultViewAction;
QAction *m_toggleLeftSidebarAction;
QAction *m_toggleRightSidebarAction;
QAction *m_goIntoComponentAction;
QWeakPointer<ItemLibraryView> m_itemLibraryView;
QWeakPointer<NavigatorView> m_navigatorView;
......
......@@ -51,6 +51,7 @@ const char * const SWITCH_TEXT_DESIGN = "QmlDesigner.SwitchTextDesign";
const char * const RESTORE_DEFAULT_VIEW = "QmlDesigner.RestoreDefaultView";
const char * const TOGGLE_LEFT_SIDEBAR = "QmlDesigner.ToggleLeftSideBar";
const char * const TOGGLE_RIGHT_SIDEBAR = "QmlDesigner.ToggleRightSideBar";
const char * const GO_INTO_COMPONENT = "QmlDesigner.GoIntoComponent";
// This setting is also accessed by the QMlJsEditor.
const char * const QML_SETTINGS_GROUP = "QML";
......
......@@ -200,6 +200,14 @@ void BauhausPlugin::createDesignModeWidget()
actionManager->registerAction(m_mainWidget->redoAction(), Core::Constants::REDO, qmlDesignerMainContext);
Core::Command *command;
//GoIntoComponent
command = actionManager->registerAction(m_mainWidget->goIntoComponentAction(),
Constants::GO_INTO_COMPONENT, qmlDesignerMainContext);
command->setDefaultKeySequence(QKeySequence(Qt::Key_F2));
//Edit Menu
command = actionManager->registerAction(m_mainWidget->deleteAction(),
QmlDesigner::Constants::DELETE, qmlDesignerFormEditorContext);
command = actionManager->registerAction(m_mainWidget->deleteAction(),
......
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