[Pkg-privacy-commits] [tails-installer] 15/27: Added basic support of drive restoration
Intrigeri
intrigeri at moszumanska.debian.org
Wed May 24 15:26:59 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 37595a6f20d2c144ab1ba040574de5f5653bcd89
Author: Martin Briza <mbriza at redhat.com>
Date: Fri Mar 11 10:32:46 2016 +0100
Added basic support of drive restoration
Notifies that a drive that can be restored was inserted
The restore dialog is just a placeholder for the actual process now.
---
liveusb/components/RestoreDialog.qml | 96 ++++++++++++++++++++++++++++++++++++
liveusb/gui.py | 17 ++++++-
liveusb/liveusb.qml | 34 ++++++++++++-
3 files changed, 144 insertions(+), 3 deletions(-)
diff --git a/liveusb/components/RestoreDialog.qml b/liveusb/components/RestoreDialog.qml
new file mode 100644
index 0000000..a58fd9d
--- /dev/null
+++ b/liveusb/components/RestoreDialog.qml
@@ -0,0 +1,96 @@
+import QtQuick 2.4
+import QtQuick.Controls 1.3
+import QtQuick.Controls.Styles 1.4
+import QtQuick.Window 2.2
+import QtGraphicalEffects 1.0
+import QtQuick.Dialogs 1.2
+import QtQuick.Layouts 1.1
+
+Dialog {
+ id: root
+ title: liveUSBData.driveToRestore ? qsTranslate("", "Restore %1?").arg(liveUSBData.driveToRestore.text) : ""
+
+ property int state: 0
+
+ contentItem : Rectangle {
+ implicitWidth: $(480)
+ implicitHeight: textItem.height + buttonItem.height + $(48)
+ height: textItem.height + buttonItem.height + $(48)
+ color: palette.window
+ Item {
+ id: wrapper
+ anchors.fill: parent
+ anchors.margins: $(18)
+ Row {
+ id: textItem
+ spacing: $(36)
+ x: root.state == 0 ? 0 : root.state == 1 ? - (parent.width + $(36)) : - (2 * parent.width + $(72))
+ height: progress.height > warningText.height ? progress.height : warningText.height
+ Behavior on x {
+ NumberAnimation {
+ duration: 300
+ easing.type: Easing.OutExpo
+ }
+ }
+ Text {
+ id: warningText
+ width: wrapper.width
+ text: qsTranslate("", "<p align=\"justify\">To reclaim all space available on the drive, it has to be restored to factory settings. The live system and all saved data will be deleted.</p><p>Do you want to continue?</p>")
+ textFormat: Text.RichText
+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
+ }
+ ColumnLayout {
+ id: progress
+ width: wrapper.width
+ spacing: $(12)
+ Item {
+ width: 1; height: 1
+ }
+
+ AdwaitaBusyIndicator {
+ id: progressIndicator
+ width: $(256)
+ Layout.alignment: Qt.AlignHCenter
+ }
+
+ Text {
+ Layout.alignment: Qt.AlignHCenter
+ Layout.fillWidth: true
+ wrapMode: Text.WrapAtWordBoundaryOrAnywhere
+ text: qsTranslate("", "<p justify=\"align\">Please wait while Fedora Media Writer restores your portable drive.</p>")
+ }
+ }
+ ColumnLayout {
+ width: wrapper.width
+ CheckMark {
+ Layout.alignment: Qt.AlignHCenter
+ }
+ Text {
+ Layout.alignment: Qt.AlignHCenter
+ text: "Your drive was successfully restored!"
+ }
+ }
+ }
+
+ Row {
+ id: buttonItem
+ anchors.bottom: parent.bottom
+ anchors.right: parent.right
+ spacing: $(12)
+ AdwaitaButton {
+ text: "Cancel"
+ enabled: root.state == 0
+ visible: root.state != 2
+ onClicked: root.visible = false
+ }
+ AdwaitaButton {
+ text: root.state == 2 ? "Close" : "Restore"
+ color: root.state == 2 ? "#628fcf" : "red"
+ textColor: "white"
+ //enabled: root.state != 1
+ onClicked: root.state = (root.state + 1) % 3
+ }
+ }
+ }
+ }
+}
diff --git a/liveusb/gui.py b/liveusb/gui.py
index bc590cd..faedfae 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -430,8 +430,8 @@ class Release(QObject):
self.infoChanged.emit()
self.errorChanged.emit()
self.warningChanged.emit()
-
- self.addInfo(_('You can use Fedora Media Writer to restore the original size of your flash drive after you will have tried or installed Fedora.'))
+
+ self.addInfo(_('After you have tried or installed Fedora, you can use Fedora Media Writer to restore your flash drive to its factory settings.'))
self._writer.run()
@@ -716,6 +716,10 @@ class LiveUSBData(QObject):
usbDrivesChanged = pyqtSignal()
currentDriveChanged = pyqtSignal()
optionsChanged = pyqtSignal()
+ driveToRestoreChanged = pyqtSignal()
+
+ # has to be a property because you can't pass python signal parameters to qml
+ _driveToRestore = None
_currentIndex = 0
_currentDrive = 0
@@ -775,11 +779,16 @@ class LiveUSBData(QObject):
self._usbDrives = tmpDrives
self.usbDrivesChanged.emit()
+ self._driveToRestore = None
+
self.currentDrive = -1
for i, drive in enumerate(self._usbDrives):
if drive.drive.device == previouslySelected:
self.currentDrive = i
+ if drive.drive.isIso9660:
+ self._driveToRestore = drive
self.currentDriveChanged.emit()
+ self.driveToRestoreChanged.emit()
@pyqtProperty(ReleaseListModel, notify=releasesChanged)
def releaseModel(self):
@@ -803,6 +812,10 @@ class LiveUSBData(QObject):
def currentImage(self):
return self.releaseData[self._currentIndex]
+ @pyqtProperty(USBDrive, notify=driveToRestoreChanged)
+ def driveToRestore(self):
+ return self._driveToRestore
+
@pyqtProperty(QQmlListProperty, notify=usbDrivesChanged)
def usbDrives(self):
return QQmlListProperty(USBDrive, self, self._usbDrives)
diff --git a/liveusb/liveusb.qml b/liveusb/liveusb.qml
index a2d5683..672382d 100644
--- a/liveusb/liveusb.qml
+++ b/liveusb/liveusb.qml
@@ -1,7 +1,10 @@
import QtQuick 2.4
import QtQuick.Controls 1.3
+import QtQuick.Controls.Styles 1.4
import QtQuick.Window 2.2
+import QtGraphicalEffects 1.0
import QtQuick.Dialogs 1.2
+import QtQuick.Layouts 1.1
import LiveUSB 1.0
@@ -27,8 +30,33 @@ ApplicationWindow {
property bool canGoBack: false
property real margin: $(64) + (width - $(800)) / 4
+ AdwaitaNotificationBar {
+ id: deviceNotification
+ text: open ? qsTranslate("", "You inserted <b>%1</b> that already contains a live system.<br>Do you want to restore it to factory settings?").arg(liveUSBData.driveToRestore.text) : ""
+ open: liveUSBData.driveToRestore
+ acceptText: qsTranslate("", "Restore")
+ cancelText: qsTranslate("", "Do Nothing")
+ property var disk: null
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: parent.top
+ }
+ onAccepted: restoreDialog.visible = true
+ Connections {
+ target: liveUSBData
+ onDriveToRestoreChanged: deviceNotification.open = liveUSBData.driveToRestore
+ }
+ }
+
Rectangle {
- anchors.fill: parent
+ anchors {
+ top: deviceNotification.bottom
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+
color: palette.window
//radius: 8
clip: true
@@ -70,5 +98,9 @@ ApplicationWindow {
}
}
}
+
+ RestoreDialog {
+ id: restoreDialog
+ }
}
--
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