Files
htpc-client/ikinuki_client/__main__.py
T
restitux 7944e4e21b Initial prototype
Basic UI outline with keyboard control. Python database
object is exposed to QML and data can be queried from its methods.
This should provide a generic structure that different UI themes
can be built around.
2022-08-15 17:50:09 +00:00

81 lines
1.7 KiB
Python

from typing import Type
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQml import qmlRegisterType, QQmlApplicationEngine
from PyQt5.QtQuick import QQuickView
from PyQt5.QtCore import QObject, QUrl, pyqtProperty
from .qtmpv import MpvObject
import sys
class Provider(QObject):
def __init__(self, name, parent=None):
super().__init__(parent)
self.name = name
# self.ip = ip
# self.port = port
@pyqtProperty("QString")
def Name(self):
return self.name
class DataSource:
def __init__(self, providers=[]):
self.providers = [Provider(name) for name in providers]
def DatabaseType(data_source) -> Type:
class Database(QObject):
def __init__(self, parent=None):
super().__init__(parent)
self.data_source = data_source
@pyqtProperty(list)
def Providers(self):
return self.data_source.providers
return Database
def main():
app = QApplication(sys.argv)
data_source = DataSource(["Anime", "TV", "Movies", "Settings"])
qmlRegisterType(DatabaseType(data_source), "Ikinuki.Client", 1, 0, "Database")
# qmlRegisterType(Provider, "Ikinuki.Client", 1, 0, "Provider")
engine = QQmlApplicationEngine()
engine.load("layouts/ikinuki-default.qml")
win = QObject()
win = engine.rootObjects()[0]
win.show()
sys.exit(app.exec_())
#
#
#
# app = QApplication([])
#
# qmlRegisterType(MpvObject, 'mpvtest', 1, 0, "MpvObject")
#
# window = QQmlApplicationEngine("layouts/mpv.qml")
# window.run
#
# view = QQuickView()
# url = QUrl("layouts/mpv.qml")
#
# import locale
#
# locale.setlocale(locale.LC_NUMERIC, 'C')
#
# view.setSource(url)
# view.show()
# app.exec_()