2 * This file is part of NeverNote
\r
3 * Copyright 2009 Randy Baumgarte
\r
5 * This file may be licensed under the terms of of the
\r
6 * GNU General Public License Version 2 (the ``GPL'').
\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
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
19 package cx.fbn.nevernote.gui;
\r
21 import com.trolltech.qt.gui.QAction;
\r
22 import com.trolltech.qt.gui.QMenu;
\r
23 import com.trolltech.qt.gui.QMenuBar;
\r
25 import cx.fbn.nevernote.Global;
\r
27 public class ExternalBrowserMenuBar extends QMenuBar {
\r
29 private final ExternalBrowse parent;
\r
30 public QAction printAction; // Action when a user selects Print from the file menu
\r
31 public QAction emailAction; // Action when a user selects "email"
\r
33 public QAction editFind; // find text in the current note
\r
34 public QAction editUndo; // Undo last change
\r
35 public QAction editRedo; // Redo last change
\r
36 public QAction editCut; // Cut selected text
\r
37 public QAction editPaste; // Paste selected text
\r
38 public QAction editPasteWithoutFormat; // Paste selected text
\r
39 public QAction editCopy; // Copy selected text;
\r
41 public QAction formatBold; // Bold selected text
\r
42 public QAction formatItalic; // Italics selected text
\r
43 public QAction formatUnderline; // Underline selected text
\r
44 public QAction formatStrikethrough; // Strikethrough selected text
\r
45 public QAction formatSuperscript; // Superscript selected text
\r
46 public QAction formatSubscript; // Subscript selected text
\r
47 public QAction formatNumberList; // insert a numbered list
\r
48 public QAction formatBulletList; // insert a bulleted list;
\r
49 public QAction alignLeftAction; // Left justify text
\r
50 public QAction alignRightAction; // Right justify text
\r
51 public QAction alignCenterAction; // Center text
\r
52 public QAction horizontalLineAction; // Insert a horizontal line
\r
53 public QAction indentAction; // Indent
\r
54 public QAction outdentAction; // outdent menu action
\r
56 public QAction spellCheckAction; // Spell checker
\r
59 //**************************************************************************
\r
60 //* External Browser Menu Bar.
\r
61 //* We don't actually show this, but we use it to setup shortcuts.
\r
62 //**************************************************************************
\r
64 public QMenu fileMenu; // File menu
\r
66 public QMenu editMenu; // Edit menu
\r
68 private QMenu formatMenu; // Text format menu
\r
69 private QMenu listMenu; // bullet or numbered list
\r
70 private QMenu indentMenu; // indent or outdent menu
\r
71 private QMenu alignMenu; // Left/Right/Center justify
\r
73 public ExternalBrowserMenuBar(ExternalBrowse p) {
\r
77 printAction = new QAction(tr("Print"), this);
\r
78 printAction.setToolTip("Print the current note");
\r
79 printAction.triggered.connect(parent, "printNote()");
\r
80 setupShortcut(printAction, "File_Print");
\r
82 emailAction = new QAction(tr("Email"), this);
\r
83 emailAction.setToolTip("Email the current note");
\r
84 emailAction.triggered.connect(parent, "emailNote()");
\r
85 setupShortcut(emailAction, "File_Email");
\r
87 editFind = new QAction(tr("Find In Note"), this);
\r
88 editFind.setToolTip(tr("Find a string in the current note"));
\r
89 editFind.triggered.connect(parent, "findText()");
\r
90 setupShortcut(editFind, "Edit_Find_In_Note");
\r
91 //editFind.setShortcut("Ctrl+F");
\r
93 editUndo = new QAction(tr("Undo"), this);
\r
94 editUndo.setToolTip(tr("Undo"));
\r
95 editUndo.triggered.connect(parent.getBrowserWindow(), "undoClicked()");
\r
96 setupShortcut(editUndo, "Edit_Undo");
\r
97 //editUndo.setShortcut("Ctrl+Z");
\r
99 editRedo = new QAction(tr("Redo"), this);
\r
100 editRedo.setToolTip(tr("Redo"));
\r
101 editRedo.triggered.connect(parent.getBrowserWindow(), "redoClicked()");
\r
102 setupShortcut(editRedo, "Edit_Redo");
\r
103 //editRedo.setShortcut("Ctrl+Y");
\r
105 editCut = new QAction(tr("Cut"), this);
\r
106 editCut.setToolTip(tr("Cut"));
\r
107 editCut.triggered.connect(parent.getBrowserWindow(), "cutClicked()");
\r
108 setupShortcut(editCut, "Edit_Cut");
\r
109 //editCut.setShortcut("Ctrl+X");
\r
111 editCopy = new QAction(tr("Copy"), this);
\r
112 editCopy.setToolTip(tr("Copy"));
\r
113 editCopy.triggered.connect(parent.getBrowserWindow(), "copyClicked()");
\r
114 setupShortcut(editCopy, "Edit_Copy");
\r
115 //editCopy.setShortcut("Ctrl+C");
\r
117 editPaste = new QAction(tr("Paste"), this);
\r
118 editPaste.setToolTip(tr("Paste"));
\r
119 editPaste.triggered.connect(parent.getBrowserWindow(), "pasteClicked()");
\r
120 setupShortcut(editPaste, "Edit_Paste");
\r
122 editPasteWithoutFormat = new QAction(tr("Paste Without Formatting"), this);
\r
123 editPasteWithoutFormat.setToolTip(tr("Paste Without Formatting"));
\r
124 editPasteWithoutFormat.triggered.connect(parent.getBrowserWindow(), "pasteWithoutFormattingClicked()");
\r
125 setupShortcut(editPasteWithoutFormat, "Edit_Paste_Without_Formatting");
\r
128 alignLeftAction = new QAction(tr("Left"), this);
\r
129 alignLeftAction.setToolTip(tr("Left Align"));
\r
130 alignLeftAction.triggered.connect(parent.getBrowserWindow(), "justifyLeftClicked()");
\r
131 setupShortcut(alignLeftAction, "Format_Alignment_Left");
\r
132 //alignLeftAction.setShortcut("Ctrl+L");
\r
134 alignRightAction = new QAction(tr("Right"), this);
\r
135 alignRightAction.setToolTip(tr("Right Align"));
\r
136 alignRightAction.triggered.connect(parent.getBrowserWindow(), "justifyRightClicked()");
\r
137 setupShortcut(alignRightAction, "Format_Alignment_Right");
\r
138 //alignRightAction.setShortcut("Ctrl+R");
\r
140 alignCenterAction = new QAction(tr("Center"), this);
\r
141 alignCenterAction.setToolTip(tr("Center Align"));
\r
142 alignCenterAction.triggered.connect(parent.getBrowserWindow(), "justifyCenterClicked()");
\r
143 setupShortcut(alignCenterAction, "Format_Alignment_Center");
\r
144 //alignCenterAction.setShortcut("Ctrl+C");
\r
146 formatBold = new QAction(tr("Bold"), this);
\r
147 formatBold.setToolTip(tr("Bold"));
\r
148 formatBold.triggered.connect(parent.getBrowserWindow(), "boldClicked()");
\r
149 setupShortcut(formatBold, "Format_Bold");
\r
150 //formatBold.setShortcut("Ctrl+B");
\r
152 formatItalic = new QAction(tr("Italic"), this);
\r
153 formatItalic.setToolTip(tr("Italic"));
\r
154 formatItalic.triggered.connect(parent.getBrowserWindow(), "italicClicked()");
\r
155 setupShortcut(formatItalic, "Format_Italic");
\r
156 //formatItalic.setShortcut("Ctrl+I");
\r
158 formatUnderline = new QAction(tr("Underline"), this);
\r
159 formatUnderline.setToolTip(tr("Underline"));
\r
160 formatUnderline.triggered.connect(parent.getBrowserWindow(), "underlineClicked()");
\r
161 setupShortcut(formatUnderline, "Format_Underline");
\r
162 // formatUnderline.setShortcut("Ctrl+U");
\r
165 formatSuperscript = new QAction(tr("Superscript"), this);
\r
166 formatSuperscript.setToolTip(tr("Superscript"));
\r
167 formatSuperscript.triggered.connect(parent.getBrowserWindow(), "superscriptClicked()");
\r
168 setupShortcut(formatSuperscript, "Format_Superscript");
\r
171 formatSubscript = new QAction(tr("Subscript"), this);
\r
172 formatSubscript.setToolTip(tr("Subscript"));
\r
173 formatSubscript.triggered.connect(parent.getBrowserWindow(), "subscriptClicked()");
\r
174 setupShortcut(formatSubscript, "Format_Subscript");
\r
177 formatStrikethrough = new QAction(tr("Strikethrough"), this);
\r
178 formatStrikethrough.setToolTip(tr("Strikethrough"));
\r
179 formatStrikethrough.triggered.connect(parent.getBrowserWindow(), "strikethroughClicked()");
\r
180 setupShortcut(formatStrikethrough, "Format_Strikethrough");
\r
182 horizontalLineAction = new QAction(tr("Horizontal Line"), this);
\r
183 horizontalLineAction.setToolTip(tr("Horizontal Line"));
\r
184 horizontalLineAction.triggered.connect(parent.getBrowserWindow(), "hlineClicked()");
\r
185 setupShortcut(horizontalLineAction, "Format_Horizontal_Line");
\r
187 formatBulletList = new QAction(tr("Bulleted List"), this);
\r
188 // formatBulletList.setText(tr("Numbered List"));
\r
189 formatBulletList.triggered.connect(parent.getBrowserWindow(), "bulletListClicked()");
\r
190 setupShortcut(formatBulletList, "Format_List_Bullet");
\r
191 // formatBulletList.setShortcut("Ctrl+Shift+B");
\r
193 formatNumberList = new QAction(tr("Numbered List"), this);
\r
194 formatNumberList.setText(tr("Numbered list"));
\r
195 formatNumberList.triggered.connect(parent.getBrowserWindow(), "numberListClicked()");
\r
196 setupShortcut(formatNumberList, "Format_List_Numbered");
\r
197 // formatNumberList.setShortcut("Ctrl+Shift+O");
\r
199 indentAction = new QAction(tr(">> Increase"), this);
\r
200 indentAction.setText(tr(">> Increase"));
\r
201 indentAction.triggered.connect(parent.getBrowserWindow(), "indentClicked()");
\r
202 setupShortcut(indentAction, "Format_Indent_Increase");
\r
203 //indentAction.setShortcut("Ctrl+M");
\r
205 outdentAction = new QAction(tr("<< Decrease"), this);
\r
206 outdentAction.setText(tr("<< Decrease"));
\r
207 outdentAction.triggered.connect(parent.getBrowserWindow(), "outdentClicked()");
\r
208 setupShortcut(outdentAction, "Format_Indent_Decrease");
\r
209 //outdentAction.setShortcut("Ctrl+Shift+M");
\r
212 spellCheckAction = new QAction(tr("Spell Check"), this);
\r
213 spellCheckAction.setToolTip("Check for spelling errors");
\r
214 spellCheckAction.triggered.connect(parent.getBrowserWindow(), "spellCheckClicked()");
\r
215 setupShortcut(spellCheckAction, "Tools_Spell_Check");
\r
220 public void setupMenuBar() {
\r
221 fileMenu = addMenu(tr("&File"));
\r
223 fileMenu.addSeparator();
\r
224 fileMenu.addAction(emailAction);
\r
225 fileMenu.addAction(printAction);
\r
226 fileMenu.addSeparator();
\r
228 editMenu = addMenu(tr("&Edit"));
\r
229 editMenu.addAction(editFind);
\r
230 editMenu.addSeparator();
\r
231 editMenu.addAction(editUndo);
\r
232 editMenu.addAction(editRedo);
\r
233 editMenu.addSeparator();
\r
234 editMenu.addAction(editCut);
\r
235 editMenu.addAction(editCopy);
\r
236 editMenu.addAction(editPaste);
\r
237 editMenu.addAction(editPasteWithoutFormat);
\r
239 formatMenu = addMenu(tr("&Format"));
\r
240 formatMenu.addAction(formatBold);
\r
241 formatMenu.addAction(formatUnderline);
\r
242 formatMenu.addAction(formatItalic);
\r
243 formatMenu.addSeparator();
\r
244 formatMenu.addAction(formatStrikethrough);
\r
245 formatMenu.addAction(horizontalLineAction);
\r
246 formatMenu.addSeparator();
\r
247 formatMenu.addAction(formatSuperscript);
\r
248 formatMenu.addAction(formatSubscript);
\r
249 formatMenu.addSeparator();
\r
251 alignMenu = formatMenu.addMenu(tr("Alignment"));
\r
252 alignMenu.addAction(alignLeftAction);
\r
253 alignMenu.addAction(alignCenterAction);
\r
254 alignMenu.addAction(alignRightAction);
\r
256 listMenu = formatMenu.addMenu(tr("Lists"));
\r
257 listMenu.addAction(formatBulletList);
\r
258 listMenu.addAction(formatNumberList);
\r
259 indentMenu = formatMenu.addMenu(tr("Indent"));
\r
260 indentMenu.addAction(indentAction);
\r
261 indentMenu.addAction(outdentAction);
\r
266 addMenu(formatMenu);
\r
270 private void setupShortcut(QAction action, String text) {
\r
271 if (!Global.shortcutKeys.containsAction(text))
\r
273 action.setShortcut(Global.shortcutKeys.getShortcut(text));
\r