[Pkg-privacy-commits] [tails-installer] 20/27: Display (so far - bogus) status of media restore
Intrigeri
intrigeri at moszumanska.debian.org
Wed May 24 15:27:00 UTC 2017
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to tag 3.91.0
in repository tails-installer.
commit 045b67d91ca113bf2a0756dabbb5fe5c594aa466
Author: Martin Briza <mbriza at redhat.com>
Date: Mon Mar 14 11:37:05 2016 +0100
Display (so far - bogus) status of media restore
---
liveusb/components/RestoreDialog.qml | 27 +++++++++++++++++++++------
liveusb/creator.py | 7 +++++++
liveusb/gui.py | 36 +++++++++++++++++++++++++++++++++++-
3 files changed, 63 insertions(+), 7 deletions(-)
diff --git a/liveusb/components/RestoreDialog.qml b/liveusb/components/RestoreDialog.qml
index a58fd9d..5272333 100644
--- a/liveusb/components/RestoreDialog.qml
+++ b/liveusb/components/RestoreDialog.qml
@@ -12,6 +12,13 @@ Dialog {
property int state: 0
+ Connections {
+ target: liveUSBData.driveToRestore
+ onBeingRestoredChanged: root.state++
+ }
+
+ onVisibleChanged: state = 0
+
contentItem : Rectangle {
implicitWidth: $(480)
implicitHeight: textItem.height + buttonItem.height + $(48)
@@ -67,7 +74,7 @@ Dialog {
}
Text {
Layout.alignment: Qt.AlignHCenter
- text: "Your drive was successfully restored!"
+ text: qsTranslate("", "Your drive was successfully restored!")
}
}
}
@@ -78,17 +85,25 @@ Dialog {
anchors.right: parent.right
spacing: $(12)
AdwaitaButton {
- text: "Cancel"
+ text: qsTranslate("", "Cancel")
enabled: root.state == 0
- visible: root.state != 2
+ visible: opacity > 0.0
+ opacity: root.state == 2 ? 0.0 : 1.0
+ Behavior on opacity { NumberAnimation {} }
onClicked: root.visible = false
}
AdwaitaButton {
- text: root.state == 2 ? "Close" : "Restore"
+ text: root.state == 2 ? qsTranslate("", "Close") : qsTranslate("", "Restore")
color: root.state == 2 ? "#628fcf" : "red"
+ Behavior on color { ColorAnimation {duration: 2000} }
textColor: "white"
- //enabled: root.state != 1
- onClicked: root.state = (root.state + 1) % 3
+ enabled: root.state != 1
+ onClicked: {
+ if (root.state == 0)
+ liveUSBData.driveToRestore.restore()
+ else
+ root.visible = false
+ }
}
}
}
diff --git a/liveusb/creator.py b/liveusb/creator.py
index 1b84774..d8251e7 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -242,6 +242,9 @@ class LiveUSBCreator(object):
def dd_image(self):
raise NotImplementedError
+ def restore_drive(self, d):
+ raise NotImplementedError
+
class LinuxLiveUSBCreator(LiveUSBCreator):
bus = None # the dbus.SystemBus
@@ -429,6 +432,10 @@ class LinuxLiveUSBCreator(LiveUSBCreator):
def is_admin(self):
return os.getuid() == 0
+ def restore_drive(self, d):
+ time.sleep(15)
+ pass
+
class MacOsLiveUSBCreator(LiveUSBCreator):
def detect_removable_drives(self, callback=None):
diff --git a/liveusb/gui.py b/liveusb/gui.py
index 2e6ca81..628ef84 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -692,12 +692,30 @@ class LiveUSBLogHandler(logging.Handler):
if record.levelname in ('INFO', 'ERROR', 'WARN'):
self.cb(record.msg)
+class USBDriveRestoreThread(QThread):
+ """ The actual write to the portable drive """
+
+ def __init__(self, parent):
+ QThread.__init__(self, parent)
+
+ self.live = parent.live
+ self.parent = parent
+
+ def run(self):
+ self.parent.beingRestored = True
+ self.live.restore_drive(self.parent.drive)
+ self.parent.beingRestored = False
+
class USBDrive(QObject):
+ beingRestoredChanged = pyqtSignal()
+
def __init__(self, parent, name, drive):
QObject.__init__(self, parent)
+ self.live = parent.live
self._name = name
self._drive = drive
+ self._beingRestored = False
@pyqtProperty(str, constant=True)
def text(self):
@@ -707,6 +725,23 @@ class USBDrive(QObject):
def drive(self):
return self._drive
+ @pyqtProperty(bool, notify=beingRestoredChanged)
+ def beingRestored(self):
+ return self._beingRestored
+
+ @beingRestored.setter
+ def beingRestored(self, v):
+ if v != self._beingRestored:
+ self._beingRestored = v
+ self.beingRestoredChanged.emit()
+ if not v:
+ self._restoreThread = None
+
+ @pyqtSlot()
+ def restore(self):
+ self._restoreThread = USBDriveRestoreThread(self)
+ self._restoreThread.start()
+
class LiveUSBData(QObject):
""" An entry point to all the exposed properties.
There is a list of images and USB drives
@@ -715,7 +750,6 @@ class LiveUSBData(QObject):
currentImageChanged = pyqtSignal()
usbDrivesChanged = pyqtSignal()
currentDriveChanged = pyqtSignal()
- optionsChanged = pyqtSignal()
driveToRestoreChanged = pyqtSignal()
# has to be a property because you can't pass python signal parameters to qml
--
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