2020-09-24 09:57:54 +10:00
|
|
|
// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
|
2020-09-06 02:06:47 +10:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2020-09-08 21:35:08 +10:00
|
|
|
import QtQuick.Controls 2.12
|
2020-09-06 02:06:47 +10:00
|
|
|
import Qt.labs.platform 1.1
|
|
|
|
import Qt.labs.folderlistmodel 2.12
|
|
|
|
|
|
|
|
SystemTrayIcon {
|
2020-09-08 21:35:08 +10:00
|
|
|
property ApplicationWindow window
|
2020-09-06 02:06:47 +10:00
|
|
|
property alias settingsFolder: showUpWatcher.folder
|
|
|
|
|
2020-09-08 21:35:08 +10:00
|
|
|
property string iconPack: theme ? theme.icons.preferredPack : "thin"
|
2020-09-06 02:06:47 +10:00
|
|
|
|
|
|
|
property FolderListModel showUpWatcher: FolderListModel {
|
|
|
|
id: showUpWatcher
|
|
|
|
showDirs: false
|
|
|
|
showHidden: true
|
|
|
|
nameFilters: [".show"]
|
|
|
|
|
|
|
|
onCountChanged: {
|
|
|
|
if (count) {
|
2020-09-06 04:25:50 +10:00
|
|
|
window.restoreFromTray()
|
2020-09-06 02:06:47 +10:00
|
|
|
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-08 21:35:08 +10:00
|
|
|
icon.source: `../icons/${iconPack}/tray-icon.png`
|
2020-09-06 02:06:47 +10:00
|
|
|
|
2020-09-06 03:47:50 +10:00
|
|
|
onActivated: {
|
|
|
|
if (reason === SystemTrayIcon.MiddleClick)
|
|
|
|
Qt.quit()
|
|
|
|
else if (reason !== SystemTrayIcon.Context)
|
2020-09-06 04:25:50 +10:00
|
|
|
window.visible ? window.hide() : window.restoreFromTray()
|
2020-09-06 03:47:50 +10:00
|
|
|
}
|
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" :
|
2020-09-08 21:35:08 +10:00
|
|
|
qsTr("Open %1").arg(Qt.application.displayName)
|
2020-09-06 02:06:47 +10:00
|
|
|
onTriggered:
|
|
|
|
window.visible ?
|
|
|
|
window.hide() :
|
2020-09-06 04:25:50 +10:00
|
|
|
window.restoreFromTray()
|
2020-09-06 02:06:47 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
MenuItem {
|
2020-09-08 21:35:08 +10:00
|
|
|
text: qsTr("Quit %1").arg(Qt.application.displayName)
|
2020-09-06 02:06:47 +10:00
|
|
|
onTriggered: Qt.quit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|