1 # Authors: Amaury Medeiros and Paulo Ouriques
2 # Software License: GPL
4 from PyQt4.QtCore import *
5 from PyQt4.QtGui import *
7 from ui.pcsapp import PcsApp
8 from ui.pcsdevicewidget import PcsDeviceWidget
9 from ui.pcsuiutils import *
10 from ui.pcsbutton import *
11 from ui.tsuigeneralmethods import *
13 from ui.pcscustombuttons import PcsCustomButton as customButton
15 from pcswindowmanager import *
17 class PcsBackup(PcsApp):
19 def __init__(self, deviceInfo, parent=None):
20 PcsApp.__init__(self, parent)
21 self.deviceInfo = deviceInfo
23 if (self.deviceInfo != None):
24 self.windowManager = PcsWindowManager(self.deviceInfo, self)
26 self.setWindowIcon(QIcon(BACKUP_IMAGE))
27 self.setWindowTitle("%s Backup" % APPLICATION_NAME)
29 self.hLayout = QHBoxLayout()
30 self.hLayout.setMargin(8)
31 self.vLayout = QVBoxLayout()
33 spc = QSpacerItem(0,50)
34 self.optionsLayout = QVBoxLayout()
35 self.optionsLayout.addItem(spc)
37 self.optionsLayout.addItem(spc)
39 self.deviceWidget = PcsDeviceWidget(1)
40 self.deviceWidget.addBorder()
41 self.deviceWidget.addDeviceName()
42 self.deviceWidget.setDeviceInfo(self.deviceInfo)
44 self.optionsBorderLayout = QGridLayout()
45 self.optionsBorderLabel = QLabel()
46 self.optionsBorderLabel.setFixedSize(208, 205)
47 self.optionsBorderLabel.setPixmap(QPixmap(DEVICE_BACKUP_BORDER))
48 self.optionsBorderLayout.addWidget(self.optionsBorderLabel, 0, 0, Qt.AlignCenter)
49 self.optionsBorderLayout.addLayout(self.optionsLayout, 0, 0, Qt.AlignCenter)
50 self.hLayout.addLayout(self.optionsBorderLayout)
51 self.hLayout.addWidget(self.deviceWidget)
54 l1 = QLabel("<font style='color: #333333'; size=2>Main</font>")
55 self.vLayout.addItem(TOP_SPACER)
56 self.vLayout.addWidget(l1)
57 self.vLayout.addLayout(self.hLayout)
58 informationLayout = QHBoxLayout()
59 spc = QSpacerItem(10, 0)
61 iconAlert.setPixmap(QPixmap(ICON_ALERT))
62 information = QLabel("<font style='color:"\
64 "Select an action.</font>")
65 informationLayout.addItem(spc)
66 informationLayout.addWidget(iconAlert)
67 informationLayout.addWidget(information, Qt.AlignLeft)
68 self.vLayout.addLayout(informationLayout)
69 self.vLayout.setMargin(8)
70 self.setLayout(self.vLayout)
72 def openBackupWizard(self):
74 if(self.deviceInfo and self.deviceInfo.ip != None):
75 backup_wizard = self.windowManager.getNewBackup()
76 centralize(backup_wizard)
77 backup_wizard.setGeometry(self.geometry())
79 self.setVisible(False)
80 self.setGeometry(backup_wizard.geometry())
82 showMessageBox("No devices were found.", "")
84 def openBackupManagerDialog(self):
85 if(self.deviceInfo and self.deviceInfo.ip != None):
86 backupManager = self.windowManager.getBackupManager()
87 centralize(backupManager)
89 self.setVisible(False)
91 showMessageBox("No devices were found.", "")
93 def openRestoreBackupDialog(self):
94 if(self.deviceInfo and self.deviceInfo.ip != None):
95 restoreBackup = self.windowManager.getRestoreBackup()
96 centralize(restoreBackup)
98 self.setVisible(False)
100 showMessageBox("No devices were found.", "")
102 def _addButtons(self):
103 infList = [("New Backup ", ICON_NEW_BACKUP),
104 ("Manage Backups", ICON_MANAGER_BACKUP),
105 ("Restore Backups ", ICON_RESTORE_BACKUP)]
108 buttonOptions = PcsButton(inf[0])
109 buttonOptions.setStyleSheet("background-image\
110 :url("+ BUTTON_WITH_ICON_BG +");\
111 qproperty-icon:url("+inf[1]+");\
112 min-height:50px; min-width:188px;\
113 max-height:50px; max-width:188px;\
114 qproperty-iconSize: 43px 36px")
115 self.optionsLayout.addWidget(buttonOptions)
116 buttonsList.append(buttonOptions)
118 self.connect(buttonsList[0], SIGNAL("clicked()"),
119 self.openBackupWizard)
120 self.connect(buttonsList[1], SIGNAL("clicked()"),
121 self.openBackupManagerDialog)
122 self.connect(buttonsList[2], SIGNAL("clicked()"),
123 self.openRestoreBackupDialog)