QmlDesigner: Consider suffix for Qml ComboBox

Task-number: QDS-9489
Change-Id: I77b883167db24deea44fa465c297c990a0d56a71
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Ali Kianian
2023-03-21 12:05:16 +02:00
parent b9b2121ae1
commit 5b28748554
4 changed files with 20 additions and 19 deletions

View File

@@ -30,6 +30,7 @@ T.ComboBox {
property real __actionIndicatorHeight: control.style.actionIndicatorSize.height property real __actionIndicatorHeight: control.style.actionIndicatorSize.height
property alias textInput: comboBoxInput property alias textInput: comboBoxInput
property alias suffix: comboBoxInput.suffix
property int maximumPopupHeight: control.style.maxComboBoxPopupHeight property int maximumPopupHeight: control.style.maxComboBoxPopupHeight

View File

@@ -15,10 +15,7 @@ TextInput {
property bool edit: control.activeFocus property bool edit: control.activeFocus
property bool hover: mouseArea.containsMouse && control.enabled property bool hover: mouseArea.containsMouse && control.enabled
property bool elidable: false property bool elidable: false
readonly property real textAdvanceWidth: control.elidable property string suffix: ""
? (elidableText.leftPadding
+ elidableTextMetrics.advanceWidth)
: control.implicitWidth
z: 2 z: 2
font: control.__parentControl.font font: control.__parentControl.font
@@ -48,15 +45,22 @@ TextInput {
verticalAlignment: control.verticalAlignment verticalAlignment: control.verticalAlignment
font: control.font font: control.font
color: control.color color: control.color
text: control.text text: control.text + control.suffix
visible: control.elidable visible: control.elidable
elide: Text.ElideRight elide: Text.ElideRight
} }
TextMetrics { Text {
id: elidableTextMetrics id: nonElidableSuffix
font: elidableText.font anchors.fill: control
text: elidableText.text 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 { Rectangle {
@@ -162,6 +166,10 @@ TextInput {
target: elidableText target: elidableText
visible: false visible: false
} }
PropertyChanges {
target: nonElidableSuffix
visible: false
}
PropertyChanges { PropertyChanges {
target: mouseArea target: mouseArea
cursorShape: Qt.IBeamCursor cursorShape: Qt.IBeamCursor

View File

@@ -16,6 +16,7 @@ T.ComboBox {
property bool edit: false property bool edit: false
property bool open: window.visible property bool open: window.visible
property bool openUpwards: false property bool openUpwards: false
property alias suffix: comboBoxInput.suffix
editable: false editable: false
width: control.style.controlSize.width width: control.style.controlSize.width

View File

@@ -238,22 +238,13 @@ Rectangle {
anchors.right: annotations.left anchors.right: annotations.left
anchors.rightMargin: 10 anchors.rightMargin: 10
model: backend.workspaces model: backend.workspaces
suffix: qsTr(" Workspace")
property int currentWorkspaceIndex: workspaces.find(backend.currentWorkspace) property int currentWorkspaceIndex: workspaces.find(backend.currentWorkspace)
onCurrentWorkspaceIndexChanged: workspaces.currentIndex = workspaces.currentWorkspaceIndex onCurrentWorkspaceIndexChanged: workspaces.currentIndex = workspaces.currentWorkspaceIndex
visible: !root.flyoutEnabled visible: !root.flyoutEnabled
onActivated: backend.setCurrentWorkspace(workspaces.currentText) 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 { ToolbarButton {