1 | /* $Id: UIActionsPool.cpp 35635 2011-01-19 16:32:11Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * VBox frontends: Qt GUI ("VirtualBox"):
|
---|
5 | * UIActionsPool class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2010 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | */
|
---|
19 |
|
---|
20 | /* Local includes */
|
---|
21 | #include "UIActionsPool.h"
|
---|
22 | #include "UIIconPool.h"
|
---|
23 | #include "UIMachineShortcuts.h"
|
---|
24 | #include "VBoxGlobal.h"
|
---|
25 |
|
---|
26 | /* Global includes */
|
---|
27 | #include <QHelpEvent>
|
---|
28 | #include <QToolTip>
|
---|
29 | #include <QtGlobal>
|
---|
30 |
|
---|
31 | /* Extended QMenu class used in UIActions */
|
---|
32 | class QIMenu : public QMenu
|
---|
33 | {
|
---|
34 | Q_OBJECT;
|
---|
35 |
|
---|
36 | public:
|
---|
37 |
|
---|
38 | /* QIMenu constructor: */
|
---|
39 | QIMenu(QWidget *pParent = 0) : QMenu(pParent), m_fShowToolTips(false) {}
|
---|
40 |
|
---|
41 | /* Setter/getter for 'show-tool-tips' feature: */
|
---|
42 | void setShowToolTips(bool fShowToolTips) { m_fShowToolTips = fShowToolTips; }
|
---|
43 | bool isToolTipsShown() const { return m_fShowToolTips; }
|
---|
44 |
|
---|
45 | private:
|
---|
46 |
|
---|
47 | /* Event handler reimplementation: */
|
---|
48 | bool event(QEvent *pEvent)
|
---|
49 | {
|
---|
50 | /* Handle particular event-types: */
|
---|
51 | switch (pEvent->type())
|
---|
52 | {
|
---|
53 | /* Tool-tip request handler: */
|
---|
54 | case QEvent::ToolTip:
|
---|
55 | {
|
---|
56 | /* Get current help-event: */
|
---|
57 | QHelpEvent *pHelpEvent = static_cast<QHelpEvent*>(pEvent);
|
---|
58 | /* Get action which caused help-event: */
|
---|
59 | QAction *pAction = actionAt(pHelpEvent->pos());
|
---|
60 | /* If action present => show action's tool-tip if needed: */
|
---|
61 | if (pAction && m_fShowToolTips)
|
---|
62 | QToolTip::showText(pHelpEvent->globalPos(), pAction->toolTip());
|
---|
63 | break;
|
---|
64 | }
|
---|
65 | default:
|
---|
66 | break;
|
---|
67 | }
|
---|
68 | /* Base-class event-handler: */
|
---|
69 | return QMenu::event(pEvent);
|
---|
70 | }
|
---|
71 |
|
---|
72 | /* Reflects 'show-tool-tip' feature activity: */
|
---|
73 | bool m_fShowToolTips;
|
---|
74 | };
|
---|
75 |
|
---|
76 | /* Action activation event */
|
---|
77 | class ActivateActionEvent : public QEvent
|
---|
78 | {
|
---|
79 | public:
|
---|
80 |
|
---|
81 | ActivateActionEvent(QAction *pAction)
|
---|
82 | : QEvent((QEvent::Type)VBoxDefs::ActivateActionEventType)
|
---|
83 | , m_pAction(pAction) {}
|
---|
84 | QAction* action() const { return m_pAction; }
|
---|
85 |
|
---|
86 | private:
|
---|
87 |
|
---|
88 | QAction *m_pAction;
|
---|
89 | };
|
---|
90 |
|
---|
91 | UIAction::UIAction(QObject *pParent, UIActionType type)
|
---|
92 | : QIWithRetranslateUI3<QAction>(pParent)
|
---|
93 | , m_type(type)
|
---|
94 | {
|
---|
95 | /* Default is no specific menu role. We will set them explicit later. */
|
---|
96 | setMenuRole(QAction::NoRole);
|
---|
97 | }
|
---|
98 |
|
---|
99 | UIActionType UIAction::type() const
|
---|
100 | {
|
---|
101 | return m_type;
|
---|
102 | }
|
---|
103 |
|
---|
104 | class UISimpleAction : public UIAction
|
---|
105 | {
|
---|
106 | Q_OBJECT;
|
---|
107 |
|
---|
108 | public:
|
---|
109 |
|
---|
110 | UISimpleAction(QObject *pParent,
|
---|
111 | const QString &strIcon = QString(), const QString &strIconDis = QString())
|
---|
112 | : UIAction(pParent, UIActionType_Simple)
|
---|
113 | {
|
---|
114 | if (!strIcon.isNull())
|
---|
115 | setIcon(UIIconPool::iconSet(strIcon,
|
---|
116 | strIconDis));
|
---|
117 | }
|
---|
118 |
|
---|
119 | UISimpleAction(QObject *pParent,
|
---|
120 | const QIcon& icon)
|
---|
121 | : UIAction(pParent, UIActionType_Simple)
|
---|
122 | {
|
---|
123 | if (!icon.isNull())
|
---|
124 | setIcon(icon);
|
---|
125 | }
|
---|
126 | };
|
---|
127 |
|
---|
128 | class UIToggleAction : public UIAction
|
---|
129 | {
|
---|
130 | Q_OBJECT;
|
---|
131 |
|
---|
132 | public:
|
---|
133 |
|
---|
134 | UIToggleAction(QObject *pParent,
|
---|
135 | const QString &strIcon = QString(), const QString &strIconDis = QString())
|
---|
136 | : UIAction(pParent, UIActionType_Toggle)
|
---|
137 | {
|
---|
138 | if (!strIcon.isNull())
|
---|
139 | setIcon(UIIconPool::iconSet(strIcon,
|
---|
140 | strIconDis));
|
---|
141 | init();
|
---|
142 | }
|
---|
143 |
|
---|
144 | UIToggleAction(QObject *pParent,
|
---|
145 | const QString &strIconOn, const QString &strIconOff,
|
---|
146 | const QString &strIconOnDis, const QString &strIconOffDis)
|
---|
147 | : UIAction(pParent, UIActionType_Toggle)
|
---|
148 | {
|
---|
149 | setIcon(UIIconPool::iconSetOnOff(strIconOn, strIconOff,
|
---|
150 | strIconOnDis, strIconOffDis));
|
---|
151 | init();
|
---|
152 | }
|
---|
153 |
|
---|
154 | UIToggleAction(QObject *pParent,
|
---|
155 | const QIcon &icon)
|
---|
156 | : UIAction(pParent, UIActionType_Toggle)
|
---|
157 | {
|
---|
158 | if (!icon.isNull())
|
---|
159 | setIcon(icon);
|
---|
160 | init();
|
---|
161 | }
|
---|
162 |
|
---|
163 | private slots:
|
---|
164 |
|
---|
165 | void sltUpdateAppearance()
|
---|
166 | {
|
---|
167 | retranslateUi();
|
---|
168 | }
|
---|
169 |
|
---|
170 | private:
|
---|
171 |
|
---|
172 | void init()
|
---|
173 | {
|
---|
174 | setCheckable(true);
|
---|
175 | connect(this, SIGNAL(toggled(bool)), this, SLOT(sltUpdateAppearance()));
|
---|
176 | }
|
---|
177 | };
|
---|
178 |
|
---|
179 | class UIMenuAction : public UIAction
|
---|
180 | {
|
---|
181 | Q_OBJECT;
|
---|
182 |
|
---|
183 | public:
|
---|
184 |
|
---|
185 | UIMenuAction(QObject *pParent,
|
---|
186 | const QString &strIcon = QString(), const QString &strIconDis = QString())
|
---|
187 | : UIAction(pParent, UIActionType_Menu)
|
---|
188 | {
|
---|
189 | if (!strIcon.isNull())
|
---|
190 | setIcon(UIIconPool::iconSet(strIcon,
|
---|
191 | strIconDis));
|
---|
192 | setMenu(new QIMenu);
|
---|
193 | }
|
---|
194 |
|
---|
195 | UIMenuAction(QObject *pParent,
|
---|
196 | const QIcon &icon)
|
---|
197 | : UIAction(pParent, UIActionType_Menu)
|
---|
198 | {
|
---|
199 | if (!icon.isNull())
|
---|
200 | setIcon(icon);
|
---|
201 | setMenu(new QIMenu);
|
---|
202 | }
|
---|
203 | };
|
---|
204 |
|
---|
205 | class MenuMachineAction : public UIMenuAction
|
---|
206 | {
|
---|
207 | Q_OBJECT;
|
---|
208 |
|
---|
209 | public:
|
---|
210 |
|
---|
211 | MenuMachineAction(QObject *pParent)
|
---|
212 | : UIMenuAction(pParent)
|
---|
213 | {
|
---|
214 | retranslateUi();
|
---|
215 | }
|
---|
216 |
|
---|
217 | protected:
|
---|
218 |
|
---|
219 | void retranslateUi()
|
---|
220 | {
|
---|
221 | menu()->setTitle(QApplication::translate("UIActionsPool", "&Machine"));
|
---|
222 | }
|
---|
223 | };
|
---|
224 |
|
---|
225 | class ToggleFullscreenModeAction : public UIToggleAction
|
---|
226 | {
|
---|
227 | Q_OBJECT;
|
---|
228 |
|
---|
229 | public:
|
---|
230 |
|
---|
231 | ToggleFullscreenModeAction(QObject *pParent)
|
---|
232 | : UIToggleAction(pParent,
|
---|
233 | ":/fullscreen_on_16px.png", ":/fullscreen_16px.png",
|
---|
234 | ":/fullscreen_on_disabled_16px.png", ":/fullscreen_disabled_16px.png")
|
---|
235 | {
|
---|
236 | retranslateUi();
|
---|
237 | }
|
---|
238 |
|
---|
239 | protected:
|
---|
240 |
|
---|
241 | void retranslateUi()
|
---|
242 | {
|
---|
243 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Switch to &Fullscreen"), gMS->shortcut(UIMachineShortcuts::FullscreenModeShortcut)));
|
---|
244 | setStatusTip(QApplication::translate("UIActionsPool", "Switch between normal and fullscreen mode"));
|
---|
245 | }
|
---|
246 | };
|
---|
247 |
|
---|
248 | class ToggleSeamlessModeAction : public UIToggleAction
|
---|
249 | {
|
---|
250 | Q_OBJECT;
|
---|
251 |
|
---|
252 | public:
|
---|
253 |
|
---|
254 | ToggleSeamlessModeAction(QObject *pParent)
|
---|
255 | : UIToggleAction(pParent,
|
---|
256 | ":/seamless_on_16px.png", ":/seamless_16px.png",
|
---|
257 | ":/seamless_on_disabled_16px.png", ":/seamless_disabled_16px.png")
|
---|
258 | {
|
---|
259 | retranslateUi();
|
---|
260 | }
|
---|
261 |
|
---|
262 | protected:
|
---|
263 |
|
---|
264 | void retranslateUi()
|
---|
265 | {
|
---|
266 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Switch to Seam&less Mode"), gMS->shortcut(UIMachineShortcuts::SeamlessModeShortcut)));
|
---|
267 | setStatusTip(QApplication::translate("UIActionsPool", "Switch between normal and seamless desktop integration mode"));
|
---|
268 | }
|
---|
269 | };
|
---|
270 |
|
---|
271 | class ToggleScaleModeAction : public UIToggleAction
|
---|
272 | {
|
---|
273 | Q_OBJECT;
|
---|
274 |
|
---|
275 | public:
|
---|
276 |
|
---|
277 | ToggleScaleModeAction(QObject *pParent)
|
---|
278 | : UIToggleAction(pParent,
|
---|
279 | ":/scale_on_16px.png", ":/scale_16px.png",
|
---|
280 | ":/scale_on_disabled_16px.png", ":/scale_disabled_16px.png")
|
---|
281 | {
|
---|
282 | retranslateUi();
|
---|
283 | }
|
---|
284 |
|
---|
285 | protected:
|
---|
286 |
|
---|
287 | void retranslateUi()
|
---|
288 | {
|
---|
289 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Switch to &Scale Mode"), gMS->shortcut(UIMachineShortcuts::ScaleModeShortcut)));
|
---|
290 | setStatusTip(QApplication::translate("UIActionsPool", "Switch between normal and scale mode"));
|
---|
291 | }
|
---|
292 | };
|
---|
293 |
|
---|
294 | class ToggleGuestAutoresizeAction : public UIToggleAction
|
---|
295 | {
|
---|
296 | Q_OBJECT;
|
---|
297 |
|
---|
298 | public:
|
---|
299 |
|
---|
300 | ToggleGuestAutoresizeAction(QObject *pParent)
|
---|
301 | : UIToggleAction(pParent,
|
---|
302 | ":/auto_resize_on_on_16px.png", ":/auto_resize_on_16px.png",
|
---|
303 | ":/auto_resize_on_on_disabled_16px.png", ":/auto_resize_on_disabled_16px.png")
|
---|
304 | {
|
---|
305 | retranslateUi();
|
---|
306 | }
|
---|
307 |
|
---|
308 | protected:
|
---|
309 |
|
---|
310 | void retranslateUi()
|
---|
311 | {
|
---|
312 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Auto-resize &Guest Display"), gMS->shortcut(UIMachineShortcuts::GuestAutoresizeShortcut)));
|
---|
313 | setStatusTip(QApplication::translate("UIActionsPool", "Automatically resize the guest display when the window is resized (requires Guest Additions)"));
|
---|
314 | }
|
---|
315 | };
|
---|
316 |
|
---|
317 | class PerformWindowAdjustAction : public UISimpleAction
|
---|
318 | {
|
---|
319 | Q_OBJECT;
|
---|
320 |
|
---|
321 | public:
|
---|
322 |
|
---|
323 | PerformWindowAdjustAction(QObject *pParent)
|
---|
324 | : UISimpleAction(pParent,
|
---|
325 | ":/adjust_win_size_16px.png", ":/adjust_win_size_disabled_16px.png")
|
---|
326 | {
|
---|
327 | retranslateUi();
|
---|
328 | }
|
---|
329 |
|
---|
330 | protected:
|
---|
331 |
|
---|
332 | void retranslateUi()
|
---|
333 | {
|
---|
334 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Adjust Window Size"), gMS->shortcut(UIMachineShortcuts::WindowAdjustShortcut)));
|
---|
335 | setStatusTip(QApplication::translate("UIActionsPool", "Adjust window size and position to best fit the guest display"));
|
---|
336 | }
|
---|
337 | };
|
---|
338 |
|
---|
339 | class MenuMouseIntegrationAction : public UIMenuAction
|
---|
340 | {
|
---|
341 | Q_OBJECT;
|
---|
342 |
|
---|
343 | public:
|
---|
344 |
|
---|
345 | MenuMouseIntegrationAction(QObject *pParent)
|
---|
346 | : UIMenuAction(pParent)
|
---|
347 | {
|
---|
348 | retranslateUi();
|
---|
349 | }
|
---|
350 |
|
---|
351 | protected:
|
---|
352 |
|
---|
353 | void retranslateUi()
|
---|
354 | {
|
---|
355 | }
|
---|
356 | };
|
---|
357 |
|
---|
358 | class ToggleMouseIntegrationAction : public UIToggleAction
|
---|
359 | {
|
---|
360 | Q_OBJECT;
|
---|
361 |
|
---|
362 | public:
|
---|
363 |
|
---|
364 | ToggleMouseIntegrationAction(QObject *pParent)
|
---|
365 | : UIToggleAction(pParent,
|
---|
366 | ":/mouse_can_seamless_on_16px.png", ":/mouse_can_seamless_16px.png",
|
---|
367 | ":/mouse_can_seamless_on_disabled_16px.png", ":/mouse_can_seamless_disabled_16px.png")
|
---|
368 | {
|
---|
369 | retranslateUi();
|
---|
370 | }
|
---|
371 |
|
---|
372 | protected:
|
---|
373 |
|
---|
374 | void retranslateUi()
|
---|
375 | {
|
---|
376 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Disable &Mouse Integration"), gMS->shortcut(UIMachineShortcuts::MouseIntegrationShortcut)));
|
---|
377 | setStatusTip(QApplication::translate("UIActionsPool", "Temporarily disable host mouse pointer integration"));
|
---|
378 | }
|
---|
379 | };
|
---|
380 |
|
---|
381 | class PerformTypeCADAction : public UISimpleAction
|
---|
382 | {
|
---|
383 | Q_OBJECT;
|
---|
384 |
|
---|
385 | public:
|
---|
386 |
|
---|
387 | PerformTypeCADAction(QObject *pParent)
|
---|
388 | : UISimpleAction(pParent,
|
---|
389 | ":/hostkey_16px.png", ":/hostkey_disabled_16px.png")
|
---|
390 | {
|
---|
391 | retranslateUi();
|
---|
392 | }
|
---|
393 |
|
---|
394 | protected:
|
---|
395 |
|
---|
396 | void retranslateUi()
|
---|
397 | {
|
---|
398 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Insert Ctrl-Alt-Del"), gMS->shortcut(UIMachineShortcuts::TypeCADShortcut)));
|
---|
399 | setStatusTip(QApplication::translate("UIActionsPool", "Send the Ctrl-Alt-Del sequence to the virtual machine"));
|
---|
400 | }
|
---|
401 | };
|
---|
402 |
|
---|
403 | #ifdef Q_WS_X11
|
---|
404 | class PerformTypeCABSAction : public UISimpleAction
|
---|
405 | {
|
---|
406 | Q_OBJECT;
|
---|
407 |
|
---|
408 | public:
|
---|
409 |
|
---|
410 | PerformTypeCABSAction(QObject *pParent)
|
---|
411 | : UISimpleAction(pParent,
|
---|
412 | ":/hostkey_16px.png", ":/hostkey_disabled_16px.png")
|
---|
413 | {
|
---|
414 | retranslateUi();
|
---|
415 | }
|
---|
416 |
|
---|
417 | protected:
|
---|
418 |
|
---|
419 | void retranslateUi()
|
---|
420 | {
|
---|
421 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Insert Ctrl-Alt-Backspace"), gMS->shortcut(UIMachineShortcuts::TypeCABSShortcut)));
|
---|
422 | setStatusTip(QApplication::translate("UIActionsPool", "Send the Ctrl-Alt-Backspace sequence to the virtual machine"));
|
---|
423 | }
|
---|
424 | };
|
---|
425 | #endif
|
---|
426 |
|
---|
427 | class PerformTakeSnapshotAction : public UISimpleAction
|
---|
428 | {
|
---|
429 | Q_OBJECT;
|
---|
430 |
|
---|
431 | public:
|
---|
432 |
|
---|
433 | PerformTakeSnapshotAction(QObject *pParent)
|
---|
434 | : UISimpleAction(pParent,
|
---|
435 | ":/take_snapshot_16px.png", ":/take_snapshot_dis_16px.png")
|
---|
436 | {
|
---|
437 | retranslateUi();
|
---|
438 | }
|
---|
439 |
|
---|
440 | protected:
|
---|
441 |
|
---|
442 | void retranslateUi()
|
---|
443 | {
|
---|
444 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Take &Snapshot..."), gMS->shortcut(UIMachineShortcuts::TakeSnapshotShortcut)));
|
---|
445 | setStatusTip(QApplication::translate("UIActionsPool", "Take a snapshot of the virtual machine"));
|
---|
446 | }
|
---|
447 | };
|
---|
448 |
|
---|
449 | class ShowInformationDialogAction : public UISimpleAction
|
---|
450 | {
|
---|
451 | Q_OBJECT;
|
---|
452 |
|
---|
453 | public:
|
---|
454 |
|
---|
455 | ShowInformationDialogAction(QObject *pParent)
|
---|
456 | : UISimpleAction(pParent,
|
---|
457 | ":/session_info_16px.png", ":/session_info_disabled_16px.png")
|
---|
458 | {
|
---|
459 | retranslateUi();
|
---|
460 | }
|
---|
461 |
|
---|
462 | protected:
|
---|
463 |
|
---|
464 | void retranslateUi()
|
---|
465 | {
|
---|
466 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Session I&nformation"), gMS->shortcut(UIMachineShortcuts::InformationDialogShortcut)));
|
---|
467 | setStatusTip(QApplication::translate("UIActionsPool", "Show Session Information Dialog"));
|
---|
468 | }
|
---|
469 | };
|
---|
470 |
|
---|
471 | class TogglePauseAction : public UIToggleAction
|
---|
472 | {
|
---|
473 | Q_OBJECT;
|
---|
474 |
|
---|
475 | public:
|
---|
476 |
|
---|
477 | TogglePauseAction(QObject *pParent)
|
---|
478 | : UIToggleAction(pParent,
|
---|
479 | ":/pause_16px.png", ":/pause_disabled_16px.png")
|
---|
480 | {
|
---|
481 | retranslateUi();
|
---|
482 | }
|
---|
483 |
|
---|
484 | protected:
|
---|
485 |
|
---|
486 | void retranslateUi()
|
---|
487 | {
|
---|
488 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Pause"), gMS->shortcut(UIMachineShortcuts::PauseShortcut)));
|
---|
489 | setStatusTip(QApplication::translate("UIActionsPool", "Suspend the execution of the virtual machine"));
|
---|
490 | }
|
---|
491 | };
|
---|
492 |
|
---|
493 | class PerformResetAction : public UISimpleAction
|
---|
494 | {
|
---|
495 | Q_OBJECT;
|
---|
496 |
|
---|
497 | public:
|
---|
498 |
|
---|
499 | PerformResetAction(QObject *pParent)
|
---|
500 | : UISimpleAction(pParent,
|
---|
501 | ":/reset_16px.png", ":/reset_disabled_16px.png")
|
---|
502 | {
|
---|
503 | retranslateUi();
|
---|
504 | }
|
---|
505 |
|
---|
506 | protected:
|
---|
507 |
|
---|
508 | void retranslateUi()
|
---|
509 | {
|
---|
510 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Reset"), gMS->shortcut(UIMachineShortcuts::ResetShortcut)));
|
---|
511 | setStatusTip(QApplication::translate("UIActionsPool", "Reset the virtual machine"));
|
---|
512 | }
|
---|
513 | };
|
---|
514 |
|
---|
515 | class PerformShutdownAction : public UISimpleAction
|
---|
516 | {
|
---|
517 | Q_OBJECT;
|
---|
518 |
|
---|
519 | public:
|
---|
520 |
|
---|
521 | PerformShutdownAction(QObject *pParent)
|
---|
522 | : UISimpleAction(pParent,
|
---|
523 | ":/acpi_16px.png", ":/acpi_disabled_16px.png")
|
---|
524 | {
|
---|
525 | retranslateUi();
|
---|
526 | }
|
---|
527 |
|
---|
528 | protected:
|
---|
529 |
|
---|
530 | void retranslateUi()
|
---|
531 | {
|
---|
532 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "ACPI Sh&utdown"), gMS->shortcut(UIMachineShortcuts::ShutdownShortcut)));
|
---|
533 | setStatusTip(QApplication::translate("UIActionsPool", "Send the ACPI Power Button press event to the virtual machine"));
|
---|
534 | }
|
---|
535 | };
|
---|
536 |
|
---|
537 | class PerformCloseAction : public UISimpleAction
|
---|
538 | {
|
---|
539 | Q_OBJECT;
|
---|
540 |
|
---|
541 | public:
|
---|
542 |
|
---|
543 | PerformCloseAction(QObject *pParent)
|
---|
544 | : UISimpleAction(pParent,
|
---|
545 | ":/exit_16px.png")
|
---|
546 | {
|
---|
547 | setMenuRole(QAction::QuitRole);
|
---|
548 | retranslateUi();
|
---|
549 | }
|
---|
550 |
|
---|
551 | protected:
|
---|
552 |
|
---|
553 | void retranslateUi()
|
---|
554 | {
|
---|
555 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Close..."), gMS->shortcut(UIMachineShortcuts::CloseShortcut)));
|
---|
556 | setStatusTip(QApplication::translate("UIActionsPool", "Close the virtual machine"));
|
---|
557 | }
|
---|
558 | };
|
---|
559 |
|
---|
560 | class MenuViewAction : public UIMenuAction
|
---|
561 | {
|
---|
562 | Q_OBJECT;
|
---|
563 |
|
---|
564 | public:
|
---|
565 |
|
---|
566 | MenuViewAction(QObject *pParent)
|
---|
567 | : UIMenuAction(pParent)
|
---|
568 | {
|
---|
569 | retranslateUi();
|
---|
570 | }
|
---|
571 |
|
---|
572 | protected:
|
---|
573 |
|
---|
574 | void retranslateUi()
|
---|
575 | {
|
---|
576 | menu()->setTitle(QApplication::translate("UIActionsPool", "&View"));
|
---|
577 | }
|
---|
578 | };
|
---|
579 |
|
---|
580 | class MenuDevicesAction : public UIMenuAction
|
---|
581 | {
|
---|
582 | Q_OBJECT;
|
---|
583 |
|
---|
584 | public:
|
---|
585 |
|
---|
586 | MenuDevicesAction(QObject *pParent)
|
---|
587 | : UIMenuAction(pParent)
|
---|
588 | {
|
---|
589 | retranslateUi();
|
---|
590 | }
|
---|
591 |
|
---|
592 | protected:
|
---|
593 |
|
---|
594 | void retranslateUi()
|
---|
595 | {
|
---|
596 | menu()->setTitle(QApplication::translate("UIActionsPool", "&Devices"));
|
---|
597 | }
|
---|
598 | };
|
---|
599 |
|
---|
600 | class MenuOpticalDevicesAction : public UIMenuAction
|
---|
601 | {
|
---|
602 | Q_OBJECT;
|
---|
603 |
|
---|
604 | public:
|
---|
605 |
|
---|
606 | MenuOpticalDevicesAction(QObject *pParent)
|
---|
607 | : UIMenuAction(pParent,
|
---|
608 | ":/cd_16px.png", ":/cd_disabled_16px.png")
|
---|
609 | {
|
---|
610 | retranslateUi();
|
---|
611 | }
|
---|
612 |
|
---|
613 | protected:
|
---|
614 |
|
---|
615 | void retranslateUi()
|
---|
616 | {
|
---|
617 | menu()->setTitle(QApplication::translate("UIActionsPool", "&CD/DVD Devices"));
|
---|
618 | }
|
---|
619 | };
|
---|
620 |
|
---|
621 | class MenuFloppyDevicesAction : public UIMenuAction
|
---|
622 | {
|
---|
623 | Q_OBJECT;
|
---|
624 |
|
---|
625 | public:
|
---|
626 |
|
---|
627 | MenuFloppyDevicesAction(QObject *pParent)
|
---|
628 | : UIMenuAction(pParent,
|
---|
629 | ":/fd_16px.png", ":/fd_disabled_16px.png")
|
---|
630 | {
|
---|
631 | retranslateUi();
|
---|
632 | }
|
---|
633 |
|
---|
634 | protected:
|
---|
635 |
|
---|
636 | void retranslateUi()
|
---|
637 | {
|
---|
638 | menu()->setTitle(QApplication::translate("UIActionsPool", "&Floppy Devices"));
|
---|
639 | }
|
---|
640 | };
|
---|
641 |
|
---|
642 | class MenuUSBDevicesAction : public UIMenuAction
|
---|
643 | {
|
---|
644 | Q_OBJECT;
|
---|
645 |
|
---|
646 | public:
|
---|
647 |
|
---|
648 | MenuUSBDevicesAction(QObject *pParent)
|
---|
649 | : UIMenuAction(pParent,
|
---|
650 | ":/usb_16px.png", ":/usb_disabled_16px.png")
|
---|
651 | {
|
---|
652 | qobject_cast<QIMenu*>(menu())->setShowToolTips(true);
|
---|
653 | retranslateUi();
|
---|
654 | }
|
---|
655 |
|
---|
656 | protected:
|
---|
657 |
|
---|
658 | void retranslateUi()
|
---|
659 | {
|
---|
660 | menu()->setTitle(QApplication::translate("UIActionsPool", "&USB Devices"));
|
---|
661 | }
|
---|
662 | };
|
---|
663 |
|
---|
664 | class MenuNetworkAdaptersAction : public UIMenuAction
|
---|
665 | {
|
---|
666 | Q_OBJECT;
|
---|
667 |
|
---|
668 | public:
|
---|
669 |
|
---|
670 | MenuNetworkAdaptersAction(QObject *pParent)
|
---|
671 | : UIMenuAction(pParent)
|
---|
672 | {
|
---|
673 | retranslateUi();
|
---|
674 | }
|
---|
675 |
|
---|
676 | protected:
|
---|
677 |
|
---|
678 | void retranslateUi()
|
---|
679 | {
|
---|
680 | }
|
---|
681 | };
|
---|
682 |
|
---|
683 | class ShowNetworkAdaptersDialogAction : public UISimpleAction
|
---|
684 | {
|
---|
685 | Q_OBJECT;
|
---|
686 |
|
---|
687 | public:
|
---|
688 |
|
---|
689 | ShowNetworkAdaptersDialogAction(QObject *pParent)
|
---|
690 | : UISimpleAction(pParent,
|
---|
691 | ":/nw_16px.png", ":/nw_disabled_16px.png")
|
---|
692 | {
|
---|
693 | retranslateUi();
|
---|
694 | }
|
---|
695 |
|
---|
696 | protected:
|
---|
697 |
|
---|
698 | void retranslateUi()
|
---|
699 | {
|
---|
700 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Network Adapters..."), gMS->shortcut(UIMachineShortcuts::NetworkAdaptersDialogShortcut)));
|
---|
701 | setStatusTip(QApplication::translate("UIActionsPool", "Change the settings of network adapters"));
|
---|
702 | }
|
---|
703 | };
|
---|
704 |
|
---|
705 | class MenuSharedFoldersAction : public UIMenuAction
|
---|
706 | {
|
---|
707 | Q_OBJECT;
|
---|
708 |
|
---|
709 | public:
|
---|
710 |
|
---|
711 | MenuSharedFoldersAction(QObject *pParent)
|
---|
712 | : UIMenuAction(pParent)
|
---|
713 | {
|
---|
714 | retranslateUi();
|
---|
715 | }
|
---|
716 |
|
---|
717 | protected:
|
---|
718 |
|
---|
719 | void retranslateUi()
|
---|
720 | {
|
---|
721 | }
|
---|
722 | };
|
---|
723 |
|
---|
724 | class ShowSharedFoldersDialogAction : public UISimpleAction
|
---|
725 | {
|
---|
726 | Q_OBJECT;
|
---|
727 |
|
---|
728 | public:
|
---|
729 |
|
---|
730 | ShowSharedFoldersDialogAction(QObject *pParent)
|
---|
731 | : UISimpleAction(pParent,
|
---|
732 | ":/shared_folder_16px.png", ":/shared_folder_disabled_16px.png")
|
---|
733 | {
|
---|
734 | retranslateUi();
|
---|
735 | }
|
---|
736 |
|
---|
737 | protected:
|
---|
738 |
|
---|
739 | void retranslateUi()
|
---|
740 | {
|
---|
741 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Shared Folders..."), gMS->shortcut(UIMachineShortcuts::SharedFoldersDialogShortcut)));
|
---|
742 | setStatusTip(QApplication::translate("UIActionsPool", "Create or modify shared folders"));
|
---|
743 | }
|
---|
744 | };
|
---|
745 |
|
---|
746 | class ToggleVRDEServerAction : public UIToggleAction
|
---|
747 | {
|
---|
748 | Q_OBJECT;
|
---|
749 |
|
---|
750 | public:
|
---|
751 |
|
---|
752 | ToggleVRDEServerAction(QObject *pParent)
|
---|
753 | : UIToggleAction(pParent,
|
---|
754 | ":/vrdp_on_16px.png", ":/vrdp_16px.png",
|
---|
755 | ":/vrdp_on_disabled_16px.png", ":/vrdp_disabled_16px.png")
|
---|
756 | {
|
---|
757 | retranslateUi();
|
---|
758 | }
|
---|
759 |
|
---|
760 | protected:
|
---|
761 |
|
---|
762 | void retranslateUi()
|
---|
763 | {
|
---|
764 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Enable R&emote Display"), gMS->shortcut(UIMachineShortcuts::VRDPServerShortcut)));
|
---|
765 | setStatusTip(QApplication::translate("UIActionsPool", "Enable remote desktop (RDP) connections to this machine"));
|
---|
766 | }
|
---|
767 | };
|
---|
768 |
|
---|
769 | class PerformInstallGuestToolsAction : public UISimpleAction
|
---|
770 | {
|
---|
771 | Q_OBJECT;
|
---|
772 |
|
---|
773 | public:
|
---|
774 |
|
---|
775 | PerformInstallGuestToolsAction(QObject *pParent)
|
---|
776 | : UISimpleAction(pParent,
|
---|
777 | ":/guesttools_16px.png", ":/guesttools_disabled_16px.png")
|
---|
778 | {
|
---|
779 | retranslateUi();
|
---|
780 | }
|
---|
781 |
|
---|
782 | protected:
|
---|
783 |
|
---|
784 | void retranslateUi()
|
---|
785 | {
|
---|
786 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Install Guest Additions..."), gMS->shortcut(UIMachineShortcuts::InstallGuestAdditionsShortcut)));
|
---|
787 | setStatusTip(QApplication::translate("UIActionsPool", "Mount the Guest Additions installation image"));
|
---|
788 | }
|
---|
789 | };
|
---|
790 |
|
---|
791 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
792 | class MenuDebugAction : public UIMenuAction
|
---|
793 | {
|
---|
794 | Q_OBJECT;
|
---|
795 |
|
---|
796 | public:
|
---|
797 |
|
---|
798 | MenuDebugAction(QObject *pParent)
|
---|
799 | : UIMenuAction(pParent)
|
---|
800 | {
|
---|
801 | retranslateUi();
|
---|
802 | }
|
---|
803 |
|
---|
804 | protected:
|
---|
805 |
|
---|
806 | void retranslateUi()
|
---|
807 | {
|
---|
808 | menu()->setTitle(QApplication::translate("UIActionsPool", "De&bug"));
|
---|
809 | }
|
---|
810 | };
|
---|
811 |
|
---|
812 | class ShowStatisticsAction : public UISimpleAction
|
---|
813 | {
|
---|
814 | Q_OBJECT;
|
---|
815 |
|
---|
816 | public:
|
---|
817 |
|
---|
818 | ShowStatisticsAction(QObject *pParent)
|
---|
819 | : UISimpleAction(pParent)
|
---|
820 | {
|
---|
821 | retranslateUi();
|
---|
822 | }
|
---|
823 |
|
---|
824 | protected:
|
---|
825 |
|
---|
826 | void retranslateUi()
|
---|
827 | {
|
---|
828 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Statistics...", "debug action"), gMS->shortcut(UIMachineShortcuts::StatisticWindowShortcut)));
|
---|
829 | }
|
---|
830 | };
|
---|
831 |
|
---|
832 | class ShowCommandLineAction : public UISimpleAction
|
---|
833 | {
|
---|
834 | Q_OBJECT;
|
---|
835 |
|
---|
836 | public:
|
---|
837 |
|
---|
838 | ShowCommandLineAction(QObject *pParent)
|
---|
839 | : UISimpleAction(pParent)
|
---|
840 | {
|
---|
841 | retranslateUi();
|
---|
842 | }
|
---|
843 |
|
---|
844 | protected:
|
---|
845 |
|
---|
846 | void retranslateUi()
|
---|
847 | {
|
---|
848 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "&Command Line...", "debug action"), gMS->shortcut(UIMachineShortcuts::CommandLineWindowShortcut)));
|
---|
849 | }
|
---|
850 | };
|
---|
851 |
|
---|
852 | class ToggleLoggingAction : public UIToggleAction
|
---|
853 | {
|
---|
854 | Q_OBJECT;
|
---|
855 |
|
---|
856 | public:
|
---|
857 |
|
---|
858 | ToggleLoggingAction(QObject *pParent)
|
---|
859 | : UIToggleAction(pParent)
|
---|
860 | {
|
---|
861 | retranslateUi();
|
---|
862 | }
|
---|
863 |
|
---|
864 | protected:
|
---|
865 |
|
---|
866 | void retranslateUi()
|
---|
867 | {
|
---|
868 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("UIActionsPool", "Enable &Logging...", "debug action"), gMS->shortcut(UIMachineShortcuts::LoggingShortcut)));
|
---|
869 | }
|
---|
870 | };
|
---|
871 | #endif
|
---|
872 |
|
---|
873 | class MenuHelpAction : public UIMenuAction
|
---|
874 | {
|
---|
875 | Q_OBJECT;
|
---|
876 |
|
---|
877 | public:
|
---|
878 |
|
---|
879 | MenuHelpAction(QObject *pParent)
|
---|
880 | : UIMenuAction(pParent)
|
---|
881 | {
|
---|
882 | retranslateUi();
|
---|
883 | }
|
---|
884 |
|
---|
885 | protected:
|
---|
886 |
|
---|
887 | void retranslateUi()
|
---|
888 | {
|
---|
889 | setText(QApplication::translate("UIActionsPool", "&Help"));
|
---|
890 | }
|
---|
891 | };
|
---|
892 |
|
---|
893 | class ShowHelpAction : public UISimpleAction
|
---|
894 | {
|
---|
895 | Q_OBJECT;
|
---|
896 |
|
---|
897 | public:
|
---|
898 |
|
---|
899 | ShowHelpAction(QObject *pParent)
|
---|
900 | : UISimpleAction(pParent,
|
---|
901 | UIIconPool::defaultIcon(UIIconPool::DialogHelpIcon))
|
---|
902 | {
|
---|
903 | retranslateUi();
|
---|
904 | }
|
---|
905 |
|
---|
906 | protected:
|
---|
907 |
|
---|
908 | void retranslateUi()
|
---|
909 | {
|
---|
910 | setShortcut(gMS->shortcut(UIMachineShortcuts::HelpShortcut));
|
---|
911 | setText(QApplication::translate("VBoxProblemReporter", "&Contents..."));
|
---|
912 | setStatusTip(QApplication::translate("VBoxProblemReporter", "Show the online help contents"));
|
---|
913 | }
|
---|
914 | };
|
---|
915 |
|
---|
916 | class ShowWebAction : public UISimpleAction
|
---|
917 | {
|
---|
918 | Q_OBJECT;
|
---|
919 |
|
---|
920 | public:
|
---|
921 |
|
---|
922 | ShowWebAction(QObject *pParent)
|
---|
923 | : UISimpleAction(pParent,
|
---|
924 | ":/site_16px.png")
|
---|
925 | {
|
---|
926 | retranslateUi();
|
---|
927 | }
|
---|
928 |
|
---|
929 | protected:
|
---|
930 |
|
---|
931 | void retranslateUi()
|
---|
932 | {
|
---|
933 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("VBoxProblemReporter", "&VirtualBox Web Site..."), gMS->shortcut(UIMachineShortcuts::WebShortcut)));
|
---|
934 | setStatusTip(QApplication::translate("VBoxProblemReporter", "Open the browser and go to the VirtualBox product web site"));
|
---|
935 | }
|
---|
936 | };
|
---|
937 |
|
---|
938 | class PerformResetWarningsAction : public UISimpleAction
|
---|
939 | {
|
---|
940 | Q_OBJECT;
|
---|
941 |
|
---|
942 | public:
|
---|
943 |
|
---|
944 | PerformResetWarningsAction(QObject *pParent)
|
---|
945 | : UISimpleAction(pParent,
|
---|
946 | ":/reset_16px.png")
|
---|
947 | {
|
---|
948 | retranslateUi();
|
---|
949 | }
|
---|
950 |
|
---|
951 | protected:
|
---|
952 |
|
---|
953 | void retranslateUi()
|
---|
954 | {
|
---|
955 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("VBoxProblemReporter", "&Reset All Warnings"), gMS->shortcut(UIMachineShortcuts::ResetWarningsShortcut)));
|
---|
956 | setStatusTip(QApplication::translate("VBoxProblemReporter", "Go back to showing all suppressed warnings and messages"));
|
---|
957 | }
|
---|
958 | };
|
---|
959 |
|
---|
960 | #ifdef VBOX_WITH_REGISTRATION
|
---|
961 | class PerformRegisterAction : public UISimpleAction
|
---|
962 | {
|
---|
963 | Q_OBJECT;
|
---|
964 |
|
---|
965 | public:
|
---|
966 |
|
---|
967 | PerformRegisterAction(QObject *pParent)
|
---|
968 | : UISimpleAction(pParent,
|
---|
969 | ":/register_16px.png", ":/register_disabled_16px.png")
|
---|
970 | {
|
---|
971 | setEnabled(vboxGlobal().virtualBox().
|
---|
972 | GetExtraData(VBoxDefs::GUI_RegistrationDlgWinID).isEmpty());
|
---|
973 | retranslateUi();
|
---|
974 | }
|
---|
975 |
|
---|
976 | protected:
|
---|
977 |
|
---|
978 | void retranslateUi()
|
---|
979 | {
|
---|
980 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("VBoxProblemReporter", "R&egister VirtualBox..."), gMS->shortcut(UIMachineShortcuts::RegisterShortcut)));
|
---|
981 | setStatusTip(QApplication::translate("VBoxProblemReporter", "Open VirtualBox registration form"));
|
---|
982 | }
|
---|
983 | };
|
---|
984 | #endif /* VBOX_WITH_REGISTRATION */
|
---|
985 |
|
---|
986 | class PerformUpdateAction : public UISimpleAction
|
---|
987 | {
|
---|
988 | Q_OBJECT;
|
---|
989 |
|
---|
990 | public:
|
---|
991 |
|
---|
992 | PerformUpdateAction(QObject *pParent)
|
---|
993 | : UISimpleAction(pParent,
|
---|
994 | ":/refresh_16px.png", ":/refresh_disabled_16px.png")
|
---|
995 | {
|
---|
996 | setMenuRole(QAction::ApplicationSpecificRole);
|
---|
997 | retranslateUi();
|
---|
998 | }
|
---|
999 |
|
---|
1000 | protected:
|
---|
1001 |
|
---|
1002 | void retranslateUi()
|
---|
1003 | {
|
---|
1004 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("VBoxProblemReporter", "C&heck for Updates..."), gMS->shortcut(UIMachineShortcuts::UpdateShortcut)));
|
---|
1005 | setStatusTip(QApplication::translate("VBoxProblemReporter", "Check for a new VirtualBox version"));
|
---|
1006 | }
|
---|
1007 | };
|
---|
1008 |
|
---|
1009 | class ShowAboutAction : public UISimpleAction
|
---|
1010 | {
|
---|
1011 | Q_OBJECT;
|
---|
1012 |
|
---|
1013 | public:
|
---|
1014 |
|
---|
1015 | ShowAboutAction(QObject *pParent)
|
---|
1016 | : UISimpleAction(pParent,
|
---|
1017 | ":/about_16px.png")
|
---|
1018 | {
|
---|
1019 | setMenuRole(QAction::AboutRole);
|
---|
1020 | retranslateUi();
|
---|
1021 | }
|
---|
1022 |
|
---|
1023 | protected:
|
---|
1024 |
|
---|
1025 | void retranslateUi()
|
---|
1026 | {
|
---|
1027 | setText(vboxGlobal().insertKeyToActionText(QApplication::translate("VBoxProblemReporter", "&About VirtualBox..."), gMS->shortcut(UIMachineShortcuts::AboutShortcut)));
|
---|
1028 | setStatusTip(QApplication::translate("VBoxProblemReporter", "Show a dialog with product information"));
|
---|
1029 | }
|
---|
1030 | };
|
---|
1031 |
|
---|
1032 | #ifdef Q_WS_MAC
|
---|
1033 | class DockMenuAction : public UIMenuAction
|
---|
1034 | {
|
---|
1035 | Q_OBJECT;
|
---|
1036 |
|
---|
1037 | public:
|
---|
1038 |
|
---|
1039 | DockMenuAction(QObject *pParent)
|
---|
1040 | : UIMenuAction(pParent)
|
---|
1041 | {
|
---|
1042 | retranslateUi();
|
---|
1043 | }
|
---|
1044 |
|
---|
1045 | protected:
|
---|
1046 |
|
---|
1047 | void retranslateUi() {}
|
---|
1048 | };
|
---|
1049 |
|
---|
1050 | class DockSettingsMenuAction : public UIMenuAction
|
---|
1051 | {
|
---|
1052 | Q_OBJECT;
|
---|
1053 |
|
---|
1054 | public:
|
---|
1055 |
|
---|
1056 | DockSettingsMenuAction(QObject *pParent)
|
---|
1057 | : UIMenuAction(pParent)
|
---|
1058 | {
|
---|
1059 | retranslateUi();
|
---|
1060 | }
|
---|
1061 |
|
---|
1062 | protected:
|
---|
1063 |
|
---|
1064 | void retranslateUi()
|
---|
1065 | {
|
---|
1066 | setText(QApplication::translate("UIActionsPool", "Dock Icon"));
|
---|
1067 | }
|
---|
1068 | };
|
---|
1069 |
|
---|
1070 | class ToggleDockPreviewMonitorAction : public UIToggleAction
|
---|
1071 | {
|
---|
1072 | Q_OBJECT;
|
---|
1073 |
|
---|
1074 | public:
|
---|
1075 |
|
---|
1076 | ToggleDockPreviewMonitorAction(QObject *pParent)
|
---|
1077 | : UIToggleAction(pParent)
|
---|
1078 | {
|
---|
1079 | retranslateUi();
|
---|
1080 | }
|
---|
1081 |
|
---|
1082 | protected:
|
---|
1083 |
|
---|
1084 | void retranslateUi()
|
---|
1085 | {
|
---|
1086 | setText(QApplication::translate("UIActionsPool", "Show Monitor Preview"));
|
---|
1087 | }
|
---|
1088 | };
|
---|
1089 |
|
---|
1090 | class ToggleDockDisableMonitorAction : public UIToggleAction
|
---|
1091 | {
|
---|
1092 | Q_OBJECT;
|
---|
1093 |
|
---|
1094 | public:
|
---|
1095 |
|
---|
1096 | ToggleDockDisableMonitorAction(QObject *pParent)
|
---|
1097 | : UIToggleAction(pParent)
|
---|
1098 | {
|
---|
1099 | retranslateUi();
|
---|
1100 | }
|
---|
1101 |
|
---|
1102 | protected:
|
---|
1103 |
|
---|
1104 | void retranslateUi()
|
---|
1105 | {
|
---|
1106 | setText(QApplication::translate("UIActionsPool", "Show Application Icon"));
|
---|
1107 | }
|
---|
1108 | };
|
---|
1109 | #endif /* Q_WS_MAC */
|
---|
1110 |
|
---|
1111 | UIActionsPool::UIActionsPool(QObject *pParent)
|
---|
1112 | : QObject(pParent)
|
---|
1113 | , m_actionsPool(UIActionIndex_End, 0)
|
---|
1114 | {
|
---|
1115 | /* "Machine" menu actions: */
|
---|
1116 | m_actionsPool[UIActionIndex_Toggle_Fullscreen] = new ToggleFullscreenModeAction(this);
|
---|
1117 | m_actionsPool[UIActionIndex_Toggle_Seamless] = new ToggleSeamlessModeAction(this);
|
---|
1118 | m_actionsPool[UIActionIndex_Toggle_Scale] = new ToggleScaleModeAction(this);
|
---|
1119 | m_actionsPool[UIActionIndex_Toggle_GuestAutoresize] = new ToggleGuestAutoresizeAction(this);
|
---|
1120 | m_actionsPool[UIActionIndex_Simple_AdjustWindow] = new PerformWindowAdjustAction(this);
|
---|
1121 | m_actionsPool[UIActionIndex_Toggle_MouseIntegration] = new ToggleMouseIntegrationAction(this);
|
---|
1122 | m_actionsPool[UIActionIndex_Simple_TypeCAD] = new PerformTypeCADAction(this);
|
---|
1123 | #ifdef Q_WS_X11
|
---|
1124 | m_actionsPool[UIActionIndex_Simple_TypeCABS] = new PerformTypeCABSAction(this);
|
---|
1125 | #endif
|
---|
1126 | m_actionsPool[UIActionIndex_Simple_TakeSnapshot] = new PerformTakeSnapshotAction(this);
|
---|
1127 | m_actionsPool[UIActionIndex_Simple_InformationDialog] = new ShowInformationDialogAction(this);
|
---|
1128 | m_actionsPool[UIActionIndex_Toggle_Pause] = new TogglePauseAction(this);
|
---|
1129 | m_actionsPool[UIActionIndex_Simple_Reset] = new PerformResetAction(this);
|
---|
1130 | m_actionsPool[UIActionIndex_Simple_Shutdown] = new PerformShutdownAction(this);
|
---|
1131 | m_actionsPool[UIActionIndex_Simple_Close] = new PerformCloseAction(this);
|
---|
1132 |
|
---|
1133 | /* "Devices" menu actions: */
|
---|
1134 | m_actionsPool[UIActionIndex_Simple_NetworkAdaptersDialog] = new ShowNetworkAdaptersDialogAction(this);
|
---|
1135 | m_actionsPool[UIActionIndex_Simple_SharedFoldersDialog] = new ShowSharedFoldersDialogAction(this);
|
---|
1136 | m_actionsPool[UIActionIndex_Toggle_VRDEServer] = new ToggleVRDEServerAction(this);
|
---|
1137 | m_actionsPool[UIActionIndex_Simple_InstallGuestTools] = new PerformInstallGuestToolsAction(this);
|
---|
1138 |
|
---|
1139 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
1140 | /* "Debugger" menu actions: */
|
---|
1141 | m_actionsPool[UIActionIndex_Simple_Statistics] = new ShowStatisticsAction(this);
|
---|
1142 | m_actionsPool[UIActionIndex_Simple_CommandLine] = new ShowCommandLineAction(this);
|
---|
1143 | m_actionsPool[UIActionIndex_Toggle_Logging] = new ToggleLoggingAction(this);
|
---|
1144 | #endif
|
---|
1145 |
|
---|
1146 | /* "Help" menu actions: */
|
---|
1147 | m_actionsPool[UIActionIndex_Simple_Help] = new ShowHelpAction(this);
|
---|
1148 | m_actionsPool[UIActionIndex_Simple_Web] = new ShowWebAction(this);
|
---|
1149 | m_actionsPool[UIActionIndex_Simple_ResetWarnings] = new PerformResetWarningsAction(this);
|
---|
1150 | #ifdef VBOX_WITH_REGISTRATION
|
---|
1151 | m_actionsPool[UIActionIndex_Simple_Register] = new PerformRegisterAction(this);
|
---|
1152 | #endif /* VBOX_WITH_REGISTRATION */
|
---|
1153 | m_actionsPool[UIActionIndex_Simple_Update] = new PerformUpdateAction(this);
|
---|
1154 | m_actionsPool[UIActionIndex_Simple_About] = new ShowAboutAction(this);
|
---|
1155 |
|
---|
1156 | #ifdef Q_WS_MAC
|
---|
1157 | /* "Dock" menu actions: */
|
---|
1158 | m_actionsPool[UIActionIndex_Toggle_DockPreviewMonitor] = new ToggleDockPreviewMonitorAction(this);
|
---|
1159 | m_actionsPool[UIActionIndex_Toggle_DockDisableMonitor] = new ToggleDockDisableMonitorAction(this);
|
---|
1160 | #endif /* Q_WS_MAC */
|
---|
1161 |
|
---|
1162 | /* Create all menus */
|
---|
1163 | createMenus();
|
---|
1164 |
|
---|
1165 | /* Test all actions were initialized */
|
---|
1166 | for (int i = 0; i < m_actionsPool.size(); ++i)
|
---|
1167 | if (!m_actionsPool.at(i))
|
---|
1168 | AssertMsgFailed(("Action #%d is not created!\n", i));
|
---|
1169 | }
|
---|
1170 |
|
---|
1171 | UIActionsPool::~UIActionsPool()
|
---|
1172 | {
|
---|
1173 | for (int i = 0; i < m_actionsPool.size(); ++i)
|
---|
1174 | delete m_actionsPool.at(i);
|
---|
1175 | m_actionsPool.clear();
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | UIAction* UIActionsPool::action(UIActionIndex index) const
|
---|
1179 | {
|
---|
1180 | return m_actionsPool.at(index);
|
---|
1181 | }
|
---|
1182 |
|
---|
1183 | void UIActionsPool::createMenus()
|
---|
1184 | {
|
---|
1185 | /* On Mac OS X, all QMenu's are consumed by Qt after they are added to
|
---|
1186 | * another QMenu or a QMenuBar. This means we have to recreate all QMenus
|
---|
1187 | * when creating a new QMenuBar. For simplicity we doing this on all
|
---|
1188 | * platforms right now. */
|
---|
1189 | if (m_actionsPool[UIActionIndex_Simple_Help])
|
---|
1190 | delete m_actionsPool[UIActionIndex_Simple_Help];
|
---|
1191 | m_actionsPool[UIActionIndex_Simple_Help] = new ShowHelpAction(this);
|
---|
1192 | if (m_actionsPool[UIActionIndex_Simple_Web])
|
---|
1193 | delete m_actionsPool[UIActionIndex_Simple_Web];
|
---|
1194 | m_actionsPool[UIActionIndex_Simple_Web] = new ShowWebAction(this);
|
---|
1195 | if (m_actionsPool[UIActionIndex_Simple_ResetWarnings])
|
---|
1196 | delete m_actionsPool[UIActionIndex_Simple_ResetWarnings];
|
---|
1197 | m_actionsPool[UIActionIndex_Simple_ResetWarnings] = new PerformResetWarningsAction(this);
|
---|
1198 | #ifdef VBOX_WITH_REGISTRATION
|
---|
1199 | if (m_actionsPool[UIActionIndex_Simple_Register])
|
---|
1200 | delete m_actionsPool[UIActionIndex_Simple_Register]
|
---|
1201 | m_actionsPool[UIActionIndex_Simple_Register] = new PerformRegisterAction(this);
|
---|
1202 | #endif /* VBOX_WITH_REGISTRATION */
|
---|
1203 | #if defined(Q_WS_MAC) && (QT_VERSION >= 0x040700)
|
---|
1204 | /* For whatever reason, Qt doesn't fully remove items with a
|
---|
1205 | * ApplicationSpecificRole from the application menu. Although the QAction
|
---|
1206 | * itself is deleted, a dummy entry is leaved back in the menu. Hiding
|
---|
1207 | * before deletion helps. */
|
---|
1208 | m_actionsPool[UIActionIndex_Simple_Update]->setVisible(false);
|
---|
1209 | #endif /* Q_WS_MAC */
|
---|
1210 | /* Delete the help items as well. This makes sure they are removed also
|
---|
1211 | * from the Application menu. */
|
---|
1212 | #if !(defined(Q_WS_MAC) && (QT_VERSION < 0x040700))
|
---|
1213 | if (m_actionsPool[UIActionIndex_Simple_About])
|
---|
1214 | delete m_actionsPool[UIActionIndex_Simple_About];
|
---|
1215 | m_actionsPool[UIActionIndex_Simple_About] = new ShowAboutAction(this);
|
---|
1216 | if (m_actionsPool[UIActionIndex_Simple_Update])
|
---|
1217 | delete m_actionsPool[UIActionIndex_Simple_Update];
|
---|
1218 | m_actionsPool[UIActionIndex_Simple_Update] = new PerformUpdateAction(this);
|
---|
1219 | #endif
|
---|
1220 | if (m_actionsPool[UIActionIndex_Simple_Close])
|
---|
1221 | delete m_actionsPool[UIActionIndex_Simple_Close];
|
---|
1222 | m_actionsPool[UIActionIndex_Simple_Close] = new PerformCloseAction(this);
|
---|
1223 |
|
---|
1224 | /* Menus */
|
---|
1225 | if (m_actionsPool[UIActionIndex_Menu_Machine])
|
---|
1226 | delete m_actionsPool[UIActionIndex_Menu_Machine];
|
---|
1227 | m_actionsPool[UIActionIndex_Menu_Machine] = new MenuMachineAction(this);
|
---|
1228 | if (m_actionsPool[UIActionIndex_Menu_View])
|
---|
1229 | delete m_actionsPool[UIActionIndex_Menu_View];
|
---|
1230 | m_actionsPool[UIActionIndex_Menu_View] = new MenuViewAction(this);
|
---|
1231 | if (m_actionsPool[UIActionIndex_Menu_MouseIntegration])
|
---|
1232 | delete m_actionsPool[UIActionIndex_Menu_MouseIntegration];
|
---|
1233 | m_actionsPool[UIActionIndex_Menu_MouseIntegration] = new MenuMouseIntegrationAction(this);
|
---|
1234 |
|
---|
1235 | if (m_actionsPool[UIActionIndex_Menu_Devices])
|
---|
1236 | delete m_actionsPool[UIActionIndex_Menu_Devices];
|
---|
1237 | m_actionsPool[UIActionIndex_Menu_Devices] = new MenuDevicesAction(this);
|
---|
1238 | if (m_actionsPool[UIActionIndex_Menu_OpticalDevices])
|
---|
1239 | delete m_actionsPool[UIActionIndex_Menu_OpticalDevices];
|
---|
1240 | m_actionsPool[UIActionIndex_Menu_OpticalDevices] = new MenuOpticalDevicesAction(this);
|
---|
1241 | if (m_actionsPool[UIActionIndex_Menu_FloppyDevices])
|
---|
1242 | delete m_actionsPool[UIActionIndex_Menu_FloppyDevices];
|
---|
1243 | m_actionsPool[UIActionIndex_Menu_FloppyDevices] = new MenuFloppyDevicesAction(this);
|
---|
1244 | if (m_actionsPool[UIActionIndex_Menu_USBDevices])
|
---|
1245 | delete m_actionsPool[UIActionIndex_Menu_USBDevices];
|
---|
1246 | m_actionsPool[UIActionIndex_Menu_USBDevices] = new MenuUSBDevicesAction(this);
|
---|
1247 | if (m_actionsPool[UIActionIndex_Menu_NetworkAdapters])
|
---|
1248 | delete m_actionsPool[UIActionIndex_Menu_NetworkAdapters];
|
---|
1249 | m_actionsPool[UIActionIndex_Menu_NetworkAdapters] = new MenuNetworkAdaptersAction(this);
|
---|
1250 |
|
---|
1251 | if (m_actionsPool[UIActionIndex_Menu_SharedFolders])
|
---|
1252 | delete m_actionsPool[UIActionIndex_Menu_SharedFolders];
|
---|
1253 | m_actionsPool[UIActionIndex_Menu_SharedFolders] = new MenuSharedFoldersAction(this);
|
---|
1254 |
|
---|
1255 | #ifdef VBOX_WITH_DEBUGGER_GUI
|
---|
1256 | if (m_actionsPool[UIActionIndex_Menu_Debug])
|
---|
1257 | delete m_actionsPool[UIActionIndex_Menu_Debug];
|
---|
1258 | m_actionsPool[UIActionIndex_Menu_Debug] = new MenuDebugAction(this);
|
---|
1259 | #endif /* VBOX_WITH_DEBUGGER_GUI */
|
---|
1260 |
|
---|
1261 | if (m_actionsPool[UIActionIndex_Menu_Help])
|
---|
1262 | delete m_actionsPool[UIActionIndex_Menu_Help];
|
---|
1263 | m_actionsPool[UIActionIndex_Menu_Help] = new MenuHelpAction(this);
|
---|
1264 |
|
---|
1265 | #ifdef Q_WS_MAC
|
---|
1266 | if (m_actionsPool[UIActionIndex_Menu_Dock])
|
---|
1267 | delete m_actionsPool[UIActionIndex_Menu_Dock];
|
---|
1268 | m_actionsPool[UIActionIndex_Menu_Dock] = new DockMenuAction(this);
|
---|
1269 | if (m_actionsPool[UIActionIndex_Menu_DockSettings])
|
---|
1270 | delete m_actionsPool[UIActionIndex_Menu_DockSettings];
|
---|
1271 | m_actionsPool[UIActionIndex_Menu_DockSettings] = new DockSettingsMenuAction(this);
|
---|
1272 | #endif /* Q_WS_MAC */
|
---|
1273 | }
|
---|
1274 |
|
---|
1275 | bool UIActionsPool::processHotKey(const QKeySequence &key)
|
---|
1276 | {
|
---|
1277 | for (int i = 0; i < m_actionsPool.size(); ++i)
|
---|
1278 | {
|
---|
1279 | UIAction *pAction = m_actionsPool.at(i);
|
---|
1280 | /* Skip menus/separators */
|
---|
1281 | if (pAction->type() == UIActionType_Menu)
|
---|
1282 | continue;
|
---|
1283 | QString hotkey = VBoxGlobal::extractKeyFromActionText(pAction->text());
|
---|
1284 | if (pAction->isEnabled() && pAction->isVisible() && !hotkey.isEmpty())
|
---|
1285 | {
|
---|
1286 | if (key.matches(QKeySequence(hotkey)) == QKeySequence::ExactMatch)
|
---|
1287 | {
|
---|
1288 | /* We asynchronously post a special event instead of calling
|
---|
1289 | * pAction->trigger() directly, to let key presses and
|
---|
1290 | * releases be processed correctly by Qt first.
|
---|
1291 | * Note: we assume that nobody will delete the menu item
|
---|
1292 | * corresponding to the key sequence, so that the pointer to
|
---|
1293 | * menu data posted along with the event will remain valid in
|
---|
1294 | * the event handler, at least until the main window is closed. */
|
---|
1295 | QApplication::postEvent(this, new ActivateActionEvent(pAction));
|
---|
1296 | return true;
|
---|
1297 | }
|
---|
1298 | }
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | return false;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 | bool UIActionsPool::event(QEvent *pEvent)
|
---|
1305 | {
|
---|
1306 | switch (pEvent->type())
|
---|
1307 | {
|
---|
1308 | case VBoxDefs::ActivateActionEventType:
|
---|
1309 | {
|
---|
1310 | ActivateActionEvent *pActionEvent = static_cast<ActivateActionEvent*>(pEvent);
|
---|
1311 | pActionEvent->action()->trigger();
|
---|
1312 |
|
---|
1313 | // TODO_NEW_CORE
|
---|
1314 | /* The main window and its children can be destroyed at this point (if, for example, the activated menu
|
---|
1315 | * item closes the main window). Detect this situation to prevent calls to destroyed widgets: */
|
---|
1316 | // QWidgetList list = QApplication::topLevelWidgets();
|
---|
1317 | // bool destroyed = list.indexOf(machineWindowWrapper()->machineWindow()) < 0;
|
---|
1318 | // if (!destroyed && machineWindowWrapper()->machineWindow()->statusBar())
|
---|
1319 | // machineWindowWrapper()->machineWindow()->statusBar()->clearMessage();
|
---|
1320 |
|
---|
1321 | pEvent->accept();
|
---|
1322 | return true;
|
---|
1323 | }
|
---|
1324 | default:
|
---|
1325 | break;
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | return QObject::event(pEvent);
|
---|
1329 | }
|
---|
1330 |
|
---|
1331 | #include "UIActionsPool.moc"
|
---|
1332 |
|
---|