19 QSortFilterProxyModel, |
19 QSortFilterProxyModel, |
20 QAbstractProxyModel, |
20 QAbstractProxyModel, |
21 ) |
21 ) |
22 from PyQt6.QtWidgets import QMenu |
22 from PyQt6.QtWidgets import QMenu |
23 |
23 |
24 from EricWidgets.EricModelMenu import EricModelMenu |
24 from eric7.EricWidgets.EricModelMenu import EricModelMenu |
25 from EricWidgets import EricMessageBox |
25 from eric7.EricWidgets import EricMessageBox |
26 |
26 |
27 from .HistoryModel import HistoryModel |
27 from .HistoryModel import HistoryModel |
28 |
28 |
29 import UI.PixmapCache |
29 from eric7.EricGui import EricPixmapCache |
30 |
30 |
31 |
31 |
32 class HistoryMenuModel(QAbstractProxyModel): |
32 class HistoryMenuModel(QAbstractProxyModel): |
33 """ |
33 """ |
34 Class implementing a model for the history menu. |
34 Class implementing a model for the history menu. |
340 Public method to add any actions before the tree. |
340 Public method to add any actions before the tree. |
341 |
341 |
342 @return flag indicating if any actions were added (boolean) |
342 @return flag indicating if any actions were added (boolean) |
343 """ |
343 """ |
344 if self.__historyManager is None: |
344 if self.__historyManager is None: |
345 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
345 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
346 |
346 |
347 self.__historyManager = WebBrowserWindow.historyManager() |
347 self.__historyManager = WebBrowserWindow.historyManager() |
348 self.__historyMenuModel = HistoryMenuModel( |
348 self.__historyMenuModel = HistoryMenuModel( |
349 self.__historyManager.historyTreeModel(), self |
349 self.__historyManager.historyTreeModel(), self |
350 ) |
350 ) |
374 self.__mostVisitedMenu.newBackgroundTab.connect(self.newBackgroundTab) |
374 self.__mostVisitedMenu.newBackgroundTab.connect(self.newBackgroundTab) |
375 self.__mostVisitedMenu.newWindow.connect(self.newWindow) |
375 self.__mostVisitedMenu.newWindow.connect(self.newWindow) |
376 self.__mostVisitedMenu.newPrivateWindow.connect(self.newPrivateWindow) |
376 self.__mostVisitedMenu.newPrivateWindow.connect(self.newPrivateWindow) |
377 self.addMenu(self.__mostVisitedMenu) |
377 self.addMenu(self.__mostVisitedMenu) |
378 act = self.addMenu(self.__closedTabsMenu) |
378 act = self.addMenu(self.__closedTabsMenu) |
379 act.setIcon(UI.PixmapCache.getIcon("trash")) |
379 act.setIcon(EricPixmapCache.getIcon("trash")) |
380 act.setEnabled(self.__tabWidget.canRestoreClosedTab()) |
380 act.setEnabled(self.__tabWidget.canRestoreClosedTab()) |
381 self.addSeparator() |
381 self.addSeparator() |
382 |
382 |
383 act = self.addAction( |
383 act = self.addAction( |
384 UI.PixmapCache.getIcon("history"), self.tr("Show All History...") |
384 EricPixmapCache.getIcon("history"), self.tr("Show All History...") |
385 ) |
385 ) |
386 act.triggered.connect(self.showHistoryDialog) |
386 act.triggered.connect(self.showHistoryDialog) |
387 act = self.addAction( |
387 act = self.addAction( |
388 UI.PixmapCache.getIcon("historyClear"), self.tr("Clear History...") |
388 EricPixmapCache.getIcon("historyClear"), self.tr("Clear History...") |
389 ) |
389 ) |
390 act.triggered.connect(self.__clearHistoryDialog) |
390 act.triggered.connect(self.__clearHistoryDialog) |
391 |
391 |
392 def setInitialActions(self, actions): |
392 def setInitialActions(self, actions): |
393 """ |
393 """ |
434 try: |
434 try: |
435 maxWidth = fm.horizontalAdvance("m") * 40 |
435 maxWidth = fm.horizontalAdvance("m") * 40 |
436 except AttributeError: |
436 except AttributeError: |
437 maxWidth = fm.width("m") * 40 |
437 maxWidth = fm.width("m") * 40 |
438 |
438 |
439 import WebBrowser.WebBrowserWindow |
439 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
440 |
440 |
441 self.__closedTabsMenu.clear() |
441 self.__closedTabsMenu.clear() |
442 for index, tab in enumerate( |
442 for index, tab in enumerate( |
443 self.__tabWidget.closedTabsManager().allClosedTabs() |
443 self.__tabWidget.closedTabsManager().allClosedTabs() |
444 ): |
444 ): |
445 title = fm.elidedText(tab.title, Qt.TextElideMode.ElideRight, maxWidth) |
445 title = fm.elidedText(tab.title, Qt.TextElideMode.ElideRight, maxWidth) |
446 act = self.__closedTabsMenu.addAction( |
446 act = self.__closedTabsMenu.addAction(WebBrowserWindow.icon(tab.url), title) |
447 WebBrowser.WebBrowserWindow.WebBrowserWindow.icon(tab.url), title |
|
448 ) |
|
449 act.setData(index) |
447 act.setData(index) |
450 act.triggered.connect( |
448 act.triggered.connect( |
451 functools.partial(self.__tabWidget.restoreClosedTab, act) |
449 functools.partial(self.__tabWidget.restoreClosedTab, act) |
452 ) |
450 ) |
453 self.__closedTabsMenu.addSeparator() |
451 self.__closedTabsMenu.addSeparator() |
525 Public method to add any actions before the tree. |
523 Public method to add any actions before the tree. |
526 |
524 |
527 @return flag indicating if any actions were added (boolean) |
525 @return flag indicating if any actions were added (boolean) |
528 """ |
526 """ |
529 if self.__historyMenuModel is None: |
527 if self.__historyMenuModel is None: |
530 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
528 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
531 |
529 |
532 historyManager = WebBrowserWindow.historyManager() |
530 historyManager = WebBrowserWindow.historyManager() |
533 self.__historyMenuModel = HistoryMostVisitedMenuModel( |
531 self.__historyMenuModel = HistoryMostVisitedMenuModel( |
534 historyManager.historyFilterModel(), self |
532 historyManager.historyFilterModel(), self |
535 ) |
533 ) |