Fri, 09 Feb 2018 18:58:21 +0100
Fixed an issue with the web tab preview on low performance machines.
--- a/APIs/Python3/eric6.api Fri Feb 09 18:53:08 2018 +0100 +++ b/APIs/Python3/eric6.api Fri Feb 09 18:58:21 2018 +0100 @@ -1082,8 +1082,10 @@ eric6.E5Gui.E5PassivePopup.E5PassivePopup.Boxed?7 eric6.E5Gui.E5PassivePopup.E5PassivePopup.Custom?7 eric6.E5Gui.E5PassivePopup.E5PassivePopup.clicked?7 +eric6.E5Gui.E5PassivePopup.E5PassivePopup.getCustomData?4(key) eric6.E5Gui.E5PassivePopup.E5PassivePopup.hideEvent?4(evt) eric6.E5Gui.E5PassivePopup.E5PassivePopup.mouseReleaseEvent?4(evt) +eric6.E5Gui.E5PassivePopup.E5PassivePopup.setCustomData?4(key, data) eric6.E5Gui.E5PassivePopup.E5PassivePopup.setTimeout?4(delay) eric6.E5Gui.E5PassivePopup.E5PassivePopup.setView?4(child) eric6.E5Gui.E5PassivePopup.E5PassivePopup.setVisible?4(visible)
--- a/Documentation/Help/source.qhp Fri Feb 09 18:53:08 2018 +0100 +++ b/Documentation/Help/source.qhp Fri Feb 09 18:58:21 2018 +0100 @@ -4667,8 +4667,10 @@ <keyword name="E5PassivePopup.__defaultArea" id="E5PassivePopup.__defaultArea" ref="eric6.E5Gui.E5PassivePopup.html#E5PassivePopup.__defaultArea" /> <keyword name="E5PassivePopup.__moveNear" id="E5PassivePopup.__moveNear" ref="eric6.E5Gui.E5PassivePopup.html#E5PassivePopup.__moveNear" /> <keyword name="E5PassivePopup.__positionSelf" id="E5PassivePopup.__positionSelf" ref="eric6.E5Gui.E5PassivePopup.html#E5PassivePopup.__positionSelf" /> + <keyword name="E5PassivePopup.getCustomData" id="E5PassivePopup.getCustomData" ref="eric6.E5Gui.E5PassivePopup.html#E5PassivePopup.getCustomData" /> <keyword name="E5PassivePopup.hideEvent" id="E5PassivePopup.hideEvent" ref="eric6.E5Gui.E5PassivePopup.html#E5PassivePopup.hideEvent" /> <keyword name="E5PassivePopup.mouseReleaseEvent" id="E5PassivePopup.mouseReleaseEvent" ref="eric6.E5Gui.E5PassivePopup.html#E5PassivePopup.mouseReleaseEvent" /> + <keyword name="E5PassivePopup.setCustomData" id="E5PassivePopup.setCustomData" ref="eric6.E5Gui.E5PassivePopup.html#E5PassivePopup.setCustomData" /> <keyword name="E5PassivePopup.setTimeout" id="E5PassivePopup.setTimeout" ref="eric6.E5Gui.E5PassivePopup.html#E5PassivePopup.setTimeout" /> <keyword name="E5PassivePopup.setView" id="E5PassivePopup.setView" ref="eric6.E5Gui.E5PassivePopup.html#E5PassivePopup.setView" /> <keyword name="E5PassivePopup.setVisible" id="E5PassivePopup.setVisible" ref="eric6.E5Gui.E5PassivePopup.html#E5PassivePopup.setVisible" /> @@ -7705,6 +7707,7 @@ <keyword name="HelpTabBar" id="HelpTabBar" ref="eric6.Helpviewer.HelpTabBar.html#HelpTabBar" /> <keyword name="HelpTabBar (Constructor)" id="HelpTabBar (Constructor)" ref="eric6.Helpviewer.HelpTabBar.html#HelpTabBar.__init__" /> <keyword name="HelpTabBar (Module)" id="HelpTabBar (Module)" ref="eric6.Helpviewer.HelpTabBar.html" /> + <keyword name="HelpTabBar.__hidePreview" id="HelpTabBar.__hidePreview" ref="eric6.Helpviewer.HelpTabBar.html#HelpTabBar.__hidePreview" /> <keyword name="HelpTabBar.__showTabPreview" id="HelpTabBar.__showTabPreview" ref="eric6.Helpviewer.HelpTabBar.html#HelpTabBar.__showTabPreview" /> <keyword name="HelpTabBar.event" id="HelpTabBar.event" ref="eric6.Helpviewer.HelpTabBar.html#HelpTabBar.event" /> <keyword name="HelpTabBar.leaveEvent" id="HelpTabBar.leaveEvent" ref="eric6.Helpviewer.HelpTabBar.html#HelpTabBar.leaveEvent" /> @@ -17553,6 +17556,7 @@ <keyword name="WebBrowserTabBar" id="WebBrowserTabBar" ref="eric6.WebBrowser.WebBrowserTabBar.html#WebBrowserTabBar" /> <keyword name="WebBrowserTabBar (Constructor)" id="WebBrowserTabBar (Constructor)" ref="eric6.WebBrowser.WebBrowserTabBar.html#WebBrowserTabBar.__init__" /> <keyword name="WebBrowserTabBar (Module)" id="WebBrowserTabBar (Module)" ref="eric6.WebBrowser.WebBrowserTabBar.html" /> + <keyword name="WebBrowserTabBar.__hidePreview" id="WebBrowserTabBar.__hidePreview" ref="eric6.WebBrowser.WebBrowserTabBar.html#WebBrowserTabBar.__hidePreview" /> <keyword name="WebBrowserTabBar.__showTabPreview" id="WebBrowserTabBar.__showTabPreview" ref="eric6.WebBrowser.WebBrowserTabBar.html#WebBrowserTabBar.__showTabPreview" /> <keyword name="WebBrowserTabBar.event" id="WebBrowserTabBar.event" ref="eric6.WebBrowser.WebBrowserTabBar.html#WebBrowserTabBar.event" /> <keyword name="WebBrowserTabBar.leaveEvent" id="WebBrowserTabBar.leaveEvent" ref="eric6.WebBrowser.WebBrowserTabBar.html#WebBrowserTabBar.leaveEvent" />
--- a/Documentation/Source/eric6.E5Gui.E5PassivePopup.html Fri Feb 09 18:53:08 2018 +0100 +++ b/Documentation/Source/eric6.E5Gui.E5PassivePopup.html Fri Feb 09 18:58:21 2018 +0100 @@ -80,12 +80,18 @@ <td><a href="#E5PassivePopup.__positionSelf">__positionSelf</a></td> <td>Private method to position the popup.</td> </tr><tr> +<td><a href="#E5PassivePopup.getCustomData">getCustomData</a></td> +<td>Public method to get some custom data.</td> +</tr><tr> <td><a href="#E5PassivePopup.hideEvent">hideEvent</a></td> <td>Protected method to handle the hide event.</td> </tr><tr> <td><a href="#E5PassivePopup.mouseReleaseEvent">mouseReleaseEvent</a></td> <td>Protected method to handle a mouse release event.</td> </tr><tr> +<td><a href="#E5PassivePopup.setCustomData">setCustomData</a></td> +<td>Public method to set some custom data.</td> +</tr><tr> <td><a href="#E5PassivePopup.setTimeout">setTimeout</a></td> <td>Public method to set the delay for the popup is removed automatically.</td> </tr><tr> @@ -162,7 +168,27 @@ <b>__positionSelf</b>(<i></i>) <p> Private method to position the popup. -</p><a NAME="E5PassivePopup.hideEvent" ID="E5PassivePopup.hideEvent"></a> +</p><a NAME="E5PassivePopup.getCustomData" ID="E5PassivePopup.getCustomData"></a> +<h4>E5PassivePopup.getCustomData</h4> +<b>getCustomData</b>(<i>key</i>) +<p> + Public method to get some custom data. +</p><dl> +<dt><i>key</i> (str)</dt> +<dd> +key for the custom data +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +stored data +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +any +</dd> +</dl><a NAME="E5PassivePopup.hideEvent" ID="E5PassivePopup.hideEvent"></a> <h4>E5PassivePopup.hideEvent</h4> <b>hideEvent</b>(<i>evt</i>) <p> @@ -182,6 +208,19 @@ <dd> reference to the mouse event (QMouseEvent) </dd> +</dl><a NAME="E5PassivePopup.setCustomData" ID="E5PassivePopup.setCustomData"></a> +<h4>E5PassivePopup.setCustomData</h4> +<b>setCustomData</b>(<i>key, data</i>) +<p> + Public method to set some custom data. +</p><dl> +<dt><i>key</i> (str)</dt> +<dd> +key for the custom data +</dd><dt><i>data</i> (any)</dt> +<dd> +data to be stored +</dd> </dl><a NAME="E5PassivePopup.setTimeout" ID="E5PassivePopup.setTimeout"></a> <h4>E5PassivePopup.setTimeout</h4> <b>setTimeout</b>(<i>delay</i>)
--- a/Documentation/Source/eric6.Helpviewer.HelpTabBar.html Fri Feb 09 18:53:08 2018 +0100 +++ b/Documentation/Source/eric6.Helpviewer.HelpTabBar.html Fri Feb 09 18:58:21 2018 +0100 @@ -60,6 +60,9 @@ <td><a href="#HelpTabBar.__init__">HelpTabBar</a></td> <td>Constructor</td> </tr><tr> +<td><a href="#HelpTabBar.__hidePreview">__hidePreview</a></td> +<td>Private method to hide the preview.</td> +</tr><tr> <td><a href="#HelpTabBar.__showTabPreview">__showTabPreview</a></td> <td>Private slot to show the tab preview.</td> </tr><tr> @@ -93,12 +96,22 @@ <dd> reference to the parent widget (HelpTabWidget) </dd> -</dl><a NAME="HelpTabBar.__showTabPreview" ID="HelpTabBar.__showTabPreview"></a> +</dl><a NAME="HelpTabBar.__hidePreview" ID="HelpTabBar.__hidePreview"></a> +<h4>HelpTabBar.__hidePreview</h4> +<b>__hidePreview</b>(<i></i>) +<p> + Private method to hide the preview. +</p><a NAME="HelpTabBar.__showTabPreview" ID="HelpTabBar.__showTabPreview"></a> <h4>HelpTabBar.__showTabPreview</h4> -<b>__showTabPreview</b>(<i></i>) +<b>__showTabPreview</b>(<i>index</i>) <p> Private slot to show the tab preview. -</p><a NAME="HelpTabBar.event" ID="HelpTabBar.event"></a> +</p><dl> +<dt><i>index</i> (int)</dt> +<dd> +index of tab to show a preview for +</dd> +</dl><a NAME="HelpTabBar.event" ID="HelpTabBar.event"></a> <h4>HelpTabBar.event</h4> <b>event</b>(<i>evt</i>) <p>
--- a/Documentation/Source/eric6.WebBrowser.WebBrowserTabBar.html Fri Feb 09 18:53:08 2018 +0100 +++ b/Documentation/Source/eric6.WebBrowser.WebBrowserTabBar.html Fri Feb 09 18:58:21 2018 +0100 @@ -60,6 +60,9 @@ <td><a href="#WebBrowserTabBar.__init__">WebBrowserTabBar</a></td> <td>Constructor</td> </tr><tr> +<td><a href="#WebBrowserTabBar.__hidePreview">__hidePreview</a></td> +<td>Private method to hide the preview.</td> +</tr><tr> <td><a href="#WebBrowserTabBar.__showTabPreview">__showTabPreview</a></td> <td>Private slot to show the tab preview.</td> </tr><tr> @@ -93,12 +96,22 @@ <dd> reference to the parent widget (WebBrowserTabWidget) </dd> -</dl><a NAME="WebBrowserTabBar.__showTabPreview" ID="WebBrowserTabBar.__showTabPreview"></a> +</dl><a NAME="WebBrowserTabBar.__hidePreview" ID="WebBrowserTabBar.__hidePreview"></a> +<h4>WebBrowserTabBar.__hidePreview</h4> +<b>__hidePreview</b>(<i></i>) +<p> + Private method to hide the preview. +</p><a NAME="WebBrowserTabBar.__showTabPreview" ID="WebBrowserTabBar.__showTabPreview"></a> <h4>WebBrowserTabBar.__showTabPreview</h4> -<b>__showTabPreview</b>(<i></i>) +<b>__showTabPreview</b>(<i>index</i>) <p> Private slot to show the tab preview. -</p><a NAME="WebBrowserTabBar.event" ID="WebBrowserTabBar.event"></a> +</p><dl> +<dt><i>index</i> (int)</dt> +<dd> +index of tab to show a preview for +</dd> +</dl><a NAME="WebBrowserTabBar.event" ID="WebBrowserTabBar.event"></a> <h4>WebBrowserTabBar.event</h4> <b>event</b>(<i>evt</i>) <p>
--- a/E5Gui/E5PassivePopup.py Fri Feb 09 18:53:08 2018 +0100 +++ b/E5Gui/E5PassivePopup.py Fri Feb 09 18:58:21 2018 +0100 @@ -47,6 +47,8 @@ self.setLineWidth(2) self.__hideTimer.timeout.connect(self.hide) self.clicked.connect(self.hide) + + self.__customData = {} # dictionary to store some custom data def setView(self, child): """ @@ -210,6 +212,28 @@ x = r.left() return QPoint(x, y) + + def setCustomData(self, key, data): + """ + Public method to set some custom data. + + @param key key for the custom data + @type str + @param data data to be stored + @type any + """ + self.__customData[key] = data + + def getCustomData(self, key): + """ + Public method to get some custom data. + + @param key key for the custom data + @type str + @return stored data + @rtype any + """ + return self.__customData[key] DEFAULT_POPUP_TYPE = E5PassivePopup.Boxed DEFAULT_POPUP_TIME = 6 * 1000
--- a/Helpviewer/HelpTabBar.py Fri Feb 09 18:53:08 2018 +0100 +++ b/Helpviewer/HelpTabBar.py Fri Feb 09 18:58:21 2018 +0100 @@ -33,16 +33,17 @@ self.__tabWidget = parent self.__previewPopup = None - self.__currentTabPreviewIndex = -1 self.setMouseTracking(True) - def __showTabPreview(self): + def __showTabPreview(self, index): """ Private slot to show the tab preview. + + @param index index of tab to show a preview for + @type int """ - indexedBrowser = self.__tabWidget.browserAt( - self.__currentTabPreviewIndex) + indexedBrowser = self.__tabWidget.browserAt(index) currentBrowser = self.__tabWidget.currentBrowser() if indexedBrowser is None or currentBrowser is None: @@ -52,13 +53,14 @@ if indexedBrowser.progress() != 0: return - w = self.tabSizeHint(self.__currentTabPreviewIndex).width() + w = self.tabSizeHint(index).width() h = int(w * currentBrowser.height() / currentBrowser.width()) self.__previewPopup = E5PassivePopup(self) self.__previewPopup.setFrameShape(QFrame.StyledPanel) self.__previewPopup.setFrameShadow(QFrame.Plain) self.__previewPopup.setFixedSize(w, h) + self.__previewPopup.setCustomData("index", index) from .HelpSnap import renderTabPreview label = QLabel() @@ -68,11 +70,19 @@ self.__previewPopup.layout().setAlignment(Qt.AlignTop) self.__previewPopup.layout().setContentsMargins(0, 0, 0, 0) - tr = self.tabRect(self.__currentTabPreviewIndex) + tr = self.tabRect(index) pos = QPoint(tr.x(), tr.y() + tr.height()) self.__previewPopup.show(self.mapToGlobal(pos)) + def __hidePreview(self): + """ + Private method to hide the preview. + """ + if self.__previewPopup is not None: + self.__previewPopup.hide() + self.__previewPopup = None + def mouseMoveEvent(self, evt): """ Protected method to handle mouse move events. @@ -96,17 +106,17 @@ # If found and not the current tab then show tab preview if tabIndex != -1 and \ tabIndex != self.currentIndex() and \ - self.__currentTabPreviewIndex != tabIndex and \ evt.buttons() == Qt.NoButton: - self.__currentTabPreviewIndex = tabIndex - QTimer.singleShot(200, self.__showTabPreview) + if self.__previewPopup is None or \ + (self.__previewPopup is not None and + self.__previewPopup.getCustomData("index") != tabIndex): + QTimer.singleShot( + 0, lambda: self.__showTabPreview(tabIndex)) # If current tab or not found then hide previous tab preview if tabIndex == self.currentIndex() or \ tabIndex == -1: - if self.__previewPopup is not None: - self.__previewPopup.hide() - self.__currentTabPreviewIndex = -1 + self.__hidePreview() def leaveEvent(self, evt): """ @@ -116,9 +126,7 @@ """ if Preferences.getHelp("ShowPreview"): # If leave tabwidget then hide previous tab preview - if self.__previewPopup is not None: - self.__previewPopup.hide() - self.__currentTabPreviewIndex = -1 + self.__hidePreview() E5WheelTabBar.leaveEvent(self, evt) @@ -129,9 +137,7 @@ @param evt reference to the mouse press event (QMouseEvent) """ if Preferences.getHelp("ShowPreview"): - if self.__previewPopup is not None: - self.__previewPopup.hide() - self.__currentTabPreviewIndex = -1 + self.__hidePreview() E5WheelTabBar.mousePressEvent(self, evt) @@ -160,6 +166,4 @@ @param index index of the removed tab (integer) """ if Preferences.getHelp("ShowPreview"): - if self.__previewPopup is not None: - self.__previewPopup.hide() - self.__currentTabPreviewIndex = -1 + self.__hidePreview()
--- a/WebBrowser/WebBrowserTabBar.py Fri Feb 09 18:53:08 2018 +0100 +++ b/WebBrowser/WebBrowserTabBar.py Fri Feb 09 18:58:21 2018 +0100 @@ -33,16 +33,17 @@ self.__tabWidget = parent self.__previewPopup = None - self.__currentTabPreviewIndex = -1 self.setMouseTracking(True) - def __showTabPreview(self): + def __showTabPreview(self, index): """ Private slot to show the tab preview. + + @param index index of tab to show a preview for + @type int """ - indexedBrowser = self.__tabWidget.browserAt( - self.__currentTabPreviewIndex) + indexedBrowser = self.__tabWidget.browserAt(index) currentBrowser = self.__tabWidget.currentBrowser() if indexedBrowser is None or currentBrowser is None: @@ -54,13 +55,14 @@ preview = indexedBrowser.getPreview() if not preview.isNull(): - w = self.tabSizeHint(self.__currentTabPreviewIndex).width() + w = self.tabSizeHint(index).width() h = int(w * currentBrowser.height() / currentBrowser.width()) self.__previewPopup = E5PassivePopup(self) self.__previewPopup.setFrameShape(QFrame.StyledPanel) self.__previewPopup.setFrameShadow(QFrame.Plain) self.__previewPopup.setFixedSize(w, h) + self.__previewPopup.setCustomData("index", index) label = QLabel() label.setPixmap(preview.scaled(w, h)) @@ -69,11 +71,19 @@ self.__previewPopup.layout().setAlignment(Qt.AlignTop) self.__previewPopup.layout().setContentsMargins(0, 0, 0, 0) - tr = self.tabRect(self.__currentTabPreviewIndex) + tr = self.tabRect(index) pos = QPoint(tr.x(), tr.y() + tr.height()) self.__previewPopup.show(self.mapToGlobal(pos)) + def __hidePreview(self): + """ + Private method to hide the preview. + """ + if self.__previewPopup is not None: + self.__previewPopup.hide() + self.__previewPopup = None + def mouseMoveEvent(self, evt): """ Protected method to handle mouse move events. @@ -97,17 +107,17 @@ # If found and not the current tab then show tab preview if tabIndex != -1 and \ tabIndex != self.currentIndex() and \ - self.__currentTabPreviewIndex != tabIndex and \ evt.buttons() == Qt.NoButton: - self.__currentTabPreviewIndex = tabIndex - QTimer.singleShot(200, self.__showTabPreview) + if self.__previewPopup is None or \ + (self.__previewPopup is not None and + self.__previewPopup.getCustomData("index") != tabIndex): + QTimer.singleShot( + 0, lambda: self.__showTabPreview(tabIndex)) # If current tab or not found then hide previous tab preview if tabIndex == self.currentIndex() or \ tabIndex == -1: - if self.__previewPopup is not None: - self.__previewPopup.hide() - self.__currentTabPreviewIndex = -1 + self.__hidePreview() def leaveEvent(self, evt): """ @@ -117,9 +127,7 @@ """ if Preferences.getWebBrowser("ShowPreview"): # If leave tabwidget then hide previous tab preview - if self.__previewPopup is not None: - self.__previewPopup.hide() - self.__currentTabPreviewIndex = -1 + self.__hidePreview() super(WebBrowserTabBar, self).leaveEvent(evt) @@ -130,9 +138,7 @@ @param evt reference to the mouse press event (QMouseEvent) """ if Preferences.getWebBrowser("ShowPreview"): - if self.__previewPopup is not None: - self.__previewPopup.hide() - self.__currentTabPreviewIndex = -1 + self.__hidePreview() super(WebBrowserTabBar, self).mousePressEvent(evt) @@ -161,6 +167,4 @@ @param index index of the removed tab (integer) """ if Preferences.getWebBrowser("ShowPreview"): - if self.__previewPopup is not None: - self.__previewPopup.hide() - self.__currentTabPreviewIndex = -1 + self.__hidePreview()