diff --git a/widgets/DapComboBox.qml b/widgets/DapComboBox.qml index d5203e5b2587279166f3b2ebadbd163ffd92c878..a15a54f7a03163b65310f427c14e7a34e07a9fc7 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 a46345d84162cf0325258b7866055f29efdf3ba1..273913a2170d364ad1966cfcc652992b11b5c2b5 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.