eric6/WebBrowser/TabManager/TabManagerWidget.py

Tue, 10 Sep 2019 19:30:07 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Sep 2019 19:30:07 +0200
changeset 7229
53054eb5b15a
parent 6942
2602857055c5
child 7270
41d09cf20415
permissions
-rw-r--r--

Removed obsolete "from __future__ import ..." statements.

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6121
diff changeset
3 # Copyright (c) 2016 - 2019 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
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import os
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import collections
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QPoint, QTimer, QRect
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QTreeWidget, \
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 QTreeWidgetItem, QMenu, QStyle, QAction
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"))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 dlg.exec_()
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]:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 if not browser.url().isEmpty() and \
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 not browser.url().scheme() == "eric":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 bookmark = BookmarkNode(BookmarkNode.Bookmark)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 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
140 bookmark.title = browser.title()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 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
143
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
144 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
145 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 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
147
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
148 @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
149 @type int (0 - 2)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 """
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
151 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
152 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
153
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 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
155 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 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
157
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 @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
159 @type QUrl
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 @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
161 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 @return domain name
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 @rtype str
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 appendStr = ":"
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 urlString = url.toString()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 if url.scheme() == "file":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 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
170 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
171 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
172 elif url.scheme() == "ftp":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 appendStr = self.tr(" [FTP]:")
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 host = url.host()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 if not host:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 return urlString + appendStr
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 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
180 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
181 host = host[4:]
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 registeredDomain = \
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 TabManagerWidget._tldExtractor.registrableDomain(host)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 if registeredDomain:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 host = registeredDomain
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 return host + appendStr
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 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
191 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 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
193
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 @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
195 @type WebBrowserPage
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 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
198 return
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.__isRefreshing and not page:
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 self.__page = page
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.__waitForRefresh = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 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
206
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 def changeGroupType(self, act):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 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
210
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 @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
212 @type QAction
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 if act is None:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
5605
1950fe1a32c4 Finished fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
217 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
218 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
219 self.__setGroupType(groupType)
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 self.delayedRefreshTree()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 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
222
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 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
224 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 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
226
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 @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
228 @type QTreeWidgetItem or QTreeWidget
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 @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
230 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 @return created item
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 @rtype QTreeWidgetItem
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 if addToTree:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 if parent:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 parentItem = parent
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 parentItem = self.__tree.invisibleRootItem()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 parentItem = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 itm = QTreeWidgetItem(parentItem)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 flags = itm.flags()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 if parent:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 flags |= Qt.ItemIsUserCheckable
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 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
247 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
248 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
249
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 return itm
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 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
253 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 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
255
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 @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
257 @type bool
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 windows = self.__mw.mainWindows()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 tabsGroupedByDomain = {}
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 for mainWin in windows:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 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
265 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
266 self.__page = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 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
269
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 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
271 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
272 groupItem.setText(0, domain)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 groupItem.setToolTip(0, domain)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 font = groupItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 groupItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 tabsGroupedByDomain[domain] = groupItem
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 groupItem = tabsGroupedByDomain[domain]
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 tabItem = self.__createEmptyItem(groupItem)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 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
282 font = tabItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 tabItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 if not browser.isLoading():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 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
287 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 tabItem.setIcon(0, UI.PixmapCache.getIcon("loading.png"))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 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
290 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
291
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 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
293 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
294
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 self.__makeWebBrowserViewConnections(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 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
298
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 def __groupByWindow(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 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
302 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 windows = self.__mw.mainWindows()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 self.__isRefreshing = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 winCount = 0
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 for mainWin in windows:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 winCount += 1
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 winItem = self.__createEmptyItem()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 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
312 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
313 if mainWin == self.__mw:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 font = winItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 winItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 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
318
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 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
320 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
321 self.__page = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 tabItem = self.__createEmptyItem(winItem)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 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
326 font = tabItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 tabItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 if not browser.isLoading():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 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
331 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 tabItem.setIcon(0, UI.PixmapCache.getIcon("loading.png"))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 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
334 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
335
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 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
337 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
338
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 self.__makeWebBrowserViewConnections(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 def __makeWebBrowserViewConnections(self, view):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 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
344
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 @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
346 @type WebBrowserView
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 if view:
6754
1177e27b0276 TabManagerWidget: littel change
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
349 view.loadFinished.connect(self.delayedRefreshTree)
1177e27b0276 TabManagerWidget: littel change
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
350 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
351 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
352 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
353
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 @pyqtSlot()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 def __refreshTree(self):
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 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
358 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 if self.__refreshBlocked:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 return
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.__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
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 # store selected items
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 selectedBrowsers = []
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 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
368 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
369 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
370 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 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
373 tabItem = winItem.child(row)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 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
375 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 selectedBrowsers.append(
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 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
378
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 self.__tree.clear()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 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
382 self.__groupByDomainName(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 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
384 self.__groupByDomainName()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 # 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
387 self.__setGroupType(TabManagerWidget.GroupByWindow)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 self.__groupByWindow()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 # restore selected items
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 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
392 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
393
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 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
395 tabItem = winItem.child(row)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 if tabItem.data(0, TabManagerWidget.WebBrowserRole) in \
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 selectedBrowsers:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 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
399
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 self.__tree.expandAll()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 self.__isRefreshing = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 self.__waitForRefresh = False
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 @pyqtSlot()
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
405 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
406 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 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
408
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
409 @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
410 @type QAction
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 self.__refreshBlocked = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 selectedBrowsers = collections.defaultdict(list)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
416 command = act.objectName()
4979
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 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
419 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
420 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
421 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 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
424 tabItem = winItem.child(row)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 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
426 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 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
429 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
430
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 selectedBrowsers[mainWin].append(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 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
434
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 if selectedBrowsers:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 if command == "closeSelection":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 self.closeSelectedBrowsers(selectedBrowsers)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 elif command == "bookmarkSelection":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 self.bookmarkSelectedBrowsers(selectedBrowsers)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 self.__refreshBlocked = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 self.delayedRefreshTree()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 @pyqtSlot(QTreeWidgetItem, int)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 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
446 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 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
448
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 @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
450 @type QTreeWidgetItem
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 @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
452 @type int
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 if not itm:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 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
458 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
459
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 if not mainWin:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 if mainWin.isMinimized():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 mainWin.showNormal()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 mainWin.show()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 mainWin.activateWindow()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 mainWin.raise_()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 mainWin.setFocus()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 tabWidget = mainWin.tabWidget()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 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
473 tabWidget.setCurrentWidget(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 browser.setFocus()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 @pyqtSlot()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 def __isBrowserSelected(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 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
480
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 @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
482 @rtype bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 selected = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 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
486 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
487 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
488 selected = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 break
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 return selected
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 @pyqtSlot(QPoint)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 def __customContextMenuRequested(self, pos):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 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
497
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 @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
499 @type QPoint
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 menu = QMenu()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 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
503 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
504 act.setData(TabManagerWidget.GroupByWindow)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 act.setCheckable(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 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
507
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 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
509 act.setData(TabManagerWidget.GroupByDomain)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 act.setCheckable(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 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
512
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 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
514 act.setData(TabManagerWidget.GroupByHost)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 act.setCheckable(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 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
517 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
518
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 menu.addMenu(groupTypeSubMenu)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 menu.addSeparator()
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 if self.__isBrowserSelected():
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
524 act = menu.addAction(
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 UI.PixmapCache.getIcon("bookmark22.png"),
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
526 self.tr("&Bookmark checked tabs"))
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
527 act.setObjectName("bookmarkSelection")
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
528 act.triggered.connect(lambda: self.__processActions(act))
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
529 act = menu.addAction(
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 UI.PixmapCache.getIcon("tabClose.png"),
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
531 self.tr("&Close checked tabs"))
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
532 act.setObjectName("closeSelection")
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
533 act.triggered.connect(lambda: self.__processActions(act))
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 menu.exec_(self.__tree.viewport().mapToGlobal(pos))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 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
538 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 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
540
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 @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
542 @type WebBrowserWindow
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 @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
544 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 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
547 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
548 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
549 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
550 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
551 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
552
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 def createStatusBarIcon(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 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
556
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 @return generated icon
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 @rtype E5ClickableLabel
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 icon = E5ClickableLabel()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 icon.setPixmap(
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 UI.PixmapCache.getPixmap("tabManager.png").scaled(16, 16))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 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
564 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
565
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 return icon
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
568 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
569 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 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
571
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
572 @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
573 @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
574 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 window = None
6121
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
576 if isinstance(icon, E5ClickableLabel):
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
577 window = icon.window()
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
578 elif isinstance(icon, QAction):
d3d64f3128b3 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
579 window = icon.parentWidget()
4979
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 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
582 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
583
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 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
585
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 desktop = e5App().desktop()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 desktopGeometry = desktop.availableGeometry(self)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
588 windowFrameGeometry = window.frameGeometry()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 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
590 self.frameGeometry().width()):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 x = windowFrameGeometry.right() + 1
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 x = windowFrameGeometry.x() - 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
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 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
597 self.setGeometry(newGeo)
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 self.activateWindow()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 self.showNormal()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 self.raise_()

eric ide

mercurial