2 * This file is part of NixNote
\r
3 * Copyright 2009 Randy Baumgarte
\r
5 * This file may be licensed under the terms of of the
\r
6 * GNU General Public License Version 2 (the ``GPL'').
\r
8 * Software distributed under the License is distributed
\r
9 * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
\r
10 * express or implied. See the GPL for the specific language
\r
11 * governing rights and limitations.
\r
13 * You should have received a copy of the GPL along with this
\r
14 * program. If not, go to http://www.gnu.org/licenses/gpl.html
\r
15 * or write to the Free Software Foundation, Inc.,
\r
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
20 //**********************************************
\r
21 //**********************************************
\r
22 //* This dialog is the debugging information
\r
23 //* page used in the Edit/Preferences dialog
\r
24 //**********************************************
\r
25 //**********************************************
\r
27 package cx.fbn.nevernote.dialog;
\r
29 import com.swabunga.spell.engine.Configuration;
\r
30 import com.trolltech.qt.core.QSize;
\r
31 import com.trolltech.qt.core.Qt.AlignmentFlag;
\r
32 import com.trolltech.qt.core.Qt.ItemFlag;
\r
33 import com.trolltech.qt.gui.QApplication;
\r
34 import com.trolltech.qt.gui.QDialog;
\r
35 import com.trolltech.qt.gui.QHBoxLayout;
\r
36 import com.trolltech.qt.gui.QIcon;
\r
37 import com.trolltech.qt.gui.QListView;
\r
38 import com.trolltech.qt.gui.QListWidget;
\r
39 import com.trolltech.qt.gui.QListWidgetItem;
\r
40 import com.trolltech.qt.gui.QPushButton;
\r
41 import com.trolltech.qt.gui.QStackedWidget;
\r
42 import com.trolltech.qt.gui.QVBoxLayout;
\r
43 import com.trolltech.qt.gui.QWidget;
\r
45 import cx.fbn.nevernote.Global;
\r
46 public class ConfigDialog extends QDialog {
\r
47 private final QListWidget contentsWidget;
\r
48 private final ConfigFontPage fontPage;
\r
49 private final QStackedWidget pagesWidget;
\r
50 private final ConfigConnectionPage connectionPage;
\r
51 private final ConfigDebugPage debugPage;
\r
52 private final ConfigAppearancePage appearancePage;
\r
53 private final ConfigSpellPage spellPage;
\r
54 private final ConfigIndexPage indexPage;
\r
55 private final String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
\r
57 public ConfigDialog(QWidget parent) {
\r
59 contentsWidget = new QListWidget(this);
\r
60 setWindowIcon(new QIcon(iconPath+"config.png"));
\r
61 contentsWidget.setViewMode(QListView.ViewMode.IconMode);
\r
62 contentsWidget.setIconSize(new QSize(96, 84));
\r
63 contentsWidget.setMovement(QListView.Movement.Static);
\r
64 contentsWidget.setMaximumWidth(128);
\r
65 contentsWidget.setSpacing(12);
\r
67 pagesWidget = new QStackedWidget(this);
\r
68 fontPage = new ConfigFontPage(this);
\r
69 connectionPage = new ConfigConnectionPage(this);
\r
70 appearancePage = new ConfigAppearancePage(this);
\r
71 indexPage = new ConfigIndexPage(this);
\r
72 debugPage = new ConfigDebugPage(this);
\r
73 spellPage = new ConfigSpellPage(this);
\r
74 pagesWidget.addWidget(appearancePage);
\r
75 pagesWidget.addWidget(fontPage);
\r
76 pagesWidget.addWidget(indexPage);
\r
77 pagesWidget.addWidget(spellPage);
\r
78 pagesWidget.addWidget(connectionPage);
\r
79 pagesWidget.addWidget(debugPage);
\r
81 QPushButton cancelButton = new QPushButton(tr("Cancel"));
\r
82 QPushButton okButton = new QPushButton(tr("OK"));
\r
83 okButton.clicked.connect(this, "okPushed()");
\r
84 cancelButton.clicked.connect(this, "close()");
\r
87 contentsWidget.setCurrentRow(0);
\r
89 QHBoxLayout horizontalLayout = new QHBoxLayout();
\r
90 horizontalLayout.addWidget(contentsWidget);
\r
91 horizontalLayout.addWidget(pagesWidget,1);
\r
93 QHBoxLayout buttonLayout = new QHBoxLayout();
\r
94 buttonLayout.addStretch(1);
\r
95 buttonLayout.addWidget(okButton);
\r
96 buttonLayout.addWidget(cancelButton);
\r
97 setWindowTitle(tr("Settings"));
\r
99 QVBoxLayout mainLayout = new QVBoxLayout();
\r
100 mainLayout.addLayout(horizontalLayout);
\r
101 mainLayout.addSpacing(1);
\r
102 mainLayout.addLayout(buttonLayout);
\r
103 setLayout(mainLayout);
\r
108 //******************************************
\r
109 //* Ok button is pushed. Save values
\r
110 //******************************************
\r
111 public void okPushed() {
\r
112 Global.setServer(debugPage.getServer());
\r
113 Global.setEnableThumbnails(debugPage.getEnableThumbnails());
\r
116 if (debugPage.getDisableUploads())
\r
117 Global.disableUploads = true;
\r
119 Global.disableUploads = false;
\r
120 Global.setDisableUploads(Global.disableUploads);
\r
121 Global.setMimicEvernoteInterface(appearancePage.getMimicEvernote());
\r
122 Global.setMinimizeOnClose(appearancePage.getMinimizeOnClose());
\r
124 if (appearancePage.getShowSplashScreen())
\r
125 Global.saveWindowVisible("SplashScreen", true);
\r
127 Global.saveWindowVisible("SplashScreen", false);
\r
130 if (appearancePage.getPdfPreview())
\r
131 Global.setPdfPreview(true);
\r
133 Global.setPdfPreview(false);
\r
135 if (appearancePage.getCheckForUpdates())
\r
136 Global.setCheckVersionUpgrade(true);
\r
138 Global.setCheckVersionUpgrade(false);
\r
141 if (appearancePage.getNewNoteWithTags())
\r
142 Global.setNewNoteWithSelectedTags(true);
\r
144 Global.setNewNoteWithSelectedTags(false);
\r
146 if (appearancePage.getAnyTagSelection())
\r
147 Global.setAnyTagSelectionMatch(true);
\r
149 Global.setAnyTagSelectionMatch(false);
\r
151 Global.setAutoSaveInterval(appearancePage.getAutoSaveInterval());
\r
153 Global.setAutomaticLogin(connectionPage.getAutomaticLogin());
\r
154 Global.setProxyValue("url", connectionPage.getProxyUrl());
\r
155 Global.setProxyValue("port", connectionPage.getProxyPort());
\r
156 Global.setProxyValue("userid", connectionPage.getProxyUserid());
\r
157 Global.setProxyValue("password", connectionPage.getProxyPassword());
\r
159 Global.setShowTrayIcon(appearancePage.getShowTrayIcon());
\r
160 Global.setVerifyDelete(appearancePage.getVerifyDelete());
\r
161 Global.setStartMinimized(appearancePage.getStartMinimized());
\r
162 Global.setSynchronizeOnClose(connectionPage.getSynchronizeOnClose());
\r
163 Global.setSynchronizeDeletedContent(connectionPage.getSynchronizeDeletedContent());
\r
164 Global.setTagBehavior(appearancePage.getTagBehavior());
\r
165 Global.setIndexAttachmentsLocally(indexPage.getIndexAttachmentsLocally());
\r
166 Global.setIndexNoteBody(indexPage.getIndexNoteBody());
\r
167 Global.setIndexNoteTitle(indexPage.getIndexNoteTitle());
\r
168 Global.setIndexImageRecognition(indexPage.getIndexImageRecognition());
\r
169 Global.setAutomaticWildcardSearches(indexPage.getAutomaticWildcardSearches());
\r
170 Global.setSpecialIndexCharacters(indexPage.getSpecialCharacters());
\r
171 Global.setIncludeTagChildren(appearancePage.getIncludeTagChildren());
\r
172 Global.setDisplayRightToLeft(appearancePage.getDisplayRightToLeft());
\r
174 Global.userStoreUrl = "https://"+debugPage.getServer()+"/edam/user";
\r
175 Global.setWordRegex(indexPage.getRegex());
\r
176 Global.setRecognitionWeight(indexPage.getRecognitionWeight());
\r
177 Global.setIndexThreadSleepInterval(indexPage.getSleepInterval());
\r
178 Global.setMessageLevel( debugPage.getDebugLevel());
\r
179 Global.saveCarriageReturnFix(debugPage.getCarriageReturnFix());
\r
180 Global.enableCarriageReturnFix = debugPage.getCarriageReturnFix();
\r
181 Global.saveHtmlEntitiesFix(debugPage.getHtmlEntitiesFix());
\r
182 Global.enableHTMLEntitiesFix = debugPage.getHtmlEntitiesFix();
\r
184 Global.setSpellSetting(Configuration.SPELL_IGNOREDIGITWORDS, spellPage.getIgnoreDigitWords());
\r
185 Global.setSpellSetting(Configuration.SPELL_IGNOREINTERNETADDRESSES, spellPage.getIgnoreInternetAddresses());
\r
186 Global.setSpellSetting(Configuration.SPELL_IGNOREMIXEDCASE, spellPage.getIgnoreMixedCase());
\r
187 Global.setSpellSetting(Configuration.SPELL_IGNOREUPPERCASE, spellPage.getIgnoreUpperCase());
\r
188 Global.setSpellSetting(Configuration.SPELL_IGNORESENTENCECAPITALIZATION, spellPage.getIgnoreSentenceCapitalization());
\r
190 String guiFormat = appearancePage.getStyle();
\r
191 QApplication.setStyle(guiFormat);
\r
192 QApplication.style().standardPalette();
\r
193 Global.setStyle(guiFormat);
\r
194 Global.setStandardPalette(appearancePage.getStandardPalette());
\r
195 if (Global.useStandardPalette())
\r
196 QApplication.setPalette(QApplication.style().standardPalette());
\r
198 QApplication.setPalette(Global.originalPalette);
\r
199 Global.setStartupNotebook(appearancePage.getStartupNotebook());
\r
201 String dateFmt = appearancePage.getDateFormat();
\r
202 String timeFmt = appearancePage.getTimeFormat();
\r
203 int dash = dateFmt.indexOf("-");
\r
204 dateFmt = dateFmt.substring(0,dash-1);
\r
205 dash = timeFmt.indexOf("-");
\r
206 timeFmt = timeFmt.substring(0,dash-1);
\r
208 Global.setDateFormat(dateFmt);
\r
209 Global.setTimeFormat(timeFmt);
\r
211 Global.setSyncInterval(connectionPage.getSyncInterval());
\r
213 Global.setOverrideDefaultFont(fontPage.overrideFont());
\r
214 Global.setDefaultFont(fontPage.getFont());
\r
215 Global.setDefaultFontSize(fontPage.getFontSize());
\r
216 Global.setDatabaseCache(debugPage.getDatabaseCacheSize());
\r
222 // Reject the current style
\r
224 public void reject() {
\r
225 QApplication.setStyle(Global.getStyle());
\r
229 //* return the debugging information page
\r
230 public ConfigDebugPage getDebugPage() {
\r
234 // Get the Evernote connection page
\r
235 public ConfigConnectionPage getConfigPage() {
\r
236 return connectionPage;
\r
239 // Create icons used for navigating the page
\r
240 public void createIcons() {
\r
241 String iconPath = new String("classpath:cx/fbn/nevernote/icons/");
\r
244 QListWidgetItem formatsButton = new QListWidgetItem(contentsWidget);
\r
245 formatsButton.setText(tr("Appearance"));
\r
246 formatsButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
247 formatsButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
248 formatsButton.setIcon(new QIcon(iconPath+"appearance.jpg"));
\r
250 QListWidgetItem fontButton = new QListWidgetItem(contentsWidget);
\r
251 fontButton.setText(tr("Fonts"));
\r
252 fontButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
253 fontButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
254 fontButton.setIcon(new QIcon(iconPath+"fontConfig.png"));
\r
256 QListWidgetItem indexButton = new QListWidgetItem(contentsWidget);
\r
257 indexButton.setText(tr("Indexing"));
\r
258 indexButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
259 indexButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
260 indexButton.setIcon(new QIcon(iconPath+"search_config.jpg"));
\r
262 QListWidgetItem spellButton = new QListWidgetItem(contentsWidget);
\r
263 spellButton.setText(tr("Spell Check"));
\r
264 spellButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
265 spellButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
266 spellButton.setIcon(new QIcon(iconPath+"dictionary.png"));
\r
268 QListWidgetItem configButton = new QListWidgetItem(contentsWidget);
\r
269 configButton.setText(tr("Connection"));
\r
270 configButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
271 configButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
272 configButton.setIcon(new QIcon(iconPath+"synchronize.png"));
\r
274 QListWidgetItem debugButton = new QListWidgetItem(contentsWidget);
\r
275 debugButton.setText(tr("Debugging"));
\r
276 debugButton.setTextAlignment(AlignmentFlag.AlignHCenter.value());
\r
277 debugButton.setFlags(ItemFlag.ItemIsSelectable, ItemFlag.ItemIsEnabled);
\r
278 debugButton.setIcon(new QIcon(iconPath+"debug.jpg"));
\r
280 contentsWidget.currentItemChanged.connect(this, "changePage(QListWidgetItem, QListWidgetItem)");
\r
283 // this is called when the user switches config pages
\r
284 protected void changePage(QListWidgetItem current, QListWidgetItem previous) {
\r
285 pagesWidget.setCurrentIndex(contentsWidget.row(current));
\r
288 // Load initial settings
\r
289 private void loadSettings() {
\r
290 Global.originalPalette = QApplication.palette();
\r
292 debugPage.setServer(Global.getServer());
\r
293 debugPage.setDisableUploads(Global.disableUploads);
\r
294 debugPage.setEnableThumbnails(Global.enableThumbnails());
\r
295 // if (Global.getUpdateSequenceNumber() > 0)
\r
296 debugPage.serverCombo.setEnabled(false);
\r
298 appearancePage.setAutoSaveInterval(Global.getAutoSaveInterval());
\r
299 connectionPage.setAutomaticLogin(Global.automaticLogin());
\r
300 appearancePage.setMimicEvernote(Global.getMimicEvernoteInterface());
\r
301 appearancePage.setShowTrayIcon(Global.showTrayIcon());
\r
302 connectionPage.setSynchronizeOnClose(Global.synchronizeOnClose());
\r
303 connectionPage.setSyncronizeDeletedContent(Global.synchronizeDeletedContent());
\r
304 appearancePage.setVerifyDelete(Global.verifyDelete());
\r
305 appearancePage.setStartMinimized(Global.startMinimized());
\r
306 appearancePage.setPdfPreview(Global.pdfPreview());
\r
307 appearancePage.setCheckForUpdates(Global.checkVersionUpgrade());
\r
308 appearancePage.setNewNoteWithTags(Global.newNoteWithSelectedTags());
\r
309 appearancePage.setAnyTagSelection(Global.anyTagSelectionMatch());
\r
310 appearancePage.setShowSplashScreen(Global.isWindowVisible("SplashScreen"));
\r
311 appearancePage.setTagBehavior(Global.tagBehavior());
\r
312 appearancePage.setMinimizeOnClose(Global.minimizeOnClose());
\r
313 appearancePage.setIncludeTagChildren(Global.includeTagChildren());
\r
314 appearancePage.setDisplayRightToLeft(Global.displayRightToLeft());
\r
315 appearancePage.setStartupNotebook(Global.getStartupNotebook());
\r
317 indexPage.setRegex(Global.getWordRegex());
\r
318 indexPage.setSleepInterval(Global.getIndexThreadSleepInterval());
\r
319 connectionPage.setSyncInterval(Global.getSyncInterval());
\r
321 appearancePage.setDateFormat(Global.getDateFormat());
\r
322 appearancePage.setTimeFormat(Global.getTimeFormat());
\r
323 appearancePage.setStyle(Global.getStyle());
\r
324 appearancePage.setStandardPalette(Global.useStandardPalette());
\r
326 debugPage.setDebugLevel(Global.getMessageLevel());
\r
327 debugPage.setCarriageReturnFix(Global.enableCarriageReturnFix());
\r
328 debugPage.setHtmlEntitiesFix(Global.enableHTMLEntitiesFix);
\r