forked from qt-creator/qt-creator
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:
committed by
Tim Jenssen
parent
58e7554f3d
commit
d5ac800b90
@@ -74,6 +74,12 @@ void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorV
|
|||||||
checkForWindow();
|
checkForWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StatesEditorView::toggleStatesViewExpanded()
|
||||||
|
{
|
||||||
|
if (m_statesEditorWidget)
|
||||||
|
m_statesEditorWidget->toggleStatesViewExpanded();
|
||||||
|
}
|
||||||
|
|
||||||
void StatesEditorView::removeState(int nodeId)
|
void StatesEditorView::removeState(int nodeId)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ public:
|
|||||||
|
|
||||||
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) override;
|
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) override;
|
||||||
|
|
||||||
|
void toggleStatesViewExpanded();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void synchonizeCurrentStateFromWidget();
|
void synchonizeCurrentStateFromWidget();
|
||||||
void createNewState();
|
void createNewState();
|
||||||
|
|||||||
@@ -117,6 +117,12 @@ QString StatesEditorWidget::qmlSourcesPath() {
|
|||||||
return Core::ICore::resourcePath() + QStringLiteral("/qmldesigner/statesEditorQmlSources");
|
return Core::ICore::resourcePath() + QStringLiteral("/qmldesigner/statesEditorQmlSources");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StatesEditorWidget::toggleStatesViewExpanded()
|
||||||
|
{
|
||||||
|
bool expanded = rootObject()->property("expanded").toBool();
|
||||||
|
rootObject()->setProperty("expanded", !expanded);
|
||||||
|
}
|
||||||
|
|
||||||
void StatesEditorWidget::reloadQmlSource()
|
void StatesEditorWidget::reloadQmlSource()
|
||||||
{
|
{
|
||||||
QString statesListQmlFilePath = qmlSourcesPath() + QStringLiteral("/StatesList.qml");
|
QString statesListQmlFilePath = qmlSourcesPath() + QStringLiteral("/StatesList.qml");
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ public:
|
|||||||
|
|
||||||
static QString qmlSourcesPath();
|
static QString qmlSourcesPath();
|
||||||
|
|
||||||
|
void toggleStatesViewExpanded();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void reloadQmlSource();
|
void reloadQmlSource();
|
||||||
void changeHeight();
|
void changeHeight();
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ public:
|
|||||||
DesignerActionManager &designerActionManager();
|
DesignerActionManager &designerActionManager();
|
||||||
const DesignerActionManager &designerActionManager() const;
|
const DesignerActionManager &designerActionManager() const;
|
||||||
|
|
||||||
|
void toggleStatesViewExpanded();
|
||||||
|
|
||||||
private: // functions
|
private: // functions
|
||||||
Q_DISABLE_COPY(ViewManager)
|
Q_DISABLE_COPY(ViewManager)
|
||||||
|
|
||||||
|
|||||||
@@ -324,6 +324,11 @@ const DesignerActionManager &ViewManager::designerActionManager() const
|
|||||||
return d->designerActionManagerView.designerActionManager();
|
return d->designerActionManagerView.designerActionManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewManager::toggleStatesViewExpanded()
|
||||||
|
{
|
||||||
|
d->statesEditorView.toggleStatesViewExpanded();
|
||||||
|
}
|
||||||
|
|
||||||
Model *ViewManager::currentModel() const
|
Model *ViewManager::currentModel() const
|
||||||
{
|
{
|
||||||
return currentDesignDocument()->currentModel();
|
return currentDesignDocument()->currentModel();
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const char SWITCH_TEXT_DESIGN[] = "QmlDesigner.SwitchTextDesign";
|
|||||||
const char RESTORE_DEFAULT_VIEW[] = "QmlDesigner.RestoreDefaultView";
|
const char RESTORE_DEFAULT_VIEW[] = "QmlDesigner.RestoreDefaultView";
|
||||||
const char TOGGLE_LEFT_SIDEBAR[] = "QmlDesigner.ToggleLeftSideBar";
|
const char TOGGLE_LEFT_SIDEBAR[] = "QmlDesigner.ToggleLeftSideBar";
|
||||||
const char TOGGLE_RIGHT_SIDEBAR[] = "QmlDesigner.ToggleRightSideBar";
|
const char TOGGLE_RIGHT_SIDEBAR[] = "QmlDesigner.ToggleRightSideBar";
|
||||||
|
const char TOGGLE_STATES_EDITOR[] = "QmlDesigner.ToggleStatesEditor";
|
||||||
const char GO_INTO_COMPONENT[] = "QmlDesigner.GoIntoComponent";
|
const char GO_INTO_COMPONENT[] = "QmlDesigner.GoIntoComponent";
|
||||||
const char EXPORT_AS_IMAGE[] = "QmlDesigner.ExportAsImage";
|
const char EXPORT_AS_IMAGE[] = "QmlDesigner.ExportAsImage";
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ ShortCutManager::ShortCutManager()
|
|||||||
m_pasteAction(tr("&Paste"), tr("Paste \"%1\""), Utils::ParameterAction::EnabledWithParameter),
|
m_pasteAction(tr("&Paste"), tr("Paste \"%1\""), Utils::ParameterAction::EnabledWithParameter),
|
||||||
m_selectAllAction(tr("Select &All"), tr("Select All \"%1\""), Utils::ParameterAction::EnabledWithParameter),
|
m_selectAllAction(tr("Select &All"), tr("Select All \"%1\""), Utils::ParameterAction::EnabledWithParameter),
|
||||||
m_hideSidebarsAction(tr("Toggle Sidebars"), 0),
|
m_hideSidebarsAction(tr("Toggle Sidebars"), 0),
|
||||||
|
m_collapseExpandStatesAction(tr("Toggle States Editor"), 0),
|
||||||
m_restoreDefaultViewAction(tr("&Restore Default View"), 0),
|
m_restoreDefaultViewAction(tr("&Restore Default View"), 0),
|
||||||
m_toggleLeftSidebarAction(tr("Toggle &Left Sidebar"), 0),
|
m_toggleLeftSidebarAction(tr("Toggle &Left Sidebar"), 0),
|
||||||
m_toggleRightSidebarAction(tr("Toggle &Right Sidebar"), 0),
|
m_toggleRightSidebarAction(tr("Toggle &Right Sidebar"), 0),
|
||||||
@@ -130,6 +131,10 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
|
|||||||
QmlDesignerPlugin::instance()->mainWidget(),
|
QmlDesignerPlugin::instance()->mainWidget(),
|
||||||
SLOT(toggleRightSidebar()));
|
SLOT(toggleRightSidebar()));
|
||||||
|
|
||||||
|
connect(&m_collapseExpandStatesAction, &QAction::triggered, [] {
|
||||||
|
QmlDesignerPlugin::instance()->viewManager().toggleStatesViewExpanded();
|
||||||
|
});
|
||||||
|
|
||||||
// Revert to saved
|
// Revert to saved
|
||||||
Core::EditorManager *em = Core::EditorManager::instance();
|
Core::EditorManager *em = Core::EditorManager::instance();
|
||||||
Core::ActionManager::registerAction(&m_revertToSavedAction,Core::Constants::REVERTTOSAVED, qmlDesignerMainContext);
|
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"));
|
command->setDefaultKeySequence(QKeySequence("Ctrl+Alt+Shift+0"));
|
||||||
viewsMenu->addAction(command);
|
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 = Core::ActionManager::registerAction(&m_restoreDefaultViewAction, Constants::RESTORE_DEFAULT_VIEW, qmlDesignerMainContext);
|
||||||
command->setAttribute(Core::Command::CA_Hide);
|
command->setAttribute(Core::Command::CA_Hide);
|
||||||
viewsMenu->addAction(command);
|
viewsMenu->addAction(command);
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ private:
|
|||||||
Utils::ParameterAction m_pasteAction;
|
Utils::ParameterAction m_pasteAction;
|
||||||
Utils::ParameterAction m_selectAllAction;
|
Utils::ParameterAction m_selectAllAction;
|
||||||
QAction m_hideSidebarsAction;
|
QAction m_hideSidebarsAction;
|
||||||
|
QAction m_collapseExpandStatesAction;
|
||||||
QAction m_restoreDefaultViewAction;
|
QAction m_restoreDefaultViewAction;
|
||||||
QAction m_toggleLeftSidebarAction;
|
QAction m_toggleLeftSidebarAction;
|
||||||
QAction m_toggleRightSidebarAction;
|
QAction m_toggleRightSidebarAction;
|
||||||
|
|||||||
Reference in New Issue
Block a user