Changeset 73492 in vbox for trunk/src/VBox
- Timestamp:
- Aug 3, 2018 3:30:44 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 6 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r73425 r73492 751 751 src/manager/UIToolPaneMachine.h \ 752 752 src/manager/UIVirtualBoxManager.h \ 753 src/manager/UIVirtualBoxManagerWidget.h \ 753 754 src/manager/UIVirtualMachineItem.h \ 754 755 src/manager/UIWelcomePane.h \ … … 1427 1428 src/manager/UIToolPaneMachine.cpp \ 1428 1429 src/manager/UIVirtualBoxManager.cpp \ 1430 src/manager/UIVirtualBoxManagerWidget.cpp \ 1429 1431 src/manager/UIVirtualMachineItem.cpp \ 1430 1432 src/manager/UIWelcomePane.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp
r73457 r73492 21 21 22 22 /* Qt includes: */ 23 # include <QMenuBar>24 23 # include <QResizeEvent> 25 24 # include <QStandardPaths> 26 25 # include <QStatusBar> 27 # include <QToolButton> 28 # include <QTimer> 26 //# include <QToolButton> 29 27 30 28 /* GUI includes: */ 31 29 # include "QIFileDialog.h" 32 # include "QISplitter.h"33 30 # include "UIActionPoolSelector.h" 34 31 # include "UIDesktopServices.h" 35 # include "UIErrorString.h"36 32 # include "UIExtraDataManager.h" 37 # include "UIChooser.h"38 33 # include "UIHostNetworkManager.h" 39 34 # include "UIMedium.h" … … 42 37 # include "UIModalWindowManager.h" 43 38 # include "UIVirtualBoxManager.h" 39 # include "UIVirtualBoxManagerWidget.h" 44 40 # include "UISettingsDialogSpecific.h" 45 # include "UISlidingWidget.h"46 # include "UITabBar.h"47 # include "UIToolBar.h"48 41 # include "UIVMLogViewerDialog.h" 49 42 # include "UIVirtualMachineItem.h" 50 # include "UIToolPaneMachine.h"51 # include "UIToolbarTools.h"52 43 # ifdef VBOX_GUI_WITH_NETWORK_MANAGER 53 44 # include "UIUpdateManager.h" … … 119 110 , m_fFirstMediumEnumerationHandled(false) 120 111 , m_pActionPool(0) 121 , m_pSlidingWidget(0)122 , m_pSplitter(0)123 , m_pToolBar(0)124 , m_pTabBarMachine(0)125 , m_pTabBarGlobal(0)126 , m_pActionTabBarMachine(0)127 , m_pActionTabBarGlobal(0)128 , m_pToolbarTools(0)129 , m_pPaneChooser(0)130 , m_pPaneToolsMachine(0)131 , m_pPaneToolsGlobal(0)132 112 , m_pGroupMenuAction(0) 133 113 , m_pMachineMenuAction(0) … … 173 153 break; 174 154 } 155 175 156 /* Call to base-class: */ 176 157 return QIWithRetranslateUI<QIMainWindow>::eventFilter(pObject, pEvent); … … 191 172 #endif /* VBOX_BLEEDING_EDGE */ 192 173 setWindowTitle(strTitle); 193 194 /* Make sure chosen item fetched: */195 sltHandleChooserPaneIndexChange(false /* update details? */, false /* update snapshots? */, false /* update the logviewer? */);196 197 #ifdef VBOX_WS_MAC198 // WORKAROUND:199 // There is a bug in Qt Cocoa which result in showing a "more arrow" when200 // the necessary size of the toolbar is increased. Also for some languages201 // the with doesn't match if the text increase. So manually adjust the size202 // after changing the text.203 m_pToolBar->updateLayout();204 #endif205 174 } 206 175 … … 251 220 break; 252 221 } 253 #ifdef VBOX_WS_MAC254 case QEvent::ContextMenu:255 {256 /* This is the unified context menu event. Lets show the context menu. */257 QContextMenuEvent *pContextMenuEvent = static_cast<QContextMenuEvent*>(pEvent);258 sltHandleContextMenuRequest(pContextMenuEvent->globalPos());259 /* Accept it to interrupt the chain. */260 pContextMenuEvent->accept();261 return false;262 break;263 }264 #endif /* VBOX_WS_MAC */265 222 default: 266 223 break; … … 287 244 void UIVirtualBoxManager::polishEvent(QShowEvent *) 288 245 { 289 /* Make sure user warned about inaccessible medium(s) 290 * even if enumeration had finished before selector window shown: */ 291 QTimer::singleShot(0, this, SLOT(sltHandleMediumEnumerationFinish())); 292 293 /* Call for async polishing: */ 294 QMetaObject::invokeMethod(this, "sltHandlePolishEvent", Qt::QueuedConnection); 246 /* Make sure user warned about inaccessible media: */ 247 QMetaObject::invokeMethod(this, "sltHandleMediumEnumerationFinish", Qt::QueuedConnection); 295 248 } 296 249 … … 302 255 /* Quit application: */ 303 256 QApplication::quit(); 304 }305 306 void UIVirtualBoxManager::sltHandlePolishEvent()307 {308 /* Get current item: */309 UIVirtualMachineItem *pItem = currentItem();310 311 /* Make sure there is accessible VM item chosen: */312 if (pItem && pItem->accessible())313 {314 // WORKAROUND:315 // By some reason some of X11 DEs unable to update() tab-bars on startup.316 // Let's just _create_ them later, asynchronously after the showEvent().317 /* Restore previously opened Machine tools at startup: */318 QMap<ToolTypeMachine, QAction*> mapActionsMachine;319 mapActionsMachine[ToolTypeMachine_Details] = actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Details);320 mapActionsMachine[ToolTypeMachine_Snapshots] = actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots);321 mapActionsMachine[ToolTypeMachine_LogViewer] = actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_LogViewer);322 for (int i = m_orderMachine.size() - 1; i >= 0; --i)323 if (m_orderMachine.at(i) != ToolTypeMachine_Invalid)324 mapActionsMachine.value(m_orderMachine.at(i))->trigger();325 /* Make sure further action triggering cause tool type switch as well: */326 actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->setProperty("watch_child_activation", true);327 }328 257 } 329 258 … … 341 270 #endif /* VBOX_WS_X11 */ 342 271 343 void UIVirtualBoxManager::sltHandleContextMenuRequest(const QPoint &position)344 {345 /* Populate toolbar/statusbar acctions: */346 QList<QAction*> actions;347 348 /* Create 'Show Toolbar' action: */349 QAction *pShowToolBar = new QAction(tr("Show Toolbar"), 0);350 AssertPtrReturnVoid(pShowToolBar);351 {352 /* Configure action: */353 pShowToolBar->setCheckable(true);354 pShowToolBar->setChecked(m_pToolBar->isVisible());355 356 /* Add into action list: */357 actions << pShowToolBar;358 }359 360 /* Create 'Show Toolbar Text' action: */361 QAction *pShowToolBarText = new QAction(tr("Show Toolbar Text"), 0);362 AssertPtrReturnVoid(pShowToolBarText);363 {364 /* Configure action: */365 pShowToolBarText->setCheckable(true);366 pShowToolBarText->setChecked(m_pToolBar->toolButtonStyle() == Qt::ToolButtonTextUnderIcon);367 368 /* Add into action list: */369 actions << pShowToolBarText;370 }371 372 /* Prepare the menu position: */373 QPoint globalPosition = position;374 QWidget *pSender = static_cast<QWidget*>(sender());375 if (pSender)376 globalPosition = pSender->mapToGlobal(position);377 QAction *pResult = QMenu::exec(actions, globalPosition);378 if (pResult == pShowToolBar)379 {380 if (pResult->isChecked())381 m_pToolBar->show();382 else383 m_pToolBar->hide();384 }385 else if (pResult == pShowToolBarText)386 {387 m_pToolBar->setToolButtonStyle( pResult->isChecked()388 ? Qt::ToolButtonTextUnderIcon389 : Qt::ToolButtonIconOnly);390 m_pToolbarTools->setToolButtonStyle( pResult->isChecked()391 ? Qt::ToolButtonTextUnderIcon392 : Qt::ToolButtonIconOnly);393 }394 }395 396 void UIVirtualBoxManager::sltHandleChooserPaneIndexChange(bool fUpdateDetails /* = true */,397 bool fUpdateSnapshots /* = true */,398 bool fUpdateLogViewer /* = true */)399 {400 /* Get current item: */401 UIVirtualMachineItem *pItem = currentItem();402 403 /* Update action visibility: */404 updateActionsVisibility();405 /* Update action appearance: */406 updateActionsAppearance();407 408 /* Update Tools-pane: */409 m_pPaneToolsMachine->setCurrentItem(pItem);410 411 /* Update Machine tab-bar visibility */412 m_pTabBarMachine->setEnabled(pItem && pItem->accessible());413 414 /* If current item exists & accessible: */415 if (pItem && pItem->accessible())416 {417 /* If Desktop pane is chosen currently: */418 if (m_pPaneToolsMachine->currentTool() == ToolTypeMachine_Desktop)419 {420 /* Make sure Details or Snapshot pane is chosen if opened: */421 if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))422 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Details)->trigger();423 else424 if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Snapshots))425 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots)->trigger();426 else427 if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_LogViewer))428 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_LogViewer)->trigger();429 }430 431 /* Update Details-pane (if requested): */432 if ( fUpdateDetails433 && m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))434 m_pPaneToolsMachine->setItems(currentItems());435 /* Update the Snapshots-pane or/and Logviewer-pane (if requested): */436 if (fUpdateSnapshots || fUpdateLogViewer)437 m_pPaneToolsMachine->setMachine(pItem->machine());438 }439 else440 {441 /* Make sure Desktop-pane raised: */442 m_pPaneToolsMachine->openTool(ToolTypeMachine_Desktop);443 444 /* Note that the machine becomes inaccessible (or if the last VM gets445 * deleted), we have to update all fields, ignoring input arguments. */446 if (pItem)447 {448 /* The VM is inaccessible: */449 m_pPaneToolsMachine->setDetailsError(UIErrorString::formatErrorInfo(pItem->accessError()));450 }451 452 /* Update Details-pane (in any case): */453 if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))454 m_pPaneToolsMachine->setItems(currentItems());455 /* Update Snapshots-pane and Logviewer-pane (in any case): */456 m_pPaneToolsMachine->setMachine(CMachine());457 }458 }459 460 272 void UIVirtualBoxManager::sltHandleMediumEnumerationFinish() 461 273 { … … 469 281 * otherwise user sees everything himself: */ 470 282 if ( m_pManagerVirtualMedia 471 || m_p PaneToolsGlobal->isToolOpened(ToolTypeGlobal_VirtualMedia))283 || m_pWidget->isToolOpened(ToolTypeGlobal_VirtualMedia)) 472 284 return; 473 285 … … 549 361 } 550 362 363 void UIVirtualBoxManager::sltHandleChooserPaneIndexChange() 364 { 365 updateActionsVisibility(); 366 updateActionsAppearance(); 367 } 368 551 369 void UIVirtualBoxManager::sltHandleGroupSavingProgressChange() 552 370 { … … 556 374 void UIVirtualBoxManager::sltHandleStateChange(const QString &) 557 375 { 558 /* Get current item: */559 UIVirtualMachineItem *pItem = currentItem();560 561 /* Make sure current item present: */562 if (!pItem)563 return;564 565 /* Update actions: */566 376 updateActionsAppearance(); 567 377 } … … 570 380 { 571 381 /* First check if instance of widget opened the embedded way: */ 572 if (m_p PaneToolsGlobal->isToolOpened(ToolTypeGlobal_VirtualMedia))573 { 574 sltHandleToolOpenedGlobal(ToolTypeGlobal_VirtualMedia);382 if (m_pWidget->isToolOpened(ToolTypeGlobal_VirtualMedia)) 383 { 384 m_pWidget->switchToTool(ToolTypeGlobal_VirtualMedia); 575 385 return; 576 386 } … … 600 410 { 601 411 /* First check if instance of widget opened the embedded way: */ 602 if (m_p PaneToolsGlobal->isToolOpened(ToolTypeGlobal_HostNetwork))603 { 604 sltHandleToolOpenedGlobal(ToolTypeGlobal_HostNetwork);412 if (m_pWidget->isToolOpened(ToolTypeGlobal_HostNetwork)) 413 { 414 m_pWidget->switchToTool(ToolTypeGlobal_HostNetwork); 605 415 return; 606 416 } … … 1201 1011 1202 1012 /* First check if a logviewer is already opened in embedded mode: */ 1203 if (m_p PaneToolsMachine->isToolOpened(ToolTypeMachine_LogViewer))1204 { 1205 sltHandleToolOpenedMachine(ToolTypeMachine_LogViewer);1013 if (m_pWidget->isToolOpened(ToolTypeMachine_LogViewer)) 1014 { 1015 m_pWidget->switchToTool(ToolTypeMachine_LogViewer); 1206 1016 return; 1207 1017 } … … 1320 1130 } 1321 1131 1322 void UIVirtualBoxManager::sltHandleToolsTypeSwitch()1323 {1324 /* If Machine tool button is checked => go backward: */1325 if (actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->isChecked())1326 m_pSlidingWidget->moveBackward();1327 1328 else1329 1330 /* If Global tool button is checked => go forward: */1331 if (actionPool()->action(UIActionIndexST_M_Tools_T_Global)->isChecked())1332 m_pSlidingWidget->moveForward();1333 1334 /* Update action visibility: */1335 updateActionsVisibility();1336 1337 /* Make sure chosen item fetched: */1338 sltHandleChooserPaneIndexChange(false /* update details? */, false /* update snapshots? */, false /* update the logviewer? */);1339 }1340 1341 void UIVirtualBoxManager::sltHandleShowTabBarMachine()1342 {1343 m_pActionTabBarGlobal->setVisible(false);1344 m_pActionTabBarMachine->setVisible(true);1345 }1346 1347 void UIVirtualBoxManager::sltHandleShowTabBarGlobal()1348 {1349 m_pActionTabBarMachine->setVisible(false);1350 m_pActionTabBarGlobal->setVisible(true);1351 }1352 1353 void UIVirtualBoxManager::sltHandleToolOpenedMachine(ToolTypeMachine enmType)1354 {1355 /* First, make sure corresponding tool set opened: */1356 if ( !actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->isChecked()1357 && actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->property("watch_child_activation").toBool())1358 actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->setChecked(true);1359 1360 /* Open corresponding tool: */1361 m_pPaneToolsMachine->openTool(enmType);1362 /* If that was 'Details' => pass there current items: */1363 if ( enmType == ToolTypeMachine_Details1364 && m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))1365 m_pPaneToolsMachine->setItems(currentItems());1366 /* If that was 'Snapshot' or 'LogViewer' => pass there current or null machine: */1367 if (enmType == ToolTypeMachine_Snapshots || enmType == ToolTypeMachine_LogViewer)1368 {1369 UIVirtualMachineItem *pItem = currentItem();1370 m_pPaneToolsMachine->setMachine(pItem ? pItem->machine() : CMachine());1371 }1372 }1373 1374 void UIVirtualBoxManager::sltHandleToolOpenedGlobal(ToolTypeGlobal enmType)1375 {1376 /* First, make sure corresponding tool set opened: */1377 if ( !actionPool()->action(UIActionIndexST_M_Tools_T_Global)->isChecked()1378 && actionPool()->action(UIActionIndexST_M_Tools_T_Global)->property("watch_child_activation").toBool())1379 actionPool()->action(UIActionIndexST_M_Tools_T_Global)->setChecked(true);1380 1381 /* Open corresponding tool: */1382 m_pPaneToolsGlobal->openTool(enmType);1383 }1384 1385 void UIVirtualBoxManager::sltHandleToolClosedMachine(ToolTypeMachine enmType)1386 {1387 /* Close corresponding tool: */1388 m_pPaneToolsMachine->closeTool(enmType);1389 }1390 1391 void UIVirtualBoxManager::sltHandleToolClosedGlobal(ToolTypeGlobal enmType)1392 {1393 /* Close corresponding tool: */1394 m_pPaneToolsGlobal->closeTool(enmType);1395 }1396 1397 UIVirtualMachineItem *UIVirtualBoxManager::currentItem() const1398 {1399 return m_pPaneChooser->currentItem();1400 }1401 1402 QList<UIVirtualMachineItem*> UIVirtualBoxManager::currentItems() const1403 {1404 return m_pPaneChooser->currentItems();1405 }1406 1407 1132 void UIVirtualBoxManager::prepare() 1408 1133 { … … 1425 1150 prepareMenuBar(); 1426 1151 prepareStatusBar(); 1427 prepareToolbar();1428 1152 prepareWidgets(); 1429 1153 prepareConnections(); … … 1436 1160 1437 1161 #ifdef VBOX_WS_MAC 1438 /* Enable unified toolbar: */1439 m_pToolBar->enableMacToolbar();1440 1441 1162 /* Beta label? */ 1442 1163 if (vboxGlobal().isBeta()) … … 1445 1166 ::darwinLabelWindow(this, &betaLabel, true); 1446 1167 } 1447 1448 /* General event filter: */1449 qApp->installEventFilter(this);1450 1168 #endif /* VBOX_WS_MAC */ 1451 1452 /* Make sure current Chooser-pane index fetched: */1453 sltHandleChooserPaneIndexChange();1454 1169 } 1455 1170 … … 1880 1595 } 1881 1596 1882 void UIVirtualBoxManager::prepareToolbar()1883 {1884 /* Create Main toolbar: */1885 m_pToolBar = new UIToolBar(this);1886 AssertPtrReturnVoid(m_pToolBar);1887 {1888 /* Configure toolbar: */1889 const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);1890 m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));1891 m_pToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);1892 m_pToolBar->setContextMenuPolicy(Qt::CustomContextMenu);1893 m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);1894 1895 /* Add main actions block: */1896 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_New));1897 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Settings));1898 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Discard));1899 m_pToolBar->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow));1900 #ifdef VBOX_WS_MAC1901 // WORKAROUND:1902 // Actually Qt should do that itself but by some unknown reason it sometimes1903 // forget to update toolbar after changing its actions on cocoa platform.1904 connect(actionPool()->action(UIActionIndexST_M_Machine_S_New), &UIAction::changed,1905 m_pToolBar, static_cast<void(UIToolBar::*)(void)>(&UIToolBar::update));1906 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Settings), &UIAction::changed,1907 m_pToolBar, static_cast<void(UIToolBar::*)(void)>(&UIToolBar::update));1908 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Discard), &UIAction::changed,1909 m_pToolBar, static_cast<void(UIToolBar::*)(void)>(&UIToolBar::update));1910 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow), &UIAction::changed,1911 m_pToolBar, static_cast<void(UIToolBar::*)(void)>(&UIToolBar::update));1912 #endif /* VBOX_WS_MAC */1913 1914 /* Create Machine tab-bar: */1915 m_pTabBarMachine = new UITabBar;1916 AssertPtrReturnVoid(m_pTabBarMachine);1917 {1918 /* Configure tab-bar: */1919 const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin);1920 const int iR = qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin);1921 m_pTabBarMachine->setContentsMargins(iL, 0, iR, 0);1922 1923 /* Add into toolbar: */1924 m_pActionTabBarMachine = m_pToolBar->addWidget(m_pTabBarMachine);1925 }1926 1927 /* Create Global tab-bar: */1928 m_pTabBarGlobal = new UITabBar;1929 AssertPtrReturnVoid(m_pTabBarGlobal);1930 {1931 /* Configure tab-bar: */1932 const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin);1933 const int iR = qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin);1934 m_pTabBarGlobal->setContentsMargins(iL, 0, iR, 0);1935 1936 /* Add into toolbar: */1937 m_pActionTabBarGlobal = m_pToolBar->addWidget(m_pTabBarGlobal);1938 }1939 1940 /* Create Tools toolbar: */1941 m_pToolbarTools = new UIToolbarTools(actionPool());1942 if (m_pToolbarTools)1943 {1944 /* Configure toolbar: */1945 m_pToolbarTools->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);1946 connect(m_pToolbarTools, &UIToolbarTools::sigShowTabBarMachine,1947 this, &UIVirtualBoxManager::sltHandleShowTabBarMachine);1948 connect(m_pToolbarTools, &UIToolbarTools::sigShowTabBarGlobal,1949 this, &UIVirtualBoxManager::sltHandleShowTabBarGlobal);1950 m_pToolbarTools->setTabBars(m_pTabBarMachine, m_pTabBarGlobal);1951 1952 /* Create exclusive action-group: */1953 QActionGroup *pActionGroupTools = new QActionGroup(m_pToolbarTools);1954 AssertPtrReturnVoid(pActionGroupTools);1955 {1956 /* Configure action-group: */1957 pActionGroupTools->setExclusive(true);1958 1959 /* Add 'Tools' actions into action-group: */1960 pActionGroupTools->addAction(actionPool()->action(UIActionIndexST_M_Tools_T_Machine));1961 pActionGroupTools->addAction(actionPool()->action(UIActionIndexST_M_Tools_T_Global));1962 }1963 1964 /* Add into toolbar: */1965 m_pToolBar->addWidget(m_pToolbarTools);1966 }1967 1968 #ifdef VBOX_WS_MAC1969 // WORKAROUND:1970 // There is a bug in Qt Cocoa which result in showing a "more arrow" when1971 // the necessary size of the toolbar is increased. Also for some languages1972 // the with doesn't match if the text increase. So manually adjust the size1973 // after changing the text.1974 m_pToolBar->updateLayout();1975 #endif1976 }1977 }1978 1979 1597 void UIVirtualBoxManager::prepareWidgets() 1980 1598 { 1981 1599 /* Create central-widget: */ 1982 QWidget *pWidget = new QWidget;1983 AssertPtrReturnVoid(pWidget);1600 m_pWidget = new UIVirtualBoxManagerWidget(this); 1601 if (m_pWidget) 1984 1602 { 1985 1603 /* Configure central-widget: */ 1986 setCentralWidget(pWidget); 1987 1988 /* Create central-layout: */ 1989 QVBoxLayout *pLayout = new QVBoxLayout(pWidget); 1990 AssertPtrReturnVoid(pLayout); 1991 { 1992 /* Configure layout: */ 1993 pLayout->setSpacing(0); 1994 pLayout->setContentsMargins(0, 0, 0, 0); 1995 1996 #ifdef VBOX_WS_MAC 1997 /* Native toolbar on MAC: */ 1998 addToolBar(m_pToolBar); 1999 #else 2000 /* Add into layout: */ 2001 pLayout->addWidget(m_pToolBar); 2002 #endif 2003 2004 /* Create sliding-widget: */ 2005 m_pSlidingWidget = new UISlidingWidget; 2006 AssertPtrReturnVoid(m_pSlidingWidget); 2007 { 2008 /* Create splitter: */ 2009 m_pSplitter = new QISplitter; 2010 AssertPtrReturnVoid(m_pSplitter); 2011 { 2012 /* Configure splitter: */ 2013 #ifdef VBOX_WS_X11 2014 m_pSplitter->setHandleType(QISplitter::Native); 2015 #endif 2016 2017 /* Create Chooser-pane: */ 2018 m_pPaneChooser = new UIChooser(this); 2019 AssertPtrReturnVoid(m_pPaneChooser); 2020 { 2021 /* Add into splitter: */ 2022 m_pSplitter->addWidget(m_pPaneChooser); 2023 } 2024 2025 /* Create Machine Tools-pane: */ 2026 m_pPaneToolsMachine = new UIToolPaneMachine(actionPool()); 2027 AssertPtrReturnVoid(m_pPaneToolsMachine); 2028 { 2029 /* Add into splitter: */ 2030 m_pSplitter->addWidget(m_pPaneToolsMachine); 2031 } 2032 2033 /* Adjust splitter colors according to main widgets it splits: */ 2034 m_pSplitter->configureColors(m_pPaneChooser->palette().color(QPalette::Active, QPalette::Window), 2035 m_pPaneToolsMachine->palette().color(QPalette::Active, QPalette::Window)); 2036 /* Set the initial distribution. The right site is bigger. */ 2037 m_pSplitter->setStretchFactor(0, 2); 2038 m_pSplitter->setStretchFactor(1, 3); 2039 } 2040 2041 /* Create Global Tools-pane: */ 2042 m_pPaneToolsGlobal = new UIToolPaneGlobal(actionPool()); 2043 AssertPtrReturnVoid(m_pPaneToolsGlobal); 2044 2045 /* Add left/right widgets into sliding widget: */ 2046 m_pSlidingWidget->setWidgets(m_pSplitter, m_pPaneToolsGlobal); 2047 2048 /* Add into layout: */ 2049 pLayout->addWidget(m_pSlidingWidget); 2050 } 2051 } 2052 } 2053 2054 /* Bring the VM list to the focus: */ 2055 m_pPaneChooser->setFocus(); 1604 setCentralWidget(m_pWidget); 1605 } 2056 1606 } 2057 1607 … … 2060 1610 #ifdef VBOX_WS_X11 2061 1611 /* Desktop event handlers: */ 2062 connect(gpDesktop, SIGNAL(sigHostScreenWorkAreaResized(int)), this, SLOT(sltHandleHostScreenAvailableAreaChange())); 2063 #endif /* VBOX_WS_X11 */ 1612 connect(gpDesktop, &UIDesktopWidgetWatchdog::sigHostScreenWorkAreaResized, 1613 this, &UIVirtualBoxManager::sltHandleHostScreenAvailableAreaChange); 1614 #endif 2064 1615 2065 1616 /* Medium enumeration connections: */ 2066 connect(&vboxGlobal(), SIGNAL(sigMediumEnumerationFinished()), this, SLOT(sltHandleMediumEnumerationFinish())); 2067 2068 /* Menu-bar connections: */ 2069 connect(menuBar(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(sltHandleContextMenuRequest(const QPoint&))); 1617 connect(&vboxGlobal(), &VBoxGlobal::sigMediumEnumerationFinished, 1618 this, &UIVirtualBoxManager::sltHandleMediumEnumerationFinish); 1619 1620 /* Widget connections: */ 1621 connect(m_pWidget, &UIVirtualBoxManagerWidget::sigChooserPaneIndexChange, 1622 this, &UIVirtualBoxManager::sltHandleChooserPaneIndexChange); 1623 connect(m_pWidget, &UIVirtualBoxManagerWidget::sigGroupSavingStateChanged, 1624 this, &UIVirtualBoxManager::sltHandleGroupSavingProgressChange); 1625 connect(m_pWidget, &UIVirtualBoxManagerWidget::sigMachineSettingsLinkClicked, 1626 this, &UIVirtualBoxManager::sltOpenMachineSettingsDialogDefault); 1627 connect(menuBar(), &QMenuBar::customContextMenuRequested, 1628 m_pWidget, &UIVirtualBoxManagerWidget::sltHandleContextMenuRequest); 1629 1630 /* Global VBox event handlers: */ 1631 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigMachineStateChange, 1632 this, &UIVirtualBoxManager::sltHandleStateChange); 1633 connect(gVBoxEvents, &UIVirtualBoxEventHandler::sigSessionStateChange, 1634 this, &UIVirtualBoxManager::sltHandleStateChange); 2070 1635 2071 1636 /* 'File' menu connections: */ 2072 connect(actionPool()->action(UIActionIndexST_M_File_S_ShowVirtualMediumManager), SIGNAL(triggered()), this, SLOT(sltOpenVirtualMediumManagerWindow())); 2073 connect(actionPool()->action(UIActionIndexST_M_File_S_ShowHostNetworkManager), SIGNAL(triggered()), this, SLOT(sltOpenHostNetworkManagerWindow())); 2074 connect(actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance), SIGNAL(triggered()), this, SLOT(sltOpenImportApplianceWizard())); 2075 connect(actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance), SIGNAL(triggered()), this, SLOT(sltOpenExportApplianceWizard())); 1637 connect(actionPool()->action(UIActionIndexST_M_File_S_ShowVirtualMediumManager), &UIAction::triggered, 1638 this, &UIVirtualBoxManager::sltOpenVirtualMediumManagerWindow); 1639 connect(actionPool()->action(UIActionIndexST_M_File_S_ShowHostNetworkManager), &UIAction::triggered, 1640 this, &UIVirtualBoxManager::sltOpenHostNetworkManagerWindow); 1641 connect(actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance), &UIAction::triggered, 1642 this, &UIVirtualBoxManager::sltOpenImportApplianceWizardDefault); 1643 connect(actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance), &UIAction::triggered, 1644 this, &UIVirtualBoxManager::sltOpenExportApplianceWizard); 2076 1645 #ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI 2077 connect(actionPool()->action(UIActionIndexST_M_File_S_ShowExtraDataManager), SIGNAL(triggered()), this, SLOT(sltOpenExtraDataManagerWindow())); 1646 connect(actionPool()->action(UIActionIndexST_M_File_S_ShowExtraDataManager), &UIAction::triggered, 1647 this, &UIVirtualBoxManager::sltOpenExtraDataManagerWindow); 2078 1648 #endif /* VBOX_GUI_WITH_EXTRADATA_MANAGER_UI */ 2079 connect(actionPool()->action(UIActionIndex_M_Application_S_Preferences), SIGNAL(triggered()), this, SLOT(sltOpenPreferencesDialog())); 2080 connect(actionPool()->action(UIActionIndexST_M_File_S_Close), SIGNAL(triggered()), this, SLOT(sltPerformExit())); 1649 connect(actionPool()->action(UIActionIndex_M_Application_S_Preferences), &UIAction::triggered, 1650 this, &UIVirtualBoxManager::sltOpenPreferencesDialog); 1651 connect(actionPool()->action(UIActionIndexST_M_File_S_Close), &UIAction::triggered, 1652 this, &UIVirtualBoxManager::sltPerformExit); 2081 1653 2082 1654 /* 'Group' menu connections: */ 2083 connect(actionPool()->action(UIActionIndexST_M_Group_S_Add), SIGNAL(triggered()), this, SLOT(sltOpenAddMachineDialog())); 2084 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow), SIGNAL(triggered()), this, SLOT(sltPerformStartOrShowMachine())); 2085 connect(actionPool()->action(UIActionIndexST_M_Group_T_Pause), SIGNAL(toggled(bool)), this, SLOT(sltPerformPauseOrResumeMachine(bool))); 2086 connect(actionPool()->action(UIActionIndexST_M_Group_S_Reset), SIGNAL(triggered()), this, SLOT(sltPerformResetMachine())); 2087 connect(actionPool()->action(UIActionIndexST_M_Group_S_Discard), SIGNAL(triggered()), this, SLOT(sltPerformDiscardMachineState())); 2088 connect(actionPool()->action(UIActionIndexST_M_Group_S_ShowLogDialog), SIGNAL(triggered()), this, SLOT(sltOpenMachineLogDialog())); 2089 connect(actionPool()->action(UIActionIndexST_M_Group_S_ShowInFileManager), SIGNAL(triggered()), this, SLOT(sltShowMachineInFileManager())); 2090 connect(actionPool()->action(UIActionIndexST_M_Group_S_CreateShortcut), SIGNAL(triggered()), this, SLOT(sltPerformCreateMachineShortcut())); 1655 connect(actionPool()->action(UIActionIndexST_M_Group_S_Add), &UIAction::triggered, 1656 this, &UIVirtualBoxManager::sltOpenAddMachineDialogDefault); 1657 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow), &UIAction::triggered, 1658 this, &UIVirtualBoxManager::sltPerformStartOrShowMachine); 1659 connect(actionPool()->action(UIActionIndexST_M_Group_T_Pause), &UIAction::toggled, 1660 this, &UIVirtualBoxManager::sltPerformPauseOrResumeMachine); 1661 connect(actionPool()->action(UIActionIndexST_M_Group_S_Reset), &UIAction::triggered, 1662 this, &UIVirtualBoxManager::sltPerformResetMachine); 1663 connect(actionPool()->action(UIActionIndexST_M_Group_S_Discard), &UIAction::triggered, 1664 this, &UIVirtualBoxManager::sltPerformDiscardMachineState); 1665 connect(actionPool()->action(UIActionIndexST_M_Group_S_ShowLogDialog), &UIAction::triggered, 1666 this, &UIVirtualBoxManager::sltOpenMachineLogDialog); 1667 connect(actionPool()->action(UIActionIndexST_M_Group_S_ShowInFileManager), &UIAction::triggered, 1668 this, &UIVirtualBoxManager::sltShowMachineInFileManager); 1669 connect(actionPool()->action(UIActionIndexST_M_Group_S_CreateShortcut), &UIAction::triggered, 1670 this, &UIVirtualBoxManager::sltPerformCreateMachineShortcut); 2091 1671 2092 1672 /* 'Machine' menu connections: */ 2093 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Add), SIGNAL(triggered()), this, SLOT(sltOpenAddMachineDialog())); 2094 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Settings), SIGNAL(triggered()), this, SLOT(sltOpenMachineSettingsDialog())); 2095 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Clone), SIGNAL(triggered()), this, SLOT(sltOpenCloneMachineWizard())); 2096 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Move), SIGNAL(triggered()), this, SLOT(sltPerformMachineMove())); 2097 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow), SIGNAL(triggered()), this, SLOT(sltPerformStartOrShowMachine())); 2098 connect(actionPool()->action(UIActionIndexST_M_Machine_T_Pause), SIGNAL(toggled(bool)), this, SLOT(sltPerformPauseOrResumeMachine(bool))); 2099 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Reset), SIGNAL(triggered()), this, SLOT(sltPerformResetMachine())); 2100 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Discard), SIGNAL(triggered()), this, SLOT(sltPerformDiscardMachineState())); 2101 connect(actionPool()->action(UIActionIndexST_M_Machine_S_ShowLogDialog), SIGNAL(triggered()), this, SLOT(sltOpenMachineLogDialog())); 2102 connect(actionPool()->action(UIActionIndexST_M_Machine_S_ShowInFileManager), SIGNAL(triggered()), this, SLOT(sltShowMachineInFileManager())); 2103 connect(actionPool()->action(UIActionIndexST_M_Machine_S_CreateShortcut), SIGNAL(triggered()), this, SLOT(sltPerformCreateMachineShortcut())); 1673 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Add), &UIAction::triggered, 1674 this, &UIVirtualBoxManager::sltOpenAddMachineDialogDefault); 1675 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Settings), &UIAction::triggered, 1676 this, &UIVirtualBoxManager::sltOpenMachineSettingsDialogDefault); 1677 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Clone), &UIAction::triggered, 1678 this, &UIVirtualBoxManager::sltOpenCloneMachineWizard); 1679 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Move), &UIAction::triggered, 1680 this, &UIVirtualBoxManager::sltPerformMachineMove); 1681 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow), &UIAction::triggered, 1682 this, &UIVirtualBoxManager::sltPerformStartOrShowMachine); 1683 connect(actionPool()->action(UIActionIndexST_M_Machine_T_Pause), &UIAction::toggled, 1684 this, &UIVirtualBoxManager::sltPerformPauseOrResumeMachine); 1685 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Reset), &UIAction::triggered, 1686 this, &UIVirtualBoxManager::sltPerformResetMachine); 1687 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Discard), &UIAction::triggered, 1688 this, &UIVirtualBoxManager::sltPerformDiscardMachineState); 1689 connect(actionPool()->action(UIActionIndexST_M_Machine_S_ShowLogDialog), &UIAction::triggered, 1690 this, &UIVirtualBoxManager::sltOpenMachineLogDialog); 1691 connect(actionPool()->action(UIActionIndexST_M_Machine_S_ShowInFileManager), &UIAction::triggered, 1692 this, &UIVirtualBoxManager::sltShowMachineInFileManager); 1693 connect(actionPool()->action(UIActionIndexST_M_Machine_S_CreateShortcut), &UIAction::triggered, 1694 this, &UIVirtualBoxManager::sltPerformCreateMachineShortcut); 2104 1695 2105 1696 /* 'Group/Start or Show' menu connections: */ 2106 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartNormal), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineNormal())); 2107 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartHeadless), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineHeadless())); 2108 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartDetachable), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineDetachable())); 1697 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartNormal), &UIAction::triggered, 1698 this, &UIVirtualBoxManager::sltPerformStartMachineNormal); 1699 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartHeadless), &UIAction::triggered, 1700 this, &UIVirtualBoxManager::sltPerformStartMachineHeadless); 1701 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartDetachable), &UIAction::triggered, 1702 this, &UIVirtualBoxManager::sltPerformStartMachineDetachable); 2109 1703 2110 1704 /* 'Machine/Start or Show' menu connections: */ 2111 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartNormal), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineNormal())); 2112 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartHeadless), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineHeadless())); 2113 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineDetachable())); 1705 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartNormal), &UIAction::triggered, 1706 this, &UIVirtualBoxManager::sltPerformStartMachineNormal); 1707 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartHeadless), &UIAction::triggered, 1708 this, &UIVirtualBoxManager::sltPerformStartMachineHeadless); 1709 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable), &UIAction::triggered, 1710 this, &UIVirtualBoxManager::sltPerformStartMachineDetachable); 2114 1711 2115 1712 /* 'Group/Close' menu connections: */ 2116 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close)->menu(), SIGNAL(aboutToShow()), this, SLOT(sltGroupCloseMenuAboutToShow())); 2117 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Detach), SIGNAL(triggered()), this, SLOT(sltPerformDetachMachineUI())); 2118 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_SaveState), SIGNAL(triggered()), this, SLOT(sltPerformSaveMachineState())); 2119 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Shutdown), SIGNAL(triggered()), this, SLOT(sltPerformShutdownMachine())); 2120 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_PowerOff), SIGNAL(triggered()), this, SLOT(sltPerformPowerOffMachine())); 1713 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close)->menu(), &UIMenu::aboutToShow, 1714 this, &UIVirtualBoxManager::sltGroupCloseMenuAboutToShow); 1715 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Detach), &UIAction::triggered, 1716 this, &UIVirtualBoxManager::sltPerformDetachMachineUI); 1717 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_SaveState), &UIAction::triggered, 1718 this, &UIVirtualBoxManager::sltPerformSaveMachineState); 1719 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Shutdown), &UIAction::triggered, 1720 this, &UIVirtualBoxManager::sltPerformShutdownMachine); 1721 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_PowerOff), &UIAction::triggered, 1722 this, &UIVirtualBoxManager::sltPerformPowerOffMachine); 2121 1723 2122 1724 /* 'Machine/Close' menu connections: */ 2123 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close)->menu(), SIGNAL(aboutToShow()), this, SLOT(sltMachineCloseMenuAboutToShow())); 2124 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Detach), SIGNAL(triggered()), this, SLOT(sltPerformDetachMachineUI())); 2125 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_SaveState), SIGNAL(triggered()), this, SLOT(sltPerformSaveMachineState())); 2126 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Shutdown), SIGNAL(triggered()), this, SLOT(sltPerformShutdownMachine())); 2127 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_PowerOff), SIGNAL(triggered()), this, SLOT(sltPerformPowerOffMachine())); 2128 2129 /* 'Tools' actions connections: */ 2130 connect(actionPool()->action(UIActionIndexST_M_Tools_T_Machine), &UIAction::toggled, 2131 this, &UIVirtualBoxManager::sltHandleToolsTypeSwitch); 2132 connect(actionPool()->action(UIActionIndexST_M_Tools_T_Global), &UIAction::toggled, 2133 this, &UIVirtualBoxManager::sltHandleToolsTypeSwitch); 2134 2135 /* Graphics VM chooser connections: */ 2136 connect(m_pPaneChooser, SIGNAL(sigSelectionChanged()), this, SLOT(sltHandleChooserPaneIndexChange())); 2137 connect(m_pPaneChooser, SIGNAL(sigSlidingStarted()), m_pPaneToolsMachine, SIGNAL(sigSlidingStarted())); 2138 connect(m_pPaneChooser, SIGNAL(sigToggleStarted()), m_pPaneToolsMachine, SIGNAL(sigToggleStarted())); 2139 connect(m_pPaneChooser, SIGNAL(sigToggleFinished()), m_pPaneToolsMachine, SIGNAL(sigToggleFinished())); 2140 connect(m_pPaneChooser, SIGNAL(sigGroupSavingStateChanged()), this, SLOT(sltHandleGroupSavingProgressChange())); 2141 2142 /* Tool-bar connections: */ 2143 #ifndef VBOX_WS_MAC 2144 connect(m_pToolBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(sltHandleContextMenuRequest(const QPoint&))); 2145 #else /* VBOX_WS_MAC */ 2146 /* We want to receive right click notifications on the title bar, so register our own handler: */ 2147 ::darwinRegisterForUnifiedToolbarContextMenuEvents(this); 2148 #endif /* VBOX_WS_MAC */ 2149 connect(m_pToolbarTools, &UIToolbarTools::sigToolOpenedMachine, this, &UIVirtualBoxManager::sltHandleToolOpenedMachine); 2150 connect(m_pToolbarTools, &UIToolbarTools::sigToolOpenedGlobal, this, &UIVirtualBoxManager::sltHandleToolOpenedGlobal); 2151 connect(m_pToolbarTools, &UIToolbarTools::sigToolClosedMachine, this, &UIVirtualBoxManager::sltHandleToolClosedMachine); 2152 connect(m_pToolbarTools, &UIToolbarTools::sigToolClosedGlobal, this, &UIVirtualBoxManager::sltHandleToolClosedGlobal); 2153 2154 /* VM desktop connections: */ 2155 connect(m_pPaneToolsMachine, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)), 2156 this, SLOT(sltOpenMachineSettingsDialog(const QString&, const QString&, const QString&))); 2157 2158 /* Global event handlers: */ 2159 connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltHandleStateChange(QString))); 2160 connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sltHandleStateChange(QString))); 1725 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close)->menu(), &UIMenu::aboutToShow, 1726 this, &UIVirtualBoxManager::sltMachineCloseMenuAboutToShow); 1727 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Detach), &UIAction::triggered, 1728 this, &UIVirtualBoxManager::sltPerformDetachMachineUI); 1729 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_SaveState), &UIAction::triggered, 1730 this, &UIVirtualBoxManager::sltPerformSaveMachineState); 1731 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Shutdown), &UIAction::triggered, 1732 this, &UIVirtualBoxManager::sltPerformShutdownMachine); 1733 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_PowerOff), &UIAction::triggered, 1734 this, &UIVirtualBoxManager::sltPerformPowerOffMachine); 2161 1735 } 2162 1736 … … 2173 1747 restoreGeometry(); 2174 1748 } 2175 2176 /* Restore splitter handle position: */2177 {2178 /* Read splitter hints: */2179 QList<int> sizes = gEDataManager->selectorWindowSplitterHints();2180 /* If both hints are zero, we have the 'default' case: */2181 if (sizes[0] == 0 && sizes[1] == 0)2182 {2183 /* Propose some 'default' based on current dialog width: */2184 sizes[0] = (int)(width() * .9 * (1.0 / 3));2185 sizes[1] = (int)(width() * .9 * (2.0 / 3));2186 }2187 /* Pass hints to the splitter: */2188 m_pSplitter->setSizes(sizes);2189 }2190 2191 /* Restore toolbar and statusbar functionality: */2192 {2193 #ifdef VBOX_WS_MAC2194 // WORKAROUND:2195 // There is an issue in Qt5 main-window toolbar implementation:2196 // if you are hiding it before it's shown for the first time,2197 // there is an ugly empty container appears instead, so we2198 // have to hide toolbar asynchronously to avoid that.2199 if (!gEDataManager->selectorWindowToolBarVisible())2200 QMetaObject::invokeMethod(m_pToolBar, "hide", Qt::QueuedConnection);2201 #else2202 m_pToolBar->setHidden(!gEDataManager->selectorWindowToolBarVisible());2203 #endif2204 m_pToolBar->setToolButtonStyle(gEDataManager->selectorWindowToolBarTextVisible()2205 ? Qt::ToolButtonTextUnderIcon : Qt::ToolButtonIconOnly);2206 m_pToolbarTools->setToolButtonStyle(gEDataManager->selectorWindowToolBarTextVisible()2207 ? Qt::ToolButtonTextUnderIcon : Qt::ToolButtonIconOnly);2208 }2209 2210 /* Restore toolbar Machine/Global tools orders: */2211 {2212 m_orderMachine = gEDataManager->selectorWindowToolsOrderMachine();2213 m_orderGlobal = gEDataManager->selectorWindowToolsOrderGlobal();2214 2215 /* We can restore previously opened Global tools right here: */2216 QMap<ToolTypeGlobal, QAction*> mapActionsGlobal;2217 mapActionsGlobal[ToolTypeGlobal_VirtualMedia] = actionPool()->action(UIActionIndexST_M_Tools_M_Global_S_VirtualMediaManager);2218 mapActionsGlobal[ToolTypeGlobal_HostNetwork] = actionPool()->action(UIActionIndexST_M_Tools_M_Global_S_HostNetworkManager);2219 for (int i = m_orderGlobal.size() - 1; i >= 0; --i)2220 if (m_orderGlobal.at(i) != ToolTypeGlobal_Invalid)2221 mapActionsGlobal.value(m_orderGlobal.at(i))->trigger();2222 /* Make sure further action triggering cause tool type switch as well: */2223 actionPool()->action(UIActionIndexST_M_Tools_T_Global)->setProperty("watch_child_activation", true);2224 2225 /* But we can't restore previously opened Machine tools here,2226 * see the reason in corresponding async sltHandlePolishEvent slot. */2227 }2228 1749 } 2229 1750 2230 1751 void UIVirtualBoxManager::saveSettings() 2231 1752 { 2232 /* Save toolbar Machine/Global tools orders: */2233 {2234 gEDataManager->setSelectorWindowToolsOrderMachine(m_pToolbarTools->tabOrderMachine());2235 gEDataManager->setSelectorWindowToolsOrderGlobal(m_pToolbarTools->tabOrderGlobal());2236 }2237 2238 /* Save toolbar and statusbar visibility: */2239 {2240 gEDataManager->setSelectorWindowToolBarVisible(!m_pToolBar->isHidden());2241 gEDataManager->setSelectorWindowToolBarTextVisible(m_pToolBar->toolButtonStyle() == Qt::ToolButtonTextUnderIcon);2242 }2243 2244 /* Save splitter handle position: */2245 {2246 gEDataManager->setSelectorWindowSplitterHints(m_pSplitter->sizes());2247 }2248 2249 1753 /* Save window geometry: */ 2250 1754 { … … 2259 1763 } 2260 1764 2261 void UIVirtualBoxManager::cleanupConnections() 2262 { 2263 #ifdef VBOX_WS_MAC 2264 /* Tool-bar connections: */ 2265 ::darwinUnregisterForUnifiedToolbarContextMenuEvents(this); 2266 #endif /* VBOX_WS_MAC */ 1765 void UIVirtualBoxManager::cleanupWidgets() 1766 { 1767 /* Deconfigure central-widget: */ 1768 setCentralWidget(0); 1769 /* Destroy central-widget: */ 1770 delete m_pWidget; 1771 m_pWidget = 0; 2267 1772 } 2268 1773 … … 2288 1793 2289 1794 /* Cleanup: */ 2290 cleanup Connections();1795 cleanupWidgets(); 2291 1796 cleanupMenuBar(); 2292 1797 } 2293 1798 1799 UIVirtualMachineItem *UIVirtualBoxManager::currentItem() const 1800 { 1801 return m_pWidget->currentItem(); 1802 } 1803 1804 QList<UIVirtualMachineItem*> UIVirtualBoxManager::currentItems() const 1805 { 1806 return m_pWidget->currentItems(); 1807 } 1808 1809 bool UIVirtualBoxManager::isGroupSavingInProgress() const 1810 { 1811 return m_pWidget->isGroupSavingInProgress(); 1812 } 1813 1814 bool UIVirtualBoxManager::isAllItemsOfOneGroupSelected() const 1815 { 1816 return m_pWidget->isAllItemsOfOneGroupSelected(); 1817 } 1818 1819 bool UIVirtualBoxManager::isSingleGroupSelected() const 1820 { 1821 return m_pWidget->isSingleGroupSelected(); 1822 } 1823 2294 1824 void UIVirtualBoxManager::performStartOrShowVirtualMachines(const QList<UIVirtualMachineItem*> &items, VBoxGlobal::LaunchMode enmLaunchMode) 2295 1825 { 2296 1826 /* Do nothing while group saving is in progress: */ 2297 if ( m_pPaneChooser->isGroupSavingInProgress())1827 if (isGroupSavingInProgress()) 2298 1828 return; 2299 1829 … … 2342 1872 /* Determine whether Machine or Group menu should be shown at all: */ 2343 1873 const bool fMachineOrGroupMenuShown = actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->isChecked(); 2344 const bool fMachineMenuShown = ! m_pPaneChooser->isSingleGroupSelected();1874 const bool fMachineMenuShown = !isSingleGroupSelected(); 2345 1875 m_pMachineMenuAction->setVisible(fMachineOrGroupMenuShown && fMachineMenuShown); 2346 1876 m_pGroupMenuAction->setVisible(fMachineOrGroupMenuShown && !fMachineMenuShown); … … 2433 1963 actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow)->toActionPolymorphicMenu()->setState(UIVirtualMachineItem::isItemPoweredOff(pItem) ? 0 : 1); 2434 1964 actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)->toActionPolymorphicMenu()->setState(UIVirtualMachineItem::isItemPoweredOff(pItem) ? 0 : 1); 2435 QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow))); 2436 if (pButton) 2437 pButton->setPopupMode(UIVirtualMachineItem::isItemPoweredOff(pItem) ? QToolButton::MenuButtonPopup : QToolButton::DelayedPopup); 1965 /// todo Hmm, fix it? 1966 // QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow))); 1967 // if (pButton) 1968 // pButton->setPopupMode(UIVirtualMachineItem::isItemPoweredOff(pItem) ? QToolButton::MenuButtonPopup : QToolButton::DelayedPopup); 2438 1969 } 2439 1970 else … … 2441 1972 actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow)->toActionPolymorphicMenu()->setState(0); 2442 1973 actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)->toActionPolymorphicMenu()->setState(0); 2443 QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow))); 2444 if (pButton) 2445 pButton->setPopupMode(UIVirtualMachineItem::isItemPoweredOff(pItem) ? QToolButton::MenuButtonPopup : QToolButton::DelayedPopup); 1974 /// todo Hmm, fix it? 1975 // QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow))); 1976 // if (pButton) 1977 // pButton->setPopupMode(UIVirtualMachineItem::isItemPoweredOff(pItem) ? QToolButton::MenuButtonPopup : QToolButton::DelayedPopup); 2446 1978 } 2447 1979 … … 2489 2021 case UIActionIndexST_M_Group_S_Remove: 2490 2022 { 2491 return ! m_pPaneChooser->isGroupSavingInProgress() &&2023 return !isGroupSavingInProgress() && 2492 2024 isItemsPoweredOff(items); 2493 2025 } 2494 2026 case UIActionIndexST_M_Group_S_Sort: 2495 2027 { 2496 return ! m_pPaneChooser->isGroupSavingInProgress() &&2497 m_pPaneChooser->isSingleGroupSelected();2028 return !isGroupSavingInProgress() && 2029 isSingleGroupSelected(); 2498 2030 } 2499 2031 case UIActionIndexST_M_Machine_S_Settings: 2500 2032 { 2501 return ! m_pPaneChooser->isGroupSavingInProgress() &&2033 return !isGroupSavingInProgress() && 2502 2034 items.size() == 1 && 2503 2035 pItem->configurationAccessLevel() != ConfigurationAccessLevel_Null; … … 2506 2038 case UIActionIndexST_M_Machine_S_Move: 2507 2039 { 2508 return ! m_pPaneChooser->isGroupSavingInProgress() &&2040 return !isGroupSavingInProgress() && 2509 2041 items.size() == 1 && 2510 2042 UIVirtualMachineItem::isItemEditable(pItem); … … 2512 2044 case UIActionIndexST_M_Machine_S_Remove: 2513 2045 { 2514 return ! m_pPaneChooser->isGroupSavingInProgress() &&2046 return !isGroupSavingInProgress() && 2515 2047 isAtLeastOneItemRemovable(items); 2516 2048 } 2517 2049 case UIActionIndexST_M_Machine_S_AddGroup: 2518 2050 { 2519 return ! m_pPaneChooser->isGroupSavingInProgress() &&2520 ! m_pPaneChooser->isAllItemsOfOneGroupSelected() &&2051 return !isGroupSavingInProgress() && 2052 !isAllItemsOfOneGroupSelected() && 2521 2053 isItemsPoweredOff(items); 2522 2054 } … … 2530 2062 case UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable: 2531 2063 { 2532 return ! m_pPaneChooser->isGroupSavingInProgress() &&2064 return !isGroupSavingInProgress() && 2533 2065 isAtLeastOneItemCanBeStartedOrShown(items); 2534 2066 } … … 2536 2068 case UIActionIndexST_M_Machine_S_Discard: 2537 2069 { 2538 return ! m_pPaneChooser->isGroupSavingInProgress() &&2070 return !isGroupSavingInProgress() && 2539 2071 isAtLeastOneItemDiscardable(items); 2540 2072 } … … 2566 2098 case UIActionIndexST_M_Machine_S_SortParent: 2567 2099 { 2568 return ! m_pPaneChooser->isGroupSavingInProgress();2100 return !isGroupSavingInProgress(); 2569 2101 } 2570 2102 case UIActionIndexST_M_Group_S_CreateShortcut: -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h
r73457 r73492 25 25 #include "QIMainWindow.h" 26 26 #include "QIWithRetranslateUI.h" 27 #include "UIToolPaneGlobal.h"28 #include "UIToolPaneMachine.h"29 27 #include "VBoxGlobal.h" 30 28 … … 32 30 class QMenu; 33 31 class QIManagerDialog; 34 class QISplitter;35 32 class UIAction; 36 33 class UIActionPool; 37 class UIChooser; 38 class UISlidingWidget; 39 class UITabBar; 40 class UIToolBar; 41 class UIToolbarTools; 34 class UIVirtualBoxManagerWidget; 42 35 class UIVirtualMachineItem; 43 36 … … 101 94 /** @name Common stuff. 102 95 * @{ */ 103 /** Handles polishing in the async way. */104 void sltHandlePolishEvent();105 106 96 #if QT_VERSION == 0 107 97 /** Stupid moc does not warn if it cannot find headers! */ … … 112 102 #endif /* VBOX_WS_X11 */ 113 103 114 /** Handles context-menu request for passed @a position. */115 void sltHandleContextMenuRequest(const QPoint &position);116 117 /** Handles signal about Chooser-pane index change.118 * @param fUpdateDetails Brings whether details should be updated.119 * @param fUpdateSnapshots Brings whether tools should be updated. */120 void sltHandleChooserPaneIndexChange(bool fUpdateDetails = true,121 bool fUpdateSnapshots = true,122 bool fUpdateLogViewer = true);123 124 104 /** Handles signal about medium-enumeration finished. */ 125 105 void sltHandleMediumEnumerationFinish(); … … 128 108 void sltHandleOpenUrlCall(QList<QUrl> list = QList<QUrl>()); 129 109 110 /** Hnadles singal about Chooser-pane index change. */ 111 void sltHandleChooserPaneIndexChange(); 130 112 /** Handles signal about group saving progress change. */ 131 113 void sltHandleGroupSavingProgressChange(); … … 156 138 * @param strFileName can bring the name of file to import appliance from. */ 157 139 void sltOpenImportApplianceWizard(const QString &strFileName = QString()); 140 /** Handles call to open Import Appliance wizard the default way. */ 141 void sltOpenImportApplianceWizardDefault() { sltOpenImportApplianceWizard(); } 158 142 /** Handles call to open Export Appliance wizard. */ 159 143 void sltOpenExportApplianceWizard(); … … 176 160 * @param strFileName can bring the name of file to add machine from. */ 177 161 void sltOpenAddMachineDialog(const QString &strFileName = QString()); 162 /** Handles call to open Add Machine dialog the default way. */ 163 void sltOpenAddMachineDialogDefault() { sltOpenAddMachineDialog(); } 178 164 179 165 /** Handles call to open Machine Settings dialog. … … 184 170 QString strControl = QString(), 185 171 const QString &strID = QString()); 172 /** Handles call to open Machine Settings dialog the default way. */ 173 void sltOpenMachineSettingsDialogDefault() { sltOpenMachineSettingsDialog(); } 186 174 187 175 /** Handles call to open Clone Machine wizard. */ … … 233 221 /** @} */ 234 222 235 /** @name Tools stuff.236 * @{ */237 /** Handles tools type switch. */238 void sltHandleToolsTypeSwitch();239 240 /** Handles request to show Machine tab-bar. */241 void sltHandleShowTabBarMachine();242 /** Handles request to show Global tab-bar. */243 void sltHandleShowTabBarGlobal();244 245 /** Handles rquest to open Machine tool of passed @a enmType. */246 void sltHandleToolOpenedMachine(ToolTypeMachine enmType);247 /** Handles rquest to open Global tool of passed @a enmType. */248 void sltHandleToolOpenedGlobal(ToolTypeGlobal enmType);249 250 /** Handles rquest to close Machine tool of passed @a enmType. */251 void sltHandleToolClosedMachine(ToolTypeMachine enmType);252 /** Handles rquest to close Global tool of passed @a enmType. */253 void sltHandleToolClosedGlobal(ToolTypeGlobal enmType);254 /** @} */255 256 223 private: 257 258 /** Returns current-item. */259 UIVirtualMachineItem *currentItem() const;260 /** Returns a list of current-items. */261 QList<UIVirtualMachineItem*> currentItems() const;262 224 263 225 /** @name Prepare/Cleanup cascade. … … 296 258 /** Saves settings. */ 297 259 void saveSettings(); 298 /** Cleanups connections. */299 void cleanup Connections();260 /** Cleanups widgets. */ 261 void cleanupWidgets(); 300 262 /** Cleanups menu-bar. */ 301 263 void cleanupMenuBar(); 302 264 /** Cleanups window. */ 303 265 void cleanup(); 266 /** @} */ 267 268 /** @name Common stuff. 269 * @{ */ 270 /** Returns current-item. */ 271 UIVirtualMachineItem *currentItem() const; 272 /** Returns a list of current-items. */ 273 QList<UIVirtualMachineItem*> currentItems() const; 274 275 /** Returns whether group saving is in progress. */ 276 bool isGroupSavingInProgress() const; 277 /** Returns whether all items of one group is selected. */ 278 bool isAllItemsOfOneGroupSelected() const; 279 /** Returns whether single group is selected. */ 280 bool isSingleGroupSelected() const; 304 281 /** @} */ 305 282 … … 358 335 UIActionPool *m_pActionPool; 359 336 360 /** Holds the sliding-widget isntance. */361 UISlidingWidget *m_pSlidingWidget;362 363 /** Holds the central splitter instance. */364 QISplitter *m_pSplitter;365 366 /** Holds the main toolbar instance. */367 UIToolBar *m_pToolBar;368 369 /** Holds the Machine tab-bar instance. */370 UITabBar *m_pTabBarMachine;371 /** Holds the Global tab-bar instance. */372 UITabBar *m_pTabBarGlobal;373 /** Holds the Machine tab-bar action reference. */374 QAction *m_pActionTabBarMachine;375 /** Holds the Global tab-bar action reference. */376 QAction *m_pActionTabBarGlobal;377 378 /** Holds the Tools-toolbar instance. */379 UIToolbarTools *m_pToolbarTools;380 381 /** Holds the Machine Tools order. */382 QList<ToolTypeMachine> m_orderMachine;383 /** Holds the Global Tools order. */384 QList<ToolTypeGlobal> m_orderGlobal;385 386 /** Holds the Chooser-pane instance. */387 UIChooser *m_pPaneChooser;388 /** Holds the Machine Tools-pane instance. */389 UIToolPaneMachine *m_pPaneToolsMachine;390 /** Holds the Global Tools-pane instance. */391 UIToolPaneGlobal *m_pPaneToolsGlobal;392 393 337 /** Holds the list of Group menu actions. */ 394 338 QList<UIAction*> m_groupActions; … … 407 351 /** Holds a map of (machineUUID, UIVMLogViewerDialog). */ 408 352 VMLogViewerMap m_logViewers; 353 354 /** Holds the central-widget instance. */ 355 UIVirtualBoxManagerWidget *m_pWidget; 409 356 }; 410 357 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp
r73457 r73492 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIVirtualBoxManager class implementation.3 * VBox Qt GUI - UIVirtualBoxManagerWidget class implementation. 4 4 */ 5 5 … … 21 21 22 22 /* Qt includes: */ 23 # include <QMenuBar> 24 # include <QResizeEvent> 25 # include <QStandardPaths> 26 # include <QStatusBar> 27 # include <QToolButton> 28 # include <QTimer> 23 # include <QStyle> 24 # include <QVBoxLayout> 29 25 30 26 /* GUI includes: */ 31 # include "QIFileDialog.h"32 27 # include "QISplitter.h" 33 28 # include "UIActionPoolSelector.h" 34 # include "UIDesktopServices.h"35 29 # include "UIErrorString.h" 36 30 # include "UIExtraDataManager.h" 37 31 # include "UIChooser.h" 38 # include "UIHostNetworkManager.h"39 # include "UIMedium.h"40 # include "UIMediumManager.h"41 # include "UIMessageCenter.h"42 # include "UIModalWindowManager.h"43 32 # include "UIVirtualBoxManager.h" 44 # include "UI SettingsDialogSpecific.h"33 # include "UIVirtualBoxManagerWidget.h" 45 34 # include "UISlidingWidget.h" 46 35 # include "UITabBar.h" 47 36 # include "UIToolBar.h" 48 # include "UIVMLogViewerDialog.h"49 37 # include "UIVirtualMachineItem.h" 50 # include "UIToolPaneMachine.h"51 38 # include "UIToolbarTools.h" 52 # ifdef VBOX_GUI_WITH_NETWORK_MANAGER53 # include "UIUpdateManager.h"54 # endif55 # include "UIVirtualBoxEventHandler.h"56 # include "UIWizardCloneVM.h"57 # include "UIWizardExportApp.h"58 # include "UIWizardImportApp.h"59 # ifdef VBOX_WS_MAC60 # include "UIImageTools.h"61 # include "UIWindowMenuManager.h"62 # include "VBoxUtils.h"63 # endif64 # ifdef VBOX_WS_X1165 # include "UIDesktopWidgetWatchdog.h"66 # endif67 39 # ifndef VBOX_WS_MAC 68 40 # include "UIMenuBar.h" 69 41 # endif 70 42 71 /* COM includes: */72 # include "CSystemProperties.h"73 74 /* Other VBox stuff: */75 # include <iprt/buildconfig.h>76 # include <VBox/version.h>77 # ifdef VBOX_WS_X1178 # include <iprt/env.h>79 # endif /* VBOX_WS_X11 */80 81 43 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 82 44 83 45 84 /* static */ 85 UIVirtualBoxManager *UIVirtualBoxManager::s_pInstance = 0; 86 87 /* static */ 88 void UIVirtualBoxManager::create() 89 { 90 /* Make sure VirtualBox Manager isn't created: */ 91 AssertReturnVoid(s_pInstance == 0); 92 93 /* Create VirtualBox Manager: */ 94 new UIVirtualBoxManager; 95 /* Prepare VirtualBox Manager: */ 96 s_pInstance->prepare(); 97 /* Show VirtualBox Manager: */ 98 s_pInstance->show(); 99 /* Register in the modal window manager: */ 100 windowManager().setMainWindowShown(s_pInstance); 101 } 102 103 /* static */ 104 void UIVirtualBoxManager::destroy() 105 { 106 /* Make sure VirtualBox Manager is created: */ 107 AssertPtrReturnVoid(s_pInstance); 108 109 /* Unregister in the modal window manager: */ 110 windowManager().setMainWindowShown(0); 111 /* Cleanup VirtualBox Manager: */ 112 s_pInstance->cleanup(); 113 /* Destroy machine UI: */ 114 delete s_pInstance; 115 } 116 117 UIVirtualBoxManager::UIVirtualBoxManager() 46 UIVirtualBoxManagerWidget::UIVirtualBoxManagerWidget(UIVirtualBoxManager *pParent) 118 47 : m_fPolished(false) 119 , m_fFirstMediumEnumerationHandled(false) 120 , m_pActionPool(0) 48 , m_pActionPool(pParent->actionPool()) 121 49 , m_pSlidingWidget(0) 122 50 , m_pSplitter(0) … … 130 58 , m_pPaneToolsMachine(0) 131 59 , m_pPaneToolsGlobal(0) 132 , m_pGroupMenuAction(0) 133 , m_pMachineMenuAction(0) 134 , m_pManagerVirtualMedia(0) 135 , m_pManagerHostNetwork(0) 136 { 137 s_pInstance = this; 138 } 139 140 UIVirtualBoxManager::~UIVirtualBoxManager() 141 { 142 s_pInstance = 0; 143 } 144 145 bool UIVirtualBoxManager::shouldBeMaximized() const 146 { 147 return gEDataManager->selectorWindowShouldBeMaximized(); 148 } 149 150 #ifdef VBOX_WS_MAC 151 bool UIVirtualBoxManager::eventFilter(QObject *pObject, QEvent *pEvent) 152 { 153 /* Ignore for non-active window except for FileOpen event which should be always processed: */ 154 if (!isActiveWindow() && pEvent->type() != QEvent::FileOpen) 155 return QIWithRetranslateUI<QIMainWindow>::eventFilter(pObject, pEvent); 156 157 /* Ignore for other objects: */ 158 if (qobject_cast<QWidget*>(pObject) && 159 qobject_cast<QWidget*>(pObject)->window() != this) 160 return QIWithRetranslateUI<QIMainWindow>::eventFilter(pObject, pEvent); 161 162 /* Which event do we have? */ 163 switch (pEvent->type()) 164 { 165 case QEvent::FileOpen: 166 { 167 sltHandleOpenUrlCall(QList<QUrl>() << static_cast<QFileOpenEvent*>(pEvent)->url()); 168 pEvent->accept(); 169 return true; 170 break; 171 } 172 default: 173 break; 174 } 175 /* Call to base-class: */ 176 return QIWithRetranslateUI<QIMainWindow>::eventFilter(pObject, pEvent); 177 } 178 #endif /* VBOX_WS_MAC */ 179 180 void UIVirtualBoxManager::retranslateUi() 181 { 182 /* Set window title: */ 183 QString strTitle(VBOX_PRODUCT); 184 strTitle += " " + tr("Manager", "Note: main window title which is prepended by the product name."); 185 #ifdef VBOX_BLEEDING_EDGE 186 strTitle += QString(" EXPERIMENTAL build ") 187 + QString(RTBldCfgVersion()) 188 + QString(" r") 189 + QString(RTBldCfgRevisionStr()) 190 + QString(" - " VBOX_BLEEDING_EDGE); 191 #endif /* VBOX_BLEEDING_EDGE */ 192 setWindowTitle(strTitle); 193 60 { 61 prepare(); 62 } 63 64 UIVirtualBoxManagerWidget::~UIVirtualBoxManagerWidget() 65 { 66 cleanup(); 67 } 68 69 UIVirtualMachineItem *UIVirtualBoxManagerWidget::currentItem() const 70 { 71 return m_pPaneChooser->currentItem(); 72 } 73 74 QList<UIVirtualMachineItem*> UIVirtualBoxManagerWidget::currentItems() const 75 { 76 return m_pPaneChooser->currentItems(); 77 } 78 79 bool UIVirtualBoxManagerWidget::isGroupSavingInProgress() const 80 { 81 return m_pPaneChooser->isGroupSavingInProgress(); 82 } 83 84 bool UIVirtualBoxManagerWidget::isAllItemsOfOneGroupSelected() const 85 { 86 return m_pPaneChooser->isAllItemsOfOneGroupSelected(); 87 } 88 89 bool UIVirtualBoxManagerWidget::isSingleGroupSelected() const 90 { 91 return m_pPaneChooser->isSingleGroupSelected(); 92 } 93 94 bool UIVirtualBoxManagerWidget::isToolOpened(ToolTypeMachine enmType) const 95 { 96 return m_pPaneToolsMachine->isToolOpened(enmType); 97 } 98 99 bool UIVirtualBoxManagerWidget::isToolOpened(ToolTypeGlobal enmType) const 100 { 101 return m_pPaneToolsGlobal->isToolOpened(enmType); 102 } 103 104 void UIVirtualBoxManagerWidget::switchToTool(ToolTypeMachine enmType) 105 { 106 sltHandleToolOpenedMachine(enmType); 107 } 108 109 void UIVirtualBoxManagerWidget::switchToTool(ToolTypeGlobal enmType) 110 { 111 sltHandleToolOpenedGlobal(enmType); 112 } 113 114 void UIVirtualBoxManagerWidget::sltHandleContextMenuRequest(const QPoint &position) 115 { 116 /* Populate toolbar actions: */ 117 QList<QAction*> actions; 118 /* Add 'Show Toolbar Text' action: */ 119 QAction *pShowToolBarText = new QAction(tr("Show Toolbar Text"), 0); 120 AssertPtrReturnVoid(pShowToolBarText); 121 { 122 /* Configure action: */ 123 pShowToolBarText->setCheckable(true); 124 pShowToolBarText->setChecked(m_pToolBar->toolButtonStyle() == Qt::ToolButtonTextUnderIcon); 125 126 /* Add into action list: */ 127 actions << pShowToolBarText; 128 } 129 130 /* Prepare the menu position: */ 131 QPoint globalPosition = position; 132 QWidget *pSender = static_cast<QWidget*>(sender()); 133 if (pSender) 134 globalPosition = pSender->mapToGlobal(position); 135 136 /* Execute the menu: */ 137 QAction *pResult = QMenu::exec(actions, globalPosition); 138 139 /* Handle the menu execution result: */ 140 if (pResult == pShowToolBarText) 141 { 142 m_pToolBar->setToolButtonStyle( pResult->isChecked() 143 ? Qt::ToolButtonTextUnderIcon 144 : Qt::ToolButtonIconOnly); 145 m_pToolbarTools->setToolButtonStyle( pResult->isChecked() 146 ? Qt::ToolButtonTextUnderIcon 147 : Qt::ToolButtonIconOnly); 148 } 149 } 150 151 void UIVirtualBoxManagerWidget::retranslateUi() 152 { 194 153 /* Make sure chosen item fetched: */ 195 154 sltHandleChooserPaneIndexChange(false /* update details? */, false /* update snapshots? */, false /* update the logviewer? */); … … 205 164 } 206 165 207 bool UIVirtualBoxManager::event(QEvent *pEvent) 208 { 209 /* Which event do we have? */ 210 switch (pEvent->type()) 211 { 212 /* Handle every ScreenChangeInternal event to notify listeners: */ 213 case QEvent::ScreenChangeInternal: 214 { 215 emit sigWindowRemapped(); 216 break; 217 } 218 /* Handle every Resize and Move we keep track of the geometry. */ 219 case QEvent::Resize: 220 { 221 #ifdef VBOX_WS_X11 222 /* Prevent handling if fake screen detected: */ 223 if (gpDesktop->isFakeScreenDetected()) 224 break; 225 #endif /* VBOX_WS_X11 */ 226 227 if (isVisible() && (windowState() & (Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen)) == 0) 228 { 229 QResizeEvent *pResizeEvent = static_cast<QResizeEvent*>(pEvent); 230 m_geometry.setSize(pResizeEvent->size()); 231 } 232 break; 233 } 234 case QEvent::Move: 235 { 236 #ifdef VBOX_WS_X11 237 /* Prevent handling if fake screen detected: */ 238 if (gpDesktop->isFakeScreenDetected()) 239 break; 240 #endif /* VBOX_WS_X11 */ 241 242 if (isVisible() && (windowState() & (Qt::WindowMaximized | Qt::WindowMinimized | Qt::WindowFullScreen)) == 0) 243 { 244 #if defined(VBOX_WS_MAC) || defined(VBOX_WS_WIN) 245 QMoveEvent *pMoveEvent = static_cast<QMoveEvent*>(pEvent); 246 m_geometry.moveTo(pMoveEvent->pos()); 247 #else /* !VBOX_WS_MAC && !VBOX_WS_WIN */ 248 m_geometry.moveTo(geometry().x(), geometry().y()); 249 #endif /* !VBOX_WS_MAC && !VBOX_WS_WIN */ 250 } 251 break; 252 } 253 #ifdef VBOX_WS_MAC 254 case QEvent::ContextMenu: 255 { 256 /* This is the unified context menu event. Lets show the context menu. */ 257 QContextMenuEvent *pContextMenuEvent = static_cast<QContextMenuEvent*>(pEvent); 258 sltHandleContextMenuRequest(pContextMenuEvent->globalPos()); 259 /* Accept it to interrupt the chain. */ 260 pContextMenuEvent->accept(); 261 return false; 262 break; 263 } 264 #endif /* VBOX_WS_MAC */ 265 default: 266 break; 267 } 166 void UIVirtualBoxManagerWidget::showEvent(QShowEvent *pEvent) 167 { 268 168 /* Call to base-class: */ 269 return QIWithRetranslateUI<QIMainWindow>::event(pEvent); 270 } 271 272 void UIVirtualBoxManager::showEvent(QShowEvent *pEvent) 273 { 274 /* Call to base-class: */ 275 QIWithRetranslateUI<QIMainWindow>::showEvent(pEvent); 169 QIWithRetranslateUI<QWidget>::showEvent(pEvent); 276 170 277 171 /* Is polishing required? */ … … 285 179 } 286 180 287 void UIVirtualBoxManager::polishEvent(QShowEvent *) 288 { 289 /* Make sure user warned about inaccessible medium(s) 290 * even if enumeration had finished before selector window shown: */ 291 QTimer::singleShot(0, this, SLOT(sltHandleMediumEnumerationFinish())); 292 293 /* Call for async polishing: */ 181 void UIVirtualBoxManagerWidget::polishEvent(QShowEvent *) 182 { 183 /* Call for async polishing finally: */ 294 184 QMetaObject::invokeMethod(this, "sltHandlePolishEvent", Qt::QueuedConnection); 295 185 } 296 186 297 void UIVirtualBoxManager::closeEvent(QCloseEvent *pEvent) 298 { 299 /* Call to base-class: */ 300 QIWithRetranslateUI<QIMainWindow>::closeEvent(pEvent); 301 302 /* Quit application: */ 303 QApplication::quit(); 304 } 305 306 void UIVirtualBoxManager::sltHandlePolishEvent() 187 void UIVirtualBoxManagerWidget::sltHandlePolishEvent() 307 188 { 308 189 /* Get current item: */ … … 328 209 } 329 210 330 #ifdef VBOX_WS_X11 331 void UIVirtualBoxManager::sltHandleHostScreenAvailableAreaChange() 332 { 333 /* Prevent handling if fake screen detected: */ 334 if (gpDesktop->isFakeScreenDetected()) 335 return; 336 337 /* Restore the geometry cached by the window: */ 338 resize(m_geometry.size()); 339 move(m_geometry.topLeft()); 340 } 341 #endif /* VBOX_WS_X11 */ 342 343 void UIVirtualBoxManager::sltHandleContextMenuRequest(const QPoint &position) 344 { 345 /* Populate toolbar/statusbar acctions: */ 346 QList<QAction*> actions; 347 348 /* Create 'Show Toolbar' action: */ 349 QAction *pShowToolBar = new QAction(tr("Show Toolbar"), 0); 350 AssertPtrReturnVoid(pShowToolBar); 351 { 352 /* Configure action: */ 353 pShowToolBar->setCheckable(true); 354 pShowToolBar->setChecked(m_pToolBar->isVisible()); 355 356 /* Add into action list: */ 357 actions << pShowToolBar; 358 } 359 360 /* Create 'Show Toolbar Text' action: */ 361 QAction *pShowToolBarText = new QAction(tr("Show Toolbar Text"), 0); 362 AssertPtrReturnVoid(pShowToolBarText); 363 { 364 /* Configure action: */ 365 pShowToolBarText->setCheckable(true); 366 pShowToolBarText->setChecked(m_pToolBar->toolButtonStyle() == Qt::ToolButtonTextUnderIcon); 367 368 /* Add into action list: */ 369 actions << pShowToolBarText; 370 } 371 372 /* Prepare the menu position: */ 373 QPoint globalPosition = position; 374 QWidget *pSender = static_cast<QWidget*>(sender()); 375 if (pSender) 376 globalPosition = pSender->mapToGlobal(position); 377 QAction *pResult = QMenu::exec(actions, globalPosition); 378 if (pResult == pShowToolBar) 379 { 380 if (pResult->isChecked()) 381 m_pToolBar->show(); 382 else 383 m_pToolBar->hide(); 384 } 385 else if (pResult == pShowToolBarText) 386 { 387 m_pToolBar->setToolButtonStyle( pResult->isChecked() 388 ? Qt::ToolButtonTextUnderIcon 389 : Qt::ToolButtonIconOnly); 390 m_pToolbarTools->setToolButtonStyle( pResult->isChecked() 391 ? Qt::ToolButtonTextUnderIcon 392 : Qt::ToolButtonIconOnly); 393 } 394 } 395 396 void UIVirtualBoxManager::sltHandleChooserPaneIndexChange(bool fUpdateDetails /* = true */, 397 bool fUpdateSnapshots /* = true */, 398 bool fUpdateLogViewer /* = true */) 399 { 211 void UIVirtualBoxManagerWidget::sltHandleChooserPaneIndexChange(bool fUpdateDetails /* = true */, 212 bool fUpdateSnapshots /* = true */, 213 bool fUpdateLogViewer /* = true */) 214 { 215 /* Let the parent know: */ 216 emit sigChooserPaneIndexChange(); 217 400 218 /* Get current item: */ 401 219 UIVirtualMachineItem *pItem = currentItem(); 402 403 /* Update action visibility: */404 updateActionsVisibility();405 /* Update action appearance: */406 updateActionsAppearance();407 220 408 221 /* Update Tools-pane: */ … … 458 271 } 459 272 460 void UIVirtualBoxManager::sltHandleMediumEnumerationFinish() 461 { 462 /* To avoid annoying the user, we check for inaccessible mediums just once, after 463 * the first media emumeration [started from main() at startup] is complete. */ 464 if (m_fFirstMediumEnumerationHandled) 465 return; 466 m_fFirstMediumEnumerationHandled = true; 467 468 /* Make sure MM window/tool is not opened, 469 * otherwise user sees everything himself: */ 470 if ( m_pManagerVirtualMedia 471 || m_pPaneToolsGlobal->isToolOpened(ToolTypeGlobal_VirtualMedia)) 472 return; 473 474 /* Look for at least one inaccessible medium: */ 475 bool fIsThereAnyInaccessibleMedium = false; 476 foreach (const QString &strMediumID, vboxGlobal().mediumIDs()) 477 { 478 if (vboxGlobal().medium(strMediumID).state() == KMediumState_Inaccessible) 479 { 480 fIsThereAnyInaccessibleMedium = true; 481 break; 482 } 483 } 484 485 /* Warn the user about inaccessible medium, propose to open MM window/tool: */ 486 if (fIsThereAnyInaccessibleMedium && !msgCenter().warnAboutInaccessibleMedia()) 487 { 488 /* Open the MM window: */ 489 sltOpenVirtualMediumManagerWindow(); 490 } 491 } 492 493 void UIVirtualBoxManager::sltHandleOpenUrlCall(QList<QUrl> list /* = QList<QUrl>() */) 494 { 495 /* If passed list is empty: */ 496 if (list.isEmpty()) 497 { 498 /* We take the one which stored in VBoxGlobal: */ 499 list = vboxGlobal().argUrlList(); 500 vboxGlobal().argUrlList().clear(); 501 /// @todo Rework this getter to do .clear() as well. 502 } 503 504 /* Check if we are can handle the dropped urls: */ 505 for (int i = 0; i < list.size(); ++i) 506 { 507 #ifdef VBOX_WS_MAC 508 const QString strFile = ::darwinResolveAlias(list.at(i).toLocalFile()); 509 #else 510 const QString strFile = list.at(i).toLocalFile(); 511 #endif 512 /* If there is such file exists: */ 513 if (!strFile.isEmpty() && QFile::exists(strFile)) 514 { 515 /* And has allowed VBox config file extension: */ 516 if (VBoxGlobal::hasAllowedExtension(strFile, VBoxFileExts)) 517 { 518 /* Handle VBox config file: */ 519 CVirtualBox comVBox = vboxGlobal().virtualBox(); 520 CMachine comMachine = comVBox.FindMachine(strFile); 521 if (comVBox.isOk() && comMachine.isNotNull()) 522 vboxGlobal().launchMachine(comMachine); 523 else 524 sltOpenAddMachineDialog(strFile); 525 } 526 /* And has allowed VBox OVF file extension: */ 527 else if (VBoxGlobal::hasAllowedExtension(strFile, OVFFileExts)) 528 { 529 /* Allow only one file at the time: */ 530 sltOpenImportApplianceWizard(strFile); 531 break; 532 } 533 /* And has allowed VBox extension pack file extension: */ 534 else if (VBoxGlobal::hasAllowedExtension(strFile, VBoxExtPackFileExts)) 535 { 536 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 537 /* Prevent update manager from proposing us to update EP: */ 538 gUpdateManager->setEPInstallationRequested(true); 539 #endif 540 /* Propose the user to install EP described by the arguments @a list. */ 541 vboxGlobal().doExtPackInstallation(strFile, QString(), this, NULL); 542 #ifdef VBOX_GUI_WITH_NETWORK_MANAGER 543 /* Allow update manager to propose us to update EP: */ 544 gUpdateManager->setEPInstallationRequested(false); 545 #endif 546 } 547 } 548 } 549 } 550 551 void UIVirtualBoxManager::sltHandleGroupSavingProgressChange() 552 { 553 updateActionsAppearance(); 554 } 555 556 void UIVirtualBoxManager::sltHandleStateChange(const QString &) 557 { 558 /* Get current item: */ 559 UIVirtualMachineItem *pItem = currentItem(); 560 561 /* Make sure current item present: */ 562 if (!pItem) 563 return; 564 565 /* Update actions: */ 566 updateActionsAppearance(); 567 } 568 569 void UIVirtualBoxManager::sltOpenVirtualMediumManagerWindow() 570 { 571 /* First check if instance of widget opened the embedded way: */ 572 if (m_pPaneToolsGlobal->isToolOpened(ToolTypeGlobal_VirtualMedia)) 573 { 574 sltHandleToolOpenedGlobal(ToolTypeGlobal_VirtualMedia); 575 return; 576 } 577 578 /* Create instance if not yet created: */ 579 if (!m_pManagerVirtualMedia) 580 { 581 UIMediumManagerFactory().prepare(m_pManagerVirtualMedia, this); 582 connect(m_pManagerVirtualMedia, &QIManagerDialog::sigClose, 583 this, &UIVirtualBoxManager::sltCloseVirtualMediumManagerWindow); 584 } 585 586 /* Show instance: */ 587 m_pManagerVirtualMedia->show(); 588 m_pManagerVirtualMedia->setWindowState(m_pManagerVirtualMedia->windowState() & ~Qt::WindowMinimized); 589 m_pManagerVirtualMedia->activateWindow(); 590 } 591 592 void UIVirtualBoxManager::sltCloseVirtualMediumManagerWindow() 593 { 594 /* Destroy instance if still exists: */ 595 if (m_pManagerVirtualMedia) 596 UIMediumManagerFactory().cleanup(m_pManagerVirtualMedia); 597 } 598 599 void UIVirtualBoxManager::sltOpenHostNetworkManagerWindow() 600 { 601 /* First check if instance of widget opened the embedded way: */ 602 if (m_pPaneToolsGlobal->isToolOpened(ToolTypeGlobal_HostNetwork)) 603 { 604 sltHandleToolOpenedGlobal(ToolTypeGlobal_HostNetwork); 605 return; 606 } 607 608 /* Create instance if not yet created: */ 609 if (!m_pManagerHostNetwork) 610 { 611 UIHostNetworkManagerFactory().prepare(m_pManagerHostNetwork, this); 612 connect(m_pManagerHostNetwork, &QIManagerDialog::sigClose, 613 this, &UIVirtualBoxManager::sltCloseHostNetworkManagerWindow); 614 } 615 616 /* Show instance: */ 617 m_pManagerHostNetwork->show(); 618 m_pManagerHostNetwork->setWindowState(m_pManagerHostNetwork->windowState() & ~Qt::WindowMinimized); 619 m_pManagerHostNetwork->activateWindow(); 620 } 621 622 void UIVirtualBoxManager::sltCloseHostNetworkManagerWindow() 623 { 624 /* Destroy instance if still exists: */ 625 if (m_pManagerHostNetwork) 626 UIHostNetworkManagerFactory().cleanup(m_pManagerHostNetwork); 627 } 628 629 void UIVirtualBoxManager::sltOpenImportApplianceWizard(const QString &strFileName /* = QString() */) 630 { 631 /* Initialize variables: */ 632 #ifdef VBOX_WS_MAC 633 const QString strTmpFile = ::darwinResolveAlias(strFileName); 634 #else 635 const QString strTmpFile = strFileName; 636 #endif 637 638 /* Lock the action preventing cascade calls: */ 639 actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance)->setEnabled(false); 640 641 /* Use the "safe way" to open stack of Mac OS X Sheets: */ 642 QWidget *pWizardParent = windowManager().realParentWindow(this); 643 UISafePointerWizardImportApp pWizard = new UIWizardImportApp(pWizardParent, strTmpFile); 644 windowManager().registerNewParent(pWizard, pWizardParent); 645 pWizard->prepare(); 646 if (strFileName.isEmpty() || pWizard->isValid()) 647 pWizard->exec(); 648 delete pWizard; 649 650 /// @todo Is it possible at all if event-loop unwind? 651 /* Unlock the action allowing further calls: */ 652 actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance)->setEnabled(true); 653 } 654 655 void UIVirtualBoxManager::sltOpenExportApplianceWizard() 656 { 657 /* Get selected items: */ 658 QList<UIVirtualMachineItem*> items = currentItems(); 659 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 660 661 /* Populate the list of VM names: */ 662 QStringList names; 663 for (int i = 0; i < items.size(); ++i) 664 names << items.at(i)->name(); 665 666 /* Lock the action preventing cascade calls: */ 667 actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance)->setEnabled(false); 668 669 /* Use the "safe way" to open stack of Mac OS X Sheets: */ 670 QWidget *pWizardParent = windowManager().realParentWindow(this); 671 UISafePointerWizard pWizard = new UIWizardExportApp(pWizardParent, names); 672 windowManager().registerNewParent(pWizard, pWizardParent); 673 pWizard->prepare(); 674 pWizard->exec(); 675 delete pWizard; 676 677 /// @todo Is it possible at all if event-loop unwind? 678 /* Unlock the action allowing further calls: */ 679 actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance)->setEnabled(true); 680 } 681 682 #ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI 683 void UIVirtualBoxManager::sltOpenExtraDataManagerWindow() 684 { 685 gEDataManager->openWindow(this); 686 } 687 #endif /* VBOX_GUI_WITH_EXTRADATA_MANAGER_UI */ 688 689 void UIVirtualBoxManager::sltOpenPreferencesDialog() 690 { 691 /* Remember that we handling that already: */ 692 actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setEnabled(false); 693 694 /* Don't show the inaccessible warning 695 * if the user tries to open global settings: */ 696 m_fFirstMediumEnumerationHandled = true; 697 698 /* Create and execute global settings window: */ 699 QPointer<UISettingsDialogGlobal> pDlg = new UISettingsDialogGlobal(this); 700 pDlg->execute(); 701 delete pDlg; 702 703 /// @todo Is it possible at all if event-loop unwind? 704 /* Remember that we do NOT handling that already: */ 705 actionPool()->action(UIActionIndex_M_Application_S_Preferences)->setEnabled(true); 706 } 707 708 void UIVirtualBoxManager::sltPerformExit() 709 { 710 close(); 711 } 712 713 void UIVirtualBoxManager::sltOpenAddMachineDialog(const QString &strFileName /* = QString() */) 714 { 715 /* Initialize variables: */ 716 #ifdef VBOX_WS_MAC 717 QString strTmpFile = ::darwinResolveAlias(strFileName); 718 #else 719 QString strTmpFile = strFileName; 720 #endif 721 CVirtualBox comVBox = vboxGlobal().virtualBox(); 722 723 /* No file specified: */ 724 if (strTmpFile.isEmpty()) 725 { 726 QString strBaseFolder = comVBox.GetSystemProperties().GetDefaultMachineFolder(); 727 QString strTitle = tr("Select a virtual machine file"); 728 QStringList extensions; 729 for (int i = 0; i < VBoxFileExts.size(); ++i) 730 extensions << QString("*.%1").arg(VBoxFileExts[i]); 731 QString strFilter = tr("Virtual machine files (%1)").arg(extensions.join(" ")); 732 /* Create open file dialog: */ 733 QStringList fileNames = QIFileDialog::getOpenFileNames(strBaseFolder, strFilter, this, strTitle, 0, true, true); 734 if (!fileNames.isEmpty()) 735 strTmpFile = fileNames.at(0); 736 } 737 /* Nothing was chosen? */ 738 if (strTmpFile.isEmpty()) 739 return; 740 741 /* Make sure this machine can be opened: */ 742 CMachine comMachineNew = comVBox.OpenMachine(strTmpFile); 743 if (!comVBox.isOk()) 744 { 745 msgCenter().cannotOpenMachine(comVBox, strTmpFile); 746 return; 747 } 748 749 /* Make sure this machine was NOT registered already: */ 750 CMachine comMachineOld = comVBox.FindMachine(comMachineNew.GetId()); 751 if (!comMachineOld.isNull()) 752 { 753 msgCenter().cannotReregisterExistingMachine(strTmpFile, comMachineOld.GetName()); 754 return; 755 } 756 757 /* Register that machine: */ 758 comVBox.RegisterMachine(comMachineNew); 759 } 760 761 void UIVirtualBoxManager::sltOpenMachineSettingsDialog(QString strCategory /* = QString() */, 762 QString strControl /* = QString() */, 763 const QString &strID /* = QString() */) 764 { 765 /* Get current item: */ 766 UIVirtualMachineItem *pItem = currentItem(); 767 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 768 769 /* Lock the action preventing cascade calls: */ 770 actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setEnabled(false); 771 772 /* Process href from VM details / description: */ 773 if (!strCategory.isEmpty() && strCategory[0] != '#') 774 { 775 vboxGlobal().openURL(strCategory); 776 } 777 else 778 { 779 /* Check if control is coded into the URL by %%: */ 780 if (strControl.isEmpty()) 781 { 782 QStringList parts = strCategory.split("%%"); 783 if (parts.size() == 2) 784 { 785 strCategory = parts.at(0); 786 strControl = parts.at(1); 787 } 788 } 789 790 /* Don't show the inaccessible warning 791 * if the user tries to open VM settings: */ 792 m_fFirstMediumEnumerationHandled = true; 793 794 /* Create and execute corresponding VM settings window: */ 795 QPointer<UISettingsDialogMachine> pDlg = new UISettingsDialogMachine(this, 796 QUuid(strID).isNull() ? pItem->id() : strID, 797 strCategory, strControl); 798 pDlg->execute(); 799 delete pDlg; 800 } 801 802 /// @todo Is it possible at all if event-loop unwind? 803 /* Unlock the action allowing further calls: */ 804 actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setEnabled(true); 805 } 806 807 void UIVirtualBoxManager::sltOpenCloneMachineWizard() 808 { 809 /* Get current item: */ 810 UIVirtualMachineItem *pItem = currentItem(); 811 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 812 813 /* Lock the action preventing cascade calls: */ 814 actionPool()->action(UIActionIndexST_M_Machine_S_Clone)->setEnabled(false); 815 816 /* Use the "safe way" to open stack of Mac OS X Sheets: */ 817 QWidget *pWizardParent = windowManager().realParentWindow(this); 818 const QStringList &machineGroupNames = pItem->groups(); 819 const QString strGroup = !machineGroupNames.isEmpty() ? machineGroupNames.at(0) : QString(); 820 UISafePointerWizard pWizard = new UIWizardCloneVM(pWizardParent, pItem->machine(), strGroup); 821 windowManager().registerNewParent(pWizard, pWizardParent); 822 pWizard->prepare(); 823 pWizard->exec(); 824 delete pWizard; 825 826 /// @todo Is it possible at all if event-loop unwind? 827 /* Unlock the action allowing further calls: */ 828 actionPool()->action(UIActionIndexST_M_Machine_S_Clone)->setEnabled(true); 829 } 830 831 void UIVirtualBoxManager::sltPerformMachineMove() 832 { 833 /* Get current item: */ 834 UIVirtualMachineItem *pItem = currentItem(); 835 AssertMsgReturnVoid(pItem, ("Current item should be selected!\n")); 836 837 /* Open a session thru which we will modify the machine: */ 838 CSession comSession = vboxGlobal().openSession(pItem->id(), KLockType_Write); 839 if (comSession.isNull()) 840 return; 841 842 /* Get session machine: */ 843 CMachine comMachine = comSession.GetMachine(); 844 AssertMsgReturnVoid(comSession.isOk() && comMachine.isNotNull(), ("Unable to acquire machine!\n")); 845 846 /* Open a file dialog for the user to select a destination folder. Start with the default machine folder: */ 847 CVirtualBox comVBox = vboxGlobal().virtualBox(); 848 QString strBaseFolder = comVBox.GetSystemProperties().GetDefaultMachineFolder(); 849 QString strTitle = tr("Select a destination folder to move the selected virtual machine"); 850 QString strDestinationFolder = QIFileDialog::getExistingDirectory(strBaseFolder, this, strTitle); 851 if (!strDestinationFolder.isEmpty()) 852 { 853 /* Prepare machine move progress: */ 854 CProgress comProgress = comMachine.MoveTo(strDestinationFolder, "basic"); 855 if (comMachine.isOk() && comProgress.isNotNull()) 856 { 857 /* Show machine move progress: */ 858 msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_clone_90px.png"); 859 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 860 msgCenter().cannotMoveMachine(comProgress, comMachine.GetName()); 861 } 862 else 863 msgCenter().cannotMoveMachine(comMachine); 864 } 865 comSession.UnlockMachine(); 866 } 867 868 void UIVirtualBoxManager::sltPerformStartOrShowMachine() 869 { 870 /* Start selected VMs in corresponding mode: */ 871 QList<UIVirtualMachineItem*> items = currentItems(); 872 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 873 performStartOrShowVirtualMachines(items, VBoxGlobal::LaunchMode_Invalid); 874 } 875 876 void UIVirtualBoxManager::sltPerformStartMachineNormal() 877 { 878 /* Start selected VMs in corresponding mode: */ 879 QList<UIVirtualMachineItem*> items = currentItems(); 880 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 881 performStartOrShowVirtualMachines(items, VBoxGlobal::LaunchMode_Default); 882 } 883 884 void UIVirtualBoxManager::sltPerformStartMachineHeadless() 885 { 886 /* Start selected VMs in corresponding mode: */ 887 QList<UIVirtualMachineItem*> items = currentItems(); 888 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 889 performStartOrShowVirtualMachines(items, VBoxGlobal::LaunchMode_Headless); 890 } 891 892 void UIVirtualBoxManager::sltPerformStartMachineDetachable() 893 { 894 /* Start selected VMs in corresponding mode: */ 895 QList<UIVirtualMachineItem*> items = currentItems(); 896 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 897 performStartOrShowVirtualMachines(items, VBoxGlobal::LaunchMode_Separate); 898 } 899 900 void UIVirtualBoxManager::sltPerformDiscardMachineState() 901 { 902 /* Get selected items: */ 903 QList<UIVirtualMachineItem*> items = currentItems(); 904 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 905 906 /* Prepare the list of the machines to be discarded: */ 907 QStringList machineNames; 908 QList<UIVirtualMachineItem*> itemsToDiscard; 909 foreach (UIVirtualMachineItem *pItem, items) 910 { 911 if (isActionEnabled(UIActionIndexST_M_Group_S_Discard, QList<UIVirtualMachineItem*>() << pItem)) 912 { 913 machineNames << pItem->name(); 914 itemsToDiscard << pItem; 915 } 916 } 917 AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!")); 918 919 /* Confirm discarding saved VM state: */ 920 if (!msgCenter().confirmDiscardSavedState(machineNames.join(", "))) 921 return; 922 923 /* For every confirmed item: */ 924 foreach (UIVirtualMachineItem *pItem, itemsToDiscard) 925 { 926 /* Open a session to modify VM: */ 927 CSession comSession = vboxGlobal().openSession(pItem->id()); 928 if (comSession.isNull()) 929 return; 930 931 /* Get session machine: */ 932 CMachine comMachine = comSession.GetMachine(); 933 comMachine.DiscardSavedState(true); 934 if (!comMachine.isOk()) 935 msgCenter().cannotDiscardSavedState(comMachine); 936 937 /* Unlock machine finally: */ 938 comSession.UnlockMachine(); 939 } 940 } 941 942 void UIVirtualBoxManager::sltPerformPauseOrResumeMachine(bool fPause) 943 { 944 /* Get selected items: */ 945 QList<UIVirtualMachineItem*> items = currentItems(); 946 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 947 948 /* For every selected item: */ 949 foreach (UIVirtualMachineItem *pItem, items) 950 { 951 /* Get item state: */ 952 const KMachineState enmState = pItem->machineState(); 953 954 /* Check if current item could be paused/resumed: */ 955 if (!isActionEnabled(UIActionIndexST_M_Group_T_Pause, QList<UIVirtualMachineItem*>() << pItem)) 956 continue; 957 958 /* Check if current item already paused: */ 959 if (fPause && 960 (enmState == KMachineState_Paused || 961 enmState == KMachineState_TeleportingPausedVM)) 962 continue; 963 964 /* Check if current item already resumed: */ 965 if (!fPause && 966 (enmState == KMachineState_Running || 967 enmState == KMachineState_Teleporting || 968 enmState == KMachineState_LiveSnapshotting)) 969 continue; 970 971 /* Open a session to modify VM state: */ 972 CSession comSession = vboxGlobal().openExistingSession(pItem->id()); 973 if (comSession.isNull()) 974 return; 975 976 /* Get session console: */ 977 CConsole comConsole = comSession.GetConsole(); 978 /* Pause/resume VM: */ 979 if (fPause) 980 comConsole.Pause(); 981 else 982 comConsole.Resume(); 983 if (!comConsole.isOk()) 984 { 985 if (fPause) 986 msgCenter().cannotPauseMachine(comConsole); 987 else 988 msgCenter().cannotResumeMachine(comConsole); 989 } 990 991 /* Unlock machine finally: */ 992 comSession.UnlockMachine(); 993 } 994 } 995 996 void UIVirtualBoxManager::sltPerformResetMachine() 997 { 998 /* Get selected items: */ 999 QList<UIVirtualMachineItem*> items = currentItems(); 1000 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1001 1002 /* Prepare the list of the machines to be reseted: */ 1003 QStringList machineNames; 1004 QList<UIVirtualMachineItem*> itemsToReset; 1005 foreach (UIVirtualMachineItem *pItem, items) 1006 { 1007 if (isActionEnabled(UIActionIndexST_M_Group_S_Reset, QList<UIVirtualMachineItem*>() << pItem)) 1008 { 1009 machineNames << pItem->name(); 1010 itemsToReset << pItem; 1011 } 1012 } 1013 AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!")); 1014 1015 /* Confirm reseting VM: */ 1016 if (!msgCenter().confirmResetMachine(machineNames.join(", "))) 1017 return; 1018 1019 /* For each selected item: */ 1020 foreach (UIVirtualMachineItem *pItem, itemsToReset) 1021 { 1022 /* Open a session to modify VM state: */ 1023 CSession comSession = vboxGlobal().openExistingSession(pItem->id()); 1024 if (comSession.isNull()) 1025 return; 1026 1027 /* Get session console: */ 1028 CConsole comConsole = comSession.GetConsole(); 1029 /* Reset VM: */ 1030 comConsole.Reset(); 1031 1032 /* Unlock machine finally: */ 1033 comSession.UnlockMachine(); 1034 } 1035 } 1036 1037 void UIVirtualBoxManager::sltPerformDetachMachineUI() 1038 { 1039 /* Get selected items: */ 1040 QList<UIVirtualMachineItem*> items = currentItems(); 1041 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1042 1043 /* For each selected item: */ 1044 foreach (UIVirtualMachineItem *pItem, items) 1045 { 1046 /* Check if current item could be detached: */ 1047 if (!isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_Detach, QList<UIVirtualMachineItem*>() << pItem)) 1048 continue; 1049 1050 /// @todo Detach separate UI process.. 1051 AssertFailed(); 1052 } 1053 } 1054 1055 void UIVirtualBoxManager::sltPerformSaveMachineState() 1056 { 1057 /* Get selected items: */ 1058 QList<UIVirtualMachineItem*> items = currentItems(); 1059 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1060 1061 /* For each selected item: */ 1062 foreach (UIVirtualMachineItem *pItem, items) 1063 { 1064 /* Check if current item could be saved: */ 1065 if (!isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_SaveState, QList<UIVirtualMachineItem*>() << pItem)) 1066 continue; 1067 1068 /* Open a session to modify VM state: */ 1069 CSession comSession = vboxGlobal().openExistingSession(pItem->id()); 1070 if (comSession.isNull()) 1071 return; 1072 1073 /* Get session console: */ 1074 CConsole comConsole = comSession.GetConsole(); 1075 /* Get session machine: */ 1076 CMachine comMachine = comSession.GetMachine(); 1077 /* Pause VM first if necessary: */ 1078 if (pItem->machineState() != KMachineState_Paused) 1079 comConsole.Pause(); 1080 if (comConsole.isOk()) 1081 { 1082 /* Prepare machine state saving progress: */ 1083 CProgress comProgress = comMachine.SaveState(); 1084 if (comMachine.isOk()) 1085 { 1086 /* Show machine state saving progress: */ 1087 msgCenter().showModalProgressDialog(comProgress, comMachine.GetName(), ":/progress_state_save_90px.png"); 1088 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1089 msgCenter().cannotSaveMachineState(comProgress, comMachine.GetName()); 1090 } 1091 else 1092 msgCenter().cannotSaveMachineState(comMachine); 1093 } 1094 else 1095 msgCenter().cannotPauseMachine(comConsole); 1096 1097 /* Unlock machine finally: */ 1098 comSession.UnlockMachine(); 1099 } 1100 } 1101 1102 void UIVirtualBoxManager::sltPerformShutdownMachine() 1103 { 1104 /* Get selected items: */ 1105 QList<UIVirtualMachineItem*> items = currentItems(); 1106 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1107 1108 /* Prepare the list of the machines to be shutdowned: */ 1109 QStringList machineNames; 1110 QList<UIVirtualMachineItem*> itemsToShutdown; 1111 foreach (UIVirtualMachineItem *pItem, items) 1112 { 1113 if (isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_Shutdown, QList<UIVirtualMachineItem*>() << pItem)) 1114 { 1115 machineNames << pItem->name(); 1116 itemsToShutdown << pItem; 1117 } 1118 } 1119 AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!")); 1120 1121 /* Confirm ACPI shutdown current VM: */ 1122 if (!msgCenter().confirmACPIShutdownMachine(machineNames.join(", "))) 1123 return; 1124 1125 /* For each selected item: */ 1126 foreach (UIVirtualMachineItem *pItem, itemsToShutdown) 1127 { 1128 /* Open a session to modify VM state: */ 1129 CSession comSession = vboxGlobal().openExistingSession(pItem->id()); 1130 if (comSession.isNull()) 1131 return; 1132 1133 /* Get session console: */ 1134 CConsole comConsole = comSession.GetConsole(); 1135 /* ACPI Shutdown: */ 1136 comConsole.PowerButton(); 1137 if (!comConsole.isOk()) 1138 msgCenter().cannotACPIShutdownMachine(comConsole); 1139 1140 /* Unlock machine finally: */ 1141 comSession.UnlockMachine(); 1142 } 1143 } 1144 1145 void UIVirtualBoxManager::sltPerformPowerOffMachine() 1146 { 1147 /* Get selected items: */ 1148 QList<UIVirtualMachineItem*> items = currentItems(); 1149 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1150 1151 /* Prepare the list of the machines to be powered off: */ 1152 QStringList machineNames; 1153 QList<UIVirtualMachineItem*> itemsToPowerOff; 1154 foreach (UIVirtualMachineItem *pItem, items) 1155 { 1156 if (isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_PowerOff, QList<UIVirtualMachineItem*>() << pItem)) 1157 { 1158 machineNames << pItem->name(); 1159 itemsToPowerOff << pItem; 1160 } 1161 } 1162 AssertMsg(!machineNames.isEmpty(), ("This action should not be allowed!")); 1163 1164 /* Confirm Power Off current VM: */ 1165 if (!msgCenter().confirmPowerOffMachine(machineNames.join(", "))) 1166 return; 1167 1168 /* For each selected item: */ 1169 foreach (UIVirtualMachineItem *pItem, itemsToPowerOff) 1170 { 1171 /* Open a session to modify VM state: */ 1172 CSession comSession = vboxGlobal().openExistingSession(pItem->id()); 1173 if (comSession.isNull()) 1174 return; 1175 1176 /* Get session console: */ 1177 CConsole comConsole = comSession.GetConsole(); 1178 /* Prepare machine power down: */ 1179 CProgress comProgress = comConsole.PowerDown(); 1180 if (comConsole.isOk()) 1181 { 1182 /* Show machine power down progress: */ 1183 CMachine machine = comSession.GetMachine(); 1184 msgCenter().showModalProgressDialog(comProgress, machine.GetName(), ":/progress_poweroff_90px.png"); 1185 if (!comProgress.isOk() || comProgress.GetResultCode() != 0) 1186 msgCenter().cannotPowerDownMachine(comProgress, machine.GetName()); 1187 } 1188 else 1189 msgCenter().cannotPowerDownMachine(comConsole); 1190 1191 /* Unlock machine finally: */ 1192 comSession.UnlockMachine(); 1193 } 1194 } 1195 1196 void UIVirtualBoxManager::sltOpenMachineLogDialog() 1197 { 1198 /* Get selected items: */ 1199 QList<UIVirtualMachineItem*> items = currentItems(); 1200 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1201 1202 /* First check if a logviewer is already opened in embedded mode: */ 1203 if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_LogViewer)) 1204 { 1205 sltHandleToolOpenedMachine(ToolTypeMachine_LogViewer); 1206 return; 1207 } 1208 1209 /* For each selected item: */ 1210 foreach (UIVirtualMachineItem *pItem, items) 1211 { 1212 /* Check if log could be show for the current item: */ 1213 if (!isActionEnabled(UIActionIndexST_M_Group_S_ShowLogDialog, QList<UIVirtualMachineItem*>() << pItem)) 1214 continue; 1215 1216 QIManagerDialog *pLogViewerDialog = 0; 1217 /* Create and Show VM Log Viewer: */ 1218 if (!m_logViewers[pItem->machine().GetHardwareUUID()]) 1219 { 1220 UIVMLogViewerDialogFactory dialogFactory(pItem->machine()); 1221 dialogFactory.prepare(pLogViewerDialog, this); 1222 if (pLogViewerDialog) 1223 { 1224 m_logViewers[pItem->machine().GetHardwareUUID()] = pLogViewerDialog; 1225 connect(pLogViewerDialog, &QIManagerDialog::sigClose, 1226 this, &UIVirtualBoxManager::sltCloseLogViewerWindow); 1227 } 1228 } 1229 else 1230 { 1231 pLogViewerDialog = m_logViewers[pItem->machine().GetHardwareUUID()]; 1232 } 1233 if (pLogViewerDialog) 1234 { 1235 /* Show instance: */ 1236 pLogViewerDialog->show(); 1237 pLogViewerDialog->setWindowState(pLogViewerDialog->windowState() & ~Qt::WindowMinimized); 1238 pLogViewerDialog->activateWindow(); 1239 } 1240 } 1241 } 1242 1243 void UIVirtualBoxManager::sltCloseLogViewerWindow() 1244 { 1245 /* Search for the sender of the signal within the m_logViewers map: */ 1246 QMap<QString, QIManagerDialog*>::iterator sendersIterator = m_logViewers.begin(); 1247 while (sendersIterator != m_logViewers.end() && sendersIterator.value() != sender()) 1248 ++sendersIterator; 1249 /* Do nothing if we cannot find it with the map: */ 1250 if (sendersIterator == m_logViewers.end()) 1251 return; 1252 1253 /* Check whether we have found the proper dialog: */ 1254 QIManagerDialog *pDialog = qobject_cast<QIManagerDialog*>(sendersIterator.value()); 1255 if (!pDialog) 1256 return; 1257 1258 /* First remove this log-viewer dialog from the map. 1259 * This should be done before closing the dialog which will incur 1260 * a second call to this function and result in double delete!!!: */ 1261 m_logViewers.erase(sendersIterator); 1262 UIVMLogViewerDialogFactory(CMachine()).cleanup(pDialog); 1263 } 1264 1265 void UIVirtualBoxManager::sltShowMachineInFileManager() 1266 { 1267 /* Get selected items: */ 1268 QList<UIVirtualMachineItem*> items = currentItems(); 1269 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1270 1271 /* For each selected item: */ 1272 foreach (UIVirtualMachineItem *pItem, items) 1273 { 1274 /* Check if that item could be shown in file-browser: */ 1275 if (!isActionEnabled(UIActionIndexST_M_Group_S_ShowInFileManager, QList<UIVirtualMachineItem*>() << pItem)) 1276 continue; 1277 1278 /* Show VM in filebrowser: */ 1279 UIDesktopServices::openInFileManager(pItem->machine().GetSettingsFilePath()); 1280 } 1281 } 1282 1283 void UIVirtualBoxManager::sltPerformCreateMachineShortcut() 1284 { 1285 /* Get selected items: */ 1286 QList<UIVirtualMachineItem*> items = currentItems(); 1287 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1288 1289 /* For each selected item: */ 1290 foreach (UIVirtualMachineItem *pItem, items) 1291 { 1292 /* Check if shortcuts could be created for this item: */ 1293 if (!isActionEnabled(UIActionIndexST_M_Group_S_CreateShortcut, QList<UIVirtualMachineItem*>() << pItem)) 1294 continue; 1295 1296 /* Create shortcut for this VM: */ 1297 const CMachine &comMachine = pItem->machine(); 1298 UIDesktopServices::createMachineShortcut(comMachine.GetSettingsFilePath(), 1299 QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), 1300 comMachine.GetName(), comMachine.GetId()); 1301 } 1302 } 1303 1304 void UIVirtualBoxManager::sltGroupCloseMenuAboutToShow() 1305 { 1306 /* Get selected items: */ 1307 QList<UIVirtualMachineItem*> items = currentItems(); 1308 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1309 1310 actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_Close_S_Shutdown, items)); 1311 } 1312 1313 void UIVirtualBoxManager::sltMachineCloseMenuAboutToShow() 1314 { 1315 /* Get selected items: */ 1316 QList<UIVirtualMachineItem*> items = currentItems(); 1317 AssertMsgReturnVoid(!items.isEmpty(), ("At least one item should be selected!\n")); 1318 1319 actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_Shutdown, items)); 1320 } 1321 1322 void UIVirtualBoxManager::sltHandleToolsTypeSwitch() 273 void UIVirtualBoxManagerWidget::sltHandleToolsTypeSwitch() 1323 274 { 1324 275 /* If Machine tool button is checked => go backward: */ … … 1333 284 1334 285 /* Update action visibility: */ 1335 updateActionsVisibility();286 emit sigToolsTypeSwitch(); 1336 287 1337 288 /* Make sure chosen item fetched: */ … … 1339 290 } 1340 291 1341 void UIVirtualBoxManager ::sltHandleShowTabBarMachine()292 void UIVirtualBoxManagerWidget::sltHandleShowTabBarMachine() 1342 293 { 1343 294 m_pActionTabBarGlobal->setVisible(false); … … 1345 296 } 1346 297 1347 void UIVirtualBoxManager ::sltHandleShowTabBarGlobal()298 void UIVirtualBoxManagerWidget::sltHandleShowTabBarGlobal() 1348 299 { 1349 300 m_pActionTabBarMachine->setVisible(false); … … 1351 302 } 1352 303 1353 void UIVirtualBoxManager ::sltHandleToolOpenedMachine(ToolTypeMachine enmType)304 void UIVirtualBoxManagerWidget::sltHandleToolOpenedMachine(ToolTypeMachine enmType) 1354 305 { 1355 306 /* First, make sure corresponding tool set opened: */ … … 1372 323 } 1373 324 1374 void UIVirtualBoxManager ::sltHandleToolOpenedGlobal(ToolTypeGlobal enmType)325 void UIVirtualBoxManagerWidget::sltHandleToolOpenedGlobal(ToolTypeGlobal enmType) 1375 326 { 1376 327 /* First, make sure corresponding tool set opened: */ … … 1383 334 } 1384 335 1385 void UIVirtualBoxManager ::sltHandleToolClosedMachine(ToolTypeMachine enmType)336 void UIVirtualBoxManagerWidget::sltHandleToolClosedMachine(ToolTypeMachine enmType) 1386 337 { 1387 338 /* Close corresponding tool: */ … … 1389 340 } 1390 341 1391 void UIVirtualBoxManager ::sltHandleToolClosedGlobal(ToolTypeGlobal enmType)342 void UIVirtualBoxManagerWidget::sltHandleToolClosedGlobal(ToolTypeGlobal enmType) 1392 343 { 1393 344 /* Close corresponding tool: */ … … 1395 346 } 1396 347 1397 UIVirtualMachineItem *UIVirtualBoxManager::currentItem() const 1398 { 1399 return m_pPaneChooser->currentItem(); 1400 } 1401 1402 QList<UIVirtualMachineItem*> UIVirtualBoxManager::currentItems() const 1403 { 1404 return m_pPaneChooser->currentItems(); 1405 } 1406 1407 void UIVirtualBoxManager::prepare() 1408 { 1409 #ifdef VBOX_WS_X11 1410 /* Assign same name to both WM_CLASS name & class for now: */ 1411 VBoxGlobal::setWMClass(this, "VirtualBox Manager", "VirtualBox Manager"); 1412 #endif 1413 1414 #ifdef VBOX_WS_MAC 1415 /* We have to make sure that we are getting the front most process: */ 1416 ::darwinSetFrontMostProcess(); 1417 #endif 1418 1419 /* Cache medium data early if necessary: */ 1420 if (vboxGlobal().agressiveCaching()) 1421 vboxGlobal().startMediumEnumeration(); 1422 348 void UIVirtualBoxManagerWidget::prepare() 349 { 1423 350 /* Prepare: */ 1424 prepareIcon();1425 prepareMenuBar();1426 prepareStatusBar();1427 351 prepareToolbar(); 1428 352 prepareWidgets(); … … 1435 359 retranslateUi(); 1436 360 1437 #ifdef VBOX_WS_MAC1438 /* Enable unified toolbar: */1439 m_pToolBar->enableMacToolbar();1440 1441 /* Beta label? */1442 if (vboxGlobal().isBeta())1443 {1444 QPixmap betaLabel = ::betaLabel(QSize(100, 16));1445 ::darwinLabelWindow(this, &betaLabel, true);1446 }1447 1448 /* General event filter: */1449 qApp->installEventFilter(this);1450 #endif /* VBOX_WS_MAC */1451 1452 361 /* Make sure current Chooser-pane index fetched: */ 1453 362 sltHandleChooserPaneIndexChange(); 1454 363 } 1455 364 1456 void UIVirtualBoxManager::prepareIcon() 1457 { 1458 /* Prepare application icon. 1459 * On Win host it's built-in to the executable. 1460 * On Mac OS X the icon referenced in info.plist is used. 1461 * On X11 we will provide as much icons as we can. */ 1462 #if !defined(VBOX_WS_WIN) && !defined(VBOX_WS_MAC) 1463 QIcon icon(":/VirtualBox.svg"); 1464 icon.addFile(":/VirtualBox_48px.png"); 1465 icon.addFile(":/VirtualBox_64px.png"); 1466 setWindowIcon(icon); 1467 #endif /* !VBOX_WS_WIN && !VBOX_WS_MAC */ 1468 } 1469 1470 void UIVirtualBoxManager::prepareMenuBar() 1471 { 1472 #ifndef VBOX_WS_MAC 1473 /* Create menu-bar: */ 1474 setMenuBar(new UIMenuBar); 1475 #endif 1476 1477 /* Create action-pool: */ 1478 m_pActionPool = UIActionPool::create(UIActionPoolType_Selector); 1479 1480 /* Prepare File-menu: */ 1481 prepareMenuFile(actionPool()->action(UIActionIndexST_M_File)->menu()); 1482 menuBar()->addMenu(actionPool()->action(UIActionIndexST_M_File)->menu()); 1483 1484 /* Prepare 'Group' / 'Start or Show' menu: */ 1485 prepareMenuGroupStartOrShow(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow)->menu()); 1486 1487 /* Prepare 'Machine' / 'Start or Show' menu: */ 1488 prepareMenuMachineStartOrShow(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)->menu()); 1489 1490 /* Prepare 'Group' / 'Close' menu: */ 1491 prepareMenuGroupClose(actionPool()->action(UIActionIndexST_M_Group_M_Close)->menu()); 1492 1493 /* Prepare 'Machine' / 'Close' menu: */ 1494 prepareMenuMachineClose(actionPool()->action(UIActionIndexST_M_Machine_M_Close)->menu()); 1495 1496 /* Prepare Group-menu: */ 1497 prepareMenuGroup(actionPool()->action(UIActionIndexST_M_Group)->menu()); 1498 m_pGroupMenuAction = menuBar()->addMenu(actionPool()->action(UIActionIndexST_M_Group)->menu()); 1499 1500 /* Prepare Machine-menu: */ 1501 prepareMenuMachine(actionPool()->action(UIActionIndexST_M_Machine)->menu()); 1502 m_pMachineMenuAction = menuBar()->addMenu(actionPool()->action(UIActionIndexST_M_Machine)->menu()); 1503 1504 #ifdef VBOX_WS_MAC 1505 /* Prepare 'Window' menu: */ 1506 UIWindowMenuManager::create(); 1507 menuBar()->addMenu(gpWindowMenuManager->createMenu(this)); 1508 gpWindowMenuManager->addWindow(this); 1509 #endif 1510 1511 /* Prepare Help-menu: */ 1512 menuBar()->addMenu(actionPool()->action(UIActionIndex_Menu_Help)->menu()); 1513 1514 /* Setup menubar policy: */ 1515 menuBar()->setContextMenuPolicy(Qt::CustomContextMenu); 1516 } 1517 1518 void UIVirtualBoxManager::prepareMenuFile(QMenu *pMenu) 1519 { 1520 /* Do not touch if filled already: */ 1521 if (!pMenu->isEmpty()) 1522 return; 1523 1524 /* The Application / 'File' menu contents is very different depending on host type. */ 1525 1526 #ifdef VBOX_WS_MAC 1527 1528 /* 'About' action goes to Application menu: */ 1529 pMenu->addAction(actionPool()->action(UIActionIndex_M_Application_S_About)); 1530 # ifdef VBOX_GUI_WITH_NETWORK_MANAGER 1531 /* 'Check for Updates' action goes to Application menu: */ 1532 pMenu->addAction(actionPool()->action(UIActionIndex_M_Application_S_CheckForUpdates)); 1533 /* 'Network Access Manager' action goes to Application menu: */ 1534 pMenu->addAction(actionPool()->action(UIActionIndex_M_Application_S_NetworkAccessManager)); 1535 # endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 1536 /* 'Reset Warnings' action goes to Application menu: */ 1537 pMenu->addAction(actionPool()->action(UIActionIndex_M_Application_S_ResetWarnings)); 1538 /* 'Preferences' action goes to Application menu: */ 1539 pMenu->addAction(actionPool()->action(UIActionIndex_M_Application_S_Preferences)); 1540 /* 'Close' action goes to Application menu: */ 1541 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_Close)); 1542 1543 /* 'Import Appliance' action goes to 'File' menu: */ 1544 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance)); 1545 /* 'Export Appliance' action goes to 'File' menu: */ 1546 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance)); 1547 # ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI 1548 /* 'Show Extra-data Manager' action goes to 'File' menu for Debug build: */ 1549 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ShowExtraDataManager)); 1550 # endif /* VBOX_GUI_WITH_EXTRADATA_MANAGER_UI */ 1551 /* 'Show Virtual Medium Manager' action goes to 'File' menu: */ 1552 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ShowVirtualMediumManager)); 1553 /* 'Show Host Network Manager' action goes to 'File' menu: */ 1554 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ShowHostNetworkManager)); 1555 1556 #else /* !VBOX_WS_MAC */ 1557 1558 # ifdef VBOX_WS_X11 1559 // WORKAROUND: 1560 // There is an issue under Ubuntu which uses special kind of QPA 1561 // plugin (appmenu-qt5) which redirects actions added to Qt menu-bar 1562 // directly to Ubuntu Application menu-bar. In that case action 1563 // shortcuts are not being handled by the Qt and that way ignored. 1564 // As a workaround we can add those actions into QMainWindow as well. 1565 addAction(actionPool()->action(UIActionIndex_M_Application_S_Preferences)); 1566 addAction(actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance)); 1567 addAction(actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance)); 1568 # ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI 1569 addAction(actionPool()->action(UIActionIndexST_M_File_S_ShowExtraDataManager)); 1570 # endif /* VBOX_GUI_WITH_EXTRADATA_MANAGER_UI */ 1571 addAction(actionPool()->action(UIActionIndexST_M_File_S_ShowVirtualMediumManager)); 1572 addAction(actionPool()->action(UIActionIndexST_M_File_S_ShowHostNetworkManager)); 1573 # ifdef VBOX_GUI_WITH_NETWORK_MANAGER 1574 addAction(actionPool()->action(UIActionIndex_M_Application_S_NetworkAccessManager)); 1575 addAction(actionPool()->action(UIActionIndex_M_Application_S_CheckForUpdates)); 1576 # endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 1577 addAction(actionPool()->action(UIActionIndex_M_Application_S_ResetWarnings)); 1578 addAction(actionPool()->action(UIActionIndexST_M_File_S_Close)); 1579 # endif /* VBOX_WS_X11 */ 1580 1581 /* 'Preferences' action goes to 'File' menu: */ 1582 pMenu->addAction(actionPool()->action(UIActionIndex_M_Application_S_Preferences)); 1583 /* Separator after 'Preferences' action of the 'File' menu: */ 1584 pMenu->addSeparator(); 1585 /* 'Import Appliance' action goes to 'File' menu: */ 1586 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance)); 1587 /* 'Export Appliance' action goes to 'File' menu: */ 1588 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance)); 1589 /* Separator after 'Export Appliance' action of the 'File' menu: */ 1590 pMenu->addSeparator(); 1591 # ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI 1592 /* 'Extra-data Manager' action goes to 'File' menu for Debug build: */ 1593 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ShowExtraDataManager)); 1594 # endif /* VBOX_GUI_WITH_EXTRADATA_MANAGER_UI */ 1595 /* 'Show Virtual Medium Manager' action goes to 'File' menu: */ 1596 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ShowVirtualMediumManager)); 1597 /* 'Show Host Network Manager' action goes to 'File' menu: */ 1598 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_ShowHostNetworkManager)); 1599 # ifdef VBOX_GUI_WITH_NETWORK_MANAGER 1600 /* 'Network Access Manager' action goes to 'File' menu: */ 1601 pMenu->addAction(actionPool()->action(UIActionIndex_M_Application_S_NetworkAccessManager)); 1602 /* 'Check for Updates' action goes to 'File' menu: */ 1603 if (gEDataManager->applicationUpdateEnabled()) 1604 pMenu->addAction(actionPool()->action(UIActionIndex_M_Application_S_CheckForUpdates)); 1605 # endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ 1606 /* 'Reset Warnings' action goes 'File' menu: */ 1607 pMenu->addAction(actionPool()->action(UIActionIndex_M_Application_S_ResetWarnings)); 1608 /* Separator after 'Reset Warnings' action of the 'File' menu: */ 1609 pMenu->addSeparator(); 1610 /* 'Close' action goes to 'File' menu: */ 1611 pMenu->addAction(actionPool()->action(UIActionIndexST_M_File_S_Close)); 1612 1613 #endif /* !VBOX_WS_MAC */ 1614 } 1615 1616 void UIVirtualBoxManager::prepareMenuGroup(QMenu *pMenu) 1617 { 1618 /* Do not touch if filled already: */ 1619 if (!pMenu->isEmpty()) 1620 return; 1621 1622 #ifdef VBOX_WS_X11 1623 // WORKAROUND: 1624 // There is an issue under Ubuntu which uses special kind of QPA 1625 // plugin (appmenu-qt5) which redirects actions added to Qt menu-bar 1626 // directly to Ubuntu Application menu-bar. In that case action 1627 // shortcuts are not being handled by the Qt and that way ignored. 1628 // As a workaround we can add those actions into QMainWindow as well. 1629 addAction(actionPool()->action(UIActionIndexST_M_Group_S_New)); 1630 addAction(actionPool()->action(UIActionIndexST_M_Group_S_Add)); 1631 addAction(actionPool()->action(UIActionIndexST_M_Group_S_Rename)); 1632 addAction(actionPool()->action(UIActionIndexST_M_Group_S_Remove)); 1633 addAction(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow)); 1634 addAction(actionPool()->action(UIActionIndexST_M_Group_T_Pause)); 1635 addAction(actionPool()->action(UIActionIndexST_M_Group_S_Reset)); 1636 addAction(actionPool()->action(UIActionIndexST_M_Group_S_Discard)); 1637 addAction(actionPool()->action(UIActionIndexST_M_Group_S_ShowLogDialog)); 1638 addAction(actionPool()->action(UIActionIndexST_M_Group_S_Refresh)); 1639 addAction(actionPool()->action(UIActionIndexST_M_Group_S_ShowInFileManager)); 1640 addAction(actionPool()->action(UIActionIndexST_M_Group_S_CreateShortcut)); 1641 addAction(actionPool()->action(UIActionIndexST_M_Group_S_Sort)); 1642 #endif /* VBOX_WS_X11 */ 1643 1644 /* Populate Machine-menu: */ 1645 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_New)); 1646 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_Add)); 1647 pMenu->addSeparator(); 1648 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_Rename)); 1649 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_Remove)); 1650 pMenu->addSeparator(); 1651 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow)); 1652 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_T_Pause)); 1653 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_Reset)); 1654 pMenu->addMenu(actionPool()->action(UIActionIndexST_M_Group_M_Close)->menu()); 1655 pMenu->addSeparator(); 1656 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_Discard)); 1657 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_ShowLogDialog)); 1658 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_Refresh)); 1659 pMenu->addSeparator(); 1660 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_ShowInFileManager)); 1661 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_CreateShortcut)); 1662 pMenu->addSeparator(); 1663 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_S_Sort)); 1664 1665 /* Remember action list: */ 1666 m_groupActions << actionPool()->action(UIActionIndexST_M_Group_S_New) 1667 << actionPool()->action(UIActionIndexST_M_Group_S_Add) 1668 << actionPool()->action(UIActionIndexST_M_Group_S_Rename) 1669 << actionPool()->action(UIActionIndexST_M_Group_S_Remove) 1670 << actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow) 1671 << actionPool()->action(UIActionIndexST_M_Group_T_Pause) 1672 << actionPool()->action(UIActionIndexST_M_Group_S_Reset) 1673 << actionPool()->action(UIActionIndexST_M_Group_S_Discard) 1674 << actionPool()->action(UIActionIndexST_M_Group_S_ShowLogDialog) 1675 << actionPool()->action(UIActionIndexST_M_Group_S_Refresh) 1676 << actionPool()->action(UIActionIndexST_M_Group_S_ShowInFileManager) 1677 << actionPool()->action(UIActionIndexST_M_Group_S_CreateShortcut) 1678 << actionPool()->action(UIActionIndexST_M_Group_S_Sort); 1679 } 1680 1681 void UIVirtualBoxManager::prepareMenuMachine(QMenu *pMenu) 1682 { 1683 /* Do not touch if filled already: */ 1684 if (!pMenu->isEmpty()) 1685 return; 1686 1687 #ifdef VBOX_WS_X11 1688 // WORKAROUND: 1689 // There is an issue under Ubuntu which uses special kind of QPA 1690 // plugin (appmenu-qt5) which redirects actions added to Qt menu-bar 1691 // directly to Ubuntu Application menu-bar. In that case action 1692 // shortcuts are not being handled by the Qt and that way ignored. 1693 // As a workaround we can add those actions into QMainWindow as well. 1694 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_New)); 1695 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Add)); 1696 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Settings)); 1697 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Clone)); 1698 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Move)); 1699 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Remove)); 1700 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_AddGroup)); 1701 addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)); 1702 addAction(actionPool()->action(UIActionIndexST_M_Machine_T_Pause)); 1703 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Reset)); 1704 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Discard)); 1705 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_ShowLogDialog)); 1706 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Refresh)); 1707 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_ShowInFileManager)); 1708 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_CreateShortcut)); 1709 addAction(actionPool()->action(UIActionIndexST_M_Machine_S_SortParent)); 1710 #endif /* VBOX_WS_X11 */ 1711 1712 /* Populate Machine-menu: */ 1713 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_New)); 1714 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Add)); 1715 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Settings)); 1716 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Clone)); 1717 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Move)); 1718 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Remove)); 1719 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_AddGroup)); 1720 pMenu->addSeparator(); 1721 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)); 1722 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_T_Pause)); 1723 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Reset)); 1724 pMenu->addMenu(actionPool()->action(UIActionIndexST_M_Machine_M_Close)->menu()); 1725 pMenu->addSeparator(); 1726 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Discard)); 1727 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_ShowLogDialog)); 1728 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_Refresh)); 1729 pMenu->addSeparator(); 1730 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_ShowInFileManager)); 1731 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_CreateShortcut)); 1732 pMenu->addSeparator(); 1733 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_S_SortParent)); 1734 1735 /* Remember action list: */ 1736 m_machineActions << actionPool()->action(UIActionIndexST_M_Machine_S_New) 1737 << actionPool()->action(UIActionIndexST_M_Machine_S_Add) 1738 << actionPool()->action(UIActionIndexST_M_Machine_S_Settings) 1739 << actionPool()->action(UIActionIndexST_M_Machine_S_Clone) 1740 << actionPool()->action(UIActionIndexST_M_Machine_S_Move) 1741 << actionPool()->action(UIActionIndexST_M_Machine_S_Remove) 1742 << actionPool()->action(UIActionIndexST_M_Machine_S_AddGroup) 1743 << actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow) 1744 << actionPool()->action(UIActionIndexST_M_Machine_T_Pause) 1745 << actionPool()->action(UIActionIndexST_M_Machine_S_Reset) 1746 << actionPool()->action(UIActionIndexST_M_Machine_S_Discard) 1747 << actionPool()->action(UIActionIndexST_M_Machine_S_ShowLogDialog) 1748 << actionPool()->action(UIActionIndexST_M_Machine_S_Refresh) 1749 << actionPool()->action(UIActionIndexST_M_Machine_S_ShowInFileManager) 1750 << actionPool()->action(UIActionIndexST_M_Machine_S_CreateShortcut) 1751 << actionPool()->action(UIActionIndexST_M_Machine_S_SortParent); 1752 } 1753 1754 void UIVirtualBoxManager::prepareMenuGroupStartOrShow(QMenu *pMenu) 1755 { 1756 /* Do not touch if filled already: */ 1757 if (!pMenu->isEmpty()) 1758 return; 1759 1760 #ifdef VBOX_WS_X11 1761 // WORKAROUND: 1762 // There is an issue under Ubuntu which uses special kind of QPA 1763 // plugin (appmenu-qt5) which redirects actions added to Qt menu-bar 1764 // directly to Ubuntu Application menu-bar. In that case action 1765 // shortcuts are not being handled by the Qt and that way ignored. 1766 // As a workaround we can add those actions into QMainWindow as well. 1767 addAction(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartNormal)); 1768 addAction(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartHeadless)); 1769 addAction(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartDetachable)); 1770 #endif /* VBOX_WS_X11 */ 1771 1772 /* Populate 'Group' / 'Start or Show' menu: */ 1773 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartNormal)); 1774 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartHeadless)); 1775 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartDetachable)); 1776 1777 /* Remember action list: */ 1778 m_groupActions << actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartNormal) 1779 << actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartHeadless) 1780 << actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartDetachable); 1781 } 1782 1783 void UIVirtualBoxManager::prepareMenuMachineStartOrShow(QMenu *pMenu) 1784 { 1785 /* Do not touch if filled already: */ 1786 if (!pMenu->isEmpty()) 1787 return; 1788 1789 #ifdef VBOX_WS_X11 1790 // WORKAROUND: 1791 // There is an issue under Ubuntu which uses special kind of QPA 1792 // plugin (appmenu-qt5) which redirects actions added to Qt menu-bar 1793 // directly to Ubuntu Application menu-bar. In that case action 1794 // shortcuts are not being handled by the Qt and that way ignored. 1795 // As a workaround we can add those actions into QMainWindow as well. 1796 addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartNormal)); 1797 addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartHeadless)); 1798 addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable)); 1799 #endif /* VBOX_WS_X11 */ 1800 1801 /* Populate 'Machine' / 'Start or Show' menu: */ 1802 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartNormal)); 1803 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartHeadless)); 1804 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable)); 1805 1806 /* Remember action list: */ 1807 m_machineActions << actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartNormal) 1808 << actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartHeadless) 1809 << actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable); 1810 } 1811 1812 void UIVirtualBoxManager::prepareMenuGroupClose(QMenu *pMenu) 1813 { 1814 /* Do not touch if filled already: */ 1815 if (!pMenu->isEmpty()) 1816 return; 1817 1818 #ifdef VBOX_WS_X11 1819 // WORKAROUND: 1820 // There is an issue under Ubuntu which uses special kind of QPA 1821 // plugin (appmenu-qt5) which redirects actions added to Qt menu-bar 1822 // directly to Ubuntu Application menu-bar. In that case action 1823 // shortcuts are not being handled by the Qt and that way ignored. 1824 // As a workaround we can add those actions into QMainWindow as well. 1825 // addAction(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Detach)); 1826 addAction(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_SaveState)); 1827 addAction(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Shutdown)); 1828 addAction(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_PowerOff)); 1829 #endif /* VBOX_WS_X11 */ 1830 1831 /* Populate 'Group' / 'Close' menu: */ 1832 // pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Detach)); 1833 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_SaveState)); 1834 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Shutdown)); 1835 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_PowerOff)); 1836 1837 /* Remember action list: */ 1838 m_groupActions // << actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Detach) 1839 << actionPool()->action(UIActionIndexST_M_Group_M_Close_S_SaveState) 1840 << actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Shutdown) 1841 << actionPool()->action(UIActionIndexST_M_Group_M_Close_S_PowerOff); 1842 } 1843 1844 void UIVirtualBoxManager::prepareMenuMachineClose(QMenu *pMenu) 1845 { 1846 /* Do not touch if filled already: */ 1847 if (!pMenu->isEmpty()) 1848 return; 1849 1850 #ifdef VBOX_WS_X11 1851 // WORKAROUND: 1852 // There is an issue under Ubuntu which uses special kind of QPA 1853 // plugin (appmenu-qt5) which redirects actions added to Qt menu-bar 1854 // directly to Ubuntu Application menu-bar. In that case action 1855 // shortcuts are not being handled by the Qt and that way ignored. 1856 // As a workaround we can add those actions into QMainWindow as well. 1857 // addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Detach)); 1858 addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_SaveState)); 1859 addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Shutdown)); 1860 addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_PowerOff)); 1861 #endif /* VBOX_WS_X11 */ 1862 1863 /* Populate 'Machine' / 'Close' menu: */ 1864 // pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Detach)); 1865 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_SaveState)); 1866 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Shutdown)); 1867 pMenu->addAction(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_PowerOff)); 1868 1869 /* Remember action list: */ 1870 m_machineActions // << actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Detach) 1871 << actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_SaveState) 1872 << actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Shutdown) 1873 << actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_PowerOff); 1874 } 1875 1876 void UIVirtualBoxManager::prepareStatusBar() 1877 { 1878 /* We are not using status-bar anymore: */ 1879 statusBar()->setHidden(true); 1880 } 1881 1882 void UIVirtualBoxManager::prepareToolbar() 365 void UIVirtualBoxManagerWidget::prepareToolbar() 1883 366 { 1884 367 /* Create Main toolbar: */ 1885 368 m_pToolBar = new UIToolBar(this); 1886 AssertPtrReturnVoid(m_pToolBar);369 if (m_pToolBar) 1887 370 { 1888 371 /* Configure toolbar: */ … … 1914 397 /* Create Machine tab-bar: */ 1915 398 m_pTabBarMachine = new UITabBar; 1916 AssertPtrReturnVoid(m_pTabBarMachine);399 if (m_pTabBarMachine) 1917 400 { 1918 401 /* Configure tab-bar: */ … … 1927 410 /* Create Global tab-bar: */ 1928 411 m_pTabBarGlobal = new UITabBar; 1929 AssertPtrReturnVoid(m_pTabBarGlobal);412 if (m_pTabBarGlobal) 1930 413 { 1931 414 /* Configure tab-bar: */ … … 1945 428 m_pToolbarTools->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding); 1946 429 connect(m_pToolbarTools, &UIToolbarTools::sigShowTabBarMachine, 1947 this, &UIVirtualBoxManager ::sltHandleShowTabBarMachine);430 this, &UIVirtualBoxManagerWidget::sltHandleShowTabBarMachine); 1948 431 connect(m_pToolbarTools, &UIToolbarTools::sigShowTabBarGlobal, 1949 this, &UIVirtualBoxManager ::sltHandleShowTabBarGlobal);432 this, &UIVirtualBoxManagerWidget::sltHandleShowTabBarGlobal); 1950 433 m_pToolbarTools->setTabBars(m_pTabBarMachine, m_pTabBarGlobal); 1951 434 1952 435 /* Create exclusive action-group: */ 1953 436 QActionGroup *pActionGroupTools = new QActionGroup(m_pToolbarTools); 1954 AssertPtrReturnVoid(pActionGroupTools);437 if (pActionGroupTools) 1955 438 { 1956 439 /* Configure action-group: */ … … 1977 460 } 1978 461 1979 void UIVirtualBoxManager::prepareWidgets() 1980 { 1981 /* Create central-widget: */ 1982 QWidget *pWidget = new QWidget; 1983 AssertPtrReturnVoid(pWidget); 1984 { 1985 /* Configure central-widget: */ 1986 setCentralWidget(pWidget); 1987 1988 /* Create central-layout: */ 1989 QVBoxLayout *pLayout = new QVBoxLayout(pWidget); 1990 AssertPtrReturnVoid(pLayout); 462 void UIVirtualBoxManagerWidget::prepareWidgets() 463 { 464 /* Create central-layout: */ 465 QVBoxLayout *pLayout = new QVBoxLayout(this); 466 if (pLayout) 467 { 468 /* Configure layout: */ 469 pLayout->setSpacing(0); 470 pLayout->setContentsMargins(0, 0, 0, 0); 471 472 /* Add into layout: */ 473 pLayout->addWidget(m_pToolBar); 474 475 /* Create sliding-widget: */ 476 m_pSlidingWidget = new UISlidingWidget; 477 if (m_pSlidingWidget) 1991 478 { 1992 /* Configure layout: */ 1993 pLayout->setSpacing(0); 1994 pLayout->setContentsMargins(0, 0, 0, 0); 1995 1996 #ifdef VBOX_WS_MAC 1997 /* Native toolbar on MAC: */ 1998 addToolBar(m_pToolBar); 1999 #else 479 /* Create splitter: */ 480 m_pSplitter = new QISplitter; 481 if (m_pSplitter) 482 { 483 /* Configure splitter: */ 484 #ifdef VBOX_WS_X11 485 m_pSplitter->setHandleType(QISplitter::Native); 486 #endif 487 488 /* Create Chooser-pane: */ 489 m_pPaneChooser = new UIChooser(this); 490 if (m_pPaneChooser) 491 { 492 /* Add into splitter: */ 493 m_pSplitter->addWidget(m_pPaneChooser); 494 } 495 496 /* Create Machine Tools-pane: */ 497 m_pPaneToolsMachine = new UIToolPaneMachine(actionPool()); 498 if (m_pPaneToolsMachine) 499 { 500 /* Add into splitter: */ 501 m_pSplitter->addWidget(m_pPaneToolsMachine); 502 } 503 504 /* Adjust splitter colors according to main widgets it splits: */ 505 m_pSplitter->configureColors(m_pPaneChooser->palette().color(QPalette::Active, QPalette::Window), 506 m_pPaneToolsMachine->palette().color(QPalette::Active, QPalette::Window)); 507 /* Set the initial distribution. The right site is bigger. */ 508 m_pSplitter->setStretchFactor(0, 2); 509 m_pSplitter->setStretchFactor(1, 3); 510 } 511 512 /* Create Global Tools-pane: */ 513 m_pPaneToolsGlobal = new UIToolPaneGlobal(actionPool()); 514 if (m_pPaneToolsGlobal) 515 516 /* Add left/right widgets into sliding widget: */ 517 m_pSlidingWidget->setWidgets(m_pSplitter, m_pPaneToolsGlobal); 518 2000 519 /* Add into layout: */ 2001 pLayout->addWidget(m_pToolBar); 2002 #endif 2003 2004 /* Create sliding-widget: */ 2005 m_pSlidingWidget = new UISlidingWidget; 2006 AssertPtrReturnVoid(m_pSlidingWidget); 2007 { 2008 /* Create splitter: */ 2009 m_pSplitter = new QISplitter; 2010 AssertPtrReturnVoid(m_pSplitter); 2011 { 2012 /* Configure splitter: */ 2013 #ifdef VBOX_WS_X11 2014 m_pSplitter->setHandleType(QISplitter::Native); 2015 #endif 2016 2017 /* Create Chooser-pane: */ 2018 m_pPaneChooser = new UIChooser(this); 2019 AssertPtrReturnVoid(m_pPaneChooser); 2020 { 2021 /* Add into splitter: */ 2022 m_pSplitter->addWidget(m_pPaneChooser); 2023 } 2024 2025 /* Create Machine Tools-pane: */ 2026 m_pPaneToolsMachine = new UIToolPaneMachine(actionPool()); 2027 AssertPtrReturnVoid(m_pPaneToolsMachine); 2028 { 2029 /* Add into splitter: */ 2030 m_pSplitter->addWidget(m_pPaneToolsMachine); 2031 } 2032 2033 /* Adjust splitter colors according to main widgets it splits: */ 2034 m_pSplitter->configureColors(m_pPaneChooser->palette().color(QPalette::Active, QPalette::Window), 2035 m_pPaneToolsMachine->palette().color(QPalette::Active, QPalette::Window)); 2036 /* Set the initial distribution. The right site is bigger. */ 2037 m_pSplitter->setStretchFactor(0, 2); 2038 m_pSplitter->setStretchFactor(1, 3); 2039 } 2040 2041 /* Create Global Tools-pane: */ 2042 m_pPaneToolsGlobal = new UIToolPaneGlobal(actionPool()); 2043 AssertPtrReturnVoid(m_pPaneToolsGlobal); 2044 2045 /* Add left/right widgets into sliding widget: */ 2046 m_pSlidingWidget->setWidgets(m_pSplitter, m_pPaneToolsGlobal); 2047 2048 /* Add into layout: */ 2049 pLayout->addWidget(m_pSlidingWidget); 2050 } 520 pLayout->addWidget(m_pSlidingWidget); 2051 521 } 2052 522 } … … 2056 526 } 2057 527 2058 void UIVirtualBoxManager::prepareConnections() 2059 { 2060 #ifdef VBOX_WS_X11 2061 /* Desktop event handlers: */ 2062 connect(gpDesktop, SIGNAL(sigHostScreenWorkAreaResized(int)), this, SLOT(sltHandleHostScreenAvailableAreaChange())); 2063 #endif /* VBOX_WS_X11 */ 2064 2065 /* Medium enumeration connections: */ 2066 connect(&vboxGlobal(), SIGNAL(sigMediumEnumerationFinished()), this, SLOT(sltHandleMediumEnumerationFinish())); 2067 2068 /* Menu-bar connections: */ 2069 connect(menuBar(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(sltHandleContextMenuRequest(const QPoint&))); 2070 2071 /* 'File' menu connections: */ 2072 connect(actionPool()->action(UIActionIndexST_M_File_S_ShowVirtualMediumManager), SIGNAL(triggered()), this, SLOT(sltOpenVirtualMediumManagerWindow())); 2073 connect(actionPool()->action(UIActionIndexST_M_File_S_ShowHostNetworkManager), SIGNAL(triggered()), this, SLOT(sltOpenHostNetworkManagerWindow())); 2074 connect(actionPool()->action(UIActionIndexST_M_File_S_ImportAppliance), SIGNAL(triggered()), this, SLOT(sltOpenImportApplianceWizard())); 2075 connect(actionPool()->action(UIActionIndexST_M_File_S_ExportAppliance), SIGNAL(triggered()), this, SLOT(sltOpenExportApplianceWizard())); 2076 #ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI 2077 connect(actionPool()->action(UIActionIndexST_M_File_S_ShowExtraDataManager), SIGNAL(triggered()), this, SLOT(sltOpenExtraDataManagerWindow())); 2078 #endif /* VBOX_GUI_WITH_EXTRADATA_MANAGER_UI */ 2079 connect(actionPool()->action(UIActionIndex_M_Application_S_Preferences), SIGNAL(triggered()), this, SLOT(sltOpenPreferencesDialog())); 2080 connect(actionPool()->action(UIActionIndexST_M_File_S_Close), SIGNAL(triggered()), this, SLOT(sltPerformExit())); 2081 2082 /* 'Group' menu connections: */ 2083 connect(actionPool()->action(UIActionIndexST_M_Group_S_Add), SIGNAL(triggered()), this, SLOT(sltOpenAddMachineDialog())); 2084 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow), SIGNAL(triggered()), this, SLOT(sltPerformStartOrShowMachine())); 2085 connect(actionPool()->action(UIActionIndexST_M_Group_T_Pause), SIGNAL(toggled(bool)), this, SLOT(sltPerformPauseOrResumeMachine(bool))); 2086 connect(actionPool()->action(UIActionIndexST_M_Group_S_Reset), SIGNAL(triggered()), this, SLOT(sltPerformResetMachine())); 2087 connect(actionPool()->action(UIActionIndexST_M_Group_S_Discard), SIGNAL(triggered()), this, SLOT(sltPerformDiscardMachineState())); 2088 connect(actionPool()->action(UIActionIndexST_M_Group_S_ShowLogDialog), SIGNAL(triggered()), this, SLOT(sltOpenMachineLogDialog())); 2089 connect(actionPool()->action(UIActionIndexST_M_Group_S_ShowInFileManager), SIGNAL(triggered()), this, SLOT(sltShowMachineInFileManager())); 2090 connect(actionPool()->action(UIActionIndexST_M_Group_S_CreateShortcut), SIGNAL(triggered()), this, SLOT(sltPerformCreateMachineShortcut())); 2091 2092 /* 'Machine' menu connections: */ 2093 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Add), SIGNAL(triggered()), this, SLOT(sltOpenAddMachineDialog())); 2094 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Settings), SIGNAL(triggered()), this, SLOT(sltOpenMachineSettingsDialog())); 2095 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Clone), SIGNAL(triggered()), this, SLOT(sltOpenCloneMachineWizard())); 2096 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Move), SIGNAL(triggered()), this, SLOT(sltPerformMachineMove())); 2097 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow), SIGNAL(triggered()), this, SLOT(sltPerformStartOrShowMachine())); 2098 connect(actionPool()->action(UIActionIndexST_M_Machine_T_Pause), SIGNAL(toggled(bool)), this, SLOT(sltPerformPauseOrResumeMachine(bool))); 2099 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Reset), SIGNAL(triggered()), this, SLOT(sltPerformResetMachine())); 2100 connect(actionPool()->action(UIActionIndexST_M_Machine_S_Discard), SIGNAL(triggered()), this, SLOT(sltPerformDiscardMachineState())); 2101 connect(actionPool()->action(UIActionIndexST_M_Machine_S_ShowLogDialog), SIGNAL(triggered()), this, SLOT(sltOpenMachineLogDialog())); 2102 connect(actionPool()->action(UIActionIndexST_M_Machine_S_ShowInFileManager), SIGNAL(triggered()), this, SLOT(sltShowMachineInFileManager())); 2103 connect(actionPool()->action(UIActionIndexST_M_Machine_S_CreateShortcut), SIGNAL(triggered()), this, SLOT(sltPerformCreateMachineShortcut())); 2104 2105 /* 'Group/Start or Show' menu connections: */ 2106 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartNormal), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineNormal())); 2107 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartHeadless), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineHeadless())); 2108 connect(actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartDetachable), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineDetachable())); 2109 2110 /* 'Machine/Start or Show' menu connections: */ 2111 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartNormal), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineNormal())); 2112 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartHeadless), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineHeadless())); 2113 connect(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable), SIGNAL(triggered()), this, SLOT(sltPerformStartMachineDetachable())); 2114 2115 /* 'Group/Close' menu connections: */ 2116 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close)->menu(), SIGNAL(aboutToShow()), this, SLOT(sltGroupCloseMenuAboutToShow())); 2117 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Detach), SIGNAL(triggered()), this, SLOT(sltPerformDetachMachineUI())); 2118 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_SaveState), SIGNAL(triggered()), this, SLOT(sltPerformSaveMachineState())); 2119 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Shutdown), SIGNAL(triggered()), this, SLOT(sltPerformShutdownMachine())); 2120 connect(actionPool()->action(UIActionIndexST_M_Group_M_Close_S_PowerOff), SIGNAL(triggered()), this, SLOT(sltPerformPowerOffMachine())); 2121 2122 /* 'Machine/Close' menu connections: */ 2123 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close)->menu(), SIGNAL(aboutToShow()), this, SLOT(sltMachineCloseMenuAboutToShow())); 2124 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Detach), SIGNAL(triggered()), this, SLOT(sltPerformDetachMachineUI())); 2125 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_SaveState), SIGNAL(triggered()), this, SLOT(sltPerformSaveMachineState())); 2126 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Shutdown), SIGNAL(triggered()), this, SLOT(sltPerformShutdownMachine())); 2127 connect(actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_PowerOff), SIGNAL(triggered()), this, SLOT(sltPerformPowerOffMachine())); 528 void UIVirtualBoxManagerWidget::prepareConnections() 529 { 530 /* Tool-bar connections: */ 531 connect(m_pToolBar, &UIToolBar::customContextMenuRequested, 532 this, &UIVirtualBoxManagerWidget::sltHandleContextMenuRequest); 533 connect(m_pToolbarTools, &UIToolbarTools::sigToolOpenedMachine, 534 this, &UIVirtualBoxManagerWidget::sltHandleToolOpenedMachine); 535 connect(m_pToolbarTools, &UIToolbarTools::sigToolOpenedGlobal, 536 this, &UIVirtualBoxManagerWidget::sltHandleToolOpenedGlobal); 537 connect(m_pToolbarTools, &UIToolbarTools::sigToolClosedMachine, 538 this, &UIVirtualBoxManagerWidget::sltHandleToolClosedMachine); 539 connect(m_pToolbarTools, &UIToolbarTools::sigToolClosedGlobal, 540 this, &UIVirtualBoxManagerWidget::sltHandleToolClosedGlobal); 2128 541 2129 542 /* 'Tools' actions connections: */ 2130 543 connect(actionPool()->action(UIActionIndexST_M_Tools_T_Machine), &UIAction::toggled, 2131 this, &UIVirtualBoxManager ::sltHandleToolsTypeSwitch);544 this, &UIVirtualBoxManagerWidget::sltHandleToolsTypeSwitch); 2132 545 connect(actionPool()->action(UIActionIndexST_M_Tools_T_Global), &UIAction::toggled, 2133 this, &UIVirtualBoxManager::sltHandleToolsTypeSwitch); 2134 2135 /* Graphics VM chooser connections: */ 2136 connect(m_pPaneChooser, SIGNAL(sigSelectionChanged()), this, SLOT(sltHandleChooserPaneIndexChange())); 2137 connect(m_pPaneChooser, SIGNAL(sigSlidingStarted()), m_pPaneToolsMachine, SIGNAL(sigSlidingStarted())); 2138 connect(m_pPaneChooser, SIGNAL(sigToggleStarted()), m_pPaneToolsMachine, SIGNAL(sigToggleStarted())); 2139 connect(m_pPaneChooser, SIGNAL(sigToggleFinished()), m_pPaneToolsMachine, SIGNAL(sigToggleFinished())); 2140 connect(m_pPaneChooser, SIGNAL(sigGroupSavingStateChanged()), this, SLOT(sltHandleGroupSavingProgressChange())); 2141 2142 /* Tool-bar connections: */ 2143 #ifndef VBOX_WS_MAC 2144 connect(m_pToolBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(sltHandleContextMenuRequest(const QPoint&))); 2145 #else /* VBOX_WS_MAC */ 2146 /* We want to receive right click notifications on the title bar, so register our own handler: */ 2147 ::darwinRegisterForUnifiedToolbarContextMenuEvents(this); 2148 #endif /* VBOX_WS_MAC */ 2149 connect(m_pToolbarTools, &UIToolbarTools::sigToolOpenedMachine, this, &UIVirtualBoxManager::sltHandleToolOpenedMachine); 2150 connect(m_pToolbarTools, &UIToolbarTools::sigToolOpenedGlobal, this, &UIVirtualBoxManager::sltHandleToolOpenedGlobal); 2151 connect(m_pToolbarTools, &UIToolbarTools::sigToolClosedMachine, this, &UIVirtualBoxManager::sltHandleToolClosedMachine); 2152 connect(m_pToolbarTools, &UIToolbarTools::sigToolClosedGlobal, this, &UIVirtualBoxManager::sltHandleToolClosedGlobal); 2153 2154 /* VM desktop connections: */ 2155 connect(m_pPaneToolsMachine, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)), 2156 this, SLOT(sltOpenMachineSettingsDialog(const QString&, const QString&, const QString&))); 2157 2158 /* Global event handlers: */ 2159 connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltHandleStateChange(QString))); 2160 connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), this, SLOT(sltHandleStateChange(QString))); 2161 } 2162 2163 void UIVirtualBoxManager::loadSettings() 2164 { 2165 /* Restore window geometry: */ 2166 { 2167 /* Load geometry: */ 2168 m_geometry = gEDataManager->selectorWindowGeometry(this); 2169 2170 /* Restore geometry: */ 2171 LogRel2(("GUI: UIVirtualBoxManager: Restoring geometry to: Origin=%dx%d, Size=%dx%d\n", 2172 m_geometry.x(), m_geometry.y(), m_geometry.width(), m_geometry.height())); 2173 restoreGeometry(); 2174 } 2175 546 this, &UIVirtualBoxManagerWidget::sltHandleToolsTypeSwitch); 547 548 /* Chooser-pane connections: */ 549 connect(m_pPaneChooser, &UIChooser::sigSelectionChanged, 550 this, &UIVirtualBoxManagerWidget::sltHandleChooserPaneIndexChangeDefault); 551 connect(m_pPaneChooser, &UIChooser::sigSlidingStarted, 552 m_pPaneToolsMachine, &UIToolPaneMachine::sigSlidingStarted); 553 connect(m_pPaneChooser, &UIChooser::sigToggleStarted, 554 m_pPaneToolsMachine, &UIToolPaneMachine::sigToggleStarted); 555 connect(m_pPaneChooser, &UIChooser::sigToggleFinished, 556 m_pPaneToolsMachine, &UIToolPaneMachine::sigToggleFinished); 557 connect(m_pPaneChooser, &UIChooser::sigGroupSavingStateChanged, 558 this, &UIVirtualBoxManagerWidget::sigGroupSavingStateChanged); 559 560 /* Details-pane connections: */ 561 connect(m_pPaneToolsMachine, &UIToolPaneMachine::sigLinkClicked, 562 this, &UIVirtualBoxManagerWidget::sigMachineSettingsLinkClicked); 563 } 564 565 void UIVirtualBoxManagerWidget::loadSettings() 566 { 2176 567 /* Restore splitter handle position: */ 2177 568 { … … 2189 580 } 2190 581 2191 /* Restore toolbar and statusbar functionality: */ 2192 { 2193 #ifdef VBOX_WS_MAC 2194 // WORKAROUND: 2195 // There is an issue in Qt5 main-window toolbar implementation: 2196 // if you are hiding it before it's shown for the first time, 2197 // there is an ugly empty container appears instead, so we 2198 // have to hide toolbar asynchronously to avoid that. 2199 if (!gEDataManager->selectorWindowToolBarVisible()) 2200 QMetaObject::invokeMethod(m_pToolBar, "hide", Qt::QueuedConnection); 2201 #else 2202 m_pToolBar->setHidden(!gEDataManager->selectorWindowToolBarVisible()); 2203 #endif 582 /* Restore toolbar settings: */ 583 { 2204 584 m_pToolBar->setToolButtonStyle(gEDataManager->selectorWindowToolBarTextVisible() 2205 585 ? Qt::ToolButtonTextUnderIcon : Qt::ToolButtonIconOnly); … … 2228 608 } 2229 609 2230 void UIVirtualBoxManager ::saveSettings()610 void UIVirtualBoxManagerWidget::saveSettings() 2231 611 { 2232 612 /* Save toolbar Machine/Global tools orders: */ … … 2236 616 } 2237 617 2238 /* Save toolbar and statusbarvisibility: */618 /* Save toolbar visibility: */ 2239 619 { 2240 620 gEDataManager->setSelectorWindowToolBarVisible(!m_pToolBar->isHidden()); … … 2246 626 gEDataManager->setSelectorWindowSplitterHints(m_pSplitter->sizes()); 2247 627 } 2248 2249 /* Save window geometry: */ 2250 { 2251 #ifdef VBOX_WS_MAC 2252 gEDataManager->setSelectorWindowGeometry(m_geometry, ::darwinIsWindowMaximized(this)); 2253 #else /* VBOX_WS_MAC */ 2254 gEDataManager->setSelectorWindowGeometry(m_geometry, isMaximized()); 2255 #endif /* !VBOX_WS_MAC */ 2256 LogRel2(("GUI: UIVirtualBoxManager: Geometry saved as: Origin=%dx%d, Size=%dx%d\n", 2257 m_geometry.x(), m_geometry.y(), m_geometry.width(), m_geometry.height())); 2258 } 2259 } 2260 2261 void UIVirtualBoxManager::cleanupConnections() 2262 { 2263 #ifdef VBOX_WS_MAC 2264 /* Tool-bar connections: */ 2265 ::darwinUnregisterForUnifiedToolbarContextMenuEvents(this); 2266 #endif /* VBOX_WS_MAC */ 2267 } 2268 2269 void UIVirtualBoxManager::cleanupMenuBar() 2270 { 2271 #ifdef VBOX_WS_MAC 2272 /* Cleanup 'Window' menu: */ 2273 UIWindowMenuManager::destroy(); 2274 #endif 2275 2276 /* Destroy action-pool: */ 2277 UIActionPool::destroy(m_pActionPool); 2278 } 2279 2280 void UIVirtualBoxManager::cleanup() 2281 { 2282 /* Close the sub-dialogs first: */ 2283 sltCloseVirtualMediumManagerWindow(); 2284 sltCloseHostNetworkManagerWindow(); 2285 628 } 629 630 void UIVirtualBoxManagerWidget::cleanup() 631 { 2286 632 /* Save settings: */ 2287 633 saveSettings(); 2288 2289 /* Cleanup: */ 2290 cleanupConnections(); 2291 cleanupMenuBar(); 2292 } 2293 2294 void UIVirtualBoxManager::performStartOrShowVirtualMachines(const QList<UIVirtualMachineItem*> &items, VBoxGlobal::LaunchMode enmLaunchMode) 2295 { 2296 /* Do nothing while group saving is in progress: */ 2297 if (m_pPaneChooser->isGroupSavingInProgress()) 2298 return; 2299 2300 /* Compose the list of startable items: */ 2301 QStringList startableMachineNames; 2302 QList<UIVirtualMachineItem*> startableItems; 2303 foreach (UIVirtualMachineItem *pItem, items) 2304 { 2305 if (isAtLeastOneItemCanBeStarted(QList<UIVirtualMachineItem*>() << pItem)) 2306 { 2307 startableItems << pItem; 2308 startableMachineNames << pItem->name(); 2309 } 2310 } 2311 2312 /* Initially we have start auto-confirmed: */ 2313 bool fStartConfirmed = true; 2314 /* But if we have more than one item to start => 2315 * We should still ask user for a confirmation: */ 2316 if (startableItems.size() > 1) 2317 fStartConfirmed = msgCenter().confirmStartMultipleMachines(startableMachineNames.join(", ")); 2318 2319 /* For every item => check if it could be launched: */ 2320 foreach (UIVirtualMachineItem *pItem, items) 2321 { 2322 if ( isAtLeastOneItemCanBeShown(QList<UIVirtualMachineItem*>() << pItem) 2323 || ( isAtLeastOneItemCanBeStarted(QList<UIVirtualMachineItem*>() << pItem) 2324 && fStartConfirmed)) 2325 { 2326 /* Fetch item launch mode: */ 2327 VBoxGlobal::LaunchMode enmItemLaunchMode = enmLaunchMode; 2328 if (enmItemLaunchMode == VBoxGlobal::LaunchMode_Invalid) 2329 enmItemLaunchMode = UIVirtualMachineItem::isItemRunningHeadless(pItem) ? VBoxGlobal::LaunchMode_Separate : 2330 qApp->keyboardModifiers() == Qt::ShiftModifier ? VBoxGlobal::LaunchMode_Headless : 2331 VBoxGlobal::LaunchMode_Default; 2332 2333 /* Launch current VM: */ 2334 CMachine machine = pItem->machine(); 2335 vboxGlobal().launchMachine(machine, enmItemLaunchMode); 2336 } 2337 } 2338 } 2339 2340 void UIVirtualBoxManager::updateActionsVisibility() 2341 { 2342 /* Determine whether Machine or Group menu should be shown at all: */ 2343 const bool fMachineOrGroupMenuShown = actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->isChecked(); 2344 const bool fMachineMenuShown = !m_pPaneChooser->isSingleGroupSelected(); 2345 m_pMachineMenuAction->setVisible(fMachineOrGroupMenuShown && fMachineMenuShown); 2346 m_pGroupMenuAction->setVisible(fMachineOrGroupMenuShown && !fMachineMenuShown); 2347 2348 /* Hide action shortcuts: */ 2349 if (!fMachineMenuShown) 2350 foreach (UIAction *pAction, m_machineActions) 2351 pAction->hideShortcut(); 2352 if (fMachineMenuShown) 2353 foreach (UIAction *pAction, m_groupActions) 2354 pAction->hideShortcut(); 2355 2356 /* Update actions visibility: */ 2357 foreach (UIAction *pAction, m_machineActions) 2358 pAction->setVisible(fMachineOrGroupMenuShown); 2359 2360 /* Show what should be shown: */ 2361 if (fMachineMenuShown) 2362 foreach (UIAction *pAction, m_machineActions) 2363 pAction->showShortcut(); 2364 if (!fMachineMenuShown) 2365 foreach (UIAction *pAction, m_groupActions) 2366 pAction->showShortcut(); 2367 } 2368 2369 void UIVirtualBoxManager::updateActionsAppearance() 2370 { 2371 /* Get current items: */ 2372 QList<UIVirtualMachineItem*> items = currentItems(); 2373 2374 /* Enable/disable group actions: */ 2375 actionPool()->action(UIActionIndexST_M_Group_S_Rename)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Rename, items)); 2376 actionPool()->action(UIActionIndexST_M_Group_S_Remove)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Remove, items)); 2377 actionPool()->action(UIActionIndexST_M_Group_T_Pause)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_T_Pause, items)); 2378 actionPool()->action(UIActionIndexST_M_Group_S_Reset)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Reset, items)); 2379 actionPool()->action(UIActionIndexST_M_Group_S_Discard)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Discard, items)); 2380 actionPool()->action(UIActionIndexST_M_Group_S_ShowLogDialog)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_ShowLogDialog, items)); 2381 actionPool()->action(UIActionIndexST_M_Group_S_Refresh)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Refresh, items)); 2382 actionPool()->action(UIActionIndexST_M_Group_S_ShowInFileManager)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_ShowInFileManager, items)); 2383 actionPool()->action(UIActionIndexST_M_Group_S_CreateShortcut)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_CreateShortcut, items)); 2384 actionPool()->action(UIActionIndexST_M_Group_S_Sort)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_S_Sort, items)); 2385 2386 /* Enable/disable machine actions: */ 2387 actionPool()->action(UIActionIndexST_M_Machine_S_Settings)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Settings, items)); 2388 actionPool()->action(UIActionIndexST_M_Machine_S_Clone)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Clone, items)); 2389 actionPool()->action(UIActionIndexST_M_Machine_S_Move)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Move, items)); 2390 actionPool()->action(UIActionIndexST_M_Machine_S_Remove)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Remove, items)); 2391 actionPool()->action(UIActionIndexST_M_Machine_S_AddGroup)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_AddGroup, items)); 2392 actionPool()->action(UIActionIndexST_M_Machine_T_Pause)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_T_Pause, items)); 2393 actionPool()->action(UIActionIndexST_M_Machine_S_Reset)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Reset, items)); 2394 actionPool()->action(UIActionIndexST_M_Machine_S_Discard)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Discard, items)); 2395 actionPool()->action(UIActionIndexST_M_Machine_S_ShowLogDialog)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_ShowLogDialog, items)); 2396 actionPool()->action(UIActionIndexST_M_Machine_S_Refresh)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_Refresh, items)); 2397 actionPool()->action(UIActionIndexST_M_Machine_S_ShowInFileManager)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_ShowInFileManager, items)); 2398 actionPool()->action(UIActionIndexST_M_Machine_S_CreateShortcut)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_CreateShortcut, items)); 2399 actionPool()->action(UIActionIndexST_M_Machine_S_SortParent)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_S_SortParent, items)); 2400 2401 /* Enable/disable group-start-or-show actions: */ 2402 actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow, items)); 2403 actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartNormal)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow_S_StartNormal, items)); 2404 actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartHeadless)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow_S_StartHeadless, items)); 2405 actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow_S_StartDetachable)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_StartOrShow_S_StartDetachable, items)); 2406 2407 /* Enable/disable machine-start-or-show actions: */ 2408 actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_StartOrShow, items)); 2409 actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartNormal)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_StartOrShow_S_StartNormal, items)); 2410 actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartHeadless)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_StartOrShow_S_StartHeadless, items)); 2411 actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable, items)); 2412 2413 /* Enable/disable group-close actions: */ 2414 actionPool()->action(UIActionIndexST_M_Group_M_Close)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_Close, items)); 2415 actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Detach)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_Close_S_Detach, items)); 2416 actionPool()->action(UIActionIndexST_M_Group_M_Close_S_SaveState)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_Close_S_SaveState, items)); 2417 actionPool()->action(UIActionIndexST_M_Group_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_Close_S_Shutdown, items)); 2418 actionPool()->action(UIActionIndexST_M_Group_M_Close_S_PowerOff)->setEnabled(isActionEnabled(UIActionIndexST_M_Group_M_Close_S_PowerOff, items)); 2419 2420 /* Enable/disable machine-close actions: */ 2421 actionPool()->action(UIActionIndexST_M_Machine_M_Close)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Close, items)); 2422 actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Detach)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_Detach, items)); 2423 actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_SaveState)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_SaveState, items)); 2424 actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_Shutdown)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_Shutdown, items)); 2425 actionPool()->action(UIActionIndexST_M_Machine_M_Close_S_PowerOff)->setEnabled(isActionEnabled(UIActionIndexST_M_Machine_M_Close_S_PowerOff, items)); 2426 2427 /* Get current item: */ 2428 UIVirtualMachineItem *pItem = currentItem(); 2429 2430 /* Start/Show action is deremined by 1st item: */ 2431 if (pItem && pItem->accessible()) 2432 { 2433 actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow)->toActionPolymorphicMenu()->setState(UIVirtualMachineItem::isItemPoweredOff(pItem) ? 0 : 1); 2434 actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)->toActionPolymorphicMenu()->setState(UIVirtualMachineItem::isItemPoweredOff(pItem) ? 0 : 1); 2435 QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow))); 2436 if (pButton) 2437 pButton->setPopupMode(UIVirtualMachineItem::isItemPoweredOff(pItem) ? QToolButton::MenuButtonPopup : QToolButton::DelayedPopup); 2438 } 2439 else 2440 { 2441 actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow)->toActionPolymorphicMenu()->setState(0); 2442 actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow)->toActionPolymorphicMenu()->setState(0); 2443 QToolButton *pButton = qobject_cast<QToolButton*>(m_pToolBar->widgetForAction(actionPool()->action(UIActionIndexST_M_Machine_M_StartOrShow))); 2444 if (pButton) 2445 pButton->setPopupMode(UIVirtualMachineItem::isItemPoweredOff(pItem) ? QToolButton::MenuButtonPopup : QToolButton::DelayedPopup); 2446 } 2447 2448 /* Pause/Resume action is deremined by 1st started item: */ 2449 UIVirtualMachineItem *pFirstStartedAction = 0; 2450 foreach (UIVirtualMachineItem *pSelectedItem, items) 2451 { 2452 if (UIVirtualMachineItem::isItemStarted(pSelectedItem)) 2453 { 2454 pFirstStartedAction = pSelectedItem; 2455 break; 2456 } 2457 } 2458 /* Update the group Pause/Resume action appearance: */ 2459 actionPool()->action(UIActionIndexST_M_Group_T_Pause)->blockSignals(true); 2460 actionPool()->action(UIActionIndexST_M_Group_T_Pause)->setChecked(pFirstStartedAction && UIVirtualMachineItem::isItemPaused(pFirstStartedAction)); 2461 actionPool()->action(UIActionIndexST_M_Group_T_Pause)->retranslateUi(); 2462 actionPool()->action(UIActionIndexST_M_Group_T_Pause)->blockSignals(false); 2463 /* Update the machine Pause/Resume action appearance: */ 2464 actionPool()->action(UIActionIndexST_M_Machine_T_Pause)->blockSignals(true); 2465 actionPool()->action(UIActionIndexST_M_Machine_T_Pause)->setChecked(pFirstStartedAction && UIVirtualMachineItem::isItemPaused(pFirstStartedAction)); 2466 actionPool()->action(UIActionIndexST_M_Machine_T_Pause)->retranslateUi(); 2467 actionPool()->action(UIActionIndexST_M_Machine_T_Pause)->blockSignals(false); 2468 2469 /* Enable/disable tools actions: */ 2470 actionPool()->action(UIActionIndexST_M_Tools_M_Machine)->setEnabled(isActionEnabled(UIActionIndexST_M_Tools_M_Machine, items)); 2471 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Details)->setEnabled(isActionEnabled(UIActionIndexST_M_Tools_M_Machine_S_Details, items)); 2472 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots)->setEnabled(isActionEnabled(UIActionIndexST_M_Tools_M_Machine_S_Snapshots, items)); 2473 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_LogViewer)->setEnabled(isActionEnabled(UIActionIndexST_M_Tools_M_Machine_S_LogViewer, items)); 2474 } 2475 2476 bool UIVirtualBoxManager::isActionEnabled(int iActionIndex, const QList<UIVirtualMachineItem*> &items) 2477 { 2478 /* No actions enabled for empty item list: */ 2479 if (items.isEmpty()) 2480 return false; 2481 2482 /* Get first item: */ 2483 UIVirtualMachineItem *pItem = items.first(); 2484 2485 /* For known action types: */ 2486 switch (iActionIndex) 2487 { 2488 case UIActionIndexST_M_Group_S_Rename: 2489 case UIActionIndexST_M_Group_S_Remove: 2490 { 2491 return !m_pPaneChooser->isGroupSavingInProgress() && 2492 isItemsPoweredOff(items); 2493 } 2494 case UIActionIndexST_M_Group_S_Sort: 2495 { 2496 return !m_pPaneChooser->isGroupSavingInProgress() && 2497 m_pPaneChooser->isSingleGroupSelected(); 2498 } 2499 case UIActionIndexST_M_Machine_S_Settings: 2500 { 2501 return !m_pPaneChooser->isGroupSavingInProgress() && 2502 items.size() == 1 && 2503 pItem->configurationAccessLevel() != ConfigurationAccessLevel_Null; 2504 } 2505 case UIActionIndexST_M_Machine_S_Clone: 2506 case UIActionIndexST_M_Machine_S_Move: 2507 { 2508 return !m_pPaneChooser->isGroupSavingInProgress() && 2509 items.size() == 1 && 2510 UIVirtualMachineItem::isItemEditable(pItem); 2511 } 2512 case UIActionIndexST_M_Machine_S_Remove: 2513 { 2514 return !m_pPaneChooser->isGroupSavingInProgress() && 2515 isAtLeastOneItemRemovable(items); 2516 } 2517 case UIActionIndexST_M_Machine_S_AddGroup: 2518 { 2519 return !m_pPaneChooser->isGroupSavingInProgress() && 2520 !m_pPaneChooser->isAllItemsOfOneGroupSelected() && 2521 isItemsPoweredOff(items); 2522 } 2523 case UIActionIndexST_M_Group_M_StartOrShow: 2524 case UIActionIndexST_M_Group_M_StartOrShow_S_StartNormal: 2525 case UIActionIndexST_M_Group_M_StartOrShow_S_StartHeadless: 2526 case UIActionIndexST_M_Group_M_StartOrShow_S_StartDetachable: 2527 case UIActionIndexST_M_Machine_M_StartOrShow: 2528 case UIActionIndexST_M_Machine_M_StartOrShow_S_StartNormal: 2529 case UIActionIndexST_M_Machine_M_StartOrShow_S_StartHeadless: 2530 case UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable: 2531 { 2532 return !m_pPaneChooser->isGroupSavingInProgress() && 2533 isAtLeastOneItemCanBeStartedOrShown(items); 2534 } 2535 case UIActionIndexST_M_Group_S_Discard: 2536 case UIActionIndexST_M_Machine_S_Discard: 2537 { 2538 return !m_pPaneChooser->isGroupSavingInProgress() && 2539 isAtLeastOneItemDiscardable(items); 2540 } 2541 case UIActionIndexST_M_Group_S_ShowLogDialog: 2542 case UIActionIndexST_M_Machine_S_ShowLogDialog: 2543 { 2544 return isAtLeastOneItemAccessible(items); 2545 } 2546 case UIActionIndexST_M_Group_T_Pause: 2547 case UIActionIndexST_M_Machine_T_Pause: 2548 { 2549 return isAtLeastOneItemStarted(items); 2550 } 2551 case UIActionIndexST_M_Group_S_Reset: 2552 case UIActionIndexST_M_Machine_S_Reset: 2553 { 2554 return isAtLeastOneItemRunning(items); 2555 } 2556 case UIActionIndexST_M_Group_S_Refresh: 2557 case UIActionIndexST_M_Machine_S_Refresh: 2558 { 2559 return isAtLeastOneItemInaccessible(items); 2560 } 2561 case UIActionIndexST_M_Group_S_ShowInFileManager: 2562 case UIActionIndexST_M_Machine_S_ShowInFileManager: 2563 { 2564 return isAtLeastOneItemAccessible(items); 2565 } 2566 case UIActionIndexST_M_Machine_S_SortParent: 2567 { 2568 return !m_pPaneChooser->isGroupSavingInProgress(); 2569 } 2570 case UIActionIndexST_M_Group_S_CreateShortcut: 2571 case UIActionIndexST_M_Machine_S_CreateShortcut: 2572 { 2573 return isAtLeastOneItemSupportsShortcuts(items); 2574 } 2575 case UIActionIndexST_M_Group_M_Close: 2576 case UIActionIndexST_M_Machine_M_Close: 2577 { 2578 return isAtLeastOneItemStarted(items); 2579 } 2580 case UIActionIndexST_M_Group_M_Close_S_Detach: 2581 case UIActionIndexST_M_Machine_M_Close_S_Detach: 2582 { 2583 return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items); 2584 } 2585 case UIActionIndexST_M_Group_M_Close_S_SaveState: 2586 case UIActionIndexST_M_Machine_M_Close_S_SaveState: 2587 { 2588 return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items); 2589 } 2590 case UIActionIndexST_M_Group_M_Close_S_Shutdown: 2591 case UIActionIndexST_M_Machine_M_Close_S_Shutdown: 2592 { 2593 return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items) && 2594 isAtLeastOneItemAbleToShutdown(items); 2595 } 2596 case UIActionIndexST_M_Group_M_Close_S_PowerOff: 2597 case UIActionIndexST_M_Machine_M_Close_S_PowerOff: 2598 { 2599 return isActionEnabled(UIActionIndexST_M_Machine_M_Close, items); 2600 } 2601 case UIActionIndexST_M_Tools_M_Machine: 2602 case UIActionIndexST_M_Tools_M_Machine_S_Details: 2603 case UIActionIndexST_M_Tools_M_Machine_S_Snapshots: 2604 case UIActionIndexST_M_Tools_M_Machine_S_LogViewer: 2605 { 2606 return pItem->accessible(); 2607 } 2608 default: 2609 break; 2610 } 2611 2612 /* Unknown actions are disabled: */ 2613 return false; 2614 } 2615 2616 /* static */ 2617 bool UIVirtualBoxManager::isItemsPoweredOff(const QList<UIVirtualMachineItem*> &items) 2618 { 2619 foreach (UIVirtualMachineItem *pItem, items) 2620 if (!UIVirtualMachineItem::isItemPoweredOff(pItem)) 2621 return false; 2622 return true; 2623 } 2624 2625 /* static */ 2626 bool UIVirtualBoxManager::isAtLeastOneItemAbleToShutdown(const QList<UIVirtualMachineItem*> &items) 2627 { 2628 /* Enumerate all the passed items: */ 2629 foreach (UIVirtualMachineItem *pItem, items) 2630 { 2631 /* Skip non-running machines: */ 2632 if (!UIVirtualMachineItem::isItemRunning(pItem)) 2633 continue; 2634 /* Skip session failures: */ 2635 CSession session = vboxGlobal().openExistingSession(pItem->id()); 2636 if (session.isNull()) 2637 continue; 2638 /* Skip console failures: */ 2639 CConsole console = session.GetConsole(); 2640 if (console.isNull()) 2641 { 2642 /* Do not forget to release machine: */ 2643 session.UnlockMachine(); 2644 continue; 2645 } 2646 /* Is the guest entered ACPI mode? */ 2647 bool fGuestEnteredACPIMode = console.GetGuestEnteredACPIMode(); 2648 /* Do not forget to release machine: */ 2649 session.UnlockMachine(); 2650 /* True if the guest entered ACPI mode: */ 2651 if (fGuestEnteredACPIMode) 2652 return true; 2653 } 2654 /* False by default: */ 2655 return false; 2656 } 2657 2658 /* static */ 2659 bool UIVirtualBoxManager::isAtLeastOneItemSupportsShortcuts(const QList<UIVirtualMachineItem*> &items) 2660 { 2661 foreach (UIVirtualMachineItem *pItem, items) 2662 { 2663 if ( pItem->accessible() 2664 #ifdef VBOX_WS_MAC 2665 /* On Mac OS X this are real alias files, which don't work with the old legacy xml files. */ 2666 && pItem->settingsFile().endsWith(".vbox", Qt::CaseInsensitive) 2667 #endif 2668 ) 2669 return true; 2670 } 2671 return false; 2672 } 2673 2674 /* static */ 2675 bool UIVirtualBoxManager::isAtLeastOneItemAccessible(const QList<UIVirtualMachineItem*> &items) 2676 { 2677 foreach (UIVirtualMachineItem *pItem, items) 2678 if (pItem->accessible()) 2679 return true; 2680 return false; 2681 } 2682 2683 /* static */ 2684 bool UIVirtualBoxManager::isAtLeastOneItemInaccessible(const QList<UIVirtualMachineItem*> &items) 2685 { 2686 foreach (UIVirtualMachineItem *pItem, items) 2687 if (!pItem->accessible()) 2688 return true; 2689 return false; 2690 } 2691 2692 /* static */ 2693 bool UIVirtualBoxManager::isAtLeastOneItemRemovable(const QList<UIVirtualMachineItem*> &items) 2694 { 2695 foreach (UIVirtualMachineItem *pItem, items) 2696 if (!pItem->accessible() || UIVirtualMachineItem::isItemEditable(pItem)) 2697 return true; 2698 return false; 2699 } 2700 2701 /* static */ 2702 bool UIVirtualBoxManager::isAtLeastOneItemCanBeStarted(const QList<UIVirtualMachineItem*> &items) 2703 { 2704 foreach (UIVirtualMachineItem *pItem, items) 2705 { 2706 if (UIVirtualMachineItem::isItemPoweredOff(pItem) && UIVirtualMachineItem::isItemEditable(pItem)) 2707 return true; 2708 } 2709 return false; 2710 } 2711 2712 /* static */ 2713 bool UIVirtualBoxManager::isAtLeastOneItemCanBeShown(const QList<UIVirtualMachineItem*> &items) 2714 { 2715 foreach (UIVirtualMachineItem *pItem, items) 2716 { 2717 if (UIVirtualMachineItem::isItemStarted(pItem) && (pItem->canSwitchTo() || UIVirtualMachineItem::isItemRunningHeadless(pItem))) 2718 return true; 2719 } 2720 return false; 2721 } 2722 2723 /* static */ 2724 bool UIVirtualBoxManager::isAtLeastOneItemCanBeStartedOrShown(const QList<UIVirtualMachineItem*> &items) 2725 { 2726 foreach (UIVirtualMachineItem *pItem, items) 2727 { 2728 if ((UIVirtualMachineItem::isItemPoweredOff(pItem) && UIVirtualMachineItem::isItemEditable(pItem)) || 2729 (UIVirtualMachineItem::isItemStarted(pItem) && (pItem->canSwitchTo() || UIVirtualMachineItem::isItemRunningHeadless(pItem)))) 2730 return true; 2731 } 2732 return false; 2733 } 2734 2735 /* static */ 2736 bool UIVirtualBoxManager::isAtLeastOneItemDiscardable(const QList<UIVirtualMachineItem*> &items) 2737 { 2738 foreach (UIVirtualMachineItem *pItem, items) 2739 if (UIVirtualMachineItem::isItemSaved(pItem) && UIVirtualMachineItem::isItemEditable(pItem)) 2740 return true; 2741 return false; 2742 } 2743 2744 /* static */ 2745 bool UIVirtualBoxManager::isAtLeastOneItemStarted(const QList<UIVirtualMachineItem*> &items) 2746 { 2747 foreach (UIVirtualMachineItem *pItem, items) 2748 if (UIVirtualMachineItem::isItemStarted(pItem)) 2749 return true; 2750 return false; 2751 } 2752 2753 /* static */ 2754 bool UIVirtualBoxManager::isAtLeastOneItemRunning(const QList<UIVirtualMachineItem*> &items) 2755 { 2756 foreach (UIVirtualMachineItem *pItem, items) 2757 if (UIVirtualMachineItem::isItemRunning(pItem)) 2758 return true; 2759 return false; 2760 } 634 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h
r73457 r73492 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UIVirtualBoxManager class declaration.3 * VBox Qt GUI - UIVirtualBoxManagerWidget class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef ___UIVirtualBoxManager _h___19 #define ___UIVirtualBoxManager _h___18 #ifndef ___UIVirtualBoxManagerWidget_h___ 19 #define ___UIVirtualBoxManagerWidget_h___ 20 20 21 21 /* Qt includes: */ 22 #include <Q Url>22 #include <QWidget> 23 23 24 24 /* GUI includes: */ 25 #include "QIMainWindow.h"26 25 #include "QIWithRetranslateUI.h" 27 26 #include "UIToolPaneGlobal.h" 28 27 #include "UIToolPaneMachine.h" 29 #include "VBoxGlobal.h"30 28 31 29 /* Forward declarations: */ 32 class QMenu;33 class QIManagerDialog;34 30 class QISplitter; 35 class UIAction;36 31 class UIActionPool; 37 32 class UIChooser; … … 40 35 class UIToolBar; 41 36 class UIToolbarTools; 37 class UIVirtualBoxManager; 42 38 class UIVirtualMachineItem; 43 39 44 /* Type definitions: */ 45 typedef QMap<QString, QIManagerDialog*> VMLogViewerMap; 46 47 /** Singleton QIMainWindow extension used as VirtualBox Manager instance. */ 48 class UIVirtualBoxManager : public QIWithRetranslateUI<QIMainWindow> 40 /** QWidget extension used as VirtualBox Manager Widget instance. */ 41 class UIVirtualBoxManagerWidget : public QIWithRetranslateUI<QWidget> 49 42 { 50 43 Q_OBJECT; … … 52 45 signals: 53 46 54 /** Notifies listeners about this window remapped to another screen. */ 55 void sigWindowRemapped(); 47 /** Notifies about Chooser-pane index change. */ 48 void sigChooserPaneIndexChange(); 49 /** Notifies about Chooser-pane group saving change. */ 50 void sigGroupSavingStateChanged(); 51 52 /** Notifies aboud Details-pane link clicked. */ 53 void sigMachineSettingsLinkClicked(const QString &strCategory, const QString &strControl, const QString &strId); 54 55 /** Notifies about Tool type switch. */ 56 void sigToolsTypeSwitch(); 56 57 57 58 public: 58 59 59 /** Singleton constructor. */ 60 static void create(); 61 /** Singleton destructor. */ 62 static void destroy(); 63 /** Singleton instance provider. */ 64 static UIVirtualBoxManager *instance() { return s_pInstance; } 65 66 /** Returns the action-pool instance. */ 67 UIActionPool *actionPool() const { return m_pActionPool; } 60 /** Constructs VirtualBox Manager widget. */ 61 UIVirtualBoxManagerWidget(UIVirtualBoxManager *pParent); 62 /** Destructs VirtualBox Manager widget. */ 63 virtual ~UIVirtualBoxManagerWidget() /* override */; 64 65 /** @name Common stuff. 66 * @{ */ 67 /** Returns the action-pool instance. */ 68 UIActionPool *actionPool() const { return m_pActionPool; } 69 70 /** Returns current-item. */ 71 UIVirtualMachineItem *currentItem() const; 72 /** Returns a list of current-items. */ 73 QList<UIVirtualMachineItem*> currentItems() const; 74 75 /** Returns whether group saving is in progress. */ 76 bool isGroupSavingInProgress() const; 77 /** Returns whether all items of one group is selected. */ 78 bool isAllItemsOfOneGroupSelected() const; 79 /** Returns whether single group is selected. */ 80 bool isSingleGroupSelected() const; 81 82 /** Returns whether Machine tool of passed @a enmType is opened. */ 83 bool isToolOpened(ToolTypeMachine enmType) const; 84 /** Returns whether Global tool of passed @a enmType is opened. */ 85 bool isToolOpened(ToolTypeGlobal enmType) const; 86 /** Switches to Machine tool of passed @a enmType. */ 87 void switchToTool(ToolTypeMachine enmType); 88 /** Switches to Global tool of passed @a enmType. */ 89 void switchToTool(ToolTypeGlobal enmType); 90 /** @} */ 91 92 public slots: 93 94 /** @name Common stuff. 95 * @{ */ 96 /** Handles context-menu request for passed @a position. */ 97 void sltHandleContextMenuRequest(const QPoint &position); 98 /** @} */ 68 99 69 100 protected: 70 101 71 /** Constructs VirtualBox Manager. */72 UIVirtualBoxManager();73 /** Destructs VirtualBox Manager. */74 virtual ~UIVirtualBoxManager() /* override */;75 76 /** Returns whether the window should be maximized when geometry being restored. */77 virtual bool shouldBeMaximized() const /* override */;78 79 102 /** @name Event handling stuff. 80 103 * @{ */ 81 #ifdef VBOX_WS_MAC82 /** Mac OS X: Preprocesses any @a pEvent for passed @a pObject. */83 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;84 #endif85 86 104 /** Handles translation event. */ 87 105 virtual void retranslateUi() /* override */; 88 106 89 /** Handles any Qt @a pEvent. */90 virtual bool event(QEvent *pEvent) /* override */;91 107 /** Handles show @a pEvent. */ 92 108 virtual void showEvent(QShowEvent *pEvent) /* override */; 93 109 /** Handles first show @a pEvent. */ 94 110 virtual void polishEvent(QShowEvent *pEvent) /* override */; 95 /** Handles close @a pEvent. */96 virtual void closeEvent(QCloseEvent *pEvent) /* override */;97 111 /** @} */ 98 112 … … 104 118 void sltHandlePolishEvent(); 105 119 106 #if QT_VERSION == 0107 /** Stupid moc does not warn if it cannot find headers! */108 void QT_VERSION_NOT_DEFINED109 #elif defined(VBOX_WS_X11)110 /** Handles host-screen available-area change. */111 void sltHandleHostScreenAvailableAreaChange();112 #endif /* VBOX_WS_X11 */113 114 /** Handles context-menu request for passed @a position. */115 void sltHandleContextMenuRequest(const QPoint &position);116 117 120 /** Handles signal about Chooser-pane index change. 118 121 * @param fUpdateDetails Brings whether details should be updated. 119 * @param fUpdateSnapshots Brings whether tools should be updated. */ 122 * @param fUpdateSnapshots Brings whether snapshots should be updated. 123 * @param fUpdateLogViewer Brings whether log-viewer should be updated. */ 120 124 void sltHandleChooserPaneIndexChange(bool fUpdateDetails = true, 121 125 bool fUpdateSnapshots = true, 122 126 bool fUpdateLogViewer = true); 123 124 /** Handles signal about medium-enumeration finished. */ 125 void sltHandleMediumEnumerationFinish(); 126 127 /** Handles call to open a @a list of URLs. */ 128 void sltHandleOpenUrlCall(QList<QUrl> list = QList<QUrl>()); 129 130 /** Handles signal about group saving progress change. */ 131 void sltHandleGroupSavingProgressChange(); 132 /** @} */ 133 134 /** @name CVirtualBox event handling stuff. 135 * @{ */ 136 /** Handles CVirtualBox event about state change for machine with @a strID. */ 137 void sltHandleStateChange(const QString &strID); 138 /** @} */ 139 140 /** @name File menu stuff. 141 * @{ */ 142 /** Handles call to open Virtual Medium Manager window. */ 143 void sltOpenVirtualMediumManagerWindow(); 144 /** Handles call to close Virtual Medium Manager window. */ 145 void sltCloseVirtualMediumManagerWindow(); 146 147 /** Handles call to open Host Network Manager window. */ 148 void sltOpenHostNetworkManagerWindow(); 149 /** Handles call to close Host Network Manager window. */ 150 void sltCloseHostNetworkManagerWindow(); 151 152 /** Handles call to close a Machine LogViewer window. */ 153 void sltCloseLogViewerWindow(); 154 155 /** Handles call to open Import Appliance wizard. 156 * @param strFileName can bring the name of file to import appliance from. */ 157 void sltOpenImportApplianceWizard(const QString &strFileName = QString()); 158 /** Handles call to open Export Appliance wizard. */ 159 void sltOpenExportApplianceWizard(); 160 161 #ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI 162 /** Handles call to open Extra-data Manager window. */ 163 void sltOpenExtraDataManagerWindow(); 164 #endif 165 166 /** Handles call to open Preferences dialog. */ 167 void sltOpenPreferencesDialog(); 168 169 /** Handles call to exit application. */ 170 void sltPerformExit(); 171 /** @} */ 172 173 /** @name Machine menu stuff. 174 * @{ */ 175 /** Handles call to open Add Machine dialog. 176 * @param strFileName can bring the name of file to add machine from. */ 177 void sltOpenAddMachineDialog(const QString &strFileName = QString()); 178 179 /** Handles call to open Machine Settings dialog. 180 * @param strCategory can bring the settings category to start from. 181 * @param strControl can bring the widget of the page to focus. 182 * @param strID can bring the ID of machine to manage. */ 183 void sltOpenMachineSettingsDialog(QString strCategory = QString(), 184 QString strControl = QString(), 185 const QString &strID = QString()); 186 187 /** Handles call to open Clone Machine wizard. */ 188 void sltOpenCloneMachineWizard(); 189 190 /** Handles the Move Machine action. */ 191 void sltPerformMachineMove(); 192 193 /** Handles call to start or show machine. */ 194 void sltPerformStartOrShowMachine(); 195 /** Handles call to start machine in normal mode. */ 196 void sltPerformStartMachineNormal(); 197 /** Handles call to start machine in headless mode. */ 198 void sltPerformStartMachineHeadless(); 199 /** Handles call to start machine in detachable mode. */ 200 void sltPerformStartMachineDetachable(); 201 202 /** Handles call to discard machine state. */ 203 void sltPerformDiscardMachineState(); 204 205 /** Handles call to @a fPause or resume machine otherwise. */ 206 void sltPerformPauseOrResumeMachine(bool fPause); 207 208 /** Handles call to reset machine. */ 209 void sltPerformResetMachine(); 210 211 /** Handles call to detach machine UI. */ 212 void sltPerformDetachMachineUI(); 213 /** Handles call to save machine state. */ 214 void sltPerformSaveMachineState(); 215 /** Handles call to ask machine for shutdown. */ 216 void sltPerformShutdownMachine(); 217 /** Handles call to power machine off. */ 218 void sltPerformPowerOffMachine(); 219 220 /** Handles call to open machine Log dialog. */ 221 void sltOpenMachineLogDialog(); 222 223 /** Handles call to show machine in File Manager. */ 224 void sltShowMachineInFileManager(); 225 226 /** Handles call to create machine shortcut. */ 227 void sltPerformCreateMachineShortcut(); 228 229 /** Handles call to show group Close menu. */ 230 void sltGroupCloseMenuAboutToShow(); 231 /** Handles call to show machine Close menu. */ 232 void sltMachineCloseMenuAboutToShow(); 127 /** Handles signal about Chooser-pane index change the default way. */ 128 void sltHandleChooserPaneIndexChangeDefault() { sltHandleChooserPaneIndexChange(); } 233 129 /** @} */ 234 130 … … 256 152 private: 257 153 258 /** Returns current-item. */259 UIVirtualMachineItem *currentItem() const;260 /** Returns a list of current-items. */261 QList<UIVirtualMachineItem*> currentItems() const;262 263 154 /** @name Prepare/Cleanup cascade. 264 155 * @{ */ 265 156 /** Prepares window. */ 266 157 void prepare(); 267 /** Prepares icon. */268 void prepareIcon();269 /** Prepares menu-bar. */270 void prepareMenuBar();271 /** Prepares @a pMenu File. */272 void prepareMenuFile(QMenu *pMenu);273 /** Prepares @a pMenu Group. */274 void prepareMenuGroup(QMenu *pMenu);275 /** Prepares @a pMenu Machine. */276 void prepareMenuMachine(QMenu *pMenu);277 /** Prepares @a pMenu Group => Start or Show. */278 void prepareMenuGroupStartOrShow(QMenu *pMenu);279 /** Prepares @a pMenu Machine => Start or Show. */280 void prepareMenuMachineStartOrShow(QMenu *pMenu);281 /** Prepares @a pMenu Group => Close. */282 void prepareMenuGroupClose(QMenu *pMenu);283 /** Prepares @a pMenu Machine => Close. */284 void prepareMenuMachineClose(QMenu *pMenu);285 /** Prepares status-bar. */286 void prepareStatusBar();287 158 /** Prepares toolbar. */ 288 159 void prepareToolbar(); … … 296 167 /** Saves settings. */ 297 168 void saveSettings(); 298 /** Cleanups connections. */299 void cleanupConnections();300 /** Cleanups menu-bar. */301 void cleanupMenuBar();302 169 /** Cleanups window. */ 303 170 void cleanup(); 304 171 /** @} */ 305 172 306 /** @name VM launching stuff.307 * @{ */308 /** Launches or shows virtual machines represented by passed @a items in corresponding @a enmLaunchMode (for launch). */309 void performStartOrShowVirtualMachines(const QList<UIVirtualMachineItem*> &items, VBoxGlobal::LaunchMode enmLaunchMode);310 /** @} */311 312 /** @name Action update stuff.313 * @{ */314 /** Performs update of actions visibility. */315 void updateActionsVisibility();316 /** Performs update of actions appearance. */317 void updateActionsAppearance();318 319 /** Returns whether the action with @a iActionIndex is enabled.320 * @param items used to calculate verdict about should the action be enabled. */321 bool isActionEnabled(int iActionIndex, const QList<UIVirtualMachineItem*> &items);322 323 /** Returns whether all passed @a items are powered off. */324 static bool isItemsPoweredOff(const QList<UIVirtualMachineItem*> &items);325 /** Returns whether at least one of passed @a items is able to shutdown. */326 static bool isAtLeastOneItemAbleToShutdown(const QList<UIVirtualMachineItem*> &items);327 /** Returns whether at least one of passed @a items supports shortcut creation. */328 static bool isAtLeastOneItemSupportsShortcuts(const QList<UIVirtualMachineItem*> &items);329 /** Returns whether at least one of passed @a items is accessible. */330 static bool isAtLeastOneItemAccessible(const QList<UIVirtualMachineItem*> &items);331 /** Returns whether at least one of passed @a items is inaccessible. */332 static bool isAtLeastOneItemInaccessible(const QList<UIVirtualMachineItem*> &items);333 /** Returns whether at least one of passed @a items is removable. */334 static bool isAtLeastOneItemRemovable(const QList<UIVirtualMachineItem*> &items);335 /** Returns whether at least one of passed @a items can be started. */336 static bool isAtLeastOneItemCanBeStarted(const QList<UIVirtualMachineItem*> &items);337 /** Returns whether at least one of passed @a items can be shown. */338 static bool isAtLeastOneItemCanBeShown(const QList<UIVirtualMachineItem*> &items);339 /** Returns whether at least one of passed @a items can be started or shown. */340 static bool isAtLeastOneItemCanBeStartedOrShown(const QList<UIVirtualMachineItem*> &items);341 /** Returns whether at least one of passed @a items can be discarded. */342 static bool isAtLeastOneItemDiscardable(const QList<UIVirtualMachineItem*> &items);343 /** Returns whether at least one of passed @a items is started. */344 static bool isAtLeastOneItemStarted(const QList<UIVirtualMachineItem*> &items);345 /** Returns whether at least one of passed @a items is running. */346 static bool isAtLeastOneItemRunning(const QList<UIVirtualMachineItem*> &items);347 /** @} */348 349 /** Holds the static instance. */350 static UIVirtualBoxManager *s_pInstance;351 352 173 /** Holds whether the dialog is polished. */ 353 bool m_fPolished : 1; 354 /** Holds whether first medium enumeration handled. */ 355 bool m_fFirstMediumEnumerationHandled : 1; 174 bool m_fPolished : 1; 356 175 357 176 /** Holds the action-pool instance. */ … … 390 209 /** Holds the Global Tools-pane instance. */ 391 210 UIToolPaneGlobal *m_pPaneToolsGlobal; 392 393 /** Holds the list of Group menu actions. */394 QList<UIAction*> m_groupActions;395 /** Holds the Group menu parent action. */396 QAction *m_pGroupMenuAction;397 398 /** Holds the list of Machine menu actions. */399 QList<UIAction*> m_machineActions;400 /** Holds the Machine menu parent action. */401 QAction *m_pMachineMenuAction;402 403 /** Holds the Virtual Media Manager window instance. */404 QIManagerDialog *m_pManagerVirtualMedia;405 /** Holds the Host Network Manager window instance. */406 QIManagerDialog *m_pManagerHostNetwork;407 /** Holds a map of (machineUUID, UIVMLogViewerDialog). */408 VMLogViewerMap m_logViewers;409 211 }; 410 212 411 #define gpManager UIVirtualBoxManager::instance() 412 413 #endif /* !___UIVirtualBoxManager_h___ */ 213 #endif /* !___UIVirtualBoxManagerWidget_h___ */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp
r73424 r73492 29 29 # include "UIChooserModel.h" 30 30 # include "UIChooserView.h" 31 # include "UIVirtualBoxManager .h"31 # include "UIVirtualBoxManagerWidget.h" 32 32 # include "VBoxGlobal.h" 33 33 … … 35 35 36 36 37 UIChooser::UIChooser(UIVirtualBoxManager *pParent)37 UIChooser::UIChooser(UIVirtualBoxManagerWidget *pParent) 38 38 : QWidget(pParent) 39 , m_p SelectorWindow(pParent)39 , m_pManagerWidget(pParent) 40 40 , m_pMainLayout(0) 41 41 , m_pChooserModel(0) … … 69 69 UIActionPool* UIChooser::actionPool() const 70 70 { 71 return selector()->actionPool();71 return managerWidget()->actionPool(); 72 72 } 73 73 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h
r73424 r73492 28 28 class UIVirtualMachineItem; 29 29 class QVBoxLayout; 30 class UIVirtualBoxManager ;30 class UIVirtualBoxManagerWidget; 31 31 class UIActionPool; 32 32 class UIChooserModel; … … 57 57 58 58 /* Constructor/destructor: */ 59 UIChooser(UIVirtualBoxManager *pParent);59 UIChooser(UIVirtualBoxManagerWidget *pParent); 60 60 ~UIChooser(); 61 61 62 /** Returns the selector-windowreference. */63 UIVirtualBoxManager * selector() const { return m_pSelectorWindow; }62 /** Returns the manager-widget reference. */ 63 UIVirtualBoxManagerWidget *managerWidget() const { return m_pManagerWidget; } 64 64 /** Returns the action-pool reference. */ 65 65 UIActionPool* actionPool() const; … … 92 92 void save(); 93 93 94 /** Holds the selector-windowreference. */95 UIVirtualBoxManager * m_pSelectorWindow;94 /** Holds the manager-widget reference. */ 95 UIVirtualBoxManagerWidget *m_pManagerWidget; 96 96 97 97 /* Variables: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp
r73424 r73492 45 45 # include "UIChooserHandlerKeyboard.h" 46 46 # include "UIWizardNewVM.h" 47 # include "UIVirtualBoxManager .h"47 # include "UIVirtualBoxManagerWidget.h" 48 48 # include "UIVirtualBoxEventHandler.h" 49 49 # include "UIModalWindowManager.h" … … 928 928 929 929 /* Use the "safe way" to open stack of Mac OS X Sheets: */ 930 QWidget *pWizardParent = windowManager().realParentWindow(m_pChooser-> selector());930 QWidget *pWizardParent = windowManager().realParentWindow(m_pChooser->managerWidget()); 931 931 UISafePointerWizardNewVM pWizard = new UIWizardNewVM(pWizardParent, strGroupName); 932 932 windowManager().registerNewParent(pWizard, pWizardParent);
Note:
See TracChangeset
for help on using the changeset viewer.