diff options
Diffstat (limited to 'share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBoxIndicator.qml')
-rw-r--r-- | share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBoxIndicator.qml | 135 |
1 files changed, 71 insertions, 64 deletions
diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBoxIndicator.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBoxIndicator.qml index 8587709201..6bafb9c11e 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBoxIndicator.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/RealSpinBoxIndicator.qml @@ -1,14 +1,16 @@ -// Copyright (C) 2021 The Qt Company Ltd. +// Copyright (C) 2023 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.Templates 2.15 as T +import QtQuick +import QtQuick.Templates as T import StudioTheme 1.0 as StudioTheme Rectangle { - id: spinBoxIndicator + id: control - property T.Control myControl + property StudioTheme.ControlStyle style: StudioTheme.Values.controlStyle + + property T.Control __parentControl property bool hover: spinBoxIndicatorMouseArea.containsMouse property bool pressed: spinBoxIndicatorMouseArea.containsPress @@ -21,13 +23,13 @@ Rectangle { property alias iconFlip: spinBoxIndicatorIconScale.yScale - color: StudioTheme.Values.themeControlBackground + color: control.style.background.idle border.width: 0 - onEnabledChanged: syncEnabled() + onEnabledChanged: control.syncEnabled() onRealEnabledChanged: { - syncEnabled() - if (spinBoxIndicator.realEnabled === false) { + control.syncEnabled() + if (control.realEnabled === false) { pressAndHoldTimer.stop() spinBoxIndicatorMouseArea.pressedAndHeld = false } @@ -36,7 +38,7 @@ Rectangle { // This function is meant to synchronize enabled with realEnabled to avoid // the internal logic messing with the actual state. function syncEnabled() { - spinBoxIndicator.enabled = spinBoxIndicator.realEnabled + control.enabled = control.realEnabled } Timer { @@ -44,7 +46,7 @@ Rectangle { repeat: true running: false interval: 100 - onTriggered: spinBoxIndicator.realPressAndHold() + onTriggered: control.realPressAndHold() } // This MouseArea is a workaround to avoid some hover state related bugs @@ -58,26 +60,26 @@ Rectangle { hoverEnabled: true pressAndHoldInterval: 500 onPressed: function(mouse) { - if (myControl.activeFocus) - spinBoxIndicator.forceActiveFocus() + if (control.__parentControl.activeFocus) + control.forceActiveFocus() - spinBoxIndicator.realPressed() + control.realPressed() mouse.accepted = true } onPressAndHold: { pressAndHoldTimer.restart() - pressedAndHeld = true + spinBoxIndicatorMouseArea.pressedAndHeld = true } onReleased: function(mouse) { // Only trigger real released when pressAndHold isn't active if (!pressAndHoldTimer.running && containsMouse) - spinBoxIndicator.realReleased() + control.realReleased() pressAndHoldTimer.stop() mouse.accepted = true - pressedAndHeld = false + spinBoxIndicatorMouseArea.pressedAndHeld = false } onEntered: { - if (pressedAndHeld) + if (spinBoxIndicatorMouseArea.pressedAndHeld) pressAndHoldTimer.restart() } onExited: { @@ -89,10 +91,10 @@ Rectangle { T.Label { id: spinBoxIndicatorIcon text: StudioTheme.Constants.upDownSquare2 - color: StudioTheme.Values.themeTextColor + color: control.style.icon.idle horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - font.pixelSize: StudioTheme.Values.spinControlIconSizeMulti + font.pixelSize: control.style.smallIconFontSize font.family: StudioTheme.Constants.iconFont.family anchors.fill: parent transform: Scale { @@ -105,54 +107,57 @@ Rectangle { states: [ State { name: "default" - when: myControl.enabled && spinBoxIndicator.enabled && !myControl.edit - && !spinBoxIndicator.hover && !myControl.hover && !myControl.drag + when: control.__parentControl.enabled && control.enabled + && !control.__parentControl.drag && !control.hover + && !control.__parentControl.hover && !control.__parentControl.edit PropertyChanges { target: spinBoxIndicatorIcon - color: StudioTheme.Values.themeTextColor + color: control.style.icon.idle } }, State { name: "globalHover" - when: myControl.enabled && spinBoxIndicator.enabled && !myControl.drag - && !spinBoxIndicator.hover && myControl.hover && !myControl.edit + when: control.__parentControl.enabled && control.enabled + && !control.__parentControl.drag && !control.hover + && control.__parentControl.hover && !control.__parentControl.edit PropertyChanges { target: spinBoxIndicatorIcon - color: StudioTheme.Values.themeTextColor + color: control.style.icon.idle } }, State { name: "hover" - when: myControl.enabled && spinBoxIndicator.enabled && !myControl.drag - && spinBoxIndicator.hover && myControl.hover && !spinBoxIndicator.pressed + when: control.__parentControl.enabled && control.enabled + && !control.__parentControl.drag && control.hover + && control.__parentControl.hover && !control.pressed PropertyChanges { target: spinBoxIndicatorIcon - color: StudioTheme.Values.themeIconColorHover + color: control.style.icon.hover } }, State { name: "press" - when: myControl.enabled && spinBoxIndicator.enabled && !myControl.drag - && spinBoxIndicator.pressed + when: control.__parentControl.enabled && control.enabled + && !control.__parentControl.drag && control.pressed PropertyChanges { target: spinBoxIndicatorIcon - color: StudioTheme.Values.themeIconColor + color: control.style.icon.idle } }, State { name: "edit" - when: myControl.edit && spinBoxIndicator.enabled + when: control.__parentControl.edit && control.enabled PropertyChanges { target: spinBoxIndicatorIcon - color: StudioTheme.Values.themeTextColor + color: control.style.icon.idle } }, State { name: "disable" - when: !myControl.enabled || !spinBoxIndicator.enabled + when: !control.__parentControl.enabled || !control.enabled PropertyChanges { target: spinBoxIndicatorIcon - color: StudioTheme.Values.themeTextColorDisabled + color: control.style.icon.disabled } } ] @@ -161,102 +166,104 @@ Rectangle { states: [ State { name: "default" - when: myControl.enabled && !myControl.edit - && !spinBoxIndicator.hover && !myControl.hover && !myControl.drag + when: control.__parentControl.enabled && !control.__parentControl.edit && !control.hover + && !control.__parentControl.hover && !control.__parentControl.drag PropertyChanges { target: spinBoxIndicatorIcon visible: false } PropertyChanges { - target: spinBoxIndicator - color: StudioTheme.Values.themeControlBackground + target: control + color: control.style.background.idle } }, State { name: "globalHover" - when: myControl.enabled && spinBoxIndicator.enabled && !myControl.drag - && !spinBoxIndicator.hover && myControl.hover && !myControl.edit + when: control.__parentControl.enabled && control.enabled + && !control.__parentControl.drag && !control.hover + && control.__parentControl.hover && !control.__parentControl.edit PropertyChanges { target: spinBoxIndicatorIcon visible: true } PropertyChanges { - target: spinBoxIndicator - color: StudioTheme.Values.themeControlBackgroundGlobalHover + target: control + color: control.style.background.globalHover } }, State { name: "hover" - when: myControl.enabled && !myControl.drag && spinBoxIndicator.enabled - && spinBoxIndicator.hover && myControl.hover && !spinBoxIndicator.pressed + when: control.__parentControl.enabled && !control.__parentControl.drag + && control.enabled && control.hover && control.__parentControl.hover + && !control.pressed PropertyChanges { target: spinBoxIndicatorIcon visible: true } PropertyChanges { - target: spinBoxIndicator - color: StudioTheme.Values.themeControlBackgroundHover + target: control + color: control.style.background.hover } }, State { name: "press" - when: myControl.enabled && spinBoxIndicator.enabled && !myControl.drag - && spinBoxIndicator.pressed + when: control.__parentControl.enabled && control.enabled + && !control.__parentControl.drag && control.pressed PropertyChanges { target: spinBoxIndicatorIcon visible: true } PropertyChanges { - target: spinBoxIndicator - color: StudioTheme.Values.themeInteraction + target: control + color: control.style.interaction } }, State { name: "edit" - when: myControl.edit && myControl.enabled && spinBoxIndicator.enabled + when: control.__parentControl.edit && control.__parentControl.enabled && control.enabled PropertyChanges { target: spinBoxIndicatorIcon visible: true } PropertyChanges { - target: spinBoxIndicator - color: StudioTheme.Values.themeControlBackground + target: control + color: control.style.background.idle } }, State { name: "drag" - when: myControl.drag && myControl.enabled + when: control.__parentControl.drag && control.__parentControl.enabled PropertyChanges { target: spinBoxIndicatorIcon visible: false } PropertyChanges { - target: spinBoxIndicator - color: StudioTheme.Values.themeControlBackgroundInteraction + target: control + color: control.style.background.interaction } }, State { name: "disable" - when: !myControl.enabled + when: !control.__parentControl.enabled PropertyChanges { target: spinBoxIndicatorIcon visible: false } PropertyChanges { - target: spinBoxIndicator - color: StudioTheme.Values.themeControlBackgroundDisabled + target: control + color: control.style.background.disabled } }, State { name: "limit" - when: !spinBoxIndicator.enabled && !spinBoxIndicator.realEnabled && myControl.hover + when: !control.enabled && !control.realEnabled && control.__parentControl.hover PropertyChanges { target: spinBoxIndicatorIcon visible: true } PropertyChanges { - target: spinBoxIndicator - color: StudioTheme.Values.themeControlBackground + target: control + color: control.style.background.idle } } ] |