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:
parent
1576ffee49
commit
822891396d
1 changed files with 8 additions and 2 deletions
10
main.qml
10
main.qml
|
@ -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 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue