forked from qt-creator/qt-creator
QmlDesigner: Fix states context menu not working in certain areas
Fixed 2 issues with the context menu: - Left clicking the area to the right of the states doesn't close the context menu. The issues seems to be a bug in the ListView, solved by limiting the width of the ListView to the states area width. - Clicking (left or right) below the states area doesn't work. This is because the height of the states view was fixed to the height needed. Solved by not restricting the view height and do necessary changes. Also some cleanups and removing unnecessary stuff. Fixes: QDS-5324 Change-Id: Ic1e3f5d0776bb4770a3276c93ad1aee7a0049388 Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -38,11 +38,7 @@ FocusScope {
|
|||||||
property int delegateColumnSpacing: 2
|
property int delegateColumnSpacing: 2
|
||||||
property int delegateStateMargin: 16
|
property int delegateStateMargin: 16
|
||||||
property int delegatePreviewMargin: 16
|
property int delegatePreviewMargin: 16
|
||||||
|
property int effectiveHeight: root.expanded ? 287 : 85 // height of the states area
|
||||||
height: (root.expanded ? (root.delegateTopAreaHeight + root.delegateBottomAreaHeight + root.delegateColumnSpacing)
|
|
||||||
: root.delegateTopAreaHeight)
|
|
||||||
+ StudioTheme.Values.scrollBarThickness
|
|
||||||
+ 2 * (root.delegateStateMargin + StudioTheme.Values.border + root.padding)
|
|
||||||
|
|
||||||
signal createNewState
|
signal createNewState
|
||||||
signal deleteState(int internalNodeId)
|
signal deleteState(int internalNodeId)
|
||||||
@@ -52,7 +48,7 @@ FocusScope {
|
|||||||
property int padding: 2
|
property int padding: 2
|
||||||
property int delegateWidth: root.stateImageSize
|
property int delegateWidth: root.stateImageSize
|
||||||
+ 2 * (root.delegateStateMargin + root.delegatePreviewMargin)
|
+ 2 * (root.delegateStateMargin + root.delegatePreviewMargin)
|
||||||
property int delegateHeight: root.height
|
property int delegateHeight: effectiveHeight
|
||||||
- StudioTheme.Values.scrollBarThickness
|
- StudioTheme.Values.scrollBarThickness
|
||||||
- 2 * (root.padding + StudioTheme.Values.border)
|
- 2 * (root.padding + StudioTheme.Values.border)
|
||||||
property int innerSpacing: 2
|
property int innerSpacing: 2
|
||||||
@@ -65,10 +61,6 @@ FocusScope {
|
|||||||
function onChangedToState(n) { root.currentStateInternalId = n }
|
function onChangedToState(n) { root.currentStateInternalId = n }
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemPalette {
|
|
||||||
id: palette
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: background
|
id: background
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -93,26 +85,10 @@ FocusScope {
|
|||||||
|
|
||||||
StudioControls.MenuItem {
|
StudioControls.MenuItem {
|
||||||
text: root.expanded ? qsTr("Collapse") : qsTr("Expand")
|
text: root.expanded ? qsTr("Collapse") : qsTr("Expand")
|
||||||
onTriggered: {
|
onTriggered: root.expanded = !root.expanded
|
||||||
root.expanded = !root.expanded
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function closeContextMenu() {
|
|
||||||
if (contextMenu.open)
|
|
||||||
contextMenu.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: addStateItem
|
|
||||||
|
|
||||||
property int buttonLeftSpacing: 8 * (root.expanded ? 1 : 2)
|
|
||||||
|
|
||||||
anchors.right: parent.right
|
|
||||||
width: root.delegateHeight / 2 + buttonLeftSpacing
|
|
||||||
height: root.delegateHeight
|
|
||||||
|
|
||||||
AbstractButton {
|
AbstractButton {
|
||||||
id: addStateButton
|
id: addStateButton
|
||||||
@@ -120,43 +96,40 @@ FocusScope {
|
|||||||
buttonIcon: root.expanded ? qsTr("Create New State") : StudioTheme.Constants.plus
|
buttonIcon: root.expanded ? qsTr("Create New State") : StudioTheme.Constants.plus
|
||||||
iconFont: root.expanded ? StudioTheme.Constants.font : StudioTheme.Constants.iconFont
|
iconFont: root.expanded ? StudioTheme.Constants.font : StudioTheme.Constants.iconFont
|
||||||
iconSize: root.expanded ? StudioTheme.Values.myFontSize : StudioTheme.Values.myIconFontSize
|
iconSize: root.expanded ? StudioTheme.Values.myFontSize : StudioTheme.Values.myIconFontSize
|
||||||
iconItalic: root.expanded ? true : false
|
iconItalic: root.expanded
|
||||||
tooltip: qsTr("Add a new state.")
|
tooltip: qsTr("Add a new state.")
|
||||||
visible: canAddNewStates
|
visible: canAddNewStates
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.rightMargin: 8
|
anchors.rightMargin: 8
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
y: (Math.min(effectiveHeight, root.height) - height) / 2
|
||||||
width: Math.max(parent.height / 2 - 8, 18)
|
width: Math.max(root.delegateHeight / 2 - 8, 18)
|
||||||
height: root.expanded ? 80 : width
|
height: root.expanded ? 60 : width
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.closeContextMenu()
|
contextMenu.dismiss()
|
||||||
root.createNewState()
|
root.createNewState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle {
|
Rectangle { // separator lines between state items
|
||||||
color: StudioTheme.Values.themeStateSeparator
|
color: StudioTheme.Values.themeStateSeparator
|
||||||
x: root.padding
|
x: root.padding
|
||||||
y: root.padding
|
y: root.padding
|
||||||
width: Math.min((root.delegateWidth * flickable.count) + (2 * (flickable.count - 1)),
|
width: statesListView.width
|
||||||
flickable.width)
|
|
||||||
height: root.delegateHeight
|
height: root.delegateHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: flickable
|
id: statesListView
|
||||||
|
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
anchors.left: parent.left
|
x: root.padding
|
||||||
anchors.right: addStateItem.left
|
|
||||||
height: root.delegateHeight + StudioTheme.Values.scrollBarThickness
|
|
||||||
y: root.padding
|
y: root.padding
|
||||||
anchors.leftMargin: root.padding
|
width: Math.min(root.delegateWidth * statesListView.count + root.innerSpacing * (statesListView.count - 1),
|
||||||
anchors.rightMargin: root.padding
|
root.width - addStateButton.width - root.padding - 16) // 16 = 2 * 8 (addStateButton margin)
|
||||||
|
height: root.delegateHeight + StudioTheme.Values.scrollBarThickness
|
||||||
|
|
||||||
model: statesEditorModel
|
model: statesEditorModel
|
||||||
orientation: ListView.Horizontal
|
orientation: ListView.Horizontal
|
||||||
@@ -174,7 +147,7 @@ FocusScope {
|
|||||||
delegateStateImageSize: stateImageSize
|
delegateStateImageSize: stateImageSize
|
||||||
delegateHasWhenCondition: hasWhenCondition
|
delegateHasWhenCondition: hasWhenCondition
|
||||||
delegateWhenConditionString: whenConditionString
|
delegateWhenConditionString: whenConditionString
|
||||||
onDelegateInteraction: root.closeContextMenu()
|
onDelegateInteraction: contextMenu.dismiss()
|
||||||
|
|
||||||
columnSpacing: root.delegateColumnSpacing
|
columnSpacing: root.delegateColumnSpacing
|
||||||
topAreaHeight: root.delegateTopAreaHeight
|
topAreaHeight: root.delegateTopAreaHeight
|
||||||
@@ -183,16 +156,6 @@ FocusScope {
|
|||||||
previewMargin: root.delegatePreviewMargin
|
previewMargin: root.delegatePreviewMargin
|
||||||
}
|
}
|
||||||
|
|
||||||
property bool bothVisible: horizontal.scrollBarVisible && vertical.scrollBarVisible
|
ScrollBar.horizontal: HorizontalScrollBar {}
|
||||||
|
|
||||||
ScrollBar.horizontal: HorizontalScrollBar {
|
|
||||||
id: horizontal
|
|
||||||
parent: flickable
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollBar.vertical: VerticalScrollBar {
|
|
||||||
id: vertical
|
|
||||||
parent: flickable
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,12 +168,9 @@ void StatesEditorWidget::reloadQmlSource()
|
|||||||
connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState()));
|
connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState()));
|
||||||
connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int)));
|
connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int)));
|
||||||
m_statesEditorView.data()->synchonizeCurrentStateFromWidget();
|
m_statesEditorView.data()->synchonizeCurrentStateFromWidget();
|
||||||
setFixedHeight(initialSize().height());
|
|
||||||
|
|
||||||
if (!DesignerSettings::getValue(DesignerSettingsKey::STATESEDITOR_EXPANDED).toBool()) {
|
if (!DesignerSettings::getValue(DesignerSettingsKey::STATESEDITOR_EXPANDED).toBool())
|
||||||
toggleStatesViewExpanded();
|
toggleStatesViewExpanded();
|
||||||
setFixedHeight(rootObject()->height());
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(rootObject(), SIGNAL(expandedChanged()), this, SLOT(handleExpandedChanged()));
|
connect(rootObject(), SIGNAL(expandedChanged()), this, SLOT(handleExpandedChanged()));
|
||||||
}
|
}
|
||||||
@@ -184,7 +181,5 @@ void StatesEditorWidget::handleExpandedChanged()
|
|||||||
|
|
||||||
bool expanded = rootObject()->property("expanded").toBool();
|
bool expanded = rootObject()->property("expanded").toBool();
|
||||||
DesignerSettings::setValue(DesignerSettingsKey::STATESEDITOR_EXPANDED, expanded);
|
DesignerSettings::setValue(DesignerSettingsKey::STATESEDITOR_EXPANDED, expanded);
|
||||||
|
|
||||||
setFixedHeight(rootObject()->height());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user