--- /dev/null
+# 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("<font style='color:"\
+ "#333333'; size=2>"\
+ +str(action).capitalize()+
+ " in progress...</font>")
+
+ self.actionLabel.setText('''<font style=color:
+ black; size=3>
+ '''+ message +'''</font>''')
+
+ 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("<font style='color:"\
+ "#333333'; size=2>"+\
+ str(self.action).capitalize()
+ +" finished.</font>")
+ if not cancel:
+ totalSize = "%.2f" % (self.totalSize/(1024.0**2))
+
+ self.progressReport.setText("<font style='color:"\
+ "#333333'; size=2>"\
+ + str(self.numberOfFiles) +\
+ " Files - " + totalSize + " MB</font>")
+ else:
+ self.progressReport.setText("<font style='color:"\
+ "#333333'; size=2> 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("<font style='color:"\
+ "#333333'; size=2>"\
+ + progress +\
+ "% Complete</font>")
+
+ def setCategory(self, catogory):
+ self.categoryLabel.setText("<font style='color:"\
+ "#333333'; size=2> Category name: "\
+ + catogory +"</font>")
+
+
+
\ No newline at end of file