OSDN Git Service

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