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.QSystemTrayIcon;
\r
37 import com.trolltech.qt.gui.QVBoxLayout;
\r
38 import com.trolltech.qt.gui.QWidget;
\r
40 import cx.fbn.nevernote.Global;
\r
42 public class ConfigAppearancePage extends QWidget {
\r
43 private final QComboBox dateFormat;
\r
44 private final QComboBox timeFormat;
\r
45 private final QComboBox styleFormat;
\r
46 private final QComboBox tagBehavior;
\r
47 private final QCheckBox standardPalette;
\r
48 private final QCheckBox showSplashScreen;
\r
49 private final QCheckBox showTrayIcon;
\r
50 private final QCheckBox verifyDelete;
\r
51 private final QCheckBox pdfPreview;
\r
52 private final QCheckBox anyTagSelection;
\r
53 private final QCheckBox checkForUpdates;
\r
54 private final QCheckBox newNoteWithTags;
\r
55 private final QCheckBox mimicEvernote;
\r
56 private final QCheckBox startMinimized;
\r
57 private final QCheckBox minimizeOnClose;
\r
58 private final QCheckBox includeTagChildren;
\r
59 private final QCheckBox displayRightToLeft;
\r
60 private final QComboBox startupNotebook;
\r
61 private final QSpinBox autoSaveInterval;
\r
63 private final List<String> tformats;
\r
64 private final List<String> dformats;
\r
66 public ConfigAppearancePage(QWidget parent) {
\r
69 dformats = new ArrayList<String>();
\r
70 tformats = new ArrayList<String>();
\r
72 dformats.add("MM/dd/yy - 02/03/09");
\r
73 dformats.add("MM/dd/yyyy - 02/03/2009");
\r
74 dformats.add("M/dd/yyyy - 2/03/2009");
\r
75 dformats.add("M/d/yyyy - 2/3/2009");
\r
76 dformats.add("dd/MM/yy - 03/02/09");
\r
77 dformats.add("d/M/yy - 3/2/09");
\r
78 dformats.add("dd/MM/yyyy - 03/02/2009");
\r
79 dformats.add("d/M/yyyy - 3/2/2009");
\r
80 dformats.add("yyyy/MM/dd - 2009/02/03");
\r
81 dformats.add("yy/MM/dd - 09/02/03");
\r
83 tformats.add("HH:mm:ss - 18:13:01");
\r
84 tformats.add("HH:mm:ss a - 18:13:01 pm");
\r
85 tformats.add("HH:mm - 18:13");
\r
86 tformats.add("HH:mm a - 18:13 pm");
\r
87 tformats.add("hh:mm:ss - 06:13:01");
\r
88 tformats.add("hh:mm:ss a - 06:13:01 pm");
\r
89 tformats.add("h:mm:ss a - 6:13:01 pm");
\r
90 tformats.add("hh:mm - 06:13");
\r
91 tformats.add("hh:mm a - 06:13 pm");
\r
92 tformats.add("h:mm a - 6:13 pm");
\r
95 // Style sheet formats
\r
96 List<String> styles = QStyleFactory.keys();
\r
97 QGroupBox styleGroup = new QGroupBox(tr("GUI Style"));
\r
98 styleFormat = new QComboBox();
\r
99 styleFormat.addItems(styles);
\r
100 styleFormat.activated.connect(this, "styleSelected(String)");
\r
102 standardPalette = new QCheckBox();
\r
103 standardPalette.setText(tr("Use standard palette"));
\r
104 standardPalette.clicked.connect(this, "standardPaletteChanged()");
\r
106 QFormLayout styleLayout = new QFormLayout();
\r
107 styleLayout.addWidget(styleFormat);
\r
108 styleLayout.addWidget(standardPalette);
\r
110 styleGroup.setLayout(styleLayout);
\r
112 QGroupBox tagBehaviorGroup = new QGroupBox(tr("Tag Behavior"));
\r
113 tagBehavior = new QComboBox();
\r
114 tagBehavior.addItem(tr("Do nothing"),"DoNothing");
\r
115 tagBehavior.addItem(tr("Count tags & do not hide inactive"),"NoHideInactiveCount");
\r
116 tagBehavior.addItem(tr("Count tags & hide inactive"),"HideInactiveCount");
\r
117 tagBehavior.addItem(tr("Color active tags"),"ColorActive");
\r
119 QFormLayout tagLayout = new QFormLayout();
\r
120 tagLayout.addWidget(tagBehavior);
\r
121 tagBehaviorGroup.setLayout(tagLayout);
\r
125 // Date/Time settings
\r
126 QGroupBox datetimeGroup = new QGroupBox(tr("Date/Time Format"));
\r
127 dateFormat = new QComboBox();
\r
128 for (int i=0; i<dformats.size(); i++) {
\r
129 dateFormat.addItem(tr(dformats.get(i)));
\r
132 timeFormat = new QComboBox();
\r
133 for (int i=0; i<tformats.size(); i++) {
\r
134 timeFormat.addItem(tr(tformats.get(i)));
\r
137 QFormLayout formatLayout = new QFormLayout();
\r
138 formatLayout.addWidget(dateFormat);
\r
139 formatLayout.addWidget(timeFormat);
\r
140 datetimeGroup.setLayout(formatLayout);
\r
142 mimicEvernote = new QCheckBox(tr("Mimic Evernote Selection Behavior (Requires Restart)"));
\r
143 showSplashScreen = new QCheckBox(tr("Show Splash Screen on Startup"));
\r
144 showTrayIcon = new QCheckBox(tr("Minimize To Tray"));
\r
145 minimizeOnClose = new QCheckBox(tr("Minimize On Close"));
\r
146 if (!QSystemTrayIcon.isSystemTrayAvailable()) {
\r
147 showTrayIcon.setEnabled(false);
\r
148 minimizeOnClose.setEnabled(false);
\r
150 verifyDelete = new QCheckBox(tr("Verify Deletes"));
\r
151 startMinimized = new QCheckBox(tr("Start Minimized"));
\r
152 pdfPreview = new QCheckBox(tr("Display PDF Documents Inline"));
\r
153 checkForUpdates = new QCheckBox(tr("Check For Updates At Startup"));
\r
154 newNoteWithTags = new QCheckBox(tr("Create New Notes With Selected Tags"));
\r
155 anyTagSelection = new QCheckBox(tr("Display Notes Matching Any Selected Tags"));
\r
156 includeTagChildren = new QCheckBox(tr("Include Children In Tag Selection"));
\r
157 displayRightToLeft = new QCheckBox(tr("Display Notes Right-To-Left"));
\r
159 QHBoxLayout startupNotebookLayout = new QHBoxLayout();
\r
160 startupNotebook = new QComboBox();
\r
161 startupNotebook.addItem(tr("All Notebooks"), "AllNotebooks");
\r
162 startupNotebook.addItem(tr("Default Notebook"), "DefaultNotebook");
\r
163 startupNotebookLayout.addWidget(new QLabel(tr("Startup Notebook")));
\r
164 startupNotebookLayout.addWidget(startupNotebook);
\r
165 startupNotebookLayout.addStretch();
\r
168 QHBoxLayout autoSaveLayout = new QHBoxLayout();
\r
169 autoSaveLayout.addWidget(new QLabel(tr("Automatic Save Interval (in Minutes)")));
\r
170 autoSaveInterval = new QSpinBox();
\r
171 autoSaveLayout.addWidget(autoSaveInterval);
\r
172 autoSaveInterval.setMaximum(1440);
\r
173 autoSaveInterval.setMinimum(0);
\r
175 QVBoxLayout mainLayout = new QVBoxLayout(this);
\r
176 mainLayout.addWidget(styleGroup);
\r
177 mainLayout.addWidget(datetimeGroup);
\r
178 mainLayout.addLayout(autoSaveLayout);
\r
179 mainLayout.addWidget(tagBehaviorGroup);
\r
182 QVBoxLayout checkboxLayout = new QVBoxLayout();
\r
183 checkboxLayout.addWidget(mimicEvernote);
\r
184 checkboxLayout.addLayout(startupNotebookLayout);
\r
185 checkboxLayout.addWidget(showTrayIcon);
\r
186 checkboxLayout.addWidget(minimizeOnClose);
\r
187 checkboxLayout.addWidget(startMinimized);
\r
188 checkboxLayout.addWidget(showSplashScreen);
\r
189 checkboxLayout.addWidget(verifyDelete);
\r
190 checkboxLayout.addWidget(pdfPreview);
\r
191 checkboxLayout.addWidget(newNoteWithTags);
\r
192 checkboxLayout.addWidget(anyTagSelection);
\r
193 checkboxLayout.addWidget(includeTagChildren);
\r
194 checkboxLayout.addWidget(displayRightToLeft);
\r
195 checkboxLayout.addWidget(checkForUpdates);
\r
196 checkboxLayout.addStretch(1);
\r
199 QWidget checkBoxGroup = new QWidget();
\r
200 checkBoxGroup.setLayout(checkboxLayout);
\r
202 QScrollArea scrollArea = new QScrollArea();
\r
203 scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded);
\r
204 scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded);
\r
205 scrollArea.setWidgetResizable(true);
\r
206 scrollArea.setWidget(checkBoxGroup);
\r
208 mainLayout.addWidget(scrollArea);
\r
209 setLayout(mainLayout);
\r
211 showTrayIcon.clicked.connect(this, "showTrayIconClicked(Boolean)");
\r
212 showTrayIconClicked(showTrayIcon.isChecked());
\r
216 private void showTrayIconClicked(Boolean checked) {
\r
218 minimizeOnClose.setEnabled(false);
\r
219 minimizeOnClose.setChecked(false);
\r
221 if (QSystemTrayIcon.isSystemTrayAvailable())
\r
222 minimizeOnClose.setEnabled(true);
\r
224 minimizeOnClose.setEnabled(false);
\r
228 //*****************************************
\r
229 //* date format get/set methods
\r
230 //*****************************************
\r
231 public void setDateFormat(String id) {
\r
232 for (int i=0; i<dformats.size(); i++) {
\r
233 String d = dformats.get(i);
\r
234 if (d.substring(0,id.length()).equals(id))
\r
235 dateFormat.setCurrentIndex(i);
\r
238 public String getDateFormat() {
\r
239 int i = dateFormat.currentIndex();
\r
240 return dateFormat.itemText(i);
\r
245 //*****************************************
\r
246 //* time format get/set methods
\r
247 //*****************************************
\r
248 public void setTimeFormat(String id) {
\r
249 for (int i=0; i<tformats.size(); i++) {
\r
250 String d = tformats.get(i);
\r
251 int dash = d.indexOf("-");
\r
252 d = d.substring(0,dash-1);
\r
253 if (d.equals(id)) {
\r
254 timeFormat.setCurrentIndex(i);
\r
259 public String getTimeFormat() {
\r
260 int i = timeFormat.currentIndex();
\r
261 return timeFormat.itemText(i);
\r
265 //*****************************************
\r
266 //* gui style format get/set methods
\r
267 //*****************************************
\r
268 public void setStyle(String id) {
\r
269 for (int i=0; i<styleFormat.count(); i++) {
\r
270 String d = styleFormat.itemText(i);
\r
272 styleFormat.setCurrentIndex(i);
\r
275 public String getStyle() {
\r
276 int i = styleFormat.currentIndex();
\r
277 return styleFormat.itemText(i);
\r
280 //*****************************************
\r
281 //* palette style get/set methods
\r
282 //*****************************************
\r
283 public void setStandardPalette(boolean value) {
\r
284 standardPalette.setChecked(value);
\r
286 public boolean getStandardPalette() {
\r
287 return standardPalette.isChecked();
\r
290 //*******************************************
\r
291 //* Show/Hide tray icon get/set
\r
292 //*******************************************
\r
293 public void setShowTrayIcon(boolean val) {
\r
294 showTrayIcon.setChecked(val);
\r
295 showTrayIconClicked(showTrayIcon.isChecked());
\r
297 public boolean getShowTrayIcon() {
\r
298 return showTrayIcon.isChecked();
\r
302 //*******************************************
\r
303 //* minimize on close get/set
\r
304 //*******************************************
\r
305 public void setMinimizeOnClose(boolean val) {
\r
306 minimizeOnClose.setChecked(val);
\r
308 public boolean getMinimizeOnClose() {
\r
309 return minimizeOnClose.isChecked();
\r
313 //*****************************************
\r
314 //* Show the splash screen on startup
\r
315 //*****************************************
\r
316 public void setShowSplashScreen(boolean val) {
\r
317 showSplashScreen.setChecked(val);
\r
319 public boolean getShowSplashScreen() {
\r
320 return showSplashScreen.isChecked();
\r
323 //*******************************************
\r
324 //* verify deletes get/set
\r
325 //*******************************************
\r
326 public void setVerifyDelete(boolean val) {
\r
327 verifyDelete.setChecked(val);
\r
329 public boolean getVerifyDelete() {
\r
330 return verifyDelete.isChecked();
\r
334 //*******************************************
\r
335 //* Show/Hide tray icon get/set
\r
336 //*******************************************
\r
337 public void setPdfPreview(boolean val) {
\r
338 pdfPreview.setChecked(val);
\r
340 public boolean getPdfPreview() {
\r
341 return pdfPreview.isChecked();
\r
344 //*******************************************
\r
345 //* check for updates get/set
\r
346 //*******************************************
\r
347 public void setCheckForUpdates(boolean val) {
\r
348 checkForUpdates.setChecked(val);
\r
350 public boolean getCheckForUpdates() {
\r
351 return checkForUpdates.isChecked();
\r
355 //********************************************
\r
356 //* Listeners for palette & style changes
\r
357 //********************************************
\r
358 public void styleSelected(String style) {
\r
359 QApplication.setStyle(style);
\r
360 QApplication.setPalette(QApplication.style().standardPalette());
\r
362 public void standardPaletteChanged() {
\r
363 if (standardPalette.isChecked())
\r
364 QApplication.setPalette(QApplication.style().standardPalette());
\r
366 QApplication.setPalette(Global.originalPalette);
\r
371 //*****************************************
\r
372 //* automatic save timer
\r
373 //*****************************************
\r
374 public void setAutoSaveInterval(int len) {
\r
375 autoSaveInterval.setValue(len);
\r
377 public int getAutoSaveInterval() {
\r
378 return autoSaveInterval.value();
\r
382 //*****************************************
\r
383 //* Get/Set tag behavior combo box
\r
384 //*****************************************
\r
385 public void setTagBehavior(String value) {
\r
386 for (int i=0; i<tagBehavior.count(); i++) {
\r
387 String d = tagBehavior.itemData(i).toString();
\r
388 if (value.equalsIgnoreCase(d)) {
\r
389 tagBehavior.setCurrentIndex(i);
\r
394 public String getTagBehavior() {
\r
395 int i = tagBehavior.currentIndex();
\r
396 return tagBehavior.itemData(i).toString();
\r
399 //*****************************************
\r
400 //* Mimic Evernote Selection
\r
401 //*****************************************
\r
402 public boolean getMimicEvernote() {
\r
403 return mimicEvernote.isChecked();
\r
405 public void setMimicEvernote(boolean val) {
\r
406 mimicEvernote.setChecked(val);
\r
410 //*****************************************
\r
411 //* Mimic Evernote Selection
\r
412 //*****************************************
\r
413 public boolean getStartMinimized() {
\r
414 return startMinimized.isChecked();
\r
416 public void setStartMinimized(boolean val) {
\r
417 startMinimized.setChecked(val);
\r
421 //*****************************************
\r
422 //* Create Note With Selected Tags
\r
423 //*****************************************
\r
424 public boolean getNewNoteWithTags() {
\r
425 return newNoteWithTags.isChecked();
\r
427 public void setNewNoteWithTags(boolean val) {
\r
428 newNoteWithTags.setChecked(val);
\r
431 //*****************************************
\r
432 //* Set tag selection behavior
\r
433 //*****************************************
\r
434 public boolean getAnyTagSelection() {
\r
435 return anyTagSelection.isChecked();
\r
437 public void setAnyTagSelection(boolean val) {
\r
438 anyTagSelection.setChecked(val);
\r
442 //*****************************************
\r
443 //* Include a tag's child when selecting a parent
\r
444 //*****************************************
\r
445 public boolean getIncludeTagChildren() {
\r
446 return includeTagChildren.isChecked();
\r
448 public void setIncludeTagChildren(boolean val) {
\r
449 includeTagChildren.setChecked(val);
\r
451 //*****************************************
\r
452 //* Include a tag's child when selecting a parent
\r
453 //*****************************************
\r
454 public boolean getDisplayRightToLeft() {
\r
455 return displayRightToLeft.isChecked();
\r
457 public void setDisplayRightToLeft(boolean val) {
\r
458 displayRightToLeft.setChecked(val);
\r
462 //**************************************************
\r
463 //* Get/Set startup notebook
\r
464 //**************************************************
\r
465 public void setStartupNotebook(String value) {
\r
466 for (int i=0; i<startupNotebook.count(); i++) {
\r
467 String d = startupNotebook.itemData(i).toString();
\r
468 if (d.equals(value))
\r
469 startupNotebook.setCurrentIndex(i);
\r
472 public String getStartupNotebook() {
\r
473 int index = startupNotebook.currentIndex();
\r
474 return startupNotebook.itemData(index).toString();
\r