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 package cx.fbn.nevernote.dialog;
\r
22 import java.util.ArrayList;
\r
23 import java.util.List;
\r
25 import com.trolltech.qt.core.Qt;
\r
26 import com.trolltech.qt.gui.QApplication;
\r
27 import com.trolltech.qt.gui.QCheckBox;
\r
28 import com.trolltech.qt.gui.QComboBox;
\r
29 import com.trolltech.qt.gui.QFormLayout;
\r
30 import com.trolltech.qt.gui.QGroupBox;
\r
31 import com.trolltech.qt.gui.QHBoxLayout;
\r
32 import com.trolltech.qt.gui.QLabel;
\r
33 import com.trolltech.qt.gui.QScrollArea;
\r
34 import com.trolltech.qt.gui.QSpinBox;
\r
35 import com.trolltech.qt.gui.QStyleFactory;
\r
36 import com.trolltech.qt.gui.QVBoxLayout;
\r
37 import com.trolltech.qt.gui.QWidget;
\r
39 import cx.fbn.nevernote.Global;
\r
41 public class ConfigAppearancePage extends QWidget {
\r
42 private final QComboBox dateFormat;
\r
43 private final QComboBox timeFormat;
\r
44 private final QComboBox styleFormat;
\r
45 private final QComboBox tagBehavior;
\r
46 private final QCheckBox standardPalette;
\r
47 private final QCheckBox showSplashScreen;
\r
48 private final QCheckBox showTrayIcon;
\r
49 private final QCheckBox verifyDelete;
\r
50 private final QCheckBox pdfPreview;
\r
51 private final QCheckBox anyTagSelection;
\r
52 private final QCheckBox checkForUpdates;
\r
53 private final QCheckBox newNoteWithTags;
\r
54 private final QCheckBox mimicEvernote;
\r
55 private final QCheckBox startMinimized;
\r
56 private final QCheckBox minimizeOnClose;
\r
57 private final QCheckBox includeTagChildren;
\r
58 private final QCheckBox displayRightToLeft;
\r
59 private final QComboBox startupNotebook;
\r
60 private final QSpinBox autoSaveInterval;
\r
62 private final List<String> tformats;
\r
63 private final List<String> dformats;
\r
65 public ConfigAppearancePage(QWidget parent) {
\r
68 dformats = new ArrayList<String>();
\r
69 tformats = new ArrayList<String>();
\r
71 dformats.add("MM/dd/yy - 02/03/09");
\r
72 dformats.add("MM/dd/yyyy - 02/03/2009");
\r
73 dformats.add("M/dd/yyyy - 2/03/2009");
\r
74 dformats.add("M/d/yyyy - 2/3/2009");
\r
75 dformats.add("dd/MM/yy - 03/02/09");
\r
76 dformats.add("d/M/yy - 3/2/09");
\r
77 dformats.add("dd/MM/yyyy - 03/02/2009");
\r
78 dformats.add("d/M/yyyy - 3/2/2009");
\r
79 dformats.add("yyyy/MM/dd - 2009/02/03");
\r
80 dformats.add("yy/MM/dd - 09/02/03");
\r
82 tformats.add("HH:mm:ss - 18:13:01");
\r
83 tformats.add("HH:mm:ss a - 18:13:01 pm");
\r
84 tformats.add("HH:mm - 18:13");
\r
85 tformats.add("HH:mm a - 18:13 pm");
\r
86 tformats.add("hh:mm:ss - 06:13:01");
\r
87 tformats.add("hh:mm:ss a - 06:13:01 pm");
\r
88 tformats.add("h:mm:ss a - 6:13:01 pm");
\r
89 tformats.add("hh:mm - 06:13");
\r
90 tformats.add("hh:mm a - 06:13 pm");
\r
91 tformats.add("h:mm a - 6:13 pm");
\r
94 // Style sheet formats
\r
95 List<String> styles = QStyleFactory.keys();
\r
96 QGroupBox styleGroup = new QGroupBox(tr("GUI Style"));
\r
97 styleFormat = new QComboBox();
\r
98 styleFormat.addItems(styles);
\r
99 styleFormat.activated.connect(this, "styleSelected(String)");
\r
101 standardPalette = new QCheckBox();
\r
102 standardPalette.setText(tr("Use standard palette"));
\r
103 standardPalette.clicked.connect(this, "standardPaletteChanged()");
\r
105 QFormLayout styleLayout = new QFormLayout();
\r
106 styleLayout.addWidget(styleFormat);
\r
107 styleLayout.addWidget(standardPalette);
\r
109 styleGroup.setLayout(styleLayout);
\r
111 QGroupBox tagBehaviorGroup = new QGroupBox(tr("Tag Behavior"));
\r
112 tagBehavior = new QComboBox();
\r
113 tagBehavior.addItem(tr("Do nothing"),"DoNothing");
\r
114 tagBehavior.addItem(tr("Count tags & do not hide inactive"),"NoHideInactiveCount");
\r
115 tagBehavior.addItem(tr("Count tags & hide inactive"),"HideInactiveCount");
\r
116 tagBehavior.addItem(tr("Color active tags"),"ColorActive");
\r
118 QFormLayout tagLayout = new QFormLayout();
\r
119 tagLayout.addWidget(tagBehavior);
\r
120 tagBehaviorGroup.setLayout(tagLayout);
\r
124 // Date/Time settings
\r
125 QGroupBox datetimeGroup = new QGroupBox(tr("Date/Time Format"));
\r
126 dateFormat = new QComboBox();
\r
127 for (int i=0; i<dformats.size(); i++) {
\r
128 dateFormat.addItem(tr(dformats.get(i)));
\r
131 timeFormat = new QComboBox();
\r
132 for (int i=0; i<tformats.size(); i++) {
\r
133 timeFormat.addItem(tr(tformats.get(i)));
\r
136 QFormLayout formatLayout = new QFormLayout();
\r
137 formatLayout.addWidget(dateFormat);
\r
138 formatLayout.addWidget(timeFormat);
\r
139 datetimeGroup.setLayout(formatLayout);
\r
141 mimicEvernote = new QCheckBox(tr("Mimic Evernote Selection Behavior (Requires Restart)"));
\r
142 showSplashScreen = new QCheckBox(tr("Show Splash Screen on Startup"));
\r
143 showTrayIcon = new QCheckBox(tr("Minimize To Tray"));
\r
144 minimizeOnClose = new QCheckBox(tr("Minimize On Close"));
\r
145 verifyDelete = new QCheckBox(tr("Verify Deletes"));
\r
146 startMinimized = new QCheckBox(tr("Start Minimized"));
\r
147 pdfPreview = new QCheckBox(tr("Display PDF Documents Inline"));
\r
148 checkForUpdates = new QCheckBox(tr("Check For Updates At Startup"));
\r
149 newNoteWithTags = new QCheckBox(tr("Create New Notes With Selected Tags"));
\r
150 anyTagSelection = new QCheckBox(tr("Display Notes Matching Any Selected Tags"));
\r
151 includeTagChildren = new QCheckBox(tr("Include Children In Tag Selection"));
\r
152 displayRightToLeft = new QCheckBox(tr("Display Notes Right-To-Left"));
\r
154 QHBoxLayout startupNotebookLayout = new QHBoxLayout();
\r
155 startupNotebook = new QComboBox();
\r
156 startupNotebook.addItem(tr("All Notebooks"), "AllNotebooks");
\r
157 startupNotebook.addItem(tr("Default Notebook"), "DefaultNotebook");
\r
158 startupNotebookLayout.addWidget(new QLabel(tr("Startup Notebook")));
\r
159 startupNotebookLayout.addWidget(startupNotebook);
\r
160 startupNotebookLayout.addStretch();
\r
163 QHBoxLayout autoSaveLayout = new QHBoxLayout();
\r
164 autoSaveLayout.addWidget(new QLabel(tr("Automatic Save Interval (in Minutes)")));
\r
165 autoSaveInterval = new QSpinBox();
\r
166 autoSaveLayout.addWidget(autoSaveInterval);
\r
167 autoSaveInterval.setMaximum(1440);
\r
168 autoSaveInterval.setMinimum(0);
\r
170 QVBoxLayout mainLayout = new QVBoxLayout(this);
\r
171 mainLayout.addWidget(styleGroup);
\r
172 mainLayout.addWidget(datetimeGroup);
\r
173 mainLayout.addLayout(autoSaveLayout);
\r
174 mainLayout.addWidget(tagBehaviorGroup);
\r
177 QVBoxLayout checkboxLayout = new QVBoxLayout();
\r
178 checkboxLayout.addWidget(mimicEvernote);
\r
179 checkboxLayout.addLayout(startupNotebookLayout);
\r
180 checkboxLayout.addWidget(showTrayIcon);
\r
181 checkboxLayout.addWidget(minimizeOnClose);
\r
182 checkboxLayout.addWidget(startMinimized);
\r
183 checkboxLayout.addWidget(showSplashScreen);
\r
184 checkboxLayout.addWidget(verifyDelete);
\r
185 checkboxLayout.addWidget(pdfPreview);
\r
186 checkboxLayout.addWidget(newNoteWithTags);
\r
187 checkboxLayout.addWidget(anyTagSelection);
\r
188 checkboxLayout.addWidget(includeTagChildren);
\r
189 checkboxLayout.addWidget(displayRightToLeft);
\r
190 checkboxLayout.addWidget(checkForUpdates);
\r
191 checkboxLayout.addStretch(1);
\r
194 QWidget checkBoxGroup = new QWidget();
\r
195 checkBoxGroup.setLayout(checkboxLayout);
\r
197 QScrollArea scrollArea = new QScrollArea();
\r
198 scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded);
\r
199 scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded);
\r
200 scrollArea.setWidgetResizable(true);
\r
201 scrollArea.setWidget(checkBoxGroup);
\r
203 mainLayout.addWidget(scrollArea);
\r
204 setLayout(mainLayout);
\r
206 showTrayIcon.clicked.connect(this, "showTrayIconClicked(Boolean)");
\r
207 showTrayIconClicked(showTrayIcon.isChecked());
\r
212 private void showTrayIconClicked(Boolean checked) {
\r
214 minimizeOnClose.setEnabled(false);
\r
215 minimizeOnClose.setChecked(false);
\r
217 minimizeOnClose.setEnabled(true);
\r
221 //*****************************************
\r
222 //* date format get/set methods
\r
223 //*****************************************
\r
224 public void setDateFormat(String id) {
\r
225 for (int i=0; i<dformats.size(); i++) {
\r
226 String d = dformats.get(i);
\r
227 if (d.substring(0,id.length()).equals(id))
\r
228 dateFormat.setCurrentIndex(i);
\r
231 public String getDateFormat() {
\r
232 int i = dateFormat.currentIndex();
\r
233 return dateFormat.itemText(i);
\r
238 //*****************************************
\r
239 //* time format get/set methods
\r
240 //*****************************************
\r
241 public void setTimeFormat(String id) {
\r
242 for (int i=0; i<tformats.size(); i++) {
\r
243 String d = tformats.get(i);
\r
244 int dash = d.indexOf("-");
\r
245 d = d.substring(0,dash-1);
\r
246 if (d.equals(id)) {
\r
247 timeFormat.setCurrentIndex(i);
\r
252 public String getTimeFormat() {
\r
253 int i = timeFormat.currentIndex();
\r
254 return timeFormat.itemText(i);
\r
258 //*****************************************
\r
259 //* gui style format get/set methods
\r
260 //*****************************************
\r
261 public void setStyle(String id) {
\r
262 for (int i=0; i<styleFormat.count(); i++) {
\r
263 String d = styleFormat.itemText(i);
\r
265 styleFormat.setCurrentIndex(i);
\r
268 public String getStyle() {
\r
269 int i = styleFormat.currentIndex();
\r
270 return styleFormat.itemText(i);
\r
273 //*****************************************
\r
274 //* palette style get/set methods
\r
275 //*****************************************
\r
276 public void setStandardPalette(boolean value) {
\r
277 standardPalette.setChecked(value);
\r
279 public boolean getStandardPalette() {
\r
280 return standardPalette.isChecked();
\r
283 //*******************************************
\r
284 //* Show/Hide tray icon get/set
\r
285 //*******************************************
\r
286 public void setShowTrayIcon(boolean val) {
\r
287 showTrayIcon.setChecked(val);
\r
288 showTrayIconClicked(showTrayIcon.isChecked());
\r
290 public boolean getShowTrayIcon() {
\r
291 return showTrayIcon.isChecked();
\r
295 //*******************************************
\r
296 //* minimize on close get/set
\r
297 //*******************************************
\r
298 public void setMinimizeOnClose(boolean val) {
\r
299 minimizeOnClose.setChecked(val);
\r
301 public boolean getMinimizeOnClose() {
\r
302 return minimizeOnClose.isChecked();
\r
306 //*****************************************
\r
307 //* Show the splash screen on startup
\r
308 //*****************************************
\r
309 public void setShowSplashScreen(boolean val) {
\r
310 showSplashScreen.setChecked(val);
\r
312 public boolean getShowSplashScreen() {
\r
313 return showSplashScreen.isChecked();
\r
316 //*******************************************
\r
317 //* verify deletes get/set
\r
318 //*******************************************
\r
319 public void setVerifyDelete(boolean val) {
\r
320 verifyDelete.setChecked(val);
\r
322 public boolean getVerifyDelete() {
\r
323 return verifyDelete.isChecked();
\r
327 //*******************************************
\r
328 //* Show/Hide tray icon get/set
\r
329 //*******************************************
\r
330 public void setPdfPreview(boolean val) {
\r
331 pdfPreview.setChecked(val);
\r
333 public boolean getPdfPreview() {
\r
334 return pdfPreview.isChecked();
\r
337 //*******************************************
\r
338 //* check for updates get/set
\r
339 //*******************************************
\r
340 public void setCheckForUpdates(boolean val) {
\r
341 checkForUpdates.setChecked(val);
\r
343 public boolean getCheckForUpdates() {
\r
344 return checkForUpdates.isChecked();
\r
348 //********************************************
\r
349 //* Listeners for palette & style changes
\r
350 //********************************************
\r
351 public void styleSelected(String style) {
\r
352 QApplication.setStyle(style);
\r
353 QApplication.setPalette(QApplication.style().standardPalette());
\r
355 public void standardPaletteChanged() {
\r
356 if (standardPalette.isChecked())
\r
357 QApplication.setPalette(QApplication.style().standardPalette());
\r
359 QApplication.setPalette(Global.originalPalette);
\r
364 //*****************************************
\r
365 //* automatic save timer
\r
366 //*****************************************
\r
367 public void setAutoSaveInterval(int len) {
\r
368 autoSaveInterval.setValue(len);
\r
370 public int getAutoSaveInterval() {
\r
371 return autoSaveInterval.value();
\r
375 //*****************************************
\r
376 //* Get/Set tag behavior combo box
\r
377 //*****************************************
\r
378 public void setTagBehavior(String value) {
\r
379 for (int i=0; i<tagBehavior.count(); i++) {
\r
380 String d = tagBehavior.itemData(i).toString();
\r
381 if (value.equalsIgnoreCase(d)) {
\r
382 tagBehavior.setCurrentIndex(i);
\r
387 public String getTagBehavior() {
\r
388 int i = tagBehavior.currentIndex();
\r
389 return tagBehavior.itemData(i).toString();
\r
392 //*****************************************
\r
393 //* Mimic Evernote Selection
\r
394 //*****************************************
\r
395 public boolean getMimicEvernote() {
\r
396 return mimicEvernote.isChecked();
\r
398 public void setMimicEvernote(boolean val) {
\r
399 mimicEvernote.setChecked(val);
\r
403 //*****************************************
\r
404 //* Mimic Evernote Selection
\r
405 //*****************************************
\r
406 public boolean getStartMinimized() {
\r
407 return startMinimized.isChecked();
\r
409 public void setStartMinimized(boolean val) {
\r
410 startMinimized.setChecked(val);
\r
414 //*****************************************
\r
415 //* Create Note With Selected Tags
\r
416 //*****************************************
\r
417 public boolean getNewNoteWithTags() {
\r
418 return newNoteWithTags.isChecked();
\r
420 public void setNewNoteWithTags(boolean val) {
\r
421 newNoteWithTags.setChecked(val);
\r
424 //*****************************************
\r
425 //* Set tag selection behavior
\r
426 //*****************************************
\r
427 public boolean getAnyTagSelection() {
\r
428 return anyTagSelection.isChecked();
\r
430 public void setAnyTagSelection(boolean val) {
\r
431 anyTagSelection.setChecked(val);
\r
435 //*****************************************
\r
436 //* Include a tag's child when selecting a parent
\r
437 //*****************************************
\r
438 public boolean getIncludeTagChildren() {
\r
439 return includeTagChildren.isChecked();
\r
441 public void setIncludeTagChildren(boolean val) {
\r
442 includeTagChildren.setChecked(val);
\r
444 //*****************************************
\r
445 //* Include a tag's child when selecting a parent
\r
446 //*****************************************
\r
447 public boolean getDisplayRightToLeft() {
\r
448 return displayRightToLeft.isChecked();
\r
450 public void setDisplayRightToLeft(boolean val) {
\r
451 displayRightToLeft.setChecked(val);
\r
455 //**************************************************
\r
456 //* Get/Set startup notebook
\r
457 //**************************************************
\r
458 public void setStartupNotebook(String value) {
\r
459 for (int i=0; i<startupNotebook.count(); i++) {
\r
460 String d = startupNotebook.itemData(i).toString();
\r
461 if (d.equals(value))
\r
462 startupNotebook.setCurrentIndex(i);
\r
465 public String getStartupNotebook() {
\r
466 int index = startupNotebook.currentIndex();
\r
467 return startupNotebook.itemData(index).toString();
\r