From 69c900e0a6443571efe8281dc82238bcade25eef Mon Sep 17 00:00:00 2001 From: "tatiana.novikova" <tatiana.novikova@demlabs.net> Date: Tue, 14 Jan 2020 16:33:54 +0300 Subject: [PATCH] [*] Update calculating and deleting the unnecessary part of text at comboBox [-] Delete unused property --- widgets/DapComboBox.qml | 23 +++++++++++++++++++++-- widgets/DapComboBoxForm.ui.qml | 12 ++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/widgets/DapComboBox.qml b/widgets/DapComboBox.qml index d5203e5..a15a54f 100644 --- a/widgets/DapComboBox.qml +++ b/widgets/DapComboBox.qml @@ -44,16 +44,35 @@ DapComboBoxForm if(index != currentIndex) return widthPopupComboBoxActive - 2*sidePaddingActive; else - return widthPopupComboBoxNormal - indicatorWidth ; + return widthPopupComboBoxNormal - indicatorWidth - indicatorLeftInterval; } } + FontMetrics + { + id: fm + font: dapComboBox.font + } text: { if(index != currentIndex) + { + console.log(fm.tightBoundingRect("le").width); + if(tm.elidedText.length < tm.text.length) + return tm.elidedText.substring(0, tm.elidedText.length-1) + + ((fm.tightBoundingRect(tm.elidedText.substring(0, tm.elidedText.length-1)).width + fm.tightBoundingRect(tm.text.charAt(tm.elidedText.length-1) + '..').width) < tm.elideWidth ? + (tm.text.charAt(tm.elidedText.length-1) + '..') + : '..'); return tm.elidedText.replace('…', '..'); + } else { - mainLineText = tm.elidedText.replace('…', '..'); + if(tm.elidedText.length < tm.text.length) + mainLineText = tm.elidedText.substring(0, tm.elidedText.length-1) + + ((fm.tightBoundingRect(tm.elidedText.substring(0, tm.elidedText.length-1)).width + fm.tightBoundingRect(tm.text.charAt(tm.elidedText.length-1) + '..').width) < tm.elideWidth ? + (tm.text.charAt(tm.elidedText.length-1) + '..') + : '..'); + else + mainLineText = tm.elidedText.replace('…', '..'); return ""; } } diff --git a/widgets/DapComboBoxForm.ui.qml b/widgets/DapComboBoxForm.ui.qml index a46345d..273913a 100644 --- a/widgets/DapComboBoxForm.ui.qml +++ b/widgets/DapComboBoxForm.ui.qml @@ -33,18 +33,8 @@ ComboBox property int sidePaddingNormal ///@detalis sidePaddingActive Sets the indent from the edge of the right and left edges of the parent in the active state. property int sidePaddingActive - ///@detalis topIndentNormal Sets the indent from the edge of the upper of the parent in the normal state. - property int topIndentNormal - ///@detalis topIndentActive Sets the indent from the edge of the upper of the parent in the active state. - property int topIndentActive - ///@detalis bottomIndentNormal Sets the indent from the edge of the lower of the parent in the normal state. - property int bottomIndentNormal - ///@detalis bottomIndentActive Sets the indent from the edge of the lower of the parent in the active state. - property int bottomIndentActive ///@detalis paddingTopItemDelegate Indent above from item delegate. property int paddingTopItemDelegate - ///@detalis paddingBottomItemDelegate Indent below from item delegate. - property int paddingBottomItemDelegate ///@detalis heightListElement List item height. property int heightListElement ///@detalis intervalListElement Spacing between items in a list. @@ -61,6 +51,8 @@ ComboBox property int indicatorWidth ///@detalis indicatorHeight Indicator height. property int indicatorHeight + ///@detalis indicatorLeftInterval Space between indicator border and text border + property int indicatorLeftInterval /// colorTopNormalDropShadow Color of the shadow effect of the combo box when minimized. property string colorTopNormalDropShadow ///@detalis colorDropShadow Unboxed shadow color in expanded state. -- GitLab