syncthingtray/plasmoid/package6/contents/ui/TopLevelView.qml

69 lines
1.8 KiB
QML

import QtQuick 2.7
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.kirigami 2.20 as Kirigami
ListView {
boundsBehavior: Flickable.StopAtBounds
interactive: contentHeight > height
keyNavigationEnabled: true
keyNavigationWraps: true
currentIndex: -1
highlightMoveDuration: 0
highlightResizeDuration: 0
highlight: PlasmaExtras.Highlight {
}
topMargin: Kirigami.Units.smallSpacing * 2
bottomMargin: Kirigami.Units.smallSpacing * 2
leftMargin: Kirigami.Units.smallSpacing * 2
rightMargin: Kirigami.Units.smallSpacing * 2
function effectiveWidth() {
return width - leftMargin - rightMargin
}
function activate(index) {
if (typeof contextMenu !== "undefined"
&& contextMenu.status !== PlasmaExtras.Menu.Closed) {
return
}
currentIndex = index
}
function clickCurrentItemButton(buttonName) {
if (!currentItem) {
return
}
var button = currentItem[buttonName]
if (button && button.enabled) {
button.clicked()
}
}
function triggerNativeActionWithCurrentItemData(actionName, fieldName) {
if (!currentItem) {
return
}
const data = currentItem[fieldName]
if (data) {
plasmoid[actionName](data)
}
}
function copyCurrentItemData(fieldName) {
this.triggerNativeActionWithCurrentItemData("copyToClipboard", fieldName)
}
function showContextMenu(item, x, y) {
if (typeof contextMenu === "undefined") {
return
}
if (typeof contextMenu.init !== "undefined") {
contextMenu.init(item)
}
contextMenu.open(x, y)
}
}