forked from qt-creator/qt-creator
QmlDesigner: Fix long expression pill texts
* Elide static texts * Clip dynamic texts Change-Id: I90a511ec6dd35d2b65f4064bc09c0a83e8d1e905 Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
e0441a9aec
commit
2a135f5d14
@@ -306,6 +306,7 @@ Rectangle {
|
|||||||
id: pill
|
id: pill
|
||||||
|
|
||||||
operatorModel: __operatorModel
|
operatorModel: __operatorModel
|
||||||
|
maxTextWidth: root.width - 2 * StudioTheme.Values.flowMargin
|
||||||
|
|
||||||
onRemove: function() {
|
onRemove: function() {
|
||||||
// If pill has focus due to selection or keyboard navigation
|
// If pill has focus due to selection or keyboard navigation
|
||||||
|
@@ -36,6 +36,8 @@ FocusScope {
|
|||||||
property bool hovered: rootMouseArea.containsMouse
|
property bool hovered: rootMouseArea.containsMouse
|
||||||
property bool selected: root.focus
|
property bool selected: root.focus
|
||||||
|
|
||||||
|
property int maxTextWidth: 600
|
||||||
|
|
||||||
width: row.width
|
width: row.width
|
||||||
height: StudioTheme.Values.flowPillHeight
|
height: StudioTheme.Values.flowPillHeight
|
||||||
|
|
||||||
@@ -111,10 +113,23 @@ FocusScope {
|
|||||||
leftPadding: root.margin
|
leftPadding: root.margin
|
||||||
rightPadding: icon.visible ? 0 : root.margin
|
rightPadding: icon.visible ? 0 : root.margin
|
||||||
|
|
||||||
|
property int textWidth: Math.min(textMetrics.width,
|
||||||
|
root.maxTextWidth - row.leftPadding
|
||||||
|
- (icon.visible ? icon.width : root.margin))
|
||||||
|
|
||||||
|
TextMetrics {
|
||||||
|
id: textMetrics
|
||||||
|
text: textItem.visible ? textItem.text : textInput.text
|
||||||
|
font: textItem.font
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: textItem
|
id: textItem
|
||||||
|
width: row.textWidth
|
||||||
height: StudioTheme.Values.flowPillHeight
|
height: StudioTheme.Values.flowPillHeight
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
elide: Text.ElideMiddle
|
||||||
font.pixelSize: StudioTheme.Values.baseFontSize
|
font.pixelSize: StudioTheme.Values.baseFontSize
|
||||||
color: root.isShadow() ? StudioTheme.Values.themePillTextSelected
|
color: root.isShadow() ? StudioTheme.Values.themePillTextSelected
|
||||||
: StudioTheme.Values.themePillText
|
: StudioTheme.Values.themePillText
|
||||||
@@ -125,10 +140,11 @@ FocusScope {
|
|||||||
|
|
||||||
TextInput {
|
TextInput {
|
||||||
id: textInput
|
id: textInput
|
||||||
|
|
||||||
x: root.isInvalid() ? root.margin : 0
|
x: root.isInvalid() ? root.margin : 0
|
||||||
|
width: row.textWidth
|
||||||
height: StudioTheme.Values.flowPillHeight
|
height: StudioTheme.Values.flowPillHeight
|
||||||
topPadding: 1
|
topPadding: 1
|
||||||
|
clip: true
|
||||||
font.pixelSize: StudioTheme.Values.baseFontSize
|
font.pixelSize: StudioTheme.Values.baseFontSize
|
||||||
color: {
|
color: {
|
||||||
if (root.isIntermediate())
|
if (root.isIntermediate())
|
||||||
|
Reference in New Issue
Block a user