X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fbackup%2Fpcsprogressdialog.py;fp=src%2Fbackup%2Fpcsprogressdialog.py;h=cf9038f2f5026426ad475e1e2bc62ddf8138e3aa;hb=256d6db84797e58f32185f042154a7c0fc54163e;hp=0000000000000000000000000000000000000000;hpb=7d8224c9f08712280a22af40325d59a19f4fb1e1;p=tablet-suite diff --git a/src/backup/pcsprogressdialog.py b/src/backup/pcsprogressdialog.py new file mode 100644 index 0000000..cf9038f --- /dev/null +++ b/src/backup/pcsprogressdialog.py @@ -0,0 +1,117 @@ +# Authors: Amaury Medeiros, Nicholas Alexander and Paulo Ouriques +# Software License: GPL + +from PyQt4.QtCore import * +from PyQt4.QtGui import * + +from style.styleTabletSuite import * +from ui.pcsuiutils import * + +class PcsProgressDialog(QDialog): + + def __init__(self, parent = None): + QDialog.__init__(self, parent, Qt.FramelessWindowHint) + self.cancelButton = QPushButton("Cancel") + self.doneButton = QPushButton("Done") + self.connect(self.doneButton, SIGNAL("clicked()"), self.close) + self.actionLabel = QLabel("Action...") + self.categoryLabel = QLabel("") + self.progressReport = QLabel("") + self.setLayout(self._insertLayout()) + + + def setAction(self, action): + self.action = action + if action == "copy": + message = "Copying..." + + elif action == "restore": + message = "Restoring..." + + self.categoryLabel.setText(""\ + +str(action).capitalize()+ + " in progress...") + + self.actionLabel.setText(''' + '''+ message +'''''') + + def _insertLayout(self): + vLay = QVBoxLayout() + vLay.addWidget(self.actionLabel) + vLay.addLayout(self._createCenterLayout()) + return vLay + + def _createCenterLayout(self): + + bgLabel = QLabel() + bgLabel.setPixmap(QPixmap(PROGRESS_BAR_DIALOG_BG)) + grid = QGridLayout() + + self.progressBar = QProgressBar() + self.progressBar.setObjectName("progressBarDialog") + self.progressBar.setValue(0) + self.progressBar.setTextVisible(False) + + grid.addWidget(bgLabel, 0, 0, Qt.AlignCenter) + grid.addWidget(self.progressBar, 0, 0, Qt.AlignCenter) + + self.cancelButton.setStyleSheet(DEFAULT_BUTTON_STYLE) + self.cancelButton.setShortcut(Qt.Key_Return) + self.doneButton.setVisible(False) + self.doneButton.setStyleSheet(DEFAULT_BUTTON_STYLE) + + gridLayout = QGridLayout() + gridLayout.setSpacing(3) + gridLayout.addWidget(self.categoryLabel, 0, 0, Qt.AlignRight) + gridLayout.addLayout(grid, 1, 0) + gridLayout.addWidget(self.progressReport, 2, 0, Qt.AlignRight) + gridLayout.addWidget(self.cancelButton, 3, 0, Qt.AlignRight) + gridLayout.addWidget(self.doneButton, 3, 0, Qt.AlignRight) + + return gridLayout + + def progressCanceled(self): + self.progressDone(True) + + def progressDone(self, cancel=False): + self.cancelButton.setVisible(False) + self.doneButton.setVisible(True) + + self.categoryLabel.setText(""+\ + str(self.action).capitalize() + +" finished.") + if not cancel: + totalSize = "%.2f" % (self.totalSize/(1024.0**2)) + + self.progressReport.setText(""\ + + str(self.numberOfFiles) +\ + " Files - " + totalSize + " MB") + else: + self.progressReport.setText(" Canceled") + self.categoryLabel.setText("") + self.progressBar.setValue(100) + + def updateInfo(self, totalSize, numberOfFiles): + self.totalSize = totalSize + self.numberOfFiles = numberOfFiles + + def setProgress(self, progress): + self.progressBar.setValue(float(progress)) + + self.progressReport.setText(""\ + + progress +\ + "% Complete") + + def setCategory(self, catogory): + self.categoryLabel.setText(" Category name: "\ + + catogory +"") + + + \ No newline at end of file