OSDN Git Service

Add logic to display stacks in notebook tree
[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 newNoteWithTags;\r
50         private final QCheckBox mimicEvernote;\r
51         private final QCheckBox startMinimized;\r
52         private final QSpinBox autoSaveInterval;\r
53         \r
54         private final List<String> tformats;\r
55         private final List<String> dformats;\r
56         \r
57         public ConfigAppearancePage(QWidget parent) {\r
58 //              super(parent);\r
59                 \r
60                 dformats = new ArrayList<String>();\r
61                 tformats = new ArrayList<String>();\r
62                 \r
63                 dformats.add("MM/dd/yy - 02/03/09");\r
64                 dformats.add("MM/dd/yyyy - 02/03/2009");\r
65                 dformats.add("M/dd/yyyy - 2/03/2009");\r
66                 dformats.add("M/d/yyyy - 2/3/2009");\r
67                 dformats.add("dd/MM/yy - 03/02/09");\r
68                 dformats.add("d/M/yy - 3/2/09");\r
69                 dformats.add("dd/MM/yyyy - 03/02/2009");\r
70                 dformats.add("d/M/yyyy - 3/2/2009");\r
71                 dformats.add("yyyy/MM/dd - 2009/02/03");\r
72                 dformats.add("yy/MM/dd - 09/02/03");\r
73                 \r
74                 tformats.add("HH:mm:ss - 18:13:01");\r
75                 tformats.add("HH:mm:ss a - 18:13:01 pm");\r
76                 tformats.add("HH:mm - 18:13");\r
77                 tformats.add("HH:mm a - 18:13 pm");\r
78                 tformats.add("hh:mm:ss - 06:13:01");\r
79                 tformats.add("hh:mm:ss a - 06:13:01 pm");\r
80                 tformats.add("h:mm:ss a - 6:13:01 pm");\r
81                 tformats.add("hh:mm - 06:13");\r
82                 tformats.add("hh:mm a - 06:13 pm");\r
83                 tformats.add("h:mm a - 6:13 pm");\r
84 \r
85                 \r
86                 // Style sheet formats\r
87                 List<String> styles = QStyleFactory.keys();\r
88                 QGroupBox styleGroup = new QGroupBox(tr("GUI Style"));\r
89                 styleFormat = new QComboBox();                          \r
90                 styleFormat.addItems(styles);\r
91                 styleFormat.activated.connect(this, "styleSelected(String)");\r
92                 \r
93                 standardPalette = new QCheckBox();\r
94                 standardPalette.setText(tr("Use standard palette"));\r
95                 standardPalette.clicked.connect(this, "standardPaletteChanged()");\r
96 \r
97                 QFormLayout styleLayout = new QFormLayout();\r
98                 styleLayout.addWidget(styleFormat);\r
99                 styleLayout.addWidget(standardPalette);\r
100                 \r
101                 styleGroup.setLayout(styleLayout);\r
102 \r
103                 QGroupBox tagBehaviorGroup = new QGroupBox(tr("Tag Behavior"));\r
104                 tagBehavior = new QComboBox();\r
105                 tagBehavior.addItem(tr("Do nothing"),"DoNothing");\r
106                 tagBehavior.addItem(tr("Count tags & do not hide inactive"),"NoHideInactiveCount");\r
107                 tagBehavior.addItem(tr("Count tags & hide inactive"),"HideInactiveCount");\r
108                 tagBehavior.addItem(tr("Color active tags"),"ColorActive");\r
109                 \r
110                 QFormLayout tagLayout = new QFormLayout();\r
111                 tagLayout.addWidget(tagBehavior);\r
112                 tagBehaviorGroup.setLayout(tagLayout);\r
113                 \r
114                 \r
115                 \r
116                 // Date/Time settings\r
117                 QGroupBox datetimeGroup = new QGroupBox(tr("Date/Time Format"));\r
118                 dateFormat = new QComboBox();                           \r
119                 for (int i=0; i<dformats.size(); i++) {\r
120                         dateFormat.addItem(tr(dformats.get(i)));\r
121                 }\r
122                 \r
123                 timeFormat = new QComboBox();           \r
124                 for (int i=0; i<tformats.size(); i++) {\r
125                         timeFormat.addItem(tr(tformats.get(i)));\r
126                 }\r
127 \r
128                 QFormLayout formatLayout = new QFormLayout();\r
129                 formatLayout.addWidget(dateFormat);\r
130                 formatLayout.addWidget(timeFormat);\r
131                 datetimeGroup.setLayout(formatLayout);\r
132                 \r
133                 mimicEvernote = new QCheckBox(tr("Mimic Evernote Selection Behavior (Requires Restart)"));\r
134                 showSplashScreen = new QCheckBox(tr("Show Splash Screen on Startup"));\r
135                 showTrayIcon = new QCheckBox(tr("Minimize To Tray"));\r
136                 verifyDelete = new QCheckBox(tr("Verify Deletes"));\r
137                 startMinimized = new QCheckBox(tr("Start Minimized"));\r
138                 pdfPreview = new QCheckBox(tr("Display PDF Documents Inline"));\r
139                 newNoteWithTags = new QCheckBox(tr("Create New Notes With Selected Tags"));\r
140                 \r
141                 QHBoxLayout autoSaveLayout = new QHBoxLayout();\r
142                 autoSaveLayout.addWidget(new QLabel(tr("Automatic Save Interval (in Minutes)")));\r
143                 autoSaveInterval = new QSpinBox();\r
144                 autoSaveLayout.addWidget(autoSaveInterval);\r
145                 autoSaveInterval.setMaximum(1440);\r
146                 autoSaveInterval.setMinimum(0);\r
147                 \r
148                 QVBoxLayout mainLayout = new QVBoxLayout();\r
149                 mainLayout.addWidget(styleGroup);\r
150                 mainLayout.addWidget(datetimeGroup);\r
151                 mainLayout.addLayout(autoSaveLayout);\r
152                 mainLayout.addWidget(tagBehaviorGroup);\r
153                 mainLayout.addWidget(mimicEvernote); \r
154                 mainLayout.addWidget(showTrayIcon);\r
155                 mainLayout.addWidget(startMinimized);\r
156                 mainLayout.addWidget(showSplashScreen);\r
157                 mainLayout.addWidget(verifyDelete);\r
158                 mainLayout.addWidget(pdfPreview);\r
159                 mainLayout.addWidget(newNoteWithTags);\r
160                 mainLayout.addStretch(1);\r
161                 setLayout(mainLayout);\r
162 \r
163 \r
164         }\r
165 \r
166         \r
167         //*****************************************\r
168         //* date format get/set methods \r
169         //*****************************************\r
170         public void setDateFormat(String id) {\r
171                 for (int i=0; i<dformats.size(); i++) {\r
172                         String d = dformats.get(i);\r
173                         if (d.substring(0,id.length()).equals(id))\r
174                                 dateFormat.setCurrentIndex(i);\r
175                 }\r
176         }\r
177         public String getDateFormat() {\r
178                 int i = dateFormat.currentIndex();\r
179                 return dateFormat.itemText(i);  \r
180         }\r
181         \r
182 \r
183         \r
184         //*****************************************\r
185         //* time format get/set methods \r
186         //*****************************************\r
187         public void setTimeFormat(String id) {\r
188                 for (int i=0; i<tformats.size(); i++) {\r
189                         String d = tformats.get(i);\r
190                         int dash = d.indexOf("-");\r
191                         d = d.substring(0,dash-1);\r
192                         if (d.equals(id)) {\r
193                                 timeFormat.setCurrentIndex(i);\r
194                                 return;\r
195                         }\r
196                 }\r
197         }\r
198         public String getTimeFormat() {\r
199                 int i = timeFormat.currentIndex();\r
200                 return timeFormat.itemText(i);  \r
201         }\r
202 \r
203         \r
204         //*****************************************\r
205         //* gui style format get/set methods \r
206         //*****************************************\r
207         public void setStyle(String id) {\r
208                 for (int i=0; i<styleFormat.count(); i++) {\r
209                         String d = styleFormat.itemText(i);\r
210                         if (d.equals(id))\r
211                                 styleFormat.setCurrentIndex(i);\r
212                 }\r
213         }\r
214         public String getStyle() {\r
215                 int i = styleFormat.currentIndex();\r
216                 return styleFormat.itemText(i); \r
217         }\r
218         \r
219         //*****************************************\r
220         //* palette style get/set methods \r
221         //*****************************************\r
222         public void setStandardPalette(boolean value) {\r
223                 standardPalette.setChecked(value);\r
224         }\r
225         public boolean getStandardPalette() {\r
226                 return standardPalette.isChecked();     \r
227         }\r
228         \r
229         //*******************************************\r
230         //* Show/Hide tray icon get/set\r
231         //*******************************************\r
232         public void setShowTrayIcon(boolean val) {\r
233                 showTrayIcon.setChecked(val);   \r
234         }\r
235         public boolean getShowTrayIcon() {\r
236                 return showTrayIcon.isChecked();\r
237         }\r
238         \r
239         \r
240         //*****************************************\r
241         //* Show the splash screen on startup\r
242         //*****************************************\r
243         public void setShowSplashScreen(boolean val) {\r
244                 showSplashScreen.setChecked(val);\r
245         }\r
246         public boolean getShowSplashScreen() {\r
247                 return showSplashScreen.isChecked();\r
248         }\r
249         \r
250         //*******************************************\r
251         //* verify deletes get/set\r
252         //*******************************************\r
253         public void setVerifyDelete(boolean val) {\r
254                 verifyDelete.setChecked(val);   \r
255         }\r
256         public boolean getVerifyDelete() {\r
257                 return verifyDelete.isChecked();\r
258         }\r
259         \r
260         \r
261         //*******************************************\r
262         //* Show/Hide tray icon get/set\r
263         //*******************************************\r
264         public void setPdfPreview(boolean val) {\r
265                 pdfPreview.setChecked(val);     \r
266         }\r
267         public boolean getPdfPreview() {\r
268                 return pdfPreview.isChecked();\r
269         }\r
270 \r
271         \r
272         //********************************************\r
273         //* Listeners for palette & style changes\r
274         //********************************************\r
275         \r
276         public void styleSelected(String style) {\r
277                 QApplication.setStyle(style);\r
278                 QApplication.setPalette(QApplication.style().standardPalette());\r
279         }\r
280         \r
281         public void standardPaletteChanged() {\r
282                 if (standardPalette.isChecked())\r
283                         QApplication.setPalette(QApplication.style().standardPalette());\r
284                 else\r
285                         QApplication.setPalette(Global.originalPalette);\r
286                         \r
287         }\r
288 \r
289         \r
290         //*****************************************\r
291         //* automatic save timer\r
292         //*****************************************\r
293         public void setAutoSaveInterval(int len) {\r
294                 autoSaveInterval.setValue(len);\r
295         }\r
296         public int getAutoSaveInterval() {\r
297                 return autoSaveInterval.value();        \r
298         }\r
299 \r
300         \r
301         //*****************************************\r
302         //* Get/Set tag behavior combo box\r
303         //*****************************************\r
304         public void setTagBehavior(String value) {\r
305                 for (int i=0; i<tagBehavior.count(); i++) {\r
306                         String d = tagBehavior.itemData(i).toString();\r
307                         if (value.equalsIgnoreCase(d)) {\r
308                                 tagBehavior.setCurrentIndex(i);\r
309                                 return;\r
310                         }\r
311                 }\r
312         }\r
313         public String getTagBehavior() {\r
314                 int i = tagBehavior.currentIndex();\r
315                 return tagBehavior.itemData(i).toString();\r
316         }\r
317 \r
318         //*****************************************\r
319         //* Mimic Evernote Selection\r
320         //*****************************************\r
321         public boolean getMimicEvernote() {\r
322                 return mimicEvernote.isChecked();\r
323         }\r
324         public void setMimicEvernote(boolean val) {\r
325                 mimicEvernote.setChecked(val);\r
326         }\r
327 \r
328         \r
329         //*****************************************\r
330         //* Mimic Evernote Selection\r
331         //*****************************************\r
332         public boolean getStartMinimized() {\r
333                 return startMinimized.isChecked();\r
334         }\r
335         public void setStartMinimized(boolean val) {\r
336                 startMinimized.setChecked(val);\r
337         }\r
338 \r
339 \r
340         //*****************************************\r
341         //* Create Note With Selected Tags\r
342         //*****************************************\r
343         public boolean getNewNoteWithTags() {\r
344                 return newNoteWithTags.isChecked();\r
345         }\r
346         public void setNewNoteWithTags(boolean val) {\r
347                 newNoteWithTags.setChecked(val);\r
348         }\r
349 \r
350 }\r