22 from PyQt6.QtWidgets import QMenu |
22 from PyQt6.QtWidgets import QMenu |
23 |
23 |
24 from eric7.EricGui import EricPixmapCache |
24 from eric7.EricGui import EricPixmapCache |
25 from eric7.EricWidgets import EricMessageBox |
25 from eric7.EricWidgets import EricMessageBox |
26 from eric7.EricWidgets.EricModelMenu import EricModelMenu |
26 from eric7.EricWidgets.EricModelMenu import EricModelMenu |
|
27 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
27 |
28 |
28 from .HistoryModel import HistoryModel |
29 from .HistoryModel import HistoryModel |
29 |
30 |
30 |
31 |
31 class HistoryMenuModel(QAbstractProxyModel): |
32 class HistoryMenuModel(QAbstractProxyModel): |
339 Public method to add any actions before the tree. |
340 Public method to add any actions before the tree. |
340 |
341 |
341 @return flag indicating if any actions were added (boolean) |
342 @return flag indicating if any actions were added (boolean) |
342 """ |
343 """ |
343 if self.__historyManager is None: |
344 if self.__historyManager is None: |
344 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
|
345 |
|
346 self.__historyManager = WebBrowserWindow.historyManager() |
345 self.__historyManager = WebBrowserWindow.historyManager() |
347 self.__historyMenuModel = HistoryMenuModel( |
346 self.__historyMenuModel = HistoryMenuModel( |
348 self.__historyManager.historyTreeModel(), self |
347 self.__historyManager.historyTreeModel(), self |
349 ) |
348 ) |
350 self.setModel(self.__historyMenuModel) |
349 self.setModel(self.__historyMenuModel) |
428 def __aboutToShowClosedTabsMenu(self): |
427 def __aboutToShowClosedTabsMenu(self): |
429 """ |
428 """ |
430 Private slot to populate the closed tabs menu. |
429 Private slot to populate the closed tabs menu. |
431 """ |
430 """ |
432 fm = self.__closedTabsMenu.fontMetrics() |
431 fm = self.__closedTabsMenu.fontMetrics() |
433 try: |
432 maxWidth = fm.horizontalAdvance("m") * 40 |
434 maxWidth = fm.horizontalAdvance("m") * 40 |
|
435 except AttributeError: |
|
436 maxWidth = fm.width("m") * 40 |
|
437 |
|
438 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
|
439 |
433 |
440 self.__closedTabsMenu.clear() |
434 self.__closedTabsMenu.clear() |
441 for index, tab in enumerate( |
435 for index, tab in enumerate( |
442 self.__tabWidget.closedTabsManager().allClosedTabs() |
436 self.__tabWidget.closedTabsManager().allClosedTabs() |
443 ): |
437 ): |
522 Public method to add any actions before the tree. |
516 Public method to add any actions before the tree. |
523 |
517 |
524 @return flag indicating if any actions were added (boolean) |
518 @return flag indicating if any actions were added (boolean) |
525 """ |
519 """ |
526 if self.__historyMenuModel is None: |
520 if self.__historyMenuModel is None: |
527 from eric7.WebBrowser.WebBrowserWindow import WebBrowserWindow |
|
528 |
|
529 historyManager = WebBrowserWindow.historyManager() |
521 historyManager = WebBrowserWindow.historyManager() |
530 self.__historyMenuModel = HistoryMostVisitedMenuModel( |
522 self.__historyMenuModel = HistoryMostVisitedMenuModel( |
531 historyManager.historyFilterModel(), self |
523 historyManager.historyFilterModel(), self |
532 ) |
524 ) |
533 self.setModel(self.__historyMenuModel) |
525 self.setModel(self.__historyMenuModel) |