+++ /dev/null
-# Authors: Amaury Medeiros and Paulo Ouriques
-# Software License: GPL
-
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-
-from ui.pcsuiutils import *
-from pcsbackupmanagerui import *
-from pcsrestorebackupui import *
-from style.styleTabletSuite import *
-
-
-class PcsProgressWizard(QWizardPage):
-
- def __init__(self, deviceInfo, wizard, windowManager, parent = None):
- QWizardPage.__init__(self, parent)
- self.windowManager = windowManager
- self.deviceInfo = deviceInfo
- self.wizard = wizard
- self.layout = QVBoxLayout()
- self.layout.setMargin(0)
- self.cancelButton = QPushButton("Cancel")
- self.doneButton = QPushButton("Done")
- self.completeReportButton = QPushButton("View Complete Report")
- self.lockMenuButtons = True
- self._insertLayout()
-
- def _insertLayout(self, name = ""):
- self.vLayout = QVBoxLayout()
- self.vLayout.setMargin(0)
- self.wayLayout = self._wayLayout(name)
- buttonLayout = self._menuButtons()
- spc = QSpacerItem(0, 3)
- self.vLayout.addLayout(buttonLayout, Qt.AlignTop)
- self.vLayout.addItem(spc)
- self.vLayout.addLayout(self.wayLayout, Qt.AlignLeft)
- spc = QSpacerItem(0, 68)
- self.vLayout.addItem(spc)
- self.vLayout.addLayout(self._createCenterLayout(), Qt.AlignVCenter)
- self.vLayout.addItem(spc)
- self.vLayout.addLayout(self._createInformationsLabel(), Qt.AlignVCenter)
- self.setLayout(self.vLayout)
-
- def _menuButtons(self):
- infList = [("New Backup", SMALL_ICON_NEW_BACKUP_STYLE_SELECTED),
- ("Manager Backup", SMALL_ICON_MANAGER_BACKUP_STYLE, self._manageDialog),
- ("Restore Backup", SMALL_ICON_RESTORE_BACKUP_STYLE, self._restoreDialog)]
- buttonsLayout = QHBoxLayout()
- buttonsLayout.setMargin(0)
- for i in range(3):
- but = QPushButton(infList[i][0])
- but.setStyleSheet(infList[i][1])
- if i <> 0:
- buttonsLayout.addWidget(but, Qt.AlignLeft)
- self.connect(but, SIGNAL("clicked()"), infList[i][2])
- else:
- buttonsLayout.addWidget(but)
- return buttonsLayout
-
- def _wayLayout(self, name = ""):
- self.barLayout = QHBoxLayout()
- self.barLayout.setMargin(0)
- main = QLabel("<font style='color: #333333'; size=2>Main</font>")
- arrow1 = self._arrow()
- arrow2 = self._arrow()
- arrow3 = self._arrow()
- arrow4 = self._arrow()
- spc = QSpacerItem(2, 0)
- newBackup = QLabel("<font style='color: #333333'; size=2> New Backup</font>")
- files = QLabel("<font style='color: #333333'; size=2>Files</font>")
- folder = QLabel("<font style='color: #333333'; size=2>Folder</font>")
- if name != "":
- loading = QLabel("<font style='color: #333333'; size=2>loading</font>")
- else:
- loading = QLabel("<font style='color: #FFFFFF'; size=2>loading</font>")
- widgetList = [main, self._arrow(), newBackup, self._arrow(), files,
- self._arrow(), folder, self._arrow(), loading]
- for widget in widgetList:
- self.barLayout.addWidget(widget, Qt.AlignLeft)
- self.barLayout.addItem(spc)
- if name != "":
- newLabel = QLabel("<font style='color: #FFFFFF'; size=2>"+ name +"</font>")
- self.barLayout.addWidget(self._arrow(), Qt.AlignLeft)
- self.barLayout.addItem(spc)
- self.barLayout.addWidget(newLabel, Qt.AlignLeft)
- self.barLayout.addItem(spc)
-
- self.barLayout.addItem(QSpacerItem(300, 0))
- return self.barLayout
-
- def _manageDialog(self):
- if self.lockMenuButtons == False:
- if(self.deviceInfo and self.deviceInfo.ip != None):
- backupManager = self.windowManager.getBackupManager()
- centralize(backupManager)
- backupManager.setGeometry(self.wizard.geometry())
- backupManager.show()
- self.close()
- self.wizard.close()
- self.lockMenuButtons = True
- self._resetPage()
- else:
- self._showNoDeviceFoundMessage()
-
- def _restoreDialog(self):
- if self.lockMenuButtons == False:
- if(self.deviceInfo and self.deviceInfo.ip != None):
- restoreBackup = self.windowManager.getRestoreBackup()
- centralize(restoreBackup)
- restoreBackup.setGeometry(self.wizard.geometry())
- restoreBackup.show()
- self.wizard.close()
- self.close()
- self.lockMenuButtons = True
- self._resetPage()
- else:
- self._showNoDeviceFoundMessage()
-
- def _showNoDeviceFoundMessage(self):
- inf = QMessageBox(self)
- inf.setWindowTitle("Connect a device.")
- inf.setText("No devices were found.")
- inf.show()
-
- def _arrow(self):
- label = QLabel()
- label.setPixmap(QPixmap(BLACK_ARROW))
- return label
-
- def _createInformationsLabel(self):
- hLay = QHBoxLayout()
- spc = QSpacerItem(10, 0)
- self.infLabel = QLabel("<font style='color:"\
- "#333333'; size=2>"\
- "Do backup from Device to your PC.</font>")
- iconAlert = QLabel()
- iconAlert.setPixmap(QPixmap(ICON_ALERT))
- hLay.addItem(spc)
- hLay.addWidget(iconAlert)
- hLay.addWidget(self.infLabel, Qt.AlignLeft)
-
- return hLay
-
- def _resetPage(self):
- self.lockMenuButtons = True
- self.cancelButton.setVisible(True)
- self.doneButton.setVisible(False)
- self.progressBar.setValue(0)
- self.progressReport.setText("")
- self.categoryLabel.setText("<font style='color:"\
- "#333333'; size=2>"\
- "Backup starting...</font>")
-
- def _createCenterLayout(self):
- gridLayout = QGridLayout()
- gridLayout.setMargin(27)
-
- self.categoryLabel = QLabel("<font style='color:"\
- "#333333'; size=2>"\
- "Backup starting...</font>")
-
- bgLabel = QLabel()
- bgLabel.setPixmap(QPixmap(PROGRESS_BAR_BG))
- grid = QGridLayout()
-
- self.progressBar = QProgressBar()
- self.progressBar.setObjectName("progressBarWizard")
- self.progressBar.setValue(0)
- self.progressBar.setTextVisible(False)
-
- grid.addWidget(bgLabel, 0, 0, Qt.AlignCenter)
- grid.addWidget(self.progressBar, 0, 0, Qt.AlignCenter)
-
- self.progressReport = QLabel("")
-
- self.cancelButton.setStyleSheet(DEFAULT_BUTTON_STYLE)
- self.cancelButton.setShortcut(Qt.Key_Return)
- self.doneButton.setVisible(False)
- self.doneButton.setStyleSheet(DEFAULT_BUTTON_STYLE)
-# self.completeReportButton.setStyleSheet()
-
- 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.lockMenuButtons = False
- self.cancelButton.setVisible(False)
- self.doneButton.setVisible(True)
-
- self.categoryLabel.setText("<font style='color:"\
- "#333333'; size=2>"\
- "Backup finished.</font>")
- if not cancel:
- totalSize = "%.2f" % (self.totalSize/(1024.0**2))
-
- self.progressReport.setText("<font style='color:"\
- "#333333'; size=2>"\
- + str(self.backedUpNumber) +\
- " Files - " + totalSize + " MB</font>")
- else:
- self.progressReport.setText("<font style='color:"\
- "#333333'; size=2> Canceled")
- self.categoryLabel.setText("")
- self.progressBar.setValue(100)
-
-
- self.infLabel.setText("<font style='color:"\
- "#333333'; size=2>"\
- "Select an action</font>")
-
- def updateInfo(self, totalSize, backedUpNumber):
- self.totalSize = totalSize
- self.backedUpNumber = backedUpNumber
-
- def setProgress(self, progress):
- self.progressBar.setValue(progress)
-
- self.progressReport.setText("<font style='color:"\
- "#333333'; size=2>"\
- + str(int(progress))+\
- "% Complete</font>")
-
- def setCategory(self, category):
- self.categoryLabel.setText("<font style='color:"\
- "#333333'; size=2> Category name: "\
- + category +"</font>")
-
-
\ No newline at end of file