OSDN Git Service

設定ページからEvernote関連ノートリスト統合機能の重み付けを変更できるように変更。設定完了後に連想ノートをリフレッシュするように変更。
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / dialog / ConfigDialog.java
1 /*\r
2  * This file is part of NixNote/NeighborNote \r
3  * Copyright 2009 Randy Baumgarte\r
4  * Copyright 2013 Yuki Takahashi\r
5  * \r
6  * This file may be licensed under the terms of of the\r
7  * GNU General Public License Version 2 (the ``GPL'').\r
8  *\r
9  * Software distributed under the License is distributed\r
10  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either\r
11  * express or implied. See the GPL for the specific language\r
12  * governing rights and limitations.\r
13  *\r
14  * You should have received a copy of the GPL along with this\r
15  * program. If not, go to http://www.gnu.org/licenses/gpl.html\r
16  * or write to the Free Software Foundation, Inc.,\r
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
18  *\r
19 */\r
20 \r
21 //**********************************************\r
22 //**********************************************\r
23 //* This dialog is the debugging information \r
24 //* page used in the Edit/Preferences dialog\r
25 //**********************************************\r
26 //**********************************************\r
27 \r
28 package cx.fbn.nevernote.dialog;\r
29 \r
30 import com.swabunga.spell.engine.Configuration;\r
31 import com.trolltech.qt.core.QSize;\r
32 import com.trolltech.qt.core.Qt.AlignmentFlag;\r
33 import com.trolltech.qt.core.Qt.ItemFlag;\r
34 import com.trolltech.qt.gui.QApplication;\r
35 import com.trolltech.qt.gui.QDialog;\r
36 import com.trolltech.qt.gui.QHBoxLayout;\r
37 import com.trolltech.qt.gui.QIcon;\r
38 import com.trolltech.qt.gui.QListView;\r
39 import com.trolltech.qt.gui.QListWidget;\r
40 import com.trolltech.qt.gui.QListWidgetItem;\r
41 import com.trolltech.qt.gui.QPushButton;\r
42 import com.trolltech.qt.gui.QStackedWidget;\r
43 import com.trolltech.qt.gui.QVBoxLayout;\r
44 \r
45 import cx.fbn.nevernote.Global;\r
46 import cx.fbn.nevernote.NeverNote;\r
47 public class ConfigDialog extends QDialog {\r
48         private final QListWidget                               contentsWidget;\r
49         private final ConfigFontPage                    fontPage;\r
50         private final QStackedWidget                    pagesWidget;\r
51         private final ConfigConnectionPage              connectionPage;\r
52         private final ConfigDebugPage                   debugPage;\r
53         private final ConfigAppearancePage              appearancePage;\r
54         private final ConfigSpellPage                   spellPage;\r
55         private final ConfigIndexPage                   indexPage;\r
56         private final ConfigRensoNoteListPage   rensoNoteListPage;\r
57         private final NeverNote                                 parent;\r
58         \r
59     private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
60         \r
61         public ConfigDialog(NeverNote parent) {\r
62                 this.parent = parent;\r
63                 \r
64                 contentsWidget = new QListWidget(this);\r
65                 setWindowIcon(new QIcon(iconPath+"config.png"));\r
66                 contentsWidget.setViewMode(QListView.ViewMode.IconMode);\r
67                 contentsWidget.setIconSize(new QSize(96, 84));\r
68                 contentsWidget.setMovement(QListView.Movement.Static);\r
69                 contentsWidget.setMaximumWidth(128);\r
70                 contentsWidget.setSpacing(12);\r
71                 \r
72                 pagesWidget = new QStackedWidget(this);\r
73                 fontPage = new ConfigFontPage(this);\r
74                 connectionPage = new ConfigConnectionPage(this);\r
75                 appearancePage = new ConfigAppearancePage(this);\r
76                 indexPage = new ConfigIndexPage(this);\r
77                 debugPage = new ConfigDebugPage(this);\r
78                 spellPage = new ConfigSpellPage(this);\r
79                 // ICHANGED\r
80                 rensoNoteListPage = new ConfigRensoNoteListPage(this);\r
81                 \r
82                 pagesWidget.addWidget(appearancePage);\r
83                 pagesWidget.addWidget(fontPage);\r
84                 pagesWidget.addWidget(indexPage);\r
85                 pagesWidget.addWidget(spellPage);\r
86                 pagesWidget.addWidget(connectionPage);\r
87                 pagesWidget.addWidget(debugPage);\r
88                 // ICHANGED\r
89                 pagesWidget.addWidget(rensoNoteListPage);\r
90                 \r
91                 QPushButton cancelButton = new QPushButton(tr("Cancel"));\r
92                 QPushButton okButton = new QPushButton(tr("OK"));\r
93                 okButton.clicked.connect(this, "okPushed()");\r
94                 cancelButton.clicked.connect(this, "close()");\r
95                 \r
96                 createIcons();\r
97                 contentsWidget.setCurrentRow(0);\r
98                 \r
99                 QHBoxLayout horizontalLayout = new QHBoxLayout();\r
100                 horizontalLayout.addWidget(contentsWidget);\r
101                 horizontalLayout.addWidget(pagesWidget,1);\r
102                 \r
103                 QHBoxLayout buttonLayout = new QHBoxLayout();\r
104                 buttonLayout.addStretch(1);\r
105                 buttonLayout.addWidget(okButton);\r
106                 buttonLayout.addWidget(cancelButton);\r
107                 setWindowTitle(tr("Settings")); \r
108                 \r
109                 QVBoxLayout mainLayout = new QVBoxLayout();\r
110                 mainLayout.addLayout(horizontalLayout);\r
111                 mainLayout.addSpacing(1);\r
112                 mainLayout.addLayout(buttonLayout);\r
113                 setLayout(mainLayout);\r
114                 \r
115                 loadSettings();\r
116         }\r
117 \r
118         //******************************************\r
119         //* Ok button is pushed.  Save values\r
120         //******************************************\r
121         public void okPushed() {\r
122                 Global.setServer(debugPage.getServer());\r
123                 Global.setEnableThumbnails(debugPage.getEnableThumbnails());\r
124 \r
125                 \r
126                 if (debugPage.getDisableUploads())\r
127                         Global.disableUploads = true;\r
128                 else\r
129                         Global.disableUploads = false;\r
130                 Global.setDisableUploads(Global.disableUploads);\r
131                 Global.setMimicEvernoteInterface(appearancePage.getMimicEvernote());\r
132                 Global.setMinimizeOnClose(appearancePage.getMinimizeOnClose());\r
133                 \r
134                 if (appearancePage.getShowSplashScreen())\r
135                         Global.saveWindowVisible("SplashScreen", true);\r
136                 else\r
137                         Global.saveWindowVisible("SplashScreen", false);\r
138                         \r
139                 \r
140                 if (appearancePage.getPdfPreview())\r
141                         Global.setPdfPreview(true);\r
142                 else\r
143                         Global.setPdfPreview(false);\r
144 \r
145                 if (appearancePage.getCheckForUpdates())\r
146                         Global.setCheckVersionUpgrade(true);\r
147                 else\r
148                         Global.setCheckVersionUpgrade(false);\r
149 \r
150                 \r
151                 if (appearancePage.getNewNoteWithTags())\r
152                         Global.setNewNoteWithSelectedTags(true);\r
153                 else\r
154                         Global.setNewNoteWithSelectedTags(false);\r
155                 \r
156                 if (appearancePage.getAnyTagSelection())\r
157                         Global.setAnyTagSelectionMatch(true);\r
158                 else\r
159                         Global.setAnyTagSelectionMatch(false);\r
160                 \r
161                 Global.setAutoSaveInterval(appearancePage.getAutoSaveInterval());\r
162                                                 \r
163                 Global.setAutomaticLogin(connectionPage.getAutomaticLogin());\r
164                 Global.setProxyValue("url", connectionPage.getProxyUrl());\r
165                 Global.setProxyValue("port", connectionPage.getProxyPort());\r
166                 Global.setProxyValue("userid", connectionPage.getProxyUserid());\r
167                 Global.setProxyValue("password", connectionPage.getProxyPassword());\r
168                 \r
169                 Global.setShowTrayIcon(appearancePage.getShowTrayIcon());\r
170                 Global.setVerifyDelete(appearancePage.getVerifyDelete());\r
171                 Global.setStartMinimized(appearancePage.getStartMinimized());\r
172                 Global.setSynchronizeOnClose(connectionPage.getSynchronizeOnClose());\r
173                 Global.setSynchronizeDeletedContent(connectionPage.getSynchronizeDeletedContent());\r
174                 Global.setTagBehavior(appearancePage.getTagBehavior());\r
175                 Global.setIndexAttachmentsLocally(indexPage.getIndexAttachmentsLocally());\r
176                 Global.setIndexNoteBody(indexPage.getIndexNoteBody());\r
177                 Global.setIndexNoteTitle(indexPage.getIndexNoteTitle());\r
178                 Global.setIndexImageRecognition(indexPage.getIndexImageRecognition());\r
179                 Global.setAutomaticWildcardSearches(indexPage.getAutomaticWildcardSearches());\r
180                 Global.setSpecialIndexCharacters(indexPage.getSpecialCharacters());\r
181                 Global.setIncludeTagChildren(appearancePage.getIncludeTagChildren());\r
182                 Global.setDisplayRightToLeft(appearancePage.getDisplayRightToLeft());\r
183                 \r
184                 Global.userStoreUrl = "https://"+debugPage.getServer()+"/edam/user";\r
185                 Global.setWordRegex(indexPage.getRegex());\r
186                 Global.setRecognitionWeight(indexPage.getRecognitionWeight());\r
187                 Global.setIndexThreadSleepInterval(indexPage.getSleepInterval());\r
188                 Global.setMessageLevel( debugPage.getDebugLevel());\r
189                 Global.saveCarriageReturnFix(debugPage.getCarriageReturnFix());\r
190                 Global.enableCarriageReturnFix = debugPage.getCarriageReturnFix();\r
191                 Global.saveHtmlEntitiesFix(debugPage.getHtmlEntitiesFix());\r
192                 Global.enableHTMLEntitiesFix = debugPage.getHtmlEntitiesFix();\r
193                 \r
194                 Global.setSpellSetting(Configuration.SPELL_IGNOREDIGITWORDS, spellPage.getIgnoreDigitWords());\r
195                 Global.setSpellSetting(Configuration.SPELL_IGNOREINTERNETADDRESSES, spellPage.getIgnoreInternetAddresses());\r
196                 Global.setSpellSetting(Configuration.SPELL_IGNOREMIXEDCASE, spellPage.getIgnoreMixedCase());\r
197                 Global.setSpellSetting(Configuration.SPELL_IGNOREUPPERCASE, spellPage.getIgnoreUpperCase());\r
198                 Global.setSpellSetting(Configuration.SPELL_IGNORESENTENCECAPITALIZATION, spellPage.getIgnoreSentenceCapitalization());\r
199                 \r
200                 String guiFormat = appearancePage.getStyle();\r
201                 QApplication.setStyle(guiFormat);\r
202                 QApplication.style().standardPalette();\r
203                 Global.setStyle(guiFormat);\r
204                 Global.setStandardPalette(appearancePage.getStandardPalette());\r
205                 if (Global.useStandardPalette())\r
206                         QApplication.setPalette(QApplication.style().standardPalette());\r
207                 else\r
208                         QApplication.setPalette(Global.originalPalette);\r
209                 Global.setStartupNotebook(appearancePage.getStartupNotebook());\r
210                 \r
211                 String dateFmt = appearancePage.getDateFormat();\r
212                 String timeFmt = appearancePage.getTimeFormat();\r
213                 int dash = dateFmt.indexOf("-");\r
214                 dateFmt = dateFmt.substring(0,dash-1);\r
215                 dash = timeFmt.indexOf("-");\r
216                 timeFmt = timeFmt.substring(0,dash-1);\r
217                 \r
218                 Global.setDateFormat(dateFmt);\r
219                 Global.setTimeFormat(timeFmt);\r
220                 \r
221                 Global.setSyncInterval(connectionPage.getSyncInterval());\r
222                 \r
223                 Global.setOverrideDefaultFont(fontPage.overrideFont());\r
224                 Global.setDefaultFont(fontPage.getFont());\r
225                 Global.setDefaultFontSize(fontPage.getFontSize());\r
226                 Global.setDatabaseCache(debugPage.getDatabaseCacheSize());\r
227                 \r
228                 // ICHANGED\r
229                 Global.setBrowseWeight(rensoNoteListPage.getBrowseWeight());\r
230                 Global.setCopyPasteWeight(rensoNoteListPage.getCopyPasteWeight());\r
231                 Global.setAddNewNoteWeight(rensoNoteListPage.getAddNewNoteWeight());\r
232                 Global.setRensoItemClickWeight(rensoNoteListPage.getRensoItemClickWeight());
233                 Global.setSameTagWeight(rensoNoteListPage.getSameTagWeight());
234                 Global.setSameNotebookWeight(rensoNoteListPage.getSameNotebookWeight());\r
235                 Global.setENRelatedNotesWeight(rensoNoteListPage.getENRelatedNotesWeight());\r
236                 \r
237                 // ICHANGED\r
238                 Global.setMergeRensoNote(rensoNoteListPage.getMergeChecked());\r
239                 Global.setDuplicateRensoNote(rensoNoteListPage.getDuplicateChecked());\r
240                 Global.setVerifyExclude(rensoNoteListPage.getVerifyExcludeChecked());\r
241                 Global.setRensoListItemMaximum(rensoNoteListPage.getRensoListItemMaximum());\r
242                 \r
243                 // 連想ノートリストをリフレッシュ\r
244                 parent.getRensoNoteList().refreshRensoNoteList(parent.getCurrentNoteGuid());\r
245                 \r
246                 close();\r
247         }\r
248         \r
249         \r
250         // Reject the current style\r
251         @Override\r
252         public void reject() {\r
253                 QApplication.setStyle(Global.getStyle());\r
254                 super.reject();\r
255         }\r
256         \r
257         //* return the debugging information page\r
258         public ConfigDebugPage getDebugPage() {\r
259                 return debugPage;\r
260         }\r
261         \r
262         // Get the Evernote connection page\r
263         public ConfigConnectionPage getConfigPage() {\r
264                 return connectionPage;\r
265         }\r
266         \r
267         // Create icons used for navigating the page\r
268         public void createIcons() {\r
269                 String iconPath = new String("classpath:cx/fbn/nevernote/icons/");\r
270                 \r
271                 QListWidgetItem formatsButton = new QListWidgetItem(contentsWidget);\r
272                 formatsButton.setText(tr("Appearance"));\r
273                 formatsButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
274                 formatsButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
275                 formatsButton.setIcon(new QIcon(iconPath+"appearance.png"));\r
276                 \r
277                 QListWidgetItem fontButton = new QListWidgetItem(contentsWidget);\r
278                 fontButton.setText(tr("Fonts"));\r
279                 fontButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
280                 fontButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
281                 fontButton.setIcon(new QIcon(iconPath+"fontConfig.png"));\r
282                 \r
283                 QListWidgetItem indexButton = new QListWidgetItem(contentsWidget);\r
284                 indexButton.setText(tr("Indexing"));\r
285                 indexButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
286                 indexButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
287                 indexButton.setIcon(new QIcon(iconPath+"search_config.jpg"));\r
288 \r
289                 QListWidgetItem spellButton = new QListWidgetItem(contentsWidget);\r
290                 spellButton.setText(tr("Spell Check"));\r
291                 spellButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
292                 spellButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
293                 spellButton.setIcon(new QIcon(iconPath+"dictionary.png"));\r
294 \r
295                 QListWidgetItem configButton = new QListWidgetItem(contentsWidget);\r
296                 configButton.setText(tr("Connection"));\r
297                 configButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
298                 configButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
299                 configButton.setIcon(new QIcon(iconPath+"synchronize.png"));\r
300 \r
301                 QListWidgetItem debugButton = new QListWidgetItem(contentsWidget);\r
302                 debugButton.setText(tr("Debugging"));\r
303                 debugButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());\r
304                 debugButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
305                 debugButton.setIcon(new QIcon(iconPath+"debug.jpg"));\r
306                 \r
307                 // ICHANGED\r
308                 QListWidgetItem rensoListButton = new QListWidgetItem(contentsWidget);\r
309                 rensoListButton.setText(tr("Renso Note List"));\r
310                 rensoListButton.setTextAlignment(AlignmentFlag.AlignCenter.value());\r
311                 rensoListButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);\r
312                 rensoListButton.setIcon(new QIcon(iconPath+"rensoNoteList.png"));\r
313                 \r
314                 contentsWidget.currentItemChanged.connect(this, "changePage(QListWidgetItem, QListWidgetItem)");\r
315         }\r
316         \r
317         // this is called when the user switches config pages\r
318         protected void changePage(QListWidgetItem current, QListWidgetItem previous) {\r
319                 pagesWidget.setCurrentIndex(contentsWidget.row(current));\r
320         }\r
321         \r
322         // Load initial settings\r
323         private void loadSettings() {\r
324                 Global.originalPalette = QApplication.palette();\r
325                 \r
326                 debugPage.setServer(Global.getServer());\r
327                 debugPage.setDisableUploads(Global.disableUploads);\r
328                 debugPage.setEnableThumbnails(Global.enableThumbnails());\r
329 //              if (Global.getUpdateSequenceNumber() > 0)\r
330                 \r
331                 // ICHANGED\r
332                 // TODO ↓のコメントアウトは最終的に外す(設定のデバッグページのサーバー選択を使用不可にする)\r
333                 //      debugPage.serverCombo.setEnabled(false);\r
334 \r
335                 appearancePage.setAutoSaveInterval(Global.getAutoSaveInterval());\r
336                 connectionPage.setAutomaticLogin(Global.automaticLogin());\r
337                 appearancePage.setMimicEvernote(Global.getMimicEvernoteInterface());\r
338                 appearancePage.setShowTrayIcon(Global.showTrayIcon());\r
339                 connectionPage.setSynchronizeOnClose(Global.synchronizeOnClose());\r
340                 connectionPage.setSyncronizeDeletedContent(Global.synchronizeDeletedContent());\r
341                 appearancePage.setVerifyDelete(Global.verifyDelete());\r
342                 appearancePage.setStartMinimized(Global.startMinimized());\r
343                 appearancePage.setPdfPreview(Global.pdfPreview());\r
344                 appearancePage.setCheckForUpdates(Global.checkVersionUpgrade());\r
345                 appearancePage.setNewNoteWithTags(Global.newNoteWithSelectedTags());\r
346                 appearancePage.setAnyTagSelection(Global.anyTagSelectionMatch());\r
347                 appearancePage.setShowSplashScreen(Global.isWindowVisible("SplashScreen"));\r
348                 appearancePage.setTagBehavior(Global.tagBehavior());\r
349                 appearancePage.setMinimizeOnClose(Global.minimizeOnClose());\r
350                 appearancePage.setIncludeTagChildren(Global.includeTagChildren());\r
351                 appearancePage.setDisplayRightToLeft(Global.displayRightToLeft());\r
352                 appearancePage.setStartupNotebook(Global.getStartupNotebook());\r
353                 \r
354                 indexPage.setRegex(Global.getWordRegex());\r
355                 indexPage.setSleepInterval(Global.getIndexThreadSleepInterval());\r
356                 connectionPage.setSyncInterval(Global.getSyncInterval());\r
357                 \r
358                 appearancePage.setDateFormat(Global.getDateFormat());\r
359                 appearancePage.setTimeFormat(Global.getTimeFormat());\r
360                 appearancePage.setStyle(Global.getStyle());\r
361                 appearancePage.setStandardPalette(Global.useStandardPalette());\r
362                                                 \r
363                 debugPage.setDebugLevel(Global.getMessageLevel());\r
364                 debugPage.setCarriageReturnFix(Global.enableCarriageReturnFix());\r
365                 debugPage.setHtmlEntitiesFix(Global.enableHTMLEntitiesFix);\r
366                 \r
367         }\r
368         \r
369 }\r