eric6/WebBrowser/WebBrowserTabBar.py

Wed, 01 Jan 2020 11:57:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2020 11:57:23 +0100
changeset 7360
9190402e4505
parent 7271
2cac5b7abcce
child 7781
607a6098cb44
permissions
-rw-r--r--

Updated copyright for 2020.

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
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7271
diff changeset
3 # Copyright (c) 2010 - 2020 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
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
10
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
11 from PyQt5.QtCore import Qt, QPoint, QTimer, QEvent
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
12 from PyQt5.QtWidgets import QFrame, QLabel
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from E5Gui.E5TabWidget import E5WheelTabBar
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from E5Gui.E5PassivePopup import E5PassivePopup
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import Preferences
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
19
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
20 class WebBrowserTabBar(E5WheelTabBar):
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 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
23 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
24 def __init__(self, parent=None):
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
28 @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
29 """
4713
8dca047daf4b Continued with the web view.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
30 super(WebBrowserTabBar, self).__init__(parent)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
638
265c31231d9d Did some refactoring of the web browser code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 634
diff changeset
32 self.__tabWidget = parent
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.__previewPopup = None
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setMouseTracking(True)
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
38 def __showTabPreview(self, index):
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
39 """
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
40 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
41
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
42 @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
43 @type int
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
44 """
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
45 indexedBrowser = self.__tabWidget.browserAt(index)
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
46 currentBrowser = self.__tabWidget.currentBrowser()
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
47
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
48 if indexedBrowser is None or currentBrowser is None:
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
49 return
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
50
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
51 # no previews during load
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
52 if indexedBrowser.progress() != 0:
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
53 return
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
54
5785
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
55 preview = indexedBrowser.getPreview()
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
56 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
57 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
58 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
59
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
60 self.__previewPopup = E5PassivePopup(self)
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
61 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
62 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
63 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
64 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
65
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
66 label = QLabel()
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
67 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
68
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
69 self.__previewPopup.setView(label)
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
70 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
71 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
72
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
73 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
74 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
75
7c7c5f9e4fad Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
76 self.__previewPopup.show(self.mapToGlobal(pos))
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
78 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
79 """
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
80 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
81 """
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
82 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
83 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
84 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
85
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 def mouseMoveEvent(self, evt):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 Protected method to handle mouse move events.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
90 @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
91 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 if self.count() == 1:
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 return
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
95 super(WebBrowserTabBar, self).mouseMoveEvent(evt)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
97 if Preferences.getWebBrowser("ShowPreview"):
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
98 # Find the tab under the mouse
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
99 i = 0
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
100 tabIndex = -1
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
101 while i < self.count() and tabIndex == -1:
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
102 if self.tabRect(i).contains(evt.pos()):
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
103 tabIndex = i
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
104 i += 1
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
105
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
106 # If found and not the current tab then show tab preview
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
107 if (
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
108 tabIndex != -1 and
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
109 tabIndex != self.currentIndex() and
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
110 evt.buttons() == Qt.NoButton
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
111 ):
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
112 if (
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
113 self.__previewPopup is None or
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
114 (self.__previewPopup is not None and
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
115 self.__previewPopup.getCustomData("index") != tabIndex)
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
116 ):
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
117 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
118 0, lambda: self.__showTabPreview(tabIndex))
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
119
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
120 # If current tab or not found then hide previous tab preview
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
121 if (
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
122 tabIndex == self.currentIndex() or
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
123 tabIndex == -1
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
124 ):
6125
bb1c79bf4f33 Fixed an issue with the web tab preview on low performance machines.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
125 self.__hidePreview()
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 def leaveEvent(self, evt):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 Protected method to handle leave events.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 @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
132 """
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
133 if Preferences.getWebBrowser("ShowPreview"):
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
134 # 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
135 self.__hidePreview()
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
137 super(WebBrowserTabBar, self).leaveEvent(evt)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 def mousePressEvent(self, evt):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 Protected method to handle mouse press events.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 @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
144 """
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
145 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
146 self.__hidePreview()
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
148 super(WebBrowserTabBar, self).mousePressEvent(evt)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 def event(self, evt):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
152 Public method to handle event.
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
154 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
155 handling of all others to the superclass.
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 @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
158 @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
159 """
7271
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
160 if (
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
161 evt.type() == QEvent.ToolTip and
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
162 Preferences.getWebBrowser("ShowPreview")
2cac5b7abcce Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
163 ):
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
164 # suppress tool tips if we are showing previews
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
165 evt.setAccepted(True)
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
166 return True
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167
4715
79009bc4acd5 Continued getting the basic web browser functions going.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4713
diff changeset
168 return super(WebBrowserTabBar, self).event(evt)
634
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 def tabRemoved(self, index):
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
172 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
173
7b84cbd2f752 Added tab previews to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 @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
175 """
4779
173e0d2ab1f9 Continued porting the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4726
diff changeset
176 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
177 self.__hidePreview()

eric ide

mercurial