Changeset 69935 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Dec 5, 2017 12:58:22 PM (7 years ago)
- 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 840 840 , m_pDockSettingsMenuSeparator(0) 841 841 , m_DockIconPreviewMonitor(0) 842 , m_pDockSettingMenuAction(0) 842 843 #endif /* VBOX_WS_MAC */ 843 844 , m_pHostLedsState(NULL) … … 1214 1215 { 1215 1216 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 1217 1220 /* Add all the 'Machine' menu entries to the 'Dock' menu: */ 1218 1221 QList<QAction*> actions = actionPool()->action(UIActionIndexRT_M_Machine)->menu()->actions(); 1222 m_dockMachineMenuActions.clear(); 1219 1223 for (int i=0; i < actions.size(); ++i) 1220 1224 { … … 1230 1234 if (qobject_cast<UIActionMenu*>(pAction)) 1231 1235 continue; 1236 if (!pAction->isAllowed()) 1237 continue; 1232 1238 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 } 1235 1245 1236 1246 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(); 1237 1249 QActionGroup *pDockPreviewModeGroup = new QActionGroup(this); 1238 1250 QAction *pDockDisablePreview = actionPool()->action(UIActionIndexRT_M_Dock_M_DockSettings_T_DisableMonitor); … … 1289 1301 } 1290 1302 1291 pDockMenu->addMenu(pDockSettingsMenu);1303 m_pDockSettingMenuAction = pDockMenu->addMenu(pDockSettingsMenu); 1292 1304 1293 1305 /* Add it to the dock: */ … … 1317 1329 { 1318 1330 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 1319 1375 /* Clean the previous preview actions: */ 1320 1376 if (m_pDockPreviewSelectMonitorGroup) -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIMachineLogic.h
r69858 r69935 138 138 void updateDockIconSize(int screenId, int width, int height); 139 139 UIMachineView* dockPreviewView() const; 140 virtual void updateDock(); 140 141 #endif /* VBOX_WS_MAC */ 141 142 … … 225 226 #ifdef VBOX_WS_MAC 226 227 virtual void prepareDock(); 227 virtual void updateDock();228 228 #endif /* VBOX_WS_MAC */ 229 229 #ifdef VBOX_WITH_DEBUGGER_GUI … … 409 409 QAction *m_pDockSettingsMenuSeparator; 410 410 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; 411 414 #endif /* VBOX_WS_MAC */ 412 415 -
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UISession.cpp
r69931 r69935 1473 1473 pMenuUI->setConsumed(true); 1474 1474 } 1475 /* Update the dock menu as well: */ 1476 if(machineLogic()) 1477 machineLogic()->updateDock(); 1475 1478 } 1476 1479 #endif /* VBOX_WS_MAC */
Note:
See TracChangeset
for help on using the changeset viewer.