1
0
Fork 0
mirror of https://github.com/kbumsik/VirtScreen.git synced 2025-03-09 15:40:18 +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 // hide screen when loosing focus
onActiveFocusItemChanged: { onActiveFocusItemChanged: {
if (!activeFocusItem) { if ((!activeFocusItem) && (!sysTrayIcon.clicked)) {
this.hide(); this.hide();
} }
} }
@ -298,6 +298,7 @@ ApplicationWindow {
id: sysTrayIcon id: sysTrayIcon
iconSource: "icon/icon.png" iconSource: "icon/icon.png"
visible: true visible: true
property bool clicked: false
onMessageClicked: console.log("Message clicked") onMessageClicked: console.log("Message clicked")
Component.onCompleted: { Component.onCompleted: {
@ -310,11 +311,13 @@ ApplicationWindow {
}, 7000); }, 7000);
} }
onActivated: { onActivated: function(reason) {
console.log(reason);
if (window.visible) { if (window.visible) {
window.hide(); window.hide();
return; return;
} }
sysTrayIcon.clicked = true;
// Move window to the corner of the primary display // Move window to the corner of the primary display
var width = backend.primaryDisplayWidth; var width = backend.primaryDisplayWidth;
var height = backend.primaryDisplayHeight; var height = backend.primaryDisplayHeight;
@ -325,6 +328,9 @@ ApplicationWindow {
window.show(); window.show();
window.raise(); window.raise();
window.requestActivate(); window.requestActivate();
timer.setTimeout (function() {
sysTrayIcon.clicked = false;
}, 200);
} }
menu: Labs.Menu { menu: Labs.Menu {