shift-shell/containments/homescreens/folio/qml/private/ContextMenuLoader.qml
Marco Allegretti 8c56409f1c Add pin-to-dock for running apps in convergence mode
Right-click a running task icon to pin the app to the dock
favourites bar. Pinned apps show a "Remove from Dock" action.

The dock overlay renders as a LayerTop window so context menus
and the dock itself stay above application windows. Menus use
popupType Window to avoid clipping inside the narrow dock
surface.
2026-04-11 09:42:21 +02:00

50 lines
1.2 KiB
QML

// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick
import QtQuick.Window
import QtQuick.Layouts
import QtQuick.Templates as T
import org.kde.plasma.components 3.0 as PC3
import org.kde.kirigami as Kirigami
Loader {
id: root
active: false
property list<Kirigami.Action> actions
property int menuPopupType: T.Popup.Item
function open() {
root.active = true;
root.item.open();
}
function close() {
if (root.item) {
root.item.close();
}
}
sourceComponent: PC3.Menu {
id: menu
title: "Context Menu"
popupType: root.menuPopupType
closePolicy: root.menuPopupType === T.Popup.Window
? (PC3.Menu.CloseOnPressOutside | PC3.Menu.CloseOnEscape)
: (PC3.Menu.CloseOnReleaseOutside | PC3.Menu.CloseOnEscape)
Repeater {
model: root.actions
delegate: PC3.MenuItem {
icon.name: modelData.iconName
text: modelData.text
enabled: modelData.enabled
onClicked: modelData.triggered()
}
}
onClosed: root.active = false
}
}