1
0
Fork 0
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:
Bumsik Kim 2018-05-09 21:09:32 -04:00
parent 6bee3d556a
commit 1e11c99b50
No known key found for this signature in database
GPG key ID: E31041C8EC5B01C6
2 changed files with 32 additions and 1 deletions

View file

@ -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
}
}
}
} }
} }

View file

@ -8,7 +8,7 @@ from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QObject, QUrl, Qt from PyQt5.QtCore import QObject, QUrl, Qt
from PyQt5.QtCore import pyqtProperty, pyqtSlot, pyqtSignal from PyQt5.QtCore import pyqtProperty, pyqtSlot, pyqtSignal
from PyQt5.QtGui import QIcon, QCursor 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 twisted.internet import protocol, error
from netifaces import interfaces, ifaddresses, AF_INET from netifaces import interfaces, ifaddresses, AF_INET
@ -342,6 +342,7 @@ class Backend(QObject):
self._portrait = False self._portrait = False
self._hidpi = False self._hidpi = False
self._virtScreenCreated = False self._virtScreenCreated = False
self._screens: List[DisplayProperty] = self.xrandr.screens
# VNC server properties # VNC server properties
self._vncPort = 5900 self._vncPort = 5900
self._vncPassword = "" self._vncPassword = ""
@ -381,6 +382,10 @@ class Backend(QObject):
self._virtScreenCreated = value self._virtScreenCreated = value
self.onVirtScreenCreatedChanged.emit(value) self.onVirtScreenCreatedChanged.emit(value)
@pyqtProperty(QQmlListProperty)
def screens(self):
return QQmlListProperty(DisplayProperty, self, self._screens)
@pyqtProperty(int) @pyqtProperty(int)
def vncPort(self): def vncPort(self):
return self._vncPort return self._vncPort