E5Network/E5NetworkIcon.py

changeset 5047
04e5dfbd3f3d
parent 4671
59cdebfb658c
child 5389
9b1c800daff3
--- a/E5Network/E5NetworkIcon.py	Tue Jul 19 18:51:15 2016 +0200
+++ b/E5Network/E5NetworkIcon.py	Sat Jul 23 13:33:54 2016 +0200
@@ -14,6 +14,7 @@
 from PyQt5.QtWidgets import QLabel
 
 import UI.PixmapCache
+import Preferences
 
 
 class E5NetworkIcon(QLabel):
@@ -34,12 +35,16 @@
         """
         super(E5NetworkIcon, self).__init__(parent)
         
-        self.__networkManager = QNetworkConfigurationManager(self)
-        self.__online = self.__networkManager.isOnline()
-        self.__onlineStateChanged(self.__online)
-        
-        self.__networkManager.onlineStateChanged.connect(
-            self.__onlineStateChanged)
+        if Preferences.getUI("DynamicOnlineCheck"):
+            self.__networkManager = QNetworkConfigurationManager(self)
+            self.__online = self.__networkManager.isOnline()
+            self.__onlineStateChanged(self.__online)
+            
+            self.__networkManager.onlineStateChanged.connect(
+                self.__onlineStateChanged)
+        else:
+            self.__online = True
+            self.__onlineStateChanged(self.__online)
     
     @pyqtSlot(bool)
     def __onlineStateChanged(self, online):
@@ -57,7 +62,7 @@
         tooltip = self.tr("<p>Shows the network status<br/><br/>"
                           "<b>Network:</b> {0}</p>")
         
-        if self.__networkManager.isOnline():
+        if online:
             tooltip = tooltip.format(self.tr("Connected"))
         else:
             tooltip = tooltip.format(self.tr("Offline"))
@@ -75,4 +80,4 @@
         @return online state
         @rtype bool
         """
-        return self.__networkManager.isOnline()
+        return self.__online

eric ide

mercurial