mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-03-09 15:40:18 +00:00
QML: Auto start support. Better footbar text
This commit is contained in:
parent
3a76aa7ef7
commit
b51ad567bb
2 changed files with 72 additions and 18 deletions
85
main.qml
85
main.qml
|
@ -21,7 +21,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
property int margin: 11
|
property int margin: 11
|
||||||
width: 380
|
width: 380
|
||||||
height: 600
|
height: 500
|
||||||
|
|
||||||
// hide screen when loosing focus
|
// hide screen when loosing focus
|
||||||
onActiveFocusItemChanged: {
|
onActiveFocusItemChanged: {
|
||||||
|
@ -34,9 +34,20 @@ ApplicationWindow {
|
||||||
Backend {
|
Backend {
|
||||||
id: backend
|
id: backend
|
||||||
}
|
}
|
||||||
|
property bool vncAutoStart: false
|
||||||
|
|
||||||
DisplayProperty {
|
function switchVNC(value) {
|
||||||
id: display
|
if (value) {
|
||||||
|
backend.startVNC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onVncAutoStartChanged: {
|
||||||
|
if (vncAutoStart) {
|
||||||
|
backend.onVirtScreenCreatedChanged.connect(switchVNC);
|
||||||
|
} else {
|
||||||
|
backend.onVirtScreenCreatedChanged.disconnect(switchVNC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timer object and function
|
// Timer object and function
|
||||||
|
@ -149,7 +160,7 @@ ApplicationWindow {
|
||||||
id: deviceComboBox
|
id: deviceComboBox
|
||||||
anchors.left: deviceLabel.right
|
anchors.left: deviceLabel.right
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.leftMargin: 120
|
anchors.leftMargin: 100
|
||||||
|
|
||||||
textRole: "name"
|
textRole: "name"
|
||||||
model: backend.screens
|
model: backend.screens
|
||||||
|
@ -179,7 +190,8 @@ ApplicationWindow {
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
// Material.background: Material.Teal
|
// Material.background: Material.Teal
|
||||||
// Material.foreground: Material.Grey
|
// Material.foreground: Material.Grey
|
||||||
enabled: backend.vncState == Backend.OFF ? true : false
|
enabled: window.vncAutoStart ? true :
|
||||||
|
backend.vncState == Backend.OFF ? true : false
|
||||||
|
|
||||||
Popup {
|
Popup {
|
||||||
id: busyDialog
|
id: busyDialog
|
||||||
|
@ -203,8 +215,24 @@ ApplicationWindow {
|
||||||
if (!backend.virtScreenCreated) {
|
if (!backend.virtScreenCreated) {
|
||||||
backend.createVirtScreen();
|
backend.createVirtScreen();
|
||||||
} else {
|
} else {
|
||||||
|
function autoOff() {
|
||||||
|
console.log("autoOff called here", backend.vncState);
|
||||||
|
if (backend.vncState == Backend.OFF) {
|
||||||
|
console.log("Yes. Delete it");
|
||||||
backend.deleteVirtScreen();
|
backend.deleteVirtScreen();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.vncAutoStart && (backend.vncState != Backend.OFF)) {
|
||||||
|
backend.onVncStateChanged.connect(autoOff);
|
||||||
|
backend.onVncStateChanged.connect(function() {
|
||||||
|
backend.onVncStateChanged.disconnect(autoOff);
|
||||||
|
});
|
||||||
|
backend.stopVNC();
|
||||||
|
} else {
|
||||||
|
backend.deleteVirtScreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,6 +255,8 @@ ApplicationWindow {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
enabled: backend.vncState == Backend.OFF ? true : false
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
@ -271,14 +301,35 @@ ApplicationWindow {
|
||||||
id: vncButton
|
id: vncButton
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
anchors.bottomMargin: 0
|
||||||
|
|
||||||
text: backend.vncState == Backend.OFF ? "Start VNC Server" : "Stop VNC Server"
|
text: window.vncAutoStart ? "Auto start enabled" :
|
||||||
enabled: backend.virtScreenCreated ? true : false
|
backend.vncState == Backend.OFF ? "Start VNC Server" : "Stop VNC Server"
|
||||||
|
enabled: window.vncAutoStart ? false :
|
||||||
|
backend.virtScreenCreated ? true : false
|
||||||
// Material.background: Material.Teal
|
// Material.background: Material.Teal
|
||||||
// Material.foreground: Material.Grey
|
// Material.foreground: Material.Grey
|
||||||
onClicked: backend.vncState == Backend.OFF ? backend.startVNC() : backend.stopVNC()
|
onClicked: backend.vncState == Backend.OFF ? backend.startVNC() : backend.stopVNC()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
anchors.top: vncButton.top
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.topMargin: vncButton.height - 10
|
||||||
|
|
||||||
|
Label { text: "Auto start"; }
|
||||||
|
Switch {
|
||||||
|
checked: window.vncAutoStart
|
||||||
|
onCheckedChanged: {
|
||||||
|
if ((checked == true) && (backend.vncState == Backend.OFF) &&
|
||||||
|
backend.virtScreenCreated) {
|
||||||
|
backend.startVNC();
|
||||||
|
}
|
||||||
|
window.vncAutoStart = checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
// width: 180;
|
// width: 180;
|
||||||
height: 200
|
height: 200
|
||||||
|
@ -294,24 +345,24 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
footer: ToolBar {
|
footer: ToolBar {
|
||||||
|
font.weight: Font.Medium
|
||||||
|
font.pointSize: 11 //parent.font.pointSize + 1
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.margins: margin
|
anchors.leftMargin: margin + 10
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: vncStateLabel
|
id: vncStateLabel
|
||||||
text: backend.vncState == Backend.OFF ? "Off" :
|
text: !backend.virtScreenCreated ? "Enable Virtual Screen first." :
|
||||||
backend.vncState == Backend.WAITING ? "Waiting" :
|
backend.vncState == Backend.OFF ? "Turn on VNC Server in the VNC tab." :
|
||||||
backend.vncState == Backend.CONNECTED ? "Connected" :
|
backend.vncState == Backend.WAITING ? "VNC Server is waiting for a client..." :
|
||||||
|
backend.vncState == Backend.CONNECTED ? "Connected." :
|
||||||
"Server state error!"
|
"Server state error!"
|
||||||
}
|
}
|
||||||
Item { Layout.fillWidth: true }
|
|
||||||
CheckBox {
|
|
||||||
id: enabler
|
|
||||||
text: "Server Enabled"
|
|
||||||
checked: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -467,6 +467,9 @@ class Backend(QObject):
|
||||||
if not self.virtScreenCreated:
|
if not self.virtScreenCreated:
|
||||||
print("Virtual Screen not crated.")
|
print("Virtual Screen not crated.")
|
||||||
return
|
return
|
||||||
|
if self.vncState is not Backend.VNCState.OFF:
|
||||||
|
print("VNC Server is already running.")
|
||||||
|
return
|
||||||
# regex used in callbacks
|
# regex used in callbacks
|
||||||
re_connection = re.compile(r"^.*Got connection from client.*$", re.M)
|
re_connection = re.compile(r"^.*Got connection from client.*$", re.M)
|
||||||
# define callbacks
|
# define callbacks
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue