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 QSpinBox autoSaveInterval;
\r
60 private final List<String> tformats;
\r
61 private final List<String> dformats;
\r
63 public ConfigAppearancePage(QWidget parent) {
\r
66 dformats = new ArrayList<String>();
\r
67 tformats = new ArrayList<String>();
\r
69 dformats.add("MM/dd/yy - 02/03/09");
\r
70 dformats.add("MM/dd/yyyy - 02/03/2009");
\r
71 dformats.add("M/dd/yyyy - 2/03/2009");
\r
72 dformats.add("M/d/yyyy - 2/3/2009");
\r
73 dformats.add("dd/MM/yy - 03/02/09");
\r
74 dformats.add("d/M/yy - 3/2/09");
\r
75 dformats.add("dd/MM/yyyy - 03/02/2009");
\r
76 dformats.add("d/M/yyyy - 3/2/2009");
\r
77 dformats.add("yyyy/MM/dd - 2009/02/03");
\r
78 dformats.add("yy/MM/dd - 09/02/03");
\r
80 tformats.add("HH:mm:ss - 18:13:01");
\r
81 tformats.add("HH:mm:ss a - 18:13:01 pm");
\r
82 tformats.add("HH:mm - 18:13");
\r
83 tformats.add("HH:mm a - 18:13 pm");
\r
84 tformats.add("hh:mm:ss - 06:13:01");
\r
85 tformats.add("hh:mm:ss a - 06:13:01 pm");
\r
86 tformats.add("h:mm:ss a - 6:13:01 pm");
\r
87 tformats.add("hh:mm - 06:13");
\r
88 tformats.add("hh:mm a - 06:13 pm");
\r
89 tformats.add("h:mm a - 6:13 pm");
\r
92 // Style sheet formats
\r
93 List<String> styles = QStyleFactory.keys();
\r
94 QGroupBox styleGroup = new QGroupBox(tr("GUI Style"));
\r
95 styleFormat = new QComboBox();
\r
96 styleFormat.addItems(styles);
\r
97 styleFormat.activated.connect(this, "styleSelected(String)");
\r
99 standardPalette = new QCheckBox();
\r
100 standardPalette.setText(tr("Use standard palette"));
\r
101 standardPalette.clicked.connect(this, "standardPaletteChanged()");
\r
103 QFormLayout styleLayout = new QFormLayout();
\r
104 styleLayout.addWidget(styleFormat);
\r
105 styleLayout.addWidget(standardPalette);
\r
107 styleGroup.setLayout(styleLayout);
\r
109 QGroupBox tagBehaviorGroup = new QGroupBox(tr("Tag Behavior"));
\r
110 tagBehavior = new QComboBox();
\r
111 tagBehavior.addItem(tr("Do nothing"),"DoNothing");
\r
112 tagBehavior.addItem(tr("Count tags & do not hide inactive"),"NoHideInactiveCount");
\r
113 tagBehavior.addItem(tr("Count tags & hide inactive"),"HideInactiveCount");
\r
114 tagBehavior.addItem(tr("Color active tags"),"ColorActive");
\r
116 QFormLayout tagLayout = new QFormLayout();
\r
117 tagLayout.addWidget(tagBehavior);
\r
118 tagBehaviorGroup.setLayout(tagLayout);
\r
122 // Date/Time settings
\r
123 QGroupBox datetimeGroup = new QGroupBox(tr("Date/Time Format"));
\r
124 dateFormat = new QComboBox();
\r
125 for (int i=0; i<dformats.size(); i++) {
\r
126 dateFormat.addItem(tr(dformats.get(i)));
\r
129 timeFormat = new QComboBox();
\r
130 for (int i=0; i<tformats.size(); i++) {
\r
131 timeFormat.addItem(tr(tformats.get(i)));
\r
134 QFormLayout formatLayout = new QFormLayout();
\r
135 formatLayout.addWidget(dateFormat);
\r
136 formatLayout.addWidget(timeFormat);
\r
137 datetimeGroup.setLayout(formatLayout);
\r
139 mimicEvernote = new QCheckBox(tr("Mimic Evernote Selection Behavior (Requires Restart)"));
\r
140 showSplashScreen = new QCheckBox(tr("Show Splash Screen on Startup"));
\r
141 showTrayIcon = new QCheckBox(tr("Minimize To Tray"));
\r
142 minimizeOnClose = new QCheckBox(tr("Minimize On Close"));
\r
143 verifyDelete = new QCheckBox(tr("Verify Deletes"));
\r
144 startMinimized = new QCheckBox(tr("Start Minimized"));
\r
145 pdfPreview = new QCheckBox(tr("Display PDF Documents Inline"));
\r
146 checkForUpdates = new QCheckBox(tr("Check For Updates At Startup"));
\r
147 newNoteWithTags = new QCheckBox(tr("Create New Notes With Selected Tags"));
\r
148 anyTagSelection = new QCheckBox(tr("Display Notes Matching Any Selected Tags"));
\r
149 includeTagChildren = new QCheckBox(tr("Include Children In Tag Selection"));
\r
151 QHBoxLayout autoSaveLayout = new QHBoxLayout();
\r
152 autoSaveLayout.addWidget(new QLabel(tr("Automatic Save Interval (in Minutes)")));
\r
153 autoSaveInterval = new QSpinBox();
\r
154 autoSaveLayout.addWidget(autoSaveInterval);
\r
155 autoSaveInterval.setMaximum(1440);
\r
156 autoSaveInterval.setMinimum(0);
\r
158 QVBoxLayout mainLayout = new QVBoxLayout(this);
\r
159 mainLayout.addWidget(styleGroup);
\r
160 mainLayout.addWidget(datetimeGroup);
\r
161 mainLayout.addLayout(autoSaveLayout);
\r
162 mainLayout.addWidget(tagBehaviorGroup);
\r
165 QVBoxLayout checkboxLayout = new QVBoxLayout();
\r
166 checkboxLayout.addWidget(mimicEvernote);
\r
167 checkboxLayout.addWidget(showTrayIcon);
\r
168 checkboxLayout.addWidget(minimizeOnClose);
\r
169 checkboxLayout.addWidget(startMinimized);
\r
170 checkboxLayout.addWidget(showSplashScreen);
\r
171 checkboxLayout.addWidget(verifyDelete);
\r
172 checkboxLayout.addWidget(pdfPreview);
\r
173 checkboxLayout.addWidget(newNoteWithTags);
\r
174 checkboxLayout.addWidget(anyTagSelection);
\r
175 checkboxLayout.addWidget(includeTagChildren);
\r
176 checkboxLayout.addWidget(checkForUpdates);
\r
177 checkboxLayout.addStretch(1);
\r
180 QWidget checkBoxGroup = new QWidget();
\r
181 checkBoxGroup.setLayout(checkboxLayout);
\r
183 QScrollArea scrollArea = new QScrollArea();
\r
184 scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded);
\r
185 scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded);
\r
186 scrollArea.setWidgetResizable(true);
\r
187 scrollArea.setWidget(checkBoxGroup);
\r
189 mainLayout.addWidget(scrollArea);
\r
190 setLayout(mainLayout);
\r
192 showTrayIcon.clicked.connect(this, "showTrayIconClicked(Boolean)");
\r
193 showTrayIconClicked(showTrayIcon.isChecked());
\r
198 private void showTrayIconClicked(Boolean checked) {
\r
200 minimizeOnClose.setEnabled(false);
\r
201 minimizeOnClose.setChecked(false);
\r
203 minimizeOnClose.setEnabled(true);
\r
207 //*****************************************
\r
208 //* date format get/set methods
\r
209 //*****************************************
\r
210 public void setDateFormat(String id) {
\r
211 for (int i=0; i<dformats.size(); i++) {
\r
212 String d = dformats.get(i);
\r
213 if (d.substring(0,id.length()).equals(id))
\r
214 dateFormat.setCurrentIndex(i);
\r
217 public String getDateFormat() {
\r
218 int i = dateFormat.currentIndex();
\r
219 return dateFormat.itemText(i);
\r
224 //*****************************************
\r
225 //* time format get/set methods
\r
226 //*****************************************
\r
227 public void setTimeFormat(String id) {
\r
228 for (int i=0; i<tformats.size(); i++) {
\r
229 String d = tformats.get(i);
\r
230 int dash = d.indexOf("-");
\r
231 d = d.substring(0,dash-1);
\r
232 if (d.equals(id)) {
\r
233 timeFormat.setCurrentIndex(i);
\r
238 public String getTimeFormat() {
\r
239 int i = timeFormat.currentIndex();
\r
240 return timeFormat.itemText(i);
\r
244 //*****************************************
\r
245 //* gui style format get/set methods
\r
246 //*****************************************
\r
247 public void setStyle(String id) {
\r
248 for (int i=0; i<styleFormat.count(); i++) {
\r
249 String d = styleFormat.itemText(i);
\r
251 styleFormat.setCurrentIndex(i);
\r
254 public String getStyle() {
\r
255 int i = styleFormat.currentIndex();
\r
256 return styleFormat.itemText(i);
\r
259 //*****************************************
\r
260 //* palette style get/set methods
\r
261 //*****************************************
\r
262 public void setStandardPalette(boolean value) {
\r
263 standardPalette.setChecked(value);
\r
265 public boolean getStandardPalette() {
\r
266 return standardPalette.isChecked();
\r
269 //*******************************************
\r
270 //* Show/Hide tray icon get/set
\r
271 //*******************************************
\r
272 public void setShowTrayIcon(boolean val) {
\r
273 showTrayIcon.setChecked(val);
\r
274 showTrayIconClicked(showTrayIcon.isChecked());
\r
276 public boolean getShowTrayIcon() {
\r
277 return showTrayIcon.isChecked();
\r
281 //*******************************************
\r
282 //* minimize on close get/set
\r
283 //*******************************************
\r
284 public void setMinimizeOnClose(boolean val) {
\r
285 minimizeOnClose.setChecked(val);
\r
287 public boolean getMinimizeOnClose() {
\r
288 return minimizeOnClose.isChecked();
\r
292 //*****************************************
\r
293 //* Show the splash screen on startup
\r
294 //*****************************************
\r
295 public void setShowSplashScreen(boolean val) {
\r
296 showSplashScreen.setChecked(val);
\r
298 public boolean getShowSplashScreen() {
\r
299 return showSplashScreen.isChecked();
\r
302 //*******************************************
\r
303 //* verify deletes get/set
\r
304 //*******************************************
\r
305 public void setVerifyDelete(boolean val) {
\r
306 verifyDelete.setChecked(val);
\r
308 public boolean getVerifyDelete() {
\r
309 return verifyDelete.isChecked();
\r
313 //*******************************************
\r
314 //* Show/Hide tray icon get/set
\r
315 //*******************************************
\r
316 public void setPdfPreview(boolean val) {
\r
317 pdfPreview.setChecked(val);
\r
319 public boolean getPdfPreview() {
\r
320 return pdfPreview.isChecked();
\r
323 //*******************************************
\r
324 //* check for updates get/set
\r
325 //*******************************************
\r
326 public void setCheckForUpdates(boolean val) {
\r
327 checkForUpdates.setChecked(val);
\r
329 public boolean getCheckForUpdates() {
\r
330 return checkForUpdates.isChecked();
\r
334 //********************************************
\r
335 //* Listeners for palette & style changes
\r
336 //********************************************
\r
337 public void styleSelected(String style) {
\r
338 QApplication.setStyle(style);
\r
339 QApplication.setPalette(QApplication.style().standardPalette());
\r
341 public void standardPaletteChanged() {
\r
342 if (standardPalette.isChecked())
\r
343 QApplication.setPalette(QApplication.style().standardPalette());
\r
345 QApplication.setPalette(Global.originalPalette);
\r
350 //*****************************************
\r
351 //* automatic save timer
\r
352 //*****************************************
\r
353 public void setAutoSaveInterval(int len) {
\r
354 autoSaveInterval.setValue(len);
\r
356 public int getAutoSaveInterval() {
\r
357 return autoSaveInterval.value();
\r
361 //*****************************************
\r
362 //* Get/Set tag behavior combo box
\r
363 //*****************************************
\r
364 public void setTagBehavior(String value) {
\r
365 for (int i=0; i<tagBehavior.count(); i++) {
\r
366 String d = tagBehavior.itemData(i).toString();
\r
367 if (value.equalsIgnoreCase(d)) {
\r
368 tagBehavior.setCurrentIndex(i);
\r
373 public String getTagBehavior() {
\r
374 int i = tagBehavior.currentIndex();
\r
375 return tagBehavior.itemData(i).toString();
\r
378 //*****************************************
\r
379 //* Mimic Evernote Selection
\r
380 //*****************************************
\r
381 public boolean getMimicEvernote() {
\r
382 return mimicEvernote.isChecked();
\r
384 public void setMimicEvernote(boolean val) {
\r
385 mimicEvernote.setChecked(val);
\r
389 //*****************************************
\r
390 //* Mimic Evernote Selection
\r
391 //*****************************************
\r
392 public boolean getStartMinimized() {
\r
393 return startMinimized.isChecked();
\r
395 public void setStartMinimized(boolean val) {
\r
396 startMinimized.setChecked(val);
\r
400 //*****************************************
\r
401 //* Create Note With Selected Tags
\r
402 //*****************************************
\r
403 public boolean getNewNoteWithTags() {
\r
404 return newNoteWithTags.isChecked();
\r
406 public void setNewNoteWithTags(boolean val) {
\r
407 newNoteWithTags.setChecked(val);
\r
410 //*****************************************
\r
411 //* Set tag selection behavior
\r
412 //*****************************************
\r
413 public boolean getAnyTagSelection() {
\r
414 return anyTagSelection.isChecked();
\r
416 public void setAnyTagSelection(boolean val) {
\r
417 anyTagSelection.setChecked(val);
\r
421 //*****************************************
\r
422 //* Include a tag's child when selecting a parent
\r
423 //*****************************************
\r
424 public boolean getIncludeTagChildren() {
\r
425 return includeTagChildren.isChecked();
\r
427 public void setIncludeTagChildren(boolean val) {
\r
428 includeTagChildren.setChecked(val);
\r