1
0
Fork 0
mirror of https://github.com/kbumsik/VirtScreen.git synced 2025-02-14 12:21:50 +00:00

Error message dialog added for X11VMC error

This commit is contained in:
Bumsik Kim 2018-05-16 07:04:16 -04:00
parent db125fe7c5
commit fb868a4f7f
No known key found for this signature in database
GPG key ID: E31041C8EC5B01C6
4 changed files with 53 additions and 15 deletions

View file

@ -29,6 +29,11 @@ Item {
// virtscreen.py backend.
Backend {
id: backend
onVncStateChanged: {
if (backend.vncState == Backend.ERROR) {
autostart = false;
}
}
}
// Timer object and function
@ -128,12 +133,24 @@ Item {
menu: Menu {
MenuItem {
id: vncStateText
text: !backend.virtScreenCreated ? "Enable Virtual Screen first." :
backend.vncState == Backend.OFF ? "Turn on VNC Server in the VNC tab." :
text: !backend.virtScreenCreated ? "Enable Virtual Screen first" :
backend.vncState == Backend.OFF ? "Turn on VNC Server in the VNC tab" :
backend.vncState == Backend.ERROR ? "Error occurred" :
backend.vncState == Backend.WAITING ? "VNC Server is waiting for a client..." :
backend.vncState == Backend.CONNECTED ? "Connected." :
backend.vncState == Backend.CONNECTED ? "Connected" :
"Server state error!"
}
MenuItem {
id: errorText
visible: (text)
text: ""
Component.onCompleted : {
backend.onError.connect(function(errMsg) {
errorText.text = "";
errorText.text = errMsg;
});
}
}
MenuItem {
separator: true
}

View file

@ -221,6 +221,29 @@ ApplicationWindow {
onRejected: passwordFIeld.text = ""
}
Dialog {
id: errorDialog
title: "Error"
focus: true
modal: true
standardButtons: Dialog.Ok
x: (parent.width - width) / 2
y: (parent.width - height) / 2 //(window.height) / 2
width: popupWidth
ColumnLayout {
anchors.fill: parent
Text {
horizontalAlignment: Text.AlignHCenter
text: errorText.text
onTextChanged: {
if (text) {
errorDialog.open();
}
}
}
}
}
Loader {
id: preferenceLoader
active: false

View file

@ -9,7 +9,7 @@ Dialog {
focus: true
modal: true
visible: true
standardButtons: Dialog.Ok | Dialog.Cancel
standardButtons: Dialog.Ok
x: (window.width - width) / 2
y: (window.width - height) / 2
width: popupWidth

View file

@ -353,22 +353,20 @@ class Backend(QObject):
class VNCState:
""" Enum to indicate a state of the VNC server """
OFF = 0
WAITING = 1
CONNECTED = 2
ERROR = 1
WAITING = 2
CONNECTED = 3
Q_ENUMS(VNCState)
# Virtual screen properties
xrandr: XRandR
xrandr: XRandR = XRandR()
_virtScreenCreated: bool = False
screens: List[DisplayProperty]
_virtScreenIndex: int
_virtScreenIndex: int = xrandr.virt_idx
# VNC server properties
_vncUsePassword: bool = False
_vncState: VNCState = VNCState.OFF
# Primary screen and mouse posistion
_primaryProp: DisplayProperty
cursor_x: int
cursor_y: int
vncServer: ProcessProtocol
# Signals
@ -376,15 +374,12 @@ class Backend(QObject):
onVirtScreenIndexChanged = pyqtSignal(int)
onVncUsePasswordChanged = pyqtSignal(bool)
onVncStateChanged = pyqtSignal(VNCState)
onVncAutoStartChanged = pyqtSignal(bool)
onIPAddressesChanged = pyqtSignal()
onDisplaySettingClosed = pyqtSignal()
onError = pyqtSignal(str)
def __init__(self, parent=None):
super(Backend, self).__init__(parent)
# create objects
self.xrandr = XRandR()
self._virtScreenIndex = self.xrandr.virt_idx
# Qt properties
@pyqtProperty(str, constant=True)
@ -534,6 +529,9 @@ class Backend(QObject):
print("VNC disconnected.")
self.vncState = self.VNCState.WAITING
def _onEnded(exitCode):
if exitCode is not 0:
self.vncState = self.VNCState.ERROR
self.onError.emit('X11VNC: Error occurred.')
print("VNC Exited.")
self.vncState = self.VNCState.OFF
atexit.unregister(self.stopVNC)