mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-03-09 15:40:18 +00:00
Backend: Added VNC State Enum
This commit is contained in:
parent
73c8f5fb7c
commit
7307a1111c
2 changed files with 18 additions and 5 deletions
2
main.qml
2
main.qml
|
@ -195,7 +195,7 @@ ApplicationWindow {
|
||||||
RowLayout {
|
RowLayout {
|
||||||
anchors.margins: spacing
|
anchors.margins: spacing
|
||||||
Label {
|
Label {
|
||||||
text: "VNC Server Waiting."
|
text: backend.vncState
|
||||||
}
|
}
|
||||||
Item { Layout.fillWidth: true }
|
Item { Layout.fillWidth: true }
|
||||||
CheckBox {
|
CheckBox {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import sys, os
|
import sys, os
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
from PyQt5.QtCore import QObject, QUrl, Qt
|
from PyQt5.QtCore import QObject, QUrl, Qt
|
||||||
|
@ -19,10 +20,18 @@ ICON_TABLET_ON_PATH = PROGRAM_PATH + "/icon/icon_tablet_on.png"
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# QML Backend class
|
# QML Backend class
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
class VNCState(Enum):
|
||||||
|
""" Enum to indicate a state of the VNC server """
|
||||||
|
OFF = "Off"
|
||||||
|
WAITING = "Waiting"
|
||||||
|
CONNECTED = "Connected"
|
||||||
|
|
||||||
class Backend(QObject):
|
class Backend(QObject):
|
||||||
|
""" Backend class for QML frontend """
|
||||||
|
# Signals
|
||||||
width_changed = pyqtSignal(int)
|
width_changed = pyqtSignal(int)
|
||||||
virtScreenChanged = pyqtSignal(bool)
|
virtScreenChanged = pyqtSignal(bool)
|
||||||
vncChanged = pyqtSignal(bool)
|
vncChanged = pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(Backend, self).__init__(parent)
|
super(Backend, self).__init__(parent)
|
||||||
|
@ -35,8 +44,9 @@ class Backend(QObject):
|
||||||
# VNC server properties
|
# VNC server properties
|
||||||
self._vncPort = 5900
|
self._vncPort = 5900
|
||||||
self._vncPassword = ""
|
self._vncPassword = ""
|
||||||
self._vncState = False
|
self._vncState = VNCState.OFF
|
||||||
|
|
||||||
|
# Qt properties
|
||||||
@pyqtProperty(int, notify=width_changed)
|
@pyqtProperty(int, notify=width_changed)
|
||||||
def width(self):
|
def width(self):
|
||||||
return self._width
|
return self._width
|
||||||
|
@ -85,6 +95,10 @@ class Backend(QObject):
|
||||||
self._vncPassword = vncPassword
|
self._vncPassword = vncPassword
|
||||||
print(self._vncPassword)
|
print(self._vncPassword)
|
||||||
|
|
||||||
|
@pyqtProperty(str)
|
||||||
|
def vncState(self):
|
||||||
|
return self._vncState.value
|
||||||
|
|
||||||
# Qt Slots
|
# Qt Slots
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def quitProgram(self):
|
def quitProgram(self):
|
||||||
|
@ -94,7 +108,6 @@ class Backend(QObject):
|
||||||
# Main Code
|
# Main Code
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys
|
|
||||||
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
|
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
app.setWindowIcon(QIcon(ICON_PATH))
|
app.setWindowIcon(QIcon(ICON_PATH))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue