Add support for minimizing to system tray on startup
If the user wants to automatically launch NeoChat when the system starts up, the user may also want to minimize the window to system tray on startup. So a new option named "Minimize to system tray on startup" is added. The option is only visible on desktop platforms, and is only enabled when "Close to system tray" is checked. In order to restore window geometry for the first time the user opens the window if the option is checked, 1. a new function named `restoreWindowGeometry` is added, and `restoreWindowGeometryConnections` will be enabled if the option is checked, and will be disabled after the window debuts. 2. `saveWindowGeometryConnections` will be enabled if the option is not checked, and will be disabled if checked and enabled after the window debuts.
This commit is contained in:
43
qml/main.qml
43
qml/main.qml
@@ -22,10 +22,9 @@ Kirigami.ApplicationWindow {
|
||||
minimumWidth: Kirigami.Units.gridUnit * 15
|
||||
minimumHeight: Kirigami.Units.gridUnit * 20
|
||||
|
||||
visible: false // Will be overridden in Component.onCompleted
|
||||
wideScreen: width > columnWidth * 5
|
||||
|
||||
onClosing: Controller.saveWindowGeometry(root)
|
||||
|
||||
pageStack.initialPage: LoadingPage {}
|
||||
pageStack.globalToolBar.canContainHandles: true
|
||||
|
||||
@@ -55,10 +54,17 @@ Kirigami.ApplicationWindow {
|
||||
onTriggered: Controller.saveWindowGeometry(root)
|
||||
}
|
||||
|
||||
onWidthChanged: saveWindowGeometryTimer.restart()
|
||||
onHeightChanged: saveWindowGeometryTimer.restart()
|
||||
onXChanged: saveWindowGeometryTimer.restart()
|
||||
onYChanged: saveWindowGeometryTimer.restart()
|
||||
Connections {
|
||||
id: saveWindowGeometryConnections
|
||||
enabled: false // Disable on startup to avoid writing wrong values if the window is hidden
|
||||
target: root
|
||||
|
||||
function onClosing() { Controller.saveWindowGeometry(root); }
|
||||
function onWidthChanged() { saveWindowGeometryTimer.restart(); }
|
||||
function onHeightChanged() { saveWindowGeometryTimer.restart(); }
|
||||
function onXChanged() { saveWindowGeometryTimer.restart(); }
|
||||
function onYChanged() { saveWindowGeometryTimer.restart(); }
|
||||
}
|
||||
|
||||
Shortcut {
|
||||
sequence: "Ctrl+K"
|
||||
@@ -271,7 +277,15 @@ Kirigami.ApplicationWindow {
|
||||
]
|
||||
}
|
||||
|
||||
Component.onCompleted: Controller.setBlur(pageStack, Config.blur && !Config.compactLayout);
|
||||
Component.onCompleted: {
|
||||
Controller.setBlur(pageStack, Config.blur && !Config.compactLayout);
|
||||
if (Config.minimizeToSystemTrayOnStartup && !Kirigami.Settings.isMobile && Controller.supportSystemTray && Config.systemTray) {
|
||||
restoreWindowGeometryConnections.enabled = true; // To restore window size and position
|
||||
} else {
|
||||
visible = true;
|
||||
saveWindowGeometryConnections.enabled = true;
|
||||
}
|
||||
}
|
||||
Connections {
|
||||
target: Config
|
||||
function onBlurChanged() {
|
||||
@@ -349,6 +363,21 @@ Kirigami.ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
id: restoreWindowGeometryConnections
|
||||
enabled: false
|
||||
target: root
|
||||
|
||||
function onVisibleChanged() {
|
||||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
Controller.restoreWindowGeometry(root);
|
||||
restoreWindowGeometryConnections.enabled = false; // Only restore window geometry for the first time
|
||||
saveWindowGeometryConnections.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: Controller.activeConnection
|
||||
function onDirectChatAvailable(directChat) {
|
||||
|
||||
Reference in New Issue
Block a user