mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-21 22:50:14 +03:00
improvements for ComboBoxButton
--centered aligned button text properly and at the same time elide the text when needed in order to not overlap with the combobox down arrow
This commit is contained in:
parent
02c388d2bf
commit
9e9a8428b5
@ -43,6 +43,7 @@ T.ComboBox {
|
||||
wheelEnabled: false
|
||||
|
||||
property bool blankSpaceForEmptyIcons: false
|
||||
property bool forcePressed: false
|
||||
property int minimumPopUpWidth: 150
|
||||
property string iconRole
|
||||
|
||||
@ -206,7 +207,7 @@ T.ComboBox {
|
||||
imagePath: editable ? "widgets/lineedit" : "widgets/button"
|
||||
prefix: editable
|
||||
? "base"
|
||||
: (control.pressed ? "pressed" : "normal")
|
||||
: (control.pressed || control.forcePressed ? "pressed" : "normal")
|
||||
Private.TextFieldFocus {
|
||||
visible: parent.editable
|
||||
z: -1
|
||||
|
@ -43,6 +43,7 @@ PlasmaComponents.Button {
|
||||
|
||||
property bool comboBoxEnabled: true
|
||||
property bool comboBoxBlankSpaceForEmptyIcons: false
|
||||
property bool comboBoxForcePressed: false
|
||||
property int comboBoxMinimumPopUpWidth: 150
|
||||
property string comboBoxTextRole: ""
|
||||
property string comboBoxIconRole: ""
|
||||
@ -56,6 +57,7 @@ PlasmaComponents.Button {
|
||||
textRole: comboBoxTextRole
|
||||
|
||||
blankSpaceForEmptyIcons: comboBoxBlankSpaceForEmptyIcons
|
||||
forcePressed: comboBoxForcePressed
|
||||
|
||||
minimumPopUpWidth: comboBoxMinimumPopUpWidth
|
||||
}
|
||||
@ -74,8 +76,31 @@ PlasmaComponents.Button {
|
||||
width: parent.width - units.iconSizes.medium + 2*units.smallSpacing
|
||||
height: mainComboBox.height
|
||||
|
||||
text: buttonText
|
||||
text: checkable && !labelMetrics.exceeds? "" : buttonText
|
||||
iconSource: buttonIconSource
|
||||
tooltip: buttonToolTip
|
||||
}
|
||||
|
||||
Label{
|
||||
anchors.fill: parent
|
||||
visible: mainButton.checkable && !labelMetrics.exceeds
|
||||
text: buttonText
|
||||
font: mainButton.font
|
||||
color: theme.buttonTextColor
|
||||
|
||||
elide: Text.ElideRight
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Label{
|
||||
id: labelMetrics
|
||||
text: root.buttonText
|
||||
opacity: 0
|
||||
elide: Text.ElideNone
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
||||
readonly property bool exceeds: width>mainButton.width
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ LatteComponents.ComboBoxButton{
|
||||
comboBoxTextRole: "name"
|
||||
comboBoxIconRole: "icon"
|
||||
comboBoxBlankSpaceForEmptyIcons: true
|
||||
comboBoxForcePressed: latteView.indicator.type === type
|
||||
|
||||
property string type: "org.kde.latte.unity"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user