2 * This file is part of NeverNote
\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.gui.QApplication;
\r
26 import com.trolltech.qt.gui.QCheckBox;
\r
27 import com.trolltech.qt.gui.QComboBox;
\r
28 import com.trolltech.qt.gui.QFormLayout;
\r
29 import com.trolltech.qt.gui.QGroupBox;
\r
30 import com.trolltech.qt.gui.QHBoxLayout;
\r
31 import com.trolltech.qt.gui.QLabel;
\r
32 import com.trolltech.qt.gui.QSpinBox;
\r
33 import com.trolltech.qt.gui.QStyleFactory;
\r
34 import com.trolltech.qt.gui.QVBoxLayout;
\r
35 import com.trolltech.qt.gui.QWidget;
\r
37 import cx.fbn.nevernote.Global;
\r
39 public class ConfigAppearancePage extends QWidget {
\r
40 private final QComboBox dateFormat;
\r
41 private final QComboBox timeFormat;
\r
42 private final QComboBox styleFormat;
\r
43 private final QComboBox tagBehavior;
\r
44 private final QCheckBox standardPalette;
\r
45 private final QCheckBox showSplashScreen;
\r
46 private final QCheckBox showTrayIcon;
\r
47 private final QCheckBox verifyDelete;
\r
48 private final QCheckBox pdfPreview;
\r
49 private final QCheckBox checkForUpdates;
\r
50 private final QCheckBox newNoteWithTags;
\r
51 private final QCheckBox mimicEvernote;
\r
52 private final QCheckBox startMinimized;
\r
53 private final QCheckBox minimizeOnClose;
\r
54 private final QSpinBox autoSaveInterval;
\r
56 private final List<String> tformats;
\r
57 private final List<String> dformats;
\r
59 public ConfigAppearancePage(QWidget parent) {
\r
62 dformats = new ArrayList<String>();
\r
63 tformats = new ArrayList<String>();
\r
65 dformats.add("MM/dd/yy - 02/03/09");
\r
66 dformats.add("MM/dd/yyyy - 02/03/2009");
\r
67 dformats.add("M/dd/yyyy - 2/03/2009");
\r
68 dformats.add("M/d/yyyy - 2/3/2009");
\r
69 dformats.add("dd/MM/yy - 03/02/09");
\r
70 dformats.add("d/M/yy - 3/2/09");
\r
71 dformats.add("dd/MM/yyyy - 03/02/2009");
\r
72 dformats.add("d/M/yyyy - 3/2/2009");
\r
73 dformats.add("yyyy/MM/dd - 2009/02/03");
\r
74 dformats.add("yy/MM/dd - 09/02/03");
\r
76 tformats.add("HH:mm:ss - 18:13:01");
\r
77 tformats.add("HH:mm:ss a - 18:13:01 pm");
\r
78 tformats.add("HH:mm - 18:13");
\r
79 tformats.add("HH:mm a - 18:13 pm");
\r
80 tformats.add("hh:mm:ss - 06:13:01");
\r
81 tformats.add("hh:mm:ss a - 06:13:01 pm");
\r
82 tformats.add("h:mm:ss a - 6:13:01 pm");
\r
83 tformats.add("hh:mm - 06:13");
\r
84 tformats.add("hh:mm a - 06:13 pm");
\r
85 tformats.add("h:mm a - 6:13 pm");
\r
88 // Style sheet formats
\r
89 List<String> styles = QStyleFactory.keys();
\r
90 QGroupBox styleGroup = new QGroupBox(tr("GUI Style"));
\r
91 styleFormat = new QComboBox();
\r
92 styleFormat.addItems(styles);
\r
93 styleFormat.activated.connect(this, "styleSelected(String)");
\r
95 standardPalette = new QCheckBox();
\r
96 standardPalette.setText(tr("Use standard palette"));
\r
97 standardPalette.clicked.connect(this, "standardPaletteChanged()");
\r
99 QFormLayout styleLayout = new QFormLayout();
\r
100 styleLayout.addWidget(styleFormat);
\r
101 styleLayout.addWidget(standardPalette);
\r
103 styleGroup.setLayout(styleLayout);
\r
105 QGroupBox tagBehaviorGroup = new QGroupBox(tr("Tag Behavior"));
\r
106 tagBehavior = new QComboBox();
\r
107 tagBehavior.addItem(tr("Do nothing"),"DoNothing");
\r
108 tagBehavior.addItem(tr("Count tags & do not hide inactive"),"NoHideInactiveCount");
\r
109 tagBehavior.addItem(tr("Count tags & hide inactive"),"HideInactiveCount");
\r
110 tagBehavior.addItem(tr("Color active tags"),"ColorActive");
\r
112 QFormLayout tagLayout = new QFormLayout();
\r
113 tagLayout.addWidget(tagBehavior);
\r
114 tagBehaviorGroup.setLayout(tagLayout);
\r
118 // Date/Time settings
\r
119 QGroupBox datetimeGroup = new QGroupBox(tr("Date/Time Format"));
\r
120 dateFormat = new QComboBox();
\r
121 for (int i=0; i<dformats.size(); i++) {
\r
122 dateFormat.addItem(tr(dformats.get(i)));
\r
125 timeFormat = new QComboBox();
\r
126 for (int i=0; i<tformats.size(); i++) {
\r
127 timeFormat.addItem(tr(tformats.get(i)));
\r
130 QFormLayout formatLayout = new QFormLayout();
\r
131 formatLayout.addWidget(dateFormat);
\r
132 formatLayout.addWidget(timeFormat);
\r
133 datetimeGroup.setLayout(formatLayout);
\r
135 mimicEvernote = new QCheckBox(tr("Mimic Evernote Selection Behavior (Requires Restart)"));
\r
136 showSplashScreen = new QCheckBox(tr("Show Splash Screen on Startup"));
\r
137 showTrayIcon = new QCheckBox(tr("Minimize To Tray"));
\r
138 minimizeOnClose = new QCheckBox(tr("Minimize On Close"));
\r
139 verifyDelete = new QCheckBox(tr("Verify Deletes"));
\r
140 startMinimized = new QCheckBox(tr("Start Minimized"));
\r
141 pdfPreview = new QCheckBox(tr("Display PDF Documents Inline"));
\r
142 checkForUpdates = new QCheckBox(tr("Check For Updates At Startup"));
\r
143 newNoteWithTags = new QCheckBox(tr("Create New Notes With Selected Tags"));
\r
145 QHBoxLayout autoSaveLayout = new QHBoxLayout();
\r
146 autoSaveLayout.addWidget(new QLabel(tr("Automatic Save Interval (in Minutes)")));
\r
147 autoSaveInterval = new QSpinBox();
\r
148 autoSaveLayout.addWidget(autoSaveInterval);
\r
149 autoSaveInterval.setMaximum(1440);
\r
150 autoSaveInterval.setMinimum(0);
\r
152 QVBoxLayout mainLayout = new QVBoxLayout();
\r
153 mainLayout.addWidget(styleGroup);
\r
154 mainLayout.addWidget(datetimeGroup);
\r
155 mainLayout.addLayout(autoSaveLayout);
\r
156 mainLayout.addWidget(tagBehaviorGroup);
\r
157 mainLayout.addWidget(mimicEvernote);
\r
158 mainLayout.addWidget(showTrayIcon);
\r
159 mainLayout.addWidget(minimizeOnClose);
\r
160 mainLayout.addWidget(startMinimized);
\r
161 mainLayout.addWidget(showSplashScreen);
\r
162 mainLayout.addWidget(verifyDelete);
\r
163 mainLayout.addWidget(pdfPreview);
\r
164 mainLayout.addWidget(newNoteWithTags);
\r
165 mainLayout.addWidget(checkForUpdates);
\r
166 mainLayout.addStretch(1);
\r
167 setLayout(mainLayout);
\r
169 showTrayIcon.clicked.connect(this, "showTrayIconClicked(Boolean)");
\r
170 showTrayIconClicked(showTrayIcon.isChecked());
\r
175 private void showTrayIconClicked(Boolean checked) {
\r
177 minimizeOnClose.setEnabled(false);
\r
178 minimizeOnClose.setChecked(false);
\r
180 minimizeOnClose.setEnabled(true);
\r
184 //*****************************************
\r
185 //* date format get/set methods
\r
186 //*****************************************
\r
187 public void setDateFormat(String id) {
\r
188 for (int i=0; i<dformats.size(); i++) {
\r
189 String d = dformats.get(i);
\r
190 if (d.substring(0,id.length()).equals(id))
\r
191 dateFormat.setCurrentIndex(i);
\r
194 public String getDateFormat() {
\r
195 int i = dateFormat.currentIndex();
\r
196 return dateFormat.itemText(i);
\r
201 //*****************************************
\r
202 //* time format get/set methods
\r
203 //*****************************************
\r
204 public void setTimeFormat(String id) {
\r
205 for (int i=0; i<tformats.size(); i++) {
\r
206 String d = tformats.get(i);
\r
207 int dash = d.indexOf("-");
\r
208 d = d.substring(0,dash-1);
\r
209 if (d.equals(id)) {
\r
210 timeFormat.setCurrentIndex(i);
\r
215 public String getTimeFormat() {
\r
216 int i = timeFormat.currentIndex();
\r
217 return timeFormat.itemText(i);
\r
221 //*****************************************
\r
222 //* gui style format get/set methods
\r
223 //*****************************************
\r
224 public void setStyle(String id) {
\r
225 for (int i=0; i<styleFormat.count(); i++) {
\r
226 String d = styleFormat.itemText(i);
\r
228 styleFormat.setCurrentIndex(i);
\r
231 public String getStyle() {
\r
232 int i = styleFormat.currentIndex();
\r
233 return styleFormat.itemText(i);
\r
236 //*****************************************
\r
237 //* palette style get/set methods
\r
238 //*****************************************
\r
239 public void setStandardPalette(boolean value) {
\r
240 standardPalette.setChecked(value);
\r
242 public boolean getStandardPalette() {
\r
243 return standardPalette.isChecked();
\r
246 //*******************************************
\r
247 //* Show/Hide tray icon get/set
\r
248 //*******************************************
\r
249 public void setShowTrayIcon(boolean val) {
\r
250 showTrayIcon.setChecked(val);
\r
251 showTrayIconClicked(showTrayIcon.isChecked());
\r
253 public boolean getShowTrayIcon() {
\r
254 return showTrayIcon.isChecked();
\r
258 //*******************************************
\r
259 //* minimize on close get/set
\r
260 //*******************************************
\r
261 public void setMinimizeOnClose(boolean val) {
\r
262 minimizeOnClose.setChecked(val);
\r
264 public boolean getMinimizeOnClose() {
\r
265 return minimizeOnClose.isChecked();
\r
269 //*****************************************
\r
270 //* Show the splash screen on startup
\r
271 //*****************************************
\r
272 public void setShowSplashScreen(boolean val) {
\r
273 showSplashScreen.setChecked(val);
\r
275 public boolean getShowSplashScreen() {
\r
276 return showSplashScreen.isChecked();
\r
279 //*******************************************
\r
280 //* verify deletes get/set
\r
281 //*******************************************
\r
282 public void setVerifyDelete(boolean val) {
\r
283 verifyDelete.setChecked(val);
\r
285 public boolean getVerifyDelete() {
\r
286 return verifyDelete.isChecked();
\r
290 //*******************************************
\r
291 //* Show/Hide tray icon get/set
\r
292 //*******************************************
\r
293 public void setPdfPreview(boolean val) {
\r
294 pdfPreview.setChecked(val);
\r
296 public boolean getPdfPreview() {
\r
297 return pdfPreview.isChecked();
\r
300 //*******************************************
\r
301 //* check for updates get/set
\r
302 //*******************************************
\r
303 public void setCheckForUpdates(boolean val) {
\r
304 checkForUpdates.setChecked(val);
\r
306 public boolean getCheckForUpdates() {
\r
307 return checkForUpdates.isChecked();
\r
311 //********************************************
\r
312 //* Listeners for palette & style changes
\r
313 //********************************************
\r
315 public void styleSelected(String style) {
\r
316 QApplication.setStyle(style);
\r
317 QApplication.setPalette(QApplication.style().standardPalette());
\r
320 public void standardPaletteChanged() {
\r
321 if (standardPalette.isChecked())
\r
322 QApplication.setPalette(QApplication.style().standardPalette());
\r
324 QApplication.setPalette(Global.originalPalette);
\r
329 //*****************************************
\r
330 //* automatic save timer
\r
331 //*****************************************
\r
332 public void setAutoSaveInterval(int len) {
\r
333 autoSaveInterval.setValue(len);
\r
335 public int getAutoSaveInterval() {
\r
336 return autoSaveInterval.value();
\r
340 //*****************************************
\r
341 //* Get/Set tag behavior combo box
\r
342 //*****************************************
\r
343 public void setTagBehavior(String value) {
\r
344 for (int i=0; i<tagBehavior.count(); i++) {
\r
345 String d = tagBehavior.itemData(i).toString();
\r
346 if (value.equalsIgnoreCase(d)) {
\r
347 tagBehavior.setCurrentIndex(i);
\r
352 public String getTagBehavior() {
\r
353 int i = tagBehavior.currentIndex();
\r
354 return tagBehavior.itemData(i).toString();
\r
357 //*****************************************
\r
358 //* Mimic Evernote Selection
\r
359 //*****************************************
\r
360 public boolean getMimicEvernote() {
\r
361 return mimicEvernote.isChecked();
\r
363 public void setMimicEvernote(boolean val) {
\r
364 mimicEvernote.setChecked(val);
\r
368 //*****************************************
\r
369 //* Mimic Evernote Selection
\r
370 //*****************************************
\r
371 public boolean getStartMinimized() {
\r
372 return startMinimized.isChecked();
\r
374 public void setStartMinimized(boolean val) {
\r
375 startMinimized.setChecked(val);
\r
379 //*****************************************
\r
380 //* Create Note With Selected Tags
\r
381 //*****************************************
\r
382 public boolean getNewNoteWithTags() {
\r
383 return newNoteWithTags.isChecked();
\r
385 public void setNewNoteWithTags(boolean val) {
\r
386 newNoteWithTags.setChecked(val);
\r