syncthingtray/plasmoid/package/contents/ui/TopLevelView.qml
Martchus 419e2971c1 plasmoid: Add context menu for top-level list views
Might be useful to add further actions because the
space for buttons is limited.
2018-03-26 22:56:55 +02:00

46 lines
1.1 KiB
QML

import QtQuick 2.7
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.components 2.0 as PlasmaComponents
ListView {
anchors.fill: parent
boundsBehavior: Flickable.StopAtBounds
interactive: contentHeight > height
keyNavigationEnabled: true
keyNavigationWraps: true
currentIndex: -1
highlightMoveDuration: 0
highlightResizeDuration: 0
highlight: PlasmaComponents.Highlight {
}
function activate(index) {
if (typeof contextMenu !== "undefined"
&& contextMenu.status !== PlasmaComponents.DialogStatus.Closed) {
return
}
currentIndex = index
}
function clickCurrentItemButton(buttonName) {
if (!currentItem) {
return
}
var button = currentItem[buttonName]
if (button && button.enabled) {
button.clicked()
}
}
function showContextMenu(item, x, y) {
if (typeof contextMenu === "undefined") {
return
}
if (typeof contextMenu.init !== "undefined") {
contextMenu.init(item)
}
contextMenu.open(x, y)
}
}