PluginManager/PluginRepositoryDialog.py

changeset 5047
04e5dfbd3f3d
parent 4631
5c1a96925da4
child 5382
5b772524f302
diff -r 021d99e03961 -r 04e5dfbd3f3d PluginManager/PluginRepositoryDialog.py
--- a/PluginManager/PluginRepositoryDialog.py	Tue Jul 19 18:51:15 2016 +0200
+++ b/PluginManager/PluginRepositoryDialog.py	Sat Jul 23 13:33:54 2016 +0200
@@ -123,12 +123,16 @@
             self.__networkManager.sslErrors.connect(self.__sslErrors)
         self.__replies = []
         
-        self.__networkConfigurationManager = QNetworkConfigurationManager(self)
-        self.__onlineStateChanged(
-            self.__networkConfigurationManager.isOnline())
-        
-        self.__networkConfigurationManager.onlineStateChanged.connect(
-            self.__onlineStateChanged)
+        if Preferences.getUI("DynamicOnlineCheck"):
+            self.__networkConfigurationManager = \
+                QNetworkConfigurationManager(self)
+            self.__onlineStateChanged(
+                self.__networkConfigurationManager.isOnline())
+            self.__networkConfigurationManager.onlineStateChanged.connect(
+                self.__onlineStateChanged)
+        else:
+            self.__networkConfigurationManager = None
+            self.__onlineStateChanged(True)
         
         self.__doneMethod = None
         self.__inDownload = False
@@ -157,6 +161,18 @@
             msg = self.tr("Network Status: offline")
         self.statusLabel.setText(msg)
     
+    def __isOnline(self):
+        """
+        Private method to check the online status.
+        
+        @return flag indicating the online status
+        @rtype bool
+        """
+        if self.__networkConfigurationManager is not None:
+            return self.__networkConfigurationManager.isOnline()
+        else:
+            return True
+    
     @pyqtSlot(QAbstractButton)
     def on_buttonBox_clicked(self, button):
         """
@@ -257,10 +273,10 @@
         """
         self.__downloadButton.setEnabled(
             len(self.__selectedItems()) and
-            self.__networkConfigurationManager.isOnline())
+            self.__isOnline())
         self.__downloadInstallButton.setEnabled(
             len(self.__selectedItems()) and
-            self.__networkConfigurationManager.isOnline())
+            self.__isOnline())
         self.__installButton.setEnabled(len(self.__selectedItems()))
     
     def __updateList(self):
@@ -422,7 +438,7 @@
         @param filename local name of the file (string)
         @param doneMethod method to be called when done
         """
-        if self.__networkConfigurationManager.isOnline():
+        if self.__isOnline():
             self.__updateButton.setEnabled(False)
             self.__downloadButton.setEnabled(False)
             self.__downloadInstallButton.setEnabled(False)
@@ -460,7 +476,7 @@
         self.__updateButton.setEnabled(True)
         self.__downloadCancelButton.setEnabled(False)
         self.__onlineStateChanged(
-            self.__networkConfigurationManager.isOnline())
+            self.__isOnline())
         
         ok = True
         reply = self.sender()

eric ide

mercurial