OSDN Git Service

Change spell check defaults and allow options to be changed without a restart.
authorRandy Baumgarte <randy@fbn.cx>
Thu, 7 Oct 2010 18:48:18 +0000 (14:48 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 10 Oct 2010 14:04:21 +0000 (10:04 -0400)
src/cx/fbn/nevernote/Global.java
src/cx/fbn/nevernote/dialog/SpellCheck.java
src/cx/fbn/nevernote/gui/BrowserWindow.java

index a13f695..d9da6fb 100644 (file)
@@ -1062,6 +1062,8 @@ public class Global {
                        return true;\r
                if (value.equalsIgnoreCase(Configuration.SPELL_IGNOREUPPERCASE))\r
                        return true;\r
+               if (value.equalsIgnoreCase(Configuration.SPELL_IGNORESENTENCECAPITALIZATION))\r
+                       return true;\r
                return false;\r
     }\r
     public static void setSpellSetting(String setting, boolean val) {\r
index e400bba..beb3ced 100644 (file)
@@ -182,16 +182,9 @@ public class SpellCheck extends QDialog {
                replacementWord.setText(word);\r
        }\r
        \r
-       public void setNoSuggestions(boolean enable) {\r
-               if (enable) {\r
-                       replacementWord.setEnabled(true);\r
-                       replace.setEnabled(true);\r
-                       suggestions.setEnabled(true);\r
-               } else {\r
-                       replacementWord.setEnabled(false);\r
-                       replace.setEnabled(false);\r
-                       suggestions.setEnabled(false);\r
-               }\r
+       // Empty out the list\r
+       public void clearSuggestions() {\r
+               suggestions.clear();\r
        }\r
        \r
        public void setSelectedSuggestion(int index) {\r
index 3c35f98..e9005dd 100644 (file)
@@ -244,14 +244,14 @@ public class BrowserWindow extends QWidget {
                        spellCheckDialog = new SpellCheck(checker);\r
                }\r
                public void spellingError(SpellCheckEvent event) {\r
+                       System.out.println("**" +event.getInvalidWord());\r
                        errorsFound = true;\r
                        spellCheckDialog.setWord(event.getInvalidWord());\r
 \r
                    List<Word> suggestions = event.getSuggestions();\r
-                   if (suggestions.isEmpty()) {\r
-                      spellCheckDialog.setNoSuggestions(true);\r
-                   } else {\r
-                      spellCheckDialog.setCurrentSuggestion(suggestions.get(0).getWord());\r
+                   spellCheckDialog.clearSuggestions();\r
+                   if (!suggestions.isEmpty()) {\r
+//                    spellCheckDialog.setCurrentSuggestion(suggestions.get(0).getWord());\r
                       for (int i=0; i<suggestions.size(); i++) {\r
                          spellCheckDialog.addSuggestion(suggestions.get(i).getWord());\r
                       }\r
@@ -260,6 +260,7 @@ public class BrowserWindow extends QWidget {
                    spellCheckDialog.exec();\r
                    if (spellCheckDialog.cancelPressed()) {\r
                        abortSpellCheck = true;\r
+                       event.cancel();\r
                        return;\r
                    }\r
                    if (spellCheckDialog.replacePressed()) {\r
@@ -267,6 +268,7 @@ public class BrowserWindow extends QWidget {
                        clipboard.setText(spellCheckDialog.getReplacementWord()); \r
                        parent.pasteClicked();\r
                    }\r
+                   event.cancel();\r
                 }\r
        }\r
 \r
@@ -2681,18 +2683,6 @@ public class BrowserWindow extends QWidget {
                        dictionary = new SpellDictionaryHashMap(wordList);\r
                        spellChecker = new SpellChecker(dictionary);\r
                        \r
-                       // Read user settings\r
-                       spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREDIGITWORDS, \r
-                                       Global.getSpellSetting(Configuration.SPELL_IGNOREDIGITWORDS));\r
-                       spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREINTERNETADDRESSES, \r
-                                       Global.getSpellSetting(Configuration.SPELL_IGNOREINTERNETADDRESSES));\r
-                       spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREMIXEDCASE, \r
-                                       Global.getSpellSetting(Configuration.SPELL_IGNOREMIXEDCASE));\r
-                       spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREUPPERCASE, \r
-                                       Global.getSpellSetting(Configuration.SPELL_IGNOREUPPERCASE));\r
-                       spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNORESENTENCECAPITALIZATION, \r
-                                       Global.getSpellSetting(Configuration.SPELL_IGNORESENTENCECAPITALIZATION));\r
-                       \r
                        File userWordList;\r
                        userWordList = new File(Global.getFileManager().getSpellDirPathUser()+"user.dic");\r
                        \r
@@ -2731,6 +2721,18 @@ public class BrowserWindow extends QWidget {
                if (spellChecker == null) {\r
                        setupDictionary();      \r
                }\r
+               \r
+               // Read user settings\r
+               spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREDIGITWORDS, \r
+                               Global.getSpellSetting(Configuration.SPELL_IGNOREDIGITWORDS));\r
+               spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREINTERNETADDRESSES, \r
+                               Global.getSpellSetting(Configuration.SPELL_IGNOREINTERNETADDRESSES));\r
+               spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREMIXEDCASE, \r
+                               Global.getSpellSetting(Configuration.SPELL_IGNOREMIXEDCASE));\r
+               spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNOREUPPERCASE, \r
+                               Global.getSpellSetting(Configuration.SPELL_IGNOREUPPERCASE));\r
+               spellChecker.getConfiguration().setBoolean(Configuration.SPELL_IGNORESENTENCECAPITALIZATION, \r
+                               Global.getSpellSetting(Configuration.SPELL_IGNORESENTENCECAPITALIZATION));\r
 \r
                spellListener.abortSpellCheck = false;\r
                spellListener.errorsFound = false;\r