VirtualBox

Changeset 27132 in vbox for trunk/src


Ignore:
Timestamp:
Mar 6, 2010 1:33:12 PM (15 years ago)
Author:
vboxsync
Message:

FE/Qt4: new core: dock menu

Location:
trunk/src/VBox/Frontends/VirtualBox/src/runtime
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionsPool.cpp

    r26919 r27132  
    2626#include "VBoxGlobal.h"
    2727
     28/* Global includes */
     29#include <QtGlobal>
     30
    2831/* Action activation event */
    2932class ActivateActionEvent : public QEvent
     
    957960};
    958961
     962#ifdef Q_WS_MAC
     963class DockMenuAction : public UIMenuAction
     964{
     965    Q_OBJECT;
     966
     967public:
     968
     969    DockMenuAction(QObject *pParent)
     970        : UIMenuAction(pParent)
     971    {
     972        retranslateUi();
     973    }
     974
     975protected:
     976
     977    void retranslateUi() {}
     978};
     979
     980class DockSettingsMenuAction : public UIMenuAction
     981{
     982    Q_OBJECT;
     983
     984public:
     985
     986    DockSettingsMenuAction(QObject *pParent)
     987        : UIMenuAction(pParent)
     988    {
     989        retranslateUi();
     990    }
     991
     992protected:
     993
     994    void retranslateUi()
     995    {
     996        setText(UIActionsPool::tr("Dock Icon"));
     997    }
     998};
     999
     1000class ToggleDockPreviewMonitorAction : public UIToggleAction
     1001{
     1002    Q_OBJECT;
     1003
     1004public:
     1005
     1006    ToggleDockPreviewMonitorAction(QObject *pParent)
     1007        : UIToggleAction(pParent)
     1008    {
     1009        retranslateUi();
     1010    }
     1011
     1012protected:
     1013
     1014    void retranslateUi()
     1015    {
     1016        setText(UIActionsPool::tr("Show Monitor Preview"));
     1017    }
     1018};
     1019
     1020class ToggleDockDisableMonitorAction : public UIToggleAction
     1021{
     1022    Q_OBJECT;
     1023
     1024public:
     1025
     1026    ToggleDockDisableMonitorAction(QObject *pParent)
     1027        : UIToggleAction(pParent)
     1028    {
     1029        retranslateUi();
     1030    }
     1031
     1032protected:
     1033
     1034    void retranslateUi()
     1035    {
     1036        setText(UIActionsPool::tr("Show Application Icon"));
     1037    }
     1038};
     1039#endif /* Q_WS_MAC */
    9591040
    9601041UIActionsPool::UIActionsPool(QObject *pParent)
     
    10031084    m_actionsPool[UIActionIndex_Simple_About] = new ShowAboutAction(this);
    10041085
     1086#ifdef Q_WS_MAC
     1087    /* "Dock" menu actions: */
     1088    m_actionsPool[UIActionIndex_Toggle_DockPreviewMonitor] = new ToggleDockPreviewMonitorAction(this);
     1089    m_actionsPool[UIActionIndex_Toggle_DockDisableMonitor] = new ToggleDockDisableMonitorAction(this);
     1090#endif /* Q_WS_MAC */
     1091
    10051092    /* Create all menus */
    10061093    createMenus();
     
    10641151        delete m_actionsPool[UIActionIndex_Menu_Help];
    10651152    m_actionsPool[UIActionIndex_Menu_Help] = new MenuHelpAction(this);
     1153
     1154#ifdef Q_WS_MAC
     1155    if (m_actionsPool[UIActionIndex_Menu_Dock])
     1156        delete m_actionsPool[UIActionIndex_Menu_Dock];
     1157    m_actionsPool[UIActionIndex_Menu_Dock] = new DockMenuAction(this);
     1158    if (m_actionsPool[UIActionIndex_Menu_DockSettings])
     1159        delete m_actionsPool[UIActionIndex_Menu_DockSettings];
     1160    m_actionsPool[UIActionIndex_Menu_DockSettings] = new DockSettingsMenuAction(this);
     1161#endif /* Q_WS_MAC */
    10661162}
    10671163
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIActionsPool.h

    r26919 r27132  
    106106    UIActionIndex_Simple_About,
    107107
     108#ifdef Q_WS_MAC
     109    UIActionIndex_Menu_Dock,
     110    UIActionIndex_Menu_DockSettings,
     111    UIActionIndex_Toggle_DockPreviewMonitor,
     112    UIActionIndex_Toggle_DockDisableMonitor,
     113#endif /* Q_WS_MAC */
     114
    108115    UIActionIndex_End
    109116};
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.cpp

    r27044 r27132  
    562562#endif
    563563}
     564
     565#ifdef Q_WS_MAC
     566void UIMachineLogic::prepareDock()
     567{
     568    QMenu *pDockMenu = actionsPool()->action(UIActionIndex_Menu_Dock)->menu();
     569
     570    /* Add all VM menu entries to the dock menu. Leave out close and stuff like
     571     * this. */
     572    QList<QAction*> actions = actionsPool()->action(UIActionIndex_Menu_Machine)->menu()->actions();
     573    for (int i=0; i < actions.size(); ++i)
     574        if (actions.at(i)->menuRole() == QAction::TextHeuristicRole)
     575            pDockMenu->addAction(actions.at(i));
     576    pDockMenu->addSeparator();
     577
     578    QMenu *pDockSettingsMenu = actionsPool()->action(UIActionIndex_Menu_DockSettings)->menu();
     579    QActionGroup *pDockPreviewModeGroup = new QActionGroup(this);
     580    QAction *pDockEnablePreviewMonitor = actionsPool()->action(UIActionIndex_Toggle_DockPreviewMonitor);
     581    pDockPreviewModeGroup->addAction(pDockEnablePreviewMonitor);
     582    QAction *pDockDisablePreview = actionsPool()->action(UIActionIndex_Toggle_DockDisableMonitor);
     583    pDockPreviewModeGroup->addAction(pDockDisablePreview);
     584    pDockSettingsMenu->addActions(pDockPreviewModeGroup->actions());
     585
     586    pDockMenu->addMenu(pDockSettingsMenu);
     587
     588    connect(pDockPreviewModeGroup, SIGNAL(triggered(QAction*)),
     589            this, SLOT(sltDockPreviewModeChanged(QAction*)));
     590
     591    /* Add it to the dock. */
     592    extern void qt_mac_set_dock_menu(QMenu *);
     593    qt_mac_set_dock_menu(pDockMenu);
     594}
     595#endif /* Q_WS_MAC */
    564596
    565597void UIMachineLogic::prepareRequiredFeatures()
     
    13991431#endif
    14001432
     1433#ifdef Q_WS_MAC
     1434void UIMachineLogic::sltDockPreviewModeChanged(QAction *pAction)
     1435{
     1436//    if (mConsole)
     1437    {
     1438        CMachine machine = m_pSession->session().GetMachine();
     1439        if (!machine.isNull())
     1440        {
     1441            if (pAction == actionsPool()->action(UIActionIndex_Toggle_DockDisableMonitor))
     1442                machine.SetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled, "false");
     1443            else if (pAction == actionsPool()->action(UIActionIndex_Toggle_DockPreviewMonitor))
     1444                machine.SetExtraData(VBoxDefs::GUI_RealtimeDockIconUpdateEnabled, "true");
     1445//            mConsole->updateDockOverlay();
     1446        }
     1447    }
     1448}
     1449#endif /* Q_WS_MAC */
     1450
    14011451void UIMachineLogic::installGuestAdditionsFrom(const QString &strSource)
    14021452{
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r27044 r27132  
    3434
    3535/* Global forwards */
     36class QAction;
    3637class QActionGroup;
    3738
     
    101102    virtual void prepareActionGroups();
    102103    virtual void prepareActionConnections();
     104#ifdef Q_WS_MAC
     105    virtual void prepareDock();
     106#endif /* Q_WS_MAC */
    103107    virtual void prepareRequiredFeatures();
    104108    virtual void prepareConsolePowerUp();
     
    153157#endif
    154158
     159#ifdef Q_WS_MAC
     160    void sltDockPreviewModeChanged(QAction *pAction);
     161#endif /* Q_WS_MAC */
     162
    155163private:
    156164
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/fullscreen/UIMachineLogicFullscreen.cpp

    r27081 r27132  
    144144        prepareMachineWindows();
    145145
     146#ifdef Q_WS_MAC
     147        /* Prepare dock: */
     148        prepareDock();
     149#endif /* Q_WS_MAC */
     150
     151
    146152        /* Initialization: */
    147153        sltMachineStateChanged();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/normal/UIMachineLogicNormal.cpp

    r26950 r27132  
    6969        prepareMachineWindows();
    7070
     71#ifdef Q_WS_MAC
     72        /* Prepare dock: */
     73        prepareDock();
     74#endif /* Q_WS_MAC */
     75
    7176        /* Initialization: */
    7277        sltMachineStateChanged();
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/seamless/UIMachineLogicSeamless.cpp

    r27032 r27132  
    134134        prepareMachineWindows();
    135135
     136#ifdef Q_WS_MAC
     137        /* Prepare dock: */
     138        prepareDock();
     139#endif /* Q_WS_MAC */
     140
    136141        /* Initialization: */
    137142        sltMachineStateChanged();
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette