QmlDesigner: Hook up states editor expanded state to command

The expanded/collpased state of the states editor is now hooked up to
a Qt Creator command. This means there is a configurable shortcurt
and an entry in the menu under Windows/Views.

Change-Id: Ied993870fe605cfd6651b203986b009620c98f1b
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2017-01-19 09:44:13 +01:00
committed by Tim Jenssen
parent 58e7554f3d
commit d5ac800b90
9 changed files with 35 additions and 0 deletions

View File

@@ -74,6 +74,12 @@ void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorV
checkForWindow();
}
void StatesEditorView::toggleStatesViewExpanded()
{
if (m_statesEditorWidget)
m_statesEditorWidget->toggleStatesViewExpanded();
}
void StatesEditorView::removeState(int nodeId)
{
try {

View File

@@ -80,6 +80,8 @@ public:
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) override;
void toggleStatesViewExpanded();
public slots:
void synchonizeCurrentStateFromWidget();
void createNewState();

View File

@@ -117,6 +117,12 @@ QString StatesEditorWidget::qmlSourcesPath() {
return Core::ICore::resourcePath() + QStringLiteral("/qmldesigner/statesEditorQmlSources");
}
void StatesEditorWidget::toggleStatesViewExpanded()
{
bool expanded = rootObject()->property("expanded").toBool();
rootObject()->setProperty("expanded", !expanded);
}
void StatesEditorWidget::reloadQmlSource()
{
QString statesListQmlFilePath = qmlSourcesPath() + QStringLiteral("/StatesList.qml");

View File

@@ -59,6 +59,8 @@ public:
static QString qmlSourcesPath();
void toggleStatesViewExpanded();
private slots:
void reloadQmlSource();
void changeHeight();

View File

@@ -91,6 +91,8 @@ public:
DesignerActionManager &designerActionManager();
const DesignerActionManager &designerActionManager() const;
void toggleStatesViewExpanded();
private: // functions
Q_DISABLE_COPY(ViewManager)

View File

@@ -324,6 +324,11 @@ const DesignerActionManager &ViewManager::designerActionManager() const
return d->designerActionManagerView.designerActionManager();
}
void ViewManager::toggleStatesViewExpanded()
{
d->statesEditorView.toggleStatesViewExpanded();
}
Model *ViewManager::currentModel() const
{
return currentDesignDocument()->currentModel();

View File

@@ -45,6 +45,7 @@ const char SWITCH_TEXT_DESIGN[] = "QmlDesigner.SwitchTextDesign";
const char RESTORE_DEFAULT_VIEW[] = "QmlDesigner.RestoreDefaultView";
const char TOGGLE_LEFT_SIDEBAR[] = "QmlDesigner.ToggleLeftSideBar";
const char TOGGLE_RIGHT_SIDEBAR[] = "QmlDesigner.ToggleRightSideBar";
const char TOGGLE_STATES_EDITOR[] = "QmlDesigner.ToggleStatesEditor";
const char GO_INTO_COMPONENT[] = "QmlDesigner.GoIntoComponent";
const char EXPORT_AS_IMAGE[] = "QmlDesigner.ExportAsImage";

View File

@@ -81,6 +81,7 @@ ShortCutManager::ShortCutManager()
m_pasteAction(tr("&Paste"), tr("Paste \"%1\""), Utils::ParameterAction::EnabledWithParameter),
m_selectAllAction(tr("Select &All"), tr("Select All \"%1\""), Utils::ParameterAction::EnabledWithParameter),
m_hideSidebarsAction(tr("Toggle Sidebars"), 0),
m_collapseExpandStatesAction(tr("Toggle States Editor"), 0),
m_restoreDefaultViewAction(tr("&Restore Default View"), 0),
m_toggleLeftSidebarAction(tr("Toggle &Left Sidebar"), 0),
m_toggleRightSidebarAction(tr("Toggle &Right Sidebar"), 0),
@@ -130,6 +131,10 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
QmlDesignerPlugin::instance()->mainWidget(),
SLOT(toggleRightSidebar()));
connect(&m_collapseExpandStatesAction, &QAction::triggered, [] {
QmlDesignerPlugin::instance()->viewManager().toggleStatesViewExpanded();
});
// Revert to saved
Core::EditorManager *em = Core::EditorManager::instance();
Core::ActionManager::registerAction(&m_revertToSavedAction,Core::Constants::REVERTTOSAVED, qmlDesignerMainContext);
@@ -250,6 +255,11 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
command->setDefaultKeySequence(QKeySequence("Ctrl+Alt+Shift+0"));
viewsMenu->addAction(command);
command = Core::ActionManager::registerAction(&m_collapseExpandStatesAction, Constants::TOGGLE_STATES_EDITOR, qmlDesignerMainContext);
command->setAttribute(Core::Command::CA_Hide);
command->setDefaultKeySequence(QKeySequence("Ctrl+Alt+s"));
viewsMenu->addAction(command);
command = Core::ActionManager::registerAction(&m_restoreDefaultViewAction, Constants::RESTORE_DEFAULT_VIEW, qmlDesignerMainContext);
command->setAttribute(Core::Command::CA_Hide);
viewsMenu->addAction(command);

View File

@@ -88,6 +88,7 @@ private:
Utils::ParameterAction m_pasteAction;
Utils::ParameterAction m_selectAllAction;
QAction m_hideSidebarsAction;
QAction m_collapseExpandStatesAction;
QAction m_restoreDefaultViewAction;
QAction m_toggleLeftSidebarAction;
QAction m_toggleRightSidebarAction;