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 QSpinBox autoSaveInterval;
\r
53 private final List<String> tformats;
\r
54 private final List<String> dformats;
\r
56 public ConfigAppearancePage(QWidget parent) {
\r
59 dformats = new ArrayList<String>();
\r
60 tformats = new ArrayList<String>();
\r
62 dformats.add("MM/dd/yy - 12/31/09");
\r
63 dformats.add("MM/dd/yyyy - 12/31/2009");
\r
64 dformats.add("dd/MM/yy - 31/12/09");
\r
65 dformats.add("dd/MM/yyyy - 31/12/2009");
\r
66 dformats.add("yyyy/MM/dd - 2009/12/31");
\r
67 dformats.add("yy/MM/dd - 9/12/31");
\r
69 tformats.add("HH:mm:ss - 2:13:01");
\r
70 tformats.add("HH:mm:ss a - 2:13:01 am");
\r
71 tformats.add("HH:mm - 2:13");
\r
72 tformats.add("HH:mm a - 2:13 am");
\r
75 // Style sheet formats
\r
76 List<String> styles = QStyleFactory.keys();
\r
77 QGroupBox styleGroup = new QGroupBox(tr("GUI Style"));
\r
78 styleFormat = new QComboBox();
\r
79 styleFormat.addItems(styles);
\r
80 styleFormat.activated.connect(this, "styleSelected(String)");
\r
82 standardPalette = new QCheckBox();
\r
83 standardPalette.setText(tr("Use standard palette"));
\r
84 standardPalette.clicked.connect(this, "standardPaletteChanged()");
\r
86 QFormLayout styleLayout = new QFormLayout();
\r
87 styleLayout.addWidget(styleFormat);
\r
88 styleLayout.addWidget(standardPalette);
\r
90 styleGroup.setLayout(styleLayout);
\r
92 QGroupBox tagBehaviorGroup = new QGroupBox(tr("Tag Behavior"));
\r
93 tagBehavior = new QComboBox();
\r
94 tagBehavior.addItem(tr("Do nothing"),"DoNothing");
\r
95 tagBehavior.addItem(tr("Count tags & do not hide inactive"),"NoHideInactiveCount");
\r
96 tagBehavior.addItem(tr("Count tags & hide inactive"),"HideInactiveCount");
\r
97 tagBehavior.addItem(tr("Color active tags"),"ColorActive");
\r
99 QFormLayout tagLayout = new QFormLayout();
\r
100 tagLayout.addWidget(tagBehavior);
\r
101 tagBehaviorGroup.setLayout(tagLayout);
\r
105 // Date/Time settings
\r
106 QGroupBox datetimeGroup = new QGroupBox(tr("Date/Time Format"));
\r
107 dateFormat = new QComboBox();
\r
108 for (int i=0; i<dformats.size(); i++) {
\r
109 dateFormat.addItem(tr(dformats.get(i)));
\r
112 timeFormat = new QComboBox();
\r
113 for (int i=0; i<tformats.size(); i++) {
\r
114 timeFormat.addItem(tr(tformats.get(i)));
\r
117 QFormLayout formatLayout = new QFormLayout();
\r
118 formatLayout.addWidget(dateFormat);
\r
119 formatLayout.addWidget(timeFormat);
\r
120 datetimeGroup.setLayout(formatLayout);
\r
122 mimicEvernote = new QCheckBox(tr("Mimic Evernote Selection Behavior (Requires Restart)"));
\r
123 showSplashScreen = new QCheckBox(tr("Show Splash Screen on Startup"));
\r
124 showTrayIcon = new QCheckBox(tr("Show Tray Icon"));
\r
125 verifyDelete = new QCheckBox(tr("Verify Deletes"));
\r
126 pdfPreview = new QCheckBox(tr("Display PDF Documents Inline"));
\r
127 newNoteWithTags = new QCheckBox(tr("Create New Notes With Selected Tags"));
\r
129 QHBoxLayout autoSaveLayout = new QHBoxLayout();
\r
130 autoSaveLayout.addWidget(new QLabel(tr("Automatic Save Interval (in Minutes)")));
\r
131 autoSaveInterval = new QSpinBox();
\r
132 autoSaveLayout.addWidget(autoSaveInterval);
\r
133 autoSaveInterval.setMaximum(1440);
\r
134 autoSaveInterval.setMinimum(0);
\r
136 QVBoxLayout mainLayout = new QVBoxLayout();
\r
137 mainLayout.addWidget(styleGroup);
\r
138 mainLayout.addWidget(datetimeGroup);
\r
139 mainLayout.addLayout(autoSaveLayout);
\r
140 mainLayout.addWidget(tagBehaviorGroup);
\r
141 mainLayout.addWidget(mimicEvernote);
\r
142 mainLayout.addWidget(showTrayIcon);
\r
143 mainLayout.addWidget(showSplashScreen);
\r
144 mainLayout.addWidget(verifyDelete);
\r
145 mainLayout.addWidget(pdfPreview);
\r
146 mainLayout.addWidget(newNoteWithTags);
\r
147 mainLayout.addStretch(1);
\r
148 setLayout(mainLayout);
\r
154 //*****************************************
\r
155 //* date format get/set methods
\r
156 //*****************************************
\r
157 public void setDateFormat(String id) {
\r
158 for (int i=0; i<dformats.size(); i++) {
\r
159 String d = dformats.get(i);
\r
160 if (d.substring(0,id.length()).equals(id))
\r
161 dateFormat.setCurrentIndex(i);
\r
164 public String getDateFormat() {
\r
165 int i = dateFormat.currentIndex();
\r
166 return dateFormat.itemText(i);
\r
171 //*****************************************
\r
172 //* time format get/set methods
\r
173 //*****************************************
\r
174 public void setTimeFormat(String id) {
\r
175 for (int i=0; i<tformats.size(); i++) {
\r
176 String d = tformats.get(i);
\r
177 int dash = d.indexOf("-");
\r
178 d = d.substring(0,dash-1);
\r
179 if (d.equals(id)) {
\r
180 timeFormat.setCurrentIndex(i);
\r
185 public String getTimeFormat() {
\r
186 int i = timeFormat.currentIndex();
\r
187 return timeFormat.itemText(i);
\r
191 //*****************************************
\r
192 //* gui style format get/set methods
\r
193 //*****************************************
\r
194 public void setStyle(String id) {
\r
195 for (int i=0; i<styleFormat.count(); i++) {
\r
196 String d = styleFormat.itemText(i);
\r
198 styleFormat.setCurrentIndex(i);
\r
201 public String getStyle() {
\r
202 int i = styleFormat.currentIndex();
\r
203 return styleFormat.itemText(i);
\r
206 //*****************************************
\r
207 //* palette style get/set methods
\r
208 //*****************************************
\r
209 public void setStandardPalette(boolean value) {
\r
210 standardPalette.setChecked(value);
\r
212 public boolean getStandardPalette() {
\r
213 return standardPalette.isChecked();
\r
216 //*******************************************
\r
217 //* Show/Hide tray icon get/set
\r
218 //*******************************************
\r
219 public void setShowTrayIcon(boolean val) {
\r
220 showTrayIcon.setChecked(val);
\r
222 public boolean getShowTrayIcon() {
\r
223 return showTrayIcon.isChecked();
\r
227 //*****************************************
\r
228 //* Show the splash screen on startup
\r
229 //*****************************************
\r
230 public void setShowSplashScreen(boolean val) {
\r
231 showSplashScreen.setChecked(val);
\r
233 public boolean getShowSplashScreen() {
\r
234 return showSplashScreen.isChecked();
\r
237 //*******************************************
\r
238 //* verify deletes get/set
\r
239 //*******************************************
\r
240 public void setVerifyDelete(boolean val) {
\r
241 verifyDelete.setChecked(val);
\r
243 public boolean getVerifyDelete() {
\r
244 return verifyDelete.isChecked();
\r
248 //*******************************************
\r
249 //* Show/Hide tray icon get/set
\r
250 //*******************************************
\r
251 public void setPdfPreview(boolean val) {
\r
252 pdfPreview.setChecked(val);
\r
254 public boolean getPdfPreview() {
\r
255 return pdfPreview.isChecked();
\r
259 //********************************************
\r
260 //* Listeners for palette & style changes
\r
261 //********************************************
\r
263 public void styleSelected(String style) {
\r
264 QApplication.setStyle(style);
\r
265 QApplication.setPalette(QApplication.style().standardPalette());
\r
268 public void standardPaletteChanged() {
\r
269 if (standardPalette.isChecked())
\r
270 QApplication.setPalette(QApplication.style().standardPalette());
\r
272 QApplication.setPalette(Global.originalPalette);
\r
277 //*****************************************
\r
278 //* automatic save timer
\r
279 //*****************************************
\r
280 public void setAutoSaveInterval(int len) {
\r
281 autoSaveInterval.setValue(len);
\r
283 public int getAutoSaveInterval() {
\r
284 return autoSaveInterval.value();
\r
288 //*****************************************
\r
289 //* Get/Set tag behavior combo box
\r
290 //*****************************************
\r
291 public void setTagBehavior(String value) {
\r
292 for (int i=0; i<tagBehavior.count(); i++) {
\r
293 String d = tagBehavior.itemData(i).toString();
\r
294 if (value.equalsIgnoreCase(d)) {
\r
295 tagBehavior.setCurrentIndex(i);
\r
300 public String getTagBehavior() {
\r
301 int i = tagBehavior.currentIndex();
\r
302 return tagBehavior.itemData(i).toString();
\r
305 //*****************************************
\r
306 //* Mimic Evernote Selection
\r
307 //*****************************************
\r
308 public boolean getMimicEvernote() {
\r
309 return mimicEvernote.isChecked();
\r
311 public void setMimicEvernote(boolean val) {
\r
312 mimicEvernote.setChecked(val);
\r
316 //*****************************************
\r
317 //* Create Note With Selected Tags
\r
318 //*****************************************
\r
319 public boolean getNewNoteWithTags() {
\r
320 return newNoteWithTags.isChecked();
\r
322 public void setNewNoteWithTags(boolean val) {
\r
323 newNoteWithTags.setChecked(val);
\r