1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-03-06 16:58:17 +03:00

make view actions menu to act as Menu shower/hider

This commit is contained in:
Michail Vourlakos 2021-02-27 19:24:27 +02:00
parent f6e7a64800
commit a57e2c37fe
2 changed files with 24 additions and 8 deletions

View File

@ -42,6 +42,7 @@ Rectangle {
property bool buttonEnabled: true
property bool buttonIsTransparent: false
property bool buttonIsTriggeringMenu: false
property string buttonText:""
property string buttonIconSource:""
property string buttonToolTip: ""
@ -77,7 +78,7 @@ Rectangle {
anchors.right: Qt.application.layoutDirection === Qt.RightToLeft ? parent.right : undefined
LayoutMirroring.enabled: false
enabled: buttonEnabled
checked: root.checked
checked: root.checked || (buttonIsTriggeringMenu && mainComboBox.popup.visible)
visible: buttonIsTransparent ? 0 : 1
/*workaround in order to replicate the proper Buttons Exclusive Group Behavior*/
@ -91,6 +92,25 @@ Rectangle {
text: root.checkable ? " " : buttonText
iconSource: buttonIconSource
tooltip: buttonToolTip
onClicked: {
if (buttonIsTriggeringMenu) {
//! hiding combobox is triggered by default behavior
mainComboBox.popup.visible = !mainComboBox.popup.visible;
mainComboBox.down = mainComboBox.popup.visible;
mainComboBox.pressed = mainComboBox.popup.visible;
}
}
//! WORKAROUND in order to miss one Clicked event from parent button,
//! when combobox menu is shown and the user clicks the button in order to hide
//! menu, this is enough in order to be dismissed. Without the workaround
//! the menu is reshown because the Clicked event is triggered after
//! the menu became hidden
MouseArea {
anchors.fill: parent
visible: parent.enabled && buttonIsTriggeringMenu && mainComboBox.popup.visible
}
}
//overlayed combobox

View File

@ -512,9 +512,10 @@ Loader {
implicitHeight: removeView.implicitHeight
buttonEnabled: true
buttonText: i18n("New Dock")
buttonIsTriggeringMenu: true
buttonText: i18n("New")
buttonIconSource: "list-add"
buttonToolTip: i18n("Add a new dock")
buttonToolTip: i18n("Add new docks and panels from various templates")
comboBoxEnabled: true
comboBoxBlankSpaceForEmptyIcons: true
@ -565,11 +566,6 @@ Loader {
}
}
Connections{
target: actionsComboBtn.button
onClicked: latteView.layout.newView(layoutsManager.viewTemplateIds()[0])
}
Connections{
target: latteView
onTypeChanged: actionsComboBtn.updateCopyText();