mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-02-15 04:41: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.
|
// virtscreen.py backend.
|
||||||
Backend {
|
Backend {
|
||||||
id: backend
|
id: backend
|
||||||
|
onVncStateChanged: {
|
||||||
|
if (backend.vncState == Backend.ERROR) {
|
||||||
|
autostart = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timer object and function
|
// Timer object and function
|
||||||
|
@ -128,12 +133,24 @@ Item {
|
||||||
menu: Menu {
|
menu: Menu {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
id: vncStateText
|
id: vncStateText
|
||||||
text: !backend.virtScreenCreated ? "Enable Virtual Screen first." :
|
text: !backend.virtScreenCreated ? "Enable Virtual Screen first" :
|
||||||
backend.vncState == Backend.OFF ? "Turn on VNC Server in the VNC tab." :
|
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.WAITING ? "VNC Server is waiting for a client..." :
|
||||||
backend.vncState == Backend.CONNECTED ? "Connected." :
|
backend.vncState == Backend.CONNECTED ? "Connected" :
|
||||||
"Server state error!"
|
"Server state error!"
|
||||||
}
|
}
|
||||||
|
MenuItem {
|
||||||
|
id: errorText
|
||||||
|
visible: (text)
|
||||||
|
text: ""
|
||||||
|
Component.onCompleted : {
|
||||||
|
backend.onError.connect(function(errMsg) {
|
||||||
|
errorText.text = "";
|
||||||
|
errorText.text = errMsg;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
separator: true
|
separator: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,6 +221,29 @@ ApplicationWindow {
|
||||||
onRejected: passwordFIeld.text = ""
|
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 {
|
Loader {
|
||||||
id: preferenceLoader
|
id: preferenceLoader
|
||||||
active: false
|
active: false
|
||||||
|
|
|
@ -9,7 +9,7 @@ Dialog {
|
||||||
focus: true
|
focus: true
|
||||||
modal: true
|
modal: true
|
||||||
visible: true
|
visible: true
|
||||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
standardButtons: Dialog.Ok
|
||||||
x: (window.width - width) / 2
|
x: (window.width - width) / 2
|
||||||
y: (window.width - height) / 2
|
y: (window.width - height) / 2
|
||||||
width: popupWidth
|
width: popupWidth
|
||||||
|
|
|
@ -353,22 +353,20 @@ class Backend(QObject):
|
||||||
class VNCState:
|
class VNCState:
|
||||||
""" Enum to indicate a state of the VNC server """
|
""" Enum to indicate a state of the VNC server """
|
||||||
OFF = 0
|
OFF = 0
|
||||||
WAITING = 1
|
ERROR = 1
|
||||||
CONNECTED = 2
|
WAITING = 2
|
||||||
|
CONNECTED = 3
|
||||||
|
|
||||||
Q_ENUMS(VNCState)
|
Q_ENUMS(VNCState)
|
||||||
# Virtual screen properties
|
# Virtual screen properties
|
||||||
xrandr: XRandR
|
xrandr: XRandR = XRandR()
|
||||||
_virtScreenCreated: bool = False
|
_virtScreenCreated: bool = False
|
||||||
screens: List[DisplayProperty]
|
_virtScreenIndex: int = xrandr.virt_idx
|
||||||
_virtScreenIndex: int
|
|
||||||
# VNC server properties
|
# VNC server properties
|
||||||
_vncUsePassword: bool = False
|
_vncUsePassword: bool = False
|
||||||
_vncState: VNCState = VNCState.OFF
|
_vncState: VNCState = VNCState.OFF
|
||||||
# Primary screen and mouse posistion
|
# Primary screen and mouse posistion
|
||||||
_primaryProp: DisplayProperty
|
_primaryProp: DisplayProperty
|
||||||
cursor_x: int
|
|
||||||
cursor_y: int
|
|
||||||
vncServer: ProcessProtocol
|
vncServer: ProcessProtocol
|
||||||
|
|
||||||
# Signals
|
# Signals
|
||||||
|
@ -376,15 +374,12 @@ class Backend(QObject):
|
||||||
onVirtScreenIndexChanged = pyqtSignal(int)
|
onVirtScreenIndexChanged = pyqtSignal(int)
|
||||||
onVncUsePasswordChanged = pyqtSignal(bool)
|
onVncUsePasswordChanged = pyqtSignal(bool)
|
||||||
onVncStateChanged = pyqtSignal(VNCState)
|
onVncStateChanged = pyqtSignal(VNCState)
|
||||||
onVncAutoStartChanged = pyqtSignal(bool)
|
|
||||||
onIPAddressesChanged = pyqtSignal()
|
onIPAddressesChanged = pyqtSignal()
|
||||||
onDisplaySettingClosed = pyqtSignal()
|
onDisplaySettingClosed = pyqtSignal()
|
||||||
|
onError = pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(Backend, self).__init__(parent)
|
super(Backend, self).__init__(parent)
|
||||||
# create objects
|
|
||||||
self.xrandr = XRandR()
|
|
||||||
self._virtScreenIndex = self.xrandr.virt_idx
|
|
||||||
|
|
||||||
# Qt properties
|
# Qt properties
|
||||||
@pyqtProperty(str, constant=True)
|
@pyqtProperty(str, constant=True)
|
||||||
|
@ -534,6 +529,9 @@ class Backend(QObject):
|
||||||
print("VNC disconnected.")
|
print("VNC disconnected.")
|
||||||
self.vncState = self.VNCState.WAITING
|
self.vncState = self.VNCState.WAITING
|
||||||
def _onEnded(exitCode):
|
def _onEnded(exitCode):
|
||||||
|
if exitCode is not 0:
|
||||||
|
self.vncState = self.VNCState.ERROR
|
||||||
|
self.onError.emit('X11VNC: Error occurred.')
|
||||||
print("VNC Exited.")
|
print("VNC Exited.")
|
||||||
self.vncState = self.VNCState.OFF
|
self.vncState = self.VNCState.OFF
|
||||||
atexit.unregister(self.stopVNC)
|
atexit.unregister(self.stopVNC)
|
||||||
|
|
Loading…
Reference in a new issue