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

QML: Added busyindicator popup when creating a screen

This commit is contained in:
Bumsik Kim 2018-05-07 21:57:57 -04:00
parent b8d9a7dc07
commit d1775042b1
2 changed files with 39 additions and 1 deletions

View file

@ -41,6 +41,9 @@ ApplicationWindow {
timer.interval = delayTime;
timer.repeat = false;
timer.triggered.connect(cb);
timer.triggered.connect(function() {
timer.triggered.disconnect(cb);
});
timer.start();
}
}
@ -140,16 +143,50 @@ ApplicationWindow {
}
Button {
text: "Create a Virtual Display"
id: virtScreenButton
text: "Enable Virtual Screen"
Layout.fillWidth: true
// Material.background: Material.Teal
// Material.foreground: Material.Grey
Popup {
id: busyDialog
modal: true
closePolicy: Popup.NoAutoClose
x: (parent.width - width) / 2
y: (parent.height - height) / 2
BusyIndicator {
x: (parent.width - width) / 2
y: (parent.height - height) / 2
running: true
}
}
onClicked: {
virtScreenButton.enabled = false;
busyDialog.open();
// Give a very short delay to show busyDialog.
timer.setTimeout (function() {
if (!backend.virtScreenCreated) {
backend.createVirtScreen();
} else {
backend.deleteVirtScreen();
}
}, 200);
}
Component.onCompleted: {
backend.virtScreenChanged.connect(function(created) {
busyDialog.close();
virtScreenButton.enabled = true;
if (created) {
virtScreenButton.text = "Disable Virtual Screen"
} else {
virtScreenButton.text = "Enable Virtual Screen"
}
});
}
}
}

View file

@ -350,6 +350,7 @@ class Backend(QObject):
print("Deleting the Virtual Screen...")
if self.vncState != VNCState.OFF.value:
print("Turn off the VNC server first")
self.virtScreenCreated = True
return
self.xrandr.delete_virtual_screen()
self.virtScreenCreated = False