OSDN Git Service

Add automatic wildcard option.
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / dialog / ConfigDialog.java
index 587faba..9be08dc 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * This file is part of NeverNote \r
+ * This file is part of NixNote \r
  * Copyright 2009 Randy Baumgarte\r
  * \r
  * This file may be licensed under the terms of of the\r
  *\r
 */\r
 \r
+//**********************************************\r
+//**********************************************\r
+//* This dialog is the debugging information \r
+//* page used in the Edit/Preferences dialog\r
+//**********************************************\r
+//**********************************************\r
+\r
 package cx.fbn.nevernote.dialog;\r
 \r
 import java.io.FileInputStream;\r
 import java.io.FileNotFoundException;\r
 import java.io.FileOutputStream;\r
 \r
+import com.swabunga.spell.engine.Configuration;\r
 import com.trolltech.qt.core.QSize;\r
 import com.trolltech.qt.core.Qt.AlignmentFlag;\r
 import com.trolltech.qt.core.Qt.ItemFlag;\r
@@ -42,16 +50,19 @@ import cx.fbn.nevernote.Global;
 import cx.fbn.nevernote.utilities.AESEncrypter;\r
 public class ConfigDialog extends QDialog {\r
        private final QListWidget                               contentsWidget;\r
+       private final ConfigFontPage                    fontPage;\r
        private final QStackedWidget                    pagesWidget;\r
        private final ConfigConnectionPage              connectionPage;\r
        private final ConfigDebugPage                   debugPage;\r
        private final ConfigAppearancePage              appearancePage;\r
+       private final ConfigSpellPage                   spellPage;\r
        private final ConfigIndexPage                   indexPage;\r
-       private final ConfigShowEditorButtonsPage               editorButtonsPage;\r
+    private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
        \r
        public ConfigDialog(QWidget parent) {\r
                \r
                contentsWidget = new QListWidget(this);\r
+               setWindowIcon(new QIcon(iconPath+"config.png"));\r
                contentsWidget.setViewMode(QListView.ViewMode.IconMode);\r
                contentsWidget.setIconSize(new QSize(96, 84));\r
                contentsWidget.setMovement(QListView.Movement.Static);\r
@@ -59,15 +70,17 @@ public class ConfigDialog extends QDialog {
                contentsWidget.setSpacing(12);\r
                \r
                pagesWidget = new QStackedWidget(this);\r
+               fontPage = new ConfigFontPage(this);\r
                connectionPage = new ConfigConnectionPage(this);\r
                appearancePage = new ConfigAppearancePage(this);\r
                indexPage = new ConfigIndexPage(this);\r
                debugPage = new ConfigDebugPage(this);\r
-               editorButtonsPage = new ConfigShowEditorButtonsPage(this);\r
+               spellPage = new ConfigSpellPage(this);\r
                pagesWidget.addWidget(appearancePage);\r
+               pagesWidget.addWidget(fontPage);\r
                pagesWidget.addWidget(indexPage);\r
+               pagesWidget.addWidget(spellPage);\r
                pagesWidget.addWidget(connectionPage);\r
-               pagesWidget.addWidget(editorButtonsPage);\r
                pagesWidget.addWidget(debugPage);\r
                \r
                QPushButton cancelButton = new QPushButton(tr("Cancel"));\r
@@ -96,8 +109,13 @@ public class ConfigDialog extends QDialog {
                \r
                loadSettings();\r
        }\r
+\r
+       //******************************************\r
+       //* Ok button is pushed.  Save values\r
+       //******************************************\r
        public void okPushed() {\r
                Global.setServer(debugPage.getServer());\r
+               Global.setEnableThumbnails(debugPage.getEnableThumbnails());\r
                AESEncrypter aes = new AESEncrypter();\r
                aes.setUserid(connectionPage.getUserid().trim());\r
                \r
@@ -107,6 +125,7 @@ public class ConfigDialog extends QDialog {
                        Global.disableUploads = false;\r
                Global.setDisableUploads(Global.disableUploads);\r
                Global.setMimicEvernoteInterface(appearancePage.getMimicEvernote());\r
+               Global.setMinimizeOnClose(appearancePage.getMinimizeOnClose());\r
                \r
                if (appearancePage.getShowSplashScreen())\r
                        Global.saveWindowVisible("SplashScreen", true);\r
@@ -118,12 +137,23 @@ public class ConfigDialog extends QDialog {
                        Global.setPdfPreview(true);\r
                else\r
                        Global.setPdfPreview(false);\r
+\r
+               if (appearancePage.getCheckForUpdates())\r
+                       Global.setCheckVersionUpgrade(true);\r
+               else\r
+                       Global.setCheckVersionUpgrade(false);\r
+\r
                \r
                if (appearancePage.getNewNoteWithTags())\r
                        Global.setNewNoteWithSelectedTags(true);\r
                else\r
                        Global.setNewNoteWithSelectedTags(false);\r
                \r
+               if (appearancePage.getAnyTagSelection())\r
+                       Global.setAnyTagSelectionMatch(true);\r
+               else\r
+                       Global.setAnyTagSelectionMatch(false);\r
+               \r
                Global.setAutoSaveInterval(appearancePage.getAutoSaveInterval());\r
                                                \r
                Global.setAutomaticLogin(connectionPage.getAutomaticLogin());\r
@@ -131,11 +161,25 @@ public class ConfigDialog extends QDialog {
                if (connectionPage.getRememberPassword()) {     \r
                        aes.setPassword(connectionPage.getPassword());\r
                }\r
+               Global.setProxyValue("url", connectionPage.getProxyUrl());\r
+               Global.setProxyValue("port", connectionPage.getProxyPort());\r
+               Global.setProxyValue("userid", connectionPage.getProxyUserid());\r
+               Global.setProxyValue("password", connectionPage.getProxyPassword());\r
+               \r
                Global.setShowTrayIcon(appearancePage.getShowTrayIcon());\r
                Global.setVerifyDelete(appearancePage.getVerifyDelete());\r
+               Global.setStartMinimized(appearancePage.getStartMinimized());\r
                Global.setSynchronizeOnClose(connectionPage.getSynchronizeOnClose());\r
                Global.setSynchronizeDeletedContent(connectionPage.getSynchronizeDeletedContent());\r
                Global.setTagBehavior(appearancePage.getTagBehavior());\r
+               Global.setIndexAttachmentsLocally(indexPage.getIndexAttachmentsLocally());\r
+               Global.setIndexNoteBody(indexPage.getIndexNoteBody());\r
+               Global.setIndexNoteTitle(indexPage.getIndexNoteTitle());\r
+               Global.setIndexImageRecognition(indexPage.getIndexImageRecognition());\r
+               Global.setAutomaticWildcardSearches(indexPage.getAutomaticWildcardSearches());\r
+               Global.setSpecialIndexCharacters(indexPage.getSpecialCharacters());\r
+               Global.setIncludeTagChildren(appearancePage.getIncludeTagChildren());\r
+               \r
        FileOutputStream out = null;\r
                try {\r
                        out = new FileOutputStream(Global.getFileManager().getHomeDirFile("secure.txt"));\r
@@ -147,12 +191,18 @@ public class ConfigDialog extends QDialog {
                Global.userStoreUrl = "https://"+debugPage.getServer()+"/edam/user";\r
                Global.setWordRegex(indexPage.getRegex());\r
                Global.setRecognitionWeight(indexPage.getRecognitionWeight());\r
-               Global.setMinimumWordLength(indexPage.getWordLength());\r
-               Global.minimumWordCount = indexPage.getWordLength();    \r
-               Global.setIndexThreads(indexPage.getIndexThreads());\r
+               Global.setIndexThreadSleepInterval(indexPage.getSleepInterval());\r
                Global.setMessageLevel( debugPage.getDebugLevel());\r
                Global.saveCarriageReturnFix(debugPage.getCarriageReturnFix());\r
                Global.enableCarriageReturnFix = debugPage.getCarriageReturnFix();\r
+               Global.saveHtmlEntitiesFix(debugPage.getHtmlEntitiesFix());\r
+               Global.enableHTMLEntitiesFix = debugPage.getHtmlEntitiesFix();\r
+               \r
+               Global.setSpellSetting(Configuration.SPELL_IGNOREDIGITWORDS, spellPage.getIgnoreDigitWords());\r
+               Global.setSpellSetting(Configuration.SPELL_IGNOREINTERNETADDRESSES, spellPage.getIgnoreInternetAddresses());\r
+               Global.setSpellSetting(Configuration.SPELL_IGNOREMIXEDCASE, spellPage.getIgnoreMixedCase());\r
+               Global.setSpellSetting(Configuration.SPELL_IGNOREUPPERCASE, spellPage.getIgnoreUpperCase());\r
+               Global.setSpellSetting(Configuration.SPELL_IGNORESENTENCECAPITALIZATION, spellPage.getIgnoreSentenceCapitalization());\r
                \r
                String guiFormat = appearancePage.getStyle();\r
                QApplication.setStyle(guiFormat);\r
@@ -176,44 +226,33 @@ public class ConfigDialog extends QDialog {
                \r
                Global.setSyncInterval(connectionPage.getSyncInterval());\r
                \r
-               \r
-               Global.saveEditorButtonsVisible("undo", editorButtonsPage.showUndo());\r
-               Global.saveEditorButtonsVisible("redo", editorButtonsPage.showRedo());\r
-               Global.saveEditorButtonsVisible("cut", editorButtonsPage.showCut());\r
-               Global.saveEditorButtonsVisible("copy", editorButtonsPage.showCopy());\r
-               Global.saveEditorButtonsVisible("paste", editorButtonsPage.showPaste());\r
-               Global.saveEditorButtonsVisible("underline", editorButtonsPage.showUnderline());\r
-               Global.saveEditorButtonsVisible("strikethrough", editorButtonsPage.showStrikethrough());\r
-               Global.saveEditorButtonsVisible("italic", editorButtonsPage.showItalic());\r
-               Global.saveEditorButtonsVisible("bold", editorButtonsPage.showBold());\r
-               Global.saveEditorButtonsVisible("font", editorButtonsPage.showFont());\r
-               Global.saveEditorButtonsVisible("fontSize", editorButtonsPage.showFontSize());\r
-               Global.saveEditorButtonsVisible("fontColor", editorButtonsPage.showFontColor());\r
-               Global.saveEditorButtonsVisible("fontHilight", editorButtonsPage.showFontHilight());\r
-               Global.saveEditorButtonsVisible("indent", editorButtonsPage.showIndent());\r
-               Global.saveEditorButtonsVisible("outdent", editorButtonsPage.showOutdent());\r
-               Global.saveEditorButtonsVisible("numberList", editorButtonsPage.showNumberList());\r
-               Global.saveEditorButtonsVisible("bulletList", editorButtonsPage.showBulletList());\r
-               Global.saveEditorButtonsVisible("alignCenter", editorButtonsPage.showAlignCenter());\r
-               Global.saveEditorButtonsVisible("alignLeft", editorButtonsPage.showAlignLeft());\r
-               Global.saveEditorButtonsVisible("alignRight", editorButtonsPage.showAlignRight());\r
+               Global.setOverrideDefaultFont(fontPage.overrideFont());\r
+               Global.setDefaultFont(fontPage.getFont());\r
+               Global.setDefaultFontSize(fontPage.getFontSize());\r
+               Global.setDatabaseCache(debugPage.getDatabaseCacheSize());\r
+                               \r
                close();\r
        }\r
+       \r
+       \r
+       // Reject the current style\r
        @Override\r
        public void reject() {\r
                QApplication.setStyle(Global.getStyle());\r
                super.reject();\r
        }\r
        \r
+       //* return the debugging information page\r
        public ConfigDebugPage getDebugPage() {\r
                return debugPage;\r
        }\r
        \r
-       \r
+       // Get the Evernote connection page\r
        public ConfigConnectionPage getConfigPage() {\r
                return connectionPage;\r
        }\r
        \r
+       // Create icons used for navigating the page\r
        public void createIcons() {\r
                String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
 \r
@@ -224,24 +263,30 @@ public class ConfigDialog extends QDialog {
                formatsButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
                formatsButton.setIcon(new QIcon(iconPath+"appearance.jpg"));\r
                \r
+               QListWidgetItem fontButton = new QListWidgetItem(contentsWidget);\r
+               fontButton.setText(tr("Fonts"));\r
+               fontButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
+               fontButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
+               fontButton.setIcon(new QIcon(iconPath+"fontConfig.png"));\r
+               \r
                QListWidgetItem indexButton = new QListWidgetItem(contentsWidget);\r
                indexButton.setText(tr("Indexing"));\r
                indexButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
                indexButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
                indexButton.setIcon(new QIcon(iconPath+"search_config.jpg"));\r
 \r
+               QListWidgetItem spellButton = new QListWidgetItem(contentsWidget);\r
+               spellButton.setText(tr("Spell Check"));\r
+               spellButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
+               spellButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
+               spellButton.setIcon(new QIcon(iconPath+"dictionary.png"));\r
+\r
                QListWidgetItem configButton = new QListWidgetItem(contentsWidget);\r
                configButton.setText(tr("Connection"));\r
                configButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
                configButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
                configButton.setIcon(new QIcon(iconPath+"synchronize.png"));\r
 \r
-               QListWidgetItem editorButton = new QListWidgetItem(contentsWidget);\r
-               editorButton.setText(tr("Hide Edit Buttons"));\r
-               editorButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
-               editorButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
-               editorButton.setIcon(new QIcon(iconPath+"scissors.jpg"));\r
-\r
                QListWidgetItem debugButton = new QListWidgetItem(contentsWidget);\r
                debugButton.setText(tr("Debugging"));\r
                debugButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
@@ -251,15 +296,18 @@ public class ConfigDialog extends QDialog {
                contentsWidget.currentItemChanged.connect(this, "changePage(QListWidgetItem, QListWidgetItem)");\r
        }\r
        \r
+       // this is called when the user switches config pages\r
        protected void changePage(QListWidgetItem current, QListWidgetItem previous) {\r
                pagesWidget.setCurrentIndex(contentsWidget.row(current));\r
        }\r
        \r
+       // Load initial settings\r
        private void loadSettings() {\r
                Global.originalPalette = QApplication.palette();\r
                \r
                debugPage.setServer(Global.getServer());\r
                debugPage.setDisableUploads(Global.disableUploads);\r
+               debugPage.setEnableThumbnails(Global.enableThumbnails());\r
 //             if (Global.getUpdateSequenceNumber() > 0)\r
                        debugPage.serverCombo.setEnabled(false);\r
                \r
@@ -287,45 +335,28 @@ public class ConfigDialog extends QDialog {
                connectionPage.setSynchronizeOnClose(Global.synchronizeOnClose());\r
                connectionPage.setSyncronizeDeletedContent(Global.synchronizeDeletedContent());\r
                appearancePage.setVerifyDelete(Global.verifyDelete());\r
+               appearancePage.setStartMinimized(Global.startMinimized());\r
                appearancePage.setPdfPreview(Global.pdfPreview());\r
+               appearancePage.setCheckForUpdates(Global.checkVersionUpgrade());\r
                appearancePage.setNewNoteWithTags(Global.newNoteWithSelectedTags());\r
+               appearancePage.setAnyTagSelection(Global.anyTagSelectionMatch());\r
                appearancePage.setShowSplashScreen(Global.isWindowVisible("SplashScreen"));\r
                appearancePage.setTagBehavior(Global.tagBehavior());\r
+               appearancePage.setMinimizeOnClose(Global.minimizeOnClose());\r
+               appearancePage.setIncludeTagChildren(Global.includeTagChildren());\r
                \r
                indexPage.setRegex(Global.getWordRegex());\r
-               indexPage.setWordLength(Global.getMinimumWordLength());\r
-               indexPage.setIndexThreads(Global.getIndexThreads());\r
+               indexPage.setSleepInterval(Global.getIndexThreadSleepInterval());\r
                connectionPage.setSyncInterval(Global.getSyncInterval());\r
                \r
                appearancePage.setDateFormat(Global.getDateFormat());\r
                appearancePage.setTimeFormat(Global.getTimeFormat());\r
                appearancePage.setStyle(Global.getStyle());\r
                appearancePage.setStandardPalette(Global.useStandardPalette());\r
-                               \r
-               editorButtonsPage.setUndo(Global.isEditorButtonVisible("undo"));\r
-               editorButtonsPage.setRedo(Global.isEditorButtonVisible("redo"));\r
-               editorButtonsPage.setCut(Global.isEditorButtonVisible("cut"));\r
-               editorButtonsPage.setCopy(Global.isEditorButtonVisible("copy"));\r
-               editorButtonsPage.setPaste(Global.isEditorButtonVisible("paste"));\r
-               editorButtonsPage.setBold(Global.isEditorButtonVisible("bold"));\r
-               editorButtonsPage.setItalic(Global.isEditorButtonVisible("italic"));\r
-               editorButtonsPage.setUnderline(Global.isEditorButtonVisible("underline"));\r
-               editorButtonsPage.setStrikethrough(Global.isEditorButtonVisible("strikethrough"));\r
-               editorButtonsPage.setIndent(Global.isEditorButtonVisible("indent"));\r
-               editorButtonsPage.setHline(Global.isEditorButtonVisible("hline"));\r
-               editorButtonsPage.setOutdent(Global.isEditorButtonVisible("outdent"));\r
-               editorButtonsPage.setBulletList(Global.isEditorButtonVisible("bulletList"));\r
-               editorButtonsPage.setNumberList(Global.isEditorButtonVisible("numberList"));\r
-               editorButtonsPage.setFont(Global.isEditorButtonVisible("font"));\r
-               editorButtonsPage.setFontSize(Global.isEditorButtonVisible("fontSize"));\r
-               editorButtonsPage.setFontColor(Global.isEditorButtonVisible("fontColor"));\r
-               editorButtonsPage.setFontHighlight(Global.isEditorButtonVisible("fontHilight"));\r
-               editorButtonsPage.setAlignLeft(Global.isEditorButtonVisible("alignLeft"));\r
-               editorButtonsPage.setAlignCenter(Global.isEditorButtonVisible("alignCenter"));\r
-               editorButtonsPage.setAlignRight(Global.isEditorButtonVisible("alignRight"));\r
-               \r
+                                               \r
                debugPage.setDebugLevel(Global.getMessageLevel());\r
                debugPage.setCarriageReturnFix(Global.enableCarriageReturnFix());\r
+               debugPage.setHtmlEntitiesFix(Global.enableHTMLEntitiesFix);\r
                \r
        }\r
        \r