mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-03-09 15:40:18 +00:00
QML: Added busyindicator popup when creating a screen
This commit is contained in:
parent
b8d9a7dc07
commit
d1775042b1
2 changed files with 39 additions and 1 deletions
39
main.qml
39
main.qml
|
@ -41,6 +41,9 @@ ApplicationWindow {
|
||||||
timer.interval = delayTime;
|
timer.interval = delayTime;
|
||||||
timer.repeat = false;
|
timer.repeat = false;
|
||||||
timer.triggered.connect(cb);
|
timer.triggered.connect(cb);
|
||||||
|
timer.triggered.connect(function() {
|
||||||
|
timer.triggered.disconnect(cb);
|
||||||
|
});
|
||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,16 +143,50 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: "Create a Virtual Display"
|
id: virtScreenButton
|
||||||
|
text: "Enable Virtual Screen"
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
// Material.background: Material.Teal
|
// Material.background: Material.Teal
|
||||||
// Material.foreground: Material.Grey
|
// 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: {
|
onClicked: {
|
||||||
|
virtScreenButton.enabled = false;
|
||||||
|
busyDialog.open();
|
||||||
|
// Give a very short delay to show busyDialog.
|
||||||
|
timer.setTimeout (function() {
|
||||||
if (!backend.virtScreenCreated) {
|
if (!backend.virtScreenCreated) {
|
||||||
backend.createVirtScreen();
|
backend.createVirtScreen();
|
||||||
} else {
|
} else {
|
||||||
backend.deleteVirtScreen();
|
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"
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,6 +350,7 @@ class Backend(QObject):
|
||||||
print("Deleting the Virtual Screen...")
|
print("Deleting the Virtual Screen...")
|
||||||
if self.vncState != VNCState.OFF.value:
|
if self.vncState != VNCState.OFF.value:
|
||||||
print("Turn off the VNC server first")
|
print("Turn off the VNC server first")
|
||||||
|
self.virtScreenCreated = True
|
||||||
return
|
return
|
||||||
self.xrandr.delete_virtual_screen()
|
self.xrandr.delete_virtual_screen()
|
||||||
self.virtScreenCreated = False
|
self.virtScreenCreated = False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue