2020-09-06 02:06:47 +10:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
|
|
|
import Qt.labs.platform 1.1
|
|
|
|
import Qt.labs.folderlistmodel 2.12
|
|
|
|
|
|
|
|
SystemTrayIcon {
|
|
|
|
property string iconPack: theme ? theme.icons.preferredPack : "thin"
|
|
|
|
property alias settingsFolder: showUpWatcher.folder
|
|
|
|
|
|
|
|
property var window
|
|
|
|
|
|
|
|
property FolderListModel showUpWatcher: FolderListModel {
|
|
|
|
id: showUpWatcher
|
|
|
|
showDirs: false
|
|
|
|
showHidden: true
|
|
|
|
nameFilters: [".show"]
|
|
|
|
|
|
|
|
onCountChanged: {
|
|
|
|
if (count) {
|
|
|
|
window.drawAttention()
|
|
|
|
py.importModule("os", () => {
|
|
|
|
py.call("os.remove", [get(0, "filePath")])
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
visible: true
|
2020-09-06 02:36:09 +10:00
|
|
|
tooltip: Qt.application.displayName
|
2020-09-06 02:06:47 +10:00
|
|
|
icon.source: `../../icons/${iconPack}/tray-icon.png`
|
|
|
|
|
2020-09-06 03:47:50 +10:00
|
|
|
onActivated: {
|
|
|
|
if (reason === SystemTrayIcon.MiddleClick)
|
|
|
|
Qt.quit()
|
|
|
|
else if (reason !== SystemTrayIcon.Context)
|
|
|
|
window.visible ? window.hide() : window.drawAttention()
|
|
|
|
}
|
2020-09-06 02:06:47 +10:00
|
|
|
|
|
|
|
menu: Menu {
|
|
|
|
MenuItem {
|
2020-09-06 02:36:09 +10:00
|
|
|
text:
|
|
|
|
window.visible ?
|
|
|
|
"Minimize to tray" :
|
|
|
|
qsTr("Open ") + Qt.application.displayName
|
2020-09-06 02:06:47 +10:00
|
|
|
onTriggered:
|
|
|
|
window.visible ?
|
|
|
|
window.hide() :
|
|
|
|
window.drawAttention()
|
|
|
|
}
|
|
|
|
|
|
|
|
MenuItem {
|
2020-09-06 02:36:09 +10:00
|
|
|
text: qsTr("Quit ") + Qt.application.displayName
|
2020-09-06 02:06:47 +10:00
|
|
|
onTriggered: Qt.quit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|