VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPool.cpp@ 82781

Last change on this file since 82781 was 82193, checked in by vboxsync, 5 years ago

FE/Qt: bugref:9609: UIActionPool: Provide Log-viewer Refresh action with standard shortcut sequence.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 100.1 KB
Line 
1/* $Id: UIActionPool.cpp 82193 2019-11-25 18:16:00Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIActionPool class implementation.
4 */
5
6/*
7 * Copyright (C) 2010-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* Qt includes: */
19#include <QHelpEvent>
20#include <QToolTip>
21
22/* GUI includes: */
23#include "UICommon.h"
24#include "UIActionPool.h"
25#include "UIActionPoolManager.h"
26#include "UIActionPoolRuntime.h"
27#include "UIConverter.h"
28#include "UIIconPool.h"
29#include "UIMessageCenter.h"
30#include "UIShortcutPool.h"
31#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
32# include "UIExtraDataManager.h"
33# include "UINetworkManager.h"
34# include "UIUpdateManager.h"
35#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
36
37
38/** QEvent extension
39 * representing action-activation event. */
40class ActivateActionEvent : public QEvent
41{
42public:
43
44 /** Constructs @a pAction event. */
45 ActivateActionEvent(QAction *pAction)
46 : QEvent((QEvent::Type)ActivateActionEventType)
47 , m_pAction(pAction)
48 {}
49
50 /** Returns the action this event corresponds to. */
51 QAction *action() const { return m_pAction; }
52
53private:
54
55 /** Holds the action this event corresponds to. */
56 QAction *m_pAction;
57};
58
59
60/*********************************************************************************************************************************
61* Class UIMenu implementation. *
62*********************************************************************************************************************************/
63
64UIMenu::UIMenu()
65 : m_fShowToolTip(false)
66#ifdef VBOX_WS_MAC
67 , m_fConsumable(false)
68 , m_fConsumed(false)
69#endif
70{
71}
72
73bool UIMenu::event(QEvent *pEvent)
74{
75 /* Handle particular event-types: */
76 switch (pEvent->type())
77 {
78 /* Tool-tip request handler: */
79 case QEvent::ToolTip:
80 {
81 /* Get current help-event: */
82 QHelpEvent *pHelpEvent = static_cast<QHelpEvent*>(pEvent);
83 /* Get action which caused help-event: */
84 QAction *pAction = actionAt(pHelpEvent->pos());
85 /* If action present => show action's tool-tip if needed: */
86 if (pAction && m_fShowToolTip)
87 QToolTip::showText(pHelpEvent->globalPos(), pAction->toolTip());
88 break;
89 }
90 default:
91 break;
92 }
93 /* Call to base-class: */
94 return QMenu::event(pEvent);
95}
96
97
98/*********************************************************************************************************************************
99* Class UIAction implementation. *
100*********************************************************************************************************************************/
101
102UIAction::UIAction(UIActionPool *pParent, UIActionType enmType, bool fMachineMenuAction /* = false */)
103 : QAction(pParent)
104 , m_enmType(enmType)
105 , m_fMachineMenuAction(fMachineMenuAction)
106 , m_pActionPool(pParent)
107 , m_enmActionPoolType(pParent->type())
108 , m_iState(0)
109 , m_fShortcutHidden(false)
110{
111 /* By default there is no specific menu role.
112 * It will be set explicitly later. */
113 setMenuRole(QAction::NoRole);
114
115#ifdef VBOX_WS_MAC
116 /* Make sure each action notifies it's parent about hovering: */
117 connect(this, &UIAction::hovered,
118 static_cast<UIActionPool*>(parent()), &UIActionPool::sltActionHovered);
119#endif
120}
121
122UIMenu *UIAction::menu() const
123{
124 return QAction::menu() ? qobject_cast<UIMenu*>(QAction::menu()) : 0;
125}
126
127UIActionPolymorphicMenu *UIAction::toActionPolymorphicMenu()
128{
129 return qobject_cast<UIActionPolymorphicMenu*>(this);
130}
131
132void UIAction::setIcon(int iState, const QIcon &icon)
133{
134 m_icons.resize(iState + 1);
135 m_icons[iState] = icon;
136 updateIcon();
137}
138
139void UIAction::setIcon(const QIcon &icon)
140{
141 setIcon(0, icon);
142}
143
144void UIAction::setName(const QString &strName)
145{
146 /* Remember internal name: */
147 m_strName = strName;
148 /* Update text according new name: */
149 updateText();
150}
151
152void UIAction::setShortcuts(const QList<QKeySequence> &shortcuts)
153{
154 /* Only for manager's action-pool: */
155 if (m_enmActionPoolType == UIActionPoolType_Manager)
156 {
157 /* If primary shortcut should be visible: */
158 if (!m_fShortcutHidden)
159 /* Call to base-class: */
160 QAction::setShortcuts(shortcuts);
161 /* Remember shortcuts: */
162 m_shortcuts = shortcuts;
163 }
164 /* Update text according to new primary shortcut: */
165 updateText();
166}
167
168void UIAction::showShortcut()
169{
170 m_fShortcutHidden = false;
171 if (!m_shortcuts.isEmpty())
172 QAction::setShortcuts(m_shortcuts);
173}
174
175void UIAction::hideShortcut()
176{
177 m_fShortcutHidden = true;
178 if (!shortcut().isEmpty())
179 QAction::setShortcuts(QList<QKeySequence>());
180}
181
182QString UIAction::nameInMenu() const
183{
184 /* Action-name format depends on action-pool type: */
185 switch (m_enmActionPoolType)
186 {
187 /* Unchanged name for Manager UI: */
188 case UIActionPoolType_Manager: return name();
189 /* Filtered name for Runtime UI: */
190 case UIActionPoolType_Runtime: return UICommon::removeAccelMark(name());
191 }
192 /* Nothing by default: */
193 return QString();
194}
195
196void UIAction::updateIcon()
197{
198 QAction::setIcon(m_icons.value(m_iState));
199}
200
201void UIAction::updateText()
202{
203 /* Action-text format depends on action-pool type: */
204 switch (m_enmActionPoolType)
205 {
206 /* The same as menu name for Manager UI: */
207 case UIActionPoolType_Manager:
208 {
209 setText(nameInMenu());
210 break;
211 }
212 /* With shortcut appended for Runtime UI: */
213 case UIActionPoolType_Runtime:
214 {
215 if (machineMenuAction())
216 setText(uiCommon().insertKeyToActionText(nameInMenu(),
217 gShortcutPool->shortcut(actionPool(), this).primaryToPortableText()));
218 else
219 setText(nameInMenu());
220 break;
221 }
222 }
223}
224
225/* static */
226QString UIAction::simplifyText(QString strText)
227{
228 return strText.remove('.').remove('&');
229}
230
231
232/*********************************************************************************************************************************
233* Class UIActionMenu implementation. *
234*********************************************************************************************************************************/
235
236UIActionMenu::UIActionMenu(UIActionPool *pParent,
237 const QString &strIcon, const QString &strIconDisabled)
238 : UIAction(pParent, UIActionType_Menu)
239{
240 if (!strIcon.isNull())
241 setIcon(UIIconPool::iconSet(strIcon, strIconDisabled));
242 prepare();
243}
244
245UIActionMenu::UIActionMenu(UIActionPool *pParent,
246 const QIcon &icon)
247 : UIAction(pParent, UIActionType_Menu)
248{
249 if (!icon.isNull())
250 setIcon(icon);
251 prepare();
252}
253
254void UIActionMenu::setShowToolTip(bool fShowToolTip)
255{
256 qobject_cast<UIMenu*>(menu())->setShowToolTip(fShowToolTip);
257}
258
259void UIActionMenu::prepare()
260{
261 /* Create menu: */
262 setMenu(new UIMenu);
263 AssertPtrReturnVoid(menu());
264 {
265 /* Prepare menu: */
266 connect(menu(), &UIMenu::aboutToShow,
267 actionPool(), &UIActionPool::sltHandleMenuPrepare);
268 }
269}
270
271void UIActionMenu::updateText()
272{
273 setText(nameInMenu());
274}
275
276
277/*********************************************************************************************************************************
278* Class UIActionSimple implementation. *
279*********************************************************************************************************************************/
280
281UIActionSimple::UIActionSimple(UIActionPool *pParent,
282 bool fMachineMenuAction /* = false */)
283 : UIAction(pParent, UIActionType_Simple, fMachineMenuAction)
284{
285}
286
287UIActionSimple::UIActionSimple(UIActionPool *pParent,
288 const QString &strIcon, const QString &strIconDisabled,
289 bool fMachineMenuAction /* = false */)
290 : UIAction(pParent, UIActionType_Simple, fMachineMenuAction)
291{
292 setIcon(UIIconPool::iconSet(strIcon, strIconDisabled));
293}
294
295UIActionSimple::UIActionSimple(UIActionPool *pParent,
296 const QString &strIconNormal, const QString &strIconSmall,
297 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled,
298 bool fMachineMenuAction /* = false */)
299 : UIAction(pParent, UIActionType_Simple, fMachineMenuAction)
300{
301 setIcon(UIIconPool::iconSetFull(strIconNormal, strIconSmall, strIconNormalDisabled, strIconSmallDisabled));
302}
303
304UIActionSimple::UIActionSimple(UIActionPool *pParent,
305 const QIcon &icon,
306 bool fMachineMenuAction /* = false */)
307 : UIAction(pParent, UIActionType_Simple, fMachineMenuAction)
308{
309 setIcon(icon);
310}
311
312
313/*********************************************************************************************************************************
314* Class UIActionToggle implementation. *
315*********************************************************************************************************************************/
316
317UIActionToggle::UIActionToggle(UIActionPool *pParent,
318 bool fMachineMenuAction /* = false */)
319 : UIAction(pParent, UIActionType_Toggle, fMachineMenuAction)
320{
321 prepare();
322}
323
324UIActionToggle::UIActionToggle(UIActionPool *pParent,
325 const QString &strIcon, const QString &strIconDisabled,
326 bool fMachineMenuAction /* = false */)
327 : UIAction(pParent, UIActionType_Toggle, fMachineMenuAction)
328{
329 setIcon(UIIconPool::iconSet(strIcon, strIconDisabled));
330 prepare();
331}
332
333UIActionToggle::UIActionToggle(UIActionPool *pParent,
334 const QString &strIconOn, const QString &strIconOff,
335 const QString &strIconOnDisabled, const QString &strIconOffDisabled,
336 bool fMachineMenuAction /* = false */)
337 : UIAction(pParent, UIActionType_Toggle, fMachineMenuAction)
338{
339 setIcon(UIIconPool::iconSetOnOff(strIconOn, strIconOff, strIconOnDisabled, strIconOffDisabled));
340 prepare();
341}
342
343UIActionToggle::UIActionToggle(UIActionPool *pParent,
344 const QIcon &icon,
345 bool fMachineMenuAction /* = false */)
346 : UIAction(pParent, UIActionType_Toggle, fMachineMenuAction)
347{
348 if (!icon.isNull())
349 setIcon(icon);
350 prepare();
351}
352
353void UIActionToggle::prepare()
354{
355 setCheckable(true);
356}
357
358
359/*********************************************************************************************************************************
360* Class UIActionPolymorphicMenu implementation. *
361*********************************************************************************************************************************/
362
363UIActionPolymorphicMenu::UIActionPolymorphicMenu(UIActionPool *pParent,
364 const QString &strIcon, const QString &strIconDisabled)
365 : UIAction(pParent, UIActionType_PolymorphicMenu)
366 , m_pMenu(0)
367 , m_iState(0)
368{
369 if (!strIcon.isNull())
370 setIcon(UIIconPool::iconSet(strIcon, strIconDisabled));
371 prepare();
372}
373
374UIActionPolymorphicMenu::UIActionPolymorphicMenu(UIActionPool *pParent,
375 const QString &strIconNormal, const QString &strIconSmall,
376 const QString &strIconNormalDisabled, const QString &strIconSmallDisabled)
377 : UIAction(pParent, UIActionType_PolymorphicMenu)
378 , m_pMenu(0)
379 , m_iState(0)
380{
381 if (!strIconNormal.isNull())
382 setIcon(UIIconPool::iconSetFull(strIconNormal, strIconSmall, strIconNormalDisabled, strIconSmallDisabled));
383 prepare();
384}
385
386UIActionPolymorphicMenu::UIActionPolymorphicMenu(UIActionPool *pParent,
387 const QIcon &icon)
388 : UIAction(pParent, UIActionType_PolymorphicMenu)
389 , m_pMenu(0)
390 , m_iState(0)
391{
392 if (!icon.isNull())
393 setIcon(icon);
394 prepare();
395}
396
397UIActionPolymorphicMenu::~UIActionPolymorphicMenu()
398{
399 /* Hide menu: */
400 hideMenu();
401 /* Delete menu: */
402 delete m_pMenu;
403 m_pMenu = 0;
404}
405
406void UIActionPolymorphicMenu::setShowToolTip(bool fShowToolTip)
407{
408 qobject_cast<UIMenu*>(menu())->setShowToolTip(fShowToolTip);
409}
410
411void UIActionPolymorphicMenu::showMenu()
412{
413 /* Show menu if necessary: */
414 if (!menu())
415 setMenu(m_pMenu);
416}
417
418void UIActionPolymorphicMenu::hideMenu()
419{
420 /* Hide menu if necessary: */
421 if (menu())
422 setMenu(0);
423}
424
425void UIActionPolymorphicMenu::prepare()
426{
427 /* Create menu: */
428 m_pMenu = new UIMenu;
429 AssertPtrReturnVoid(m_pMenu);
430 {
431 /* Prepare menu: */
432 connect(m_pMenu, &UIMenu::aboutToShow,
433 actionPool(), &UIActionPool::sltHandleMenuPrepare);
434 /* Show menu: */
435 showMenu();
436 }
437}
438
439void UIActionPolymorphicMenu::updateText()
440{
441 setText(nameInMenu());
442}
443
444
445/** Menu action extension, used as 'Application' menu class. */
446class UIActionMenuApplication : public UIActionMenu
447{
448 Q_OBJECT;
449
450public:
451
452 /** Constructs action passing @a pParent to the base-class. */
453 UIActionMenuApplication(UIActionPool *pParent)
454 : UIActionMenu(pParent)
455 {
456#ifdef VBOX_WS_MAC
457 menu()->setConsumable(true);
458#endif
459 retranslateUi();
460 }
461
462protected:
463
464 /** Returns action extra-data ID. */
465 virtual int extraDataID() const /* override */
466 {
467 return UIExtraDataMetaDefs::MenuType_Application;
468 }
469 /** Returns action extra-data key. */
470 virtual QString extraDataKey() const /* override */
471 {
472 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_Application);
473 }
474 /** Returns whether action is allowed. */
475 virtual bool isAllowed() const /* override */
476 {
477 return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Application);
478 }
479
480 /** Handles translation event. */
481 virtual void retranslateUi() /* override */
482 {
483#ifdef VBOX_WS_MAC
484 setName(QApplication::translate("UIActionPool", "&VirtualBox"));
485#else
486 setName(QApplication::translate("UIActionPool", "&File"));
487#endif
488 }
489};
490
491
492/** Simple action extension, used as 'Close' action class. */
493class UIActionSimplePerformClose : public UIActionSimple
494{
495 Q_OBJECT;
496
497public:
498
499 /** Constructs action passing @a pParent to the base-class. */
500 UIActionSimplePerformClose(UIActionPool *pParent)
501 : UIActionSimple(pParent, ":/exit_16px.png", ":/exit_16px.png", true)
502 {
503 setMenuRole(QAction::QuitRole);
504 }
505
506protected:
507
508 /** Returns action extra-data ID. */
509 virtual int extraDataID() const /* override */
510 {
511 return UIExtraDataMetaDefs::MenuApplicationActionType_Close;
512 }
513 /** Returns action extra-data key. */
514 virtual QString extraDataKey() const /* override */
515 {
516 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuApplicationActionType_Close);
517 }
518 /** Returns whether action is allowed. */
519 virtual bool isAllowed() const /* override */
520 {
521 return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Close);
522 }
523
524 /** Returns shortcut extra-data ID. */
525 virtual QString shortcutExtraDataID() const /* override */
526 {
527 return QString("Close");
528 }
529
530 /** Returns default shortcut. */
531 virtual QKeySequence defaultShortcut(UIActionPoolType actionPoolType) const /* override */
532 {
533 switch (actionPoolType)
534 {
535 case UIActionPoolType_Manager: break;
536 case UIActionPoolType_Runtime: return QKeySequence("Q");
537 }
538 return QKeySequence();
539 }
540
541 /** Handles translation event. */
542 virtual void retranslateUi() /* override */
543 {
544 setName(QApplication::translate("UIActionPool", "&Close..."));
545 setStatusTip(QApplication::translate("UIActionPool", "Close the virtual machine"));
546 }
547};
548
549#ifdef VBOX_WS_MAC
550/** Menu action extension, used as 'Window' menu class. */
551class UIActionMenuWindow : public UIActionMenu
552{
553 Q_OBJECT;
554
555public:
556
557 /** Constructs action passing @a pParent to the base-class. */
558 UIActionMenuWindow(UIActionPool *pParent)
559 : UIActionMenu(pParent)
560 {}
561
562protected:
563
564 /** Returns action extra-data ID. */
565 virtual int extraDataID() const /* override */
566 {
567 return UIExtraDataMetaDefs::MenuType_Window;
568 }
569 /** Returns action extra-data key. */
570 virtual QString extraDataKey() const /* override */
571 {
572 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_Window);
573 }
574 /** Returns whether action is allowed. */
575 virtual bool isAllowed() const /* override */
576 {
577 return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Window);
578 }
579
580 /** Handles translation event. */
581 virtual void retranslateUi() /* override */
582 {
583 setName(QApplication::translate("UIActionPool", "&Window"));
584 }
585};
586
587
588/** Simple action extension, used as 'Minimize' action class. */
589class UIActionSimpleMinimize : public UIActionSimple
590{
591 Q_OBJECT;
592
593public:
594
595 /** Constructs action passing @a pParent to the base-class. */
596 UIActionSimpleMinimize(UIActionPool *pParent)
597 : UIActionSimple(pParent)
598 {}
599
600protected:
601
602 /** Returns action extra-data ID. */
603 virtual int extraDataID() const /* override */
604 {
605 return UIExtraDataMetaDefs::MenuWindowActionType_Minimize;
606 }
607 /** Returns action extra-data key. */
608 virtual QString extraDataKey() const /* override */
609 {
610 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuWindowActionType_Minimize);
611 }
612 /** Returns whether action is allowed. */
613 virtual bool isAllowed() const /* override */
614 {
615 return actionPool()->isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType_Minimize);
616 }
617
618 /** Returns shortcut extra-data ID. */
619 virtual QString shortcutExtraDataID() const /* override */
620 {
621 return QString("Minimize");
622 }
623
624 /** Handles translation event. */
625 virtual void retranslateUi() /* override */
626 {
627 setName(QApplication::translate("UIActionPool", "&Minimize"));
628 setStatusTip(QApplication::translate("UIActionPool", "Minimize active window"));
629 }
630};
631#endif /* VBOX_WS_MAC */
632
633
634/** Menu action extension, used as 'Help' menu class. */
635class UIActionMenuHelp : public UIActionMenu
636{
637 Q_OBJECT;
638
639public:
640
641 /** Constructs action passing @a pParent to the base-class. */
642 UIActionMenuHelp(UIActionPool *pParent)
643 : UIActionMenu(pParent)
644 {
645 retranslateUi();
646 }
647
648protected:
649
650 /** Returns action extra-data ID. */
651 virtual int extraDataID() const /* override */
652 {
653 return UIExtraDataMetaDefs::MenuType_Help;
654 }
655 /** Returns action extra-data key. */
656 virtual QString extraDataKey() const /* override */
657 {
658 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuType_Help);
659 }
660 /** Returns whether action is allowed. */
661 virtual bool isAllowed() const /* override */
662 {
663 return actionPool()->isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType_Help);
664 }
665
666 /** Handles translation event. */
667 virtual void retranslateUi() /* override */
668 {
669 setName(QApplication::translate("UIActionPool", "&Help"));
670 }
671};
672
673
674/** Simple action extension, used as 'Contents' action class. */
675class UIActionSimpleContents : public UIActionSimple
676{
677 Q_OBJECT;
678
679public:
680
681 /** Constructs action passing @a pParent to the base-class. */
682 UIActionSimpleContents(UIActionPool *pParent)
683 : UIActionSimple(pParent, UIIconPool::defaultIcon(UIIconPool::UIDefaultIconType_DialogHelp), true)
684 {
685 retranslateUi();
686 }
687
688protected:
689
690 /** Returns action extra-data ID. */
691 virtual int extraDataID() const /* override */
692 {
693 return UIExtraDataMetaDefs::MenuHelpActionType_Contents;
694 }
695 /** Returns action extra-data key. */
696 virtual QString extraDataKey() const /* override */
697 {
698 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuHelpActionType_Contents);
699 }
700 /** Returns whether action is allowed. */
701 virtual bool isAllowed() const /* override */
702 {
703 return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Contents);
704 }
705
706 /** Returns shortcut extra-data ID. */
707 virtual QString shortcutExtraDataID() const /* override */
708 {
709 return QString("Help");
710 }
711
712 /** Returns default shortcut. */
713 virtual QKeySequence defaultShortcut(UIActionPoolType actionPoolType) const /* override */
714 {
715 switch (actionPoolType)
716 {
717 case UIActionPoolType_Manager: return QKeySequence(QKeySequence::HelpContents);
718 case UIActionPoolType_Runtime: break;
719 }
720 return QKeySequence();
721 }
722
723 /** Handles translation event. */
724 virtual void retranslateUi() /* override */
725 {
726 setName(QApplication::translate("UIActionPool", "&Contents..."));
727 setStatusTip(QApplication::translate("UIActionPool", "Show help contents"));
728 }
729};
730
731
732/** Simple action extension, used as 'Web Site' action class. */
733class UIActionSimpleWebSite : public UIActionSimple
734{
735 Q_OBJECT;
736
737public:
738
739 /** Constructs action passing @a pParent to the base-class. */
740 UIActionSimpleWebSite(UIActionPool *pParent)
741 : UIActionSimple(pParent, ":/site_16px.png", ":/site_16px.png", true)
742 {
743 retranslateUi();
744 }
745
746protected:
747
748 /** Returns action extra-data ID. */
749 virtual int extraDataID() const /* override */
750 {
751 return UIExtraDataMetaDefs::MenuHelpActionType_WebSite;
752 }
753 /** Returns action extra-data key. */
754 virtual QString extraDataKey() const /* override */
755 {
756 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuHelpActionType_WebSite);
757 }
758 /** Returns whether action is allowed. */
759 virtual bool isAllowed() const /* override */
760 {
761 return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_WebSite);
762 }
763
764 /** Returns shortcut extra-data ID. */
765 virtual QString shortcutExtraDataID() const /* override */
766 {
767 return QString("Web");
768 }
769
770 /** Handles translation event. */
771 virtual void retranslateUi() /* override */
772 {
773 setName(QApplication::translate("UIActionPool", "&VirtualBox Web Site..."));
774 setStatusTip(QApplication::translate("UIActionPool", "Open the browser and go to the VirtualBox product web site"));
775 }
776};
777
778
779/** Simple action extension, used as 'Bug Tracker' action class. */
780class UIActionSimpleBugTracker : public UIActionSimple
781{
782 Q_OBJECT;
783
784public:
785
786 /** Constructs action passing @a pParent to the base-class. */
787 UIActionSimpleBugTracker(UIActionPool *pParent)
788 : UIActionSimple(pParent, ":/site_bugtracker_16px.png", ":/site_bugtracker_16px.png", true)
789 {
790 retranslateUi();
791 }
792
793protected:
794
795 /** Returns action extra-data ID. */
796 virtual int extraDataID() const /* override */
797 {
798 return UIExtraDataMetaDefs::MenuHelpActionType_BugTracker;
799 }
800 /** Returns action extra-data key. */
801 virtual QString extraDataKey() const /* override */
802 {
803 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuHelpActionType_BugTracker);
804 }
805 /** Returns whether action is allowed. */
806 virtual bool isAllowed() const /* override */
807 {
808 return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_BugTracker);
809 }
810
811 /** Returns shortcut extra-data ID. */
812 virtual QString shortcutExtraDataID() const /* override */
813 {
814 return QString("BugTracker");
815 }
816
817 /** Handles translation event. */
818 virtual void retranslateUi() /* override */
819 {
820 setName(QApplication::translate("UIActionPool", "&VirtualBox Bug Tracker..."));
821 setStatusTip(QApplication::translate("UIActionPool", "Open the browser and go to the VirtualBox product bug tracker"));
822 }
823};
824
825
826/** Simple action extension, used as 'Forums' action class. */
827class UIActionSimpleForums : public UIActionSimple
828{
829 Q_OBJECT;
830
831public:
832
833 /** Constructs action passing @a pParent to the base-class. */
834 UIActionSimpleForums(UIActionPool *pParent)
835 : UIActionSimple(pParent, ":/site_forum_16px.png", ":/site_forum_16px.png", true)
836 {
837 retranslateUi();
838 }
839
840protected:
841
842 /** Returns action extra-data ID. */
843 virtual int extraDataID() const /* override */
844 {
845 return UIExtraDataMetaDefs::MenuHelpActionType_Forums;
846 }
847 /** Returns action extra-data key. */
848 virtual QString extraDataKey() const /* override */
849 {
850 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuHelpActionType_Forums);
851 }
852 /** Returns whether action is allowed. */
853 virtual bool isAllowed() const /* override */
854 {
855 return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Forums);
856 }
857
858 /** Returns shortcut extra-data ID. */
859 virtual QString shortcutExtraDataID() const /* override */
860 {
861 return QString("Forums");
862 }
863
864 /** Handles translation event. */
865 virtual void retranslateUi() /* override */
866 {
867 setName(QApplication::translate("UIActionPool", "&VirtualBox Forums..."));
868 setStatusTip(QApplication::translate("UIActionPool", "Open the browser and go to the VirtualBox product forums"));
869 }
870};
871
872
873/** Simple action extension, used as 'Oracle' action class. */
874class UIActionSimpleOracle : public UIActionSimple
875{
876 Q_OBJECT;
877
878public:
879
880 /** Constructs action passing @a pParent to the base-class. */
881 UIActionSimpleOracle(UIActionPool *pParent)
882 : UIActionSimple(pParent, ":/site_oracle_16px.png", ":/site_oracle_16px.png", true)
883 {
884 retranslateUi();
885 }
886
887protected:
888
889 /** Returns action extra-data ID. */
890 virtual int extraDataID() const /* override */
891 {
892 return UIExtraDataMetaDefs::MenuHelpActionType_Oracle;
893 }
894 /** Returns action extra-data key. */
895 virtual QString extraDataKey() const /* override */
896 {
897 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuHelpActionType_Oracle);
898 }
899 /** Returns whether action is allowed. */
900 virtual bool isAllowed() const /* override */
901 {
902 return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_Oracle);
903 }
904
905 /** Returns shortcut extra-data ID. */
906 virtual QString shortcutExtraDataID() const /* override */
907 {
908 return QString("Oracle");
909 }
910
911 /** Handles translation event. */
912 virtual void retranslateUi() /* override */
913 {
914 setName(QApplication::translate("UIActionPool", "&Oracle Web Site..."));
915 setStatusTip(QApplication::translate("UIActionPool", "Open the browser and go to the Oracle web site"));
916 }
917};
918
919
920/** Simple action extension, used as 'Reset Warnings' action class. */
921class UIActionSimpleResetWarnings : public UIActionSimple
922{
923 Q_OBJECT;
924
925public:
926
927 /** Constructs action passing @a pParent to the base-class. */
928 UIActionSimpleResetWarnings(UIActionPool *pParent)
929 : UIActionSimple(pParent, ":/reset_warnings_16px.png", ":/reset_warnings_16px.png", true)
930 {
931 setMenuRole(QAction::ApplicationSpecificRole);
932 retranslateUi();
933 }
934
935protected:
936
937 /** Returns action extra-data ID. */
938 virtual int extraDataID() const /* override */
939 {
940 return UIExtraDataMetaDefs::MenuApplicationActionType_ResetWarnings;
941 }
942 /** Returns action extra-data key. */
943 virtual QString extraDataKey() const /* override */
944 {
945 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuApplicationActionType_ResetWarnings);
946 }
947 /** Returns whether action is allowed. */
948 virtual bool isAllowed() const /* override */
949 {
950 return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_ResetWarnings);
951 }
952
953 /** Returns shortcut extra-data ID. */
954 virtual QString shortcutExtraDataID() const /* override */
955 {
956 return QString("ResetWarnings");
957 }
958
959 /** Handles translation event. */
960 virtual void retranslateUi() /* override */
961 {
962 setName(QApplication::translate("UIActionPool", "&Reset All Warnings"));
963 setStatusTip(QApplication::translate("UIActionPool", "Go back to showing all suppressed warnings and messages"));
964 }
965};
966
967
968#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
969/** Simple action extension, used as 'Network Access Manager' action class. */
970class UIActionSimpleNetworkAccessManager : public UIActionSimple
971{
972 Q_OBJECT;
973
974public:
975
976 /** Constructs action passing @a pParent to the base-class. */
977 UIActionSimpleNetworkAccessManager(UIActionPool *pParent)
978 : UIActionSimple(pParent, ":/download_manager_16px.png", ":/download_manager_16px.png", true)
979 {
980 setMenuRole(QAction::ApplicationSpecificRole);
981 retranslateUi();
982 }
983
984protected:
985
986 /** Returns action extra-data ID. */
987 virtual int extraDataID() const /* override */
988 {
989 return UIExtraDataMetaDefs::MenuApplicationActionType_NetworkAccessManager;
990 }
991 /** Returns action extra-data key. */
992 virtual QString extraDataKey() const /* override */
993 {
994 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuApplicationActionType_NetworkAccessManager);
995 }
996 /** Returns whether action is allowed. */
997 virtual bool isAllowed() const /* override */
998 {
999 return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_NetworkAccessManager);
1000 }
1001
1002 /** Returns shortcut extra-data ID. */
1003 virtual QString shortcutExtraDataID() const /* override */
1004 {
1005 return QString("NetworkAccessManager");
1006 }
1007
1008 /** Handles translation event. */
1009 virtual void retranslateUi() /* override */
1010 {
1011 setName(QApplication::translate("UIActionPool", "&Network Operations Manager..."));
1012 setStatusTip(QApplication::translate("UIActionPool", "Display the Network Operations Manager window"));
1013 }
1014};
1015
1016
1017/** Simple action extension, used as 'Check for Updates' action class. */
1018class UIActionSimpleCheckForUpdates : public UIActionSimple
1019{
1020 Q_OBJECT;
1021
1022public:
1023
1024 /** Constructs action passing @a pParent to the base-class. */
1025 UIActionSimpleCheckForUpdates(UIActionPool *pParent)
1026 : UIActionSimple(pParent, ":/refresh_16px.png", ":/refresh_disabled_16px.png", true)
1027 {
1028 setMenuRole(QAction::ApplicationSpecificRole);
1029 retranslateUi();
1030 }
1031
1032protected:
1033
1034 /** Returns action extra-data ID. */
1035 virtual int extraDataID() const /* override */
1036 {
1037 return UIExtraDataMetaDefs::MenuApplicationActionType_CheckForUpdates;
1038 }
1039 /** Returns action extra-data key. */
1040 virtual QString extraDataKey() const /* override */
1041 {
1042 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuApplicationActionType_CheckForUpdates);
1043 }
1044 /** Returns whether action is allowed. */
1045 virtual bool isAllowed() const /* override */
1046 {
1047 return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_CheckForUpdates);
1048 }
1049
1050 /** Returns shortcut extra-data ID. */
1051 virtual QString shortcutExtraDataID() const /* override */
1052 {
1053 return QString("Update");
1054 }
1055
1056 /** Handles translation event. */
1057 virtual void retranslateUi() /* override */
1058 {
1059 setName(QApplication::translate("UIActionPool", "C&heck for Updates..."));
1060 setStatusTip(QApplication::translate("UIActionPool", "Check for a new VirtualBox version"));
1061 }
1062};
1063#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
1064
1065
1066/** Simple action extension, used as 'About' action class. */
1067class UIActionSimpleAbout : public UIActionSimple
1068{
1069 Q_OBJECT;
1070
1071public:
1072
1073 /** Constructs action passing @a pParent to the base-class. */
1074 UIActionSimpleAbout(UIActionPool *pParent)
1075 : UIActionSimple(pParent, ":/about_16px.png", ":/about_16px.png", true)
1076 {
1077 setMenuRole(QAction::AboutRole);
1078 retranslateUi();
1079 }
1080
1081protected:
1082
1083 /** Returns action extra-data ID. */
1084 virtual int extraDataID() const /* override */
1085 {
1086#ifdef VBOX_WS_MAC
1087 return UIExtraDataMetaDefs::MenuApplicationActionType_About;
1088#else
1089 return UIExtraDataMetaDefs::MenuHelpActionType_About;
1090#endif
1091 }
1092 /** Returns action extra-data key. */
1093 virtual QString extraDataKey() const /* override */
1094 {
1095#ifdef VBOX_WS_MAC
1096 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuApplicationActionType_About);
1097#else
1098 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuHelpActionType_About);
1099#endif
1100 }
1101 /** Returns whether action is allowed. */
1102 virtual bool isAllowed() const /* override */
1103 {
1104#ifdef VBOX_WS_MAC
1105 return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_About);
1106#else
1107 return actionPool()->isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType_About);
1108#endif
1109 }
1110
1111 /** Returns shortcut extra-data ID. */
1112 virtual QString shortcutExtraDataID() const /* override */
1113 {
1114 return QString("About");
1115 }
1116
1117 /** Handles translation event. */
1118 virtual void retranslateUi() /* override */
1119 {
1120 setName(QApplication::translate("UIActionPool", "&About VirtualBox..."));
1121 setStatusTip(QApplication::translate("UIActionPool", "Display a window with product information"));
1122 }
1123};
1124
1125
1126/** Simple action extension, used as 'Preferences' action class. */
1127class UIActionSimplePreferences : public UIActionSimple
1128{
1129 Q_OBJECT;
1130
1131public:
1132
1133 /** Constructs action passing @a pParent to the base-class. */
1134 UIActionSimplePreferences(UIActionPool *pParent)
1135 : UIActionSimple(pParent,
1136 ":/global_settings_32px.png", ":/global_settings_16px.png",
1137 ":/global_settings_disabled_32px.png", ":/global_settings_disabled_16px.png",
1138 true)
1139 {
1140 setMenuRole(QAction::PreferencesRole);
1141 retranslateUi();
1142 }
1143
1144protected:
1145
1146 /** Returns action extra-data ID. */
1147 virtual int extraDataID() const /* override */
1148 {
1149 return UIExtraDataMetaDefs::MenuApplicationActionType_Preferences;
1150 }
1151 /** Returns action extra-data key. */
1152 virtual QString extraDataKey() const /* override */
1153 {
1154 return gpConverter->toInternalString(UIExtraDataMetaDefs::MenuApplicationActionType_Preferences);
1155 }
1156 /** Returns whether action is allowed. */
1157 virtual bool isAllowed() const /* override */
1158 {
1159 return actionPool()->isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType_Preferences);
1160 }
1161
1162 /** Returns shortcut extra-data ID. */
1163 virtual QString shortcutExtraDataID() const /* override */
1164 {
1165 return QString("Preferences");
1166 }
1167
1168 /** Returns default shortcut. */
1169 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1170 {
1171 switch (actionPool()->type())
1172 {
1173 case UIActionPoolType_Manager: return QKeySequence("Ctrl+G");
1174 case UIActionPoolType_Runtime: break;
1175 }
1176 return QKeySequence();
1177 }
1178
1179 /** Handles translation event. */
1180 virtual void retranslateUi() /* override */
1181 {
1182 setName(QApplication::translate("UIActionPool", "&Preferences...", "global preferences window"));
1183 setStatusTip(QApplication::translate("UIActionPool", "Display the global preferences window"));
1184 setToolTip( QApplication::translate("UIActionPool", "Display Global Preferences")
1185 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1186 }
1187};
1188
1189/** Menu action extension, used as 'Log' menu class. */
1190class UIActionMenuSelectorLog : public UIActionMenu
1191{
1192 Q_OBJECT;
1193
1194public:
1195
1196 /** Constructs action passing @a pParent to the base-class. */
1197 UIActionMenuSelectorLog(UIActionPool *pParent)
1198 : UIActionMenu(pParent)
1199 {}
1200
1201protected:
1202
1203 /** Returns shortcut extra-data ID. */
1204 virtual QString shortcutExtraDataID() const /* override */
1205 {
1206 return QString("LogViewerMenu");
1207 }
1208
1209 /** Handles translation event. */
1210 virtual void retranslateUi() /* override */
1211 {
1212 setName(QApplication::translate("UIActionPool", "&Log"));
1213 }
1214};
1215
1216/** Simple action extension, used as 'Toggle Pane Find' action class. */
1217class UIActionMenuSelectorLogTogglePaneFind : public UIActionToggle
1218{
1219 Q_OBJECT;
1220
1221public:
1222
1223 /** Constructs action passing @a pParent to the base-class. */
1224 UIActionMenuSelectorLogTogglePaneFind(UIActionPool *pParent)
1225 : UIActionToggle(pParent)
1226 {
1227 setShortcutContext(Qt::WidgetWithChildrenShortcut);
1228 setIcon(UIIconPool::iconSetFull(":/log_viewer_find_32px.png", ":/log_viewer_find_16px.png",
1229 ":/log_viewer_find_disabled_32px.png", ":/log_viewer_find_disabled_16px.png"));
1230 }
1231
1232protected:
1233
1234 /** Returns shortcut extra-data ID. */
1235 virtual QString shortcutExtraDataID() const /* override */
1236 {
1237 return QString("ToggleLogFind");
1238 }
1239
1240 /** Returns default shortcut. */
1241 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1242 {
1243 return QKeySequence("Ctrl+Shift+F");
1244 }
1245
1246 /** Handles translation event. */
1247 virtual void retranslateUi() /* override */
1248 {
1249 setName(QApplication::translate("UIActionPool", "&Find"));
1250 setShortcutScope(QApplication::translate("UIActionPool", "Log Viewer"));
1251 setStatusTip(QApplication::translate("UIActionPool", "Open pane with searching options"));
1252 setToolTip( QApplication::translate("UIActionPool", "Open Find Pane")
1253 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1254 }
1255};
1256
1257/** Simple action extension, used as 'Toggle Pane Filter' action class. */
1258class UIActionMenuSelectorLogTogglePaneFilter : public UIActionToggle
1259{
1260 Q_OBJECT;
1261
1262public:
1263
1264 /** Constructs action passing @a pParent to the base-class. */
1265 UIActionMenuSelectorLogTogglePaneFilter(UIActionPool *pParent)
1266 : UIActionToggle(pParent)
1267 {
1268 setShortcutContext(Qt::WidgetWithChildrenShortcut);
1269 setIcon(UIIconPool::iconSetFull(":/log_viewer_filter_32px.png", ":/log_viewer_filter_16px.png",
1270 ":/log_viewer_filter_disabled_32px.png", ":/log_viewer_filter_disabled_16px.png"));
1271 }
1272
1273protected:
1274
1275 /** Returns shortcut extra-data ID. */
1276 virtual QString shortcutExtraDataID() const /* override */
1277 {
1278 return QString("ToggleLogFilter");
1279 }
1280
1281 /** Returns default shortcut. */
1282 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1283 {
1284 return QKeySequence("Ctrl+Shift+T");
1285 }
1286
1287 /** Handles translation event. */
1288 virtual void retranslateUi() /* override */
1289 {
1290 setName(QApplication::translate("UIActionPool", "&Filter"));
1291 setShortcutScope(QApplication::translate("UIActionPool", "Log Viewer"));
1292 setStatusTip(QApplication::translate("UIActionPool", "Open pane with filtering options"));
1293 setToolTip( QApplication::translate("UIActionPool", "Open Filter Pane")
1294 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1295 }
1296};
1297
1298/** Simple action extension, used as 'Toggle Pane Bookmark' action class. */
1299class UIActionMenuSelectorLogTogglePaneBookmark : public UIActionToggle
1300{
1301 Q_OBJECT;
1302
1303public:
1304
1305 /** Constructs action passing @a pParent to the base-class. */
1306 UIActionMenuSelectorLogTogglePaneBookmark(UIActionPool *pParent)
1307 : UIActionToggle(pParent)
1308 {
1309 setShortcutContext(Qt::WidgetWithChildrenShortcut);
1310 setIcon(UIIconPool::iconSetFull(":/log_viewer_bookmark_32px.png", ":/log_viewer_bookmark_16px.png",
1311 ":/log_viewer_bookmark_disabled_32px.png", ":/log_viewer_bookmark_disabled_16px.png"));
1312 }
1313
1314protected:
1315
1316 /** Returns shortcut extra-data ID. */
1317 virtual QString shortcutExtraDataID() const /* override */
1318 {
1319 return QString("ToggleLogBookmark");
1320 }
1321
1322 /** Returns default shortcut. */
1323 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1324 {
1325 return QKeySequence("Ctrl+Shift+D");
1326 }
1327
1328 /** Handles translation event. */
1329 virtual void retranslateUi() /* override */
1330 {
1331 setName(QApplication::translate("UIActionPool", "&Bookmark"));
1332 setShortcutScope(QApplication::translate("UIActionPool", "Log Viewer"));
1333 setStatusTip(QApplication::translate("UIActionPool", "Open pane with bookmarking options"));
1334 setToolTip( QApplication::translate("UIActionPool", "Open Bookmark Pane")
1335 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1336 }
1337};
1338
1339/** Simple action extension, used as 'Toggle Pane Options' action class. */
1340class UIActionMenuSelectorLogTogglePaneOptions : public UIActionToggle
1341{
1342 Q_OBJECT;
1343
1344public:
1345
1346 /** Constructs action passing @a pParent to the base-class. */
1347 UIActionMenuSelectorLogTogglePaneOptions(UIActionPool *pParent)
1348 : UIActionToggle(pParent)
1349 {
1350 setShortcutContext(Qt::WidgetWithChildrenShortcut);
1351 setIcon(UIIconPool::iconSetFull(":/log_viewer_options_32px.png", ":/log_viewer_options_16px.png",
1352 ":/log_viewer_options_disabled_32px.png", ":/log_viewer_options_disabled_16px.png"));
1353 }
1354
1355protected:
1356
1357 /** Returns shortcut extra-data ID. */
1358 virtual QString shortcutExtraDataID() const /* override */
1359 {
1360 return QString("ToggleLogOptions");
1361 }
1362
1363 /** Returns default shortcut. */
1364 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1365 {
1366 return QKeySequence("Ctrl+Shift+P");
1367 }
1368
1369 /** Handles translation event. */
1370 virtual void retranslateUi() /* override */
1371 {
1372 setName(QApplication::translate("UIActionPool", "&Options"));
1373 setShortcutScope(QApplication::translate("UIActionPool", "Log Viewer"));
1374 setStatusTip(QApplication::translate("UIActionPool", "Open pane with log viewer options"));
1375 setToolTip( QApplication::translate("UIActionPool", "Open Options Pane")
1376 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1377 }
1378};
1379
1380/** Simple action extension, used as 'Perform Refresh' action class. */
1381class UIActionMenuSelectorLogPerformRefresh : public UIActionSimple
1382{
1383 Q_OBJECT;
1384
1385public:
1386
1387 /** Constructs action passing @a pParent to the base-class. */
1388 UIActionMenuSelectorLogPerformRefresh(UIActionPool *pParent)
1389 : UIActionSimple(pParent,
1390 ":/log_viewer_refresh_32px.png", ":/log_viewer_refresh_16px.png",
1391 ":/log_viewer_refresh_disabled_32px.png", ":/log_viewer_refresh_disabled_16px.png")
1392 {
1393 setShortcutContext(Qt::WidgetWithChildrenShortcut);
1394 }
1395
1396protected:
1397
1398 /** Returns shortcut extra-data ID. */
1399 virtual QString shortcutExtraDataID() const /* override */
1400 {
1401 return QString("RefreshLog");
1402 }
1403
1404 /** Returns default shortcut. */
1405 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1406 {
1407 return QKeySequence("Ctrl+Shift+R");
1408 }
1409
1410 /** Returns standard shortcut. */
1411 virtual QKeySequence standardShortcut(UIActionPoolType) const /* override */
1412 {
1413 return QKeySequence(QKeySequence::Refresh);
1414 }
1415
1416 /** Handles translation event. */
1417 virtual void retranslateUi() /* override */
1418 {
1419 setName(QApplication::translate("UIActionPool", "&Refresh"));
1420 setShortcutScope(QApplication::translate("UIActionPool", "Log Viewer"));
1421 setStatusTip(QApplication::translate("UIActionPool", "Refresh selected virtual machine log"));
1422 setToolTip( QApplication::translate("UIActionPool", "Refresh Virtual Machine Log")
1423 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1424 }
1425};
1426
1427/** Simple action extension, used as 'Perform Save' action class. */
1428class UIActionMenuSelectorLogPerformSave : public UIActionSimple
1429{
1430 Q_OBJECT;
1431
1432public:
1433
1434 /** Constructs action passing @a pParent to the base-class. */
1435 UIActionMenuSelectorLogPerformSave(UIActionPool *pParent)
1436 : UIActionSimple(pParent,
1437 ":/log_viewer_save_32px.png", ":/log_viewer_save_16px.png",
1438 ":/log_viewer_save_disabled_32px.png", ":/log_viewer_save_disabled_16px.png")
1439 {
1440 setShortcutContext(Qt::WidgetWithChildrenShortcut);
1441 }
1442
1443protected:
1444
1445 /** Returns shortcut extra-data ID. */
1446 virtual QString shortcutExtraDataID() const /* override */
1447 {
1448 return QString("SaveLog");
1449 }
1450
1451 /** Returns default shortcut. */
1452 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1453 {
1454 return QKeySequence("Ctrl+Shift+S");
1455 }
1456
1457 /** Handles translation event. */
1458 virtual void retranslateUi() /* override */
1459 {
1460 setName(QApplication::translate("UIActionPool", "&Save..."));
1461 setShortcutScope(QApplication::translate("UIActionPool", "Log Viewer"));
1462 setStatusTip(QApplication::translate("UIActionPool", "Save selected virtual machine log"));
1463 setToolTip( QApplication::translate("UIActionPool", "Save Virtual Machine Log")
1464 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1465 }
1466};
1467
1468/** Menu action extension, used as 'File Manager' menu class. */
1469class UIActionMenuFileManager : public UIActionMenu
1470{
1471 Q_OBJECT;
1472
1473public:
1474
1475 /** Constructs action passing @a pParent to the base-class. */
1476 UIActionMenuFileManager(UIActionPool *pParent)
1477 : UIActionMenu(pParent)
1478 {}
1479
1480protected:
1481
1482 /** Returns shortcut extra-data ID. */
1483 virtual QString shortcutExtraDataID() const /* override */
1484 {
1485 return QString("FileManagerMenu");
1486 }
1487
1488 /** Handles translation event. */
1489 virtual void retranslateUi() /* override */
1490 {
1491 setName(QApplication::translate("UIActionPool", "File Manager"));
1492 }
1493};
1494
1495class UIActionMenuFileManagerHostSubmenu : public UIActionMenu
1496{
1497 Q_OBJECT;
1498
1499public:
1500
1501 /** Constructs action passing @a pParent to the base-class. */
1502 UIActionMenuFileManagerHostSubmenu(UIActionPool *pParent)
1503 : UIActionMenu(pParent)
1504 {}
1505
1506protected:
1507
1508 /** Returns shortcut extra-data ID. */
1509 virtual QString shortcutExtraDataID() const /* override */
1510 {
1511 return QString("FileManagerHostSubmenu");
1512 }
1513
1514 /** Handles translation event. */
1515 virtual void retranslateUi() /* override */
1516 {
1517 setName(QApplication::translate("UIActionPool", "Host"));
1518 }
1519};
1520
1521class UIActionMenuFileManagerGuestSubmenu : public UIActionMenu
1522{
1523 Q_OBJECT;
1524
1525public:
1526
1527 /** Constructs action passing @a pParent to the base-class. */
1528 UIActionMenuFileManagerGuestSubmenu(UIActionPool *pParent)
1529 : UIActionMenu(pParent)
1530 {}
1531
1532protected:
1533
1534 /** Returns shortcut extra-data ID. */
1535 virtual QString shortcutExtraDataID() const /* override */
1536 {
1537 return QString("FileManagerGuestSubmenu");
1538 }
1539
1540 /** Handles translation event. */
1541 virtual void retranslateUi() /* override */
1542 {
1543 setName(QApplication::translate("UIActionPool", "Guest"));
1544 }
1545};
1546
1547
1548/** Simple action extension, used as 'Copy to Guest' in file manager action class. */
1549class UIActionMenuFileManagerCopyToGuest : public UIActionSimple
1550{
1551 Q_OBJECT;
1552
1553public:
1554
1555 /** Constructs action passing @a pParent to the base-class. */
1556 UIActionMenuFileManagerCopyToGuest(UIActionPool *pParent)
1557 : UIActionSimple(pParent,
1558 ":/file_manager_copy_to_guest_24px.png", ":/file_manager_copy_to_guest_16px.png",
1559 ":/file_manager_copy_to_guest_disabled_24px.png", ":/file_manager_copy_to_guest_disabled_16px.png"){}
1560
1561protected:
1562
1563 /** Returns shortcut extra-data ID. */
1564 virtual QString shortcutExtraDataID() const /* override */
1565 {
1566 return QString("FileManagerCopyToGuest");
1567 }
1568
1569 /** Returns default shortcut. */
1570 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1571 {
1572 return QKeySequence();
1573 }
1574
1575 /** Handles translation event. */
1576 virtual void retranslateUi() /* override */
1577 {
1578 setName(QApplication::translate("UIActionPool", "Copy to guest"));
1579 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1580 setStatusTip(QApplication::translate("UIActionPool", "Copy the selected object(s) from host to guest"));
1581 setToolTip( QApplication::translate("UIActionPool", "Copy from Host to Guest")
1582 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1583 }
1584};
1585
1586/** Simple action extension, used as 'Copy to Host' in file manager action class. */
1587class UIActionMenuFileManagerCopyToHost : public UIActionSimple
1588{
1589 Q_OBJECT;
1590
1591public:
1592
1593 /** Constructs action passing @a pParent to the base-class. */
1594 UIActionMenuFileManagerCopyToHost(UIActionPool *pParent)
1595 : UIActionSimple(pParent,
1596 ":/file_manager_copy_to_host_24px.png", ":/file_manager_copy_to_host_16px.png",
1597 ":/file_manager_copy_to_host_disabled_24px.png", ":/file_manager_copy_to_host_disabled_16px.png"){}
1598
1599protected:
1600
1601 /** Returns shortcut extra-data ID. */
1602 virtual QString shortcutExtraDataID() const /* override */
1603 {
1604 return QString("FileManagerCopyToHost");
1605 }
1606
1607 /** Returns default shortcut. */
1608 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1609 {
1610 return QKeySequence();
1611 }
1612
1613 /** Handles translation event. */
1614 virtual void retranslateUi() /* override */
1615 {
1616 setName(QApplication::translate("UIActionPool", "Copy to host"));
1617 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1618 setStatusTip(QApplication::translate("UIActionPool", "Copy the selected object(s) from guest to host"));
1619 setToolTip( QApplication::translate("UIActionPool", "Copy from Guest to Host")
1620 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1621 }
1622};
1623
1624/** Toggle action extension, used to toggle 'File Manager Options' panel in file manager. */
1625class UIActionMenuFileManagerOptions : public UIActionToggle
1626{
1627 Q_OBJECT;
1628
1629public:
1630
1631 /** Constructs action passing @a pParent to the base-class. */
1632 UIActionMenuFileManagerOptions(UIActionPool *pParent)
1633 : UIActionToggle(pParent)
1634 {
1635 setShortcutContext(Qt::WidgetWithChildrenShortcut);
1636 setIcon(UIIconPool::iconSetFull(":/file_manager_options_32px.png", ":/file_manager_options_16px.png",
1637 ":/file_manager_options_disabled_32px.png", ":/file_manager_options_disabled_16px.png"));
1638 }
1639
1640protected:
1641
1642 /** Returns shortcut extra-data ID. */
1643 virtual QString shortcutExtraDataID() const /* override */
1644 {
1645 return QString("ToggleFileManagerOptionsPanel");
1646 }
1647
1648 /** Returns default shortcut. */
1649 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1650 {
1651 return QKeySequence();
1652 }
1653
1654 /** Handles translation event. */
1655 virtual void retranslateUi() /* override */
1656 {
1657 setName(QApplication::translate("UIActionPool", "Options"));
1658 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1659 setStatusTip(QApplication::translate("UIActionPool", "Open panel with file manager options"));
1660 setToolTip( QApplication::translate("UIActionPool", "Open Options Pane")
1661 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1662 }
1663};
1664
1665/** Toggle action extension, used to toggle 'File Manager Log' panel in file manager. */
1666class UIActionMenuFileManagerLog : public UIActionToggle
1667{
1668 Q_OBJECT;
1669
1670public:
1671
1672 /** Constructs action passing @a pParent to the base-class. */
1673 UIActionMenuFileManagerLog(UIActionPool *pParent)
1674 : UIActionToggle(pParent)
1675 {
1676 setShortcutContext(Qt::WidgetWithChildrenShortcut);
1677 setIcon(UIIconPool::iconSetFull(":/file_manager_log_32px.png", ":/file_manager_log_16px.png",
1678 ":/file_manager_log_disabled_32px.png", ":/file_manager_log_disabled_16px.png"));
1679 }
1680
1681protected:
1682
1683 /** Returns shortcut extra-data ID. */
1684 virtual QString shortcutExtraDataID() const /* override */
1685 {
1686 return QString("ToggleFileManagerLogPanel");
1687 }
1688
1689 /** Returns default shortcut. */
1690 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1691 {
1692 return QKeySequence();
1693 }
1694
1695 /** Handles translation event. */
1696 virtual void retranslateUi() /* override */
1697 {
1698 setName(QApplication::translate("UIActionPool", "Log"));
1699 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1700 setStatusTip(QApplication::translate("UIActionPool", "Open panel with file manager log"));
1701 setToolTip( QApplication::translate("UIActionPool", "Open Log Pane")
1702 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1703 }
1704};
1705
1706/** Toggle action extension, used to toggle 'File Manager Operations' panel in file manager. */
1707class UIActionMenuFileManagerOperations : public UIActionToggle
1708{
1709 Q_OBJECT;
1710
1711public:
1712
1713 /** Constructs action passing @a pParent to the base-class. */
1714 UIActionMenuFileManagerOperations(UIActionPool *pParent)
1715 : UIActionToggle(pParent)
1716 {
1717 setShortcutContext(Qt::WidgetWithChildrenShortcut);
1718 setIcon(UIIconPool::iconSetFull(":/file_manager_operations_32px.png", ":/file_manager_operations_16px.png",
1719 ":/file_manager_operations_disabled_32px.png", ":/file_manager_operations_disabled_16px.png"));
1720 }
1721
1722protected:
1723
1724 /** Returns shortcut extra-data ID. */
1725 virtual QString shortcutExtraDataID() const /* override */
1726 {
1727 return QString("ToggleFileManagerOperationsPanel");
1728 }
1729
1730 /** Returns default shortcut. */
1731 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1732 {
1733 return QKeySequence();
1734 }
1735
1736 /** Handles translation event. */
1737 virtual void retranslateUi() /* override */
1738 {
1739 setName(QApplication::translate("UIActionPool", "Operations"));
1740 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1741 setStatusTip(QApplication::translate("UIActionPool", "Open panel with file manager operations"));
1742 setToolTip( QApplication::translate("UIActionPool", "Open Operations Pane")
1743 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1744 }
1745};
1746
1747/** Toggle action extension, used to toggle 'File Manager Session' panel in file manager. */
1748class UIActionMenuFileManagerSession : public UIActionToggle
1749{
1750 Q_OBJECT;
1751
1752public:
1753
1754 /** Constructs action passing @a pParent to the base-class. */
1755 UIActionMenuFileManagerSession(UIActionPool *pParent)
1756 : UIActionToggle(pParent)
1757 {
1758 setShortcutContext(Qt::WidgetWithChildrenShortcut);
1759 setIcon(UIIconPool::iconSetFull(":/file_manager_session_32px.png", ":/file_manager_session_16px.png",
1760 ":/file_manager_session_disabled_32px.png", ":/file_manager_session_disabled_16px.png"));
1761 }
1762
1763protected:
1764
1765 /** Returns shortcut extra-data ID. */
1766 virtual QString shortcutExtraDataID() const /* override */
1767 {
1768 return QString("ToggleFileManagerSessionPanel");
1769 }
1770
1771 /** Returns default shortcut. */
1772 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1773 {
1774 return QKeySequence();
1775 }
1776
1777 /** Handles translation event. */
1778 virtual void retranslateUi() /* override */
1779 {
1780 setName(QApplication::translate("UIActionPool", "Session"));
1781 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1782 setStatusTip(QApplication::translate("UIActionPool", "Open panel with file manager session"));
1783 setToolTip( QApplication::translate("UIActionPool", "Open Session Pane")
1784 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1785 }
1786};
1787
1788/** Simple action extension, used as 'Perform GoUp' in file manager action class. */
1789class UIActionMenuFileManagerGoUp : public UIActionSimple
1790{
1791 Q_OBJECT;
1792
1793public:
1794
1795 /** Constructs action passing @a pParent to the base-class. */
1796 UIActionMenuFileManagerGoUp(UIActionPool *pParent)
1797 : UIActionSimple(pParent,
1798 ":/file_manager_go_up_24px.png", ":/file_manager_go_up_16px.png",
1799 ":/file_manager_go_up_disabled_24px.png", ":/file_manager_go_up_disabled_16px.png")
1800 {}
1801
1802protected:
1803
1804 /** Returns shortcut extra-data ID. */
1805 virtual QString shortcutExtraDataID() const /* override */
1806 {
1807 return QString("FileManagerGoUp");
1808 }
1809
1810 /** Returns default shortcut. */
1811 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1812 {
1813 return QKeySequence();
1814 }
1815
1816 /** Handles translation event. */
1817 virtual void retranslateUi() /* override */
1818 {
1819 setName(QApplication::translate("UIActionPool", "Go Up"));
1820 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1821 setStatusTip(QApplication::translate("UIActionPool", "Go one level up to parent folder"));
1822 setToolTip( QApplication::translate("UIActionPool", "Go One Level Up")
1823 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1824 }
1825};
1826
1827
1828/** Simple action extension, used as 'Perform GoHome' in file manager action class. */
1829class UIActionMenuFileManagerGoHome : public UIActionSimple
1830{
1831 Q_OBJECT;
1832
1833public:
1834
1835 /** Constructs action passing @a pParent to the base-class. */
1836 UIActionMenuFileManagerGoHome(UIActionPool *pParent)
1837 : UIActionSimple(pParent,
1838 ":/file_manager_go_home_24px.png", ":/file_manager_go_home_16px.png",
1839 ":/file_manager_go_home_disabled_24px.png", ":/file_manager_go_home_disabled_16px.png")
1840 {}
1841
1842protected:
1843
1844 /** Returns shortcut extra-data ID. */
1845 virtual QString shortcutExtraDataID() const /* override */
1846 {
1847 return QString("FileManagerGoHome");
1848 }
1849
1850 /** Returns default shortcut. */
1851 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1852 {
1853 return QKeySequence();
1854 }
1855
1856 /** Handles translation event. */
1857 virtual void retranslateUi() /* override */
1858 {
1859 setName(QApplication::translate("UIActionPool", "Go Home"));
1860 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1861 setStatusTip(QApplication::translate("UIActionPool", "Go to home folder"));
1862 setToolTip( QApplication::translate("UIActionPool", "Go to Home Folder")
1863 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1864 }
1865};
1866
1867
1868/** Simple action extension, used as 'Perform Delete' in file manager action class. */
1869class UIActionMenuFileManagerDelete : public UIActionSimple
1870{
1871 Q_OBJECT;
1872
1873public:
1874
1875 /** Constructs action passing @a pParent to the base-class. */
1876 UIActionMenuFileManagerDelete(UIActionPool *pParent)
1877 : UIActionSimple(pParent,
1878 ":/file_manager_delete_24px.png", ":/file_manager_delete_16px.png",
1879 ":/file_manager_delete_disabled_24px.png", ":/file_manager_delete_disabled_16px.png")
1880 {}
1881
1882protected:
1883
1884 /** Returns shortcut extra-data ID. */
1885 virtual QString shortcutExtraDataID() const /* override */
1886 {
1887 return QString("FileManagerDelete");
1888 }
1889
1890 /** Returns default shortcut. */
1891 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1892 {
1893 return QKeySequence();
1894 }
1895
1896 /** Handles translation event. */
1897 virtual void retranslateUi() /* override */
1898 {
1899 setName(QApplication::translate("UIActionPool", "Delete"));
1900 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1901 setStatusTip(QApplication::translate("UIActionPool", "Delete selected file object(s)"));
1902 setToolTip( QApplication::translate("UIActionPool", "Delete Selected Object(s)")
1903 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1904 }
1905};
1906
1907/** Simple action extension, used as 'Perform Refresh' in file manager action class. */
1908class UIActionMenuFileManagerRefresh : public UIActionSimple
1909{
1910 Q_OBJECT;
1911
1912public:
1913
1914 /** Constructs action passing @a pParent to the base-class. */
1915 UIActionMenuFileManagerRefresh(UIActionPool *pParent)
1916 : UIActionSimple(pParent,
1917 ":/file_manager_refresh_24px.png", ":/file_manager_refresh_16px.png",
1918 ":/file_manager_refresh_disabled_24px.png", ":/file_manager_refresh_disabled_16px.png")
1919 {}
1920
1921protected:
1922
1923 /** Returns shortcut extra-data ID. */
1924 virtual QString shortcutExtraDataID() const /* override */
1925 {
1926 return QString("FileManagerRefresh");
1927 }
1928
1929 /** Returns default shortcut. */
1930 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1931 {
1932 return QKeySequence();
1933 }
1934
1935 /** Handles translation event. */
1936 virtual void retranslateUi() /* override */
1937 {
1938 setName(QApplication::translate("UIActionPool", "Refresh"));
1939 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1940 setStatusTip(QApplication::translate("UIActionPool", "Refresh"));
1941 setToolTip( QApplication::translate("UIActionPool", "Refresh Contents")
1942 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1943 }
1944};
1945
1946
1947/** Simple action extension, used as 'Perform Rename' in file manager action class. */
1948class UIActionMenuFileManagerRename : public UIActionSimple
1949{
1950 Q_OBJECT;
1951
1952public:
1953
1954 /** Constructs action passing @a pParent to the base-class. */
1955 UIActionMenuFileManagerRename(UIActionPool *pParent)
1956 : UIActionSimple(pParent,
1957 ":/file_manager_rename_24px.png", ":/file_manager_rename_16px.png",
1958 ":/file_manager_rename_disabled_24px.png", ":/file_manager_rename_disabled_16px.png"){}
1959
1960protected:
1961
1962 /** Returns shortcut extra-data ID. */
1963 virtual QString shortcutExtraDataID() const /* override */
1964 {
1965 return QString("FileManagerRename");
1966 }
1967
1968 /** Returns default shortcut. */
1969 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
1970 {
1971 return QKeySequence();
1972 }
1973
1974 /** Handles translation event. */
1975 virtual void retranslateUi() /* override */
1976 {
1977 setName(QApplication::translate("UIActionPool", "Rename"));
1978 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
1979 setStatusTip(QApplication::translate("UIActionPool", "Rename selected file object"));
1980 setToolTip( QApplication::translate("UIActionPool", "Rename Selected Object")
1981 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
1982 }
1983};
1984
1985/** Simple action extension, used as 'Perform Rename' in file manager action class. */
1986class UIActionMenuFileManagerCreateNewDirectory : public UIActionSimple
1987{
1988 Q_OBJECT;
1989
1990public:
1991
1992 /** Constructs action passing @a pParent to the base-class. */
1993 UIActionMenuFileManagerCreateNewDirectory(UIActionPool *pParent)
1994 : UIActionSimple(pParent,
1995 ":/file_manager_new_directory_24px.png", ":/file_manager_new_directory_16px.png",
1996 ":/file_manager_new_directory_disabled_24px.png", ":/file_manager_new_directory_disabled_16px.png"){}
1997
1998protected:
1999
2000 /** Returns shortcut extra-data ID. */
2001 virtual QString shortcutExtraDataID() const /* override */
2002 {
2003 return QString("FileManagerCreateNewDirectory");
2004 }
2005
2006 /** Returns default shortcut. */
2007 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
2008 {
2009 return QKeySequence();
2010 }
2011
2012 /** Handles translation event. */
2013 virtual void retranslateUi() /* override */
2014 {
2015 setName(QApplication::translate("UIActionPool", "Create New Directory"));
2016 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
2017 setStatusTip(QApplication::translate("UIActionPool", "Create New Directory"));
2018 setToolTip( QApplication::translate("UIActionPool", "Create New Directory")
2019 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
2020 }
2021};
2022
2023
2024/** Simple action extension, used as 'Perform Copy' in file manager action class. */
2025class UIActionMenuFileManagerCopy : public UIActionSimple
2026{
2027 Q_OBJECT;
2028
2029public:
2030
2031 /** Constructs action passing @a pParent to the base-class. */
2032 UIActionMenuFileManagerCopy(UIActionPool *pParent)
2033 : UIActionSimple(pParent,
2034 ":/file_manager_copy_24px.png", ":/file_manager_copy_16px.png",
2035 ":/file_manager_copy_disabled_24px.png", ":/file_manager_copy_disabled_16px.png"){}
2036
2037protected:
2038
2039 /** Returns shortcut extra-data ID. */
2040 virtual QString shortcutExtraDataID() const /* override */
2041 {
2042 return QString("FileManagerCopy");
2043 }
2044
2045 /** Returns default shortcut. */
2046 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
2047 {
2048 return QKeySequence();
2049 }
2050
2051 /** Handles translation event. */
2052 virtual void retranslateUi() /* override */
2053 {
2054 setName(QApplication::translate("UIActionPool", "Copy"));
2055 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
2056 setStatusTip(QApplication::translate("UIActionPool", "Copy selected file object(s)"));
2057 setToolTip( QApplication::translate("UIActionPool", "Copy Selected Object(s)")
2058 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
2059 }
2060};
2061
2062/** Simple action extension, used as 'Perform Cut' in file manager action class. */
2063class UIActionMenuFileManagerCut : public UIActionSimple
2064{
2065 Q_OBJECT;
2066
2067public:
2068
2069 /** Constructs action passing @a pParent to the base-class. */
2070 UIActionMenuFileManagerCut(UIActionPool *pParent)
2071 : UIActionSimple(pParent,
2072 ":/file_manager_cut_24px.png", ":/file_manager_cut_16px.png",
2073 ":/file_manager_cut_disabled_24px.png", ":/file_manager_cut_disabled_16px.png"){}
2074
2075protected:
2076
2077 /** Returns shortcut extra-data ID. */
2078 virtual QString shortcutExtraDataID() const /* override */
2079 {
2080 return QString("FileManagerCut");
2081 }
2082
2083 /** Returns default shortcut. */
2084 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
2085 {
2086 return QKeySequence();
2087 }
2088
2089 /** Handles translation event. */
2090 virtual void retranslateUi() /* override */
2091 {
2092 setName(QApplication::translate("UIActionPool", "Cut"));
2093 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
2094 setStatusTip(QApplication::translate("UIActionPool", "Cut selected file object(s)"));
2095 setToolTip( QApplication::translate("UIActionPool", "Cut Selected Object(s)")
2096 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
2097 }
2098};
2099
2100/** Simple action extension, used as 'Perform Paste' in file manager action class. */
2101class UIActionMenuFileManagerPaste : public UIActionSimple
2102{
2103 Q_OBJECT;
2104
2105public:
2106
2107 /** Constructs action passing @a pParent to the base-class. */
2108 UIActionMenuFileManagerPaste(UIActionPool *pParent)
2109 : UIActionSimple(pParent,
2110 ":/file_manager_paste_24px.png", ":/file_manager_paste_16px.png",
2111 ":/file_manager_paste_disabled_24px.png", ":/file_manager_paste_disabled_16px.png"){}
2112
2113protected:
2114
2115 /** Returns shortcut extra-data ID. */
2116 virtual QString shortcutExtraDataID() const /* override */
2117 {
2118 return QString("FileManagerPaste");
2119 }
2120
2121 /** Returns default shortcut. */
2122 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
2123 {
2124 return QKeySequence();
2125 }
2126
2127 /** Handles translation event. */
2128 virtual void retranslateUi() /* override */
2129 {
2130 setName(QApplication::translate("UIActionPool", "Paste"));
2131 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
2132 setStatusTip(QApplication::translate("UIActionPool", "Paste copied/cut file object(s)"));
2133 setToolTip( QApplication::translate("UIActionPool", "Paste Copied/Cut Object(s)")
2134 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
2135 }
2136};
2137
2138/** Simple action extension, used as 'Select All' in file manager action class. */
2139class UIActionMenuFileManagerSelectAll : public UIActionSimple
2140{
2141 Q_OBJECT;
2142
2143public:
2144
2145 /** Constructs action passing @a pParent to the base-class. */
2146 UIActionMenuFileManagerSelectAll(UIActionPool *pParent)
2147 : UIActionSimple(pParent,
2148 ":/file_manager_select_all_24px.png", ":/file_manager_select_all_16px.png",
2149 ":/file_manager_select_all_disabled_24px.png", ":/file_manager_select_all_disabled_16px.png"){}
2150
2151protected:
2152
2153 /** Returns shortcut extra-data ID. */
2154 virtual QString shortcutExtraDataID() const /* override */
2155 {
2156 return QString("FileManagerSelectAll");
2157 }
2158
2159 /** Returns default shortcut. */
2160 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
2161 {
2162 return QKeySequence();
2163 }
2164
2165 /** Handles translation event. */
2166 virtual void retranslateUi() /* override */
2167 {
2168 setName(QApplication::translate("UIActionPool", "Select All"));
2169 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
2170 setStatusTip(QApplication::translate("UIActionPool", "Select all files objects"));
2171 setToolTip( QApplication::translate("UIActionPool", "Select All Objects")
2172 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
2173 }
2174};
2175
2176
2177/** Simple action extension, used as 'Invert Selection' in file manager action class. */
2178class UIActionMenuFileManagerInvertSelection : public UIActionSimple
2179{
2180 Q_OBJECT;
2181
2182public:
2183
2184 /** Constructs action passing @a pParent to the base-class. */
2185 UIActionMenuFileManagerInvertSelection(UIActionPool *pParent)
2186 : UIActionSimple(pParent,
2187 ":/file_manager_invert_selection_24px.png", ":/file_manager_invert_selection_16px.png",
2188 ":/file_manager_invert_selection_disabled_24px.png", ":/file_manager_invert_selection_disabled_16px.png"){}
2189
2190protected:
2191
2192 /** Returns shortcut extra-data ID. */
2193 virtual QString shortcutExtraDataID() const /* override */
2194 {
2195 return QString("FileManagerInvertSelection");
2196 }
2197
2198 /** Returns default shortcut. */
2199 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
2200 {
2201 return QKeySequence();
2202 }
2203
2204 /** Handles translation event. */
2205 virtual void retranslateUi() /* override */
2206 {
2207 setName(QApplication::translate("UIActionPool", "Invert Selection"));
2208 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
2209 setStatusTip(QApplication::translate("UIActionPool", "Invert the current selection"));
2210 setToolTip( QApplication::translate("UIActionPool", "Invert Current Selection")
2211 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
2212 }
2213};
2214
2215
2216/** Simple action extension, used as 'Show Properties' in file manager action class. */
2217class UIActionMenuFileManagerShowProperties : public UIActionSimple
2218{
2219 Q_OBJECT;
2220
2221public:
2222
2223 /** Constructs action passing @a pParent to the base-class. */
2224 UIActionMenuFileManagerShowProperties(UIActionPool *pParent)
2225 : UIActionSimple(pParent,
2226 ":/file_manager_properties_24px.png", ":/file_manager_properties_16px.png",
2227 ":/file_manager_properties_disabled_24px.png", ":/file_manager_properties_disabled_16px.png"){}
2228
2229protected:
2230
2231 /** Returns shortcut extra-data ID. */
2232 virtual QString shortcutExtraDataID() const /* override */
2233 {
2234 return QString("FileManagerShowProperties");
2235 }
2236
2237 /** Returns default shortcut. */
2238 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */
2239 {
2240 return QKeySequence();
2241 }
2242
2243 /** Handles translation event. */
2244 virtual void retranslateUi() /* override */
2245 {
2246 setName(QApplication::translate("UIActionPool", "Show Properties"));
2247 setShortcutScope(QApplication::translate("UIActionPool", "File Manager"));
2248 setStatusTip(QApplication::translate("UIActionPool", "Show the properties of currently selected file object(s)"));
2249 setToolTip( QApplication::translate("UIActionPool", "Show Properties of Current Object(s)")
2250 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString())));
2251 }
2252};
2253
2254
2255
2256
2257
2258/*********************************************************************************************************************************
2259* Class UIActionPool implementation. *
2260*********************************************************************************************************************************/
2261
2262/* static */
2263UIActionPool *UIActionPool::create(UIActionPoolType enmType)
2264{
2265 UIActionPool *pActionPool = 0;
2266 switch (enmType)
2267 {
2268 case UIActionPoolType_Manager: pActionPool = new UIActionPoolManager; break;
2269 case UIActionPoolType_Runtime: pActionPool = new UIActionPoolRuntime; break;
2270 default: AssertFailedReturn(0);
2271 }
2272 AssertPtrReturn(pActionPool, 0);
2273 pActionPool->prepare();
2274 return pActionPool;
2275}
2276
2277/* static */
2278void UIActionPool::destroy(UIActionPool *pActionPool)
2279{
2280 AssertPtrReturnVoid(pActionPool);
2281 pActionPool->cleanup();
2282 delete pActionPool;
2283}
2284
2285/* static */
2286void UIActionPool::createTemporary(UIActionPoolType enmType)
2287{
2288 UIActionPool *pActionPool = 0;
2289 switch (enmType)
2290 {
2291 case UIActionPoolType_Manager: pActionPool = new UIActionPoolManager(true); break;
2292 case UIActionPoolType_Runtime: pActionPool = new UIActionPoolRuntime(true); break;
2293 default: AssertFailedReturnVoid();
2294 }
2295 AssertPtrReturnVoid(pActionPool);
2296 pActionPool->prepare();
2297 pActionPool->cleanup();
2298 delete pActionPool;
2299}
2300
2301UIActionPool::UIActionPool(UIActionPoolType enmType, bool fTemporary /* = false */)
2302 : m_enmType(enmType)
2303 , m_fTemporary(fTemporary)
2304{
2305}
2306
2307UIActionPoolRuntime *UIActionPool::toRuntime()
2308{
2309 return qobject_cast<UIActionPoolRuntime*>(this);
2310}
2311
2312UIActionPoolManager *UIActionPool::toManager()
2313{
2314 return qobject_cast<UIActionPoolManager*>(this);
2315}
2316
2317QActionGroup *UIActionPool::actionGroup(int iIndex) const
2318{
2319 AssertReturn(m_groupPool.contains(iIndex), 0);
2320 return m_groupPool.value(iIndex);
2321}
2322
2323bool UIActionPool::isAllowedInMenuBar(UIExtraDataMetaDefs::MenuType enmType) const
2324{
2325 foreach (const UIExtraDataMetaDefs::MenuType &enmRestriction, m_restrictedMenus.values())
2326 if (enmRestriction & enmType)
2327 return false;
2328 return true;
2329}
2330
2331void UIActionPool::setRestrictionForMenuBar(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuType enmRestriction)
2332{
2333 m_restrictedMenus[enmLevel] = enmRestriction;
2334 updateMenus();
2335}
2336
2337bool UIActionPool::isAllowedInMenuApplication(UIExtraDataMetaDefs::MenuApplicationActionType enmType) const
2338{
2339 foreach (const UIExtraDataMetaDefs::MenuApplicationActionType &enmRestriction, m_restrictedActionsMenuApplication.values())
2340 if (enmRestriction & enmType)
2341 return false;
2342 return true;
2343}
2344
2345void UIActionPool::setRestrictionForMenuApplication(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuApplicationActionType enmRestriction)
2346{
2347 m_restrictedActionsMenuApplication[enmLevel] = enmRestriction;
2348 m_invalidations << UIActionIndex_M_Application;
2349}
2350
2351#ifdef VBOX_WS_MAC
2352bool UIActionPool::isAllowedInMenuWindow(UIExtraDataMetaDefs::MenuWindowActionType enmType) const
2353{
2354 foreach (const UIExtraDataMetaDefs::MenuWindowActionType &enmRestriction, m_restrictedActionsMenuWindow.values())
2355 if (enmRestriction & enmType)
2356 return false;
2357 return true;
2358}
2359
2360void UIActionPool::setRestrictionForMenuWindow(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuWindowActionType enmRestriction)
2361{
2362 m_restrictedActionsMenuWindow[enmLevel] = enmRestriction;
2363 m_invalidations << UIActionIndex_M_Window;
2364}
2365#endif /* VBOX_WS_MAC */
2366
2367bool UIActionPool::isAllowedInMenuHelp(UIExtraDataMetaDefs::MenuHelpActionType enmType) const
2368{
2369 foreach (const UIExtraDataMetaDefs::MenuHelpActionType &enmRestriction, m_restrictedActionsMenuHelp.values())
2370 if (enmRestriction & enmType)
2371 return false;
2372 return true;
2373}
2374
2375void UIActionPool::setRestrictionForMenuHelp(UIActionRestrictionLevel enmLevel, UIExtraDataMetaDefs::MenuHelpActionType enmRestriction)
2376{
2377 m_restrictedActionsMenuHelp[enmLevel] = enmRestriction;
2378 m_invalidations << UIActionIndex_Menu_Help;
2379}
2380
2381void UIActionPool::sltHandleMenuPrepare()
2382{
2383 /* Make sure menu is valid: */
2384 AssertPtrReturnVoid(sender());
2385 UIMenu *pMenu = qobject_cast<UIMenu*>(sender());
2386 AssertPtrReturnVoid(pMenu);
2387 /* Make sure action is valid: */
2388 AssertPtrReturnVoid(pMenu->menuAction());
2389 UIAction *pAction = qobject_cast<UIAction*>(pMenu->menuAction());
2390 AssertPtrReturnVoid(pAction);
2391
2392 /* Determine action index: */
2393 const int iIndex = m_pool.key(pAction);
2394
2395 /* Update menu if necessary: */
2396 updateMenu(iIndex);
2397
2398 /* Notify listeners about menu prepared: */
2399 emit sigNotifyAboutMenuPrepare(iIndex, pMenu);
2400}
2401
2402#ifdef VBOX_WS_MAC
2403void UIActionPool::sltActionHovered()
2404{
2405 /* Acquire sender action: */
2406 UIAction *pAction = qobject_cast<UIAction*>(sender());
2407 AssertPtrReturnVoid(pAction);
2408 //printf("Action hovered: {%s}\n", pAction->name().toUtf8().constData());
2409
2410 /* Notify listener about action hevering: */
2411 emit sigActionHovered(pAction);
2412}
2413#endif /* VBOX_WS_MAC */
2414
2415void UIActionPool::prepare()
2416{
2417 /* Prepare pool: */
2418 preparePool();
2419 /* Prepare connections: */
2420 prepareConnections();
2421 /* Update configuration: */
2422 updateConfiguration();
2423 /* Update shortcuts: */
2424 updateShortcuts();
2425}
2426
2427void UIActionPool::preparePool()
2428{
2429 /* Create 'Application' actions: */
2430 m_pool[UIActionIndex_M_Application] = new UIActionMenuApplication(this);
2431#ifdef VBOX_WS_MAC
2432 m_pool[UIActionIndex_M_Application_S_About] = new UIActionSimpleAbout(this);
2433#endif
2434 m_pool[UIActionIndex_M_Application_S_Preferences] = new UIActionSimplePreferences(this);
2435#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
2436 m_pool[UIActionIndex_M_Application_S_NetworkAccessManager] = new UIActionSimpleNetworkAccessManager(this);
2437 m_pool[UIActionIndex_M_Application_S_CheckForUpdates] = new UIActionSimpleCheckForUpdates(this);
2438#endif
2439 m_pool[UIActionIndex_M_Application_S_ResetWarnings] = new UIActionSimpleResetWarnings(this);
2440 m_pool[UIActionIndex_M_Application_S_Close] = new UIActionSimplePerformClose(this);
2441
2442#ifdef VBOX_WS_MAC
2443 /* Create 'Window' actions: */
2444 m_pool[UIActionIndex_M_Window] = new UIActionMenuWindow(this);
2445 m_pool[UIActionIndex_M_Window_S_Minimize] = new UIActionSimpleMinimize(this);
2446#endif
2447
2448 /* Create 'Help' actions: */
2449 m_pool[UIActionIndex_Menu_Help] = new UIActionMenuHelp(this);
2450 m_pool[UIActionIndex_Simple_Contents] = new UIActionSimpleContents(this);
2451 m_pool[UIActionIndex_Simple_WebSite] = new UIActionSimpleWebSite(this);
2452 m_pool[UIActionIndex_Simple_BugTracker] = new UIActionSimpleBugTracker(this);
2453 m_pool[UIActionIndex_Simple_Forums] = new UIActionSimpleForums(this);
2454 m_pool[UIActionIndex_Simple_Oracle] = new UIActionSimpleOracle(this);
2455#ifndef VBOX_WS_MAC
2456 m_pool[UIActionIndex_Simple_About] = new UIActionSimpleAbout(this);
2457#endif
2458
2459 /* Create 'Log Viewer' actions: */
2460 m_pool[UIActionIndex_M_LogWindow] = new UIActionMenuSelectorLog(this);
2461 m_pool[UIActionIndex_M_Log] = new UIActionMenuSelectorLog(this);
2462 m_pool[UIActionIndex_M_Log_T_Find] = new UIActionMenuSelectorLogTogglePaneFind(this);
2463 m_pool[UIActionIndex_M_Log_T_Filter] = new UIActionMenuSelectorLogTogglePaneFilter(this);
2464 m_pool[UIActionIndex_M_Log_T_Bookmark] = new UIActionMenuSelectorLogTogglePaneBookmark(this);
2465 m_pool[UIActionIndex_M_Log_T_Options] = new UIActionMenuSelectorLogTogglePaneOptions(this);
2466 m_pool[UIActionIndex_M_Log_S_Refresh] = new UIActionMenuSelectorLogPerformRefresh(this);
2467 m_pool[UIActionIndex_M_Log_S_Save] = new UIActionMenuSelectorLogPerformSave(this);
2468
2469 /* Create 'File Manager' actions: */
2470 m_pool[UIActionIndex_M_FileManager] = new UIActionMenuFileManager(this);
2471 m_pool[UIActionIndex_M_FileManager_M_HostSubmenu] = new UIActionMenuFileManagerHostSubmenu(this);
2472 m_pool[UIActionIndex_M_FileManager_M_GuestSubmenu] = new UIActionMenuFileManagerGuestSubmenu(this);
2473 m_pool[UIActionIndex_M_FileManager_S_CopyToGuest] = new UIActionMenuFileManagerCopyToGuest(this);
2474 m_pool[UIActionIndex_M_FileManager_S_CopyToHost] = new UIActionMenuFileManagerCopyToHost(this);
2475
2476 m_pool[UIActionIndex_M_FileManager_T_Options] = new UIActionMenuFileManagerOptions(this);
2477 m_pool[UIActionIndex_M_FileManager_T_Log] = new UIActionMenuFileManagerLog(this);
2478 m_pool[UIActionIndex_M_FileManager_T_Operations] = new UIActionMenuFileManagerOperations(this);
2479 m_pool[UIActionIndex_M_FileManager_T_Session] = new UIActionMenuFileManagerSession(this);
2480
2481 m_pool[UIActionIndex_M_FileManager_S_Host_GoUp] = new UIActionMenuFileManagerGoUp(this);
2482 m_pool[UIActionIndex_M_FileManager_S_Guest_GoUp] = new UIActionMenuFileManagerGoUp(this);
2483 m_pool[UIActionIndex_M_FileManager_S_Host_GoHome] = new UIActionMenuFileManagerGoHome(this);
2484 m_pool[UIActionIndex_M_FileManager_S_Guest_GoHome] = new UIActionMenuFileManagerGoHome(this);
2485 m_pool[UIActionIndex_M_FileManager_S_Host_Refresh] = new UIActionMenuFileManagerRefresh(this);
2486 m_pool[UIActionIndex_M_FileManager_S_Guest_Refresh] = new UIActionMenuFileManagerRefresh(this);
2487 m_pool[UIActionIndex_M_FileManager_S_Host_Delete] = new UIActionMenuFileManagerDelete(this);
2488 m_pool[UIActionIndex_M_FileManager_S_Guest_Delete] = new UIActionMenuFileManagerDelete(this);
2489 m_pool[UIActionIndex_M_FileManager_S_Host_Rename] = new UIActionMenuFileManagerRename(this);
2490 m_pool[UIActionIndex_M_FileManager_S_Guest_Rename] = new UIActionMenuFileManagerRename(this);
2491 m_pool[UIActionIndex_M_FileManager_S_Host_CreateNewDirectory] = new UIActionMenuFileManagerCreateNewDirectory(this);
2492 m_pool[UIActionIndex_M_FileManager_S_Guest_CreateNewDirectory] = new UIActionMenuFileManagerCreateNewDirectory(this);
2493 m_pool[UIActionIndex_M_FileManager_S_Host_Copy] = new UIActionMenuFileManagerCopy(this);
2494 m_pool[UIActionIndex_M_FileManager_S_Guest_Copy] = new UIActionMenuFileManagerCopy(this);
2495 m_pool[UIActionIndex_M_FileManager_S_Host_Cut] = new UIActionMenuFileManagerCut(this);
2496 m_pool[UIActionIndex_M_FileManager_S_Guest_Cut] = new UIActionMenuFileManagerCut(this);
2497 m_pool[UIActionIndex_M_FileManager_S_Host_Paste] = new UIActionMenuFileManagerPaste(this);
2498 m_pool[UIActionIndex_M_FileManager_S_Guest_Paste] = new UIActionMenuFileManagerPaste(this);
2499 m_pool[UIActionIndex_M_FileManager_S_Host_SelectAll] = new UIActionMenuFileManagerSelectAll(this);
2500 m_pool[UIActionIndex_M_FileManager_S_Guest_SelectAll] = new UIActionMenuFileManagerSelectAll(this);
2501 m_pool[UIActionIndex_M_FileManager_S_Host_InvertSelection] = new UIActionMenuFileManagerInvertSelection(this);
2502 m_pool[UIActionIndex_M_FileManager_S_Guest_InvertSelection] = new UIActionMenuFileManagerInvertSelection(this);
2503 m_pool[UIActionIndex_M_FileManager_S_Host_ShowProperties] = new UIActionMenuFileManagerShowProperties(this);
2504 m_pool[UIActionIndex_M_FileManager_S_Guest_ShowProperties] = new UIActionMenuFileManagerShowProperties(this);
2505
2506
2507 /* Prepare update-handlers for known menus: */
2508#ifdef VBOX_WS_MAC
2509 m_menuUpdateHandlers[UIActionIndex_M_Application].ptf = &UIActionPool::updateMenuApplication;
2510 m_menuUpdateHandlers[UIActionIndex_M_Window].ptf = &UIActionPool::updateMenuWindow;
2511#endif
2512 m_menuUpdateHandlers[UIActionIndex_Menu_Help].ptf = &UIActionPool::updateMenuHelp;
2513 m_menuUpdateHandlers[UIActionIndex_M_LogWindow].ptf = &UIActionPool::updateMenuLogViewerWindow;
2514 m_menuUpdateHandlers[UIActionIndex_M_Log].ptf = &UIActionPool::updateMenuLogViewer;
2515
2516 m_menuUpdateHandlers[UIActionIndex_M_FileManager].ptf = &UIActionPool::updateMenuFileManager;
2517
2518 /* Invalidate all known menus: */
2519 m_invalidations.unite(m_menuUpdateHandlers.keys().toSet());
2520
2521 /* Retranslate finally: */
2522 retranslateUi();
2523}
2524
2525void UIActionPool::prepareConnections()
2526{
2527 /* 'Application' menu connections: */
2528#ifdef VBOX_WS_MAC
2529 connect(action(UIActionIndex_M_Application_S_About), &UIAction::triggered,
2530 &msgCenter(), &UIMessageCenter::sltShowHelpAboutDialog, Qt::UniqueConnection);
2531#endif
2532#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
2533 connect(action(UIActionIndex_M_Application_S_NetworkAccessManager), &UIAction::triggered,
2534 gNetworkManager, &UINetworkManager::show, Qt::UniqueConnection);
2535 connect(action(UIActionIndex_M_Application_S_CheckForUpdates), &UIAction::triggered,
2536 gUpdateManager, &UIUpdateManager::sltForceCheck, Qt::UniqueConnection);
2537#endif
2538 connect(action(UIActionIndex_M_Application_S_ResetWarnings), &UIAction::triggered,
2539 &msgCenter(), &UIMessageCenter::sltResetSuppressedMessages, Qt::UniqueConnection);
2540
2541 /* 'Help' menu connections: */
2542 connect(action(UIActionIndex_Simple_Contents), &UIAction::triggered,
2543 &msgCenter(), &UIMessageCenter::sltShowHelpHelpDialog, Qt::UniqueConnection);
2544 connect(action(UIActionIndex_Simple_WebSite), &UIAction::triggered,
2545 &msgCenter(), &UIMessageCenter::sltShowHelpWebDialog, Qt::UniqueConnection);
2546 connect(action(UIActionIndex_Simple_BugTracker), &UIAction::triggered,
2547 &msgCenter(), &UIMessageCenter::sltShowBugTracker, Qt::UniqueConnection);
2548 connect(action(UIActionIndex_Simple_Forums), &UIAction::triggered,
2549 &msgCenter(), &UIMessageCenter::sltShowForums, Qt::UniqueConnection);
2550 connect(action(UIActionIndex_Simple_Oracle), &UIAction::triggered,
2551 &msgCenter(), &UIMessageCenter::sltShowOracle, Qt::UniqueConnection);
2552#ifndef VBOX_WS_MAC
2553 connect(action(UIActionIndex_Simple_About), &UIAction::triggered,
2554 &msgCenter(), &UIMessageCenter::sltShowHelpAboutDialog, Qt::UniqueConnection);
2555#endif
2556}
2557
2558void UIActionPool::cleanupPool()
2559{
2560 qDeleteAll(m_groupPool);
2561 qDeleteAll(m_pool);
2562}
2563
2564void UIActionPool::cleanup()
2565{
2566 /* Cleanup pool: */
2567 cleanupPool();
2568}
2569
2570void UIActionPool::updateShortcuts()
2571{
2572 gShortcutPool->applyShortcuts(this);
2573}
2574
2575bool UIActionPool::processHotKey(const QKeySequence &key)
2576{
2577 /* Iterate through the whole list of keys: */
2578 foreach (const int &iKey, m_pool.keys())
2579 {
2580 /* Get current action: */
2581 UIAction *pAction = m_pool.value(iKey);
2582 /* Skip menus/separators: */
2583 if (pAction->type() == UIActionType_Menu)
2584 continue;
2585 /* Get the hot-key of the current action: */
2586 const QString strHotKey = gShortcutPool->shortcut(this, pAction).primaryToPortableText();
2587 if (pAction->isEnabled() && pAction->isAllowed() && !strHotKey.isEmpty())
2588 {
2589 if (key.matches(QKeySequence(strHotKey)) == QKeySequence::ExactMatch)
2590 {
2591 /* We asynchronously post a special event instead of calling
2592 * pAction->trigger() directly, to let key presses and
2593 * releases be processed correctly by Qt first.
2594 * Note: we assume that nobody will delete the menu item
2595 * corresponding to the key sequence, so that the pointer to
2596 * menu data posted along with the event will remain valid in
2597 * the event handler, at least until the main window is closed. */
2598 QApplication::postEvent(this, new ActivateActionEvent(pAction));
2599 return true;
2600 }
2601 }
2602 }
2603 return false;
2604}
2605
2606void UIActionPool::updateConfiguration()
2607{
2608 /* Recache common action restrictions: */
2609 // Nothing here for now..
2610
2611#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
2612 /* Recache update action restrictions: */
2613 bool fUpdateAllowed = gEDataManager->applicationUpdateEnabled();
2614 if (!fUpdateAllowed)
2615 {
2616 m_restrictedActionsMenuApplication[UIActionRestrictionLevel_Base] = (UIExtraDataMetaDefs::MenuApplicationActionType)
2617 (m_restrictedActionsMenuApplication[UIActionRestrictionLevel_Base] | UIExtraDataMetaDefs::MenuApplicationActionType_CheckForUpdates);
2618 }
2619#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
2620
2621 /* Update menus: */
2622 updateMenus();
2623}
2624
2625void UIActionPool::updateMenu(int iIndex)
2626{
2627 /* Make sure index belongs to this class: */
2628 AssertReturnVoid(iIndex < UIActionIndex_Max);
2629
2630 /* If menu with such index is invalidated
2631 * and there is update-handler => handle it here: */
2632 if ( m_invalidations.contains(iIndex)
2633 && m_menuUpdateHandlers.contains(iIndex))
2634 (this->*(m_menuUpdateHandlers.value(iIndex).ptf))();
2635}
2636
2637void UIActionPool::updateMenuApplication()
2638{
2639 /* Get corresponding menu: */
2640 UIMenu *pMenu = action(UIActionIndex_M_Application)->menu();
2641 AssertPtrReturnVoid(pMenu);
2642#ifdef VBOX_WS_MAC
2643 AssertReturnVoid(pMenu->isConsumable());
2644#endif
2645 /* Clear contents: */
2646#ifdef VBOX_WS_MAC
2647 if (!pMenu->isConsumed())
2648#endif
2649 pMenu->clear();
2650
2651 /* Separator: */
2652 bool fSeparator = false;
2653
2654#ifdef VBOX_WS_MAC
2655 /* 'About' action: */
2656 fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_About)) || fSeparator;
2657#endif
2658
2659 /* 'Preferences' action: */
2660 fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_Preferences)) || fSeparator;
2661
2662#ifndef VBOX_WS_MAC
2663 /* Separator: */
2664 if (fSeparator)
2665 {
2666 pMenu->addSeparator();
2667 fSeparator = false;
2668 }
2669#endif
2670
2671#ifdef VBOX_GUI_WITH_NETWORK_MANAGER
2672 /* 'Network Manager' action: */
2673 fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_NetworkAccessManager)) || fSeparator;
2674#endif
2675 /* 'Reset Warnings' action: */
2676 fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_ResetWarnings)) || fSeparator;
2677
2678#ifndef VBOX_WS_MAC
2679 /* Separator: */
2680 if (fSeparator)
2681 {
2682 pMenu->addSeparator();
2683 fSeparator = false;
2684 }
2685#endif
2686
2687 /* 'Close' action: */
2688 fSeparator = addAction(pMenu, action(UIActionIndex_M_Application_S_Close)) || fSeparator;
2689
2690 /* Mark menu as valid: */
2691 m_invalidations.remove(UIActionIndex_M_Application);
2692}
2693
2694#ifdef VBOX_WS_MAC
2695void UIActionPool::updateMenuWindow()
2696{
2697 /* Get corresponding menu: */
2698 UIMenu *pMenu = action(UIActionIndex_M_Window)->menu();
2699 AssertPtrReturnVoid(pMenu);
2700 /* Clear contents: */
2701 pMenu->clear();
2702
2703 /* Separator: */
2704 bool fSeparator = false;
2705
2706 /* 'Minimize' action: */
2707 fSeparator = addAction(pMenu, action(UIActionIndex_M_Window_S_Minimize)) || fSeparator;
2708
2709 /* Separator: */
2710 if (fSeparator)
2711 {
2712 pMenu->addSeparator();
2713 fSeparator = false;
2714 }
2715
2716 /* This menu always remains invalid.. */
2717}
2718#endif /* VBOX_WS_MAC */
2719
2720void UIActionPool::updateMenuHelp()
2721{
2722 /* Get corresponding menu: */
2723 UIMenu *pMenu = action(UIActionIndex_Menu_Help)->menu();
2724 AssertPtrReturnVoid(pMenu);
2725 /* Clear contents: */
2726 pMenu->clear();
2727
2728 /* Separator? */
2729 bool fSeparator = false;
2730
2731 /* 'Contents' action: */
2732 fSeparator = addAction(pMenu, action(UIActionIndex_Simple_Contents)) || fSeparator;
2733 /* 'Web Site' action: */
2734 fSeparator = addAction(pMenu, action(UIActionIndex_Simple_WebSite)) || fSeparator;
2735 /* 'Bug Tracker' action: */
2736 fSeparator = addAction(pMenu, action(UIActionIndex_Simple_BugTracker)) || fSeparator;
2737 /* 'Forums' action: */
2738 fSeparator = addAction(pMenu, action(UIActionIndex_Simple_Forums)) || fSeparator;
2739 /* 'Oracle' action: */
2740 fSeparator = addAction(pMenu, action(UIActionIndex_Simple_Oracle)) || fSeparator;
2741
2742 /* Separator? */
2743 if (fSeparator)
2744 {
2745 pMenu->addSeparator();
2746 fSeparator = false;
2747 }
2748
2749#ifndef VBOX_WS_MAC
2750 /* 'About' action: */
2751 fSeparator = addAction(pMenu, action(UIActionIndex_Simple_About)) || fSeparator;
2752#endif
2753
2754 /* Mark menu as valid: */
2755 m_invalidations.remove(UIActionIndex_Menu_Help);
2756}
2757
2758void UIActionPool::updateMenuLogViewerWindow()
2759{
2760 /* Update corresponding menu: */
2761 updateMenuLogViewerWrapper(action(UIActionIndex_M_LogWindow)->menu());
2762
2763 /* Mark menu as valid: */
2764 m_invalidations.remove(UIActionIndex_M_LogWindow);
2765}
2766
2767void UIActionPool::updateMenuLogViewer()
2768{
2769 /* Update corresponding menu: */
2770 updateMenuLogViewerWrapper(action(UIActionIndex_M_Log)->menu());
2771
2772 /* Mark menu as valid: */
2773 m_invalidations.remove(UIActionIndex_M_Log);
2774}
2775
2776void UIActionPool::updateMenuLogViewerWrapper(UIMenu *pMenu)
2777{
2778 /* Clear contents: */
2779 pMenu->clear();
2780
2781 /* Separator? */
2782 bool fSeparator = false;
2783
2784 /* 'Save' action: */
2785 fSeparator = addAction(pMenu, action(UIActionIndex_M_Log_S_Save)) || fSeparator;
2786
2787 /* Separator? */
2788 if (fSeparator)
2789 {
2790 pMenu->addSeparator();
2791 fSeparator = false;
2792 }
2793
2794 /* 'Find' action: */
2795 fSeparator = addAction(pMenu, action(UIActionIndex_M_Log_T_Find)) || fSeparator;
2796 /* 'Filter' action: */
2797 fSeparator = addAction(pMenu, action(UIActionIndex_M_Log_T_Filter)) || fSeparator;
2798 /* 'Bookmarks' action: */
2799 fSeparator = addAction(pMenu, action(UIActionIndex_M_Log_T_Bookmark)) || fSeparator;
2800 /* 'Options' action: */
2801 fSeparator = addAction(pMenu, action(UIActionIndex_M_Log_T_Options)) || fSeparator;
2802
2803 /* Separator? */
2804 if (fSeparator)
2805 {
2806 pMenu->addSeparator();
2807 fSeparator = false;
2808 }
2809
2810 /* 'Refresh' action: */
2811 fSeparator = addAction(pMenu, action(UIActionIndex_M_Log_S_Refresh)) || fSeparator;
2812}
2813
2814void UIActionPool::updateMenuFileManager()
2815{
2816 updateMenuFileManagerWrapper(action(UIActionIndex_M_FileManager)->menu());
2817
2818 /* Mark menu as valid: */
2819 m_invalidations.remove(UIActionIndex_M_FileManager);
2820}
2821
2822void UIActionPool::updateMenuFileManagerWrapper(UIMenu *pMenu)
2823{
2824 addAction(pMenu, action(UIActionIndex_M_FileManager_T_Session));
2825 addAction(pMenu, action(UIActionIndex_M_FileManager_T_Options));
2826 addAction(pMenu, action(UIActionIndex_M_FileManager_T_Operations));
2827 addAction(pMenu, action(UIActionIndex_M_FileManager_T_Log));
2828
2829 addAction(pMenu, action(UIActionIndex_M_FileManager_M_HostSubmenu));
2830 addAction(pMenu, action(UIActionIndex_M_FileManager_M_GuestSubmenu));
2831
2832 UIMenu *pHostSubmenu = action(UIActionIndex_M_FileManager_M_HostSubmenu)->menu();
2833 if (pHostSubmenu)
2834 {
2835 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_GoUp));
2836 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_GoHome));
2837 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_Refresh));
2838 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_Delete));
2839 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_Rename));
2840 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_CreateNewDirectory));
2841 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_Copy));
2842 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_Cut));
2843 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_Paste));
2844 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_SelectAll));
2845 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_InvertSelection));
2846 addAction(pHostSubmenu, action(UIActionIndex_M_FileManager_S_Host_ShowProperties));
2847 }
2848
2849 UIMenu *pGuestSubmenu = action(UIActionIndex_M_FileManager_M_GuestSubmenu)->menu();
2850 if (pGuestSubmenu)
2851 {
2852 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Host_GoUp));
2853 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_GoHome));
2854 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_Refresh));
2855 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_Delete));
2856 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_Rename));
2857 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_CreateNewDirectory));
2858 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_Copy));
2859 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_Cut));
2860 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_Paste));
2861 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_SelectAll));
2862 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_InvertSelection));
2863 addAction(pGuestSubmenu, action(UIActionIndex_M_FileManager_S_Guest_ShowProperties));
2864 }
2865}
2866
2867void UIActionPool::retranslateUi()
2868{
2869 /* Translate all the actions: */
2870 foreach (const int iActionPoolKey, m_pool.keys())
2871 m_pool[iActionPoolKey]->retranslateUi();
2872 /* Update shortcuts: */
2873 updateShortcuts();
2874}
2875
2876bool UIActionPool::event(QEvent *pEvent)
2877{
2878 /* Depending on event-type: */
2879 switch ((UIEventType)pEvent->type())
2880 {
2881 case ActivateActionEventType:
2882 {
2883 /* Process specific event: */
2884 ActivateActionEvent *pActionEvent = static_cast<ActivateActionEvent*>(pEvent);
2885 pActionEvent->action()->trigger();
2886 pEvent->accept();
2887 return true;
2888 }
2889 default:
2890 break;
2891 }
2892 /* Pass to the base-class: */
2893 return QObject::event(pEvent);
2894}
2895
2896bool UIActionPool::addAction(UIMenu *pMenu, UIAction *pAction, bool fReallyAdd /* = true */)
2897{
2898 /* Check if action is allowed: */
2899 const bool fIsActionAllowed = pAction->isAllowed();
2900
2901#ifdef VBOX_WS_MAC
2902 /* Check if menu is consumable: */
2903 const bool fIsMenuConsumable = pMenu->isConsumable();
2904 /* Check if menu is NOT yet consumed: */
2905 const bool fIsMenuConsumed = pMenu->isConsumed();
2906#endif
2907
2908 /* Make this action visible
2909 * depending on clearance state. */
2910 pAction->setVisible(fIsActionAllowed);
2911
2912#ifdef VBOX_WS_MAC
2913 /* If menu is consumable: */
2914 if (fIsMenuConsumable)
2915 {
2916 /* Add action only if menu was not yet consumed: */
2917 if (!fIsMenuConsumed)
2918 pMenu->addAction(pAction);
2919 }
2920 /* If menu is NOT consumable: */
2921 else
2922#endif
2923 {
2924 /* Add action only if is allowed: */
2925 if (fIsActionAllowed && fReallyAdd)
2926 pMenu->addAction(pAction);
2927 }
2928
2929 /* Return if action is allowed: */
2930 return fIsActionAllowed;
2931}
2932
2933bool UIActionPool::addMenu(QList<QMenu*> &menuList, UIAction *pAction, bool fReallyAdd /* = true */)
2934{
2935 /* Check if action is allowed: */
2936 const bool fIsActionAllowed = pAction->isAllowed();
2937
2938 /* Get action's menu: */
2939 UIMenu *pMenu = pAction->menu();
2940
2941#ifdef VBOX_WS_MAC
2942 /* Check if menu is consumable: */
2943 const bool fIsMenuConsumable = pMenu->isConsumable();
2944 /* Check if menu is NOT yet consumed: */
2945 const bool fIsMenuConsumed = pMenu->isConsumed();
2946#endif
2947
2948 /* Make this action visible
2949 * depending on clearance state. */
2950 pAction->setVisible( fIsActionAllowed
2951#ifdef VBOX_WS_MAC
2952 && !fIsMenuConsumable
2953#endif
2954 );
2955
2956#ifdef VBOX_WS_MAC
2957 /* If menu is consumable: */
2958 if (fIsMenuConsumable)
2959 {
2960 /* Add action's menu only if menu was not yet consumed: */
2961 if (!fIsMenuConsumed)
2962 menuList << pMenu;
2963 }
2964 /* If menu is NOT consumable: */
2965 else
2966#endif
2967 {
2968 /* Add action only if is allowed: */
2969 if (fIsActionAllowed && fReallyAdd)
2970 menuList << pMenu;
2971 }
2972
2973 /* Return if action is allowed: */
2974 return fIsActionAllowed;
2975}
2976
2977
2978#include "UIActionPool.moc"
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use