1
0
Fork 0
mirror of https://github.com/kbumsik/VirtScreen.git synced 2025-03-09 15:40:18 +00:00

Added: Open ARandR or Gnome display settings

This commit is contained in:
Bumsik Kim 2018-05-11 22:19:37 -04:00
parent 3c31266c5c
commit b0baf026c5
No known key found for this signature in database
GPG key ID: E31041C8EC5B01C6
2 changed files with 99 additions and 22 deletions

View file

@ -26,10 +26,32 @@ ApplicationWindow {
height: 550
// hide screen when loosing focus
property bool autoClose: true
property bool ignoreCloseOnce: false
onAutoCloseChanged: {
// When setting auto close disabled and then enabled again, we need to
// ignore focus change once. Otherwise the window always is closed one time
// even when the mouse is clicked in the window.
if (!autoClose) {
ignoreCloseOnce = true;
}
}
onActiveFocusItemChanged: {
if ((!activeFocusItem) && (!sysTrayIcon.clicked)) {
if (autoClose && !ignoreCloseOnce && !activeFocusItem && !sysTrayIcon.clicked) {
this.hide();
}
if (ignoreCloseOnce && autoClose) {
ignoreCloseOnce = false;
}
}
// One-shot signal connect
function connectOnce (signal, slot) {
var f = function() {
slot.apply(this, arguments);
signal.disconnect(f);
}
signal.connect(f);
}
// virtscreen.py backend.
@ -262,20 +284,16 @@ ApplicationWindow {
if (!backend.virtScreenCreated) {
backend.createVirtScreen();
} else {
function autoOff() {
console.log("autoOff called here", backend.vncState);
if (backend.vncState == Backend.OFF) {
console.log("Yes. Delete it");
backend.deleteVirtScreen();
backend.vncAutoStart = true;
}
}
// If auto start enabled, stop VNC first then
if (backend.vncAutoStart && (backend.vncState != Backend.OFF)) {
backend.vncAutoStart = false;
backend.onVncStateChanged.connect(autoOff);
backend.onVncStateChanged.connect(function() {
backend.onVncStateChanged.disconnect(autoOff);
connectOnce(backend.onVncStateChanged, function() {
console.log("autoOff called here", backend.vncState);
if (backend.vncState == Backend.OFF) {
console.log("Yes. Delete it");
backend.deleteVirtScreen();
backend.vncAutoStart = true;
}
});
backend.stopVNC();
} else {
@ -291,6 +309,43 @@ ApplicationWindow {
});
}
}
Button {
id: displaySettingButton
text: "Open Display Setting"
anchors.left: parent.left
anchors.right: parent.right
// Material.accent: Material.Teal
// Material.theme: Material.Dark
enabled: backend.virtScreenCreated ? true : false
onClicked: {
busyDialog.open();
window.autoClose = false;
if (backend.vncState != Backend.OFF) {
console.log("vnc is running");
var restoreVNC = true;
if (backend.vncAutoStart) {
backend.vncAutoStart = false;
var restoreAutoStart = true;
}
}
connectOnce(backend.onDisplaySettingClosed, function() {
window.autoClose = true;
busyDialog.close();
if (restoreAutoStart) {
backend.vncAutoStart = true;
}
if (restoreVNC) {
backend.startVNC();
}
});
backend.stopVNC();
backend.openDisplaySetting();
}
}
}
ColumnLayout {