mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-02-12 11:21:53 +00:00
QML: Added combobox to select device (no real effect on select yet)
This commit is contained in:
parent
6bee3d556a
commit
1e11c99b50
2 changed files with 32 additions and 1 deletions
26
main.qml
26
main.qml
|
@ -138,6 +138,32 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Label { text: "Device"; Layout.fillWidth: true }
|
||||
ComboBox {
|
||||
id: deviceComboBox
|
||||
textRole: "name"
|
||||
model: []
|
||||
|
||||
Component.onCompleted: {
|
||||
var screens = backend.screens;
|
||||
var list = [];
|
||||
for (var i = 0; i < screens.length; i++) {
|
||||
list.push(screens[i]);
|
||||
}
|
||||
deviceComboBox.model = list;
|
||||
}
|
||||
delegate: ItemDelegate {
|
||||
width: deviceComboBox.width
|
||||
text: modelData.name
|
||||
font.weight: deviceComboBox.currentIndex === index ? Font.DemiBold : Font.Normal
|
||||
highlighted: ListView.isCurrentItem
|
||||
enabled: modelData.connected? false: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from PyQt5.QtWidgets import QApplication
|
|||
from PyQt5.QtCore import QObject, QUrl, Qt
|
||||
from PyQt5.QtCore import pyqtProperty, pyqtSlot, pyqtSignal
|
||||
from PyQt5.QtGui import QIcon, QCursor
|
||||
from PyQt5.QtQml import qmlRegisterType, QQmlApplicationEngine
|
||||
from PyQt5.QtQml import qmlRegisterType, QQmlApplicationEngine, QQmlListProperty
|
||||
|
||||
from twisted.internet import protocol, error
|
||||
from netifaces import interfaces, ifaddresses, AF_INET
|
||||
|
@ -342,6 +342,7 @@ class Backend(QObject):
|
|||
self._portrait = False
|
||||
self._hidpi = False
|
||||
self._virtScreenCreated = False
|
||||
self._screens: List[DisplayProperty] = self.xrandr.screens
|
||||
# VNC server properties
|
||||
self._vncPort = 5900
|
||||
self._vncPassword = ""
|
||||
|
@ -381,6 +382,10 @@ class Backend(QObject):
|
|||
self._virtScreenCreated = value
|
||||
self.onVirtScreenCreatedChanged.emit(value)
|
||||
|
||||
@pyqtProperty(QQmlListProperty)
|
||||
def screens(self):
|
||||
return QQmlListProperty(DisplayProperty, self, self._screens)
|
||||
|
||||
@pyqtProperty(int)
|
||||
def vncPort(self):
|
||||
return self._vncPort
|
||||
|
|
Loading…
Reference in a new issue