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 {
|
||||
anchors.top: tabBar.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
|
|
|
@ -109,7 +109,7 @@ ColumnLayout {
|
|||
window.autoClose = false;
|
||||
if (backend.vncState != Backend.OFF) {
|
||||
console.log("vnc is running");
|
||||
backend.stopVNC();
|
||||
stopVNC();
|
||||
var restoreVNC = true;
|
||||
if (autostart) {
|
||||
autostart = false;
|
||||
|
@ -123,7 +123,7 @@ ColumnLayout {
|
|||
autostart = true;
|
||||
}
|
||||
if (restoreVNC) {
|
||||
backend.startVNC(settings.vnc.port);
|
||||
startVNC();
|
||||
}
|
||||
});
|
||||
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()
|
||||
}
|
||||
}
|
||||
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 {
|
||||
|
@ -64,7 +75,7 @@ ColumnLayout {
|
|||
autostart = checked;
|
||||
if ((checked == true) && (backend.vncState == Backend.OFF) &&
|
||||
backend.virtScreenCreated) {
|
||||
backend.startVNC(settings.vnc.port);
|
||||
startVNC();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,11 @@
|
|||
"available": null,
|
||||
"enabled": true,
|
||||
"arg": null
|
||||
},
|
||||
"-repeat": {
|
||||
"available": null,
|
||||
"enabled": true,
|
||||
"arg": null
|
||||
}
|
||||
},
|
||||
"presets": []
|
||||
|
|
|
@ -2,12 +2,19 @@
|
|||
"version": "0.2",
|
||||
"x11vncOptions": {
|
||||
"-ncache": {
|
||||
"value": "-ncache",
|
||||
"description": "Client side caching",
|
||||
"long_description": "Enables cache"
|
||||
},
|
||||
"-multiptr": {
|
||||
"value": "-multiptr",
|
||||
"description": "Show mouse pointer",
|
||||
"long_description": "This also enables input per-client."
|
||||
},
|
||||
"-repeat": {
|
||||
"value": "-repeat",
|
||||
"description": "Keyboard auto repeating",
|
||||
"long_description": "Enables X server key auto repeat"
|
||||
}
|
||||
},
|
||||
"displaySettingApps": {
|
||||
|
|
|
@ -10,9 +10,28 @@ Item {
|
|||
property var settings: JSON.parse(backend.settings)
|
||||
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 () {
|
||||
if ((backend.vncState == Backend.OFF) && backend.virtScreenCreated) {
|
||||
backend.startVNC(settings.vnc.port);
|
||||
startVNC();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +199,7 @@ Item {
|
|||
autostart = true;
|
||||
}
|
||||
});
|
||||
backend.stopVNC();
|
||||
stopVNC();
|
||||
} else {
|
||||
backend.deleteVirtScreen();
|
||||
}
|
||||
|
@ -194,7 +213,7 @@ Item {
|
|||
backend.vncState == Backend.OFF ? "Start VNC Server" : "Stop VNC Server"
|
||||
enabled: autostart ? 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 {
|
||||
separator: true
|
||||
|
|
|
@ -579,8 +579,8 @@ class Backend(QObject):
|
|||
else:
|
||||
self.onError.emit("Failed deleting the password file")
|
||||
|
||||
@pyqtSlot(int)
|
||||
def startVNC(self, port):
|
||||
@pyqtSlot(int, str)
|
||||
def startVNC(self, port, options=''):
|
||||
# Check if a virtual screen created
|
||||
if not self.virtScreenCreated:
|
||||
self.onError.emit("Virtual Screen not crated.")
|
||||
|
@ -621,7 +621,7 @@ class Backend(QObject):
|
|||
self.vncServer = ProcessProtocol(_onConnected, _onReceived, _onReceived, _onEnded, logfile)
|
||||
virt = self.xrandr.get_virtual_screen()
|
||||
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:
|
||||
arg += f" -rfbauth {X11VNC_PASSWORD_PATH}"
|
||||
self.vncServer.run(arg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue