mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-03-09 15:40:18 +00:00
Selectable x11vnc options in QML
This commit is contained in:
parent
b2a54b7b87
commit
7f3448a25e
8 changed files with 124 additions and 9 deletions
|
@ -277,6 +277,17 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: vncOptionsLoader
|
||||||
|
active: false
|
||||||
|
source: "VncOptionsDialog.qml"
|
||||||
|
onLoaded: {
|
||||||
|
item.onClosed.connect(function() {
|
||||||
|
vncOptionsLoader.active = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SwipeView {
|
SwipeView {
|
||||||
anchors.top: tabBar.bottom
|
anchors.top: tabBar.bottom
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
|
@ -109,7 +109,7 @@ ColumnLayout {
|
||||||
window.autoClose = false;
|
window.autoClose = false;
|
||||||
if (backend.vncState != Backend.OFF) {
|
if (backend.vncState != Backend.OFF) {
|
||||||
console.log("vnc is running");
|
console.log("vnc is running");
|
||||||
backend.stopVNC();
|
stopVNC();
|
||||||
var restoreVNC = true;
|
var restoreVNC = true;
|
||||||
if (autostart) {
|
if (autostart) {
|
||||||
autostart = false;
|
autostart = false;
|
||||||
|
@ -123,7 +123,7 @@ ColumnLayout {
|
||||||
autostart = true;
|
autostart = true;
|
||||||
}
|
}
|
||||||
if (restoreVNC) {
|
if (restoreVNC) {
|
||||||
backend.startVNC(settings.vnc.port);
|
startVNC();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
backend.openDisplaySetting(settings.displaySettingApp);
|
backend.openDisplaySetting(settings.displaySettingApp);
|
||||||
|
|
62
virtscreen/assets/VncOptionsDialog.qml
Normal file
62
virtscreen/assets/VncOptionsDialog.qml
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
import QtQuick 2.10
|
||||||
|
import QtQuick.Controls 2.3
|
||||||
|
import QtQuick.Controls.Material 2.3
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
|
Dialog {
|
||||||
|
id: preferenceDialog
|
||||||
|
title: "VNC Options"
|
||||||
|
focus: true
|
||||||
|
modal: true
|
||||||
|
visible: true
|
||||||
|
standardButtons: Dialog.Ok
|
||||||
|
x: (window.width - width) / 2
|
||||||
|
y: (window.width - height) / 2
|
||||||
|
width: popupWidth
|
||||||
|
height: 300
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
var request = new XMLHttpRequest();
|
||||||
|
request.open('GET', 'data.json');
|
||||||
|
request.onreadystatechange = function(event) {
|
||||||
|
if (request.readyState == XMLHttpRequest.DONE) {
|
||||||
|
var data = JSON.parse(request.responseText).x11vncOptions;
|
||||||
|
// merge data and settings
|
||||||
|
for (var key in data) {
|
||||||
|
Object.assign(data[key], settings.x11vncOptions[key]);
|
||||||
|
}
|
||||||
|
var repeater = vncOptionsRepeater;
|
||||||
|
repeater.model = Object.keys(data).map(function(k){return data[k]});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
request.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
id: vncOptionsRepeater
|
||||||
|
RowLayout {
|
||||||
|
enabled: modelData.available
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: modelData.description + ' (' + modelData.value + ')'
|
||||||
|
}
|
||||||
|
Switch {
|
||||||
|
checked: modelData.available ? modelData.enabled : false
|
||||||
|
onCheckedChanged: {
|
||||||
|
settings.x11vncOptions[modelData.value].enabled = checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
// Empty layout
|
||||||
|
Layout.fillHeight: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onAccepted: {}
|
||||||
|
onRejected: {}
|
||||||
|
}
|
|
@ -45,6 +45,17 @@ ColumnLayout {
|
||||||
onClicked: passwordDialog.open()
|
onClicked: passwordDialog.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RowLayout {
|
||||||
|
Layout.alignment: Qt.AlignRight
|
||||||
|
Button {
|
||||||
|
text: "Advanced"
|
||||||
|
font.capitalization: Font.MixedCase
|
||||||
|
onClicked: vncOptionsLoader.active = true;
|
||||||
|
background.opacity : 0
|
||||||
|
onHoveredChanged: hovered ? background.opacity = 0.4
|
||||||
|
:background.opacity = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
@ -64,7 +75,7 @@ ColumnLayout {
|
||||||
autostart = checked;
|
autostart = checked;
|
||||||
if ((checked == true) && (backend.vncState == Backend.OFF) &&
|
if ((checked == true) && (backend.vncState == Backend.OFF) &&
|
||||||
backend.virtScreenCreated) {
|
backend.virtScreenCreated) {
|
||||||
backend.startVNC(settings.vnc.port);
|
startVNC();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
"available": null,
|
"available": null,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"arg": null
|
"arg": null
|
||||||
|
},
|
||||||
|
"-repeat": {
|
||||||
|
"available": null,
|
||||||
|
"enabled": true,
|
||||||
|
"arg": null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"presets": []
|
"presets": []
|
||||||
|
|
|
@ -2,12 +2,19 @@
|
||||||
"version": "0.2",
|
"version": "0.2",
|
||||||
"x11vncOptions": {
|
"x11vncOptions": {
|
||||||
"-ncache": {
|
"-ncache": {
|
||||||
|
"value": "-ncache",
|
||||||
"description": "Client side caching",
|
"description": "Client side caching",
|
||||||
"long_description": "Enables cache"
|
"long_description": "Enables cache"
|
||||||
},
|
},
|
||||||
"-multiptr": {
|
"-multiptr": {
|
||||||
|
"value": "-multiptr",
|
||||||
"description": "Show mouse pointer",
|
"description": "Show mouse pointer",
|
||||||
"long_description": "This also enables input per-client."
|
"long_description": "This also enables input per-client."
|
||||||
|
},
|
||||||
|
"-repeat": {
|
||||||
|
"value": "-repeat",
|
||||||
|
"description": "Keyboard auto repeating",
|
||||||
|
"long_description": "Enables X server key auto repeat"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"displaySettingApps": {
|
"displaySettingApps": {
|
||||||
|
|
|
@ -10,9 +10,28 @@ Item {
|
||||||
property var settings: JSON.parse(backend.settings)
|
property var settings: JSON.parse(backend.settings)
|
||||||
property bool autostart: settings.vnc.autostart
|
property bool autostart: settings.vnc.autostart
|
||||||
|
|
||||||
|
function startVNC () {
|
||||||
|
var options = '';
|
||||||
|
var data = settings.x11vncOptions;
|
||||||
|
for (var key in data) {
|
||||||
|
if(data[key].available && data[key].enabled) {
|
||||||
|
options += key + ' ';
|
||||||
|
if(data[key].arg !== null) {
|
||||||
|
options += data[key].arg.toString() + ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('options: ', options);
|
||||||
|
backend.startVNC(settings.vnc.port, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopVNC () {
|
||||||
|
backend.stopVNC();
|
||||||
|
}
|
||||||
|
|
||||||
function switchVNC () {
|
function switchVNC () {
|
||||||
if ((backend.vncState == Backend.OFF) && backend.virtScreenCreated) {
|
if ((backend.vncState == Backend.OFF) && backend.virtScreenCreated) {
|
||||||
backend.startVNC(settings.vnc.port);
|
startVNC();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +199,7 @@ Item {
|
||||||
autostart = true;
|
autostart = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
backend.stopVNC();
|
stopVNC();
|
||||||
} else {
|
} else {
|
||||||
backend.deleteVirtScreen();
|
backend.deleteVirtScreen();
|
||||||
}
|
}
|
||||||
|
@ -194,7 +213,7 @@ Item {
|
||||||
backend.vncState == Backend.OFF ? "Start VNC Server" : "Stop VNC Server"
|
backend.vncState == Backend.OFF ? "Start VNC Server" : "Stop VNC Server"
|
||||||
enabled: autostart ? false :
|
enabled: autostart ? false :
|
||||||
backend.virtScreenCreated ? true : false
|
backend.virtScreenCreated ? true : false
|
||||||
onTriggered: backend.vncState == Backend.OFF ? backend.startVNC(settings.vnc.port) : backend.stopVNC()
|
onTriggered: backend.vncState == Backend.OFF ? startVNC() : stopVNC()
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
separator: true
|
separator: true
|
||||||
|
|
|
@ -579,8 +579,8 @@ class Backend(QObject):
|
||||||
else:
|
else:
|
||||||
self.onError.emit("Failed deleting the password file")
|
self.onError.emit("Failed deleting the password file")
|
||||||
|
|
||||||
@pyqtSlot(int)
|
@pyqtSlot(int, str)
|
||||||
def startVNC(self, port):
|
def startVNC(self, port, options=''):
|
||||||
# Check if a virtual screen created
|
# Check if a virtual screen created
|
||||||
if not self.virtScreenCreated:
|
if not self.virtScreenCreated:
|
||||||
self.onError.emit("Virtual Screen not crated.")
|
self.onError.emit("Virtual Screen not crated.")
|
||||||
|
@ -621,7 +621,7 @@ class Backend(QObject):
|
||||||
self.vncServer = ProcessProtocol(_onConnected, _onReceived, _onReceived, _onEnded, logfile)
|
self.vncServer = ProcessProtocol(_onConnected, _onReceived, _onReceived, _onEnded, logfile)
|
||||||
virt = self.xrandr.get_virtual_screen()
|
virt = self.xrandr.get_virtual_screen()
|
||||||
clip = f"{virt.width}x{virt.height}+{virt.x_offset}+{virt.y_offset}"
|
clip = f"{virt.width}x{virt.height}+{virt.x_offset}+{virt.y_offset}"
|
||||||
arg = f"x11vnc -multiptr -repeat -rfbport {port} -clip {clip}"
|
arg = f"x11vnc -rfbport {port} -clip {clip} {options}"
|
||||||
if self.vncUsePassword:
|
if self.vncUsePassword:
|
||||||
arg += f" -rfbauth {X11VNC_PASSWORD_PATH}"
|
arg += f" -rfbauth {X11VNC_PASSWORD_PATH}"
|
||||||
self.vncServer.run(arg)
|
self.vncServer.run(arg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue