312 self.connect(self.page(), SIGNAL('downloadRequested(const QNetworkRequest &)'), |
312 self.connect(self.page(), SIGNAL('downloadRequested(const QNetworkRequest &)'), |
313 self.__downloadRequested) |
313 self.__downloadRequested) |
314 self.connect(self.page(), SIGNAL("frameCreated(QWebFrame *)"), |
314 self.connect(self.page(), SIGNAL("frameCreated(QWebFrame *)"), |
315 self.__addExternalBinding) |
315 self.__addExternalBinding) |
316 self.__addExternalBinding(self.page().mainFrame()) |
316 self.__addExternalBinding(self.page().mainFrame()) |
|
317 |
|
318 self.connect(self.page(), SIGNAL('databaseQuotaExceeded(QWebFrame*, QString)'), |
|
319 self.__databaseQuotaExceeded) |
317 |
320 |
318 self.connect(self.mw.openSearchManager(), |
321 self.connect(self.mw.openSearchManager(), |
319 SIGNAL("currentEngineChanged()"), |
322 SIGNAL("currentEngineChanged()"), |
320 self.__currentEngineChanged) |
323 self.__currentEngineChanged) |
321 |
324 |
991 """ |
994 """ |
992 Private slot to handle the icon change. |
995 Private slot to handle the icon change. |
993 """ |
996 """ |
994 self.mw.iconChanged(self.icon()) |
997 self.mw.iconChanged(self.icon()) |
995 |
998 |
|
999 def __databaseQuotaExceeded(self, frame, databaseName): |
|
1000 """ |
|
1001 Private slot to handle the case, where the database quota is exceeded. |
|
1002 |
|
1003 @param frame reference to the frame (QWebFrame) |
|
1004 @param databaseName name of the web database (string) |
|
1005 """ |
|
1006 securityOrigin = frame.securityOrigin() |
|
1007 if securityOrigin.databaseQuota() > 0 and \ |
|
1008 securityOrigin.databaseUsage() == 0: |
|
1009 # cope with a strange behavior of Qt 4.6, if a database is |
|
1010 # accessed for the first time |
|
1011 return |
|
1012 |
|
1013 res = QMessageBox.question(self, |
|
1014 self.trUtf8("Web Database Quota"), |
|
1015 self.trUtf8("""<p>The database quota of <strong>{0}</strong> has""" |
|
1016 """ been exceeded while accessing database <strong>{1}""" |
|
1017 """</strong>.</p><p>Shall it be changed?</p>""")\ |
|
1018 .format(self.__dataString(securityOrigin.databaseQuota()), databaseName), |
|
1019 QMessageBox.StandardButtons(\ |
|
1020 QMessageBox.No | \ |
|
1021 QMessageBox.Yes), |
|
1022 QMessageBox.Yes) |
|
1023 if res == QMessageBox.Yes: |
|
1024 newQuota, ok = QInputDialog.getInteger(\ |
|
1025 self, |
|
1026 self.trUtf8("New Web Database Quota"), |
|
1027 self.trUtf8("Enter the new quota in MB (current = {0}, used = {1}; " |
|
1028 "step size = 5 MB):"\ |
|
1029 .format(self.__dataString(securityOrigin.databaseQuota()), |
|
1030 self.__dataString(securityOrigin.databaseUsage()))), |
|
1031 securityOrigin.databaseQuota() // (1024 * 1024), 0, 2147483647, 5) |
|
1032 if ok: |
|
1033 securityOrigin.setDatabaseQuota(newQuota * 1024 * 1024) |
|
1034 |
|
1035 def __dataString(self, size): |
|
1036 """ |
|
1037 Private method to generate a formatted data string. |
|
1038 |
|
1039 @param size size to be formatted (integer) |
|
1040 @return formatted data string (string) |
|
1041 """ |
|
1042 unit = "" |
|
1043 if size < 1024: |
|
1044 unit = self.trUtf8("bytes") |
|
1045 elif size < 1024 * 1024: |
|
1046 size /= 1024 |
|
1047 unit = self.trUtf8("kB") |
|
1048 else: |
|
1049 size /= 1024 * 1024 |
|
1050 unit = self.trUtf8("MB") |
|
1051 return "{0:.1f} {1}".format(size, unit) |
|
1052 |
996 ############################################################################ |
1053 ############################################################################ |
997 ## Miscellaneous methods below |
1054 ## Miscellaneous methods below |
998 ############################################################################ |
1055 ############################################################################ |
999 |
1056 |
1000 def createWindow(self, windowType): |
1057 def createWindow(self, windowType): |