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:
parent
db125fe7c5
commit
fb868a4f7f
4 changed files with 53 additions and 15 deletions
23
main.qml
23
main.qml
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue