Helpviewer/Sync/SyncCheckPage.py

changeset 1700
40c911b8c0dd
parent 1695
7b115f986d48
child 1701
9eee32bac32e
equal deleted inserted replaced
1699:10706f6ad9d2 1700:40c911b8c0dd
7 Module implementing the synchronization status wizard page. 7 Module implementing the synchronization status wizard page.
8 """ 8 """
9 9
10 import os 10 import os
11 11
12 from PyQt4.QtCore import QByteArray 12 from PyQt4.QtCore import QByteArray, QTimer
13 from PyQt4.QtGui import QWizardPage, QMovie 13 from PyQt4.QtGui import QWizardPage, QMovie
14 14
15 from . import SyncGlobals 15 from . import SyncGlobals
16 16
17 from .Ui_SyncCheckPage import Ui_SyncCheckPage 17 from .Ui_SyncCheckPage import Ui_SyncCheckPage
45 45
46 forceUpload = self.field("ReencryptData") 46 forceUpload = self.field("ReencryptData")
47 47
48 syncMgr = Helpviewer.HelpWindow.HelpWindow.syncManager() 48 syncMgr = Helpviewer.HelpWindow.HelpWindow.syncManager()
49 syncMgr.syncError.connect(self.__syncError) 49 syncMgr.syncError.connect(self.__syncError)
50 syncMgr.syncStatus.connect(self.__updatePage) 50 syncMgr.syncStatus.connect(self.__updateMessages)
51 syncMgr.syncFinished.connect(self.__updateLabels)
51 52
52 if Preferences.getHelp("SyncType") == SyncGlobals.SyncTypeFtp: 53 if Preferences.getHelp("SyncType") == SyncGlobals.SyncTypeFtp:
53 self.handlerLabel.setText(self.trUtf8("FTP")) 54 self.handlerLabel.setText(self.trUtf8("FTP"))
54 self.hostLabel.setText(Preferences.getHelp("SyncFtpServer")) 55 self.infoLabel.setText(self.trUtf8("Host:"))
56 self.infoDataLabel.setText(Preferences.getHelp("SyncFtpServer"))
55 elif Preferences.getHelp("SyncType") == SyncGlobals.SyncTypeDirectory: 57 elif Preferences.getHelp("SyncType") == SyncGlobals.SyncTypeDirectory:
56 self.handlerLabel.setText(self.trUtf8("Shared Directory")) 58 self.handlerLabel.setText(self.trUtf8("Shared Directory"))
57 self.hostLabel.setText(Preferences.getHelp("SyncDirectoryPath")) 59 self.infoLabel.setText(self.trUtf8("Directory:"))
60 self.infoDataLabel.setText(Preferences.getHelp("SyncDirectoryPath"))
58 else: 61 else:
59 self.handlerLabel.setText(self.trUtf8("No Synchronization")) 62 self.handlerLabel.setText(self.trUtf8("No Synchronization"))
60 self.hostLabel.setText("") 63 self.hostLabel.setText("")
61 64
62 self.bookmarkMsgLabel.setText("") 65 self.bookmarkMsgLabel.setText("")
63 self.historyMsgLabel.setText("") 66 self.historyMsgLabel.setText("")
64 self.passwordsMsgLabel.setText("") 67 self.passwordsMsgLabel.setText("")
65 self.userAgentsMsgLabel.setText("") 68 self.userAgentsMsgLabel.setText("")
69 self.speedDialMsgLabel.setText("")
66 70
67 if not syncMgr.syncEnabled(): 71 if not syncMgr.syncEnabled():
68 self.bookmarkLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png")) 72 self.bookmarkLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png"))
69 self.historyLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png")) 73 self.historyLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png"))
70 self.passwordsLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png")) 74 self.passwordsLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png"))
71 self.userAgentsLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png")) 75 self.userAgentsLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png"))
76 self.speedDialLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png"))
72 return 77 return
73 78
74 animationFile = os.path.join(getConfig("ericPixDir"), "loading.gif") 79 animationFile = os.path.join(getConfig("ericPixDir"), "loading.gif")
75 80
76 # bookmarks 81 # bookmarks
95 if Preferences.getHelp("SyncUserAgents"): 100 if Preferences.getHelp("SyncUserAgents"):
96 self.__makeAnimatedLabel(animationFile, self.userAgentsLabel) 101 self.__makeAnimatedLabel(animationFile, self.userAgentsLabel)
97 else: 102 else:
98 self.userAgentsLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png")) 103 self.userAgentsLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png"))
99 104
100 syncMgr.loadSettings(forceUpload=forceUpload) 105 # speed dial settings
106 if Preferences.getHelp("SyncSpeedDial"):
107 self.__makeAnimatedLabel(animationFile, self.speedDialLabel)
108 else:
109 self.speedDialLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png"))
110
111 QTimer.singleShot(0, lambda: syncMgr.loadSettings(forceUpload=forceUpload))
101 112
102 def __makeAnimatedLabel(self, fileName, label): 113 def __makeAnimatedLabel(self, fileName, label):
103 """ 114 """
104 Private slot to create an animated label. 115 Private slot to create an animated label.
105 116
109 movie = QMovie(fileName, QByteArray(), label) 120 movie = QMovie(fileName, QByteArray(), label)
110 movie.setSpeed(100) 121 movie.setSpeed(100)
111 label.setMovie(movie) 122 label.setMovie(movie)
112 movie.start() 123 movie.start()
113 124
114 def __updatePage(self, type_, done, msg): 125 def __updateMessages(self, type_, msg):
115 """ 126 """
116 Private slot to update the synchronization status info. 127 Private slot to update the synchronization status info.
117 128
118 @param type_ type of synchronization data (string) 129 @param type_ type of synchronization data (string)
119 @param done flag indicating success (boolean)
120 @param msg synchronization message (string) 130 @param msg synchronization message (string)
121 """ 131 """
122 if type_ == "bookmarks": 132 if type_ == "bookmarks":
123 if done: 133 self.bookmarkMsgLabel.setText(msg)
134 elif type_ == "history":
135 self.historyMsgLabel.setText(msg)
136 elif type_ == "passwords":
137 self.passwordsMsgLabel.setText(msg)
138 elif type_ == "useragents":
139 self.userAgentsMsgLabel.setText(msg)
140 elif type_ == "speeddial":
141 self.speedDialMsgLabel.setText(msg)
142
143 def __updateLabels(self, type_, status, download):
144 """
145 Private slot to handle a finished synchronization event.
146
147 @param type_ type of the synchronization event (string one
148 of "bookmarks", "history", "passwords" or "useragents")
149 @param status flag indicating success (boolean)
150 @param download flag indicating a download of a file (boolean)
151 """
152 if type_ == "bookmarks":
153 if status:
124 self.bookmarkLabel.setPixmap( 154 self.bookmarkLabel.setPixmap(
125 UI.PixmapCache.getPixmap("syncCompleted.png")) 155 UI.PixmapCache.getPixmap("syncCompleted.png"))
126 else: 156 else:
127 self.bookmarkLabel.setPixmap(UI.PixmapCache.getPixmap("syncFailed.png")) 157 self.bookmarkLabel.setPixmap(UI.PixmapCache.getPixmap("syncFailed.png"))
128 self.bookmarkMsgLabel.setText(msg)
129 elif type_ == "history": 158 elif type_ == "history":
130 if done: 159 if status:
131 self.historyLabel.setPixmap(UI.PixmapCache.getPixmap("syncCompleted.png")) 160 self.historyLabel.setPixmap(UI.PixmapCache.getPixmap("syncCompleted.png"))
132 else: 161 else:
133 self.historyLabel.setPixmap(UI.PixmapCache.getPixmap("syncFailed.png")) 162 self.historyLabel.setPixmap(UI.PixmapCache.getPixmap("syncFailed.png"))
134 self.historyMsgLabel.setText(msg)
135 elif type_ == "passwords": 163 elif type_ == "passwords":
136 if done: 164 if status:
137 self.passwordsLabel.setPixmap( 165 self.passwordsLabel.setPixmap(
138 UI.PixmapCache.getPixmap("syncCompleted.png")) 166 UI.PixmapCache.getPixmap("syncCompleted.png"))
139 else: 167 else:
140 self.passwordsLabel.setPixmap(UI.PixmapCache.getPixmap("syncFailed.png")) 168 self.passwordsLabel.setPixmap(UI.PixmapCache.getPixmap("syncFailed.png"))
141 self.passwordsMsgLabel.setText(msg)
142 elif type_ == "useragents": 169 elif type_ == "useragents":
143 if done: 170 if status:
144 self.userAgentsLabel.setPixmap( 171 self.userAgentsLabel.setPixmap(
145 UI.PixmapCache.getPixmap("syncCompleted.png")) 172 UI.PixmapCache.getPixmap("syncCompleted.png"))
146 else: 173 else:
147 self.userAgentsLabel.setPixmap(UI.PixmapCache.getPixmap("syncFailed.png")) 174 self.userAgentsLabel.setPixmap(UI.PixmapCache.getPixmap("syncFailed.png"))
148 self.userAgentsMsgLabel.setText(msg) 175 elif type_ == "speeddial":
176 if status:
177 self.speedDialLabel.setPixmap(
178 UI.PixmapCache.getPixmap("syncCompleted.png"))
179 else:
180 self.speedDialLabel.setPixmap(UI.PixmapCache.getPixmap("syncFailed.png"))
149 181
150 def __syncError(self, message): 182 def __syncError(self, message):
151 """ 183 """
152 Private slot to handle general synchronization issues. 184 Private slot to handle general synchronization issues.
153 185

eric ide

mercurial