OSDN Git Service

ツールバーの「新規」ボタンを押した時にノートを新しいタブで開けるように変更した
authoryuki <kimaira7@gmail.com>
Mon, 28 Oct 2013 09:19:17 +0000 (18:19 +0900)
committeryuki <kimaira7@gmail.com>
Mon, 28 Oct 2013 09:19:17 +0000 (18:19 +0900)
src/cx/fbn/nevernote/Global.java
src/cx/fbn/nevernote/NeverNote.java
src/cx/fbn/nevernote/dialog/ConfigAppearancePage.java
src/cx/fbn/nevernote/dialog/ConfigDialog.java
src/cx/fbn/nevernote/gui/BrowserWindow.java

index 1a557c3..0b04922 100644 (file)
@@ -2599,5 +2599,27 @@ public class Global {
                settings.setValue("customENRelatedNotesWeight", weight);
                settings.endGroup();
        }
+
+       // ツールバーの「新規」ボタンを押した時、新規ノートをタブで開くかどうか
+       public static boolean toolBarNewAction() {
+               settings.beginGroup("General");
+               try {
+                       String text = (String)settings.value("toolBarNewAction", "true");
+                       settings.endGroup();
+                       if (text.equalsIgnoreCase("true"))
+                               return true;
+                       else
+                               return false;
+               } catch (java.lang.ClassCastException e) {
+                       Boolean value = (Boolean) settings.value("toolBarNewAction", true);
+                       settings.endGroup();
+                       return value;
+               }
+       }
+       public static void setToolBarNewAction(boolean value) {
+               settings.beginGroup("General");
+               settings.setValue("toolBarNewAction", value);
+               settings.endGroup();    
+       }
 }
 
index 022276a..7728f11 100644 (file)
@@ -3263,7 +3263,12 @@ public class NeverNote extends QMainWindow{
 
        newButton = toolBar.addAction(tr("New"));
        QIcon newIcon = new QIcon(iconPath+"new.png");
-       newButton.triggered.connect(this, "addNote()");
+       if (Global.toolBarNewAction()) {
+               newButton.triggered.connect(this, "noteAddNewTab()");
+       } else {
+               newButton.triggered.connect(this, "addNote()");
+       }
+
        newButton.setIcon(newIcon);
        toggleNewButton(Global.isToolbarButtonVisible("new"));
        
@@ -7722,4 +7727,10 @@ public class NeverNote extends QMainWindow{
        private void informRateLimit(Integer rateLimitDuration) {
                QMessageBox.warning(this, tr("Rate limit reached"), tr("Rate limit reached.\nRetry your request in " + rateLimitDuration + " seconds."));
        }
+       
+       // ツールバーの「新規」ボタンの接続スロットを設定
+       public void connectNewButtonSlot(String slot) {
+               newButton.triggered.disconnect();
+               newButton.triggered.connect(this, slot);
+       }
 }
index 90b99a9..6437567 100644 (file)
@@ -57,6 +57,7 @@ public class ConfigAppearancePage extends QWidget {
        private final QCheckBox minimizeOnClose;\r
        private final QCheckBox includeTagChildren;\r
        private final QCheckBox displayRightToLeft;\r
+       private final QCheckBox toolBarNewAction;\r
        private final QComboBox startupNotebook;\r
        private final QSpinBox autoSaveInterval;\r
        \r
@@ -155,6 +156,7 @@ public class ConfigAppearancePage extends QWidget {
                anyTagSelection = new QCheckBox(tr("Display Notes Matching Any Selected Tags"));\r
                includeTagChildren = new QCheckBox(tr("Include Children In Tag Selection"));\r
                displayRightToLeft = new QCheckBox(tr("Display Notes Right-To-Left"));\r
+               toolBarNewAction = new QCheckBox(tr("Add Note in New Tab When Click Tool Bar New Button"));\r
                \r
                QHBoxLayout startupNotebookLayout = new QHBoxLayout();\r
                startupNotebook = new QComboBox();\r
@@ -193,6 +195,7 @@ public class ConfigAppearancePage extends QWidget {
                checkboxLayout.addWidget(includeTagChildren);\r
                checkboxLayout.addWidget(displayRightToLeft);\r
                checkboxLayout.addWidget(checkForUpdates);\r
+               checkboxLayout.addWidget(toolBarNewAction);\r
                checkboxLayout.addStretch(1);\r
 \r
                \r
@@ -350,6 +353,16 @@ public class ConfigAppearancePage extends QWidget {
        public boolean getCheckForUpdates() {\r
                return checkForUpdates.isChecked();\r
        }\r
+       \r
+       //*******************************************\r
+       //* tool bar new button action get/set\r
+       //*******************************************\r
+       public void setNewAction(boolean val) {\r
+               toolBarNewAction.setChecked(val);\r
+       }\r
+       public boolean getNewAction() {\r
+               return toolBarNewAction.isChecked();\r
+       }\r
 \r
        \r
        //********************************************\r
index 7a18037..db344b7 100644 (file)
@@ -148,6 +148,11 @@ public class ConfigDialog extends QDialog {
                        Global.setCheckVersionUpgrade(true);\r
                else\r
                        Global.setCheckVersionUpgrade(false);\r
+               \r
+               if (appearancePage.getNewAction())\r
+                       Global.setToolBarNewAction(true);\r
+               else\r
+                       Global.setToolBarNewAction(false);\r
 \r
                \r
                if (appearancePage.getNewNoteWithTags())\r
@@ -265,6 +270,13 @@ public class ConfigDialog extends QDialog {
                Global.rebuildFullTextNoteTarget(conn);\r
                Global.rebuildFullTextResourceTarget(conn);\r
                \r
+               // ツールバーの「新規」ボタンを押した時の動作を再設定\r
+       if (Global.toolBarNewAction()) {\r
+               parent.connectNewButtonSlot("noteAddNewTab()");\r
+       } else {\r
+               parent.connectNewButtonSlot("addNote()");\r
+       }\r
+               \r
                close();\r
        }\r
        \r
@@ -370,6 +382,7 @@ public class ConfigDialog extends QDialog {
                appearancePage.setIncludeTagChildren(Global.includeTagChildren());\r
                appearancePage.setDisplayRightToLeft(Global.displayRightToLeft());\r
                appearancePage.setStartupNotebook(Global.getStartupNotebook());\r
+               appearancePage.setNewAction(Global.toolBarNewAction());\r
                \r
 //             indexPage.setRegex(Global.getWordRegex());\r
                indexPage.setSleepInterval(Global.getIndexThreadSleepInterval());\r
index 4b4a3fb..2434e5d 100644 (file)
@@ -1858,6 +1858,10 @@ public class BrowserWindow extends QWidget {
                if (tagEdit.text().equalsIgnoreCase(saveTagList))
                        return;
 
+               if (saveTagList == null) {
+                       return;
+               }
+               
                // We know something has changed...
                String oldTagArray[] = saveTagList.split(Global.tagDelimeter);
                String newTagArray[];