aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/fluentwinui3/RadioButton.qml
diff options
context:
space:
mode:
authorDoris Verria <[email protected]>2024-05-28 15:16:20 +0200
committerDoris Verria <[email protected]>2024-06-02 23:26:54 +0200
commit6093d75cbbc3d1f58f414cf858d7f568a26a8870 (patch)
tree113332386a36f5b00f2b96c16190bcf80ca23514 /src/quickcontrols/fluentwinui3/RadioButton.qml
parent7c2c2fd16c6e55545c79cd52d4e974f13a7d8e7d (diff)
Rename Fluent style to FluentWinUI3
The style is based on the WinUI3 design system, which follows the Fluent design. Task-number: QTBUG-125279 Change-Id: Ie92c35a5c1d3eafdbb377d1c49df4b8cc84e1e98 Reviewed-by: Richard Moe Gustavsen <[email protected]>
Diffstat (limited to 'src/quickcontrols/fluentwinui3/RadioButton.qml')
-rw-r--r--src/quickcontrols/fluentwinui3/RadioButton.qml59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/quickcontrols/fluentwinui3/RadioButton.qml b/src/quickcontrols/fluentwinui3/RadioButton.qml
new file mode 100644
index 0000000000..ee1ed8d4ad
--- /dev/null
+++ b/src/quickcontrols/fluentwinui3/RadioButton.qml
@@ -0,0 +1,59 @@
+// 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.Controls.impl
+import QtQuick.Templates as T
+
+T.RadioButton {
+ 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
+ bottomPadding: config.bottomPadding || 0
+ leftPadding: config.leftPadding || 0
+ rightPadding: config.rightPadding || 0
+
+ topInset: -config.topInset || 0
+ bottomInset: -config.bottomInset || 0
+ leftInset: -config.leftInset || 0
+ rightInset: -config.rightInset || 0
+
+ readonly property string __currentState: [
+ control.checked && "checked",
+ !control.enabled && "disabled",
+ control.enabled && !control.down && control.hovered && "hovered",
+ control.down && "pressed"
+ ].filter(Boolean).join("_") || "normal"
+ readonly property var config: Config.controls.radiobutton[__currentState] || {}
+ readonly property bool mirroredIndicator: control.mirrored !== (config.mirrored || false)
+
+ indicator: Image {
+ x: control.text ? (control.mirroredIndicator ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2
+ y: control.topPadding + (control.availableHeight - height) / 2
+ source: Qt.resolvedUrl(control.config.indicator.filePath)
+ }
+
+ contentItem: Text {
+ leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0
+ rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0
+
+ text: control.text
+ font: control.font
+ color: control.palette.text
+ elide: Text.ElideRight
+ horizontalAlignment: Text.AlignLeft
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ background: StyleImage {
+ imageConfig: control.config.background
+ }
+}