2 * This file is part of NixNote/NeighborNote
\r
3 * Copyright 2009 Randy Baumgarte
\r
4 * Copyright 2013 Yuki Takahashi
\r
6 * This file may be licensed under the terms of of the
\r
7 * GNU General Public License Version 2 (the ``GPL'').
\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
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
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
28 package cx.fbn.nevernote.dialog;
\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 import com.trolltech.qt.gui.QWidget;
\r
46 import cx.fbn.nevernote.Global;
\r
47 import cx.fbn.nevernote.sql.DatabaseConnection;
\r
48 import cx.fbn.nevernote.sql.driver.NSqlQuery;
\r
49 public class ConfigDialog extends QDialog {
\r
50 private final QListWidget contentsWidget;
\r
51 private final ConfigFontPage fontPage;
\r
52 private final QStackedWidget pagesWidget;
\r
53 private final ConfigConnectionPage connectionPage;
\r
54 private final ConfigDebugPage debugPage;
\r
55 private final ConfigAppearancePage appearancePage;
\r
56 private final ConfigSpellPage spellPage;
\r
57 private final ConfigIndexPage indexPage;
\r
59 private final ConfigRensoNoteListPage rensoNoteListPage;
\r
60 private final DatabaseConnection conn;
\r
62 private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
\r
64 public ConfigDialog(QWidget parent, DatabaseConnection conn) {
\r
67 contentsWidget = new QListWidget(this);
\r
68 setWindowIcon(new QIcon(iconPath+"config.png"));
\r
69 contentsWidget.setViewMode(QListView.ViewMode.IconMode);
\r
70 contentsWidget.setIconSize(new QSize(96, 84));
\r
71 contentsWidget.setMovement(QListView.Movement.Static);
\r
72 contentsWidget.setMaximumWidth(128);
\r
73 contentsWidget.setSpacing(12);
\r
75 pagesWidget = new QStackedWidget(this);
\r
76 fontPage = new ConfigFontPage(this);
\r
77 connectionPage = new ConfigConnectionPage(this);
\r
78 appearancePage = new ConfigAppearancePage(this);
\r
79 indexPage = new ConfigIndexPage(this);
\r
80 debugPage = new ConfigDebugPage(this);
\r
81 spellPage = new ConfigSpellPage(this);
\r
83 rensoNoteListPage = new ConfigRensoNoteListPage(this);
\r
85 pagesWidget.addWidget(appearancePage);
\r
86 pagesWidget.addWidget(fontPage);
\r
87 pagesWidget.addWidget(indexPage);
\r
88 pagesWidget.addWidget(spellPage);
\r
89 pagesWidget.addWidget(connectionPage);
\r
90 pagesWidget.addWidget(debugPage);
\r
92 pagesWidget.addWidget(rensoNoteListPage);
\r
94 QPushButton cancelButton = new QPushButton(tr("Cancel"));
\r
95 QPushButton okButton = new QPushButton(tr("OK"));
\r
96 okButton.clicked.connect(this, "okPushed()");
\r
97 cancelButton.clicked.connect(this, "close()");
\r
100 contentsWidget.setCurrentRow(0);
\r
102 QHBoxLayout horizontalLayout = new QHBoxLayout();
\r
103 horizontalLayout.addWidget(contentsWidget);
\r
104 horizontalLayout.addWidget(pagesWidget,1);
\r
106 QHBoxLayout buttonLayout = new QHBoxLayout();
\r
107 buttonLayout.addStretch(1);
\r
108 buttonLayout.addWidget(okButton);
\r
109 buttonLayout.addWidget(cancelButton);
\r
110 setWindowTitle(tr("Settings"));
\r
112 QVBoxLayout mainLayout = new QVBoxLayout();
\r
113 mainLayout.addLayout(horizontalLayout);
\r
114 mainLayout.addSpacing(1);
\r
115 mainLayout.addLayout(buttonLayout);
\r
116 setLayout(mainLayout);
\r
121 //******************************************
\r
122 //* Ok button is pushed. Save values
\r
123 //******************************************
\r
124 public void okPushed() {
\r
125 Global.setServer(debugPage.getServer());
\r
126 Global.setEnableThumbnails(debugPage.getEnableThumbnails());
\r
129 if (debugPage.getDisableUploads())
\r
130 Global.disableUploads = true;
\r
132 Global.disableUploads = false;
\r
133 Global.setDisableUploads(Global.disableUploads);
\r
134 Global.setMimicEvernoteInterface(appearancePage.getMimicEvernote());
\r
135 Global.setMinimizeOnClose(appearancePage.getMinimizeOnClose());
\r
137 if (appearancePage.getShowSplashScreen())
\r
138 Global.saveWindowVisible("SplashScreen", true);
\r
140 Global.saveWindowVisible("SplashScreen", false);
\r
143 if (appearancePage.getPdfPreview())
\r
144 Global.setPdfPreview(true);
\r
146 Global.setPdfPreview(false);
\r
148 if (appearancePage.getCheckForUpdates())
\r
149 Global.setCheckVersionUpgrade(true);
\r
151 Global.setCheckVersionUpgrade(false);
\r
154 if (appearancePage.getNewNoteWithTags())
\r
155 Global.setNewNoteWithSelectedTags(true);
\r
157 Global.setNewNoteWithSelectedTags(false);
\r
159 if (appearancePage.getAnyTagSelection())
\r
160 Global.setAnyTagSelectionMatch(true);
\r
162 Global.setAnyTagSelectionMatch(false);
\r
164 Global.setAutoSaveInterval(appearancePage.getAutoSaveInterval());
\r
166 Global.setAutomaticLogin(connectionPage.getAutomaticLogin());
\r
167 Global.setProxyValue("url", connectionPage.getProxyUrl());
\r
168 Global.setProxyValue("port", connectionPage.getProxyPort());
\r
169 Global.setProxyValue("userid", connectionPage.getProxyUserid());
\r
170 Global.setProxyValue("password", connectionPage.getProxyPassword());
\r
172 Global.setShowTrayIcon(appearancePage.getShowTrayIcon());
\r
173 Global.setVerifyDelete(appearancePage.getVerifyDelete());
\r
174 Global.setStartMinimized(appearancePage.getStartMinimized());
\r
175 Global.setSynchronizeOnClose(connectionPage.getSynchronizeOnClose());
\r
176 Global.setSynchronizeDeletedContent(connectionPage.getSynchronizeDeletedContent());
\r
177 Global.setTagBehavior(appearancePage.getTagBehavior());
\r
178 Global.setIndexAttachmentsLocally(indexPage.getIndexAttachmentsLocally());
\r
179 Global.setIndexNoteBody(indexPage.getIndexNoteBody());
\r
180 Global.setIndexNoteTitle(indexPage.getIndexNoteTitle());
\r
181 Global.setIndexImageRecognition(indexPage.getIndexImageRecognition());
\r
182 // Global.setAutomaticWildcardSearches(indexPage.getAutomaticWildcardSearches());
\r
183 Global.setSpecialIndexCharacters(indexPage.getSpecialCharacters());
\r
184 Global.setIncludeTagChildren(appearancePage.getIncludeTagChildren());
\r
185 Global.setDisplayRightToLeft(appearancePage.getDisplayRightToLeft());
\r
187 Global.userStoreUrl = "https://"+debugPage.getServer()+"/edam/user";
\r
188 Global.setWordRegex(indexPage.getRegex());
\r
189 Global.setRecognitionWeight(indexPage.getRecognitionWeight());
\r
190 Global.setIndexThreadSleepInterval(indexPage.getSleepInterval());
\r
191 Global.setMessageLevel( debugPage.getDebugLevel());
\r
192 Global.saveCarriageReturnFix(debugPage.getCarriageReturnFix());
\r
193 Global.enableCarriageReturnFix = debugPage.getCarriageReturnFix();
\r
194 Global.saveHtmlEntitiesFix(debugPage.getHtmlEntitiesFix());
\r
195 Global.enableHTMLEntitiesFix = debugPage.getHtmlEntitiesFix();
\r
197 Global.setSpellSetting(Configuration.SPELL_IGNOREDIGITWORDS, spellPage.getIgnoreDigitWords());
\r
198 Global.setSpellSetting(Configuration.SPELL_IGNOREINTERNETADDRESSES, spellPage.getIgnoreInternetAddresses());
\r
199 Global.setSpellSetting(Configuration.SPELL_IGNOREMIXEDCASE, spellPage.getIgnoreMixedCase());
\r
200 Global.setSpellSetting(Configuration.SPELL_IGNOREUPPERCASE, spellPage.getIgnoreUpperCase());
\r
201 Global.setSpellSetting(Configuration.SPELL_IGNORESENTENCECAPITALIZATION, spellPage.getIgnoreSentenceCapitalization());
\r
203 String guiFormat = appearancePage.getStyle();
\r
204 QApplication.setStyle(guiFormat);
\r
205 QApplication.style().standardPalette();
\r
206 Global.setStyle(guiFormat);
\r
207 Global.setStandardPalette(appearancePage.getStandardPalette());
\r
208 if (Global.useStandardPalette())
\r
209 QApplication.setPalette(QApplication.style().standardPalette());
\r
211 QApplication.setPalette(Global.originalPalette);
\r
212 Global.setStartupNotebook(appearancePage.getStartupNotebook());
\r
214 String dateFmt = appearancePage.getDateFormat();
\r
215 String timeFmt = appearancePage.getTimeFormat();
\r
216 int dash = dateFmt.indexOf("-");
\r
217 dateFmt = dateFmt.substring(0,dash-1);
\r
218 dash = timeFmt.indexOf("-");
\r
219 timeFmt = timeFmt.substring(0,dash-1);
\r
221 Global.setDateFormat(dateFmt);
\r
222 Global.setTimeFormat(timeFmt);
\r
224 Global.setSyncInterval(connectionPage.getSyncInterval());
\r
226 Global.setOverrideDefaultFont(fontPage.overrideFont());
\r
227 Global.setDefaultFont(fontPage.getFont());
\r
228 Global.setDefaultFontSize(fontPage.getFontSize());
\r
229 Global.setDatabaseCache(debugPage.getDatabaseCacheSize());
\r
232 Global.setBrowseWeight(rensoNoteListPage.getBrowseWeight());
\r
233 Global.setCopyPasteWeight(rensoNoteListPage.getCopyPasteWeight());
\r
234 Global.setAddNewNoteWeight(rensoNoteListPage.getAddNewNoteWeight());
\r
235 Global.setRensoItemClickWeight(rensoNoteListPage.getRensoItemClickWeight());
236 Global.setSameTagWeight(rensoNoteListPage.getSameTagWeight());
237 Global.setSameNotebookWeight(rensoNoteListPage.getSameNotebookWeight());
\r
240 Global.setMergeRensoNote(rensoNoteListPage.getMergeChecked());
\r
241 Global.setDuplicateRensoNote(rensoNoteListPage.getDuplicateChecked());
\r
242 Global.setVerifyExclude(rensoNoteListPage.getVerifyExcludeChecked());
\r
243 Global.setRensoListItemMaximum(rensoNoteListPage.getRensoListItemMaximum());
\r
246 NSqlQuery query = new NSqlQuery(conn.getConnection());
\r
247 query.exec("CALL FTL_DROP_ALL();"); // カラム単位で削除できないので一度全部消して、再構築
\r
248 Global.rebuildFullTextTarget(query);
\r
254 // Reject the current style
\r
256 public void reject() {
\r
257 QApplication.setStyle(Global.getStyle());
\r
261 //* return the debugging information page
\r
262 public ConfigDebugPage getDebugPage() {
\r
266 // Get the Evernote connection page
\r
267 public ConfigConnectionPage getConfigPage() {
\r
268 return connectionPage;
\r
271 // Create icons used for navigating the page
\r
272 public void createIcons() {
\r
273 String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
\r
276 QListWidgetItem formatsButton = new QListWidgetItem(contentsWidget);
\r
277 formatsButton.setText(tr("Appearance"));
\r
278 formatsButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
279 formatsButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
280 formatsButton.setIcon(new QIcon(iconPath+"appearance.png"));
\r
282 QListWidgetItem fontButton = new QListWidgetItem(contentsWidget);
\r
283 fontButton.setText(tr("Fonts"));
\r
284 fontButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
285 fontButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
286 fontButton.setIcon(new QIcon(iconPath+"fontConfig.png"));
\r
288 QListWidgetItem indexButton = new QListWidgetItem(contentsWidget);
\r
289 indexButton.setText(tr("Indexing"));
\r
290 indexButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
291 indexButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
292 indexButton.setIcon(new QIcon(iconPath+"search_config.jpg"));
\r
294 QListWidgetItem spellButton = new QListWidgetItem(contentsWidget);
\r
295 spellButton.setText(tr("Spell Check"));
\r
296 spellButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
297 spellButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
298 spellButton.setIcon(new QIcon(iconPath+"dictionary.png"));
\r
300 QListWidgetItem configButton = new QListWidgetItem(contentsWidget);
\r
301 configButton.setText(tr("Connection"));
\r
302 configButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
303 configButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
304 configButton.setIcon(new QIcon(iconPath+"synchronize.png"));
\r
306 QListWidgetItem debugButton = new QListWidgetItem(contentsWidget);
\r
307 debugButton.setText(tr("Debugging"));
\r
308 debugButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
309 debugButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
310 debugButton.setIcon(new QIcon(iconPath+"debug.jpg"));
\r
313 QListWidgetItem rensoListButton = new QListWidgetItem(contentsWidget);
\r
314 rensoListButton.setText(tr("Renso Note List"));
\r
315 rensoListButton.setTextAlignment(AlignmentFlag.AlignCenter.value());
\r
316 rensoListButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
317 rensoListButton.setIcon(new QIcon(iconPath+"rensoNoteList.png"));
\r
319 contentsWidget.currentItemChanged.connect(this, "changePage(QListWidgetItem, QListWidgetItem)");
\r
322 // this is called when the user switches config pages
\r
323 protected void changePage(QListWidgetItem current, QListWidgetItem previous) {
\r
324 pagesWidget.setCurrentIndex(contentsWidget.row(current));
\r
327 // Load initial settings
\r
328 private void loadSettings() {
\r
329 Global.originalPalette = QApplication.palette();
\r
331 debugPage.setServer(Global.getServer());
\r
332 debugPage.setDisableUploads(Global.disableUploads);
\r
333 debugPage.setEnableThumbnails(Global.enableThumbnails());
\r
334 // if (Global.getUpdateSequenceNumber() > 0)
\r
337 // TODO ↓のコメントアウトは最終的に外す(設定のデバッグページのサーバー選択を使用不可にする)
\r
338 // debugPage.serverCombo.setEnabled(false);
\r
340 appearancePage.setAutoSaveInterval(Global.getAutoSaveInterval());
\r
341 connectionPage.setAutomaticLogin(Global.automaticLogin());
\r
342 appearancePage.setMimicEvernote(Global.getMimicEvernoteInterface());
\r
343 appearancePage.setShowTrayIcon(Global.showTrayIcon());
\r
344 connectionPage.setSynchronizeOnClose(Global.synchronizeOnClose());
\r
345 connectionPage.setSyncronizeDeletedContent(Global.synchronizeDeletedContent());
\r
346 appearancePage.setVerifyDelete(Global.verifyDelete());
\r
347 appearancePage.setStartMinimized(Global.startMinimized());
\r
348 appearancePage.setPdfPreview(Global.pdfPreview());
\r
349 appearancePage.setCheckForUpdates(Global.checkVersionUpgrade());
\r
350 appearancePage.setNewNoteWithTags(Global.newNoteWithSelectedTags());
\r
351 appearancePage.setAnyTagSelection(Global.anyTagSelectionMatch());
\r
352 appearancePage.setShowSplashScreen(Global.isWindowVisible("SplashScreen"));
\r
353 appearancePage.setTagBehavior(Global.tagBehavior());
\r
354 appearancePage.setMinimizeOnClose(Global.minimizeOnClose());
\r
355 appearancePage.setIncludeTagChildren(Global.includeTagChildren());
\r
356 appearancePage.setDisplayRightToLeft(Global.displayRightToLeft());
\r
357 appearancePage.setStartupNotebook(Global.getStartupNotebook());
\r
359 indexPage.setRegex(Global.getWordRegex());
\r
360 indexPage.setSleepInterval(Global.getIndexThreadSleepInterval());
\r
361 connectionPage.setSyncInterval(Global.getSyncInterval());
\r
363 appearancePage.setDateFormat(Global.getDateFormat());
\r
364 appearancePage.setTimeFormat(Global.getTimeFormat());
\r
365 appearancePage.setStyle(Global.getStyle());
\r
366 appearancePage.setStandardPalette(Global.useStandardPalette());
\r
368 debugPage.setDebugLevel(Global.getMessageLevel());
\r
369 debugPage.setCarriageReturnFix(Global.enableCarriageReturnFix());
\r
370 debugPage.setHtmlEntitiesFix(Global.enableHTMLEntitiesFix);
\r