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 {
|
TextField {
|
||||||
id: passwordFIeld
|
id: passwordFIeld
|
||||||
focus: true
|
focus: true
|
||||||
anchors.left: parent.left
|
Layout.fillWidth: true
|
||||||
anchors.right: parent.right
|
|
||||||
placeholderText: "New Password";
|
placeholderText: "New Password";
|
||||||
echoMode: TextInput.Password;
|
echoMode: TextInput.Password;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ Dialog {
|
||||||
x: (window.width - width) / 2
|
x: (window.width - width) / 2
|
||||||
y: (window.width - height) / 2
|
y: (window.width - height) / 2
|
||||||
width: popupWidth
|
width: popupWidth
|
||||||
height: 300
|
height: 350
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
var request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
|
@ -33,24 +33,44 @@ Dialog {
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
RowLayout {
|
||||||
Repeater {
|
TextField {
|
||||||
id: vncOptionsRepeater
|
id: vncCustomArgsTextField
|
||||||
RowLayout {
|
enabled: vncCustomArgsCheckbox.checked
|
||||||
enabled: modelData.available
|
Layout.fillWidth: true
|
||||||
Label {
|
placeholderText: "Custom x11vnc arguments"
|
||||||
Layout.fillWidth: true
|
onTextEdited: {
|
||||||
text: modelData.description + ' (' + modelData.value + ')'
|
settings.customX11vncArgs.value = text;
|
||||||
}
|
}
|
||||||
Switch {
|
text: vncCustomArgsCheckbox.checked ? settings.customX11vncArgs.value : ""
|
||||||
checked: modelData.available ? modelData.enabled : false
|
}
|
||||||
onCheckedChanged: {
|
CheckBox {
|
||||||
settings.x11vncOptions[modelData.value].enabled = checked;
|
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 {
|
RowLayout {
|
||||||
// Empty layout
|
// Empty layout
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.3.0",
|
||||||
"x11vncVersion": "0.9.15",
|
"x11vncVersion": "0.9.15",
|
||||||
"theme_color": 8,
|
"theme_color": 8,
|
||||||
"virt": {
|
"virt": {
|
||||||
|
@ -31,5 +31,9 @@
|
||||||
"arg": null
|
"arg": null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"customX11vncArgs": {
|
||||||
|
"enabled": false,
|
||||||
|
"value": ""
|
||||||
|
},
|
||||||
"presets": []
|
"presets": []
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.3.0",
|
||||||
"x11vncOptions": {
|
"x11vncOptions": {
|
||||||
"-ncache": {
|
"-ncache": {
|
||||||
"value": "-ncache",
|
"value": "-ncache",
|
||||||
|
|
|
@ -11,6 +11,11 @@ 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 saveSettings () {
|
||||||
|
settings.vnc.autostart = autostart;
|
||||||
|
backend.settings = JSON.stringify(settings, null, 4);
|
||||||
|
}
|
||||||
|
|
||||||
function createVirtScreen () {
|
function createVirtScreen () {
|
||||||
backend.createVirtScreen(settings.virt.device, settings.virt.width,
|
backend.createVirtScreen(settings.virt.device, settings.virt.width,
|
||||||
settings.virt.height, settings.virt.portrait,
|
settings.virt.height, settings.virt.portrait,
|
||||||
|
@ -18,18 +23,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function startVNC () {
|
function startVNC () {
|
||||||
var options = '';
|
saveSettings();
|
||||||
var data = settings.x11vncOptions;
|
backend.startVNC(settings.vnc.port);
|
||||||
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 () {
|
function stopVNC () {
|
||||||
|
@ -234,8 +229,7 @@ Item {
|
||||||
id: quitAction
|
id: quitAction
|
||||||
text: qsTr("&Quit")
|
text: qsTr("&Quit")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
settings.vnc.autostart = autostart;
|
saveSettings();
|
||||||
backend.settings = JSON.stringify(settings, null, 4);
|
|
||||||
backend.quitProgram();
|
backend.quitProgram();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,7 +457,7 @@ class Backend(QObject):
|
||||||
value["available"] = True
|
value["available"] = True
|
||||||
else:
|
else:
|
||||||
value["available"] = False
|
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()
|
desktop_environ = os.environ['XDG_CURRENT_DESKTOP'].lower()
|
||||||
for key, value in data['displaySettingApps'].items():
|
for key, value in data['displaySettingApps'].items():
|
||||||
for de in value['XDG_CURRENT_DESKTOP']:
|
for de in value['XDG_CURRENT_DESKTOP']:
|
||||||
|
@ -569,8 +569,8 @@ class Backend(QObject):
|
||||||
else:
|
else:
|
||||||
self.onError.emit("Failed deleting the password file")
|
self.onError.emit("Failed deleting the password file")
|
||||||
|
|
||||||
@pyqtSlot(int, str)
|
@pyqtSlot(int)
|
||||||
def startVNC(self, port, options=''):
|
def startVNC(self, port):
|
||||||
# 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.")
|
||||||
|
@ -606,7 +606,19 @@ class Backend(QObject):
|
||||||
self.vncState = self.VNCState.OFF
|
self.vncState = self.VNCState.OFF
|
||||||
print("VNC Exited.")
|
print("VNC Exited.")
|
||||||
atexit.unregister(self.stopVNC)
|
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")
|
logfile = open(X11VNC_LOG_PATH, "wb")
|
||||||
self.vncServer = ProcessProtocol(_onConnected, _onReceived, _onReceived, _onEnded, logfile)
|
self.vncServer = ProcessProtocol(_onConnected, _onReceived, _onReceived, _onEnded, logfile)
|
||||||
try:
|
try:
|
||||||
|
@ -856,13 +868,6 @@ def main_cli(args: argparse.Namespace):
|
||||||
for key, value in tmp_args.items():
|
for key, value in tmp_args.items():
|
||||||
if value:
|
if value:
|
||||||
position = key
|
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
|
# Create virtscreen and Start VNC
|
||||||
def handle_error(msg):
|
def handle_error(msg):
|
||||||
print('Error: ', msg)
|
print('Error: ', msg)
|
||||||
|
@ -876,7 +881,7 @@ def main_cli(args: argparse.Namespace):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
backend.onVncStateChanged.connect(handle_vnc_changed)
|
backend.onVncStateChanged.connect(handle_vnc_changed)
|
||||||
from twisted.internet import reactor # pylint: disable=E0401
|
from twisted.internet import reactor # pylint: disable=E0401
|
||||||
backend.startVNC(config['vnc']['port'], vnc_option)
|
backend.startVNC(config['vnc']['port'])
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue