VirtualBox

Ignore:
Timestamp:
Dec 5, 2017 12:58:22 PM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8939 Fixing MacOS doc menu update issue

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

Legend:

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

    r69917 r69935  
    840840    , m_pDockSettingsMenuSeparator(0)
    841841    , m_DockIconPreviewMonitor(0)
     842    , m_pDockSettingMenuAction(0)
    842843#endif /* VBOX_WS_MAC */
    843844    , m_pHostLedsState(NULL)
     
    12141215{
    12151216    QMenu *pDockMenu = actionPool()->action(UIActionIndexRT_M_Dock)->menu();
    1216 
     1217    /* Clear the menu to get rid of any previously added actions and separators: */
     1218    pDockMenu->clear();
     1219   
    12171220    /* Add all the 'Machine' menu entries to the 'Dock' menu: */
    12181221    QList<QAction*> actions = actionPool()->action(UIActionIndexRT_M_Machine)->menu()->actions();
     1222    m_dockMachineMenuActions.clear();
    12191223    for (int i=0; i < actions.size(); ++i)
    12201224    {
     
    12301234        if (qobject_cast<UIActionMenu*>(pAction))
    12311235            continue;
     1236        if (!pAction->isAllowed())
     1237            continue;
    12321238        pDockMenu->addAction(actions.at(i));
    1233     }
    1234     pDockMenu->addSeparator();
     1239        m_dockMachineMenuActions.push_back(actions.at(i));
     1240    }
     1241    if (!m_dockMachineMenuActions.empty())
     1242    {
     1243        m_dockMachineMenuActions.push_back(pDockMenu->addSeparator());
     1244    }
    12351245
    12361246    QMenu *pDockSettingsMenu = actionPool()->action(UIActionIndexRT_M_Dock_M_DockSettings)->menu();
     1247    /* Clear the menu to get rid of any previously added actions and separators: */
     1248    pDockSettingsMenu->clear();
    12371249    QActionGroup *pDockPreviewModeGroup = new QActionGroup(this);
    12381250    QAction *pDockDisablePreview = actionPool()->action(UIActionIndexRT_M_Dock_M_DockSettings_T_DisableMonitor);
     
    12891301    }
    12901302
    1291     pDockMenu->addMenu(pDockSettingsMenu);
     1303    m_pDockSettingMenuAction = pDockMenu->addMenu(pDockSettingsMenu);
    12921304
    12931305    /* Add it to the dock: */
     
    13171329{
    13181330    QMenu *pDockSettingsMenu = actionPool()->action(UIActionIndexRT_M_Dock_M_DockSettings)->menu();
     1331    AssertReturnVoid(pDockSettingsMenu);
     1332
     1333    QMenu *pDockMenu = actionPool()->action(UIActionIndexRT_M_Dock)->menu();
     1334    AssertReturnVoid(pDockMenu);
     1335
     1336    /* Clean previous machine menu actions: */
     1337    for (int i=0; i < m_dockMachineMenuActions.size(); ++i)
     1338    {
     1339        pDockMenu->removeAction(m_dockMachineMenuActions.at(i));
     1340        if (m_dockMachineMenuActions.at(i)->isSeparator())
     1341            delete m_dockMachineMenuActions[i];
     1342    }
     1343    m_dockMachineMenuActions.clear();
     1344
     1345    /* Determine the list of actions to be inserted: */
     1346    QList<QAction*> actions = actionPool()->action(UIActionIndexRT_M_Machine)->menu()->actions();
     1347    QList<QAction*> allowedActions;
     1348    for (int i=0; i < actions.size(); ++i)
     1349    {
     1350        /* Check if we really have correct action: */
     1351        UIAction *pAction = qobject_cast<UIAction*>(actions.at(i));
     1352        /* Skip incorrect actions: */
     1353        if (!pAction)
     1354            continue;
     1355        /* Skip actions which have 'role' (to prevent consuming): */
     1356        if (pAction->menuRole() != QAction::NoRole)
     1357            continue;
     1358        /* Skip actions which have menu (to prevent consuming): */
     1359        if (qobject_cast<UIActionMenu*>(pAction))
     1360            continue;
     1361        if (!pAction->isAllowed())
     1362            continue;
     1363        allowedActions.push_back(actions.at(i));
     1364    }
     1365
     1366    if (!allowedActions.empty())
     1367    {
     1368        QAction *separator = new QAction(pDockMenu);
     1369        separator->setSeparator(true);
     1370        allowedActions.push_back(separator);
     1371        pDockMenu->insertActions(m_pDockSettingMenuAction, allowedActions);
     1372        m_dockMachineMenuActions = allowedActions;
     1373    }
     1374
    13191375    /* Clean the previous preview actions: */
    13201376    if (m_pDockPreviewSelectMonitorGroup)
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h

    r69858 r69935  
    138138    void updateDockIconSize(int screenId, int width, int height);
    139139    UIMachineView* dockPreviewView() const;
     140    virtual void updateDock();
    140141#endif /* VBOX_WS_MAC */
    141142
     
    225226#ifdef VBOX_WS_MAC
    226227    virtual void prepareDock();
    227     virtual void updateDock();
    228228#endif /* VBOX_WS_MAC */
    229229#ifdef VBOX_WITH_DEBUGGER_GUI
     
    409409    QAction *m_pDockSettingsMenuSeparator;
    410410    int m_DockIconPreviewMonitor;
     411    QAction *m_pDockSettingMenuAction;
     412    /* Keep a list of machine menu actions that we add to dock menu: */
     413    QList<QAction*> m_dockMachineMenuActions;
    411414#endif /* VBOX_WS_MAC */
    412415
  • trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp

    r69931 r69935  
    14731473            pMenuUI->setConsumed(true);
    14741474    }
     1475    /* Update the dock menu as well: */
     1476    if(machineLogic())
     1477        machineLogic()->updateDock();
    14751478}
    14761479#endif /* VBOX_WS_MAC */
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