OSDN Git Service

c210bc5200c378166d54ad46a87d8dbbb6127d6c
[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         \r
38 \r
39 \r
40         public EditorButtonBar() {\r
41                 contextMenu = new QMenu();\r
42                 \r
43                 toggleUndoVisible = addAction("undo" ,tr("Undo"));\r
44                 toggleRedoVisible = addAction("redo", tr("Redo Change"));\r
45                 toggleCutVisible = addAction("cut", tr("Cut"));\r
46                 toggleCopyVisible = addAction("copy", tr("Copy"));\r
47                 togglePasteVisible = addAction("paste", tr("Paste"));\r
48                 toggleBoldVisible = addAction("bold", tr("Bold"));\r
49                 toggleItalicVisible = addAction("italic", tr("Italic"));\r
50                 toggleUnderlineVisible = addAction("underline", tr("Underline"));\r
51                 toggleStrikethroughVisible = addAction("strikethrough", tr("Strikethrough"));\r
52 \r
53                 toggleLeftAlignVisible = addAction("alignLeft", tr("Left Align"));\r
54                 toggleCenterAlignVisible = addAction("alignCenter", tr("Center Align"));\r
55                 toggleRightAlignVisible = addAction("alignRight", tr("Right Align"));\r
56 \r
57                 toggleHLineVisible = addAction("hline", tr("Insert Horizontal Line"));\r
58                 toggleIndentVisible = addAction("indent", tr("Shift Right"));\r
59                 toggleOutdentVisible = addAction("outdent", tr("Shift Left"));\r
60                 toggleBulletListVisible = addAction("bulletList", tr("Bullet List"));\r
61                 toggleNumberListVisible = addAction("numberList", tr("Number List"));\r
62 \r
63                 toggleFontVisible = addAction("font", tr("Font"));\r
64                 toggleFontSizeVisible = addAction("fontSize", tr("Font Size"));\r
65                 toggleFontColorVisible = addAction("fontColor", tr("Font Color"));\r
66                 toggleFontHilight = addAction("fontHilight", tr("Font Hilight"));\r
67                 toggleSpellCheck = addAction("spellCheck", tr("Spell Check"));\r
68         }\r
69         \r
70         \r
71         private QAction addAction(String config, String name) {\r
72                 QAction newAction = new QAction(this);\r
73                 newAction.setText(name);\r
74                 newAction.setCheckable(true);\r
75                 newAction.setChecked(Global.isEditorButtonVisible(config));\r
76                 contextMenu.addAction(newAction);\r
77                 return newAction;\r
78         }\r
79         \r
80         @Override\r
81         public void contextMenuEvent(QContextMenuEvent event) {\r
82                 contextMenu.exec(event.globalPos());\r
83         }\r
84 }\r