aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2024-09-02 11:42:24 +0200
committerDoris Verria <doris.verria@qt.io>2024-09-06 13:01:00 +0200
commit00ca804c557f2ac8c7cbd9ed09711bf846b8a762 (patch)
tree3863b73b7262a69217061fd41596fbbb19912a70
parent746b4d1086c27b70d153de80420f20bb9fab8f30 (diff)
FluentWinUI3 Style: Add SwipeDelegate
Task-number: QTBUG-125279 Pick-to: 6.8 Change-Id: Ia1f35705cd1f6ff912294ddce172bde381789fbb Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quickcontrols/fluentwinui3/CMakeLists.txt1
-rw-r--r--src/quickcontrols/fluentwinui3/SwipeDelegate.qml66
2 files changed, 67 insertions, 0 deletions
diff --git a/src/quickcontrols/fluentwinui3/CMakeLists.txt b/src/quickcontrols/fluentwinui3/CMakeLists.txt
index e3dfa42302..ecf986369e 100644
--- a/src/quickcontrols/fluentwinui3/CMakeLists.txt
+++ b/src/quickcontrols/fluentwinui3/CMakeLists.txt
@@ -32,6 +32,7 @@ set(qml_files
"RoundButton.qml"
"Slider.qml"
"SpinBox.qml"
+ "SwipeDelegate.qml"
"Switch.qml"
"SwitchDelegate.qml"
"TabBar.qml"
diff --git a/src/quickcontrols/fluentwinui3/SwipeDelegate.qml b/src/quickcontrols/fluentwinui3/SwipeDelegate.qml
new file mode 100644
index 0000000000..9714d33549
--- /dev/null
+++ b/src/quickcontrols/fluentwinui3/SwipeDelegate.qml
@@ -0,0 +1,66 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import QtQuick
+import QtQuick.Templates as T
+import QtQuick.Controls.impl
+
+T.SwipeDelegate {
+ id: control
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ implicitContentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding,
+ implicitIndicatorHeight + topPadding + bottomPadding)
+
+ spacing: config.spacing || 0
+
+ topPadding: config.topPadding || 0
+ leftPadding: config.leftPadding || 0
+ rightPadding: config.rightPadding || 0
+ bottomPadding: config.bottomPadding || 0
+
+ icon.width: 16
+ icon.height: 16
+ icon.color: control.down ? __pressedText : control.palette.buttonText
+
+ readonly property color __pressedText: Application.styleHints.colorScheme === Qt.Light
+ ? Color.transparent(control.palette.buttonText, 0.62)
+ : Color.transparent(control.palette.buttonText, 0.7725)
+ readonly property string __currentState: [
+ !control.enabled && "disabled",
+ control.highlighted && "highlighted",
+ control.enabled && !control.down && control.hovered && "hovered",
+ control.down && "pressed"
+ ].filter(Boolean).join("_") || "normal"
+ readonly property var config: Config.controls.itemdelegate[__currentState] || {}
+
+ readonly property Item __focusFrameTarget: control
+
+ swipe.transition: Transition { SmoothedAnimation { duration: 167; easing.type: Easing.OutCubic } }
+
+ contentItem: IconLabel {
+ spacing: control.spacing
+ mirrored: control.mirrored
+ display: control.display
+ alignment: control.display === IconLabel.IconOnly || control.display === IconLabel.TextUnderIcon ? Qt.AlignCenter : Qt.AlignLeft
+
+ icon: control.icon
+ text: control.text
+ font: control.font
+ color: control.icon.color
+ }
+
+ background: Rectangle {
+ implicitWidth: control.config.background.width
+ implicitHeight: control.config.background.height
+ readonly property bool lightScheme: Application.styleHints.colorScheme === Qt.Light
+ readonly property color bakcgroundColorTint: control.down
+ ? lightScheme ? Color.transparent("black", 0.02) : Color.transparent("white", 0.04)
+ : control.hovered || control.highlighted
+ ? lightScheme ? Color.transparent("black", 0.04) : Color.transparent("white", 0.06)
+ : "transparent"
+ color: Qt.tint(control.palette.window, bakcgroundColorTint)
+ }
+}