[Pkg-privacy-commits] [tails-installer] 47/210: Download dialog advanced options initial work
Intrigeri
intrigeri at moszumanska.debian.org
Wed May 24 15:26:27 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 03c8289168920885ad0df926c87bb4be4a76bddd
Author: Martin Briza <mbriza at redhat.com>
Date: Thu Apr 2 15:02:09 2015 +0200
Download dialog advanced options initial work
Getting the download dialog to scale to fit its contents was much harder than expected but finally it works as expected...
---
liveusb/components/DownloadDialog.qml | 236 ++++++++++++++++++----------------
liveusb/gui.py | 97 ++++++++------
2 files changed, 181 insertions(+), 152 deletions(-)
diff --git a/liveusb/components/DownloadDialog.qml b/liveusb/components/DownloadDialog.qml
index d7edaba..b77539a 100644
--- a/liveusb/components/DownloadDialog.qml
+++ b/liveusb/components/DownloadDialog.qml
@@ -1,143 +1,155 @@
-import QtQuick 2.0
+import QtQuick 2.4
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Window 2.0
-Dialog {
+Window {
id: root
title: "Write " + liveUSBData.currentImage.name + " to USB"
+ color: palette.window
+
+ maximumWidth: 640
+ minimumWidth: maximumWidth
+ height: layout.height + 96
+
+ Column {
+ id: layout
+ spacing: 24
+ clip: true
+ anchors {
+ top: parent.top
+ left: parent.left
+ right: parent.right
+ topMargin: 48
+ leftMargin: 64
+ rightMargin: anchors.leftMargin
+ }
+ Text {
+ wrapMode: Text.WordWrap
+ //text: "Writing the image of " + liveUSBData.currentImage.name +" will delete everything that's currently on the drive."
+ text: liveUSBData.currentImage.info
+ }
- contentItem: Rectangle {
- color: palette.window
- implicitWidth: 600
- implicitHeight: 300
ColumnLayout {
- id: layout
- spacing: 24
- anchors {
- fill: parent
- topMargin: 48
- leftMargin: 64
- rightMargin: anchors.leftMargin
- bottomMargin: anchors.topMargin * 2
+ width: parent.width
+ Behavior on y {
+ NumberAnimation {
+ duration: 1000
+ }
}
Text {
Layout.fillWidth: true
- width: layout.width
- wrapMode: Text.WordWrap
- text: "Writing the image of " + liveUSBData.currentImage.name +" will delete everything that's currently on the drive."
+ horizontalAlignment: Text.AlignHCenter
+ property double leftSize: liveUSBData.currentImage.download.maxProgress - liveUSBData.currentImage.download.progress
+ property string leftStr: leftSize <= 0 ? "" :
+ (leftSize < 1024) ? (leftSize + " B") :
+ (leftSize < (1024 * 1024)) ? ((leftSize / 1024).toFixed(1) + " KB") :
+ (leftSize < (1024 * 1024 * 1024)) ? ((leftSize / 1024 / 1024).toFixed(1) + " MB") :
+ ((leftSize / 1024 / 1024 / 1024).toFixed(1) + " GB")
+ text: liveUSBData.currentImage.status + (liveUSBData.currentImage.download.maxProgress > 0 ? " (" + leftStr + " left)" : "")
}
-
- ColumnLayout {
- Text {
- Layout.fillWidth: true
- horizontalAlignment: Text.AlignHCenter
- property double leftSize: liveUSBData.currentImage.download.maxProgress - liveUSBData.currentImage.download.progress
- property string leftStr: leftSize <= 0 ? "" :
- (leftSize < 1024) ? (leftSize + " B") :
- (leftSize < (1024 * 1024)) ? ((leftSize / 1024).toFixed(1) + " KB") :
- (leftSize < (1024 * 1024 * 1024)) ? ((leftSize / 1024 / 1024).toFixed(1) + " MB") :
- ((leftSize / 1024 / 1024 / 1024).toFixed(1) + " GB")
- text: liveUSBData.currentImage.status + (liveUSBData.currentImage.download.maxProgress > 0 ? " (" + leftStr + " left)" : "")
+ Item {
+ Layout.fillWidth: true
+ height: childrenRect.height
+ AdwaitaProgressBar {
+ width: parent.width
+ value: liveUSBData.currentImage.download.running ? liveUSBData.currentImage.download.progress / liveUSBData.currentImage.download.maxProgress : 0
+ visible: !liveUSBData.currentImage.writer.running
}
- Item {
- Layout.fillWidth: true
- height: childrenRect.height
- AdwaitaProgressBar {
- width: parent.width
- value: liveUSBData.currentImage.download.running ? liveUSBData.currentImage.download.progress / liveUSBData.currentImage.download.maxProgress : 0
- visible: !liveUSBData.currentImage.writer.running
- }
- AdwaitaProgressBar {
- width: parent.width
- value: liveUSBData.currentImage.writer.running ? liveUSBData.currentImage.writer.progress / liveUSBData.currentImage.writer.maxProgress : 0
- visible: !liveUSBData.currentImage.download.running
- progressColor: liveUSBData.currentImage.writer.status == "Checking the source image" ? Qt.lighter("green") : "red"
- }
+ AdwaitaProgressBar {
+ width: parent.width
+ value: liveUSBData.currentImage.writer.running ? liveUSBData.currentImage.writer.progress / liveUSBData.currentImage.writer.maxProgress : 0
+ visible: !liveUSBData.currentImage.download.running
+ progressColor: liveUSBData.currentImage.writer.status == "Checking the source image" ? Qt.lighter("green") : "red"
}
}
+ }
- RowLayout {
- Layout.fillWidth: true
- Layout.alignment: Qt.AlignCenter
- spacing: 32
- IndicatedImage {
- source: liveUSBData.currentImage.logo
- sourceSize.width: 64
- sourceSize.height: 64
- fillMode: Image.PreserveAspectFit
- }
- Arrow {
+ RowLayout {
+ anchors.horizontalCenter: parent.horizontalCenter
+ spacing: 32
+ IndicatedImage {
+ source: liveUSBData.currentImage.logo
+ sourceSize.width: 64
+ sourceSize.height: 64
+ fillMode: Image.PreserveAspectFit
+ }
+ Arrow {
- }
- AdwaitaComboBox {
- Layout.preferredWidth: implicitWidth * 2.3
- model: liveUSBData.usbDriveNames
- currentIndex: liveUSBData.currentDrive
- onCurrentIndexChanged: liveUSBData.currentDrive = currentIndex
- enabled: !liveUSBData.currentImage.writer.running
+ }
+ AdwaitaComboBox {
+ Layout.preferredWidth: implicitWidth * 2.3
+ model: liveUSBData.usbDriveNames
+ currentIndex: liveUSBData.currentDrive
+ onCurrentIndexChanged: liveUSBData.currentDrive = currentIndex
+ enabled: !liveUSBData.currentImage.writer.running
+ }
+ }
+ GroupBox {
+ id: group
+ title: "Advanced Options"
+ flat: true
+ checked: false
+ checkable: true
+ enabled: liveUSBData.options && liveUSBData.options[0]
+ ColumnLayout {
+ Repeater {
+ id: groupLayoutRepeater
+ model: group.checked ? liveUSBData.options : null
+ CheckBox {
+ checked: false
+ height: 20
+ width: 20
+ text: groupLayoutRepeater.model[index]
+ }
}
}
}
- Item {
- id: dialogToolBar
- height: 32
+ }
+ Item {
+ id: dialogButtonBar
+ height: 32
+ anchors {
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ bottomMargin: 24
+ leftMargin: 16
+ rightMargin: anchors.leftMargin
+ }
+
+ AdwaitaButton {
+ id: cancelButton
anchors {
- left: parent.left
- right: parent.right
+ right: acceptButton.left
+ top: parent.top
bottom: parent.bottom
- bottomMargin: 24
- leftMargin: 16
- rightMargin: anchors.leftMargin
+ rightMargin: 6
}
-
- AdwaitaButton {
- id: cancelButton
- anchors {
- right: acceptButton.left
- top: parent.top
- bottom: parent.bottom
- rightMargin: 6
- }
- width: implicitWidth * 1.2
- text: "Cancel"
- enabled: !liveUSBData.currentImage.writer.running
- onClicked: {
- liveUSBData.currentImage.download.cancel()
- liveUSBData.currentImage.writer.cancel()
- root.close()
- }
- }
- AdwaitaButton {
- id: acceptButton
- anchors {
- right: parent.right
- top: parent.top
- bottom: parent.bottom
- }
- color: "red"
- textColor: enabled ? "white" : palette.text
- width: implicitWidth * 1.2
- enabled: liveUSBData.currentImage.readyToWrite && !liveUSBData.currentImage.writer.running
- text: "Write to disk"
- onClicked: liveUSBData.currentImage.write()
+ width: implicitWidth * 1.2
+ text: "Cancel"
+ enabled: !liveUSBData.currentImage.writer.running
+ onClicked: {
+ liveUSBData.currentImage.download.cancel()
+ liveUSBData.currentImage.writer.cancel()
+ root.close()
}
}
- Dialog {
- id: confirmDialog
- Item {
- implicitWidth: 800
- implicitHeight: 240
- Text {
- text: "Your drive already contains a live operating system. Do you wish to continue?"
- }
- Text {
- text: "By continuing, the existing OS will be overwritten."
- }
+ AdwaitaButton {
+ id: acceptButton
+ anchors {
+ right: parent.right
+ top: parent.top
+ bottom: parent.bottom
}
- standardButtons: StandardButton.Yes | StandardButton.No
+ color: "red"
+ textColor: enabled ? "white" : palette.text
+ width: implicitWidth * 1.2
+ enabled: liveUSBData.currentImage.readyToWrite && !liveUSBData.currentImage.writer.running
+ text: "Write to disk"
+ onClicked: liveUSBData.currentImage.write()
}
}
}
diff --git a/liveusb/gui.py b/liveusb/gui.py
index 1b06eb3..ec26cf6 100755
--- a/liveusb/gui.py
+++ b/liveusb/gui.py
@@ -205,6 +205,7 @@ class ReleaseWriterProgressThread(QThread):
class ReleaseWriterThread(QThread):
+
def __init__(self, parent, progressThread, useDD = False):
QThread.__init__(self, parent)
@@ -231,6 +232,7 @@ class ReleaseWriterThread(QThread):
#self.live.log.removeHandler(handler)
def ddImage(self, now):
+ self.status = _("WARNING: You are about to perform a destructive install. This will destroy all data and partitions on your USB drive. Press 'Create Live USB' again to continue.")
self.live.dd_image()
#self.live.log.removeHandler(handler)
duration = str(datetime.now() - now).split('.')[0]
@@ -238,12 +240,6 @@ class ReleaseWriterThread(QThread):
return
def copyImage(self, now):
- self.live.verify_filesystem()
- if not self.live.drive['uuid'] and not self.live.label:
- self.parent.status = _("Error: Cannot set the label or obtain "
- "the UUID of your device. Unable to continue.")
- #self.live.log.removeHandler(handler)
- return
self.parent.status = _("Checking the source image")
self.live.check_free_space()
@@ -338,41 +334,7 @@ class ReleaseWriter(QObject):
self.runningChanged.emit()
self.currentChanged.emit()
self.maximumChanged.emit()
-
self.status = "Writing"
-
- if useDD:
- self.status = _("WARNING: You are about to perform a destructive install. This will destroy all data and partitions on your USB drive. Press 'Create Live USB' again to continue.")
-
- else:
- if self.live.blank_mbr():
- print("AAA")
- elif not self.live.mbr_matches_syslinux_bin():
- if False: # TODO
- self.live.reset_mbr()
- else:
- self.live.log.warn(_("Warning: The Master Boot Record on your device "
- "does not match your system's syslinux MBR. If you "
- "have trouble booting this stick, try running the "
- "liveusb-creator with the --reset-mbr option."))
-
- try:
- self.live.mount_device()
- self.status = 'Drive mounted'
- except LiveUSBError, e:
- self.status(e.args[0])
- self._running = False
- self.runningChanged.emit()
- except OSError, e:
- self.status = _('Unable to mount device')
- self._running = False
- self.runningChanged.emit()
-
- if self.live.existing_liveos():
- self.status = _("Your device already contains a LiveOS.\nIf you "
- "continue, this will be overwritten.")
- #TODO
-
self.worker.start()
@pyqtSlot()
@@ -434,6 +396,7 @@ class ReleaseWriter(QObject):
class Release(QObject):
screenshotsChanged = pyqtSignal()
+ infoChanged = pyqtSignal()
statusChanged = pyqtSignal()
pathChanged = pyqtSignal()
sizeChanged = pyqtSignal()
@@ -455,6 +418,7 @@ class Release(QObject):
self._screenshots = screenshots
self._url = url
self._path = ''
+ self._info = ''
if self._logo == '':
if self._name == 'Fedora Workstation':
@@ -484,6 +448,8 @@ class Release(QObject):
self._writer = ReleaseWriter(self)
+ self._download.runningChanged.connect(self.inspectDestination)
+
self.pathChanged.connect(self.statusChanged)
self._download.runningChanged.connect(self.statusChanged)
self._writer.runningChanged.connect(self.statusChanged)
@@ -499,6 +465,36 @@ class Release(QObject):
def write(self):
self._writer.run()
+ @pyqtSlot()
+ def inspectDestination(self):
+ if self.live.blank_mbr():
+ self.info = _("The Master Boot Record on your device is blank. Writing the image will reset the MBR on this device")
+ elif not self.live.mbr_matches_syslinux_bin():
+ self.info = _("The Master Boot Record on your device does not match your system's syslinux MBR.\n"
+ "If you have trouble booting it, try setting the \"Reset the MBR\" advanced option")
+
+ try:
+ self.live.mount_device()
+ except LiveUSBError, e:
+ self.info = e.args[0]
+ self._running = False
+ self.runningChanged.emit()
+ except OSError, e:
+ self.info = _('Unable to mount device')
+ self._running = False
+ self.runningChanged.emit()
+
+ if self.live.existing_liveos():
+ self.info += _("\nYour device already contains a LiveOS. If you continue, this will be overwritten.")
+ #TODO
+
+ self.live.verify_filesystem()
+ if not self.live.drive['uuid'] and not self.live.label:
+ self.parent.status = _("Error: Cannot set the label or obtain "
+ "the UUID of your device. Unable to continue.")
+ #self.live.log.removeHandler(handler)
+ return
+
@pyqtProperty(int, constant=True)
def index(self):
return self._index
@@ -591,6 +587,16 @@ class Release(QObject):
else:
return 'Finished'
+ @pyqtProperty(str, notify=infoChanged)
+ def info(self):
+ return self._info
+
+ @info.setter
+ def info(self, value):
+ if self._info != value:
+ self._info = value
+ self.infoChanged.emit()
+
class ReleaseListModel(QAbstractListModel):
def __init__(self, parent, title=False):
QAbstractListModel.__init__(self, parent)
@@ -695,6 +701,9 @@ class LiveUSBData(QObject):
_currentIndex = 0
_currentDrive = 0
+ _options = [_("Use dd to write the image (destructive method)"), _("Reset the MBR (Master Boot Record)")]
+ _optionValues = [False, False]
+
def __init__(self, opts):
QObject.__init__(self)
self.live = LiveUSBCreator(opts=opts)
@@ -814,6 +823,14 @@ class LiveUSBData(QObject):
for r in self.releaseData:
r.download.finished = False
+ @pyqtProperty('QStringList', constant=True)
+ def options(self):
+ return self._options
+
+ @pyqtSlot(int, bool)
+ def setOption(self, index, value):
+ self._options[index] = value
+
class LiveUSBApp(QApplication):
""" Main application class """
--
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