1 # Authors: Amaury Medeiros, Nicholas Alexander and Paulo Ouriques
2 # Software License: GPL
4 from PyQt4.QtCore import *
5 from PyQt4.QtGui import *
7 from style.styleTabletSuite import *
8 from ui.pcsuiutils import *
10 class PcsProgressDialog(QDialog):
12 def __init__(self, parent = None):
13 QDialog.__init__(self, parent, Qt.FramelessWindowHint)
14 self.cancelButton = QPushButton("Cancel")
15 self.doneButton = QPushButton("Done")
16 self.connect(self.doneButton, SIGNAL("clicked()"), self.close)
17 self.actionLabel = QLabel("Action...")
18 self.categoryLabel = QLabel("")
19 self.progressReport = QLabel("")
20 self.setLayout(self._insertLayout())
23 def setAction(self, action):
26 message = "Copying..."
28 elif action == "restore":
29 message = "Restoring..."
31 self.categoryLabel.setText("<font style='color:"\
33 +str(action).capitalize()+
34 " in progress...</font>")
36 self.actionLabel.setText('''<font style=color:
38 '''+ message +'''</font>''')
40 def _insertLayout(self):
42 vLay.addWidget(self.actionLabel)
43 vLay.addLayout(self._createCenterLayout())
46 def _createCenterLayout(self):
49 bgLabel.setPixmap(QPixmap(PROGRESS_BAR_DIALOG_BG))
52 self.progressBar = QProgressBar()
53 self.progressBar.setObjectName("progressBarDialog")
54 self.progressBar.setValue(0)
55 self.progressBar.setTextVisible(False)
57 grid.addWidget(bgLabel, 0, 0, Qt.AlignCenter)
58 grid.addWidget(self.progressBar, 0, 0, Qt.AlignCenter)
60 self.cancelButton.setStyleSheet(DEFAULT_BUTTON_STYLE)
61 self.cancelButton.setShortcut(Qt.Key_Return)
62 self.doneButton.setVisible(False)
63 self.doneButton.setStyleSheet(DEFAULT_BUTTON_STYLE)
65 gridLayout = QGridLayout()
66 gridLayout.setSpacing(3)
67 gridLayout.addWidget(self.categoryLabel, 0, 0, Qt.AlignRight)
68 gridLayout.addLayout(grid, 1, 0)
69 gridLayout.addWidget(self.progressReport, 2, 0, Qt.AlignRight)
70 gridLayout.addWidget(self.cancelButton, 3, 0, Qt.AlignRight)
71 gridLayout.addWidget(self.doneButton, 3, 0, Qt.AlignRight)
75 def progressCanceled(self):
76 self.progressDone(True)
78 def progressDone(self, cancel=False):
79 self.cancelButton.setVisible(False)
80 self.doneButton.setVisible(True)
82 self.categoryLabel.setText("<font style='color:"\
84 str(self.action).capitalize()
87 totalSize = "%.2f" % (self.totalSize/(1024.0**2))
89 self.progressReport.setText("<font style='color:"\
91 + str(self.numberOfFiles) +\
92 " Files - " + totalSize + " MB</font>")
94 self.progressReport.setText("<font style='color:"\
95 "#333333'; size=2> Canceled")
96 self.categoryLabel.setText("")
97 self.progressBar.setValue(100)
99 def updateInfo(self, totalSize, numberOfFiles):
100 self.totalSize = totalSize
101 self.numberOfFiles = numberOfFiles
103 def setProgress(self, progress):
104 self.progressBar.setValue(float(progress))
106 self.progressReport.setText("<font style='color:"\
111 def setCategory(self, catogory):
112 self.categoryLabel.setText("<font style='color:"\
113 "#333333'; size=2> Category name: "\
114 + catogory +"</font>")