1
0
Fork 0
mirror of https://github.com/kbumsik/VirtScreen.git synced 2025-02-14 12:21:50 +00:00

QML: Preven closing the window right after clicking systrayicon

This commit is contained in:
Bumsik Kim 2018-05-09 11:37:02 -04:00
parent 1576ffee49
commit 822891396d
No known key found for this signature in database
GPG key ID: E31041C8EC5B01C6

View file

@ -24,7 +24,7 @@ ApplicationWindow {
// hide screen when loosing focus
onActiveFocusItemChanged: {
if (!activeFocusItem) {
if ((!activeFocusItem) && (!sysTrayIcon.clicked)) {
this.hide();
}
}
@ -298,6 +298,7 @@ ApplicationWindow {
id: sysTrayIcon
iconSource: "icon/icon.png"
visible: true
property bool clicked: false
onMessageClicked: console.log("Message clicked")
Component.onCompleted: {
@ -310,11 +311,13 @@ ApplicationWindow {
}, 7000);
}
onActivated: {
onActivated: function(reason) {
console.log(reason);
if (window.visible) {
window.hide();
return;
}
sysTrayIcon.clicked = true;
// Move window to the corner of the primary display
var width = backend.primaryDisplayWidth;
var height = backend.primaryDisplayHeight;
@ -325,6 +328,9 @@ ApplicationWindow {
window.show();
window.raise();
window.requestActivate();
timer.setTimeout (function() {
sysTrayIcon.clicked = false;
}, 200);
}
menu: Labs.Menu {