OSDN Git Service

設定ページからEvernote関連ノートリスト統合機能の重み付けを変更できるように変更。設定完了後に連想ノートをリフレッシュするように変更。
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / Global.java
index 4d3fb6e..1a731e2 100644 (file)
@@ -23,6 +23,7 @@ package cx.fbn.nevernote;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
@@ -40,6 +41,7 @@ import com.evernote.edam.type.User;
 import com.evernote.edam.type.UserAttributes;
 import com.swabunga.spell.engine.Configuration;
 import com.trolltech.qt.core.QByteArray;
+import com.trolltech.qt.core.QFile;
 import com.trolltech.qt.core.QSettings;
 import com.trolltech.qt.core.QSize;
 import com.trolltech.qt.gui.QPalette;
@@ -65,8 +67,8 @@ import cx.fbn.nevernote.utilities.Pair;
 public class Global {
        // Set current version and the known versions.
        // ICHANGED 自分用に変更
-       public static String version = "0.1.1";
-       public static String[] validVersions = {"0.1.1", "0.1"};
+       public static String version = "0.1.3";
+       public static String[] validVersions = {"0.1.3", "0.1.2", "0.1.1", "0.1"};
        
     public static String username = ""; 
     //public static String password = "";     
@@ -196,8 +198,19 @@ public class Global {
        
     // Do initial setup 
     public static void setup(StartupConfig startupConfig) throws InitializationException  {
-       // ICHANGED 設定値の保存先を変更
-        settings = new QSettings("NeighborNote.ini", QSettings.Format.IniFormat);
+       String settingFileName = new String("NeighborNote.ini");
+       
+       // バージョン0.1.2以下で作成された古い設定ファイルを見つけたら、ホームディレクトリに移動させる。
+       String oldSettingPath = new QSettings(settingFileName, QSettings.Format.IniFormat).fileName();
+       File homeDir = new File(FileManager.toPlatformPathSeparator(startupConfig.getHomeDirPath()));
+       String homePath = FileManager.slashTerminatePath(homeDir.getPath());
+       if (QFile.exists(oldSettingPath)) {
+               QFile file = new QFile(oldSettingPath);
+               file.copy(homePath + settingFileName);
+               file.remove();
+       }
+       
+        settings = new QSettings(homePath + settingFileName, QSettings.Format.IniFormat);
         
         disableViewing = startupConfig.getDisableViewing();
         syncOnly = startupConfig.isSyncOnly();
@@ -1773,6 +1786,12 @@ public class Global {
                settings.endGroup();    
                return text;
     }
+    public static String getUpdateDownloadUrl() {
+               settings.beginGroup("Upgrade");
+               String text = (String)settings.value("downloadUrl", "http://puma.cis.ibaraki.ac.jp/products/neighbornote/download.html");
+               settings.endGroup();    
+               return text;
+    }
     
     //*******************
     // Index settings
@@ -2204,6 +2223,29 @@ public class Global {
                settings.endGroup();
                return value;
        }
+       
+       // Evernote関連ノート機能統合に対する重み付け
+       public static void setENRelatedNotesWeight(int weight) {
+               settings.beginGroup("RensoNoteList");
+               settings.setValue("enRelatedNotesWeight", weight);
+               settings.endGroup();
+       }
+       public static int getENRelatedNotesWeight() {
+               settings.beginGroup("RensoNoteList");
+               Integer value;
+               try {
+                       String val = (String)settings.value("enRelatedNotesWeight", 10);
+                       value = new Integer(val.trim());
+               } catch (Exception e) {
+                       try {
+                               value = (Integer)settings.value("enRelatedNotesWeight", 10);
+                       } catch (Exception e1) {
+                               value = 10;
+                       }
+               }
+               settings.endGroup();
+               return value;
+       }
     
     //*******************
     // ノートのマージ・複製の関連ノートリストへの適用