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 newNoteWithTags;
\r
50 private final QCheckBox mimicEvernote;
\r
51 private final QCheckBox startMinimized;
\r
52 private final QCheckBox minimizeOnClose;
\r
53 private final QSpinBox autoSaveInterval;
\r
55 private final List<String> tformats;
\r
56 private final List<String> dformats;
\r
58 public ConfigAppearancePage(QWidget parent) {
\r
61 dformats = new ArrayList<String>();
\r
62 tformats = new ArrayList<String>();
\r
64 dformats.add("MM/dd/yy - 02/03/09");
\r
65 dformats.add("MM/dd/yyyy - 02/03/2009");
\r
66 dformats.add("M/dd/yyyy - 2/03/2009");
\r
67 dformats.add("M/d/yyyy - 2/3/2009");
\r
68 dformats.add("dd/MM/yy - 03/02/09");
\r
69 dformats.add("d/M/yy - 3/2/09");
\r
70 dformats.add("dd/MM/yyyy - 03/02/2009");
\r
71 dformats.add("d/M/yyyy - 3/2/2009");
\r
72 dformats.add("yyyy/MM/dd - 2009/02/03");
\r
73 dformats.add("yy/MM/dd - 09/02/03");
\r
75 tformats.add("HH:mm:ss - 18:13:01");
\r
76 tformats.add("HH:mm:ss a - 18:13:01 pm");
\r
77 tformats.add("HH:mm - 18:13");
\r
78 tformats.add("HH:mm a - 18:13 pm");
\r
79 tformats.add("hh:mm:ss - 06:13:01");
\r
80 tformats.add("hh:mm:ss a - 06:13:01 pm");
\r
81 tformats.add("h:mm:ss a - 6:13:01 pm");
\r
82 tformats.add("hh:mm - 06:13");
\r
83 tformats.add("hh:mm a - 06:13 pm");
\r
84 tformats.add("h:mm a - 6:13 pm");
\r
87 // Style sheet formats
\r
88 List<String> styles = QStyleFactory.keys();
\r
89 QGroupBox styleGroup = new QGroupBox(tr("GUI Style"));
\r
90 styleFormat = new QComboBox();
\r
91 styleFormat.addItems(styles);
\r
92 styleFormat.activated.connect(this, "styleSelected(String)");
\r
94 standardPalette = new QCheckBox();
\r
95 standardPalette.setText(tr("Use standard palette"));
\r
96 standardPalette.clicked.connect(this, "standardPaletteChanged()");
\r
98 QFormLayout styleLayout = new QFormLayout();
\r
99 styleLayout.addWidget(styleFormat);
\r
100 styleLayout.addWidget(standardPalette);
\r
102 styleGroup.setLayout(styleLayout);
\r
104 QGroupBox tagBehaviorGroup = new QGroupBox(tr("Tag Behavior"));
\r
105 tagBehavior = new QComboBox();
\r
106 tagBehavior.addItem(tr("Do nothing"),"DoNothing");
\r
107 tagBehavior.addItem(tr("Count tags & do not hide inactive"),"NoHideInactiveCount");
\r
108 tagBehavior.addItem(tr("Count tags & hide inactive"),"HideInactiveCount");
\r
109 tagBehavior.addItem(tr("Color active tags"),"ColorActive");
\r
111 QFormLayout tagLayout = new QFormLayout();
\r
112 tagLayout.addWidget(tagBehavior);
\r
113 tagBehaviorGroup.setLayout(tagLayout);
\r
117 // Date/Time settings
\r
118 QGroupBox datetimeGroup = new QGroupBox(tr("Date/Time Format"));
\r
119 dateFormat = new QComboBox();
\r
120 for (int i=0; i<dformats.size(); i++) {
\r
121 dateFormat.addItem(tr(dformats.get(i)));
\r
124 timeFormat = new QComboBox();
\r
125 for (int i=0; i<tformats.size(); i++) {
\r
126 timeFormat.addItem(tr(tformats.get(i)));
\r
129 QFormLayout formatLayout = new QFormLayout();
\r
130 formatLayout.addWidget(dateFormat);
\r
131 formatLayout.addWidget(timeFormat);
\r
132 datetimeGroup.setLayout(formatLayout);
\r
134 mimicEvernote = new QCheckBox(tr("Mimic Evernote Selection Behavior (Requires Restart)"));
\r
135 showSplashScreen = new QCheckBox(tr("Show Splash Screen on Startup"));
\r
136 showTrayIcon = new QCheckBox(tr("Minimize To Tray"));
\r
137 minimizeOnClose = new QCheckBox(tr("Minimize On Close"));
\r
138 verifyDelete = new QCheckBox(tr("Verify Deletes"));
\r
139 startMinimized = new QCheckBox(tr("Start Minimized"));
\r
140 pdfPreview = new QCheckBox(tr("Display PDF Documents Inline"));
\r
141 newNoteWithTags = new QCheckBox(tr("Create New Notes With Selected Tags"));
\r
143 QHBoxLayout autoSaveLayout = new QHBoxLayout();
\r
144 autoSaveLayout.addWidget(new QLabel(tr("Automatic Save Interval (in Minutes)")));
\r
145 autoSaveInterval = new QSpinBox();
\r
146 autoSaveLayout.addWidget(autoSaveInterval);
\r
147 autoSaveInterval.setMaximum(1440);
\r
148 autoSaveInterval.setMinimum(0);
\r
150 QVBoxLayout mainLayout = new QVBoxLayout();
\r
151 mainLayout.addWidget(styleGroup);
\r
152 mainLayout.addWidget(datetimeGroup);
\r
153 mainLayout.addLayout(autoSaveLayout);
\r
154 mainLayout.addWidget(tagBehaviorGroup);
\r
155 mainLayout.addWidget(mimicEvernote);
\r
156 mainLayout.addWidget(showTrayIcon);
\r
157 mainLayout.addWidget(minimizeOnClose);
\r
158 mainLayout.addWidget(startMinimized);
\r
159 mainLayout.addWidget(showSplashScreen);
\r
160 mainLayout.addWidget(verifyDelete);
\r
161 mainLayout.addWidget(pdfPreview);
\r
162 mainLayout.addWidget(newNoteWithTags);
\r
163 mainLayout.addStretch(1);
\r
164 setLayout(mainLayout);
\r
166 showTrayIcon.clicked.connect(this, "showTrayIconClicked(Boolean)");
\r
167 showTrayIconClicked(showTrayIcon.isChecked());
\r
172 private void showTrayIconClicked(Boolean checked) {
\r
174 minimizeOnClose.setEnabled(false);
\r
175 minimizeOnClose.setChecked(false);
\r
177 minimizeOnClose.setEnabled(true);
\r
181 //*****************************************
\r
182 //* date format get/set methods
\r
183 //*****************************************
\r
184 public void setDateFormat(String id) {
\r
185 for (int i=0; i<dformats.size(); i++) {
\r
186 String d = dformats.get(i);
\r
187 if (d.substring(0,id.length()).equals(id))
\r
188 dateFormat.setCurrentIndex(i);
\r
191 public String getDateFormat() {
\r
192 int i = dateFormat.currentIndex();
\r
193 return dateFormat.itemText(i);
\r
198 //*****************************************
\r
199 //* time format get/set methods
\r
200 //*****************************************
\r
201 public void setTimeFormat(String id) {
\r
202 for (int i=0; i<tformats.size(); i++) {
\r
203 String d = tformats.get(i);
\r
204 int dash = d.indexOf("-");
\r
205 d = d.substring(0,dash-1);
\r
206 if (d.equals(id)) {
\r
207 timeFormat.setCurrentIndex(i);
\r
212 public String getTimeFormat() {
\r
213 int i = timeFormat.currentIndex();
\r
214 return timeFormat.itemText(i);
\r
218 //*****************************************
\r
219 //* gui style format get/set methods
\r
220 //*****************************************
\r
221 public void setStyle(String id) {
\r
222 for (int i=0; i<styleFormat.count(); i++) {
\r
223 String d = styleFormat.itemText(i);
\r
225 styleFormat.setCurrentIndex(i);
\r
228 public String getStyle() {
\r
229 int i = styleFormat.currentIndex();
\r
230 return styleFormat.itemText(i);
\r
233 //*****************************************
\r
234 //* palette style get/set methods
\r
235 //*****************************************
\r
236 public void setStandardPalette(boolean value) {
\r
237 standardPalette.setChecked(value);
\r
239 public boolean getStandardPalette() {
\r
240 return standardPalette.isChecked();
\r
243 //*******************************************
\r
244 //* Show/Hide tray icon get/set
\r
245 //*******************************************
\r
246 public void setShowTrayIcon(boolean val) {
\r
247 showTrayIcon.setChecked(val);
\r
248 showTrayIconClicked(showTrayIcon.isChecked());
\r
250 public boolean getShowTrayIcon() {
\r
251 return showTrayIcon.isChecked();
\r
255 //*******************************************
\r
256 //* minimize on close get/set
\r
257 //*******************************************
\r
258 public void setMinimizeOnClose(boolean val) {
\r
259 minimizeOnClose.setChecked(val);
\r
261 public boolean getMinimizeOnClose() {
\r
262 return minimizeOnClose.isChecked();
\r
266 //*****************************************
\r
267 //* Show the splash screen on startup
\r
268 //*****************************************
\r
269 public void setShowSplashScreen(boolean val) {
\r
270 showSplashScreen.setChecked(val);
\r
272 public boolean getShowSplashScreen() {
\r
273 return showSplashScreen.isChecked();
\r
276 //*******************************************
\r
277 //* verify deletes get/set
\r
278 //*******************************************
\r
279 public void setVerifyDelete(boolean val) {
\r
280 verifyDelete.setChecked(val);
\r
282 public boolean getVerifyDelete() {
\r
283 return verifyDelete.isChecked();
\r
287 //*******************************************
\r
288 //* Show/Hide tray icon get/set
\r
289 //*******************************************
\r
290 public void setPdfPreview(boolean val) {
\r
291 pdfPreview.setChecked(val);
\r
293 public boolean getPdfPreview() {
\r
294 return pdfPreview.isChecked();
\r
298 //********************************************
\r
299 //* Listeners for palette & style changes
\r
300 //********************************************
\r
302 public void styleSelected(String style) {
\r
303 QApplication.setStyle(style);
\r
304 QApplication.setPalette(QApplication.style().standardPalette());
\r
307 public void standardPaletteChanged() {
\r
308 if (standardPalette.isChecked())
\r
309 QApplication.setPalette(QApplication.style().standardPalette());
\r
311 QApplication.setPalette(Global.originalPalette);
\r
316 //*****************************************
\r
317 //* automatic save timer
\r
318 //*****************************************
\r
319 public void setAutoSaveInterval(int len) {
\r
320 autoSaveInterval.setValue(len);
\r
322 public int getAutoSaveInterval() {
\r
323 return autoSaveInterval.value();
\r
327 //*****************************************
\r
328 //* Get/Set tag behavior combo box
\r
329 //*****************************************
\r
330 public void setTagBehavior(String value) {
\r
331 for (int i=0; i<tagBehavior.count(); i++) {
\r
332 String d = tagBehavior.itemData(i).toString();
\r
333 if (value.equalsIgnoreCase(d)) {
\r
334 tagBehavior.setCurrentIndex(i);
\r
339 public String getTagBehavior() {
\r
340 int i = tagBehavior.currentIndex();
\r
341 return tagBehavior.itemData(i).toString();
\r
344 //*****************************************
\r
345 //* Mimic Evernote Selection
\r
346 //*****************************************
\r
347 public boolean getMimicEvernote() {
\r
348 return mimicEvernote.isChecked();
\r
350 public void setMimicEvernote(boolean val) {
\r
351 mimicEvernote.setChecked(val);
\r
355 //*****************************************
\r
356 //* Mimic Evernote Selection
\r
357 //*****************************************
\r
358 public boolean getStartMinimized() {
\r
359 return startMinimized.isChecked();
\r
361 public void setStartMinimized(boolean val) {
\r
362 startMinimized.setChecked(val);
\r
366 //*****************************************
\r
367 //* Create Note With Selected Tags
\r
368 //*****************************************
\r
369 public boolean getNewNoteWithTags() {
\r
370 return newNoteWithTags.isChecked();
\r
372 public void setNewNoteWithTags(boolean val) {
\r
373 newNoteWithTags.setChecked(val);
\r