Changed logic when showing the 'Edit Dictionaries' menu. 5_3_x

Tue, 28 May 2013 17:40:53 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 28 May 2013 17:40:53 +0200
branch
5_3_x
changeset 2675
3215c3dc3bfa
parent 2668
4c5320acf00d
child 2676
1638771366c2

Changed logic when showing the 'Edit Dictionaries' menu.
(grafted from c62efb5f2d7940541361845b68e48cc327e134a3)

ViewManager/ViewManager.py file | annotate | diff | comparison | revisions
--- a/ViewManager/ViewManager.py	Mon May 20 11:42:14 2013 +0200
+++ b/ViewManager/ViewManager.py	Tue May 28 17:40:53 2013 +0200
@@ -3591,14 +3591,13 @@
             QApplication.translate('ViewManager', "Project Exception List"),
             self.__editProjectPEL)
         self.__editSpellingMenu.addSeparator()
-        self.__editSpellingMenu.addAction(
+        self.__editUserPwlAct = self.__editSpellingMenu.addAction(
             QApplication.translate('ViewManager', "User Word List"),
             self.__editUserPWL)
-        self.__editSpellingMenu.addAction(
+        self.__editUserPelAct = self.__editSpellingMenu.addAction(
             QApplication.translate('ViewManager', "User Exception List"),
             self.__editUserPEL)
-        self.__editProjectPwlAct.setEnabled(False)
-        self.__editProjectPelAct.setEnabled(False)
+        self.__editSpellingMenu.aboutToShow.connect(self.__showEditSpellingMenu)
         
         menu.addAction(self.spellCheckAct)
         menu.addAction(self.autoSpellCheckAct)
@@ -5336,6 +5335,23 @@
     ## Below are the action methods for the spell checking functions
     ##################################################################
     
+    def __showEditSpellingMenu(self):
+        """
+        Private method to set up the edit dictionaries menu.
+        """
+        proj = e5App().getObject("Project")
+        projetOpen = proj.isOpen()
+        pwl = e5App().getObject("Project").getProjectDictionaries()[0]
+        self.__editProjectPwlAct.setEnabled(projetOpen and bool(pwl))
+        pel = e5App().getObject("Project").getProjectDictionaries()[1]
+        self.__editProjectPelAct.setEnabled(projetOpen and bool(pel))
+        
+        from QScintilla.SpellChecker import SpellChecker
+        pwl = SpellChecker.getUserDictionaryPath()
+        self.__editUserPwlAct.setEnabled(bool(pwl))
+        pel = SpellChecker.getUserDictionaryPath(True)
+        self.__editUserPelAct.setEnabled(bool(pel))
+    
     def __setAutoSpellChecking(self):
         """
         Private slot to set the automatic spell checking of all editors.
@@ -5358,26 +5374,14 @@
         Private slot to edit the project word list.
         """
         pwl = e5App().getObject("Project").getProjectDictionaries()[0]
-        if pwl:
-            self.__editSpellingDictionary(pwl)
-        else:
-            E5MessageBox.warning(self.ui,
-                QApplication.translate('ViewManager', "Edit Project Word List"),
-                QApplication.translate('ViewManager',
-                    """No word list defined for the current project."""))
+        self.__editSpellingDictionary(pwl)
     
     def __editProjectPEL(self):
         """
         Private slot to edit the project exception list.
         """
         pel = e5App().getObject("Project").getProjectDictionaries()[1]
-        if pel:
-            self.__editSpellingDictionary(pel)
-        else:
-            E5MessageBox.warning(self.ui,
-                QApplication.translate('ViewManager', "Edit Project Exception List"),
-                QApplication.translate('ViewManager',
-                    """No exception list defined for the current project."""))
+        self.__editSpellingDictionary(pel)
     
     def __editUserPWL(self):
         """

eric ide

mercurial