Changeset 107359 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Dec 18, 2024 1:58:06 PM (3 months ago)
- svn:sync-xref-src-repo-rev:
- 166397
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerAdvancedWidget.cpp
r107299 r107359 28 28 /* Qt includes: */ 29 29 #include <QApplication> 30 #include <QHBoxLayout>31 #include <QStackedWidget>32 30 #include <QStyle> 33 #include <QTimer>34 31 #include <QToolButton> 35 32 #include <QVBoxLayout> 36 33 37 34 /* GUI includes: */ 38 #include "QISplitter.h"39 35 #include "QIToolBar.h" 40 36 #include "UIActionPoolManager.h" 41 37 #include "UIChooser.h" 42 38 #include "UICommon.h" 43 #include "UIDesktopWidgetWatchdog.h"44 39 #include "UIExtraDataManager.h" 45 #include "UIGlobalSession.h" 46 #include "UILoggingDefs.h" 47 #include "UIMessageCenter.h" 40 #include "UIGlobalToolsManagerWidget.h" 41 #include "UIMachineManagerWidget.h" 48 42 #include "UINotificationCenter.h" 49 #include "UISlidingAnimation.h"50 #include "UITabBar.h"51 43 #include "UIToolPaneGlobal.h" 52 44 #include "UIToolPaneMachine.h" 53 #include "UITools.h"54 #include "UITranslationEventListener.h"55 #include "UIVirtualBoxEventHandler.h"56 45 #include "UIVirtualBoxManager.h" 57 46 #include "UIVirtualBoxManagerAdvancedWidget.h" 58 #include "UIVirtualMachineItemCloud.h"59 #include "UIVirtualMachineItemLocal.h"60 47 #if defined(VBOX_WS_MAC) && (defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32)) 61 48 # include "UIIconPool.h" 62 49 # include "UIVersion.h" 63 50 #endif /* VBOX_WS_MAC && (RT_ARCH_ARM64 || RT_ARCH_ARM32) */ 64 #ifndef VBOX_WS_MAC65 # include "UIMenuBar.h"66 #endif67 51 68 52 /* COM includes: */ … … 74 58 UIVirtualBoxManagerAdvancedWidget::UIVirtualBoxManagerAdvancedWidget(UIVirtualBoxManager *pParent) 75 59 : m_pActionPool(pParent->actionPool()) 76 , m_pSplitter(0)77 60 , m_pToolBar(0) 78 , m_pPaneChooser(0) 79 , m_pStackedWidget(0) 80 , m_pPaneToolsGlobal(0) 81 , m_pPaneToolsMachine(0) 82 , m_pMenuToolsGlobal(0) 83 , m_pMenuToolsMachine(0) 84 , m_enmSelectionType(SelectionType_Invalid) 85 , m_fSelectedMachineItemAccessible(false) 86 , m_pSplitterSettingsSaveTimer(0) 61 , m_pGlobalToolManager(0) 87 62 { 88 63 prepare(); … … 96 71 void UIVirtualBoxManagerAdvancedWidget::updateToolBarMenuButtons(bool fSeparateMenuSection) 97 72 { 98 QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow))); 73 QAction *pAction = actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow); 74 AssertPtrReturnVoid(pAction); 75 QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(pAction)); 99 76 if (pButton) 100 77 pButton->setPopupMode(fSeparateMenuSection ? QToolButton::MenuButtonPopup : QToolButton::DelayedPopup); … … 103 80 UIVirtualMachineItem *UIVirtualBoxManagerAdvancedWidget::currentItem() const 104 81 { 105 return m_pPaneChooser->currentItem(); 82 AssertPtrReturn(chooser(), 0); 83 return chooser()->currentItem(); 106 84 } 107 85 108 86 QList<UIVirtualMachineItem*> UIVirtualBoxManagerAdvancedWidget::currentItems() const 109 87 { 110 return m_pPaneChooser->currentItems(); 111 } 112 113 bool UIVirtualBoxManagerAdvancedWidget::isItemAccessible(UIVirtualMachineItem *pItem /* = 0 */) const 114 { 115 if (!pItem) 116 pItem = currentItem(); 117 return pItem && pItem->accessible(); 88 AssertPtrReturn(chooser(), QList<UIVirtualMachineItem*>()); 89 return chooser()->currentItems(); 118 90 } 119 91 120 92 bool UIVirtualBoxManagerAdvancedWidget::isGroupItemSelected() const 121 93 { 122 return m_pPaneChooser->isGroupItemSelected(); 94 AssertPtrReturn(chooser(), false); 95 return chooser()->isGroupItemSelected(); 123 96 } 124 97 125 98 bool UIVirtualBoxManagerAdvancedWidget::isGlobalItemSelected() const 126 99 { 127 return m_pPaneChooser->isGlobalItemSelected(); 100 AssertPtrReturn(chooser(), false); 101 return chooser()->isGlobalItemSelected(); 128 102 } 129 103 130 104 bool UIVirtualBoxManagerAdvancedWidget::isMachineItemSelected() const 131 105 { 132 return m_pPaneChooser->isMachineItemSelected(); 106 AssertPtrReturn(chooser(), false); 107 return chooser()->isMachineItemSelected(); 133 108 } 134 109 135 110 bool UIVirtualBoxManagerAdvancedWidget::isLocalMachineItemSelected() const 136 111 { 137 return m_pPaneChooser->isLocalMachineItemSelected(); 112 AssertPtrReturn(chooser(), false); 113 return chooser()->isLocalMachineItemSelected(); 138 114 } 139 115 140 116 bool UIVirtualBoxManagerAdvancedWidget::isCloudMachineItemSelected() const 141 117 { 142 return m_pPaneChooser->isCloudMachineItemSelected(); 118 AssertPtrReturn(chooser(), false); 119 return chooser()->isCloudMachineItemSelected(); 143 120 } 144 121 145 122 bool UIVirtualBoxManagerAdvancedWidget::isSingleGroupSelected() const 146 123 { 147 return m_pPaneChooser->isSingleGroupSelected(); 124 AssertPtrReturn(chooser(), false); 125 return chooser()->isSingleGroupSelected(); 148 126 } 149 127 150 128 bool UIVirtualBoxManagerAdvancedWidget::isSingleLocalGroupSelected() const 151 129 { 152 return m_pPaneChooser->isSingleLocalGroupSelected(); 130 AssertPtrReturn(chooser(), false); 131 return chooser()->isSingleLocalGroupSelected(); 153 132 } 154 133 155 134 bool UIVirtualBoxManagerAdvancedWidget::isSingleCloudProviderGroupSelected() const 156 135 { 157 return m_pPaneChooser->isSingleCloudProviderGroupSelected(); 136 AssertPtrReturn(chooser(), false); 137 return chooser()->isSingleCloudProviderGroupSelected(); 158 138 } 159 139 160 140 bool UIVirtualBoxManagerAdvancedWidget::isSingleCloudProfileGroupSelected() const 161 141 { 162 return m_pPaneChooser->isSingleCloudProfileGroupSelected(); 142 AssertPtrReturn(chooser(), false); 143 return chooser()->isSingleCloudProfileGroupSelected(); 163 144 } 164 145 165 146 bool UIVirtualBoxManagerAdvancedWidget::isAllItemsOfOneGroupSelected() const 166 147 { 167 return m_pPaneChooser->isAllItemsOfOneGroupSelected(); 168 } 169 170 UIVirtualBoxManagerAdvancedWidget::SelectionType UIVirtualBoxManagerAdvancedWidget::selectionType() const 171 { 172 return isSingleLocalGroupSelected() 173 ? SelectionType_SingleLocalGroupItem 174 : isSingleCloudProviderGroupSelected() || isSingleCloudProfileGroupSelected() 175 ? SelectionType_SingleCloudGroupItem 176 : isGlobalItemSelected() 177 ? SelectionType_FirstIsGlobalItem 178 : isLocalMachineItemSelected() 179 ? SelectionType_FirstIsLocalMachineItem 180 : isCloudMachineItemSelected() 181 ? SelectionType_FirstIsCloudMachineItem 182 : SelectionType_Invalid; 148 AssertPtrReturn(chooser(), false); 149 return chooser()->isAllItemsOfOneGroupSelected(); 183 150 } 184 151 185 152 QString UIVirtualBoxManagerAdvancedWidget::fullGroupName() const 186 153 { 187 return m_pPaneChooser->fullGroupName(); 154 AssertPtrReturn(chooser(), QString()); 155 return chooser()->fullGroupName(); 188 156 } 189 157 190 158 bool UIVirtualBoxManagerAdvancedWidget::isGroupSavingInProgress() const 191 159 { 192 return m_pPaneChooser->isGroupSavingInProgress(); 160 AssertPtrReturn(chooser(), false); 161 return chooser()->isGroupSavingInProgress(); 193 162 } 194 163 195 164 bool UIVirtualBoxManagerAdvancedWidget::isCloudProfileUpdateInProgress() const 196 165 { 197 return m_pPaneChooser->isCloudProfileUpdateInProgress(); 166 AssertPtrReturn(chooser(), false); 167 return chooser()->isCloudProfileUpdateInProgress(); 198 168 } 199 169 200 170 void UIVirtualBoxManagerAdvancedWidget::openGroupNameEditor() 201 171 { 202 m_pPaneChooser->openGroupNameEditor(); 172 AssertPtrReturnVoid(chooser()); 173 chooser()->openGroupNameEditor(); 203 174 } 204 175 205 176 void UIVirtualBoxManagerAdvancedWidget::disbandGroup() 206 177 { 207 m_pPaneChooser->disbandGroup(); 178 AssertPtrReturnVoid(chooser()); 179 chooser()->disbandGroup(); 208 180 } 209 181 210 182 void UIVirtualBoxManagerAdvancedWidget::removeMachine() 211 183 { 212 m_pPaneChooser->removeMachine(); 184 AssertPtrReturnVoid(chooser()); 185 chooser()->removeMachine(); 213 186 } 214 187 215 188 void UIVirtualBoxManagerAdvancedWidget::moveMachineToGroup(const QString &strName /* = QString() */) 216 189 { 217 m_pPaneChooser->moveMachineToGroup(strName); 190 AssertPtrReturnVoid(chooser()); 191 chooser()->moveMachineToGroup(strName); 218 192 } 219 193 220 194 QStringList UIVirtualBoxManagerAdvancedWidget::possibleGroupsForMachineToMove(const QUuid &uId) 221 195 { 222 return m_pPaneChooser->possibleGroupsForMachineToMove(uId); 196 AssertPtrReturn(chooser(), QStringList()); 197 return chooser()->possibleGroupsForMachineToMove(uId); 223 198 } 224 199 225 200 QStringList UIVirtualBoxManagerAdvancedWidget::possibleGroupsForGroupToMove(const QString &strFullName) 226 201 { 227 return m_pPaneChooser->possibleGroupsForGroupToMove(strFullName); 202 AssertPtrReturn(chooser(), QStringList()); 203 return chooser()->possibleGroupsForGroupToMove(strFullName); 228 204 } 229 205 230 206 void UIVirtualBoxManagerAdvancedWidget::refreshMachine() 231 207 { 232 m_pPaneChooser->refreshMachine(); 208 AssertPtrReturnVoid(chooser()); 209 chooser()->refreshMachine(); 233 210 } 234 211 235 212 void UIVirtualBoxManagerAdvancedWidget::sortGroup() 236 213 { 237 m_pPaneChooser->sortGroup(); 214 AssertPtrReturnVoid(chooser()); 215 chooser()->sortGroup(); 238 216 } 239 217 240 218 void UIVirtualBoxManagerAdvancedWidget::setMachineSearchWidgetVisibility(bool fVisible) 241 219 { 242 m_pPaneChooser->setMachineSearchWidgetVisibility(fVisible); 243 } 244 245 void UIVirtualBoxManagerAdvancedWidget::setToolsTypeGlobal(UIToolType enmType, bool fMakeSureItsVisible /* = false */) 246 { 247 /* Make sure global item is selected if requested: */ 248 if (fMakeSureItsVisible) 249 { 250 AssertPtrReturnVoid(m_pPaneChooser); 251 m_pPaneChooser->setCurrentGlobal(); 252 } 253 254 /* Change the tool to requested type: */ 255 AssertPtrReturnVoid(m_pMenuToolsGlobal); 256 m_pMenuToolsGlobal->setToolsType(enmType); 220 AssertPtrReturnVoid(chooser()); 221 chooser()->setMachineSearchWidgetVisibility(fVisible); 222 } 223 224 void UIVirtualBoxManagerAdvancedWidget::setToolsTypeGlobal(UIToolType enmType, bool) 225 { 226 AssertPtrReturnVoid(globalToolManager()); 227 globalToolManager()->setMenuToolType(enmType); 257 228 } 258 229 259 230 UIToolType UIVirtualBoxManagerAdvancedWidget::toolsTypeGlobal() const 260 231 { 261 return m_pMenuToolsGlobal ? m_pMenuToolsGlobal->toolsType() : UIToolType_Invalid; 232 AssertPtrReturn(globalToolManager(), UIToolType_Invalid); 233 return globalToolManager()->menuToolType(); 262 234 } 263 235 264 236 void UIVirtualBoxManagerAdvancedWidget::setToolsTypeMachine(UIToolType enmType) 265 237 { 266 /* Change the tool to requested type: */ 267 AssertPtrReturnVoid(m_pMenuToolsMachine); 268 m_pMenuToolsMachine->setToolsType(enmType); 238 AssertPtrReturnVoid(machineToolManager()); 239 machineToolManager()->setMenuToolType(enmType); 269 240 } 270 241 271 242 UIToolType UIVirtualBoxManagerAdvancedWidget::toolsTypeMachine() const 272 243 { 273 return m_pMenuToolsMachine ? m_pMenuToolsMachine->toolsType() : UIToolType_Invalid; 244 AssertPtrReturn(machineToolManager(), UIToolType_Invalid); 245 return machineToolManager()->menuToolType(); 274 246 } 275 247 276 248 UIToolType UIVirtualBoxManagerAdvancedWidget::currentGlobalTool() const 277 249 { 278 return m_pPaneToolsGlobal ? m_pPaneToolsGlobal->currentTool() : UIToolType_Invalid; 250 AssertPtrReturn(globalToolManager(), UIToolType_Invalid); 251 return globalToolManager()->toolType(); 279 252 } 280 253 281 254 UIToolType UIVirtualBoxManagerAdvancedWidget::currentMachineTool() const 282 255 { 283 return m_pPaneToolsMachine ? m_pPaneToolsMachine->currentTool() : UIToolType_Invalid; 256 AssertPtrReturn(machineToolManager(), UIToolType_Invalid); 257 return machineToolManager()->toolType(); 284 258 } 285 259 286 260 bool UIVirtualBoxManagerAdvancedWidget::isGlobalToolOpened(UIToolType enmType) const 287 261 { 288 return m_pPaneToolsGlobal ? m_pPaneToolsGlobal->isToolOpened(enmType) : false; 262 AssertPtrReturn(globalToolManager(), false); 263 return globalToolManager()->isToolOpened(enmType); 289 264 } 290 265 291 266 bool UIVirtualBoxManagerAdvancedWidget::isMachineToolOpened(UIToolType enmType) const 292 267 { 293 return m_pPaneToolsMachine ? m_pPaneToolsMachine->isToolOpened(enmType) : false; 294 } 295 296 void UIVirtualBoxManagerAdvancedWidget::switchGlobalToolTo(UIToolType enmType) 297 { 298 /* Open corresponding tool: */ 299 m_pPaneToolsGlobal->openTool(enmType); 300 301 /* Let the parent know: */ 302 emit sigToolTypeChangeGlobal(); 303 304 /* Update toolbar: */ 305 updateToolbar(); 306 307 /* Handle current tool type change: */ 308 handleCurrentToolTypeChange(enmType); 309 } 310 311 void UIVirtualBoxManagerAdvancedWidget::switchMachineToolTo(UIToolType enmType) 312 { 313 /* Open corresponding tool: */ 314 m_pPaneToolsMachine->openTool(enmType); 315 316 /* Let the parent know: */ 317 emit sigToolTypeChangeMachine(); 318 319 /* Update toolbar: */ 320 updateToolbar(); 321 322 /* Handle current tool type change: */ 323 handleCurrentToolTypeChange(enmType); 268 AssertPtrReturn(machineToolManager(), false); 269 return machineToolManager()->isToolOpened(enmType); 324 270 } 325 271 326 272 void UIVirtualBoxManagerAdvancedWidget::closeGlobalTool(UIToolType enmType) 327 273 { 328 m_pPaneToolsGlobal->closeTool(enmType); 274 AssertPtrReturnVoid(globalToolManager()); 275 globalToolManager()->closeTool(enmType); 329 276 } 330 277 331 278 void UIVirtualBoxManagerAdvancedWidget::closeMachineTool(UIToolType enmType) 332 279 { 333 m_pPaneToolsMachine->closeTool(enmType); 280 AssertPtrReturnVoid(machineToolManager()); 281 machineToolManager()->closeTool(enmType); 334 282 } 335 283 336 284 bool UIVirtualBoxManagerAdvancedWidget::isCurrentStateItemSelected() const 337 285 { 338 return m_pPaneToolsMachine->isCurrentStateItemSelected(); 286 AssertPtrReturn(machineToolPane(), false); 287 return machineToolPane()->isCurrentStateItemSelected(); 339 288 } 340 289 341 290 QUuid UIVirtualBoxManagerAdvancedWidget::currentSnapshotId() 342 291 { 343 return m_pPaneToolsMachine->currentSnapshotId(); 292 AssertPtrReturn(machineToolPane(), QUuid()); 293 return machineToolPane()->currentSnapshotId(); 344 294 } 345 295 346 296 QString UIVirtualBoxManagerAdvancedWidget::currentHelpKeyword() const 347 297 { 348 QString strHelpKeyword; 349 if (isGlobalItemSelected()) 350 strHelpKeyword = m_pPaneToolsGlobal->currentHelpKeyword(); 351 else if (isMachineItemSelected()) 352 strHelpKeyword = m_pPaneToolsMachine->currentHelpKeyword(); 353 return strHelpKeyword; 298 AssertPtrReturn(globalToolManager(), QString()); 299 return globalToolManager()->currentHelpKeyword(); 354 300 } 355 301 … … 384 330 } 385 331 386 void UIVirtualBoxManagerAdvancedWidget::sltRetranslateUI()387 {388 /* Make sure chosen item fetched: */389 sltHandleChooserPaneIndexChange();390 }391 392 332 void UIVirtualBoxManagerAdvancedWidget::sltHandleCommitData() 393 333 { 394 // WORKAROUND:395 // This will be fixed proper way during session management cleanup for Qt6.396 // But for now we will just cleanup connections which is Ok anyway.397 334 cleanupConnections(); 398 335 } 399 336 400 void UIVirtualBoxManagerAdvancedWidget::sltHandleMachineStateChange(const QUuid &uId) 401 { 402 // WORKAROUND: 403 // In certain intermediate states VM info can be NULL which 404 // causing annoying assertions, such updates can be ignored? 405 CVirtualBox comVBox = gpGlobalSession->virtualBox(); 406 CMachine comMachine = comVBox.FindMachine(uId.toString()); 407 if (comVBox.isOk() && comMachine.isNotNull()) 408 { 409 switch (comMachine.GetState()) 410 { 411 case KMachineState_DeletingSnapshot: 412 return; 413 default: 414 break; 415 } 416 } 417 418 /* Recache current machine item information: */ 419 recacheCurrentMachineItemInformation(); 420 } 421 422 void UIVirtualBoxManagerAdvancedWidget::sltHandleSettingsExpertModeChange() 337 void UIVirtualBoxManagerAdvancedWidget::sltUpdateToolbar() 423 338 { 424 339 /* Update toolbar to show/hide corresponding actions: */ 425 340 updateToolbar(); 426 427 /* Update tools restrictions for currently selected item: */428 if (currentItem())429 updateToolsMenuMachine(currentItem());430 else431 updateToolsMenuGlobal();432 }433 434 void UIVirtualBoxManagerAdvancedWidget::sltHandleSplitterMove()435 {436 /* Create timer if isn't exist already: */437 if (!m_pSplitterSettingsSaveTimer)438 {439 m_pSplitterSettingsSaveTimer = new QTimer(this);440 if (m_pSplitterSettingsSaveTimer)441 {442 m_pSplitterSettingsSaveTimer->setInterval(300);443 m_pSplitterSettingsSaveTimer->setSingleShot(true);444 connect(m_pSplitterSettingsSaveTimer, &QTimer::timeout,445 this, &UIVirtualBoxManagerAdvancedWidget::sltSaveSplitterSettings);446 }447 }448 /* [Re]start timer finally: */449 m_pSplitterSettingsSaveTimer->start();450 }451 452 void UIVirtualBoxManagerAdvancedWidget::sltSaveSplitterSettings()453 {454 const QList<int> splitterSizes = m_pSplitter->sizes();455 LogRel2(("GUI: UIVirtualBoxManagerAdvancedWidget: Saving splitter as: Size=%d,%d\n",456 splitterSizes.at(0), splitterSizes.at(1)));457 gEDataManager->setSelectorWindowSplitterHints(splitterSizes);458 }459 460 void UIVirtualBoxManagerAdvancedWidget::sltHandleToolBarResize(const QSize &newSize)461 {462 emit sigToolBarHeightChange(newSize.height());463 }464 465 void UIVirtualBoxManagerAdvancedWidget::sltHandleChooserPaneIndexChange()466 {467 /* Let the parent know: */468 emit sigChooserPaneIndexChange();469 470 /* If global item is selected and we are on machine tools pane => switch to global tools pane: */471 if ( isGlobalItemSelected()472 && m_pStackedWidget->currentWidget() != m_pPaneToolsGlobal)473 {474 m_pStackedWidget->setCurrentWidget(m_pPaneToolsGlobal);475 m_pPaneToolsMachine->setActive(false);476 m_pPaneToolsGlobal->setActive(true);477 /* Handle current tool type change: */478 handleCurrentToolTypeChange(m_pMenuToolsGlobal->toolsType());479 }480 481 else482 483 /* If machine or group item is selected and we are on global tools pane => switch to machine tools pane: */484 if ( (isMachineItemSelected() || isGroupItemSelected())485 && m_pStackedWidget->currentWidget() != m_pPaneToolsMachine)486 {487 m_pStackedWidget->setCurrentWidget(m_pPaneToolsMachine);488 m_pPaneToolsGlobal->setActive(false);489 m_pPaneToolsMachine->setActive(true);490 /* Handle current tool type change: */491 handleCurrentToolTypeChange(m_pMenuToolsMachine->toolsType());492 }493 494 /* Update tools restrictions for currently selected item: */495 UIVirtualMachineItem *pItem = currentItem();496 if (pItem)497 updateToolsMenuMachine(pItem);498 else499 updateToolsMenuGlobal();500 501 /* Recache current machine item information: */502 recacheCurrentMachineItemInformation();503 504 /* Calculate new selection type and item accessibility status: */505 const SelectionType enmSelectedItemType = selectionType();506 const bool fCurrentItemIsOk = isItemAccessible();507 508 /* Update toolbar if selection type or item accessibility status got changed: */509 if ( m_enmSelectionType != enmSelectedItemType510 || m_fSelectedMachineItemAccessible != fCurrentItemIsOk)511 updateToolbar();512 513 /* Remember selection type and item accessibility status: */514 m_enmSelectionType = enmSelectedItemType;515 m_fSelectedMachineItemAccessible = fCurrentItemIsOk;516 }517 518 void UIVirtualBoxManagerAdvancedWidget::sltHandleCloudProfileStateChange(const QString &strProviderShortName,519 const QString &strProfileName)520 {521 RT_NOREF(strProviderShortName, strProfileName);522 523 /* If Global Activity Overview tool is currently chosen: */524 if ( m_pStackedWidget->currentWidget() == m_pPaneToolsGlobal525 && m_pPaneToolsGlobal->currentTool() == UIToolType_Activities)526 m_pPaneToolsGlobal->setCloudMachineItems(m_pPaneChooser->cloudMachineItems());527 }528 529 void UIVirtualBoxManagerAdvancedWidget::sltHandleCloudMachineStateChange(const QUuid &uId)530 {531 /* Not for global items: */532 if (isGlobalItemSelected())533 return;534 535 /* Acquire current item: */536 UIVirtualMachineItem *pItem = currentItem();537 const bool fCurrentItemIsOk = isItemAccessible(pItem);538 539 /* If current item is Ok: */540 if (fCurrentItemIsOk)541 {542 /* If Error-pane is chosen currently => switch to tool currently chosen in Tools-menu: */543 if (m_pPaneToolsMachine->currentTool() == UIToolType_Error)544 switchMachineToolTo(m_pMenuToolsMachine->toolsType());545 546 /* If we still have same item selected: */547 if (pItem && pItem->id() == uId)548 {549 /* Propagate current items to update the Details-pane: */550 m_pPaneToolsMachine->setItems(currentItems());551 }552 }553 else554 {555 /* Make sure Error pane raised: */556 if (m_pPaneToolsMachine->currentTool() != UIToolType_Error)557 m_pPaneToolsMachine->openTool(UIToolType_Error);558 559 /* If we still have same item selected: */560 if (pItem && pItem->id() == uId)561 {562 /* Propagate current items to update the Details-pane (in any case): */563 m_pPaneToolsMachine->setItems(currentItems());564 /* Propagate last access error to update the Error-pane (if machine selected but inaccessible): */565 m_pPaneToolsMachine->setErrorDetails(pItem->accessError());566 }567 }568 569 /* Pass the signal further: */570 emit sigCloudMachineStateChange(uId);571 }572 573 void UIVirtualBoxManagerAdvancedWidget::sltHandleToolMenuRequested(const QPoint &position, UIVirtualMachineItem *pItem)574 {575 /* Update tools menu beforehand: */576 UITools *pMenu = pItem ? m_pMenuToolsMachine : m_pMenuToolsGlobal;577 AssertPtrReturnVoid(pMenu);578 if (pItem)579 updateToolsMenuMachine(pItem);580 else581 updateToolsMenuGlobal();582 583 /* Compose popup-menu geometry first of all: */584 QRect ourGeo = QRect(position, pMenu->minimumSizeHint());585 /* Adjust location only to properly fit into available geometry space: */586 const QRect availableGeo = gpDesktop->availableGeometry(position);587 ourGeo = gpDesktop->normalizeGeometry(ourGeo, availableGeo, false /* resize? */);588 589 /* Move, resize and show: */590 pMenu->move(ourGeo.topLeft());591 pMenu->show();592 // WORKAROUND:593 // Don't want even to think why, but for Qt::Popup resize to594 // smaller size often being ignored until it is actually shown.595 pMenu->resize(ourGeo.size());596 }597 598 void UIVirtualBoxManagerAdvancedWidget::sltSwitchToMachineActivityPane(const QUuid &uMachineId)599 {600 AssertPtrReturnVoid(m_pPaneChooser);601 AssertPtrReturnVoid(m_pMenuToolsMachine);602 m_pPaneChooser->setCurrentMachine(uMachineId);603 m_pMenuToolsMachine->setToolsType(UIToolType_VMActivity);604 }605 606 void UIVirtualBoxManagerAdvancedWidget::sltSwitchToActivityOverviewPane()607 {608 AssertPtrReturnVoid(m_pPaneChooser);609 AssertPtrReturnVoid(m_pMenuToolsGlobal);610 m_pMenuToolsGlobal->setToolsType(UIToolType_Activities);611 m_pPaneChooser->setCurrentGlobal();612 341 } 613 342 … … 620 349 /* Load settings: */ 621 350 loadSettings(); 622 623 /* Translate UI: */624 sltRetranslateUI();625 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,626 this, &UIVirtualBoxManagerAdvancedWidget::sltRetranslateUI);627 628 /* Make sure current Chooser-pane index fetched: */629 sltHandleChooserPaneIndexChange();630 351 } 631 352 632 353 void UIVirtualBoxManagerAdvancedWidget::prepareWidgets() 633 354 { 634 /* Create main-layout: */635 Q HBoxLayout *pLayoutMain = new QHBoxLayout(this);636 if (pLayoutMain)355 /* Create layout: */ 356 QVBoxLayout *pLayout = new QVBoxLayout(this); 357 if(pLayout) 637 358 { 638 359 /* Configure layout: */ 639 pLayoutMain->setSpacing(0); 640 pLayoutMain->setContentsMargins(0, 0, 0, 0); 641 642 /* Create splitter: */ 643 m_pSplitter = new QISplitter; 644 if (m_pSplitter) 645 { 646 /* Create Chooser-pane: */ 647 m_pPaneChooser = new UIChooser(this, actionPool()); 648 if (m_pPaneChooser) 360 pLayout->setContentsMargins(0, 0, 0, 0); 361 362 /* Create Main toolbar: */ 363 m_pToolBar = new QIToolBar(this); 364 if (m_pToolBar) 365 { 366 /* Configure toolbar: */ 367 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); 368 m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric)); 369 m_pToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 370 m_pToolBar->setContextMenuPolicy(Qt::CustomContextMenu); 371 m_pToolBar->setUseTextLabels(true); 372 373 #if defined(VBOX_WS_MAC) && (defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32)) 374 /* Check whether we should show Dev Preview tag: */ 375 bool fShowDevPreviewTag = false; 376 const CVirtualBox comVBox = gpGlobalSession->virtualBox(); 377 if (comVBox.isNotNull()) 649 378 { 650 /* Add into splitter: */ 651 m_pSplitter->addWidget(m_pPaneChooser); 379 const CSystemProperties comSystemProps = comVBox.GetSystemProperties(); 380 if (comVBox.isOk() && comSystemProps.isNotNull()) 381 fShowDevPreviewTag = 382 comSystemProps.GetSupportedPlatformArchitectures().contains(KPlatformArchitecture_x86); 652 383 } 653 654 /* Create right widget: */ 655 QWidget *pWidgetRight = new QWidget; 656 if (pWidgetRight) 384 /* Enable Dev Preview tag: */ 385 if (fShowDevPreviewTag) 657 386 { 658 /* Create right-layout: */ 659 QVBoxLayout *pLayoutRight = new QVBoxLayout(pWidgetRight); 660 if(pLayoutRight) 661 { 662 /* Configure layout: */ 663 pLayoutRight->setSpacing(0); 664 pLayoutRight->setContentsMargins(0, 0, 0, 0); 665 666 /* Create Main toolbar: */ 667 m_pToolBar = new QIToolBar; 668 if (m_pToolBar) 669 { 670 /* Configure toolbar: */ 671 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize); 672 m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric)); 673 m_pToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 674 m_pToolBar->setContextMenuPolicy(Qt::CustomContextMenu); 675 m_pToolBar->setUseTextLabels(true); 676 677 #if defined(VBOX_WS_MAC) && (defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32)) 678 /* Check whether we should show Dev Preview tag: */ 679 bool fShowDevPreviewTag = false; 680 const CVirtualBox comVBox = gpGlobalSession->virtualBox(); 681 if (comVBox.isNotNull()) 682 { 683 const CSystemProperties comSystemProps = comVBox.GetSystemProperties(); 684 if (comVBox.isOk() && comSystemProps.isNotNull()) 685 fShowDevPreviewTag = 686 comSystemProps.GetSupportedPlatformArchitectures().contains(KPlatformArchitecture_x86); 687 } 688 /* Enable Dev Preview tag: */ 689 if (fShowDevPreviewTag) 690 { 691 m_pToolBar->emulateMacToolbar(); 692 m_pToolBar->enableBranding(UIIconPool::iconSet(":/explosion_hazard_32px.png"), 693 "Dev Preview", // do we need to make it NLS? 694 QColor(246, 179, 0), 695 74 /* width of BETA label */); 696 } 387 m_pToolBar->emulateMacToolbar(); 388 m_pToolBar->enableBranding(UIIconPool::iconSet(":/explosion_hazard_32px.png"), 389 "Dev Preview", // do we need to make it NLS? 390 QColor(246, 179, 0), 391 74 /* width of BETA label */); 392 } 697 393 #endif /* VBOX_WS_MAC && (RT_ARCH_ARM64 || RT_ARCH_ARM32) */ 698 394 699 /* Add toolbar into layout: */ 700 pLayoutRight->addWidget(m_pToolBar); 701 } 702 703 /* Create stacked-widget: */ 704 m_pStackedWidget = new QStackedWidget; 705 if (m_pStackedWidget) 706 { 707 /* Create Global Tools-pane: */ 708 m_pPaneToolsGlobal = new UIToolPaneGlobal(actionPool()); 709 if (m_pPaneToolsGlobal) 710 { 711 if (m_pPaneChooser->isGlobalItemSelected()) 712 m_pPaneToolsGlobal->setActive(true); 713 connect(m_pPaneToolsGlobal, &UIToolPaneGlobal::sigCreateMedium, 714 this, &UIVirtualBoxManagerAdvancedWidget::sigCreateMedium); 715 connect(m_pPaneToolsGlobal, &UIToolPaneGlobal::sigCopyMedium, 716 this, &UIVirtualBoxManagerAdvancedWidget::sigCopyMedium); 717 connect(m_pPaneToolsGlobal, &UIToolPaneGlobal::sigSwitchToMachineActivityPane, 718 this, &UIVirtualBoxManagerAdvancedWidget::sltSwitchToMachineActivityPane); 719 720 /* Add into stack: */ 721 m_pStackedWidget->addWidget(m_pPaneToolsGlobal); 722 } 723 724 /* Create Machine Tools-pane: */ 725 m_pPaneToolsMachine = new UIToolPaneMachine(actionPool()); 726 if (m_pPaneToolsMachine) 727 { 728 if (!m_pPaneChooser->isGlobalItemSelected()) 729 m_pPaneToolsMachine->setActive(true); 730 connect(m_pPaneToolsMachine, &UIToolPaneMachine::sigCurrentSnapshotItemChange, 731 this, &UIVirtualBoxManagerAdvancedWidget::sigCurrentSnapshotItemChange); 732 connect(m_pPaneToolsMachine, &UIToolPaneMachine::sigSwitchToActivityOverviewPane, 733 this, &UIVirtualBoxManagerAdvancedWidget::sltSwitchToActivityOverviewPane); 734 connect(m_pPaneToolsMachine, &UIToolPaneMachine::sigDetachToolPane, 735 this, &UIVirtualBoxManagerAdvancedWidget::sigDetachToolPane); 736 737 /* Add into stack: */ 738 m_pStackedWidget->addWidget(m_pPaneToolsMachine); 739 } 740 741 /* Choose which pane should be active initially: */ 742 if (m_pPaneChooser->isGlobalItemSelected()) 743 m_pStackedWidget->setCurrentWidget(m_pPaneToolsGlobal); 744 else 745 m_pStackedWidget->setCurrentWidget(m_pPaneToolsMachine); 746 747 /* Add into layout: */ 748 pLayoutRight->addWidget(m_pStackedWidget, 1); 749 } 750 } 751 752 /* Add into splitter: */ 753 m_pSplitter->addWidget(pWidgetRight); 754 } 755 756 /* Set the initial distribution. The right site is bigger. */ 757 m_pSplitter->setStretchFactor(0, 2); 758 m_pSplitter->setStretchFactor(1, 3); 759 395 /* Add toolbar into layout: */ 396 pLayout->addWidget(m_pToolBar); 397 } 398 399 /* Create Global Tool Manager: */ 400 m_pGlobalToolManager = new UIGlobalToolsManagerWidget(this, actionPool()); 401 if (globalToolManager()) 402 { 760 403 /* Add into layout: */ 761 pLayoutMain->addWidget(m_pSplitter); 762 } 763 764 /* Create Global Tools-menu: */ 765 m_pMenuToolsGlobal = new UITools(this, UIToolClass_Global, actionPool()); 766 /* Create Machine Tools-menu: */ 767 m_pMenuToolsMachine = new UITools(this, UIToolClass_Machine, actionPool()); 404 pLayout->addWidget(globalToolManager()); 405 } 768 406 } 769 407 … … 775 413 776 414 /* Bring the VM list to the focus: */ 777 m_pPaneChooser->setFocus();415 chooser()->setFocus(); 778 416 } 779 417 … … 784 422 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleCommitData); 785 423 786 /* Global VBox event handlers: */ 787 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, 788 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleMachineStateChange); 789 790 /* Global VBox extra-data event handlers: */ 424 /* Global COM event handlers: */ 791 425 connect(gEDataManager, &UIExtraDataManager::sigSettingsExpertModeChange, 792 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleSettingsExpertModeChange); 793 794 /* Splitter connections: */ 795 connect(m_pSplitter, &QISplitter::splitterMoved, 796 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleSplitterMove); 426 this, &UIVirtualBoxManagerAdvancedWidget::sltUpdateToolbar); 797 427 798 428 /* Tool-bar connections: */ 799 429 connect(m_pToolBar, &QIToolBar::customContextMenuRequested, 800 430 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleToolBarContextMenuRequest); 801 connect(m_pToolBar, &QIToolBar::sigResized, 802 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleToolBarResize); 431 432 /* Global Tool Manager connections: */ 433 connect(globalToolManager(), &UIGlobalToolsManagerWidget::sigToolTypeChange, 434 this, &UIVirtualBoxManagerAdvancedWidget::sltUpdateToolbar); 435 connect(globalToolManager(), &UIGlobalToolsManagerWidget::sigToolTypeChange, 436 this, &UIVirtualBoxManagerAdvancedWidget::sigToolTypeChangeGlobal); 437 /* Global Tool Pane connections: */ 438 connect(globalToolPane(), &UIToolPaneGlobal::sigCreateMedium, 439 this, &UIVirtualBoxManagerAdvancedWidget::sigCreateMedium); 440 connect(globalToolPane(), &UIToolPaneGlobal::sigCopyMedium, 441 this, &UIVirtualBoxManagerAdvancedWidget::sigCopyMedium); 442 443 /* Machine Tool Manager connections: */ 444 connect(machineToolManager(), &UIMachineManagerWidget::sigToolTypeChange, 445 this, &UIVirtualBoxManagerAdvancedWidget::sigToolTypeChangeMachine); 446 connect(machineToolManager(), &UIMachineManagerWidget::sigChooserPaneIndexChange, 447 this, &UIVirtualBoxManagerAdvancedWidget::sigChooserPaneIndexChange); 448 connect(machineToolManager(), &UIMachineManagerWidget::sigChooserPaneSelectionChange, 449 this, &UIVirtualBoxManagerAdvancedWidget::sltUpdateToolbar); 450 connect(machineToolManager(), &UIMachineManagerWidget::sigCloudMachineStateChange, 451 this, &UIVirtualBoxManagerAdvancedWidget::sigCloudMachineStateChange); 452 /* Machine Tool Pane connections: */ 453 connect(machineToolPane(), &UIToolPaneMachine::sigLinkClicked, 454 this, &UIVirtualBoxManagerAdvancedWidget::sigMachineSettingsLinkClicked); 455 connect(machineToolPane(), &UIToolPaneMachine::sigCurrentSnapshotItemChange, 456 this, &UIVirtualBoxManagerAdvancedWidget::sigCurrentSnapshotItemChange); 457 connect(machineToolPane(), &UIToolPaneMachine::sigDetachToolPane, 458 this, &UIVirtualBoxManagerAdvancedWidget::sigDetachToolPane); 803 459 804 460 /* Chooser-pane connections: */ 805 connect(m_pPaneChooser, &UIChooser::sigSelectionChanged, 806 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleChooserPaneIndexChange); 807 connect(m_pPaneChooser, &UIChooser::sigSelectionInvalidated, 808 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleChooserPaneSelectionInvalidated); 809 connect(m_pPaneChooser, &UIChooser::sigToggleStarted, 810 m_pPaneToolsMachine, &UIToolPaneMachine::sigToggleStarted); 811 connect(m_pPaneChooser, &UIChooser::sigToggleFinished, 812 m_pPaneToolsMachine, &UIToolPaneMachine::sigToggleFinished); 813 connect(m_pPaneChooser, &UIChooser::sigGroupSavingStateChanged, 461 connect(chooser(), &UIChooser::sigGroupSavingStateChanged, 814 462 this, &UIVirtualBoxManagerAdvancedWidget::sigGroupSavingStateChanged); 815 connect( m_pPaneChooser, &UIChooser::sigCloudUpdateStateChanged,463 connect(chooser(), &UIChooser::sigCloudUpdateStateChanged, 816 464 this, &UIVirtualBoxManagerAdvancedWidget::sigCloudUpdateStateChanged); 817 connect(m_pPaneChooser, &UIChooser::sigToolMenuRequested, 818 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleToolMenuRequested); 819 connect(m_pPaneChooser, &UIChooser::sigCloudProfileStateChange, 820 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleCloudProfileStateChange); 821 connect(m_pPaneChooser, &UIChooser::sigCloudMachineStateChange, 822 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleCloudMachineStateChange); 823 connect(m_pPaneChooser, &UIChooser::sigStartOrShowRequest, 465 connect(chooser(), &UIChooser::sigStartOrShowRequest, 824 466 this, &UIVirtualBoxManagerAdvancedWidget::sigStartOrShowRequest); 825 connect( m_pPaneChooser, &UIChooser::sigMachineSearchWidgetVisibilityChanged,467 connect(chooser(), &UIChooser::sigMachineSearchWidgetVisibilityChanged, 826 468 this, &UIVirtualBoxManagerAdvancedWidget::sigMachineSearchWidgetVisibilityChanged); 827 828 /* Details-pane connections: */829 connect(m_pPaneToolsMachine, &UIToolPaneMachine::sigLinkClicked,830 this, &UIVirtualBoxManagerAdvancedWidget::sigMachineSettingsLinkClicked);831 832 /* Tools-pane connections: */833 connect(m_pMenuToolsGlobal, &UITools::sigSelectionChanged,834 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleGlobalToolsMenuIndexChange);835 connect(m_pMenuToolsMachine, &UITools::sigSelectionChanged,836 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleMachineToolsMenuIndexChange);837 469 } 838 470 839 471 void UIVirtualBoxManagerAdvancedWidget::loadSettings() 840 472 { 841 /* Restore splitter handle position: */ 473 /* Make sure stuff exists: */ 474 AssertPtrReturnVoid(m_pToolBar); 475 m_pToolBar->setUseTextLabels(gEDataManager->selectorWindowToolBarTextVisible()); 476 } 477 478 void UIVirtualBoxManagerAdvancedWidget::updateToolbar() 479 { 480 /* Make sure stuff exists: */ 481 AssertPtrReturnVoid(m_pToolBar); 482 AssertPtrReturnVoid(globalToolManager()); 483 AssertPtrReturnVoid(machineToolManager()); 484 485 /* Clear toolbar initially: */ 486 m_pToolBar->clear(); 487 488 switch (globalToolManager()->toolType()) 842 489 { 843 QList<int> sizes = gEDataManager->selectorWindowSplitterHints(); 844 /* If both hints are zero, we have the 'default' case: */ 845 if (sizes.at(0) == 0 && sizes.at(1) == 0) 846 { 847 sizes[0] = (int)(width() * .9 * (1.0 / 3)); 848 sizes[1] = (int)(width() * .9 * (2.0 / 3)); 849 } 850 LogRel2(("GUI: UIVirtualBoxManagerAdvancedWidget: Restoring splitter to: Size=%d,%d\n", 851 sizes.at(0), sizes.at(1))); 852 m_pSplitter->setSizes(sizes); 853 } 854 855 /* Restore toolbar settings: */ 856 { 857 m_pToolBar->setUseTextLabels(gEDataManager->selectorWindowToolBarTextVisible()); 858 } 859 860 /* Open tools last chosen in Tools-menu: */ 861 switchGlobalToolTo(m_pMenuToolsGlobal->toolsType()); 862 switchMachineToolTo(m_pMenuToolsMachine->toolsType()); 863 } 864 865 void UIVirtualBoxManagerAdvancedWidget::updateToolbar() 866 { 867 /* Make sure toolbar exists: */ 868 AssertPtrReturnVoid(m_pToolBar); 869 870 /* Clear initially: */ 871 m_pToolBar->clear(); 872 873 /* If global item selected: */ 874 if (isGlobalItemSelected()) 875 { 876 switch (currentGlobalTool()) 877 { 878 case UIToolType_Welcome: 490 case UIToolType_Welcome: 491 { 492 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Application_S_Preferences)); 493 m_pToolBar->addSeparator(); 494 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_File_S_ImportAppliance)); 495 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_File_S_ExportAppliance)); 496 m_pToolBar->addSeparator(); 497 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Welcome_S_New)); 498 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Welcome_S_Add)); 499 break; 500 } 501 case UIToolType_Extensions: 502 { 503 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Extension_S_Install)); 504 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Extension_S_Uninstall)); 505 break; 506 } 507 case UIToolType_Media: 508 { 509 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Add)); 510 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Create)); 511 m_pToolBar->addSeparator(); 512 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Copy)); 513 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Move)); 514 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Remove)); 515 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Release)); 516 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Clear)); 517 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_T_Search)); 518 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_T_Details)); 519 m_pToolBar->addSeparator(); 520 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Refresh)); 521 break; 522 } 523 case UIToolType_Network: 524 { 525 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_S_Create)); 526 m_pToolBar->addSeparator(); 527 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_S_Remove)); 528 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_T_Details)); 529 //m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_S_Refresh)); 530 break; 531 } 532 case UIToolType_Cloud: 533 { 534 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Add)); 535 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Import)); 536 m_pToolBar->addSeparator(); 537 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Remove)); 538 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_T_Details)); 539 m_pToolBar->addSeparator(); 540 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_TryPage)); 541 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Help)); 542 break; 543 } 544 case UIToolType_Activities: 545 { 546 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_VMActivityOverview_M_Columns)); 547 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_VMActivityOverview_S_SwitchToMachineActivity)); 548 QToolButton *pButton = 549 qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexMN_M_VMActivityOverview_M_Columns))); 550 if (pButton) 879 551 { 880 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Application_S_Preferences)); 881 m_pToolBar->addSeparator(); 882 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_File_S_ImportAppliance)); 883 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_File_S_ExportAppliance)); 884 m_pToolBar->addSeparator(); 885 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Welcome_S_New)); 886 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Welcome_S_Add)); 887 break; 552 pButton->setPopupMode(QToolButton::InstantPopup); 553 pButton->setAutoRaise(true); 888 554 } 889 case UIToolType_Extensions: 555 break; 556 } 557 case UIToolType_Machines: 558 { 559 switch (machineToolManager()->toolType()) 890 560 { 891 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Extension_S_Install)); 892 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Extension_S_Uninstall)); 893 break; 894 } 895 case UIToolType_Media: 896 { 897 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Add)); 898 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Create)); 899 m_pToolBar->addSeparator(); 900 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Copy)); 901 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Move)); 902 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Remove)); 903 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Release)); 904 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Clear)); 905 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_T_Search)); 906 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_T_Details)); 907 m_pToolBar->addSeparator(); 908 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Medium_S_Refresh)); 909 break; 910 } 911 case UIToolType_Network: 912 { 913 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_S_Create)); 914 m_pToolBar->addSeparator(); 915 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_S_Remove)); 916 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_T_Details)); 917 //m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Network_S_Refresh)); 918 break; 919 } 920 case UIToolType_Cloud: 921 { 922 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Add)); 923 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Import)); 924 m_pToolBar->addSeparator(); 925 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Remove)); 926 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_T_Details)); 927 m_pToolBar->addSeparator(); 928 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_TryPage)); 929 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Cloud_S_Help)); 930 break; 931 } 932 case UIToolType_Activities: 933 { 934 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_VMActivityOverview_M_Columns)); 935 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_VMActivityOverview_S_SwitchToMachineActivity)); 936 QToolButton *pButton = 937 qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexMN_M_VMActivityOverview_M_Columns))); 938 if (pButton) 561 case UIToolType_Details: 939 562 { 940 pButton->setPopupMode(QToolButton::InstantPopup); 941 pButton->setAutoRaise(true); 563 if (isSingleGroupSelected()) 564 { 565 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_New)); 566 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Add)); 567 m_pToolBar->addSeparator(); 568 if (isSingleLocalGroupSelected()) 569 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Discard)); 570 else if ( isSingleCloudProviderGroupSelected() 571 || isSingleCloudProfileGroupSelected()) 572 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Stop_S_Terminate)); 573 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_StartOrShow)); 574 } 575 else 576 { 577 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_New)); 578 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Add)); 579 m_pToolBar->addSeparator(); 580 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 581 if (isLocalMachineItemSelected()) 582 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 583 else if (isCloudMachineItemSelected()) 584 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Stop_S_Terminate)); 585 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 586 } 587 break; 942 588 } 943 break; 944 } 945 946 default: 947 break; 948 } 949 } 950 951 else 952 953 /* If machine or group item selected: */ 954 if (isMachineItemSelected() || isGroupItemSelected()) 955 { 956 switch (currentMachineTool()) 957 { 958 case UIToolType_Details: 959 { 960 if (isSingleGroupSelected()) 589 case UIToolType_Snapshots: 961 590 { 962 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_New)); 963 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Add)); 591 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Take)); 592 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Delete)); 593 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Restore)); 594 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_T_Properties)); 595 if (gEDataManager->isSettingsInExpertMode()) 596 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Clone)); 964 597 m_pToolBar->addSeparator(); 965 if (isSingleLocalGroupSelected()) 966 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_S_Discard)); 967 else if ( isSingleCloudProviderGroupSelected() 968 || isSingleCloudProfileGroupSelected()) 969 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_Stop_S_Terminate)); 970 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Group_M_StartOrShow)); 598 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 599 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 600 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 601 break; 971 602 } 972 else 603 case UIToolType_Logs: 604 { 605 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Save)); 606 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Find)); 607 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Filter)); 608 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Bookmark)); 609 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Preferences)); 610 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Refresh)); 611 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Reload)); 612 m_pToolBar->addSeparator(); 613 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 614 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 615 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 616 break; 617 } 618 case UIToolType_VMActivity: 619 { 620 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Activity_S_Export)); 621 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Activity_S_ToVMActivityOverview)); 622 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Activity_T_Preferences)); 623 m_pToolBar->addSeparator(); 624 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 625 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 626 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 627 break; 628 } 629 case UIToolType_FileManager: 630 { 631 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_FileManager_T_Preferences)); 632 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_FileManager_T_Operations)); 633 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_FileManager_T_Log)); 634 m_pToolBar->addSeparator(); 635 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 636 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 637 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 638 break; 639 } 640 case UIToolType_Error: 973 641 { 974 642 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_New)); 975 643 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Add)); 976 644 m_pToolBar->addSeparator(); 977 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 978 if (isLocalMachineItemSelected()) 979 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 980 else if (isCloudMachineItemSelected()) 981 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_Stop_S_Terminate)); 982 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 645 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Refresh)); 646 break; 983 647 } 984 break; 648 default: 649 break; 985 650 } 986 case UIToolType_Snapshots: 987 { 988 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Take)); 989 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Delete)); 990 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Restore)); 991 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_T_Properties)); 992 if (gEDataManager->isSettingsInExpertMode()) 993 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Snapshot_S_Clone)); 994 m_pToolBar->addSeparator(); 995 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 996 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 997 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 998 break; 999 } 1000 case UIToolType_Logs: 1001 { 1002 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Save)); 1003 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Find)); 1004 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Filter)); 1005 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Bookmark)); 1006 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_T_Preferences)); 1007 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Refresh)); 1008 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Log_S_Reload)); 1009 m_pToolBar->addSeparator(); 1010 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 1011 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 1012 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 1013 break; 1014 } 1015 case UIToolType_VMActivity: 1016 { 1017 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Activity_S_Export)); 1018 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Activity_S_ToVMActivityOverview)); 1019 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_Activity_T_Preferences)); 1020 m_pToolBar->addSeparator(); 1021 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 1022 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 1023 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 1024 break; 1025 } 1026 case UIToolType_FileManager: 1027 { 1028 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_FileManager_T_Preferences)); 1029 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_FileManager_T_Operations)); 1030 m_pToolBar->addAction(actionPool()->action(UIActionIndex_M_FileManager_T_Log)); 1031 m_pToolBar->addSeparator(); 1032 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Settings)); 1033 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Discard)); 1034 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_M_StartOrShow)); 1035 break; 1036 } 1037 case UIToolType_Error: 1038 { 1039 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_New)); 1040 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Add)); 1041 m_pToolBar->addSeparator(); 1042 m_pToolBar->addAction(actionPool()->action(UIActionIndexMN_M_Machine_S_Refresh)); 1043 break; 1044 } 1045 default: 1046 break; 1047 } 651 break; 652 } 653 default: 654 break; 1048 655 } 1049 656 } … … 1051 658 void UIVirtualBoxManagerAdvancedWidget::cleanupConnections() 1052 659 { 660 /* Global COM event handlers: */ 661 disconnect(gEDataManager, &UIExtraDataManager::sigSettingsExpertModeChange, 662 this, &UIVirtualBoxManagerAdvancedWidget::sltUpdateToolbar); 663 1053 664 /* Tool-bar connections: */ 1054 665 disconnect(m_pToolBar, &QIToolBar::customContextMenuRequested, 1055 666 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleToolBarContextMenuRequest); 1056 disconnect(m_pToolBar, &QIToolBar::sigResized, 1057 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleToolBarResize); 667 668 /* Global Tool Manager connections: */ 669 disconnect(globalToolManager(), &UIGlobalToolsManagerWidget::sigToolTypeChange, 670 this, &UIVirtualBoxManagerAdvancedWidget::sltUpdateToolbar); 671 disconnect(globalToolManager(), &UIGlobalToolsManagerWidget::sigToolTypeChange, 672 this, &UIVirtualBoxManagerAdvancedWidget::sigToolTypeChangeGlobal); 673 /* Global Tool Pane connections: */ 674 disconnect(globalToolPane(), &UIToolPaneGlobal::sigCreateMedium, 675 this, &UIVirtualBoxManagerAdvancedWidget::sigCreateMedium); 676 disconnect(globalToolPane(), &UIToolPaneGlobal::sigCopyMedium, 677 this, &UIVirtualBoxManagerAdvancedWidget::sigCopyMedium); 678 679 /* Machine Tool Manager connections: */ 680 disconnect(machineToolManager(), &UIMachineManagerWidget::sigToolTypeChange, 681 this, &UIVirtualBoxManagerAdvancedWidget::sigToolTypeChangeMachine); 682 disconnect(machineToolManager(), &UIMachineManagerWidget::sigChooserPaneIndexChange, 683 this, &UIVirtualBoxManagerAdvancedWidget::sigChooserPaneIndexChange); 684 disconnect(machineToolManager(), &UIMachineManagerWidget::sigChooserPaneSelectionChange, 685 this, &UIVirtualBoxManagerAdvancedWidget::sltUpdateToolbar); 686 disconnect(machineToolManager(), &UIMachineManagerWidget::sigCloudMachineStateChange, 687 this, &UIVirtualBoxManagerAdvancedWidget::sigCloudMachineStateChange); 688 /* Machine Tool Pane connections: */ 689 disconnect(machineToolPane(), &UIToolPaneMachine::sigLinkClicked, 690 this, &UIVirtualBoxManagerAdvancedWidget::sigMachineSettingsLinkClicked); 691 disconnect(machineToolPane(), &UIToolPaneMachine::sigCurrentSnapshotItemChange, 692 this, &UIVirtualBoxManagerAdvancedWidget::sigCurrentSnapshotItemChange); 693 disconnect(machineToolPane(), &UIToolPaneMachine::sigDetachToolPane, 694 this, &UIVirtualBoxManagerAdvancedWidget::sigDetachToolPane); 1058 695 1059 696 /* Chooser-pane connections: */ 1060 disconnect(m_pPaneChooser, &UIChooser::sigSelectionChanged, 1061 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleChooserPaneIndexChange); 1062 disconnect(m_pPaneChooser, &UIChooser::sigSelectionInvalidated, 1063 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleChooserPaneSelectionInvalidated); 1064 disconnect(m_pPaneChooser, &UIChooser::sigToggleStarted, 1065 m_pPaneToolsMachine, &UIToolPaneMachine::sigToggleStarted); 1066 disconnect(m_pPaneChooser, &UIChooser::sigToggleFinished, 1067 m_pPaneToolsMachine, &UIToolPaneMachine::sigToggleFinished); 1068 disconnect(m_pPaneChooser, &UIChooser::sigGroupSavingStateChanged, 697 disconnect(chooser(), &UIChooser::sigGroupSavingStateChanged, 1069 698 this, &UIVirtualBoxManagerAdvancedWidget::sigGroupSavingStateChanged); 1070 disconnect( m_pPaneChooser, &UIChooser::sigCloudUpdateStateChanged,699 disconnect(chooser(), &UIChooser::sigCloudUpdateStateChanged, 1071 700 this, &UIVirtualBoxManagerAdvancedWidget::sigCloudUpdateStateChanged); 1072 disconnect(m_pPaneChooser, &UIChooser::sigToolMenuRequested, 1073 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleToolMenuRequested); 1074 disconnect(m_pPaneChooser, &UIChooser::sigCloudProfileStateChange, 1075 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleCloudProfileStateChange); 1076 disconnect(m_pPaneChooser, &UIChooser::sigCloudMachineStateChange, 1077 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleCloudMachineStateChange); 1078 disconnect(m_pPaneChooser, &UIChooser::sigStartOrShowRequest, 701 disconnect(chooser(), &UIChooser::sigStartOrShowRequest, 1079 702 this, &UIVirtualBoxManagerAdvancedWidget::sigStartOrShowRequest); 1080 disconnect( m_pPaneChooser, &UIChooser::sigMachineSearchWidgetVisibilityChanged,703 disconnect(chooser(), &UIChooser::sigMachineSearchWidgetVisibilityChanged, 1081 704 this, &UIVirtualBoxManagerAdvancedWidget::sigMachineSearchWidgetVisibilityChanged); 1082 1083 /* Details-pane connections: */ 1084 disconnect(m_pPaneToolsMachine, &UIToolPaneMachine::sigLinkClicked, 1085 this, &UIVirtualBoxManagerAdvancedWidget::sigMachineSettingsLinkClicked); 1086 1087 /* Tools-pane connections: */ 1088 disconnect(m_pMenuToolsGlobal, &UITools::sigSelectionChanged, 1089 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleGlobalToolsMenuIndexChange); 1090 disconnect(m_pMenuToolsMachine, &UITools::sigSelectionChanged, 1091 this, &UIVirtualBoxManagerAdvancedWidget::sltHandleMachineToolsMenuIndexChange); 1092 } 1093 1094 void UIVirtualBoxManagerAdvancedWidget::cleanupWidgets() 1095 { 705 } 706 707 void UIVirtualBoxManagerAdvancedWidget::cleanup() 708 { 709 /* Destroy notification-center: */ 1096 710 UINotificationCenter::destroy(); 1097 711 } 1098 712 1099 void UIVirtualBoxManagerAdvancedWidget::cleanup() 1100 { 1101 /* Ask sub-dialogs to commit data: */ 1102 sltHandleCommitData(); 1103 1104 /* Cleanup everything: */ 1105 cleanupWidgets(); 1106 } 1107 1108 void UIVirtualBoxManagerAdvancedWidget::recacheCurrentMachineItemInformation(bool fDontRaiseErrorPane /* = false */) 1109 { 1110 /* Sanity check, this method is for machine or group of machine items: */ 1111 if (!isMachineItemSelected() && !isGroupItemSelected()) 1112 return; 1113 1114 /* Get current item: */ 1115 UIVirtualMachineItem *pItem = currentItem(); 1116 const bool fCurrentItemIsOk = isItemAccessible(pItem); 1117 1118 /* If current item is Ok: */ 1119 if (fCurrentItemIsOk) 1120 { 1121 /* If Error-pane is chosen currently => switch to tool currently chosen in Tools-menu: */ 1122 if (m_pPaneToolsMachine->currentTool() == UIToolType_Error) 1123 switchMachineToolTo(m_pMenuToolsMachine->toolsType()); 1124 1125 /* Propagate current items to the Tools pane: */ 1126 m_pPaneToolsMachine->setItems(currentItems()); 1127 } 1128 /* Otherwise if we were not asked separately to calm down: */ 1129 else if (!fDontRaiseErrorPane) 1130 { 1131 /* Make sure Error pane raised: */ 1132 if (m_pPaneToolsMachine->currentTool() != UIToolType_Error) 1133 m_pPaneToolsMachine->openTool(UIToolType_Error); 1134 1135 /* Propagate last access error to the Error-pane: */ 1136 if (pItem) 1137 m_pPaneToolsMachine->setErrorDetails(pItem->accessError()); 1138 } 1139 } 1140 1141 void UIVirtualBoxManagerAdvancedWidget::updateToolsMenuGlobal() 1142 { 1143 /* Update global tools restrictions: */ 1144 QSet<UIToolType> restrictedTypes; 1145 const bool fExpertMode = gEDataManager->isSettingsInExpertMode(); 1146 if (!fExpertMode) 1147 restrictedTypes << UIToolType_Media 1148 << UIToolType_Network; 1149 if (restrictedTypes.contains(m_pMenuToolsGlobal->toolsType())) 1150 m_pMenuToolsGlobal->setToolsType(UIToolType_Welcome); 1151 const QList restrictions(restrictedTypes.begin(), restrictedTypes.end()); 1152 m_pMenuToolsGlobal->setRestrictedToolTypes(restrictions); 1153 1154 /* Take restrictions into account, closing all restricted tools: */ 1155 foreach (const UIToolType &enmRestrictedType, restrictedTypes) 1156 m_pPaneToolsGlobal->closeTool(enmRestrictedType); 1157 } 1158 1159 void UIVirtualBoxManagerAdvancedWidget::updateToolsMenuMachine(UIVirtualMachineItem *pItem) 1160 { 1161 /* Get current item state: */ 1162 const bool fCurrentItemIsOk = isItemAccessible(pItem); 1163 1164 /* Update machine tools restrictions: */ 1165 QSet<UIToolType> restrictedTypes; 1166 const bool fExpertMode = gEDataManager->isSettingsInExpertMode(); 1167 if (!fExpertMode) 1168 restrictedTypes << UIToolType_FileManager; 1169 if (pItem && pItem->itemType() != UIVirtualMachineItemType_Local) 1170 restrictedTypes << UIToolType_Snapshots 1171 << UIToolType_Logs 1172 << UIToolType_FileManager; 1173 if (restrictedTypes.contains(m_pMenuToolsMachine->toolsType())) 1174 m_pMenuToolsMachine->setToolsType(UIToolType_Details); 1175 const QList restrictions(restrictedTypes.begin(), restrictedTypes.end()); 1176 m_pMenuToolsMachine->setRestrictedToolTypes(restrictions); 1177 /* Update machine menu items availability: */ 1178 m_pMenuToolsMachine->setItemsEnabled(fCurrentItemIsOk); 1179 1180 /* Take restrictions into account, closing all restricted tools: */ 1181 foreach (const UIToolType &enmRestrictedType, restrictedTypes) 1182 m_pPaneToolsMachine->closeTool(enmRestrictedType); 1183 } 1184 1185 void UIVirtualBoxManagerAdvancedWidget::handleCurrentToolTypeChange(UIToolType enmType) 1186 { 1187 /* This method's behavior depends first of all of currently selected tool class. 1188 * But keep in mind, it is called for both Global and Machine type changes. */ 1189 1190 /* If Global tools currently chosen: */ 1191 if (m_pStackedWidget->currentWidget() == m_pPaneToolsGlobal) 1192 { 1193 /* For the Global tool type changes, 1194 * start unconditionally updating all cloud VMs, 1195 * if Activity Overview tool currently chosen (even if VMs are not selected): */ 1196 if (UIToolStuff::isTypeOfClass(enmType, UIToolClass_Global)) 1197 { 1198 bool fActivityOverviewActive = enmType == UIToolType_Activities; 1199 m_pPaneChooser->setKeepCloudNodesUpdated(fActivityOverviewActive); 1200 if (fActivityOverviewActive) 1201 m_pPaneToolsGlobal->setCloudMachineItems(m_pPaneChooser->cloudMachineItems()); 1202 } 1203 } 1204 /* If Machine tools currently chosen: */ 1205 else 1206 { 1207 /* Stop unconditionally updating all cloud VMs, 1208 * (tho they will still be updated if selected): */ 1209 m_pPaneChooser->setKeepCloudNodesUpdated(false); 1210 } 1211 } 713 UIGlobalToolsManagerWidget *UIVirtualBoxManagerAdvancedWidget::globalToolManager() const 714 { 715 return m_pGlobalToolManager; 716 } 717 718 UIToolPaneGlobal *UIVirtualBoxManagerAdvancedWidget::globalToolPane() const 719 { 720 return globalToolManager()->toolPane(); 721 } 722 723 UIMachineManagerWidget *UIVirtualBoxManagerAdvancedWidget::machineToolManager() const 724 { 725 return globalToolManager()->machineManager(); 726 } 727 728 UIToolPaneMachine *UIVirtualBoxManagerAdvancedWidget::machineToolPane() const 729 { 730 return machineToolManager()->toolPane(); 731 } 732 733 UIChooser *UIVirtualBoxManagerAdvancedWidget::chooser() const 734 { 735 return machineToolManager()->chooser(); 736 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerAdvancedWidget.h
r107288 r107359 40 40 41 41 /* Forward declarations: */ 42 class QStackedWidget;43 class QTimer;44 class QISplitter;45 42 class QIToolBar; 46 43 class UIActionPool; 47 44 class UIChooser; 45 class UIGlobalToolsManagerWidget; 46 class UIMachineManagerWidget; 48 47 class UIToolPaneGlobal; 49 48 class UIToolPaneMachine; 50 class UITools;51 49 class UIVirtualBoxManager; 52 50 class UIVirtualMachineItem; … … 57 55 Q_OBJECT; 58 56 59 /** Possible selection types. */60 enum SelectionType61 {62 SelectionType_Invalid,63 SelectionType_SingleLocalGroupItem,64 SelectionType_SingleCloudGroupItem,65 SelectionType_FirstIsGlobalItem,66 SelectionType_FirstIsLocalMachineItem,67 SelectionType_FirstIsCloudMachineItem68 };69 70 57 signals: 71 72 /** @name Tool-bar stuff.73 * @{ */74 /* Notifies listeners about tool-bar height change. */75 void sigToolBarHeightChange(int iHeight);76 /** @} */77 58 78 59 /** @name Chooser pane stuff. … … 153 134 /** Returns a list of current-items. */ 154 135 QList<UIVirtualMachineItem*> currentItems() const; 155 156 /** Returns whether passed @a pItem accessible, by default it's the current one. */157 bool isItemAccessible(UIVirtualMachineItem *pItem = 0) const;158 136 159 137 /** Returns whether group item is selected. */ … … 178 156 /** Returns whether all items of one group are selected. */ 179 157 bool isAllItemsOfOneGroupSelected() const; 180 181 /** Returns current selection type. */182 SelectionType selectionType() const;183 158 184 159 /** Returns full name of currently selected group. */ … … 230 205 /** Returns whether Machine tool of passed @a enmType is opened. */ 231 206 bool isMachineToolOpened(UIToolType enmType) const; 232 /** Switches Global tool to passed @a enmType. */233 void switchGlobalToolTo(UIToolType enmType);234 /** Switches Machine tool to passed @a enmType. */235 void switchMachineToolTo(UIToolType enmType);236 207 /** Closes Global tool of passed @a enmType. */ 237 208 void closeGlobalTool(UIToolType enmType); … … 265 236 private slots: 266 237 267 /** @name Event handling stuff.268 * @{ */269 /** Handles translation event. */270 void sltRetranslateUI();271 /** @} */272 273 238 /** @name General stuff. 274 239 * @{ */ … … 277 242 /** @} */ 278 243 279 /** @name CVirtualBox event handling stuff.280 * @{ */281 /** Handles CVirtualBox event about state change for machine with @a uId. */282 void sltHandleMachineStateChange(const QUuid &uId);283 /** @} */284 285 /** @name CVirtualBox extra-data event handling stuff.286 * @{ */287 /** Handles signal about settings expert mode change. */288 void sltHandleSettingsExpertModeChange();289 /** @} */290 291 /** @name Splitter stuff.292 * @{ */293 /** Handles signal about splitter move. */294 void sltHandleSplitterMove();295 /** Handles request to save splitter settings. */296 void sltSaveSplitterSettings();297 /** @} */298 299 244 /** @name Tool-bar stuff. 300 245 * @{ */ 301 /** Handles signal about tool-bar resize to @a newSize. */ 302 void sltHandleToolBarResize(const QSize &newSize); 303 /** @} */ 304 305 /** @name Chooser pane stuff. 306 * @{ */ 307 /** Handles signal about Chooser-pane index change. */ 308 void sltHandleChooserPaneIndexChange(); 309 310 /** Handles signal about Chooser-pane selection invalidated. */ 311 void sltHandleChooserPaneSelectionInvalidated() { recacheCurrentMachineItemInformation(true /* fDontRaiseErrorPane */); } 312 313 /** Handles state change for cloud profile with certain @a strProviderShortName and @a strProfileName. */ 314 void sltHandleCloudProfileStateChange(const QString &strProviderShortName, 315 const QString &strProfileName); 316 /** Handles state change for cloud machine with certain @a uId. */ 317 void sltHandleCloudMachineStateChange(const QUuid &uId); 318 /** @} */ 319 320 /** @name Tools pane stuff. 321 * @{ */ 322 /** Handles tool popup-menu request. */ 323 void sltHandleToolMenuRequested(const QPoint &position, UIVirtualMachineItem *pItem); 324 325 /** Handles signal about global Tools-menu index change. 326 * @param enmType Brings current tool type. */ 327 void sltHandleGlobalToolsMenuIndexChange(UIToolType enmType) { switchGlobalToolTo(enmType); } 328 /** Handles signal about machine Tools-menu index change. 329 * @param enmType Brings current tool type. */ 330 void sltHandleMachineToolsMenuIndexChange(UIToolType enmType) { switchMachineToolTo(enmType); } 331 332 /** Handles signal requesting switch to Activity pane of machine with @a uMachineId. */ 333 void sltSwitchToMachineActivityPane(const QUuid &uMachineId); 334 /** Handles signal requesting switch to Resources pane. */ 335 void sltSwitchToActivityOverviewPane(); 246 /** Updates tool-bar. */ 247 void sltUpdateToolbar(); 336 248 /** @} */ 337 249 … … 354 266 /** Cleanups connections. */ 355 267 void cleanupConnections(); 356 /** Cleanups widgets. */357 void cleanupWidgets();358 268 /** Cleanups all. */ 359 269 void cleanup(); … … 362 272 /** @name Tools stuff. 363 273 * @{ */ 364 /** Re caches current machine item information.365 * @param fDontRaiseErrorPane Brings whether we should not raise error-pane. */366 void recacheCurrentMachineItemInformation(bool fDontRaiseErrorPane = false);367 368 /** Updates Global tools menu. */ 369 void updateToolsMenuGlobal();370 /** Updates Machine tools menu for @a pItem specified. */371 void updateToolsMenuMachine(UIVirtualMachineItem *pItem);372 373 /** Handles current tool @a enmType change. */374 void handleCurrentToolTypeChange(UIToolType enmType);375 /** @} */ 376 377 /** Holds the action-pool instance. */274 /** Returns Global Tool Manager instance. */ 275 UIGlobalToolsManagerWidget *globalToolManager() const; 276 /** Returns Global Tool Pane reference. */ 277 UIToolPaneGlobal *globalToolPane() const; 278 279 /** Returns Machine Tool Manager reference. */ 280 UIMachineManagerWidget *machineToolManager() const; 281 /** Returns Machine Tool Pane reference. */ 282 UIToolPaneMachine *machineToolPane() const; 283 /** Returns Machine Chooser Pane reference. */ 284 UIChooser *chooser() const; 285 /** @} */ 286 287 /** Holds the action-pool reference. */ 378 288 UIActionPool *m_pActionPool; 379 380 /** Holds the central splitter instance. */381 QISplitter *m_pSplitter;382 289 383 290 /** Holds the main toolbar instance. */ 384 291 QIToolBar *m_pToolBar; 385 292 386 /** Holds the Chooser-pane instance. */ 387 UIChooser *m_pPaneChooser; 388 /** Holds the stacked-widget. */ 389 QStackedWidget *m_pStackedWidget; 390 /** Holds the Global Tools-pane instance. */ 391 UIToolPaneGlobal *m_pPaneToolsGlobal; 392 /** Holds the Machine Tools-pane instance. */ 393 UIToolPaneMachine *m_pPaneToolsMachine; 394 /** Holds the Global Tools-menu instance. */ 395 UITools *m_pMenuToolsGlobal; 396 /** Holds the Machine Tools-menu instance. */ 397 UITools *m_pMenuToolsMachine; 398 399 /** Holds the last selection type. */ 400 SelectionType m_enmSelectionType; 401 /** Holds whether the last selected item was accessible. */ 402 bool m_fSelectedMachineItemAccessible; 403 404 /** Holds the splitter settings save timer. */ 405 QTimer *m_pSplitterSettingsSaveTimer; 293 /** Holds the Global Tool Manager instance. */ 294 UIGlobalToolsManagerWidget *m_pGlobalToolManager; 406 295 }; 407 296
Note:
See TracChangeset
for help on using the changeset viewer.