OSDN Git Service

a2d226f074fa1b1a93d525ebea790235ccf0ef4d
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / gui / EditorButtonBar.java
1 package cx.fbn.nevernote.gui;\r
2 \r
3 import com.trolltech.qt.gui.QAction;\r
4 import com.trolltech.qt.gui.QContextMenuEvent;\r
5 import com.trolltech.qt.gui.QMenu;\r
6 import com.trolltech.qt.gui.QToolBar;\r
7 \r
8 import cx.fbn.nevernote.Global;\r
9 \r
10 public class EditorButtonBar extends QToolBar {\r
11         QMenu contextMenu;\r
12         QAction toggleUndoVisible;\r
13         QAction toggleRedoVisible;\r
14         QAction toggleCutVisible;\r
15         QAction toggleCopyVisible;\r
16         QAction toggleCopyBoldVisible;\r
17         QAction togglePasteVisible;\r
18         QAction toggleBoldVisible;\r
19         QAction toggleUnderlineVisible;\r
20         QAction toggleItalicVisible;\r
21         QAction toggleRightAlignVisible;\r
22         QAction toggleLeftAlignVisible;\r
23         QAction toggleCenterAlignVisible;\r
24 \r
25         QAction toggleStrikethroughVisible;\r
26         QAction toggleHLineVisible;\r
27         QAction toggleIndentVisible;\r
28         QAction toggleOutdentVisible;\r
29         QAction toggleBulletListVisible;\r
30         QAction toggleNumberListVisible;\r
31         \r
32         QAction toggleFontVisible;\r
33         QAction toggleFontSizeVisible;\r
34         QAction toggleFontColorVisible;\r
35         QAction toggleFontHilight;\r
36         QAction toggleSpellCheck;\r
37         QAction toggleTodo;\r
38         \r
39 \r
40 \r
41         public EditorButtonBar() {\r
42                 contextMenu = new QMenu();\r
43                 \r
44                 toggleUndoVisible = addAction("undo" ,tr("Undo"));\r
45                 toggleRedoVisible = addAction("redo", tr("Redo Change"));\r
46                 toggleCutVisible = addAction("cut", tr("Cut"));\r
47                 toggleCopyVisible = addAction("copy", tr("Copy"));\r
48                 togglePasteVisible = addAction("paste", tr("Paste"));\r
49                 toggleBoldVisible = addAction("bold", tr("Bold"));\r
50                 toggleItalicVisible = addAction("italic", tr("Italic"));\r
51                 toggleUnderlineVisible = addAction("underline", tr("Underline"));\r
52                 toggleStrikethroughVisible = addAction("strikethrough", tr("Strikethrough"));\r
53 \r
54                 toggleLeftAlignVisible = addAction("alignLeft", tr("Left Align"));\r
55                 toggleCenterAlignVisible = addAction("alignCenter", tr("Center Align"));\r
56                 toggleRightAlignVisible = addAction("alignRight", tr("Right Align"));\r
57 \r
58                 toggleHLineVisible = addAction("hline", tr("Insert Horizontal Line"));\r
59                 toggleIndentVisible = addAction("indent", tr("Shift Right"));\r
60                 toggleOutdentVisible = addAction("outdent", tr("Shift Left"));\r
61                 toggleBulletListVisible = addAction("bulletList", tr("Bullet List"));\r
62                 toggleNumberListVisible = addAction("numberList", tr("Number List"));\r
63 \r
64                 toggleFontVisible = addAction("font", tr("Font"));\r
65                 toggleFontSizeVisible = addAction("fontSize", tr("Font Size"));\r
66                 toggleFontColorVisible = addAction("fontColor", tr("Font Color"));\r
67                 toggleFontHilight = addAction("fontHilight", tr("Font Hilight"));\r
68                 toggleSpellCheck = addAction("spellCheck", tr("Spell Check"));\r
69                 toggleTodo = addAction("todo", tr("To-Do"));\r
70         }\r
71         \r
72         \r
73         private QAction addAction(String config, String name) {\r
74                 QAction newAction = new QAction(this);\r
75                 newAction.setText(name);\r
76                 newAction.setCheckable(true);\r
77                 newAction.setChecked(Global.isEditorButtonVisible(config));\r
78                 contextMenu.addAction(newAction);\r
79                 return newAction;\r
80         }\r
81         \r
82         @Override\r
83         public void contextMenuEvent(QContextMenuEvent event) {\r
84                 contextMenu.exec(event.globalPos());\r
85         }\r
86 }\r