mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-03-09 15:40:18 +00:00
#6: Added support for custom x11vnc arguments
This commit is contained in:
parent
7941f1909a
commit
8c65910f27
6 changed files with 66 additions and 44 deletions
|
@ -209,8 +209,7 @@ ApplicationWindow {
|
|||
TextField {
|
||||
id: passwordFIeld
|
||||
focus: true
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
Layout.fillWidth: true
|
||||
placeholderText: "New Password";
|
||||
echoMode: TextInput.Password;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ Dialog {
|
|||
x: (window.width - width) / 2
|
||||
y: (window.width - height) / 2
|
||||
width: popupWidth
|
||||
height: 300
|
||||
height: 350
|
||||
|
||||
Component.onCompleted: {
|
||||
var request = new XMLHttpRequest();
|
||||
|
@ -33,24 +33,44 @@ Dialog {
|
|||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
Repeater {
|
||||
id: vncOptionsRepeater
|
||||
RowLayout {
|
||||
enabled: modelData.available
|
||||
Label {
|
||||
Layout.fillWidth: true
|
||||
text: modelData.description + ' (' + modelData.value + ')'
|
||||
RowLayout {
|
||||
TextField {
|
||||
id: vncCustomArgsTextField
|
||||
enabled: vncCustomArgsCheckbox.checked
|
||||
Layout.fillWidth: true
|
||||
placeholderText: "Custom x11vnc arguments"
|
||||
onTextEdited: {
|
||||
settings.customX11vncArgs.value = text;
|
||||
}
|
||||
Switch {
|
||||
checked: modelData.available ? modelData.enabled : false
|
||||
onCheckedChanged: {
|
||||
settings.x11vncOptions[modelData.value].enabled = checked;
|
||||
text: vncCustomArgsCheckbox.checked ? settings.customX11vncArgs.value : ""
|
||||
}
|
||||
CheckBox {
|
||||
id: vncCustomArgsCheckbox
|
||||
checked: settings.customX11vncArgs.enabled
|
||||
onToggled: {
|
||||
settings.customX11vncArgs.enabled = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
enabled: !vncCustomArgsCheckbox.checked
|
||||
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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"x11vncVersion": "0.9.15",
|
||||
"theme_color": 8,
|
||||
"virt": {
|
||||
|
@ -31,5 +31,9 @@
|
|||
"arg": null
|
||||
}
|
||||
},
|
||||
"customX11vncArgs": {
|
||||
"enabled": false,
|
||||
"value": ""
|
||||
},
|
||||
"presets": []
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"x11vncOptions": {
|
||||
"-ncache": {
|
||||
"value": "-ncache",
|
||||
|
|
|
@ -11,6 +11,11 @@ Item {
|
|||
property var settings: JSON.parse(backend.settings)
|
||||
property bool autostart: settings.vnc.autostart
|
||||
|
||||
function saveSettings () {
|
||||
settings.vnc.autostart = autostart;
|
||||
backend.settings = JSON.stringify(settings, null, 4);
|
||||
}
|
||||
|
||||
function createVirtScreen () {
|
||||
backend.createVirtScreen(settings.virt.device, settings.virt.width,
|
||||
settings.virt.height, settings.virt.portrait,
|
||||
|
@ -18,18 +23,8 @@ Item {
|
|||
}
|
||||
|
||||
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);
|
||||
saveSettings();
|
||||
backend.startVNC(settings.vnc.port);
|
||||
}
|
||||
|
||||
function stopVNC () {
|
||||
|
@ -234,8 +229,7 @@ Item {
|
|||
id: quitAction
|
||||
text: qsTr("&Quit")
|
||||
onTriggered: {
|
||||
settings.vnc.autostart = autostart;
|
||||
backend.settings = JSON.stringify(settings, null, 4);
|
||||
saveSettings();
|
||||
backend.quitProgram();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -457,7 +457,7 @@ class Backend(QObject):
|
|||
value["available"] = True
|
||||
else:
|
||||
value["available"] = False
|
||||
# 2. Default Display settings app for a Desktop Environment
|
||||
# Default Display settings app for a Desktop Environment
|
||||
desktop_environ = os.environ['XDG_CURRENT_DESKTOP'].lower()
|
||||
for key, value in data['displaySettingApps'].items():
|
||||
for de in value['XDG_CURRENT_DESKTOP']:
|
||||
|
@ -569,8 +569,8 @@ class Backend(QObject):
|
|||
else:
|
||||
self.onError.emit("Failed deleting the password file")
|
||||
|
||||
@pyqtSlot(int, str)
|
||||
def startVNC(self, port, options=''):
|
||||
@pyqtSlot(int)
|
||||
def startVNC(self, port):
|
||||
# Check if a virtual screen created
|
||||
if not self.virtScreenCreated:
|
||||
self.onError.emit("Virtual Screen not crated.")
|
||||
|
@ -606,7 +606,19 @@ class Backend(QObject):
|
|||
self.vncState = self.VNCState.OFF
|
||||
print("VNC Exited.")
|
||||
atexit.unregister(self.stopVNC)
|
||||
|
||||
# load settings
|
||||
with open(CONFIG_PATH, 'r') as f:
|
||||
config = json.load(f)
|
||||
options = ''
|
||||
if config['customX11vncArgs']['enabled']:
|
||||
options = config['customX11vncArgs']['value']
|
||||
else:
|
||||
for key, value in config['x11vncOptions'].items():
|
||||
if value['available'] and value['enabled']:
|
||||
options += key + ' '
|
||||
if value['arg'] is not None:
|
||||
options += str(value['arg']) + ' '
|
||||
# Sart x11vnc, turn settings object into VNC arguments format
|
||||
logfile = open(X11VNC_LOG_PATH, "wb")
|
||||
self.vncServer = ProcessProtocol(_onConnected, _onReceived, _onReceived, _onEnded, logfile)
|
||||
try:
|
||||
|
@ -856,13 +868,6 @@ def main_cli(args: argparse.Namespace):
|
|||
for key, value in tmp_args.items():
|
||||
if value:
|
||||
position = key
|
||||
# Turn settings object into VNC arguments format
|
||||
vnc_option = ''
|
||||
for key, value in config['x11vncOptions'].items():
|
||||
if value['available'] and value['enabled']:
|
||||
vnc_option += key + ' '
|
||||
if value['arg'] is not None:
|
||||
vnc_option += str(value['arg']) + ' '
|
||||
# Create virtscreen and Start VNC
|
||||
def handle_error(msg):
|
||||
print('Error: ', msg)
|
||||
|
@ -876,7 +881,7 @@ def main_cli(args: argparse.Namespace):
|
|||
sys.exit(0)
|
||||
backend.onVncStateChanged.connect(handle_vnc_changed)
|
||||
from twisted.internet import reactor # pylint: disable=E0401
|
||||
backend.startVNC(config['vnc']['port'], vnc_option)
|
||||
backend.startVNC(config['vnc']['port'])
|
||||
reactor.run()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue