WebBrowser/TabManager/TabManagerWidget.py

Sat, 31 Dec 2016 13:34:21 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 31 Dec 2016 13:34:21 +0100
changeset 5389
9b1c800daff3
parent 5039
200f12184a43
child 5605
1950fe1a32c4
permissions
-rw-r--r--

Updated copyright for 2017.

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
5389
9b1c800daff3 Updated copyright for 2017.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5039
diff changeset
3 # Copyright (c) 2016 - 2017 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 from __future__ import unicode_literals
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import os
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import collections
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 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
21 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
22 QTreeWidgetItem, QMenu, QStyle, QAction
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 import E5Network
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 from E5Network import E5TldExtractor
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 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
28 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
29
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 import Utilities
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 import UI.PixmapCache
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 import Preferences
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
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 class TabManagerWidget(QWidget):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 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
38
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @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
40 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 GroupByWindow = 0
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 GroupByDomain = 1
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 GroupByHost = 2
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 WebBrowserRole = Qt.UserRole + 1
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 WebWindowRole = Qt.UserRole + 2
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 groupTypeChanged = pyqtSignal(int)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 _tldExtractor = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 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
53 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 Constructor
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @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
57 @type WebBrowserWindow
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @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
59 @type QWidget
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 @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
61 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 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
64 self.setWindowFlags(Qt.Window)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.__layout = QVBoxLayout(self)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 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
68 self.__tree = QTreeWidget(self)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.__tree.setHeaderHidden(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.__tree.setExpandsOnDoubleClick(False)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 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
72 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
73
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 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
75
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__mw = mainWindow
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.__page = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.__isRefreshing = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.__refreshBlocked = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__waitForRefresh = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 self.__isDefaultWidget = defaultWidget
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 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
84
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 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
86 TabManagerWidget._tldExtractor = E5TldExtractor.instance()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 TabManagerWidget._tldExtractor.setDataSearchPaths([
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 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
89
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 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
91 self.__tree.customContextMenuRequested.connect(
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.__customContextMenuRequested)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 self.resize(400, 600)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 def closeSelectedBrowsers(self, browsersDict):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 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
99
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 @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
101 @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
102 as value
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 if not browsersDict:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 for mainWindow in browsersDict:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 tabWidget = mainWindow.tabWidget()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 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
110 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
111
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 def bookmarkSelectedBrowsers(self, browsersDict):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 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
115
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 @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
117 @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
118 as value
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 if not browsersDict:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 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
124 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
125
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 dlg = AddBookmarkDialog()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 dlg.setFolder(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 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
129 dlg.exec_()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 folder = dlg.addedNode()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 if folder is None:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 for mainWin in browsersDict:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 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
137 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
138 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
139 bookmark = BookmarkNode(BookmarkNode.Bookmark)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 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
141 bookmark.title = browser.title()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 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
144
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 def __setGroupType(self, type):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 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
148
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 @param type 'Group By' type to be set
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 @type int (0 - 2)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 self.__groupType = type
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 Preferences.setWebBrowser("TabManagerGroupByType", type)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 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
156 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 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
158
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 @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
160 @type QUrl
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 @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
162 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 @return domain name
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 @rtype str
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 appendStr = ":"
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 urlString = url.toString()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 if url.scheme() == "file":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 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
171 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
172 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
173 elif url.scheme() == "ftp":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 appendStr = self.tr(" [FTP]:")
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 host = url.host()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 if not host:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 return urlString + appendStr
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 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
181 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
182 host = host[4:]
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 registeredDomain = \
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 TabManagerWidget._tldExtractor.registrableDomain(host)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 if registeredDomain:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 host = registeredDomain
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 return host + appendStr
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 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
192 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 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
194
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 @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
196 @type WebBrowserPage
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 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
199 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 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
202 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.__page = page
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 self.__waitForRefresh = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 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
207
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 def changeGroupType(self, act):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 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
211
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 @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
213 @type QAction
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 if act is None:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 type = act.data()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 if self.__groupType != type:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 self.__setGroupType(type)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 self.delayedRefreshTree()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 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
223
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 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
225 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 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
227
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 @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
229 @type QTreeWidgetItem or QTreeWidget
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 @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
231 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 @return created item
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 @rtype QTreeWidgetItem
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 if addToTree:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 if parent:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 parentItem = parent
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 parentItem = self.__tree.invisibleRootItem()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 parentItem = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 itm = QTreeWidgetItem(parentItem)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 flags = itm.flags()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 if parent:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 flags |= Qt.ItemIsUserCheckable
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 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
248 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
249 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
250
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 return itm
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 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
254 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 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
256
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 @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
258 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 windows = self.__mw.mainWindows()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 tabsGroupedByDomain = {}
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 for mainWin in windows:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 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
266 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
267 self.__page = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 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
270
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 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
272 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
273 groupItem.setText(0, domain)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 groupItem.setToolTip(0, domain)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 font = groupItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 groupItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 tabsGroupedByDomain[domain] = groupItem
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 groupItem = tabsGroupedByDomain[domain]
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 tabItem = self.__createEmptyItem(groupItem)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 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
283 font = tabItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 tabItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 if not browser.isLoading():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 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
288 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 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
290 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
291 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
292
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.WebBrowserRole, browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 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
295
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 self.__makeWebBrowserViewConnections(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 self.__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
299
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 def __groupByWindow(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 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
303 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 windows = self.__mw.mainWindows()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 self.__isRefreshing = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 winCount = 0
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 for mainWin in windows:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 winCount += 1
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 winItem = self.__createEmptyItem()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 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
313 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
314 if mainWin == self.__mw:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 font = winItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 winItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 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
319
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 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
321 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
322 self.__page = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 tabItem = self.__createEmptyItem(winItem)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 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
327 font = tabItem.font(0)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 font.setBold(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 tabItem.setFont(0, font)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 if not browser.isLoading():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 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
332 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 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
334 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
335 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
336
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.WebBrowserRole, browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 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
339
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 self.__makeWebBrowserViewConnections(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 def __makeWebBrowserViewConnections(self, view):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 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
345
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 @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
347 @type WebBrowserView
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 if view:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 view.page().loadFinished.connect(self.delayedRefreshTree)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 view.page().loadStarted.connect(self.delayedRefreshTree)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 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
353 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
354
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 @pyqtSlot()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 def __refreshTree(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 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
359 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 if self.__refreshBlocked:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 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
364 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 # store selected items
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 selectedBrowsers = []
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 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
369 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
370 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
371 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 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
374 tabItem = winItem.child(row)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 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
376 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 selectedBrowsers.append(
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 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
379
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 self.__tree.clear()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 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
383 self.__groupByDomainName(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 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
385 self.__groupByDomainName()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 # 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
388 self.__setGroupType(TabManagerWidget.GroupByWindow)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 self.__groupByWindow()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 # restore selected items
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 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
393 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
394
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 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
396 tabItem = winItem.child(row)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 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
398 selectedBrowsers:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 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
400
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 self.__tree.expandAll()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 self.__isRefreshing = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 self.__waitForRefresh = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 @pyqtSlot()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 def __processActions(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 Private slot to process the actions.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 if self.sender() is None:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 self.__refreshBlocked = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 selectedBrowsers = collections.defaultdict(list)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 command = self.sender().objectName()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 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
420 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
421 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
422 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 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
425 tabItem = winItem.child(row)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 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
427 continue
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 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
430 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
431
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 selectedBrowsers[mainWin].append(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 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
435
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 if selectedBrowsers:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 if command == "closeSelection":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 self.closeSelectedBrowsers(selectedBrowsers)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 elif command == "bookmarkSelection":
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 self.bookmarkSelectedBrowsers(selectedBrowsers)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 self.__refreshBlocked = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 self.delayedRefreshTree()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 @pyqtSlot(QTreeWidgetItem, int)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 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
447 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
448 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
449
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 @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
451 @type QTreeWidgetItem
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 @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
453 @type int
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 if not itm:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 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
459 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
460
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 if not mainWin:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 return
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 if mainWin.isMinimized():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 mainWin.showNormal()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 mainWin.show()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 mainWin.activateWindow()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 mainWin.raise_()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 mainWin.setFocus()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 tabWidget = mainWin.tabWidget()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 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
474 tabWidget.setCurrentWidget(browser)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 browser.setFocus()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 @pyqtSlot()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 def __isBrowserSelected(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 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
481
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 @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
483 @rtype bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 selected = False
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 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
487 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
488 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
489 selected = True
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 break
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 return selected
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 @pyqtSlot(QPoint)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 def __customContextMenuRequested(self, pos):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 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
498
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 @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
500 @type QPoint
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 menu = QMenu()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 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
504 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
505 act.setData(TabManagerWidget.GroupByWindow)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 act.setCheckable(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 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
508
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 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
510 act.setData(TabManagerWidget.GroupByDomain)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 act.setCheckable(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 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
513
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 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
515 act.setData(TabManagerWidget.GroupByHost)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 act.setCheckable(True)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 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
518 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
519
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 menu.addMenu(groupTypeSubMenu)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 menu.addSeparator()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 if self.__isBrowserSelected():
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 menu.addAction(
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 UI.PixmapCache.getIcon("bookmark22.png"),
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 self.tr("&Bookmark checked tabs"),
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 self.__processActions).setObjectName("bookmarkSelection")
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 menu.addAction(
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"),
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 self.tr("&Close checked tabs"),
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 self.__processActions).setObjectName("closeSelection")
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 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
535
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 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
537 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 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
539
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 @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
541 @type WebBrowserWindow
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 @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
543 @type bool
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 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
546 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
547 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
548 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
549 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
550 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
551
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 def createStatusBarIcon(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 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
555
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 @return generated icon
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 @rtype E5ClickableLabel
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 icon = E5ClickableLabel()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 icon.setPixmap(
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 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
562 icon.setToolTip(self.tr("Show Tab Manager"))
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 icon.clicked.connect(self.raiseTabManager)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565 return icon
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 def raiseTabManager(self):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 Public slot to show the tab manager.
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 """
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 window = None
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 icon = self.sender()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 if icon:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574 if isinstance(icon, E5ClickableLabel):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 window = icon.window()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 elif isinstance(icon, QAction):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577 window = icon.parentWidget()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 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
580 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
581
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582 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
583
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 desktop = e5App().desktop()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 desktopGeometry = desktop.availableGeometry(self)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 windowFrameGeometry = window.frameGeometry()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 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
588 self.frameGeometry().width()):
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 x = windowFrameGeometry.right() + 1
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 else:
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 x = windowFrameGeometry.x() - 1 \
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 - self.frameGeometry().width()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 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
595 self.setGeometry(newGeo)
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 self.activateWindow()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598 self.showNormal()
7ac0959842f9 Added a tab manager window to the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 self.raise_()

eric ide

mercurial