Commit c5dad0f6 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.StatesEditor: Adding context menu to collapse the view



Change-Id: I5c118281ec8b9b3ef059e668ed4f534b70f952e1
Reviewed-by: default avatarTim Jenssen <tim.jenssen@digia.com>
parent 6d1ae0e2
...@@ -49,9 +49,28 @@ Rectangle { ...@@ -49,9 +49,28 @@ Rectangle {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: { onClicked: {
focus = true if (mouse.button === Qt.LeftButton) {
root.currentStateInternalId = internalNodeId focus = true
root.currentStateInternalId = internalNodeId
} else if (mouse.button === Qt.RightButton) {
contextMenu.popup()
}
}
Menu {
id: contextMenu
MenuItem {
text: root.expanded ? qsTr("Collapse") : qsTr("Expand")
onTriggered: {
root.expanded = ! root.expanded
}
}
} }
} }
......
...@@ -34,7 +34,7 @@ import QtQuick.Controls.Styles 1.1 ...@@ -34,7 +34,7 @@ import QtQuick.Controls.Styles 1.1
FocusScope { FocusScope {
id: root id: root
height: 132 height: expanded ? 132 : 32
signal createNewState signal createNewState
signal deleteState(int internalNodeId) signal deleteState(int internalNodeId)
signal duplicateCurrentState signal duplicateCurrentState
...@@ -46,6 +46,8 @@ FocusScope { ...@@ -46,6 +46,8 @@ FocusScope {
property int innerSpacing: 2 property int innerSpacing: 2
property int currentStateInternalId : 0 property int currentStateInternalId : 0
property bool expanded: true
Connections { Connections {
target: statesEditorModel target: statesEditorModel
onChangedToState: root.currentStateInternalId = n onChangedToState: root.currentStateInternalId = n
......
...@@ -135,6 +135,13 @@ void StatesEditorWidget::reloadQmlSource() ...@@ -135,6 +135,13 @@ void StatesEditorWidget::reloadQmlSource()
connect(m_quickView->rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState())); connect(m_quickView->rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState()));
connect(m_quickView->rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int))); connect(m_quickView->rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int)));
m_statesEditorView.data()->synchonizeCurrentStateFromWidget(); m_statesEditorView.data()->synchonizeCurrentStateFromWidget();
setMaximumHeight(m_quickView->initialSize().height()); setFixedHeight(m_quickView->initialSize().height());
connect(m_quickView->rootObject(), SIGNAL(expandedChanged()), this, SLOT(changeHeight()));
}
void StatesEditorWidget::changeHeight()
{
setFixedHeight(m_quickView->rootObject()->height());
} }
} }
...@@ -66,6 +66,8 @@ public: ...@@ -66,6 +66,8 @@ public:
private slots: private slots:
void reloadQmlSource(); void reloadQmlSource();
void changeHeight();
private: private:
QPointer<QQuickView> m_quickView; QPointer<QQuickView> m_quickView;
QPointer<StatesEditorView> m_statesEditorView; QPointer<StatesEditorView> m_statesEditorView;
......
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