From d87e420b39da9f2c055540dbe8ac841982217caf Mon Sep 17 00:00:00 2001 From: Henning Gruendl Date: Wed, 7 Jun 2023 09:38:20 +0200 Subject: [PATCH] QmlDesigner: Remove old states editor QML source Task-number: QDS-10037 Change-Id: I3fac32afa35940bd857df04ad5f1a0ba2695401e Reviewed-by: Reviewed-by: Tim Jenssen --- .../statesEditorQmlSources/StatesDelegate.qml | 296 ------------------ .../statesEditorQmlSources/StatesList.qml | 159 ---------- .../images/checkers.png | Bin 80 -> 0 bytes .../Main.qml | 0 .../MenuButton.qml | 0 .../StateMenu.qml | 0 .../StateScrollBar.qml | 0 .../StateThumbnail.qml | 0 .../images/checkers.png | Bin .../imports/StatesEditor/Constants.qml | 0 .../imports/StatesEditor/qmldir | 0 11 files changed, 455 deletions(-) delete mode 100644 share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml delete mode 100644 share/qtcreator/qmldesigner/statesEditorQmlSources/StatesList.qml delete mode 100644 share/qtcreator/qmldesigner/statesEditorQmlSources/images/checkers.png rename share/qtcreator/qmldesigner/{newstateseditor => stateseditor}/Main.qml (100%) rename share/qtcreator/qmldesigner/{newstateseditor => stateseditor}/MenuButton.qml (100%) rename share/qtcreator/qmldesigner/{newstateseditor => stateseditor}/StateMenu.qml (100%) rename share/qtcreator/qmldesigner/{newstateseditor => stateseditor}/StateScrollBar.qml (100%) rename share/qtcreator/qmldesigner/{newstateseditor => stateseditor}/StateThumbnail.qml (100%) rename share/qtcreator/qmldesigner/{newstateseditor => stateseditor}/images/checkers.png (100%) rename share/qtcreator/qmldesigner/{newstateseditor => stateseditor}/imports/StatesEditor/Constants.qml (100%) rename share/qtcreator/qmldesigner/{newstateseditor => stateseditor}/imports/StatesEditor/qmldir (100%) diff --git a/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml b/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml deleted file mode 100644 index 3f42fb75117..00000000000 --- a/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesDelegate.qml +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -import QtQuick 2.15 -import QtQuick.Layouts 1.15 -import QtQuickDesignerTheme 1.0 -import HelperWidgets 2.0 -import StudioControls 1.0 as StudioControls -import StudioTheme 1.0 as StudioTheme - -Rectangle { - id: myRoot - - property bool isBaseState - property bool isCurrentState - property string delegateStateName - property string delegateStateImageSource - property bool delegateHasWhenCondition - property string delegateWhenConditionString - property bool hasAnnotation: checkAnnotation() - property int topAreaHeight - property int bottomAreaHeight - property int stateMargin - property int previewMargin - - readonly property bool isDefaultState: isDefault - - property int closeButtonMargin: 6 - property int textFieldMargin: 4 - - property int scrollBarH: 0 - property int listMargin: 0 - - function autoComplete(text, pos, explicitComplete, filter) { - var stringList = statesEditorModel.autoComplete(text, pos, explicitComplete) - return stringList - } - - function checkAnnotation() { - return statesEditorModel.hasAnnotation(internalNodeId) - } - - color: isCurrentState ? StudioTheme.Values.themeInteraction - : StudioTheme.Values.themeControlBackgroundInteraction - MouseArea { - id: mouseArea - anchors.fill: parent - - onClicked: { - focus = true - root.currentStateInternalId = internalNodeId - contextMenu.dismiss() // close potentially open context menu - } - } - - StudioControls.AbstractButton { - id: removeStateButton - - buttonIcon: StudioTheme.Constants.closeCross - - anchors.right: parent.right - anchors.rightMargin: myRoot.closeButtonMargin - anchors.top: parent.top - anchors.topMargin: myRoot.closeButtonMargin - - visible: !isBaseState && isCurrentState - - onClicked: { - if (isDefaultState) - statesEditorModel.resetDefaultState() - - root.deleteState(internalNodeId) - } - } - - StudioControls.Menu { - id: contextMenu - - StudioControls.MenuItem { - enabled: !isBaseState - text: qsTr("Set when Condition") - onTriggered: { - bindingEditor.showWidget() - bindingEditor.text = delegateWhenConditionString - bindingEditor.prepareBindings() - bindingEditor.updateWindowName() - } - } - - StudioControls.MenuItem { - enabled: !isBaseState && delegateHasWhenCondition - text: qsTr("Reset when Condition") - onTriggered: { - statesEditorModel.resetWhenCondition(internalNodeId) - } - } - - StudioControls.MenuItem { - enabled: !isBaseState && !isDefaultState - text: qsTr("Set as Default") - onTriggered: { - statesEditorModel.setStateAsDefault(internalNodeId) - } - } - - StudioControls.MenuItem { - enabled: (!isBaseState && isDefaultState) || (isBaseState && modelHasDefaultState) - text: qsTr("Reset Default") - onTriggered: { - statesEditorModel.resetDefaultState() - } - } - - StudioControls.MenuItem { - enabled: !isBaseState - text: (hasAnnotation ? qsTr("Edit Annotation") - : qsTr("Add Annotation")) - onTriggered: { - statesEditorModel.setAnnotation(internalNodeId) - hasAnnotation = checkAnnotation() - } - } - - StudioControls.MenuItem { - enabled: !isBaseState && hasAnnotation - text: qsTr("Remove Annotation") - onTriggered: { - statesEditorModel.removeAnnotation(internalNodeId) - hasAnnotation = checkAnnotation() - } - } - - onClosed: { - stateNameField.actionIndicator.forceVisible = false - } - - onOpened: { - hasAnnotation = checkAnnotation() - myRoot.delegateInteraction() - } - } - - Column { - id: column - - anchors.margins: myRoot.stateMargin - anchors.fill: parent - - Rectangle { - width: myRoot.width - 2 * myRoot.stateMargin - height: myRoot.topAreaHeight - - color: StudioTheme.Values.themeStateBackground - - StudioControls.TextField { - id: stateNameField - - property string oldValue - - width: StudioTheme.Values.height * 5.5 - - anchors.top: parent.top - anchors.topMargin: myRoot.textFieldMargin - anchors.left: parent.left - anchors.leftMargin: myRoot.textFieldMargin - - translationIndicatorVisible: false - readOnly: isBaseState - - actionIndicator.icon.text: delegateHasWhenCondition - ? StudioTheme.Constants.actionIconBinding - : StudioTheme.Constants.actionIcon - - - actionIndicator.onClicked: { - stateNameField.actionIndicator.forceVisible = true - contextMenu.popup() - } - - onEditChanged: { - if (contextMenu.open && stateNameField.edit) - contextMenu.dismiss() - } - - onActiveFocusChanged: { - if (activeFocus) - root.currentStateInternalId = internalNodeId - } - - onEditingFinished: { - if (stateNameField.oldValue === stateNameField.text) - return - - stateNameField.oldValue = stateNameField.text - - if (stateNameField.text !== myRoot.delegateStateName) - statesEditorModel.renameState(internalNodeId, stateNameField.text) - } - - Component.onCompleted: { - text = myRoot.delegateStateName - } - - //QDS-5649: - Keys.priority: Keys.BeforeItem - Keys.onEscapePressed: function (event) { - event.accepted = true - stateNameField.text = myRoot.delegateStateName - stateNameField.focus = false - } - } - - Text { - id: stateDefaultIndicator - - anchors.right: parent.right - anchors.rightMargin: myRoot.previewMargin - anchors.verticalCenter: stateNameField.verticalCenter - - color: StudioTheme.Values.themeTextColor - font.italic: true - font.pixelSize: StudioTheme.Values.myFontSize - font.family: StudioTheme.Constants.font - - visible: isDefaultState || (isBaseState && !modelHasDefaultState) - - text: qsTr("Default") - } - } - - Rectangle { // separator - width: column.width - height: 2 - color: StudioTheme.Values.themeStateSeparator - } - - Rectangle { - id: stateImageArea - width: myRoot.width - 2 * myRoot.stateMargin - height: myRoot.bottomAreaHeight - color: StudioTheme.Values.themeStateBackground - - Image { - anchors.fill: stateImageBackground - source: "images/checkers.png" - fillMode: Image.Tile - } - - Rectangle { - id: stateImageBackground - anchors.centerIn: parent - width: Math.round(stateImage.paintedWidth) + 2 * StudioTheme.Values.border - height: Math.round(stateImage.paintedHeight) + 2 * StudioTheme.Values.border - color: "transparent" - border.width: StudioTheme.Values.border - border.color: StudioTheme.Values.themeStatePreviewOutline - } - - Image { - id: stateImage - anchors.margins: myRoot.previewMargin - anchors.centerIn: parent - anchors.fill: parent - source: delegateStateImageSource - fillMode: Image.PreserveAspectFit - mipmap: true - } - } - } - - BindingEditor { - id: bindingEditor - - property string newWhenCondition - - property Timer timer: Timer { - id: timer - running: false - interval: 50 - repeat: false - onTriggered: statesEditorModel.setWhenCondition(internalNodeId, bindingEditor.newWhenCondition) - } - - stateModelNodeProperty: statesEditorModel.stateModelNode() - stateNameProperty: myRoot.delegateStateName - - onRejected: { - hideWidget() - } - onAccepted: { - bindingEditor.newWhenCondition = bindingEditor.text.trim() - timer.start() - hideWidget() - } - } -} diff --git a/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesList.qml b/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesList.qml deleted file mode 100644 index e56d7419099..00000000000 --- a/share/qtcreator/qmldesigner/statesEditorQmlSources/StatesList.qml +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuickDesignerTheme 1.0 -import Qt.labs.qmlmodels 1.0 -import HelperWidgets 2.0 -import StudioControls 1.0 as StudioControls -import StudioTheme 1.0 as StudioTheme - -FocusScope { - id: root - - readonly property int delegateTopAreaHeight: StudioTheme.Values.height + 8 - readonly property int delegateBottomAreaHeight: delegateHeight - 2 * delegateStateMargin - delegateTopAreaHeight - 2 - readonly property int delegateStateMargin: 16 - readonly property int delegatePreviewMargin: 10 - readonly property int effectiveHeight: root.height < 130 ? 89 : Math.min(root.height, 287) - - readonly property int scrollBarH: statesListView.ScrollBar.horizontal.scrollBarVisible ? StudioTheme.Values.scrollBarThickness : 0 - readonly property int listMargin: 10 - readonly property int delegateWidth: 264 - readonly property int delegateHeight: Math.max(effectiveHeight - scrollBarH - 2 * listMargin, 69) - readonly property int innerSpacing: 2 - - property int currentStateInternalId: 0 - - signal createNewState - signal deleteState(int internalNodeId) - signal duplicateCurrentState - - Connections { - target: statesEditorModel - function onChangedToState(n) { root.currentStateInternalId = n } - } - - Rectangle { - id: background - anchors.fill: parent - color: StudioTheme.Values.themePanelBackground - } - - AbstractButton { - id: addStateButton - - buttonIcon: StudioTheme.Constants.plus - iconFont: StudioTheme.Constants.iconFont - iconSize: StudioTheme.Values.myIconFontSize - tooltip: qsTr("Add a new state.") - visible: canAddNewStates - anchors.right: parent.right - anchors.rightMargin: 4 - anchors.bottom: parent.bottom - anchors.bottomMargin: statesListView.contentWidth - statesListView.contentX - root.delegateWidth / 2 > statesListView.width ? scrollBarH + 5 : -35 - width: 35 - height: 35 - - Behavior on anchors.bottomMargin { - PropertyAnimation { - duration: 700 - easing.type: Easing.InOutBack - } - } - - onClicked: root.createNewState() - } - - ListView { - id: statesListView - - clip: true - anchors.fill: parent - anchors.topMargin: listMargin - anchors.leftMargin: listMargin - anchors.rightMargin: listMargin - - model: statesEditorModel - orientation: ListView.Horizontal - spacing: root.innerSpacing - - property int prevCount: 0 - onCountChanged: { - if (count > prevCount) - Qt.callLater(statesListView.positionViewAtEnd) - prevCount = count - } - - delegate: DelegateChooser { - role: "type" - - DelegateChoice { - roleValue: "state" - - StatesDelegate { - width: root.delegateWidth - height: root.delegateHeight - anchors.verticalCenter: parent ? parent.verticalCenter : undefined - anchors.verticalCenterOffset: -.5 * (scrollBarH + listMargin) - isBaseState: 0 === internalNodeId - isCurrentState: root.currentStateInternalId === internalNodeId - delegateStateName: stateName - delegateStateImageSource: stateImageSource - delegateHasWhenCondition: hasWhenCondition - delegateWhenConditionString: whenConditionString - - topAreaHeight: root.delegateTopAreaHeight - bottomAreaHeight: root.delegateBottomAreaHeight - stateMargin: root.delegateStateMargin - previewMargin: root.delegatePreviewMargin - scrollBarH: root.scrollBarH - listMargin: root.listMargin - } - } - - DelegateChoice { - roleValue: "add" - - Rectangle { - visible: canAddNewStates - - width: root.delegateWidth - height: root.delegateHeight - anchors.verticalCenter: parent ? parent.verticalCenter : undefined - anchors.verticalCenterOffset: -.5 * (scrollBarH + listMargin) - color: Qt.lighter(StudioTheme.Values.themeControlBackgroundInteraction, addState.containsMouse ? 1.5 : 1) - - ToolTip.text: qsTr("Add a new state.") - ToolTip.visible: addState.containsMouse - ToolTip.delay: 1000 - - Rectangle { // inner rect - width: parent.width - 30 - height: parent.height - 30 - anchors.centerIn: parent - color: StudioTheme.Values.themeStateBackground - } - - Text { - text: "+" - anchors.centerIn: parent - anchors.verticalCenterOffset: -(5 + (font.pixelSize - 35) / 9) - font.pixelSize: parent.height * .5 - color: Qt.lighter(StudioTheme.Values.themeControlBackgroundInteraction, addState.containsMouse ? 1.5 : 1) - } - - MouseArea { - id: addState - hoverEnabled: true - anchors.fill: parent - onClicked: root.createNewState() - } - } - } - } - - ScrollBar.horizontal: HorizontalScrollBar {} - } -} diff --git a/share/qtcreator/qmldesigner/statesEditorQmlSources/images/checkers.png b/share/qtcreator/qmldesigner/statesEditorQmlSources/images/checkers.png deleted file mode 100644 index 72cb9f0350646967cbd0bdc5c69981796f43a2dd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 80 zcmeAS@N?(olHy`uVBq!ia0y~yVBi5^4h9AWhGIEpYX$}eaZeY=5RT~N3Kq8i2OAob f_*$Ac0?#lqSbc8ylogof3sUOo>gTe~DWM4fJ|+>W diff --git a/share/qtcreator/qmldesigner/newstateseditor/Main.qml b/share/qtcreator/qmldesigner/stateseditor/Main.qml similarity index 100% rename from share/qtcreator/qmldesigner/newstateseditor/Main.qml rename to share/qtcreator/qmldesigner/stateseditor/Main.qml diff --git a/share/qtcreator/qmldesigner/newstateseditor/MenuButton.qml b/share/qtcreator/qmldesigner/stateseditor/MenuButton.qml similarity index 100% rename from share/qtcreator/qmldesigner/newstateseditor/MenuButton.qml rename to share/qtcreator/qmldesigner/stateseditor/MenuButton.qml diff --git a/share/qtcreator/qmldesigner/newstateseditor/StateMenu.qml b/share/qtcreator/qmldesigner/stateseditor/StateMenu.qml similarity index 100% rename from share/qtcreator/qmldesigner/newstateseditor/StateMenu.qml rename to share/qtcreator/qmldesigner/stateseditor/StateMenu.qml diff --git a/share/qtcreator/qmldesigner/newstateseditor/StateScrollBar.qml b/share/qtcreator/qmldesigner/stateseditor/StateScrollBar.qml similarity index 100% rename from share/qtcreator/qmldesigner/newstateseditor/StateScrollBar.qml rename to share/qtcreator/qmldesigner/stateseditor/StateScrollBar.qml diff --git a/share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml b/share/qtcreator/qmldesigner/stateseditor/StateThumbnail.qml similarity index 100% rename from share/qtcreator/qmldesigner/newstateseditor/StateThumbnail.qml rename to share/qtcreator/qmldesigner/stateseditor/StateThumbnail.qml diff --git a/share/qtcreator/qmldesigner/newstateseditor/images/checkers.png b/share/qtcreator/qmldesigner/stateseditor/images/checkers.png similarity index 100% rename from share/qtcreator/qmldesigner/newstateseditor/images/checkers.png rename to share/qtcreator/qmldesigner/stateseditor/images/checkers.png diff --git a/share/qtcreator/qmldesigner/newstateseditor/imports/StatesEditor/Constants.qml b/share/qtcreator/qmldesigner/stateseditor/imports/StatesEditor/Constants.qml similarity index 100% rename from share/qtcreator/qmldesigner/newstateseditor/imports/StatesEditor/Constants.qml rename to share/qtcreator/qmldesigner/stateseditor/imports/StatesEditor/Constants.qml diff --git a/share/qtcreator/qmldesigner/newstateseditor/imports/StatesEditor/qmldir b/share/qtcreator/qmldesigner/stateseditor/imports/StatesEditor/qmldir similarity index 100% rename from share/qtcreator/qmldesigner/newstateseditor/imports/StatesEditor/qmldir rename to share/qtcreator/qmldesigner/stateseditor/imports/StatesEditor/qmldir