eric6/WebBrowser/WebBrowserTabBar.py

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

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

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

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

eric ide

mercurial