Move tray code to a reasonable place

- Move required properties to top
- Do not use concatenation on qsTr, use .arg()
This commit is contained in:
vslg 2020-09-08 08:35:08 -03:00
parent ae9f88cae5
commit 67012d6334
2 changed files with 7 additions and 6 deletions

View File

@ -1,13 +1,14 @@
// SPDX-License-Identifier: LGPL-3.0-or-later // SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick.Controls 2.12
import Qt.labs.platform 1.1 import Qt.labs.platform 1.1
import Qt.labs.folderlistmodel 2.12 import Qt.labs.folderlistmodel 2.12
SystemTrayIcon { SystemTrayIcon {
property string iconPack: theme ? theme.icons.preferredPack : "thin" property ApplicationWindow window
property alias settingsFolder: showUpWatcher.folder property alias settingsFolder: showUpWatcher.folder
property var window property string iconPack: theme ? theme.icons.preferredPack : "thin"
property FolderListModel showUpWatcher: FolderListModel { property FolderListModel showUpWatcher: FolderListModel {
id: showUpWatcher id: showUpWatcher
@ -28,7 +29,7 @@ SystemTrayIcon {
visible: true visible: true
tooltip: Qt.application.displayName tooltip: Qt.application.displayName
icon.source: `../../icons/${iconPack}/tray-icon.png` icon.source: `../icons/${iconPack}/tray-icon.png`
onActivated: { onActivated: {
if (reason === SystemTrayIcon.MiddleClick) if (reason === SystemTrayIcon.MiddleClick)
@ -42,7 +43,7 @@ SystemTrayIcon {
text: text:
window.visible ? window.visible ?
"Minimize to tray" : "Minimize to tray" :
qsTr("Open ") + Qt.application.displayName qsTr("Open %1").arg(Qt.application.displayName)
onTriggered: onTriggered:
window.visible ? window.visible ?
window.hide() : window.hide() :
@ -50,7 +51,7 @@ SystemTrayIcon {
} }
MenuItem { MenuItem {
text: qsTr("Quit ") + Qt.application.displayName text: qsTr("Quit %1").arg(Qt.application.displayName)
onTriggered: Qt.quit() onTriggered: Qt.quit()
} }
} }

View File

@ -112,7 +112,7 @@ ApplicationWindow {
Behavior on scale { HNumberAnimation { overshoot: 3; factor: 1.2 } } Behavior on scale { HNumberAnimation { overshoot: 3; factor: 1.2 } }
} }
HTrayIcon { TrayIcon {
window: window window: window
settingsFolder: window.settingsFolder settingsFolder: window.settingsFolder
} }