eric6/WebBrowser/TabManager/TabManagerWidget.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7937
181d1160f617
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2016 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a window for managing the web browser tabs.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 #
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 # Modeled after the tab manager plug-in of Qupzilla
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 # Copyright (C) 2013 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 #
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 import os
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import collections
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QPoint, QTimer, QRect
7270
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
19 from PyQt5.QtWidgets import (
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
20 QWidget, QVBoxLayout, QTreeWidget, QTreeWidgetItem, QMenu, QStyle, QAction
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
21 )
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import E5Network
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 from E5Network import E5TldExtractor
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 from E5Gui.E5Application import e5App
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 from E5Gui.E5ClickableLabel import E5ClickableLabel
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 import Utilities
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 import UI.PixmapCache
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 import Preferences
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 class TabManagerWidget(QWidget):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 Class implementing a window for managing the web browser tabs.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @signal groupTypeChanged(int) emitted when the 'Group By' value was changed
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 GroupByWindow = 0
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 GroupByDomain = 1
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 GroupByHost = 2
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 WebBrowserRole = Qt.UserRole + 1
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 WebWindowRole = Qt.UserRole + 2
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 groupTypeChanged = pyqtSignal(int)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 _tldExtractor = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 def __init__(self, mainWindow, parent=None, defaultWidget=False):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 Constructor
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @param mainWindow reference to the main window
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @type WebBrowserWindow
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @param parent reference to the parent widget
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @type QWidget
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 @param defaultWidget flag indicating the default widget
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 super(TabManagerWidget, self).__init__(parent)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.setWindowFlags(Qt.Window)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.__layout = QVBoxLayout(self)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__layout.setContentsMargins(0, 0, 0, 0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.__tree = QTreeWidget(self)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.__tree.setHeaderHidden(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__tree.setExpandsOnDoubleClick(False)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.__tree.setContextMenuPolicy(Qt.CustomContextMenu)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.__layout.addWidget(self.__tree)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.setWindowTitle(self.tr("Tab Manager"))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__mw = mainWindow
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__page = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.__isRefreshing = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.__refreshBlocked = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.__waitForRefresh = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__isDefaultWidget = defaultWidget
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__groupType = Preferences.getWebBrowser("TabManagerGroupByType")
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 if TabManagerWidget._tldExtractor is None:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 TabManagerWidget._tldExtractor = E5TldExtractor.instance()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 TabManagerWidget._tldExtractor.setDataSearchPaths([
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 os.path.join(Utilities.getConfigDir(), "web_browser")])
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.__tree.itemDoubleClicked.connect(self.__itemDoubleClicked)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.__tree.customContextMenuRequested.connect(
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__customContextMenuRequested)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.resize(400, 600)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 def closeSelectedBrowsers(self, browsersDict):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 Public method to close the selected browsers.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 @param browsersDict dictionary containing the browsers per window
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @type dict with WebBrowserWindow as key and list of WebBrowserView
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 as value
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 if not browsersDict:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 for mainWindow in browsersDict:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 tabWidget = mainWindow.tabWidget()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 for browser in browsersDict[mainWindow]:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 tabWidget.closeBrowserAt(tabWidget.indexOf(browser))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 def bookmarkSelectedBrowsers(self, browsersDict):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 Public method to bookmark the selected browsers.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 @param browsersDict dictionary containing the browsers per window
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 @type dict with WebBrowserWindow as key and list of WebBrowserView
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 as value
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 if not browsersDict:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 from ..Bookmarks.BookmarkNode import BookmarkNode
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 from ..Bookmarks.AddBookmarkDialog import AddBookmarkDialog
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 dlg = AddBookmarkDialog()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 dlg.setFolder(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 dlg.setTitle(self.tr("Saved Tabs"))
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
128 dlg.exec()
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 folder = dlg.addedNode()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 if folder is None:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 for mainWin in browsersDict:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 for browser in browsersDict[mainWin]:
7270
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
136 if (
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
137 not browser.url().isEmpty() and
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
138 not browser.url().scheme() == "eric"
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
139 ):
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 bookmark = BookmarkNode(BookmarkNode.Bookmark)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 bookmark.url = bytes(browser.url().toEncoded()).decode()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 bookmark.title = browser.title()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 self.__mw.bookmarksManager().addBookmark(folder, bookmark)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
146 def __setGroupType(self, groupType):
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 Private method to set the 'Group By' type.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
150 @param groupType 'Group By' type to be set
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 @type int (0 - 2)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 """
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
153 self.__groupType = groupType
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
154 Preferences.setWebBrowser("TabManagerGroupByType", groupType)
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 def domainFromUrl(self, url, useHostName=False):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 Public method to extract the domain from an URL.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 @param url URL to extract the domain from
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 @type QUrl
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 @param useHostName flag indicating to use the host name
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 @return domain name
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 @rtype str
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 appendStr = ":"
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 urlString = url.toString()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 if url.scheme() == "file":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 return self.tr("Local File System:")
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 elif url.scheme() == "eric" or not urlString:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 return self.tr("eric Web Browser:")
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 elif url.scheme() == "ftp":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 appendStr = self.tr(" [FTP]:")
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 host = url.host()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 if not host:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 return urlString + appendStr
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 if useHostName or E5Network.isValidAddress(host):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 if host.lower().startswith("www."):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 host = host[4:]
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 else:
7270
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
185 registeredDomain = (
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 TabManagerWidget._tldExtractor.registrableDomain(host)
7270
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
187 )
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 if registeredDomain:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 host = registeredDomain
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 return host + appendStr
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 def delayedRefreshTree(self, page=None):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 Public slot to do a delyed refresh of the tree.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 @param page reference to the web page
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 @type WebBrowserPage
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 if self.__refreshBlocked or self.__waitForRefresh:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 if self.__isRefreshing and not page:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 self.__page = page
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 self.__waitForRefresh = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 QTimer.singleShot(50, self.__refreshTree)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def changeGroupType(self, act):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Public slot to change the 'Group By' type.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 @param act reference to the action that was triggered
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 @type QAction
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 if act is None:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
220 groupType = act.data()
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
221 if self.__groupType != groupType:
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
222 self.__setGroupType(groupType)
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 self.delayedRefreshTree()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 self.groupTypeChanged.emit(self.__groupType)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 def __createEmptyItem(self, parent=None, addToTree=True):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 Private method to create an empty tree item.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 @param parent reference to the parent item
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 @type QTreeWidgetItem or QTreeWidget
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 @param addToTree flag indicating to add the item to the tree
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 @return created item
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 @rtype QTreeWidgetItem
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 if addToTree:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 if parent:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 parentItem = parent
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 parentItem = self.__tree.invisibleRootItem()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 parentItem = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 itm = QTreeWidgetItem(parentItem)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 flags = itm.flags()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 if parent:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 flags |= Qt.ItemIsUserCheckable
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 flags |= Qt.ItemIsUserCheckable | Qt.ItemIsTristate
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 itm.setFlags(itm.flags() | flags)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 itm.setCheckState(0, Qt.Unchecked)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 return itm
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 def __groupByDomainName(self, useHostName=False):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 Private method to group the tree items by domain name.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 @param useHostName flag indicating to use the host name
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 windows = self.__mw.mainWindows()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 tabsGroupedByDomain = {}
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 for mainWin in windows:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 for browser in mainWin.tabWidget().browsers():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 if self.__page == browser.page():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 self.__page = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 domain = self.domainFromUrl(browser.url(), useHostName)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 if domain not in tabsGroupedByDomain:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 groupItem = self.__createEmptyItem(None, False)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 groupItem.setText(0, domain)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 groupItem.setToolTip(0, domain)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 font = groupItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 groupItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 tabsGroupedByDomain[domain] = groupItem
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 groupItem = tabsGroupedByDomain[domain]
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 tabItem = self.__createEmptyItem(groupItem)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 if browser == mainWin.tabWidget().currentBrowser():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 font = tabItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 tabItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 if not browser.isLoading():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 tabItem.setIcon(0, browser.icon())
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 else:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
291 tabItem.setIcon(0, UI.PixmapCache.getIcon("loading"))
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 tabItem.setText(0, browser.title())
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 tabItem.setToolTip(0, browser.title())
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 tabItem.setData(0, TabManagerWidget.WebBrowserRole, browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 tabItem.setData(0, TabManagerWidget.WebWindowRole, mainWin)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 self.__makeWebBrowserViewConnections(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 self.__tree.insertTopLevelItems(0, tabsGroupedByDomain.values())
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 def __groupByWindow(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 Private method to group the tree items by window.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 windows = self.__mw.mainWindows()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 self.__isRefreshing = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 winCount = 0
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 for mainWin in windows:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 winCount += 1
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 winItem = self.__createEmptyItem()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 winItem.setText(0, self.tr("Window {0}").format(winCount))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 winItem.setToolTip(0, self.tr("Double click to switch"))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 if mainWin == self.__mw:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 font = winItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 winItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 winItem.setData(0, TabManagerWidget.WebWindowRole, mainWin)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 for browser in mainWin.tabWidget().browsers():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 if self.__page == browser.page():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 self.__page = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 tabItem = self.__createEmptyItem(winItem)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 if browser == mainWin.tabWidget().currentBrowser():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 font = tabItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 tabItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 if not browser.isLoading():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 tabItem.setIcon(0, browser.icon())
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 else:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
335 tabItem.setIcon(0, UI.PixmapCache.getIcon("loading"))
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 tabItem.setText(0, browser.title())
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 tabItem.setToolTip(0, browser.title())
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 tabItem.setData(0, TabManagerWidget.WebBrowserRole, browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 tabItem.setData(0, TabManagerWidget.WebWindowRole, mainWin)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 self.__makeWebBrowserViewConnections(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 def __makeWebBrowserViewConnections(self, view):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 Private method to create the signal connections to the web view.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 @param view reference to the web view
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 @type WebBrowserView
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 if view:
6754
1177e27b0276 TabManagerWidget: littel change
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
352 view.loadFinished.connect(self.delayedRefreshTree)
1177e27b0276 TabManagerWidget: littel change
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
353 view.loadStarted.connect(self.delayedRefreshTree)
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 view.titleChanged.connect(self.delayedRefreshTree)
5039
200f12184a43 Renamed the iconChanged signal of WebBrowserView to faviconChanged in order to get rid of a name clash with Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4979
diff changeset
355 view.faviconChanged.connect(self.delayedRefreshTree)
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 @pyqtSlot()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 def __refreshTree(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 Private slot to referesh the tree.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 if self.__refreshBlocked:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 if self.__isRefreshing and not self.__page:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 # store selected items
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 selectedBrowsers = []
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 for index in range(self.__tree.topLevelItemCount()):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 winItem = self.__tree.topLevelItem(index)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 if winItem.checkState(0) == Qt.Unchecked:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 for row in range(winItem.childCount()):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 tabItem = winItem.child(row)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 if tabItem.checkState(0) == Qt.Unchecked:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 selectedBrowsers.append(
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 tabItem.data(0, TabManagerWidget.WebBrowserRole))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 self.__tree.clear()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 if self.__groupType == TabManagerWidget.GroupByHost:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 self.__groupByDomainName(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 elif self.__groupType == TabManagerWidget.GroupByDomain:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 self.__groupByDomainName()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 # default is group by window
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 self.__setGroupType(TabManagerWidget.GroupByWindow)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 self.__groupByWindow()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 # restore selected items
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 for index in range(self.__tree.topLevelItemCount()):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 winItem = self.__tree.topLevelItem(index)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 for row in range(winItem.childCount()):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 tabItem = winItem.child(row)
7270
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
399 if tabItem.data(0, TabManagerWidget.WebBrowserRole) in (
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
400 selectedBrowsers
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
401 ):
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 tabItem.setCheckState(0, Qt.Checked)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 self.__tree.expandAll()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 self.__isRefreshing = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 self.__waitForRefresh = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 @pyqtSlot()
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
409 def __processActions(self, act):
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 Private slot to process the actions.
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
412
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
413 @param act reference to the action that triggered
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
414 @type QAction
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 self.__refreshBlocked = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 selectedBrowsers = collections.defaultdict(list)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
420 command = act.objectName()
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 for index in range(self.__tree.topLevelItemCount()):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 winItem = self.__tree.topLevelItem(index)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 if winItem.checkState(0) == Qt.Unchecked:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 for row in range(winItem.childCount()):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 tabItem = winItem.child(row)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 if tabItem.checkState(0) == Qt.Unchecked:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 mainWin = tabItem.data(0, TabManagerWidget.WebWindowRole)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 browser = tabItem.data(0, TabManagerWidget.WebBrowserRole)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 selectedBrowsers[mainWin].append(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 winItem.setCheckState(0, Qt.Unchecked)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 if selectedBrowsers:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 if command == "closeSelection":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 self.closeSelectedBrowsers(selectedBrowsers)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 elif command == "bookmarkSelection":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 self.bookmarkSelectedBrowsers(selectedBrowsers)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 self.__refreshBlocked = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 self.delayedRefreshTree()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 @pyqtSlot(QTreeWidgetItem, int)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 def __itemDoubleClicked(self, itm, column):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 Private slot to handle double clicking a tree item.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 @param itm reference to the item having been double clicked
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 @type QTreeWidgetItem
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 @param column column of the double click
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 @type int
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 if not itm:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 mainWin = itm.data(0, TabManagerWidget.WebWindowRole)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 browser = itm.data(0, TabManagerWidget.WebBrowserRole)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 if not mainWin:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 if mainWin.isMinimized():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 mainWin.showNormal()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 mainWin.show()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 mainWin.activateWindow()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 mainWin.raise_()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 mainWin.setFocus()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 tabWidget = mainWin.tabWidget()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 if browser and browser != tabWidget.currentWidget():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 tabWidget.setCurrentWidget(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 browser.setFocus()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 @pyqtSlot()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 def __isBrowserSelected(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 Private slot to check, if any browser entry is selected.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 @return flag indicating the existence of a selected entry
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 @rtype bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 selected = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 for topRow in range(self.__tree.topLevelItemCount()):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 topItm = self.__tree.topLevelItem(topRow)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 if topItm.checkState(0) != Qt.Unchecked:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 selected = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 break
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 return selected
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 @pyqtSlot(QPoint)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 def __customContextMenuRequested(self, pos):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 Private slot to show the context menu.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 @param pos position the menu should be shown at
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 @type QPoint
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 menu = QMenu()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 groupTypeSubMenu = QMenu(self.tr("Group by"))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 act = groupTypeSubMenu.addAction(self.tr("&Window"))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 act.setData(TabManagerWidget.GroupByWindow)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 act.setCheckable(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 act.setChecked(self.__groupType == TabManagerWidget.GroupByWindow)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 act = groupTypeSubMenu.addAction(self.tr("&Domain"))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 act.setData(TabManagerWidget.GroupByDomain)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 act.setCheckable(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 act.setChecked(self.__groupType == TabManagerWidget.GroupByDomain)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 act = groupTypeSubMenu.addAction(self.tr("&Host"))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 act.setData(TabManagerWidget.GroupByHost)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 act.setCheckable(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 act.setChecked(self.__groupType == TabManagerWidget.GroupByHost)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 groupTypeSubMenu.triggered.connect(self.changeGroupType)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 menu.addMenu(groupTypeSubMenu)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 menu.addSeparator()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 if self.__isBrowserSelected():
7937
181d1160f617 Fixed some 'lambda' related issues by converting them to 'functools.partial'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
528 act1 = menu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
529 UI.PixmapCache.getIcon("bookmark22"),
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
530 self.tr("&Bookmark checked tabs"))
7937
181d1160f617 Fixed some 'lambda' related issues by converting them to 'functools.partial'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
531 act1.setObjectName("bookmarkSelection")
181d1160f617 Fixed some 'lambda' related issues by converting them to 'functools.partial'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
532 act1.triggered.connect(lambda: self.__processActions(act1))
181d1160f617 Fixed some 'lambda' related issues by converting them to 'functools.partial'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
533 act2 = menu.addAction(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
534 UI.PixmapCache.getIcon("tabClose"),
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
535 self.tr("&Close checked tabs"))
7937
181d1160f617 Fixed some 'lambda' related issues by converting them to 'functools.partial'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
536 act2.setObjectName("closeSelection")
181d1160f617 Fixed some 'lambda' related issues by converting them to 'functools.partial'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
537 act2.triggered.connect(lambda: self.__processActions(act2))
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538
7759
51aa6c6b66f7 Changed calls to exec_() into exec() (remainder of Python2 elimination).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
539 menu.exec(self.__tree.viewport().mapToGlobal(pos))
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 def mainWindowCreated(self, mainWin, refresh=True):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 Public method to act on the creation of a new web browser window.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 @param mainWin reference to the web browser window
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 @type WebBrowserWindow
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 @param refresh flag indicating to refresh the widget
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 mainWin.webBrowserWindowClosed.connect(self.delayedRefreshTree)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 mainWin.webBrowserWindowOpened.connect(self.mainWindowCreated)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 mainWin.webBrowserOpened.connect(self.delayedRefreshTree)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 mainWin.webBrowserClosed.connect(self.delayedRefreshTree)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 mainWin.tabWidget().currentUrlChanged.connect(self.delayedRefreshTree)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 mainWin.tabWidget().currentChanged.connect(self.delayedRefreshTree)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 def createStatusBarIcon(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 Public method to create a status bar icon.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 @return generated icon
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 @rtype E5ClickableLabel
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 icon = E5ClickableLabel()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565 icon.setPixmap(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
566 UI.PixmapCache.getPixmap("tabManager").scaled(16, 16))
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 icon.setToolTip(self.tr("Show Tab Manager"))
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
568 icon.clicked.connect(lambda: self.raiseTabManager(icon))
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 return icon
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
572 def raiseTabManager(self, icon):
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574 Public slot to show the tab manager.
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
575
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
576 @param icon reference to the clicked icon
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
577 @type E5ClickableLabel or QAction
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 window = None
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
580 if isinstance(icon, E5ClickableLabel):
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
581 window = icon.window()
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
582 elif isinstance(icon, QAction):
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
583 window = icon.parentWidget()
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 if window is not None:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 titleBarHeight = self.style().pixelMetric(QStyle.PM_TitleBarHeight)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
588 y = max(0, window.frameGeometry().top() + titleBarHeight + 1)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 desktop = e5App().desktop()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 desktopGeometry = desktop.availableGeometry(self)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 windowFrameGeometry = window.frameGeometry()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 if (desktopGeometry.width() - windowFrameGeometry.right() - 1 >
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 self.frameGeometry().width()):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 x = windowFrameGeometry.right() + 1
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 else:
7270
41d09cf20415 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
597 x = windowFrameGeometry.x() - 1 - self.frameGeometry().width()
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 newGeo = QRect(x, y, self.width(), window.height())
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 self.setGeometry(newGeo)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
602 self.activateWindow()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603 self.showNormal()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 self.raise_()

eric ide

mercurial