From 5b28748554b3f97c4e163606208878d573f2a655 Mon Sep 17 00:00:00 2001 From: Ali Kianian Date: Tue, 21 Mar 2023 12:05:16 +0200 Subject: [PATCH] QmlDesigner: Consider suffix for Qml ComboBox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QDS-9489 Change-Id: I77b883167db24deea44fa465c297c990a0d56a71 Reviewed-by: Mahmoud Badri Reviewed-by: Henning Gründl --- .../imports/StudioControls/ComboBox.qml | 1 + .../imports/StudioControls/ComboBoxInput.qml | 26 ++++++++++++------- .../StudioControls/TopLevelComboBox.qml | 1 + share/qtcreator/qmldesigner/toolbar/Main.qml | 11 +------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBox.qml index b5a5756fdfe..39b1ac8a1cf 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBox.qml @@ -30,6 +30,7 @@ T.ComboBox { property real __actionIndicatorHeight: control.style.actionIndicatorSize.height property alias textInput: comboBoxInput + property alias suffix: comboBoxInput.suffix property int maximumPopupHeight: control.style.maxComboBoxPopupHeight diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBoxInput.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBoxInput.qml index 93015fe7198..12dd3b1fbc2 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBoxInput.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/ComboBoxInput.qml @@ -15,10 +15,7 @@ TextInput { property bool edit: control.activeFocus property bool hover: mouseArea.containsMouse && control.enabled property bool elidable: false - readonly property real textAdvanceWidth: control.elidable - ? (elidableText.leftPadding - + elidableTextMetrics.advanceWidth) - : control.implicitWidth + property string suffix: "" z: 2 font: control.__parentControl.font @@ -48,15 +45,22 @@ TextInput { verticalAlignment: control.verticalAlignment font: control.font color: control.color - text: control.text + text: control.text + control.suffix visible: control.elidable elide: Text.ElideRight } - TextMetrics { - id: elidableTextMetrics - font: elidableText.font - text: elidableText.text + Text { + id: nonElidableSuffix + anchors.fill: control + leftPadding: control.implicitWidth - control.rightPadding + rightPadding: control.rightPadding + horizontalAlignment: control.horizontalAlignment + verticalAlignment: control.verticalAlignment + font: control.font + color: control.color + text: control.suffix + visible: !control.elidable } Rectangle { @@ -162,6 +166,10 @@ TextInput { target: elidableText visible: false } + PropertyChanges { + target: nonElidableSuffix + visible: false + } PropertyChanges { target: mouseArea cursorShape: Qt.IBeamCursor diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/TopLevelComboBox.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/TopLevelComboBox.qml index dd13ba586b7..1dddfec0b4f 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/TopLevelComboBox.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioControls/TopLevelComboBox.qml @@ -16,6 +16,7 @@ T.ComboBox { property bool edit: false property bool open: window.visible property bool openUpwards: false + property alias suffix: comboBoxInput.suffix editable: false width: control.style.controlSize.width diff --git a/share/qtcreator/qmldesigner/toolbar/Main.qml b/share/qtcreator/qmldesigner/toolbar/Main.qml index 69d85073b1b..3daf50c14b8 100644 --- a/share/qtcreator/qmldesigner/toolbar/Main.qml +++ b/share/qtcreator/qmldesigner/toolbar/Main.qml @@ -238,22 +238,13 @@ Rectangle { anchors.right: annotations.left anchors.rightMargin: 10 model: backend.workspaces + suffix: qsTr(" Workspace") property int currentWorkspaceIndex: workspaces.find(backend.currentWorkspace) onCurrentWorkspaceIndexChanged: workspaces.currentIndex = workspaces.currentWorkspaceIndex visible: !root.flyoutEnabled onActivated: backend.setCurrentWorkspace(workspaces.currentText) - Text { - z: 20 - x: workspaces.contentItem.implicitWidth - - text: qsTr("Workspace") - font: workspaces.font - anchors.verticalCenter: parent.verticalCenter - - color: workspaces.contentItem.color - } } ToolbarButton {