summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrook Cronin <brook.cronin@qt.io>2023-02-21 12:43:21 +0100
committerTim Jenssen <tim.jenssen@qt.io>2023-02-21 20:15:45 +0000
commit596e41b1929328155d95f71ecfbb6c4855a3b7c9 (patch)
treec1cf67da30f3fc0d99cef21c63962e92d482dabe
parent38aa0e3a2cca3191688538c7389ec3de1b20eae3 (diff)
downloadqt-creator-596e41b1929328155d95f71ecfbb6c4855a3b7c9.tar.gz
QmlDesigner: Add double button to material browser
Change-Id: I5dda141374b2804bab009359b1826aea9ba16e31 Reviewed-by: Brook Cronin <brook.cronin@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> (cherry picked from commit 0d8c76e853b8d8becb3b836988089078ff31fd0b) Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml129
1 files changed, 123 insertions, 6 deletions
diff --git a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml
index c749ee03f5..ae9b09ac0a 100644
--- a/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml
+++ b/share/qtcreator/qmldesigner/materialBrowserQmlSource/MaterialBrowser.qml
@@ -373,6 +373,125 @@ Item {
id: ctxMenuTextures
}
+ component DoubleButton: Rectangle {
+ id: doubleButton
+
+ signal clicked()
+
+ property alias icon: iconLabel.text
+ property alias tooltip: mouseArea.tooltip
+
+ property StudioTheme.ControlStyle style: StudioTheme.Values.viewBarButtonStyle
+
+ width: doubleButton.style.squareControlSize.width * 2
+ height: doubleButton.style.squareControlSize.height
+ radius: StudioTheme.Values.smallRadius
+
+ Row {
+ id: contentRow
+ spacing: 0
+
+ Text {
+ id: iconLabel
+ width: doubleButton.style.squareControlSize.width
+ height: doubleButton.height
+ text: StudioTheme.Constants.material_medium
+ font.family: StudioTheme.Constants.iconFont.family
+ font.pixelSize: doubleButton.style.baseIconFontSize
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ Text {
+ id: plusLabel
+ width: doubleButton.style.squareControlSize.width
+ height: doubleButton.height
+ text: StudioTheme.Constants.add_medium
+ font.family: StudioTheme.Constants.iconFont.family
+ font.pixelSize: doubleButton.style.baseIconFontSize
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ }
+ }
+
+ HelperWidgets.ToolTipArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: doubleButton.clicked()
+ }
+
+ states: [
+ State {
+ name: "default"
+ when: doubleButton.enabled && !mouseArea.containsMouse && !mouseArea.pressed
+ PropertyChanges {
+ target: doubleButton
+ color: doubleButton.style.background.idle
+ border.color: doubleButton.style.border.idle
+ }
+ PropertyChanges {
+ target: iconLabel
+ color: doubleButton.style.icon.idle
+ }
+ PropertyChanges {
+ target: plusLabel
+ color: doubleButton.style.icon.idle
+ }
+ },
+ State {
+ name: "hover"
+ when: doubleButton.enabled && mouseArea.containsMouse && !mouseArea.pressed
+ PropertyChanges {
+ target: doubleButton
+ color: doubleButton.style.background.hover
+ border.color: doubleButton.style.border.hover
+ }
+ PropertyChanges {
+ target: iconLabel
+ color: doubleButton.style.icon.hover
+ }
+ PropertyChanges {
+ target: plusLabel
+ color: doubleButton.style.icon.hover
+ }
+ },
+ State {
+ name: "pressed"
+ when: doubleButton.enabled && mouseArea.containsMouse && mouseArea.pressed
+ PropertyChanges {
+ target: doubleButton
+ color: doubleButton.style.interaction
+ border.color: doubleButton.style.interaction
+ }
+ PropertyChanges {
+ target: iconLabel
+ color: doubleButton.style.icon.interaction
+ }
+ PropertyChanges {
+ target: plusLabel
+ color: doubleButton.style.icon.interaction
+ }
+ },
+ State {
+ name: "disable"
+ when: !doubleButton.enabled
+ PropertyChanges {
+ target: doubleButton
+ color: doubleButton.style.background.disabled
+ border.color: doubleButton.style.border.disabled
+ }
+ PropertyChanges {
+ target: iconLabel
+ color: doubleButton.style.icon.disabled
+ }
+ PropertyChanges {
+ target: plusLabel
+ color: doubleButton.style.icon.disabled
+ }
+ }
+ ]
+ }
+
Column {
id: col
spacing: 5
@@ -425,19 +544,17 @@ Item {
height: StudioTheme.Values.toolbarHeight
spacing: 6
- HelperWidgets.AbstractButton {
+ DoubleButton {
id: addMaterial
- style: StudioTheme.Values.viewBarButtonStyle
- buttonIcon: StudioTheme.Constants.material_medium
+ icon: StudioTheme.Constants.material_medium
tooltip: qsTr("Add a Material.")
onClicked: materialBrowserModel.addNewMaterial()
enabled: root.enableUiElements
}
- HelperWidgets.AbstractButton {
+ DoubleButton {
id: addTexture
- style: StudioTheme.Values.viewBarButtonStyle
- buttonIcon: StudioTheme.Constants.textures_medium
+ icon: StudioTheme.Constants.textures_medium
tooltip: qsTr("Add a Texture.")
onClicked: materialBrowserTexturesModel.addNewTexture()
enabled: root.enableUiElements