From da71983891cc6756da85ef757d3fdd1a949d9b48 Mon Sep 17 00:00:00 2001 From: Joey de l'Arago Date: Thu, 17 Nov 2022 14:41:14 +0100 Subject: [PATCH] Make combobox font and padding customizable. Style WorkspaceDialog comboboxes similar to MachineSelector CURA-9424 --- plugins/3MFReader/WorkspaceDialog.qml | 22 ++++++++++++++++++++++ resources/qml/RoundedRectangle.qml | 1 + resources/qml/Widgets/ComboBox.qml | 8 ++++++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index c0128ab4de..cb93aec37e 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -195,6 +195,17 @@ UM.Dialog model: resolveStrategiesModel textRole: "label" visible: manager.qualityChangesConflict + contentLeftPadding: UM.Theme.getSize("default_margin").width + textFont: UM.Theme.getFont("medium") + + background: Cura.RoundedRectangle + { + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("lining") + color: qualityChangesResolveComboBox.hovered ? UM.Theme.getColor("expandable_hover") : UM.Theme.getColor("action_button") + cornerSide: Cura.RoundedRectangle.Direction.All + radius: UM.Theme.getSize("default_radius").width + } // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded currentIndex: @@ -238,6 +249,17 @@ UM.Dialog model: resolveStrategiesModel textRole: "label" visible: manager.materialConflict + contentLeftPadding: UM.Theme.getSize("default_margin").width + textFont: UM.Theme.getFont("medium") + + background: Cura.RoundedRectangle + { + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("lining") + color: materialResolveComboBox.hovered ? UM.Theme.getColor("expandable_hover") : UM.Theme.getColor("action_button") + cornerSide: Cura.RoundedRectangle.Direction.All + radius: UM.Theme.getSize("default_radius").width + } // This is a hack. This will trigger onCurrentIndexChanged and set the index when this component in loaded currentIndex: diff --git a/resources/qml/RoundedRectangle.qml b/resources/qml/RoundedRectangle.qml index 3ca05e2125..86f7214654 100644 --- a/resources/qml/RoundedRectangle.qml +++ b/resources/qml/RoundedRectangle.qml @@ -1,3 +1,4 @@ + import QtQuick 2.7 import UM 1.2 as UM diff --git a/resources/qml/Widgets/ComboBox.qml b/resources/qml/Widgets/ComboBox.qml index 06ac2425bb..efe14497bc 100644 --- a/resources/qml/Widgets/ComboBox.qml +++ b/resources/qml/Widgets/ComboBox.qml @@ -20,6 +20,8 @@ ComboBox property alias textFormat: contentLabel.textFormat property alias backgroundColor: background.color property bool forceHighlight: false + property int contentLeftPadding: UM.Theme.getSize("setting_unit_margin").width + property var textFont: UM.Theme.getFont("default") enabled: delegateModel.count > 0 @@ -104,9 +106,10 @@ ComboBox contentItem: UM.Label { id: contentLabel - leftPadding: UM.Theme.getSize("setting_unit_margin").width + UM.Theme.getSize("default_margin").width + leftPadding: contentLeftPadding + UM.Theme.getSize("default_margin").width anchors.right: downArrow.left wrapMode: Text.NoWrap + font: textFont text: { if (control.delegateModel.count == 0) @@ -176,11 +179,12 @@ ComboBox id: delegateLabel // FIXME: Somehow the top/bottom anchoring is not correct on Linux and it results in invisible texts. anchors.fill: parent - anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width + anchors.leftMargin: contentLeftPadding anchors.rightMargin: UM.Theme.getSize("setting_unit_margin").width text: delegateItem.text textFormat: control.textFormat + font: textFont color: UM.Theme.getColor("setting_control_text") elide: Text.ElideRight wrapMode: Text.NoWrap