9 |
9 |
10 import os |
10 import os |
11 |
11 |
12 from PyQt4.QtCore import * |
12 from PyQt4.QtCore import * |
13 from PyQt4.QtGui import * |
13 from PyQt4.QtGui import * |
14 from PyQt4.QtWebKit import QWebSettings |
14 from PyQt4.QtWebKit import QWebSettings, QWebDatabase, QWebSecurityOrigin |
15 from PyQt4.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery |
15 from PyQt4.QtHelp import QHelpEngine, QHelpEngineCore, QHelpSearchQuery |
16 |
16 |
17 from .SearchWidget import SearchWidget |
17 from .SearchWidget import SearchWidget |
18 from .HelpBrowserWV import HelpBrowser |
18 from .HelpBrowserWV import HelpBrowser |
19 from .HelpTocWidget import HelpTocWidget |
19 from .HelpTocWidget import HelpTocWidget |
38 from .History.HistoryMenu import HistoryMenu |
38 from .History.HistoryMenu import HistoryMenu |
39 from .History.HistoryCompleter import HistoryCompletionModel, HistoryCompleter |
39 from .History.HistoryCompleter import HistoryCompletionModel, HistoryCompleter |
40 from .Passwords.PasswordManager import PasswordManager |
40 from .Passwords.PasswordManager import PasswordManager |
41 from .Network.NetworkAccessManager import NetworkAccessManager |
41 from .Network.NetworkAccessManager import NetworkAccessManager |
42 from .AdBlock.AdBlockManager import AdBlockManager |
42 from .AdBlock.AdBlockManager import AdBlockManager |
|
43 from .OfflineStorage.OfflineStorageConfigDialog import OfflineStorageConfigDialog |
43 |
44 |
44 from E5Gui.E5TabWidget import E5TabWidget |
45 from E5Gui.E5TabWidget import E5TabWidget |
45 from E5Gui.E5Action import E5Action |
46 from E5Gui.E5Action import E5Action |
46 |
47 |
47 from E5Network.E5NetworkMonitor import E5NetworkMonitor |
48 from E5Network.E5NetworkMonitor import E5NetworkMonitor |
313 |
314 |
314 if hasattr(QWebSettings, "PrintElementBackgrounds"): |
315 if hasattr(QWebSettings, "PrintElementBackgrounds"): |
315 settings.setAttribute(QWebSettings.PrintElementBackgrounds, |
316 settings.setAttribute(QWebSettings.PrintElementBackgrounds, |
316 Preferences.getHelp("PrintBackgrounds")) |
317 Preferences.getHelp("PrintBackgrounds")) |
317 |
318 |
|
319 if hasattr(QWebSettings, "setOfflineStoragePath"): |
|
320 settings.setAttribute(QWebSettings.OfflineStorageDatabaseEnabled, |
|
321 Preferences.getHelp("OfflineStorageDatabaseEnabled")) |
|
322 webDatabaseDir = os.path.join( |
|
323 Utilities.getConfigDir(), "browser", "webdatabases") |
|
324 if not os.path.exists(webDatabaseDir): |
|
325 os.makedirs(webDatabaseDir) |
|
326 settings.setOfflineStoragePath(webDatabaseDir) |
|
327 settings.setOfflineStorageDefaultQuota( |
|
328 Preferences.getHelp("OfflineStorageDatabaseQuota") * 1024 * 1024) |
|
329 |
318 def __initActions(self): |
330 def __initActions(self): |
319 """ |
331 """ |
320 Private method to define the user interface actions. |
332 Private method to define the user interface actions. |
321 """ |
333 """ |
322 # list of all actions |
334 # list of all actions |
874 )) |
886 )) |
875 self.connect(self.cookiesAct, SIGNAL('triggered()'), |
887 self.connect(self.cookiesAct, SIGNAL('triggered()'), |
876 self.__showCookiesConfiguration) |
888 self.__showCookiesConfiguration) |
877 self.__actions.append(self.cookiesAct) |
889 self.__actions.append(self.cookiesAct) |
878 |
890 |
|
891 self.offlineStorageAct = E5Action(self.trUtf8('Offline Storage'), |
|
892 UI.PixmapCache.getIcon("preferences-html5.png"), |
|
893 self.trUtf8('Offline &Storage...'), 0, 0, self, 'help_offline_storage') |
|
894 self.offlineStorageAct.setStatusTip(self.trUtf8( |
|
895 'Configure offline storage')) |
|
896 self.offlineStorageAct.setWhatsThis(self.trUtf8( |
|
897 """<b>Offline Storage</b>""" |
|
898 """<p>Opens a dialog to configure offline storage.</p>""" |
|
899 )) |
|
900 self.connect(self.offlineStorageAct, SIGNAL('triggered()'), |
|
901 self.__showOfflineStorageConfiguration) |
|
902 self.__actions.append(self.offlineStorageAct) |
|
903 |
879 self.syncTocAct = E5Action(self.trUtf8('Sync with Table of Contents'), |
904 self.syncTocAct = E5Action(self.trUtf8('Sync with Table of Contents'), |
880 UI.PixmapCache.getIcon("syncToc.png"), |
905 UI.PixmapCache.getIcon("syncToc.png"), |
881 self.trUtf8('Sync with Table of Contents'), |
906 self.trUtf8('Sync with Table of Contents'), |
882 0, 0, self, 'help_sync_toc') |
907 0, 0, self, 'help_sync_toc') |
883 self.syncTocAct.setStatusTip(self.trUtf8( |
908 self.syncTocAct.setStatusTip(self.trUtf8( |
990 )) |
1015 )) |
991 self.connect(self.clearIconsAct, SIGNAL('triggered()'), self.__clearIconsDatabase) |
1016 self.connect(self.clearIconsAct, SIGNAL('triggered()'), self.__clearIconsDatabase) |
992 self.__actions.append(self.clearIconsAct) |
1017 self.__actions.append(self.clearIconsAct) |
993 |
1018 |
994 self.searchEnginesAct = E5Action(self.trUtf8('Configure Search Engines'), |
1019 self.searchEnginesAct = E5Action(self.trUtf8('Configure Search Engines'), |
995 self.trUtf8('Configure &Search Engines...'), |
1020 self.trUtf8('Configure Search &Engines...'), |
996 0, 0, |
1021 0, 0, |
997 self, 'help_search_engines') |
1022 self, 'help_search_engines') |
998 self.searchEnginesAct.setStatusTip(self.trUtf8( |
1023 self.searchEnginesAct.setStatusTip(self.trUtf8( |
999 'Configure the available search engines')) |
1024 'Configure the available search engines')) |
1000 self.searchEnginesAct.setWhatsThis(self.trUtf8( |
1025 self.searchEnginesAct.setWhatsThis(self.trUtf8( |
1147 menu = mb.addMenu(self.trUtf8('&Settings')) |
1172 menu = mb.addMenu(self.trUtf8('&Settings')) |
1148 menu.setTearOffEnabled(True) |
1173 menu.setTearOffEnabled(True) |
1149 menu.addAction(self.prefAct) |
1174 menu.addAction(self.prefAct) |
1150 menu.addAction(self.acceptedLanguagesAct) |
1175 menu.addAction(self.acceptedLanguagesAct) |
1151 menu.addAction(self.cookiesAct) |
1176 menu.addAction(self.cookiesAct) |
|
1177 menu.addAction(self.offlineStorageAct) |
1152 menu.addSeparator() |
1178 menu.addSeparator() |
1153 menu.addAction(self.searchEnginesAct) |
1179 menu.addAction(self.searchEnginesAct) |
1154 menu.addSeparator() |
1180 menu.addSeparator() |
1155 menu.addAction(self.passwordsAct) |
1181 menu.addAction(self.passwordsAct) |
1156 menu.addSeparator() |
1182 menu.addSeparator() |
1277 settingstb.setObjectName("SettingsToolBar") |
1303 settingstb.setObjectName("SettingsToolBar") |
1278 settingstb.setIconSize(UI.Config.ToolBarIconSize) |
1304 settingstb.setIconSize(UI.Config.ToolBarIconSize) |
1279 settingstb.addAction(self.prefAct) |
1305 settingstb.addAction(self.prefAct) |
1280 settingstb.addAction(self.acceptedLanguagesAct) |
1306 settingstb.addAction(self.acceptedLanguagesAct) |
1281 settingstb.addAction(self.cookiesAct) |
1307 settingstb.addAction(self.cookiesAct) |
|
1308 settingstb.addAction(self.offlineStorageAct) |
1282 |
1309 |
1283 helptb = self.addToolBar(self.trUtf8("Help")) |
1310 helptb = self.addToolBar(self.trUtf8("Help")) |
1284 helptb.setObjectName("HelpToolBar") |
1311 helptb.setObjectName("HelpToolBar") |
1285 helptb.setIconSize(UI.Config.ToolBarIconSize) |
1312 helptb.setIconSize(UI.Config.ToolBarIconSize) |
1286 helptb.addAction(self.whatsThisAct) |
1313 helptb.addAction(self.whatsThisAct) |
2034 txt = self.trUtf8("""<b>Are you sure you want to turn on private""" |
2061 txt = self.trUtf8("""<b>Are you sure you want to turn on private""" |
2035 """ browsing?</b><p>When private browsing is turned on,""" |
2062 """ browsing?</b><p>When private browsing is turned on,""" |
2036 """ web pages are not added to the history, searches""" |
2063 """ web pages are not added to the history, searches""" |
2037 """ are not added to the list of recent searches and""" |
2064 """ are not added to the list of recent searches and""" |
2038 """ web site icons and cookies are not stored.""" |
2065 """ web site icons and cookies are not stored.""" |
|
2066 """ HTML5 offline storage will be deactivated.""" |
2039 """ Until you close the window, you can still click""" |
2067 """ Until you close the window, you can still click""" |
2040 """ the Back and Forward buttons to return to the""" |
2068 """ the Back and Forward buttons to return to the""" |
2041 """ web pages you have opened.</p>""") |
2069 """ web pages you have opened.</p>""") |
2042 res = QMessageBox.question(self, "", txt, |
2070 res = QMessageBox.question(self, "", txt, |
2043 QMessageBox.StandardButtons(\ |
2071 QMessageBox.StandardButtons(\ |
2273 Private slot to configure the cookies handling. |
2301 Private slot to configure the cookies handling. |
2274 """ |
2302 """ |
2275 dlg = CookiesConfigurationDialog(self) |
2303 dlg = CookiesConfigurationDialog(self) |
2276 dlg.exec_() |
2304 dlg.exec_() |
2277 |
2305 |
|
2306 def __showOfflineStorageConfiguration(self): |
|
2307 """ |
|
2308 Private slot to configure the offline storage. |
|
2309 """ |
|
2310 dlg = OfflineStorageConfigDialog(self) |
|
2311 if dlg.exec_() == QDialog.Accepted: |
|
2312 dlg.storeData() |
|
2313 self.__initWebSettings() |
|
2314 |
2278 def setLoading(self, widget): |
2315 def setLoading(self, widget): |
2279 """ |
2316 """ |
2280 Public method to set the loading icon. |
2317 Public method to set the loading icon. |
2281 |
2318 |
2282 @param widget reference to the widget to set the icon for (QWidget) |
2319 @param widget reference to the widget to set the icon for (QWidget) |
2711 """ |
2748 """ |
2712 Private slot to clear the private data. |
2749 Private slot to clear the private data. |
2713 """ |
2750 """ |
2714 dlg = HelpClearPrivateDataDialog(self) |
2751 dlg = HelpClearPrivateDataDialog(self) |
2715 if dlg.exec_() == QDialog.Accepted: |
2752 if dlg.exec_() == QDialog.Accepted: |
2716 history, searches, favicons, cache, cookies, passwords = dlg.getData() |
2753 history, searches, favicons, cache, cookies, passwords, databases = \ |
2717 # browsing history, search history, favicons, disk cache, cookies, passwords |
2754 dlg.getData() |
|
2755 # browsing history, search history, favicons, disk cache, cookies, |
|
2756 # passwords, web databases |
2718 if history: |
2757 if history: |
2719 self.historyManager().clear() |
2758 self.historyManager().clear() |
2720 if searches: |
2759 if searches: |
2721 self.searchEdit.clear() |
2760 self.searchEdit.clear() |
2722 if favicons: |
2761 if favicons: |
2728 pass |
2767 pass |
2729 if cookies: |
2768 if cookies: |
2730 self.cookieJar().clear() |
2769 self.cookieJar().clear() |
2731 if passwords: |
2770 if passwords: |
2732 self.passwordManager().clear() |
2771 self.passwordManager().clear() |
|
2772 if databases: |
|
2773 if hasattr(QWebDatabase, "removeAllDatabases"): |
|
2774 QWebDatabase.removeAllDatabases() |
|
2775 else: |
|
2776 for securityOrigin in QWebSecurityOrigin.allOrigins(): |
|
2777 for database in securityOrigin.databases(): |
|
2778 QWebDatabase.removeDatabase(database) |
2733 |
2779 |
2734 def __showEnginesConfigurationDialog(self): |
2780 def __showEnginesConfigurationDialog(self): |
2735 """ |
2781 """ |
2736 Private slot to show the search engines configuration dialog. |
2782 Private slot to show the search engines configuration dialog. |
2737 """ |
2783 """ |