CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)

Sun, 22 Apr 2018 14:01:39 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 22 Apr 2018 14:01:39 +0200
changeset 6266
c7bc0e516cd6
parent 6265
56bd09c4c297
child 6267
350655a6c85f

CodeDocumentationViewer: added code to remember the most recently unregistered provider for some time in case it is registered again (e.g. during plug-in update)

Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric6.UI.CodeDocumentationViewer.html file | annotate | diff | comparison | revisions
UI/CodeDocumentationViewer.py file | annotate | diff | comparison | revisions
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Sat Apr 21 18:02:04 2018 +0200
+++ b/Documentation/Help/source.qhp	Sun Apr 22 14:01:39 2018 +0200
@@ -2945,11 +2945,13 @@
       <keyword name="CodeDocumentationViewer" id="CodeDocumentationViewer" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer" />
       <keyword name="CodeDocumentationViewer (Constructor)" id="CodeDocumentationViewer (Constructor)" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.__init__" />
       <keyword name="CodeDocumentationViewer (Module)" id="CodeDocumentationViewer (Module)" ref="eric6.UI.CodeDocumentationViewer.html" />
+      <keyword name="CodeDocumentationViewer.__selectProvider" id="CodeDocumentationViewer.__selectProvider" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.__selectProvider" />
       <keyword name="CodeDocumentationViewer.__setHtml" id="CodeDocumentationViewer.__setHtml" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.__setHtml" />
       <keyword name="CodeDocumentationViewer.__setHtmlWarning" id="CodeDocumentationViewer.__setHtmlWarning" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.__setHtmlWarning" />
       <keyword name="CodeDocumentationViewer.__setupUi" id="CodeDocumentationViewer.__setupUi" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.__setupUi" />
       <keyword name="CodeDocumentationViewer.__showDisabledMessage" id="CodeDocumentationViewer.__showDisabledMessage" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.__showDisabledMessage" />
       <keyword name="CodeDocumentationViewer.__showTextViewer" id="CodeDocumentationViewer.__showTextViewer" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.__showTextViewer" />
+      <keyword name="CodeDocumentationViewer.__unregisterTimerTimeout" id="CodeDocumentationViewer.__unregisterTimerTimeout" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.__unregisterTimerTimeout" />
       <keyword name="CodeDocumentationViewer.documentationReady" id="CodeDocumentationViewer.documentationReady" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.documentationReady" />
       <keyword name="CodeDocumentationViewer.finalizeSetup" id="CodeDocumentationViewer.finalizeSetup" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.finalizeSetup" />
       <keyword name="CodeDocumentationViewer.getProviders" id="CodeDocumentationViewer.getProviders" ref="eric6.UI.CodeDocumentationViewer.html#CodeDocumentationViewer.getProviders" />
--- a/Documentation/Source/eric6.UI.CodeDocumentationViewer.html	Sat Apr 21 18:02:04 2018 +0200
+++ b/Documentation/Source/eric6.UI.CodeDocumentationViewer.html	Sun Apr 22 14:01:39 2018 +0200
@@ -78,6 +78,9 @@
 <td><a href="#CodeDocumentationViewer.__init__">CodeDocumentationViewer</a></td>
 <td>Constructor</td>
 </tr><tr>
+<td><a href="#CodeDocumentationViewer.__selectProvider">__selectProvider</a></td>
+<td>Private method to select a provider programmatically.</td>
+</tr><tr>
 <td><a href="#CodeDocumentationViewer.__setHtml">__setHtml</a></td>
 <td>Private slot to set the prepared HTML text.</td>
 </tr><tr>
@@ -93,6 +96,9 @@
 <td><a href="#CodeDocumentationViewer.__showTextViewer">__showTextViewer</a></td>
 <td>Private slot to show the selected viewer.</td>
 </tr><tr>
+<td><a href="#CodeDocumentationViewer.__unregisterTimerTimeout">__unregisterTimerTimeout</a></td>
+<td>Private slot handling the timeout signal of the unregister timer.</td>
+</tr><tr>
 <td><a href="#CodeDocumentationViewer.documentationReady">documentationReady</a></td>
 <td>Public method to provide the documentation info to the viewer.</td>
 </tr><tr>
@@ -138,6 +144,16 @@
 <dd>
 reference to the parent widget
 </dd>
+</dl><a NAME="CodeDocumentationViewer.__selectProvider" ID="CodeDocumentationViewer.__selectProvider"></a>
+<h4>CodeDocumentationViewer.__selectProvider</h4>
+<b>__selectProvider</b>(<i>provider</i>)
+<p>
+        Private method to select a provider programmatically.
+</p><dl>
+<dt><i>provider</i> (str)</dt>
+<dd>
+name of the provider to be selected
+</dd>
 </dl><a NAME="CodeDocumentationViewer.__setHtml" ID="CodeDocumentationViewer.__setHtml"></a>
 <h4>CodeDocumentationViewer.__setHtml</h4>
 <b>__setHtml</b>(<i>html</i>)
@@ -178,7 +194,12 @@
 <dd>
 flag indicating the rich text viewer
 </dd>
-</dl><a NAME="CodeDocumentationViewer.documentationReady" ID="CodeDocumentationViewer.documentationReady"></a>
+</dl><a NAME="CodeDocumentationViewer.__unregisterTimerTimeout" ID="CodeDocumentationViewer.__unregisterTimerTimeout"></a>
+<h4>CodeDocumentationViewer.__unregisterTimerTimeout</h4>
+<b>__unregisterTimerTimeout</b>(<i></i>)
+<p>
+        Private slot handling the timeout signal of the unregister timer.
+</p><a NAME="CodeDocumentationViewer.documentationReady" ID="CodeDocumentationViewer.documentationReady"></a>
 <h4>CodeDocumentationViewer.documentationReady</h4>
 <b>documentationReady</b>(<i>documentationInfo, isWarning=False, isDocWarning=False</i>)
 <p>
--- a/UI/CodeDocumentationViewer.py	Sat Apr 21 18:02:04 2018 +0200
+++ b/UI/CodeDocumentationViewer.py	Sun Apr 22 14:01:39 2018 +0200
@@ -14,7 +14,7 @@
 except NameError:
     basestring = str
 
-from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QUrl
+from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QUrl, QTimer
 from PyQt5.QtGui import QCursor
 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, \
     QComboBox, QSizePolicy, QLineEdit, QTextEdit, QToolTip, QToolButton, \
@@ -210,6 +210,12 @@
         
         self.__lastDocumentation = None
         self.__requestingEditor = None
+        
+        self.__unregisterTimer = QTimer(self)
+        self.__unregisterTimer.setInterval(30000)   # 30 seconds
+        self.__unregisterTimer.setSingleShot(True)
+        self.__unregisterTimer.timeout.connect(self.__unregisterTimerTimeout)
+        self.__mostRecentlyUnregisteredProvider = None
     
     def __setupUi(self):
         """
@@ -342,6 +348,13 @@
         self.providerComboBox.addItem(providerDisplay, providerName)
         
         self.providerAdded.emit()
+        
+        if self.__unregisterTimer.isActive():
+            if providerName == self.__mostRecentlyUnregisteredProvider:
+                # this is assumed to be a plug-in reload
+                self.__unregisterTimer.stop()
+                self.__mostRecentlyUnregisteredProvider = None
+                self.__selectProvider(providerName)
     
     def unregisterProvider(self, providerName):
         """
@@ -353,6 +366,11 @@
         if providerName in self.__providers:
             if providerName == self.__selectedProvider:
                 self.providerComboBox.setCurrentIndex(0)
+                
+                # in case this is just a temporary unregistration (< 30s)
+                # e.g. when the plug-in is re-installed or updated
+                self.__mostRecentlyUnregisteredProvider = providerName
+                self.__unregisterTimer.start()
             
             del self.__providers[providerName]
             index = self.providerComboBox.findData(providerName)
@@ -360,6 +378,13 @@
             
             self.providerRemoved.emit()
     
+    @pyqtSlot()
+    def __unregisterTimerTimeout(self):
+        """
+        Private slot handling the timeout signal of the unregister timer.
+        """
+        self.__mostRecentlyUnregisteredProvider = None
+    
     def isSupportedLanguage(self, language):
         """
         Public method to check, if the given language is supported by the
@@ -581,6 +606,15 @@
             self.__showTextViewer(showMarkdown)
         
         provider = Preferences.getDocuViewer("Provider")
+        self.__selectProvider(provider)
+    
+    def __selectProvider(self, provider):
+        """
+        Private method to select a provider programmatically.
+        
+        @param provider name of the provider to be selected
+        @type str
+        """
         if provider != self.__selectedProvider:
             index = self.providerComboBox.findData(provider)
             if index < 0:

eric ide

mercurial