aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2023-10-30 16:28:07 +0800
committerMitch Curtis <mitch.curtis@qt.io>2023-11-01 21:45:06 +0800
commita7a39cce2ac3b3dd804be43172bdca9dd4c66a50 (patch)
tree30a68c3ea2d228502ed95cde5bfdb55410a939a4
parentc4591ceea11092a6f96e382a3c08ae06e9f6d20c (diff)
Windows: add ItemDelegate
Task-number: QTBUG-115165 Change-Id: Ibc4fd7b1f85a47a9bfec3a4900e351ea61bcc7ae Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r--src/quickcontrols/macos/ItemDelegate.qml31
-rw-r--r--src/quickcontrols/windows/CMakeLists.txt1
-rw-r--r--src/quickcontrols/windows/ItemDelegate.qml10
-rw-r--r--src/quicknativestyle/CMakeLists.txt1
-rw-r--r--src/quicknativestyle/controls/DefaultItemDelegate.qml36
-rw-r--r--tests/auto/quickcontrols/customization/tst_customization.cpp2
6 files changed, 50 insertions, 31 deletions
diff --git a/src/quickcontrols/macos/ItemDelegate.qml b/src/quickcontrols/macos/ItemDelegate.qml
index 61a2d8c5c9..e73f19c12f 100644
--- a/src/quickcontrols/macos/ItemDelegate.qml
+++ b/src/quickcontrols/macos/ItemDelegate.qml
@@ -1,35 +1,6 @@
// Copyright (C) 2023 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.NativeStyle as NativeStyle
-T.ItemDelegate {
- id: control
-
- readonly property bool __notCustomizable: true
-
- implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
- implicitContentWidth + leftPadding + rightPadding)
- implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
- implicitContentHeight + topPadding + bottomPadding,
- implicitIndicatorHeight + topPadding + bottomPadding)
-
- padding: 6
- spacing: 6
-
- icon.width: 16
- icon.height: 16
-
- contentItem: NativeStyle.DefaultItemDelegateIconLabel {}
-
- background: Rectangle {
- implicitWidth: 100
- implicitHeight: 20
- color: Qt.darker(control.highlighted
- ? control.palette.highlight : control.palette.button, control.down ? 1.05 : 1)
-
- readonly property bool __ignoreNotCustomizable: true
- }
-}
+NativeStyle.DefaultItemDelegate {}
diff --git a/src/quickcontrols/windows/CMakeLists.txt b/src/quickcontrols/windows/CMakeLists.txt
index 27e712d199..6b55882c33 100644
--- a/src/quickcontrols/windows/CMakeLists.txt
+++ b/src/quickcontrols/windows/CMakeLists.txt
@@ -14,6 +14,7 @@ set(qml_files
"DelayButton.qml"
"Frame.qml"
"GroupBox.qml"
+ "ItemDelegate.qml"
"ProgressBar.qml"
"RadioButton.qml"
"RangeSlider.qml"
diff --git a/src/quickcontrols/windows/ItemDelegate.qml b/src/quickcontrols/windows/ItemDelegate.qml
new file mode 100644
index 0000000000..879c4532ec
--- /dev/null
+++ b/src/quickcontrols/windows/ItemDelegate.qml
@@ -0,0 +1,10 @@
+// Copyright (C) 2023 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.NativeStyle as NativeStyle
+
+NativeStyle.DefaultItemDelegate {
+ contentItem: NativeStyle.DefaultItemDelegateIconLabel {
+ color: control.highlighted ? control.palette.button : control.palette.windowText
+ }
+}
diff --git a/src/quicknativestyle/CMakeLists.txt b/src/quicknativestyle/CMakeLists.txt
index 0217e78424..7fade6ae72 100644
--- a/src/quicknativestyle/CMakeLists.txt
+++ b/src/quicknativestyle/CMakeLists.txt
@@ -12,6 +12,7 @@ set(qml_files
"controls/DefaultDial.qml"
"controls/DefaultFrame.qml"
"controls/DefaultGroupBox.qml"
+ "controls/DefaultItemDelegate.qml"
"controls/DefaultItemDelegateIconLabel.qml"
"controls/DefaultProgressBar.qml"
"controls/DefaultRadioButton.qml"
diff --git a/src/quicknativestyle/controls/DefaultItemDelegate.qml b/src/quicknativestyle/controls/DefaultItemDelegate.qml
new file mode 100644
index 0000000000..bce6b10da7
--- /dev/null
+++ b/src/quicknativestyle/controls/DefaultItemDelegate.qml
@@ -0,0 +1,36 @@
+// Copyright (C) 2023 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
+import QtQuick.NativeStyle as NativeStyle
+
+T.ItemDelegate {
+ id: control
+
+ readonly property bool __notCustomizable: true
+
+ implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ implicitContentWidth + leftPadding + rightPadding)
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding,
+ implicitIndicatorHeight + topPadding + bottomPadding)
+
+ padding: 6
+ spacing: 6
+
+ icon.width: 16
+ icon.height: 16
+
+ contentItem: NativeStyle.DefaultItemDelegateIconLabel {}
+
+ background: Rectangle {
+ implicitWidth: 100
+ implicitHeight: 20
+ color: Qt.darker(control.highlighted
+ ? control.palette.highlight : control.palette.button, control.down ? 1.05 : 1)
+
+ readonly property bool __ignoreNotCustomizable: true
+ }
+}
diff --git a/tests/auto/quickcontrols/customization/tst_customization.cpp b/tests/auto/quickcontrols/customization/tst_customization.cpp
index fcc8f0bb9a..e3483721fb 100644
--- a/tests/auto/quickcontrols/customization/tst_customization.cpp
+++ b/tests/auto/quickcontrols/customization/tst_customization.cpp
@@ -375,7 +375,7 @@ void tst_customization::override_data()
"Windows",
{
"Button", "CheckBox", "CheckDelegate", "ComboBox", "DelayButton", "Frame", "GroupBox",
- "ProgressBar", "RadioButton", "RangeSlider", "SelectionRectangle",
+ "ItemDelegate", "ProgressBar", "RadioButton", "RangeSlider", "SelectionRectangle",
"ScrollBar", "Slider", "SpinBox", "Switch", "TextArea", "TextField"
}
}