mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 07:03:08 +00:00
halcyon: use the new menu popup
This commit is contained in:
parent
a2f6c51665
commit
a353e87e47
2 changed files with 39 additions and 28 deletions
|
|
@ -52,18 +52,17 @@ Item {
|
|||
// close context menu if drag move
|
||||
onXChanged: {
|
||||
if (dialogLoader.item) {
|
||||
dialogLoader.item.close()
|
||||
dialogLoader.active = false;
|
||||
}
|
||||
}
|
||||
onYChanged: {
|
||||
if (dialogLoader.item) {
|
||||
dialogLoader.item.close()
|
||||
dialogLoader.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openContextMenu() {
|
||||
dialogLoader.active = true;
|
||||
dialogLoader.item.open();
|
||||
}
|
||||
|
||||
function launch() {
|
||||
|
|
@ -91,27 +90,28 @@ Item {
|
|||
application.setMinimizedDelegate(delegate);
|
||||
MobileShell.ShellUtil.launchApp(application.storageId);
|
||||
}
|
||||
|
||||
|
||||
Loader {
|
||||
id: dialogLoader
|
||||
active: false
|
||||
|
||||
sourceComponent: PlasmaComponents.Menu {
|
||||
id: menu
|
||||
sourceComponent: MobileShell.PopupMenu {
|
||||
id: popup
|
||||
|
||||
mappedGlobalCoordinates: delegate.mapToGlobal(delegate.x, delegate.y)
|
||||
relatedTo: delegate
|
||||
|
||||
title: label.text
|
||||
closePolicy: PlasmaComponents.Menu.CloseOnReleaseOutside | PlasmaComponents.Menu.CloseOnEscape
|
||||
|
||||
Repeater {
|
||||
model: menuActions
|
||||
delegate: PlasmaComponents.MenuItem {
|
||||
icon.name: modelData.iconName
|
||||
text: modelData.text
|
||||
onClicked: modelData.triggered()
|
||||
menuActions: delegate.menuActions
|
||||
|
||||
onVisibleChanged: {
|
||||
if (!popup.visible) {
|
||||
dialogLoader.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
onClosed: dialogLoader.active = false
|
||||
}
|
||||
|
||||
onLoaded: item.showOverlay()
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ MouseArea {
|
|||
|
||||
function openContextMenu() {
|
||||
dialogLoader.active = true;
|
||||
dialogLoader.item.open();
|
||||
}
|
||||
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
|
@ -50,24 +49,34 @@ MouseArea {
|
|||
delegate.launch(delegate.x + (PlasmaCore.Units.smallSpacing * 2), delegate.y + (PlasmaCore.Units.smallSpacing * 2), icon.source, application.name, application.storageId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loader {
|
||||
id: dialogLoader
|
||||
active: false
|
||||
|
||||
sourceComponent: PlasmaComponents.Menu {
|
||||
|
||||
sourceComponent: MobileShell.PopupMenu {
|
||||
id: popup
|
||||
|
||||
mappedGlobalCoordinates: icon.mapToGlobal(icon.x, icon.y)
|
||||
relatedTo: icon
|
||||
|
||||
title: label.text
|
||||
closePolicy: PlasmaComponents.Menu.CloseOnReleaseOutside | PlasmaComponents.Menu.CloseOnEscape
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
icon.name: "emblem-favorite"
|
||||
text: i18n("Add to favourites")
|
||||
onClicked: {
|
||||
Halcyon.PinnedModel.addApp(application.storageId, 0);
|
||||
menuActions: [
|
||||
Kirigami.Action {
|
||||
iconName: "emblem-favorite"
|
||||
text: i18n("Add to favourites")
|
||||
onTriggered: Halcyon.PinnedModel.addApp(application.storageId, 0);
|
||||
}
|
||||
]
|
||||
|
||||
onVisibleChanged: {
|
||||
if (!popup.visible) {
|
||||
dialogLoader.active = false;
|
||||
}
|
||||
}
|
||||
onClosed: dialogLoader.active = false
|
||||
}
|
||||
|
||||
onLoaded: item.showOverlay()
|
||||
}
|
||||
|
||||
// grow/shrink animation
|
||||
|
|
@ -124,6 +133,8 @@ MouseArea {
|
|||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: columnLayout
|
||||
|
||||
anchors {
|
||||
fill: parent
|
||||
leftMargin: margins
|
||||
|
|
|
|||
Loading…
Reference in a new issue