OSDN Git Service

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