[Pkg-privacy-commits] [tails-installer] 19/210: Start porting - export basic image information as Qt properties

Intrigeri intrigeri at moszumanska.debian.org
Wed May 24 15:26:24 UTC 2017


This is an automated email from the git hooks/post-receive script.

intrigeri pushed a commit to tag 3.90.0
in repository tails-installer.

commit cdc92a43b34fd3a8b44cb49f8f4c24ae613c5c95
Author: Martin Briza <mbriza at redhat.com>
Date:   Wed Feb 18 11:07:06 2015 +0100

    Start porting - export basic image information as Qt properties
---
 liveusb/__init__.py |  7 +----
 liveusb/gui.py      | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 87 insertions(+), 9 deletions(-)

diff --git a/liveusb/__init__.py b/liveusb/__init__.py
index edf3ef5..0b47050 100644
--- a/liveusb/__init__.py
+++ b/liveusb/__init__.py
@@ -39,11 +39,6 @@ def utf8_gettext(string):
 
 from liveusb.creator import LiveUSBError
 
-if sys.platform == "win32":
-    from liveusb.creator import WindowsLiveUSBCreator as LiveUSBCreator
-    from liveusb.windows_dialog import Ui_MainWindow as LiveUSBInterface
-else:
-    from liveusb.creator import LinuxLiveUSBCreator as LiveUSBCreator
-    from liveusb.linux_dialog import Ui_MainWindow as LiveUSBInterface
+from liveusb.creator import LiveUSBCreator
 
 __all__ = ("LiveUSBCreator", "LiveUSBError", "LiveUSBWindow", "_", "utf8_gettext")
diff --git a/liveusb/gui.py b/liveusb/gui.py
index a3d3bb6..0af5041 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -31,12 +31,12 @@ import urlparse
 
 from time import sleep
 from datetime import datetime
-from PyQt5.QtCore import pyqtProperty, QObject, QUrl
+from PyQt5.QtCore import pyqtProperty, QObject, QUrl, QDateTime, pyqtSignal
 from PyQt5.QtWidgets import QApplication
-from PyQt5.QtQml import qmlRegisterType, QQmlComponent, QQmlApplicationEngine
+from PyQt5.QtQml import qmlRegisterType, qmlRegisterUncreatableType, QQmlComponent, QQmlApplicationEngine, QQmlListProperty
 from PyQt5.QtQuick import QQuickView
 
-from liveusb import LiveUSBCreator, LiveUSBError, LiveUSBInterface, _
+from liveusb import LiveUSBCreator, LiveUSBError, _
 from liveusb.releases import releases, get_fedora_releases
 
 if sys.platform == 'win32':
@@ -56,12 +56,95 @@ MAX_FAT16 = 2047
 MAX_FAT32 = 3999
 MAX_EXT = 2097152
 
+class Release(QObject):
+    nameChanged = pyqtSignal()
+    logoChanged = pyqtSignal()
+    sizeChanged = pyqtSignal()
+    archChanged = pyqtSignal()
+    fullNameChanged = pyqtSignal()
+    releaseDateChanged = pyqtSignal()
+    shortDescriptionChanged = pyqtSignal()
+    fullDescriptionChanged = pyqtSignal()
+    hasDetailsChanged = pyqtSignal()
+
+    def __init__(self, parent=None, name = '', logo = '', size = 0, arch = '', fullName = '', releaseDate = QDateTime(), shortDescription = '', fullDescription = '', hasDetails = True):
+        QObject.__init__(self, parent)
+
+        self._name = name
+        self._logo = logo
+        self._size = size
+        self._arch = arch
+        self._fullName = fullName
+        self._releaseDate = releaseDate
+        self._shortDescription = shortDescription
+        self._fullDescription = fullDescription
+        self._hasDetails = hasDetails
+
+    @pyqtProperty(str, notify=nameChanged)
+    def name(self):
+        return self._name
+
+    @pyqtProperty(str, notify=logoChanged)
+    def logo(self):
+        return self._logo
+
+    @pyqtProperty(int, notify=sizeChanged)
+    def size(self):
+        return self._size
+
+    @pyqtProperty(str, notify=archChanged)
+    def arch(self):
+        return self._arch
+
+    @pyqtProperty(str, notify=fullNameChanged)
+    def fullName(self):
+        return self._fullName
+
+    @pyqtProperty('QDateTime', notify=releaseDateChanged)
+    def releaseDate(self):
+        return self._releaseDate
+
+    @pyqtProperty(str, notify=shortDescriptionChanged)
+    def shortDescription(self):
+        return self._shortDescription
+
+    @pyqtProperty(str, notify=fullDescriptionChanged)
+    def fullDescription(self):
+        return self._fullDescription
+
+    @pyqtProperty(bool, notify=hasDetailsChanged)
+    def hasDetails(self):
+        return self._hasDetails
+
+
+class LiveUSBData(QObject):
+    releasesChanged = pyqtSignal()
+
+    def __init__(self, opts):
+        QObject.__init__(self)
+        self.live = LiveUSBCreator(opts=opts)
+        self.releaseData = [Release(self, name='Custom OS...', shortDescription='<pick from file chooser>', fullDescription='Here you can choose a OS image from your hard drive to be written to your flash disk', hasDetails=False)]
+        for release in [release['name'] for release in releases]:
+            self.releaseData.append(Release(self, name=release, logo='http://upload.wikimedia.org/wikipedia/commons/3/3f/Fedora_logo.svg', fullDescription='Lorem ipsum, quia dolor sit, amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt, ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehender [...]
+        #self.titleReleaseData = releaseData[0
+
+    @pyqtProperty(QQmlListProperty, notify=releasesChanged)
+    def releases(self):
+        return QQmlListProperty(Release, self, self.releaseData)
+
+    @pyqtProperty(QQmlListProperty, notify=releasesChanged)
+    def titleReleases(self):
+        return QQmlListProperty(Release, self, self.releaseData[0:4])
 
 class LiveUSBApp(QApplication):
     """ Main application class """
     def __init__(self, opts, args):
         QApplication.__init__(self, args)
+        qmlRegisterUncreatableType(Release, "LiveUSB", 1, 0, "Release", "Not creatable directly, use the liveUSBData instance instead")
+        qmlRegisterUncreatableType(LiveUSBData, "LiveUSB", 1, 0, "Data", "Use the liveUSBData root instance")
         view = QQmlApplicationEngine()
+        self.data = LiveUSBData(opts)
+        view.rootContext().setContextProperty("liveUSBData", self.data);
         view.load(QUrl('liveusb/liveusb.qml'))
         view.rootObjects()[0].show()
         self.exec_()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/tails-installer.git



More information about the Pkg-privacy-commits mailing list