eric6/WebBrowser/SpellCheck/ManageDictionariesDialog.py

changeset 7946
6901746220fc
parent 7923
91e843545d9a
child 8143
2c730d5fd177
diff -r 76daafe10009 -r 6901746220fc eric6/WebBrowser/SpellCheck/ManageDictionariesDialog.py
--- a/eric6/WebBrowser/SpellCheck/ManageDictionariesDialog.py	Sun Jan 03 15:33:39 2021 +0100
+++ b/eric6/WebBrowser/SpellCheck/ManageDictionariesDialog.py	Sun Jan 03 17:49:38 2021 +0100
@@ -17,9 +17,7 @@
 from PyQt5.QtWidgets import (
     QDialog, QDialogButtonBox, QAbstractButton, QListWidgetItem
 )
-from PyQt5.QtNetwork import (
-    QNetworkConfigurationManager, QNetworkRequest, QNetworkReply
-)
+from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply
 
 from E5Gui import E5MessageBox
 
@@ -68,16 +66,6 @@
         self.dictionariesUrlEdit.setText(
             Preferences.getWebBrowser("SpellCheckDictionariesUrl"))
         
-        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.__replies = []
         
         self.__downloadCancelled = False
@@ -85,36 +73,6 @@
         
         self.__populateList()
     
-    @pyqtSlot(bool)
-    def __onlineStateChanged(self, online):
-        """
-        Private slot handling online state changes.
-        
-        @param online flag indicating the online status
-        @type bool
-        """
-        self.__refreshButton.setEnabled(online)
-        
-        if online:
-            msg = self.tr("Network Status: online")
-        else:
-            msg = self.tr("Network Status: offline")
-        self.statusLabel.setText(msg)
-        
-        self.on_dictionariesList_itemSelectionChanged()
-    
-    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):
         """
@@ -139,8 +97,7 @@
         """
         self.__installButton.setEnabled(
             self.locationComboBox.count() > 0 and
-            len(self.dictionariesList.selectedItems()) > 0 and
-            self.__isOnline()
+            len(self.dictionariesList.selectedItems()) > 0
         )
         
         self.__uninstallButton.setEnabled(
@@ -180,32 +137,23 @@
         
         url = self.dictionariesUrlEdit.text()
         
-        if self.__isOnline():
-            self.__refreshButton.setEnabled(False)
-            self.__installButton.setEnabled(False)
-            self.__uninstallButton.setEnabled(False)
-            self.__cancelButton.setEnabled(True)
-            
-            self.statusLabel.setText(url)
-            
-            self.__downloadCancelled = False
-            
-            request = QNetworkRequest(QUrl(url))
-            request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
-                                 QNetworkRequest.AlwaysNetwork)
-            reply = WebBrowserWindow.networkManager().get(request)
-            reply.finished.connect(
-                lambda: self.__listFileDownloaded(reply))
-            reply.downloadProgress.connect(self.__downloadProgress)
-            self.__replies.append(reply)
-        else:
-            E5MessageBox.warning(
-                self,
-                self.tr("Error populating list of dictionaries"),
-                self.tr(
-                    """<p>Could not download the dictionaries list"""
-                    """ from {0}.</p><p>Error: {1}</p>"""
-                ).format(url, self.tr("Computer is offline.")))
+        self.__refreshButton.setEnabled(False)
+        self.__installButton.setEnabled(False)
+        self.__uninstallButton.setEnabled(False)
+        self.__cancelButton.setEnabled(True)
+        
+        self.statusLabel.setText(url)
+        
+        self.__downloadCancelled = False
+        
+        request = QNetworkRequest(QUrl(url))
+        request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
+                             QNetworkRequest.AlwaysNetwork)
+        reply = WebBrowserWindow.networkManager().get(request)
+        reply.finished.connect(
+            lambda: self.__listFileDownloaded(reply))
+        reply.downloadProgress.connect(self.__downloadProgress)
+        self.__replies.append(reply)
     
     def __listFileDownloaded(self, reply):
         """
@@ -217,7 +165,6 @@
         """
         self.__refreshButton.setEnabled(True)
         self.__cancelButton.setEnabled(False)
-        self.__onlineStateChanged(self.__isOnline())
         
         self.downloadProgress.setValue(0)
         
@@ -356,7 +303,7 @@
         """
         Private method to install the selected dictionaries.
         """
-        if self.__isOnline() and bool(self.locationComboBox.currentText()):
+        if bool(self.locationComboBox.currentText()):
             self.__dictionariesToDownload = [
                 itm.data(ManageDictionariesDialog.UrlRole)
                 for itm in self.dictionariesList.selectedItems()
@@ -375,31 +322,22 @@
         """
         Private slot to download a dictionary.
         """
-        if self.__isOnline():
-            if self.__dictionariesToDownload:
-                url = self.__dictionariesToDownload.pop(0)
-                self.statusLabel.setText(url)
-                
-                self.__downloadCancelled = False
-                
-                request = QNetworkRequest(QUrl(url))
-                request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
-                                     QNetworkRequest.AlwaysNetwork)
-                reply = WebBrowserWindow.networkManager().get(request)
-                reply.finished.connect(
-                    lambda: self.__installDictionary(reply))
-                reply.downloadProgress.connect(self.__downloadProgress)
-                self.__replies.append(reply)
-            else:
-                self.__installationFinished()
+        if self.__dictionariesToDownload:
+            url = self.__dictionariesToDownload.pop(0)
+            self.statusLabel.setText(url)
+            
+            self.__downloadCancelled = False
+            
+            request = QNetworkRequest(QUrl(url))
+            request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
+                                 QNetworkRequest.AlwaysNetwork)
+            reply = WebBrowserWindow.networkManager().get(request)
+            reply.finished.connect(
+                lambda: self.__installDictionary(reply))
+            reply.downloadProgress.connect(self.__downloadProgress)
+            self.__replies.append(reply)
         else:
-            E5MessageBox.warning(
-                self,
-                self.tr("Error downloading dictionary file"),
-                self.tr(
-                    """<p>Could not download the requested dictionary file"""
-                    """ from {0}.</p><p>Error: {1}</p>"""
-                ).format(url, self.tr("Computer is offline.")))
+            self.__installationFinished()
             
             self.__installationFinished()
     
@@ -454,7 +392,6 @@
         """
         self.__refreshButton.setEnabled(True)
         self.__cancelButton.setEnabled(False)
-        self.__onlineStateChanged(self.__isOnline())
         
         self.dictionariesList.clearSelection()
         self.downloadProgress.setValue(0)

eric ide

mercurial