33 from .Bookmarks.BookmarkNode import BookmarkNode |
33 from .Bookmarks.BookmarkNode import BookmarkNode |
34 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog |
34 from .Bookmarks.AddBookmarkDialog import AddBookmarkDialog |
35 from .Bookmarks.BookmarksDialog import BookmarksDialog |
35 from .Bookmarks.BookmarksDialog import BookmarksDialog |
36 from .History.HistoryManager import HistoryManager |
36 from .History.HistoryManager import HistoryManager |
37 from .History.HistoryMenu import HistoryMenu |
37 from .History.HistoryMenu import HistoryMenu |
38 from .History.HistoryCompleter import HistoryCompletionModel, HistoryCompleter |
|
39 from .Passwords.PasswordManager import PasswordManager |
38 from .Passwords.PasswordManager import PasswordManager |
40 from .Network.NetworkAccessManager import NetworkAccessManager |
39 from .Network.NetworkAccessManager import NetworkAccessManager |
41 from .AdBlock.AdBlockManager import AdBlockManager |
40 from .AdBlock.AdBlockManager import AdBlockManager |
42 from .OfflineStorage.OfflineStorageConfigDialog import OfflineStorageConfigDialog |
41 from .OfflineStorage.OfflineStorageConfigDialog import OfflineStorageConfigDialog |
43 from .UserAgent.UserAgentMenu import UserAgentMenu |
42 from .UserAgent.UserAgentMenu import UserAgentMenu |
102 self.fromEric = fromEric |
102 self.fromEric = fromEric |
103 self.initShortcutsOnly = initShortcutsOnly |
103 self.initShortcutsOnly = initShortcutsOnly |
104 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png")) |
104 self.setWindowIcon(UI.PixmapCache.getIcon("eric.png")) |
105 |
105 |
106 self.mHistory = [] |
106 self.mHistory = [] |
107 self.pathCombo = None |
|
108 |
107 |
109 if self.initShortcutsOnly: |
108 if self.initShortcutsOnly: |
110 self.__initActions() |
109 self.__initActions() |
111 else: |
110 else: |
112 self.__helpEngine = \ |
111 self.__helpEngine = \ |
113 QHelpEngine(os.path.join(Utilities.getConfigDir(), |
112 QHelpEngine(os.path.join(Utilities.getConfigDir(), |
114 "browser", "eric5help.qhc"), self) |
113 "browser", "eric5help.qhc"), self) |
115 self.__helpEngine.warning.connect(self.__warning) |
114 self.__helpEngine.warning.connect(self.__warning) |
116 self.__helpInstaller = None |
115 self.__helpInstaller = None |
117 |
116 |
118 # Attributes for WebKit based browser |
|
119 self.__progressBar = None |
|
120 |
|
121 self.tabWidget = HelpTabWidget(self) |
117 self.tabWidget = HelpTabWidget(self) |
122 self.tabWidget.currentChanged[int].connect(self.__currentChanged) |
118 self.tabWidget.currentChanged[int].connect(self.__currentChanged) |
123 self.tabWidget.sourceChanged.connect(self.__sourceChanged) |
|
124 self.tabWidget.titleChanged.connect(self.__titleChanged) |
119 self.tabWidget.titleChanged.connect(self.__titleChanged) |
125 self.tabWidget.showMessage.connect(self.statusBar().showMessage) |
120 self.tabWidget.showMessage.connect(self.statusBar().showMessage) |
126 |
121 |
127 self.findDlg = SearchWidget(self, self) |
122 self.findDlg = SearchWidget(self, self) |
128 centralWidget = QWidget() |
123 centralWidget = QWidget() |
1297 gotb.addAction(self.reloadAct) |
1292 gotb.addAction(self.reloadAct) |
1298 gotb.addAction(self.stopAct) |
1293 gotb.addAction(self.stopAct) |
1299 gotb.addAction(self.homeAct) |
1294 gotb.addAction(self.homeAct) |
1300 gotb.addSeparator() |
1295 gotb.addSeparator() |
1301 |
1296 |
1302 self.iconLabel = QLabel() |
1297 self.__navigationSplitter = QSplitter(gotb) |
1303 gotb.addWidget(self.iconLabel) |
1298 self.__navigationSplitter.addWidget(self.tabWidget.stackedUrlBar()) |
1304 |
1299 |
1305 self.pathCombo = QComboBox() |
|
1306 self.pathCombo.setDuplicatesEnabled(False) |
|
1307 self.pathCombo.setInsertPolicy(QComboBox.InsertAtTop) |
|
1308 self.pathCombo.setEditable(1) |
|
1309 self.pathCombo.setAutoCompletion(True) |
|
1310 self.pathCombo.activated[str].connect(self.__pathSelected) |
|
1311 self.pathCombo.setWhatsThis(self.trUtf8( |
|
1312 """<p>Enter the help file to be displayed directly into this""" |
|
1313 """ edit field. Select a previously shown help file from the""" |
|
1314 """ drop down list.</p>""" |
|
1315 )) |
|
1316 sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) |
|
1317 sizePolicy.setHorizontalStretch(6) |
|
1318 sizePolicy.setVerticalStretch(0) |
|
1319 sizePolicy.setHeightForWidth(self.pathCombo.sizePolicy().hasHeightForWidth()) |
|
1320 self.pathCombo.setSizePolicy(sizePolicy) |
|
1321 gotb.addWidget(self.pathCombo) |
|
1322 self.pathComboDefaultColor = \ |
|
1323 self.pathCombo.lineEdit().palette().color(QPalette.Base) |
|
1324 self.__historyCompletionModel = HistoryCompletionModel(self) |
|
1325 self.__historyCompletionModel.setSourceModel( |
|
1326 self.historyManager().historyFilterModel()) |
|
1327 self.__historyCompleter = HistoryCompleter(self.__historyCompletionModel, self) |
|
1328 self.__historyCompleter.activated[str].connect(self.__pathSelected) |
|
1329 self.pathCombo.setCompleter(self.__historyCompleter) |
|
1330 |
|
1331 self.privacyLabel = QLabel() |
|
1332 gotb.addWidget(self.privacyLabel) |
|
1333 |
|
1334 gotb.addSeparator() |
|
1335 self.searchEdit = HelpWebSearchWidget(self) |
1300 self.searchEdit = HelpWebSearchWidget(self) |
1336 sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) |
1301 sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) |
1337 sizePolicy.setHorizontalStretch(2) |
1302 sizePolicy.setHorizontalStretch(2) |
1338 sizePolicy.setVerticalStretch(0) |
1303 sizePolicy.setVerticalStretch(0) |
1339 sizePolicy.setHeightForWidth(self.searchEdit.sizePolicy().hasHeightForWidth()) |
|
1340 self.searchEdit.setSizePolicy(sizePolicy) |
1304 self.searchEdit.setSizePolicy(sizePolicy) |
1341 self.searchEdit.search.connect(self.__linkActivated) |
1305 self.searchEdit.search.connect(self.__linkActivated) |
1342 gotb.addWidget(self.searchEdit) |
1306 self.__navigationSplitter.addWidget(self.searchEdit) |
|
1307 gotb.addWidget(self.__navigationSplitter) |
|
1308 |
|
1309 self.__navigationSplitter.setSizePolicy( |
|
1310 QSizePolicy.Expanding, QSizePolicy.Maximum) |
|
1311 self.__navigationSplitter.setCollapsible(0, False) |
1343 |
1312 |
1344 self.backMenu = QMenu(self) |
1313 self.backMenu = QMenu(self) |
1345 self.backMenu.aboutToShow.connect(self.__showBackMenu) |
1314 self.backMenu.aboutToShow.connect(self.__showBackMenu) |
1346 self.backMenu.triggered.connect(self.__navigationMenuActionTriggered) |
1315 self.backMenu.triggered.connect(self.__navigationMenuActionTriggered) |
1347 backButton = gotb.widgetForAction(self.backAct) |
1316 backButton = gotb.widgetForAction(self.backAct) |
1414 Utilities.compactPath(hist, self.maxMenuFilePathLen)) |
1383 Utilities.compactPath(hist, self.maxMenuFilePathLen)) |
1415 act.setData(idx) |
1384 act.setData(idx) |
1416 idx += 1 |
1385 idx += 1 |
1417 act.setIcon(HelpWindow.__getWebIcon(QUrl(hist))) |
1386 act.setIcon(HelpWindow.__getWebIcon(QUrl(hist))) |
1418 |
1387 |
1419 def __pathSelected(self, path): |
|
1420 """ |
|
1421 Private slot called when a file is selected in the combobox. |
|
1422 |
|
1423 @param path path to be shown (string) |
|
1424 """ |
|
1425 url = self.__guessUrlFromPath(path) |
|
1426 self.currentBrowser().setSource(url) |
|
1427 self.__setPathComboBackground() |
|
1428 |
|
1429 def __guessUrlFromPath(self, path): |
|
1430 """ |
|
1431 Private method to guess an URL given a path string. |
|
1432 |
|
1433 @param path path string to guess an URL for (string) |
|
1434 @return guessed URL (QUrl) |
|
1435 """ |
|
1436 manager = self.searchEdit.openSearchManager() |
|
1437 path = Utilities.fromNativeSeparators(path) |
|
1438 url = manager.convertKeywordSearchToUrl(path) |
|
1439 if url.isValid(): |
|
1440 return url |
|
1441 |
|
1442 try: |
|
1443 return QUrl.fromUserInput(path) |
|
1444 except AttributeError: |
|
1445 return QUrl(path) |
|
1446 |
|
1447 def __setPathComboBackground(self): |
|
1448 """ |
|
1449 Private slot to change the path combo background to indicate save URLs. |
|
1450 """ |
|
1451 url = QUrl(self.pathCombo.currentText()) |
|
1452 le = self.pathCombo.lineEdit() |
|
1453 p = le.palette() |
|
1454 if url.isEmpty() or url.scheme() != "https": |
|
1455 p.setBrush(QPalette.Base, self.pathComboDefaultColor) |
|
1456 else: |
|
1457 p.setBrush(QPalette.Base, QBrush(Preferences.getHelp("SaveUrlColor"))) |
|
1458 le.setPalette(p) |
|
1459 le.update() |
|
1460 |
|
1461 def __sourceChanged(self, url): |
|
1462 """ |
|
1463 Private slot called when the displayed text of the combobox is changed. |
|
1464 |
|
1465 @param url URL of the new site (QUrl) |
|
1466 """ |
|
1467 selectedURL = url.toString() |
|
1468 if selectedURL != "" and self.pathCombo is not None: |
|
1469 i = self.pathCombo.findText(selectedURL) |
|
1470 if i == -1: |
|
1471 if not QWebSettings.globalSettings()\ |
|
1472 .testAttribute(QWebSettings.PrivateBrowsingEnabled): |
|
1473 self.pathCombo.insertItem(0, selectedURL) |
|
1474 self.pathCombo.setCurrentIndex(0) |
|
1475 else: |
|
1476 self.pathCombo.setCurrentIndex(i) |
|
1477 |
|
1478 self.__setPathComboBackground() |
|
1479 |
|
1480 self.iconChanged(self.currentBrowser().icon()) |
|
1481 |
|
1482 def __titleChanged(self, title): |
1388 def __titleChanged(self, title): |
1483 """ |
1389 """ |
1484 Private slot called to handle a change of the current browsers title. |
1390 Private slot called to handle a change of the current browsers title. |
1485 |
1391 |
1486 @param title new title (string) |
1392 @param title new title (string) |
1821 """ Until you close the window, you can still click""" |
1727 """ Until you close the window, you can still click""" |
1822 """ the Back and Forward buttons to return to the""" |
1728 """ the Back and Forward buttons to return to the""" |
1823 """ web pages you have opened.</p>""") |
1729 """ web pages you have opened.</p>""") |
1824 res = E5MessageBox.yesNo(self, "", txt) |
1730 res = E5MessageBox.yesNo(self, "", txt) |
1825 if res: |
1731 if res: |
1826 settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, True) |
1732 self.setPrivateMode(True) |
1827 self.pathCombo.setInsertPolicy(QComboBox.NoInsert) |
|
1828 self.privacyLabel.setPixmap( |
|
1829 UI.PixmapCache.getPixmap("privateBrowsing.png")) |
|
1830 self.__setIconDatabasePath(False) |
|
1831 else: |
1733 else: |
1832 settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, False) |
1734 self.setPrivateMode(False) |
1833 self.pathCombo.setInsertPolicy(QComboBox.InsertAtTop) |
1735 |
1834 self.privacyLabel.setPixmap(QPixmap()) |
1736 def setPrivateMode(self, on): |
|
1737 """ |
|
1738 Public method to set the privacy mode. |
|
1739 |
|
1740 @param on flag indicating the privacy state (boolean) |
|
1741 """ |
|
1742 QWebSettings.globalSettings().setAttribute( |
|
1743 QWebSettings.PrivateBrowsingEnabled, on) |
|
1744 if on: |
|
1745 self.__setIconDatabasePath(False) |
|
1746 else: |
1835 self.__setIconDatabasePath(True) |
1747 self.__setIconDatabasePath(True) |
|
1748 self.privateBrowsingAct.setChecked(on) |
|
1749 self.privacyChanged.emit(on) |
1836 |
1750 |
1837 def currentBrowser(self): |
1751 def currentBrowser(self): |
1838 """ |
1752 """ |
1839 Public method to get a reference to the current help browser. |
1753 Public method to get a reference to the current help browser. |
1840 |
1754 |
1869 cb = self.currentBrowser() |
1783 cb = self.currentBrowser() |
1870 if cb is not None: |
1784 if cb is not None: |
1871 self.setForwardAvailable(cb.isForwardAvailable()) |
1785 self.setForwardAvailable(cb.isForwardAvailable()) |
1872 self.setBackwardAvailable(cb.isBackwardAvailable()) |
1786 self.setBackwardAvailable(cb.isBackwardAvailable()) |
1873 self.setLoadingActions(cb.isLoading()) |
1787 self.setLoadingActions(cb.isLoading()) |
1874 |
|
1875 url = cb.source().toString() |
|
1876 index2 = self.pathCombo.findText(url) |
|
1877 if index2 > -1: |
|
1878 self.pathCombo.setCurrentIndex(index2) |
|
1879 else: |
|
1880 self.pathCombo.clearEditText() |
|
1881 |
|
1882 self.__setPathComboBackground() |
|
1883 |
|
1884 self.iconChanged(cb.icon()) |
|
1885 |
1788 |
1886 def __showPreferences(self): |
1789 def __showPreferences(self): |
1887 """ |
1790 """ |
1888 Private slot to set the preferences. |
1791 Private slot to set the preferences. |
1889 """ |
1792 """ |
1938 dlg = OfflineStorageConfigDialog(self) |
1839 dlg = OfflineStorageConfigDialog(self) |
1939 if dlg.exec_() == QDialog.Accepted: |
1840 if dlg.exec_() == QDialog.Accepted: |
1940 dlg.storeData() |
1841 dlg.storeData() |
1941 self.__initWebSettings() |
1842 self.__initWebSettings() |
1942 |
1843 |
1943 ############################################################################ |
|
1944 ## Methods to support Webkit based browser below. |
|
1945 ############################################################################ |
|
1946 |
|
1947 def progressBar(self): |
|
1948 """ |
|
1949 Public method to get a reference to the load progress bar. |
|
1950 |
|
1951 @return reference to the load progress bar (QProgressBar) |
|
1952 """ |
|
1953 if self.__progressBar is None: |
|
1954 self.__progressBar = QProgressBar() |
|
1955 self.statusBar().addPermanentWidget(self.__progressBar) |
|
1956 self.__progressBar.setMaximumWidth(100) |
|
1957 self.__progressBar.setFixedHeight(16) |
|
1958 self.__progressBar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) |
|
1959 self.__progressBar.hide() |
|
1960 |
|
1961 return self.__progressBar |
|
1962 |
|
1963 @classmethod |
1844 @classmethod |
1964 def helpEngine(cls): |
1845 def helpEngine(cls): |
1965 """ |
1846 """ |
1966 Class method to get a reference to the help engine. |
1847 Class method to get a reference to the help engine. |
1967 |
1848 |
1994 Class method to get a reference to the cookie jar. |
1875 Class method to get a reference to the cookie jar. |
1995 |
1876 |
1996 @return reference to the cookie jar (CookieJar) |
1877 @return reference to the cookie jar (CookieJar) |
1997 """ |
1878 """ |
1998 return cls.networkAccessManager().cookieJar() |
1879 return cls.networkAccessManager().cookieJar() |
1999 |
|
2000 def iconChanged(self, icon): |
|
2001 """ |
|
2002 Public slot to change the icon shown to the left of the URL entry. |
|
2003 |
|
2004 @param icon icon to be shown (QIcon) |
|
2005 """ |
|
2006 self.iconLabel.setPixmap(icon.pixmap(16, 16)) |
|
2007 |
1880 |
2008 def __clearIconsDatabase(self): |
1881 def __clearIconsDatabase(self): |
2009 """ |
1882 """ |
2010 Private slot to clear the icons databse. |
1883 Private slot to clear the icons databse. |
2011 """ |
1884 """ |