eric6/WebBrowser/WebBrowserTabBar.py

Sun, 14 Apr 2019 15:09:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 14 Apr 2019 15:09:21 +0200
changeset 6942
2602857055c5
parent 6645
WebBrowser/WebBrowserTabBar.py@ad476851d7e0
child 7229
53054eb5b15a
permissions
-rw-r--r--

Major restructuring of the source tree to get prepared for a setup.py based installation.

634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6125
diff changeset
3 # Copyright (c) 2010 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a specialized tab bar for the web browser.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2403
diff changeset
11
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
12 from PyQt5.QtCore import Qt, QPoint, QTimer, QEvent
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
13 from PyQt5.QtWidgets import QFrame, QLabel
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from E5Gui.E5TabWidget import E5WheelTabBar
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from E5Gui.E5PassivePopup import E5PassivePopup
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 import Preferences
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
20
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
21 class WebBrowserTabBar(E5WheelTabBar):
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Class implementing the tab bar of the web browser.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
25 def __init__(self, parent=None):
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Constructor
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
29 @param parent reference to the parent widget (WebBrowserTabWidget)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
31 super(WebBrowserTabBar, self).__init__(parent)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 634
diff changeset
33 self.__tabWidget = parent
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.__previewPopup = None
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setMouseTracking(True)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
39 def __showTabPreview(self, index):
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
40 """
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
41 Private slot to show the tab preview.
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
42
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
43 @param index index of tab to show a preview for
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
44 @type int
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
45 """
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
46 indexedBrowser = self.__tabWidget.browserAt(index)
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
47 currentBrowser = self.__tabWidget.currentBrowser()
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
48
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
49 if indexedBrowser is None or currentBrowser is None:
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
50 return
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
51
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
52 # no previews during load
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
53 if indexedBrowser.progress() != 0:
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
54 return
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
55
5785
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
56 preview = indexedBrowser.getPreview()
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
57 if not preview.isNull():
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
58 w = self.tabSizeHint(index).width()
5785
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
59 h = int(w * currentBrowser.height() / currentBrowser.width())
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
60
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
61 self.__previewPopup = E5PassivePopup(self)
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
62 self.__previewPopup.setFrameShape(QFrame.StyledPanel)
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
63 self.__previewPopup.setFrameShadow(QFrame.Plain)
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
64 self.__previewPopup.setFixedSize(w, h)
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
65 self.__previewPopup.setCustomData("index", index)
5785
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
66
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
67 label = QLabel()
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
68 label.setPixmap(preview.scaled(w, h))
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
69
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
70 self.__previewPopup.setView(label)
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
71 self.__previewPopup.layout().setAlignment(Qt.AlignTop)
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
72 self.__previewPopup.layout().setContentsMargins(0, 0, 0, 0)
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
73
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
74 tr = self.tabRect(index)
5785
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
75 pos = QPoint(tr.x(), tr.y() + tr.height())
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
76
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
77 self.__previewPopup.show(self.mapToGlobal(pos))
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
79 def __hidePreview(self):
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
80 """
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
81 Private method to hide the preview.
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
82 """
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
83 if self.__previewPopup is not None:
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
84 self.__previewPopup.hide()
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
85 self.__previewPopup = None
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
86
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 def mouseMoveEvent(self, evt):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 Protected method to handle mouse move events.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
91 @param evt reference to the mouse move event (QMouseEvent)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 if self.count() == 1:
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 return
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
96 super(WebBrowserTabBar, self).mouseMoveEvent(evt)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
98 if Preferences.getWebBrowser("ShowPreview"):
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
99 # Find the tab under the mouse
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
100 i = 0
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
101 tabIndex = -1
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
102 while i < self.count() and tabIndex == -1:
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
103 if self.tabRect(i).contains(evt.pos()):
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
104 tabIndex = i
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
105 i += 1
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
106
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
107 # If found and not the current tab then show tab preview
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
108 if tabIndex != -1 and \
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
109 tabIndex != self.currentIndex() and \
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
110 evt.buttons() == Qt.NoButton:
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
111 if self.__previewPopup is None or \
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
112 (self.__previewPopup is not None and
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
113 self.__previewPopup.getCustomData("index") != tabIndex):
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
114 QTimer.singleShot(
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
115 0, lambda: self.__showTabPreview(tabIndex))
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
116
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
117 # If current tab or not found then hide previous tab preview
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
118 if tabIndex == self.currentIndex() or \
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
119 tabIndex == -1:
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
120 self.__hidePreview()
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 def leaveEvent(self, evt):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 Protected method to handle leave events.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 @param evt reference to the leave event (QEvent)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 """
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
128 if Preferences.getWebBrowser("ShowPreview"):
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
129 # If leave tabwidget then hide previous tab preview
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
130 self.__hidePreview()
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
132 super(WebBrowserTabBar, self).leaveEvent(evt)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 def mousePressEvent(self, evt):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 Protected method to handle mouse press events.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @param evt reference to the mouse press event (QMouseEvent)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
140 if Preferences.getWebBrowser("ShowPreview"):
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
141 self.__hidePreview()
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
143 super(WebBrowserTabBar, self).mousePressEvent(evt)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 def event(self, evt):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
147 Public method to handle event.
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
149 This event handler just handles the tooltip event and passes the
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 handling of all others to the superclass.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 @param evt reference to the event to be handled (QEvent)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 @return flag indicating, if the event was handled (boolean)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 """
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
155 if evt.type() == QEvent.ToolTip and \
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
156 Preferences.getWebBrowser("ShowPreview"):
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
157 # suppress tool tips if we are showing previews
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
158 evt.setAccepted(True)
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
159 return True
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
161 return super(WebBrowserTabBar, self).event(evt)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 def tabRemoved(self, index):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
165 Public slot to handle the removal of a tab.
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 @param index index of the removed tab (integer)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 """
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
169 if Preferences.getWebBrowser("ShowPreview"):
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
170 self.__hidePreview()

eric ide

mercurial