OSDN Git Service

ツールバーの「新規」ボタンを押した時にノートを新しいタブで開けるように変更した
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / dialog / ConfigAppearancePage.java
1 /*\r
2  * This file is part of NixNote/NeighborNote \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.core.Qt;\r
26 import com.trolltech.qt.gui.QApplication;\r
27 import com.trolltech.qt.gui.QCheckBox;\r
28 import com.trolltech.qt.gui.QComboBox;\r
29 import com.trolltech.qt.gui.QFormLayout;\r
30 import com.trolltech.qt.gui.QGroupBox;\r
31 import com.trolltech.qt.gui.QHBoxLayout;\r
32 import com.trolltech.qt.gui.QLabel;\r
33 import com.trolltech.qt.gui.QScrollArea;\r
34 import com.trolltech.qt.gui.QSpinBox;\r
35 import com.trolltech.qt.gui.QStyleFactory;\r
36 import com.trolltech.qt.gui.QSystemTrayIcon;\r
37 import com.trolltech.qt.gui.QVBoxLayout;\r
38 import com.trolltech.qt.gui.QWidget;\r
39 \r
40 import cx.fbn.nevernote.Global;\r
41 \r
42 public class ConfigAppearancePage extends QWidget {\r
43         private final QComboBox dateFormat;\r
44         private final QComboBox timeFormat;\r
45         private final QComboBox styleFormat;\r
46         private final QComboBox tagBehavior;\r
47         private final QCheckBox standardPalette;\r
48         private final QCheckBox showSplashScreen;\r
49         private final QCheckBox showTrayIcon;\r
50         private final QCheckBox verifyDelete;\r
51         private final QCheckBox pdfPreview;\r
52         private final QCheckBox anyTagSelection;\r
53         private final QCheckBox checkForUpdates;\r
54         private final QCheckBox newNoteWithTags;\r
55         private final QCheckBox mimicEvernote;\r
56         private final QCheckBox startMinimized;\r
57         private final QCheckBox minimizeOnClose;\r
58         private final QCheckBox includeTagChildren;\r
59         private final QCheckBox displayRightToLeft;\r
60         private final QCheckBox toolBarNewAction;\r
61         private final QComboBox startupNotebook;\r
62         private final QSpinBox autoSaveInterval;\r
63         \r
64         private final List<String> tformats;\r
65         private final List<String> dformats;\r
66         \r
67         public ConfigAppearancePage(QWidget parent) {\r
68 //              super(parent);\r
69                 \r
70                 dformats = new ArrayList<String>();\r
71                 tformats = new ArrayList<String>();\r
72                 \r
73                 dformats.add("MM/dd/yy - 02/03/09");\r
74                 dformats.add("MM/dd/yyyy - 02/03/2009");\r
75                 dformats.add("M/dd/yyyy - 2/03/2009");\r
76                 dformats.add("M/d/yyyy - 2/3/2009");\r
77                 dformats.add("dd/MM/yy - 03/02/09");\r
78                 dformats.add("d/M/yy - 3/2/09");\r
79                 dformats.add("dd/MM/yyyy - 03/02/2009");\r
80                 dformats.add("d/M/yyyy - 3/2/2009");\r
81                 dformats.add("yyyy/MM/dd - 2009/02/03");\r
82                 dformats.add("yy/MM/dd - 09/02/03");\r
83                 \r
84                 tformats.add("HH:mm:ss - 18:13:01");\r
85                 tformats.add("HH:mm:ss a - 18:13:01 pm");\r
86                 tformats.add("HH:mm - 18:13");\r
87                 tformats.add("HH:mm a - 18:13 pm");\r
88                 tformats.add("hh:mm:ss - 06:13:01");\r
89                 tformats.add("hh:mm:ss a - 06:13:01 pm");\r
90                 tformats.add("h:mm:ss a - 6:13:01 pm");\r
91                 tformats.add("hh:mm - 06:13");\r
92                 tformats.add("hh:mm a - 06:13 pm");\r
93                 tformats.add("h:mm a - 6:13 pm");\r
94 \r
95                 \r
96                 // Style sheet formats\r
97                 List<String> styles = QStyleFactory.keys();\r
98                 QGroupBox styleGroup = new QGroupBox(tr("GUI Style"));\r
99                 styleFormat = new QComboBox();                          \r
100                 styleFormat.addItems(styles);\r
101                 styleFormat.activated.connect(this, "styleSelected(String)");\r
102                 \r
103                 standardPalette = new QCheckBox();\r
104                 standardPalette.setText(tr("Use standard palette"));\r
105                 standardPalette.clicked.connect(this, "standardPaletteChanged()");\r
106 \r
107                 QFormLayout styleLayout = new QFormLayout();\r
108                 styleLayout.addWidget(styleFormat);\r
109                 styleLayout.addWidget(standardPalette);\r
110                 \r
111                 styleGroup.setLayout(styleLayout);\r
112 \r
113                 QGroupBox tagBehaviorGroup = new QGroupBox(tr("Tag Behavior"));\r
114                 tagBehavior = new QComboBox();\r
115                 tagBehavior.addItem(tr("Do nothing"),"DoNothing");\r
116                 tagBehavior.addItem(tr("Count tags & do not hide inactive"),"NoHideInactiveCount");\r
117                 tagBehavior.addItem(tr("Count tags & hide inactive"),"HideInactiveCount");\r
118                 tagBehavior.addItem(tr("Color active tags"),"ColorActive");\r
119                 \r
120                 QFormLayout tagLayout = new QFormLayout();\r
121                 tagLayout.addWidget(tagBehavior);\r
122                 tagBehaviorGroup.setLayout(tagLayout);\r
123                 \r
124                 \r
125                 \r
126                 // Date/Time settings\r
127                 QGroupBox datetimeGroup = new QGroupBox(tr("Date/Time Format"));\r
128                 dateFormat = new QComboBox();                           \r
129                 for (int i=0; i<dformats.size(); i++) {\r
130                         dateFormat.addItem(tr(dformats.get(i)));\r
131                 }\r
132                 \r
133                 timeFormat = new QComboBox();           \r
134                 for (int i=0; i<tformats.size(); i++) {\r
135                         timeFormat.addItem(tr(tformats.get(i)));\r
136                 }\r
137 \r
138                 QFormLayout formatLayout = new QFormLayout();\r
139                 formatLayout.addWidget(dateFormat);\r
140                 formatLayout.addWidget(timeFormat);\r
141                 datetimeGroup.setLayout(formatLayout);\r
142                 \r
143                 mimicEvernote = new QCheckBox(tr("Mimic Evernote Selection Behavior (Requires Restart)"));\r
144                 showSplashScreen = new QCheckBox(tr("Show Splash Screen on Startup"));\r
145                 showTrayIcon = new QCheckBox(tr("Minimize To Tray"));\r
146                 minimizeOnClose = new QCheckBox(tr("Close To Tray"));\r
147                 if (!QSystemTrayIcon.isSystemTrayAvailable()) { \r
148                         showTrayIcon.setEnabled(false);\r
149                         minimizeOnClose.setEnabled(false);\r
150                 }\r
151                 verifyDelete = new QCheckBox(tr("Verify Deletes"));\r
152                 startMinimized = new QCheckBox(tr("Start Minimized"));\r
153                 pdfPreview = new QCheckBox(tr("Display PDF Documents Inline"));\r
154                 checkForUpdates = new QCheckBox(tr("Check For Updates At Startup"));\r
155                 newNoteWithTags = new QCheckBox(tr("Create New Notes With Selected Tags"));\r
156                 anyTagSelection = new QCheckBox(tr("Display Notes Matching Any Selected Tags"));\r
157                 includeTagChildren = new QCheckBox(tr("Include Children In Tag Selection"));\r
158                 displayRightToLeft = new QCheckBox(tr("Display Notes Right-To-Left"));\r
159                 toolBarNewAction = new QCheckBox(tr("Add Note in New Tab When Click Tool Bar New Button"));\r
160                 \r
161                 QHBoxLayout startupNotebookLayout = new QHBoxLayout();\r
162                 startupNotebook = new QComboBox();\r
163                 startupNotebook.addItem(tr("All Notebooks"), "AllNotebooks");\r
164                 startupNotebook.addItem(tr("Default Notebook"), "DefaultNotebook");\r
165                 startupNotebookLayout.addWidget(new QLabel(tr("Startup Notebook")));\r
166                 startupNotebookLayout.addWidget(startupNotebook);\r
167                 startupNotebookLayout.addStretch();\r
168         \r
169                 \r
170                 QHBoxLayout autoSaveLayout = new QHBoxLayout();\r
171                 autoSaveLayout.addWidget(new QLabel(tr("Automatic Save Interval (in Minutes)")));\r
172                 autoSaveInterval = new QSpinBox();\r
173                 autoSaveLayout.addWidget(autoSaveInterval);\r
174                 autoSaveInterval.setMaximum(1440);\r
175                 autoSaveInterval.setMinimum(0);\r
176                 \r
177                 QVBoxLayout mainLayout = new QVBoxLayout(this);\r
178                 mainLayout.addWidget(styleGroup);\r
179                 mainLayout.addWidget(datetimeGroup);\r
180                 mainLayout.addLayout(autoSaveLayout);\r
181                 mainLayout.addWidget(tagBehaviorGroup);\r
182                 \r
183                 \r
184                 QVBoxLayout checkboxLayout = new QVBoxLayout();\r
185                 checkboxLayout.addWidget(mimicEvernote); \r
186                 checkboxLayout.addLayout(startupNotebookLayout);\r
187                 checkboxLayout.addWidget(showTrayIcon);\r
188                 checkboxLayout.addWidget(minimizeOnClose);\r
189                 checkboxLayout.addWidget(startMinimized);\r
190                 checkboxLayout.addWidget(showSplashScreen);\r
191                 checkboxLayout.addWidget(verifyDelete);\r
192                 checkboxLayout.addWidget(pdfPreview);\r
193                 checkboxLayout.addWidget(newNoteWithTags);\r
194                 checkboxLayout.addWidget(anyTagSelection);\r
195                 checkboxLayout.addWidget(includeTagChildren);\r
196                 checkboxLayout.addWidget(displayRightToLeft);\r
197                 checkboxLayout.addWidget(checkForUpdates);\r
198                 checkboxLayout.addWidget(toolBarNewAction);\r
199                 checkboxLayout.addStretch(1);\r
200 \r
201                 \r
202                 QWidget checkBoxGroup = new QWidget();\r
203                 checkBoxGroup.setLayout(checkboxLayout);\r
204 \r
205                 QScrollArea scrollArea = new QScrollArea();\r
206                 scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded);\r
207                 scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded);\r
208                 scrollArea.setWidgetResizable(true);\r
209                 scrollArea.setWidget(checkBoxGroup);\r
210 \r
211                 mainLayout.addWidget(scrollArea);\r
212                 setLayout(mainLayout);\r
213                 \r
214                 showTrayIcon.clicked.connect(this, "showTrayIconClicked(Boolean)");\r
215                 showTrayIconClicked(showTrayIcon.isChecked());\r
216 \r
217         }\r
218         \r
219         private void showTrayIconClicked(Boolean checked) {\r
220 //              if (!checked) {\r
221 //                      minimizeOnClose.setEnabled(false);\r
222 //                      minimizeOnClose.setChecked(false);\r
223 //              } else\r
224 //                      if (QSystemTrayIcon.isSystemTrayAvailable()) \r
225 //                              minimizeOnClose.setEnabled(true);\r
226 //                      else\r
227 //                              minimizeOnClose.setEnabled(false);\r
228         }\r
229 \r
230         \r
231         //*****************************************\r
232         //* date format get/set methods \r
233         //*****************************************\r
234         public void setDateFormat(String id) {\r
235                 for (int i=0; i<dformats.size(); i++) {\r
236                         String d = dformats.get(i);\r
237                         if (d.substring(0,id.length()).equals(id))\r
238                                 dateFormat.setCurrentIndex(i);\r
239                 }\r
240         }\r
241         public String getDateFormat() {\r
242                 int i = dateFormat.currentIndex();\r
243                 return dateFormat.itemText(i);  \r
244         }\r
245         \r
246 \r
247         \r
248         //*****************************************\r
249         //* time format get/set methods \r
250         //*****************************************\r
251         public void setTimeFormat(String id) {\r
252                 for (int i=0; i<tformats.size(); i++) {\r
253                         String d = tformats.get(i);\r
254                         int dash = d.indexOf("-");\r
255                         d = d.substring(0,dash-1);\r
256                         if (d.equals(id)) {\r
257                                 timeFormat.setCurrentIndex(i);\r
258                                 return;\r
259                         }\r
260                 }\r
261         }\r
262         public String getTimeFormat() {\r
263                 int i = timeFormat.currentIndex();\r
264                 return timeFormat.itemText(i);  \r
265         }\r
266 \r
267         \r
268         //*****************************************\r
269         //* gui style format get/set methods \r
270         //*****************************************\r
271         public void setStyle(String id) {\r
272                 for (int i=0; i<styleFormat.count(); i++) {\r
273                         String d = styleFormat.itemText(i);\r
274                         if (d.equals(id))\r
275                                 styleFormat.setCurrentIndex(i);\r
276                 }\r
277         }\r
278         public String getStyle() {\r
279                 int i = styleFormat.currentIndex();\r
280                 return styleFormat.itemText(i); \r
281         }\r
282         \r
283         //*****************************************\r
284         //* palette style get/set methods \r
285         //*****************************************\r
286         public void setStandardPalette(boolean value) {\r
287                 standardPalette.setChecked(value);\r
288         }\r
289         public boolean getStandardPalette() {\r
290                 return standardPalette.isChecked();     \r
291         }\r
292         \r
293         //*******************************************\r
294         //* Show/Hide tray icon get/set\r
295         //*******************************************\r
296         public void setShowTrayIcon(boolean val) {\r
297                 showTrayIcon.setChecked(val);   \r
298                 showTrayIconClicked(showTrayIcon.isChecked());\r
299         }\r
300         public boolean getShowTrayIcon() {\r
301                 return showTrayIcon.isChecked();\r
302         }\r
303         \r
304         \r
305         //*******************************************\r
306         //* minimize on close get/set\r
307         //*******************************************\r
308         public void setMinimizeOnClose(boolean val) {\r
309                 minimizeOnClose.setChecked(val);        \r
310         }\r
311         public boolean getMinimizeOnClose() {\r
312                 return minimizeOnClose.isChecked();\r
313         }\r
314         \r
315         \r
316         //*****************************************\r
317         //* Show the splash screen on startup\r
318         //*****************************************\r
319         public void setShowSplashScreen(boolean val) {\r
320                 showSplashScreen.setChecked(val);\r
321         }\r
322         public boolean getShowSplashScreen() {\r
323                 return showSplashScreen.isChecked();\r
324         }\r
325         \r
326         //*******************************************\r
327         //* verify deletes get/set\r
328         //*******************************************\r
329         public void setVerifyDelete(boolean val) {\r
330                 verifyDelete.setChecked(val);   \r
331         }\r
332         public boolean getVerifyDelete() {\r
333                 return verifyDelete.isChecked();\r
334         }\r
335         \r
336         \r
337         //*******************************************\r
338         //* Show/Hide tray icon get/set\r
339         //*******************************************\r
340         public void setPdfPreview(boolean val) {\r
341                 pdfPreview.setChecked(val);     \r
342         }\r
343         public boolean getPdfPreview() {\r
344                 return pdfPreview.isChecked();\r
345         }\r
346         \r
347         //*******************************************\r
348         //* check for updates get/set\r
349         //*******************************************\r
350         public void setCheckForUpdates(boolean val) {\r
351                 checkForUpdates.setChecked(val);        \r
352         }\r
353         public boolean getCheckForUpdates() {\r
354                 return checkForUpdates.isChecked();\r
355         }\r
356         \r
357         //*******************************************\r
358         //* tool bar new button action get/set\r
359         //*******************************************\r
360         public void setNewAction(boolean val) {\r
361                 toolBarNewAction.setChecked(val);\r
362         }\r
363         public boolean getNewAction() {\r
364                 return toolBarNewAction.isChecked();\r
365         }\r
366 \r
367         \r
368         //********************************************\r
369         //* Listeners for palette & style changes\r
370         //********************************************\r
371         public void styleSelected(String style) {\r
372                 QApplication.setStyle(style);\r
373                 QApplication.setPalette(QApplication.style().standardPalette());\r
374         }       \r
375         public void standardPaletteChanged() {\r
376                 if (standardPalette.isChecked())\r
377                         QApplication.setPalette(QApplication.style().standardPalette());\r
378                 else\r
379                         QApplication.setPalette(Global.originalPalette);\r
380                         \r
381         }\r
382 \r
383         \r
384         //*****************************************\r
385         //* automatic save timer\r
386         //*****************************************\r
387         public void setAutoSaveInterval(int len) {\r
388                 autoSaveInterval.setValue(len);\r
389         }\r
390         public int getAutoSaveInterval() {\r
391                 return autoSaveInterval.value();        \r
392         }\r
393 \r
394         \r
395         //*****************************************\r
396         //* Get/Set tag behavior combo box\r
397         //*****************************************\r
398         public void setTagBehavior(String value) {\r
399                 for (int i=0; i<tagBehavior.count(); i++) {\r
400                         String d = tagBehavior.itemData(i).toString();\r
401                         if (value.equalsIgnoreCase(d)) {\r
402                                 tagBehavior.setCurrentIndex(i);\r
403                                 return;\r
404                         }\r
405                 }\r
406         }\r
407         public String getTagBehavior() {\r
408                 int i = tagBehavior.currentIndex();\r
409                 return tagBehavior.itemData(i).toString();\r
410         }\r
411 \r
412         //*****************************************\r
413         //* Mimic Evernote Selection\r
414         //*****************************************\r
415         public boolean getMimicEvernote() {\r
416                 return mimicEvernote.isChecked();\r
417         }\r
418         public void setMimicEvernote(boolean val) {\r
419                 mimicEvernote.setChecked(val);\r
420         }\r
421 \r
422         \r
423         //*****************************************\r
424         //* Mimic Evernote Selection\r
425         //*****************************************\r
426         public boolean getStartMinimized() {\r
427                 return startMinimized.isChecked();\r
428         }\r
429         public void setStartMinimized(boolean val) {\r
430                 startMinimized.setChecked(val);\r
431         }\r
432 \r
433 \r
434         //*****************************************\r
435         //* Create Note With Selected Tags\r
436         //*****************************************\r
437         public boolean getNewNoteWithTags() {\r
438                 return newNoteWithTags.isChecked();\r
439         }\r
440         public void setNewNoteWithTags(boolean val) {\r
441                 newNoteWithTags.setChecked(val);\r
442         }\r
443         \r
444         //*****************************************\r
445         //* Set tag selection behavior\r
446         //*****************************************\r
447         public boolean getAnyTagSelection() {\r
448                 return anyTagSelection.isChecked();\r
449         }\r
450         public void setAnyTagSelection(boolean val) {\r
451                 anyTagSelection.setChecked(val);\r
452         }\r
453 \r
454 \r
455         //*****************************************\r
456         //* Include a tag's child when selecting a parent\r
457         //*****************************************\r
458         public boolean getIncludeTagChildren() {\r
459                 return includeTagChildren.isChecked();\r
460         }\r
461         public void setIncludeTagChildren(boolean val) {\r
462                 includeTagChildren.setChecked(val);\r
463         }\r
464         //*****************************************\r
465         //* Include a tag's child when selecting a parent\r
466         //*****************************************\r
467         public boolean getDisplayRightToLeft() {\r
468                 return displayRightToLeft.isChecked();\r
469         }\r
470         public void setDisplayRightToLeft(boolean val) {\r
471                 displayRightToLeft.setChecked(val);\r
472         }\r
473 \r
474         \r
475         //**************************************************\r
476         //* Get/Set startup notebook\r
477         //**************************************************\r
478         public void setStartupNotebook(String value) {\r
479                 for (int i=0; i<startupNotebook.count(); i++) {\r
480                         String d = startupNotebook.itemData(i).toString();\r
481                         if (d.equals(value))\r
482                                 startupNotebook.setCurrentIndex(i);\r
483                 }\r
484         }\r
485         public String getStartupNotebook() {\r
486                 int index = startupNotebook.currentIndex();\r
487                 return startupNotebook.itemData(index).toString();      \r
488         }\r
489 \r
490 }\r