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

QML: Auto start when VNC closed by client

This commit is contained in:
Bumsik Kim 2018-05-11 12:53:14 -04:00
parent be5e4da1aa
commit 859044c6eb
No known key found for this signature in database
GPG key ID: E31041C8EC5B01C6

View file

@ -38,8 +38,8 @@ ApplicationWindow {
} }
property bool vncAutoStart: false property bool vncAutoStart: false
function switchVNC(value) { function switchVNC () {
if (value) { if ((backend.vncState == Backend.OFF) && backend.virtScreenCreated) {
backend.startVNC(); backend.startVNC();
} }
} }
@ -47,8 +47,10 @@ ApplicationWindow {
onVncAutoStartChanged: { onVncAutoStartChanged: {
if (vncAutoStart) { if (vncAutoStart) {
backend.onVirtScreenCreatedChanged.connect(switchVNC); backend.onVirtScreenCreatedChanged.connect(switchVNC);
backend.onVncStateChanged.connect(switchVNC);
} else { } else {
backend.onVirtScreenCreatedChanged.disconnect(switchVNC); backend.onVirtScreenCreatedChanged.disconnect(switchVNC);
backend.onVncStateChanged.disconnect(switchVNC);
} }
} }
@ -91,10 +93,7 @@ ApplicationWindow {
font.pointSize: 11 //parent.font.pointSize + 1 font.pointSize: 11 //parent.font.pointSize + 1
RowLayout { RowLayout {
anchors.top: parent.top anchors.fill: parent
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: margin + 10 anchors.leftMargin: margin + 10
Label { Label {
@ -124,15 +123,8 @@ ApplicationWindow {
y: (parent.height - height) / 2 y: (parent.height - height) / 2
BusyIndicator { BusyIndicator {
anchors.top: parent.top anchors.fill: parent
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
Material.accent: Material.Cyan Material.accent: Material.Cyan
x: (parent.width - width) / 2
y: (parent.height - height) / 2
running: true running: true
} }
@ -149,10 +141,7 @@ ApplicationWindow {
currentIndex: tabBar.currentIndex currentIndex: tabBar.currentIndex
ColumnLayout { ColumnLayout {
anchors.top: parent.top anchors.fill: parent
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: margin anchors.margins: margin
GroupBox { GroupBox {
@ -273,10 +262,12 @@ ApplicationWindow {
if (backend.vncState == Backend.OFF) { if (backend.vncState == Backend.OFF) {
console.log("Yes. Delete it"); console.log("Yes. Delete it");
backend.deleteVirtScreen(); backend.deleteVirtScreen();
window.vncAutoStart = true;
} }
} }
if (window.vncAutoStart && (backend.vncState != Backend.OFF)) { if (window.vncAutoStart && (backend.vncState != Backend.OFF)) {
window.vncAutoStart = false;
backend.onVncStateChanged.connect(autoOff); backend.onVncStateChanged.connect(autoOff);
backend.onVncStateChanged.connect(function() { backend.onVncStateChanged.connect(function() {
backend.onVncStateChanged.disconnect(autoOff); backend.onVncStateChanged.disconnect(autoOff);
@ -298,10 +289,7 @@ ApplicationWindow {
} }
ColumnLayout { ColumnLayout {
anchors.top: parent.top anchors.fill: parent
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: margin anchors.margins: margin
GroupBox { GroupBox {