OSDN Git Service

Correct SQL due to database being split apart.
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / dialog / ConfigAppearancePage.java
1 /*\r
2  * This file is part of NeverNote \r
3  * Copyright 2009 Randy Baumgarte\r
4  * \r
5  * This file may be licensed under the terms of of the\r
6  * GNU General Public License Version 2 (the ``GPL'').\r
7  *\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
12  *\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
17  *\r
18 */\r
19 \r
20 package cx.fbn.nevernote.dialog;\r
21 \r
22 import java.util.ArrayList;\r
23 import java.util.List;\r
24 \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
36 \r
37 import cx.fbn.nevernote.Global;\r
38 \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
55         \r
56         private final List<String> tformats;\r
57         private final List<String> dformats;\r
58         \r
59         public ConfigAppearancePage(QWidget parent) {\r
60 //              super(parent);\r
61                 \r
62                 dformats = new ArrayList<String>();\r
63                 tformats = new ArrayList<String>();\r
64                 \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
75                 \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
86 \r
87                 \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
94                 \r
95                 standardPalette = new QCheckBox();\r
96                 standardPalette.setText(tr("Use standard palette"));\r
97                 standardPalette.clicked.connect(this, "standardPaletteChanged()");\r
98 \r
99                 QFormLayout styleLayout = new QFormLayout();\r
100                 styleLayout.addWidget(styleFormat);\r
101                 styleLayout.addWidget(standardPalette);\r
102                 \r
103                 styleGroup.setLayout(styleLayout);\r
104 \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
111                 \r
112                 QFormLayout tagLayout = new QFormLayout();\r
113                 tagLayout.addWidget(tagBehavior);\r
114                 tagBehaviorGroup.setLayout(tagLayout);\r
115                 \r
116                 \r
117                 \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
123                 }\r
124                 \r
125                 timeFormat = new QComboBox();           \r
126                 for (int i=0; i<tformats.size(); i++) {\r
127                         timeFormat.addItem(tr(tformats.get(i)));\r
128                 }\r
129 \r
130                 QFormLayout formatLayout = new QFormLayout();\r
131                 formatLayout.addWidget(dateFormat);\r
132                 formatLayout.addWidget(timeFormat);\r
133                 datetimeGroup.setLayout(formatLayout);\r
134                 \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
144                 \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
151                 \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
168                 \r
169                 showTrayIcon.clicked.connect(this, "showTrayIconClicked(Boolean)");\r
170                 showTrayIconClicked(showTrayIcon.isChecked());\r
171 \r
172 \r
173         }\r
174         \r
175         private void showTrayIconClicked(Boolean checked) {\r
176                 if (!checked) {\r
177                         minimizeOnClose.setEnabled(false);\r
178                         minimizeOnClose.setChecked(false);\r
179                 } else\r
180                         minimizeOnClose.setEnabled(true);\r
181         }\r
182 \r
183         \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
192                 }\r
193         }\r
194         public String getDateFormat() {\r
195                 int i = dateFormat.currentIndex();\r
196                 return dateFormat.itemText(i);  \r
197         }\r
198         \r
199 \r
200         \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
211                                 return;\r
212                         }\r
213                 }\r
214         }\r
215         public String getTimeFormat() {\r
216                 int i = timeFormat.currentIndex();\r
217                 return timeFormat.itemText(i);  \r
218         }\r
219 \r
220         \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
227                         if (d.equals(id))\r
228                                 styleFormat.setCurrentIndex(i);\r
229                 }\r
230         }\r
231         public String getStyle() {\r
232                 int i = styleFormat.currentIndex();\r
233                 return styleFormat.itemText(i); \r
234         }\r
235         \r
236         //*****************************************\r
237         //* palette style get/set methods \r
238         //*****************************************\r
239         public void setStandardPalette(boolean value) {\r
240                 standardPalette.setChecked(value);\r
241         }\r
242         public boolean getStandardPalette() {\r
243                 return standardPalette.isChecked();     \r
244         }\r
245         \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
252         }\r
253         public boolean getShowTrayIcon() {\r
254                 return showTrayIcon.isChecked();\r
255         }\r
256         \r
257         \r
258         //*******************************************\r
259         //* minimize on close get/set\r
260         //*******************************************\r
261         public void setMinimizeOnClose(boolean val) {\r
262                 minimizeOnClose.setChecked(val);        \r
263         }\r
264         public boolean getMinimizeOnClose() {\r
265                 return minimizeOnClose.isChecked();\r
266         }\r
267         \r
268         \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
274         }\r
275         public boolean getShowSplashScreen() {\r
276                 return showSplashScreen.isChecked();\r
277         }\r
278         \r
279         //*******************************************\r
280         //* verify deletes get/set\r
281         //*******************************************\r
282         public void setVerifyDelete(boolean val) {\r
283                 verifyDelete.setChecked(val);   \r
284         }\r
285         public boolean getVerifyDelete() {\r
286                 return verifyDelete.isChecked();\r
287         }\r
288         \r
289         \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
295         }\r
296         public boolean getPdfPreview() {\r
297                 return pdfPreview.isChecked();\r
298         }\r
299         \r
300         //*******************************************\r
301         //* check for updates get/set\r
302         //*******************************************\r
303         public void setCheckForUpdates(boolean val) {\r
304                 checkForUpdates.setChecked(val);        \r
305         }\r
306         public boolean getCheckForUpdates() {\r
307                 return checkForUpdates.isChecked();\r
308         }\r
309 \r
310         \r
311         //********************************************\r
312         //* Listeners for palette & style changes\r
313         //********************************************\r
314         \r
315         public void styleSelected(String style) {\r
316                 QApplication.setStyle(style);\r
317                 QApplication.setPalette(QApplication.style().standardPalette());\r
318         }\r
319         \r
320         public void standardPaletteChanged() {\r
321                 if (standardPalette.isChecked())\r
322                         QApplication.setPalette(QApplication.style().standardPalette());\r
323                 else\r
324                         QApplication.setPalette(Global.originalPalette);\r
325                         \r
326         }\r
327 \r
328         \r
329         //*****************************************\r
330         //* automatic save timer\r
331         //*****************************************\r
332         public void setAutoSaveInterval(int len) {\r
333                 autoSaveInterval.setValue(len);\r
334         }\r
335         public int getAutoSaveInterval() {\r
336                 return autoSaveInterval.value();        \r
337         }\r
338 \r
339         \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
348                                 return;\r
349                         }\r
350                 }\r
351         }\r
352         public String getTagBehavior() {\r
353                 int i = tagBehavior.currentIndex();\r
354                 return tagBehavior.itemData(i).toString();\r
355         }\r
356 \r
357         //*****************************************\r
358         //* Mimic Evernote Selection\r
359         //*****************************************\r
360         public boolean getMimicEvernote() {\r
361                 return mimicEvernote.isChecked();\r
362         }\r
363         public void setMimicEvernote(boolean val) {\r
364                 mimicEvernote.setChecked(val);\r
365         }\r
366 \r
367         \r
368         //*****************************************\r
369         //* Mimic Evernote Selection\r
370         //*****************************************\r
371         public boolean getStartMinimized() {\r
372                 return startMinimized.isChecked();\r
373         }\r
374         public void setStartMinimized(boolean val) {\r
375                 startMinimized.setChecked(val);\r
376         }\r
377 \r
378 \r
379         //*****************************************\r
380         //* Create Note With Selected Tags\r
381         //*****************************************\r
382         public boolean getNewNoteWithTags() {\r
383                 return newNoteWithTags.isChecked();\r
384         }\r
385         public void setNewNoteWithTags(boolean val) {\r
386                 newNoteWithTags.setChecked(val);\r
387         }\r
388 \r
389 }\r