VirtualBox

Changeset 73492 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 3, 2018 3:30:44 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager UI: Split UIVirtualBoxManager class to actual manager and manager-widget classes.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r73425 r73492  
    751751        src/manager/UIToolPaneMachine.h \
    752752        src/manager/UIVirtualBoxManager.h \
     753        src/manager/UIVirtualBoxManagerWidget.h \
    753754        src/manager/UIVirtualMachineItem.h \
    754755        src/manager/UIWelcomePane.h \
     
    14271428        src/manager/UIToolPaneMachine.cpp \
    14281429        src/manager/UIVirtualBoxManager.cpp \
     1430        src/manager/UIVirtualBoxManagerWidget.cpp \
    14291431        src/manager/UIVirtualMachineItem.cpp \
    14301432        src/manager/UIWelcomePane.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r73457 r73492  
    2121
    2222/* Qt includes: */
    23 # include <QMenuBar>
    2423# include <QResizeEvent>
    2524# include <QStandardPaths>
    2625# include <QStatusBar>
    27 # include <QToolButton>
    28 # include <QTimer>
     26//# include <QToolButton>
    2927
    3028/* GUI includes: */
    3129# include "QIFileDialog.h"
    32 # include "QISplitter.h"
    3330# include "UIActionPoolSelector.h"
    3431# include "UIDesktopServices.h"
    35 # include "UIErrorString.h"
    3632# include "UIExtraDataManager.h"
    37 # include "UIChooser.h"
    3833# include "UIHostNetworkManager.h"
    3934# include "UIMedium.h"
     
    4237# include "UIModalWindowManager.h"
    4338# include "UIVirtualBoxManager.h"
     39# include "UIVirtualBoxManagerWidget.h"
    4440# include "UISettingsDialogSpecific.h"
    45 # include "UISlidingWidget.h"
    46 # include "UITabBar.h"
    47 # include "UIToolBar.h"
    4841# include "UIVMLogViewerDialog.h"
    4942# include "UIVirtualMachineItem.h"
    50 # include "UIToolPaneMachine.h"
    51 # include "UIToolbarTools.h"
    5243# ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    5344#  include "UIUpdateManager.h"
     
    119110    , m_fFirstMediumEnumerationHandled(false)
    120111    , 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)
    132112    , m_pGroupMenuAction(0)
    133113    , m_pMachineMenuAction(0)
     
    173153            break;
    174154    }
     155
    175156    /* Call to base-class: */
    176157    return QIWithRetranslateUI<QIMainWindow>::eventFilter(pObject, pEvent);
     
    191172#endif /* VBOX_BLEEDING_EDGE */
    192173    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_MAC
    198     // WORKAROUND:
    199     // There is a bug in Qt Cocoa which result in showing a "more arrow" when
    200     // the necessary size of the toolbar is increased. Also for some languages
    201     // the with doesn't match if the text increase. So manually adjust the size
    202     // after changing the text.
    203     m_pToolBar->updateLayout();
    204 #endif
    205174}
    206175
     
    251220            break;
    252221        }
    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 */
    265222        default:
    266223            break;
     
    287244void UIVirtualBoxManager::polishEvent(QShowEvent *)
    288245{
    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);
    295248}
    296249
     
    302255    /* Quit application: */
    303256    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     }
    328257}
    329258
     
    341270#endif /* VBOX_WS_X11 */
    342271
    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 {
    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             else
    424             if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Snapshots))
    425                 actionPool()->action(UIActionIndexST_M_Tools_M_Machine_S_Snapshots)->trigger();
    426             else
    427             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 (   fUpdateDetails
    433             && 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     else
    440     {
    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 gets
    445          * 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 
    460272void UIVirtualBoxManager::sltHandleMediumEnumerationFinish()
    461273{
     
    469281     * otherwise user sees everything himself: */
    470282    if (   m_pManagerVirtualMedia
    471         || m_pPaneToolsGlobal->isToolOpened(ToolTypeGlobal_VirtualMedia))
     283        || m_pWidget->isToolOpened(ToolTypeGlobal_VirtualMedia))
    472284        return;
    473285
     
    549361}
    550362
     363void UIVirtualBoxManager::sltHandleChooserPaneIndexChange()
     364{
     365    updateActionsVisibility();
     366    updateActionsAppearance();
     367}
     368
    551369void UIVirtualBoxManager::sltHandleGroupSavingProgressChange()
    552370{
     
    556374void UIVirtualBoxManager::sltHandleStateChange(const QString &)
    557375{
    558     /* Get current item: */
    559     UIVirtualMachineItem *pItem = currentItem();
    560 
    561     /* Make sure current item present: */
    562     if (!pItem)
    563         return;
    564 
    565     /* Update actions: */
    566376    updateActionsAppearance();
    567377}
     
    570380{
    571381    /* First check if instance of widget opened the embedded way: */
    572     if (m_pPaneToolsGlobal->isToolOpened(ToolTypeGlobal_VirtualMedia))
    573     {
    574         sltHandleToolOpenedGlobal(ToolTypeGlobal_VirtualMedia);
     382    if (m_pWidget->isToolOpened(ToolTypeGlobal_VirtualMedia))
     383    {
     384        m_pWidget->switchToTool(ToolTypeGlobal_VirtualMedia);
    575385        return;
    576386    }
     
    600410{
    601411    /* First check if instance of widget opened the embedded way: */
    602     if (m_pPaneToolsGlobal->isToolOpened(ToolTypeGlobal_HostNetwork))
    603     {
    604         sltHandleToolOpenedGlobal(ToolTypeGlobal_HostNetwork);
     412    if (m_pWidget->isToolOpened(ToolTypeGlobal_HostNetwork))
     413    {
     414        m_pWidget->switchToTool(ToolTypeGlobal_HostNetwork);
    605415        return;
    606416    }
     
    12011011
    12021012    /* First check if a logviewer is already opened in embedded mode: */
    1203     if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_LogViewer))
    1204     {
    1205         sltHandleToolOpenedMachine(ToolTypeMachine_LogViewer);
     1013    if (m_pWidget->isToolOpened(ToolTypeMachine_LogViewer))
     1014    {
     1015        m_pWidget->switchToTool(ToolTypeMachine_LogViewer);
    12061016        return;
    12071017    }
     
    13201130}
    13211131
    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     else
    1329 
    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_Details
    1364         && 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() const
    1398 {
    1399     return m_pPaneChooser->currentItem();
    1400 }
    1401 
    1402 QList<UIVirtualMachineItem*> UIVirtualBoxManager::currentItems() const
    1403 {
    1404     return m_pPaneChooser->currentItems();
    1405 }
    1406 
    14071132void UIVirtualBoxManager::prepare()
    14081133{
     
    14251150    prepareMenuBar();
    14261151    prepareStatusBar();
    1427     prepareToolbar();
    14281152    prepareWidgets();
    14291153    prepareConnections();
     
    14361160
    14371161#ifdef VBOX_WS_MAC
    1438     /* Enable unified toolbar: */
    1439     m_pToolBar->enableMacToolbar();
    1440 
    14411162    /* Beta label? */
    14421163    if (vboxGlobal().isBeta())
     
    14451166        ::darwinLabelWindow(this, &betaLabel, true);
    14461167    }
    1447 
    1448     /* General event filter: */
    1449     qApp->installEventFilter(this);
    14501168#endif /* VBOX_WS_MAC */
    1451 
    1452     /* Make sure current Chooser-pane index fetched: */
    1453     sltHandleChooserPaneIndexChange();
    14541169}
    14551170
     
    18801595}
    18811596
    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_MAC
    1901         // WORKAROUND:
    1902         // Actually Qt should do that itself but by some unknown reason it sometimes
    1903         // 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_MAC
    1969         // WORKAROUND:
    1970         // There is a bug in Qt Cocoa which result in showing a "more arrow" when
    1971         // the necessary size of the toolbar is increased. Also for some languages
    1972         // the with doesn't match if the text increase. So manually adjust the size
    1973         // after changing the text.
    1974         m_pToolBar->updateLayout();
    1975 #endif
    1976     }
    1977 }
    1978 
    19791597void UIVirtualBoxManager::prepareWidgets()
    19801598{
    19811599    /* Create central-widget: */
    1982     QWidget *pWidget = new QWidget;
    1983     AssertPtrReturnVoid(pWidget);
     1600    m_pWidget = new UIVirtualBoxManagerWidget(this);
     1601    if (m_pWidget)
    19841602    {
    19851603        /* 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    }
    20561606}
    20571607
     
    20601610#ifdef VBOX_WS_X11
    20611611    /* 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
    20641615
    20651616    /* 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);
    20701635
    20711636    /* '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);
    20761645#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);
    20781648#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);
    20811653
    20821654    /* '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);
    20911671
    20921672    /* '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);
    21041695
    21051696    /* '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);
    21091703
    21101704    /* '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);
    21141711
    21151712    /* '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);
    21211723
    21221724    /* '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);
    21611735}
    21621736
     
    21731747        restoreGeometry();
    21741748    }
    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_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
    2204         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     }
    22281749}
    22291750
    22301751void UIVirtualBoxManager::saveSettings()
    22311752{
    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 
    22491753    /* Save window geometry: */
    22501754    {
     
    22591763}
    22601764
    2261 void UIVirtualBoxManager::cleanupConnections()
    2262 {
    2263 #ifdef VBOX_WS_MAC
    2264     /* Tool-bar connections: */
    2265     ::darwinUnregisterForUnifiedToolbarContextMenuEvents(this);
    2266 #endif /* VBOX_WS_MAC */
     1765void UIVirtualBoxManager::cleanupWidgets()
     1766{
     1767    /* Deconfigure central-widget: */
     1768    setCentralWidget(0);
     1769    /* Destroy central-widget: */
     1770    delete m_pWidget;
     1771    m_pWidget = 0;
    22671772}
    22681773
     
    22881793
    22891794    /* Cleanup: */
    2290     cleanupConnections();
     1795    cleanupWidgets();
    22911796    cleanupMenuBar();
    22921797}
    22931798
     1799UIVirtualMachineItem *UIVirtualBoxManager::currentItem() const
     1800{
     1801    return m_pWidget->currentItem();
     1802}
     1803
     1804QList<UIVirtualMachineItem*> UIVirtualBoxManager::currentItems() const
     1805{
     1806    return m_pWidget->currentItems();
     1807}
     1808
     1809bool UIVirtualBoxManager::isGroupSavingInProgress() const
     1810{
     1811    return m_pWidget->isGroupSavingInProgress();
     1812}
     1813
     1814bool UIVirtualBoxManager::isAllItemsOfOneGroupSelected() const
     1815{
     1816    return m_pWidget->isAllItemsOfOneGroupSelected();
     1817}
     1818
     1819bool UIVirtualBoxManager::isSingleGroupSelected() const
     1820{
     1821    return m_pWidget->isSingleGroupSelected();
     1822}
     1823
    22941824void UIVirtualBoxManager::performStartOrShowVirtualMachines(const QList<UIVirtualMachineItem*> &items, VBoxGlobal::LaunchMode enmLaunchMode)
    22951825{
    22961826    /* Do nothing while group saving is in progress: */
    2297     if (m_pPaneChooser->isGroupSavingInProgress())
     1827    if (isGroupSavingInProgress())
    22981828        return;
    22991829
     
    23421872    /* Determine whether Machine or Group menu should be shown at all: */
    23431873    const bool fMachineOrGroupMenuShown = actionPool()->action(UIActionIndexST_M_Tools_T_Machine)->isChecked();
    2344     const bool fMachineMenuShown = !m_pPaneChooser->isSingleGroupSelected();
     1874    const bool fMachineMenuShown = !isSingleGroupSelected();
    23451875    m_pMachineMenuAction->setVisible(fMachineOrGroupMenuShown && fMachineMenuShown);
    23461876    m_pGroupMenuAction->setVisible(fMachineOrGroupMenuShown && !fMachineMenuShown);
     
    24331963        actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow)->toActionPolymorphicMenu()->setState(UIVirtualMachineItem::isItemPoweredOff(pItem) ? 0 : 1);
    24341964        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);
    24381969    }
    24391970    else
     
    24411972        actionPool()->action(UIActionIndexST_M_Group_M_StartOrShow)->toActionPolymorphicMenu()->setState(0);
    24421973        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);
    24461978    }
    24471979
     
    24892021        case UIActionIndexST_M_Group_S_Remove:
    24902022        {
    2491             return !m_pPaneChooser->isGroupSavingInProgress() &&
     2023            return !isGroupSavingInProgress() &&
    24922024                   isItemsPoweredOff(items);
    24932025        }
    24942026        case UIActionIndexST_M_Group_S_Sort:
    24952027        {
    2496             return !m_pPaneChooser->isGroupSavingInProgress() &&
    2497                    m_pPaneChooser->isSingleGroupSelected();
     2028            return !isGroupSavingInProgress() &&
     2029                   isSingleGroupSelected();
    24982030        }
    24992031        case UIActionIndexST_M_Machine_S_Settings:
    25002032        {
    2501             return !m_pPaneChooser->isGroupSavingInProgress() &&
     2033            return !isGroupSavingInProgress() &&
    25022034                   items.size() == 1 &&
    25032035                   pItem->configurationAccessLevel() != ConfigurationAccessLevel_Null;
     
    25062038        case UIActionIndexST_M_Machine_S_Move:
    25072039        {
    2508             return !m_pPaneChooser->isGroupSavingInProgress() &&
     2040            return !isGroupSavingInProgress() &&
    25092041                   items.size() == 1 &&
    25102042                   UIVirtualMachineItem::isItemEditable(pItem);
     
    25122044        case UIActionIndexST_M_Machine_S_Remove:
    25132045        {
    2514             return !m_pPaneChooser->isGroupSavingInProgress() &&
     2046            return !isGroupSavingInProgress() &&
    25152047                   isAtLeastOneItemRemovable(items);
    25162048        }
    25172049        case UIActionIndexST_M_Machine_S_AddGroup:
    25182050        {
    2519             return !m_pPaneChooser->isGroupSavingInProgress() &&
    2520                    !m_pPaneChooser->isAllItemsOfOneGroupSelected() &&
     2051            return !isGroupSavingInProgress() &&
     2052                   !isAllItemsOfOneGroupSelected() &&
    25212053                   isItemsPoweredOff(items);
    25222054        }
     
    25302062        case UIActionIndexST_M_Machine_M_StartOrShow_S_StartDetachable:
    25312063        {
    2532             return !m_pPaneChooser->isGroupSavingInProgress() &&
     2064            return !isGroupSavingInProgress() &&
    25332065                   isAtLeastOneItemCanBeStartedOrShown(items);
    25342066        }
     
    25362068        case UIActionIndexST_M_Machine_S_Discard:
    25372069        {
    2538             return !m_pPaneChooser->isGroupSavingInProgress() &&
     2070            return !isGroupSavingInProgress() &&
    25392071                   isAtLeastOneItemDiscardable(items);
    25402072        }
     
    25662098        case UIActionIndexST_M_Machine_S_SortParent:
    25672099        {
    2568             return !m_pPaneChooser->isGroupSavingInProgress();
     2100            return !isGroupSavingInProgress();
    25692101        }
    25702102        case UIActionIndexST_M_Group_S_CreateShortcut:
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.h

    r73457 r73492  
    2525#include "QIMainWindow.h"
    2626#include "QIWithRetranslateUI.h"
    27 #include "UIToolPaneGlobal.h"
    28 #include "UIToolPaneMachine.h"
    2927#include "VBoxGlobal.h"
    3028
     
    3230class QMenu;
    3331class QIManagerDialog;
    34 class QISplitter;
    3532class UIAction;
    3633class UIActionPool;
    37 class UIChooser;
    38 class UISlidingWidget;
    39 class UITabBar;
    40 class UIToolBar;
    41 class UIToolbarTools;
     34class UIVirtualBoxManagerWidget;
    4235class UIVirtualMachineItem;
    4336
     
    10194    /** @name Common stuff.
    10295      * @{ */
    103         /** Handles polishing in the async way. */
    104         void sltHandlePolishEvent();
    105 
    10696#if QT_VERSION == 0
    10797        /** Stupid moc does not warn if it cannot find headers! */
     
    112102#endif /* VBOX_WS_X11 */
    113103
    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 
    124104        /** Handles signal about medium-enumeration finished. */
    125105        void sltHandleMediumEnumerationFinish();
     
    128108        void sltHandleOpenUrlCall(QList<QUrl> list = QList<QUrl>());
    129109
     110        /** Hnadles singal about Chooser-pane index change.  */
     111        void sltHandleChooserPaneIndexChange();
    130112        /** Handles signal about group saving progress change. */
    131113        void sltHandleGroupSavingProgressChange();
     
    156138          * @param strFileName can bring the name of file to import appliance from. */
    157139        void sltOpenImportApplianceWizard(const QString &strFileName = QString());
     140        /** Handles call to open Import Appliance wizard the default way. */
     141        void sltOpenImportApplianceWizardDefault() { sltOpenImportApplianceWizard(); }
    158142        /** Handles call to open Export Appliance wizard. */
    159143        void sltOpenExportApplianceWizard();
     
    176160          * @param strFileName can bring the name of file to add machine from. */
    177161        void sltOpenAddMachineDialog(const QString &strFileName = QString());
     162        /** Handles call to open Add Machine dialog the default way. */
     163        void sltOpenAddMachineDialogDefault() { sltOpenAddMachineDialog(); }
    178164
    179165        /** Handles call to open Machine Settings dialog.
     
    184170                                          QString strControl = QString(),
    185171                                          const QString &strID = QString());
     172        /** Handles call to open Machine Settings dialog the default way. */
     173        void sltOpenMachineSettingsDialogDefault() { sltOpenMachineSettingsDialog(); }
    186174
    187175        /** Handles call to open Clone Machine wizard. */
     
    233221    /** @} */
    234222
    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 
    256223private:
    257 
    258     /** Returns current-item. */
    259     UIVirtualMachineItem *currentItem() const;
    260     /** Returns a list of current-items. */
    261     QList<UIVirtualMachineItem*> currentItems() const;
    262224
    263225    /** @name Prepare/Cleanup cascade.
     
    296258        /** Saves settings. */
    297259        void saveSettings();
    298         /** Cleanups connections. */
    299         void cleanupConnections();
     260        /** Cleanups widgets. */
     261        void cleanupWidgets();
    300262        /** Cleanups menu-bar. */
    301263        void cleanupMenuBar();
    302264        /** Cleanups window. */
    303265        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;
    304281    /** @} */
    305282
     
    358335    UIActionPool *m_pActionPool;
    359336
    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 
    393337    /** Holds the list of Group menu actions. */
    394338    QList<UIAction*>  m_groupActions;
     
    407351    /** Holds a map of (machineUUID, UIVMLogViewerDialog). */
    408352    VMLogViewerMap   m_logViewers;
     353
     354    /** Holds the central-widget instance. */
     355    UIVirtualBoxManagerWidget *m_pWidget;
    409356};
    410357
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r73457 r73492  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIVirtualBoxManager class implementation.
     3 * VBox Qt GUI - UIVirtualBoxManagerWidget class implementation.
    44 */
    55
     
    2121
    2222/* 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>
    2925
    3026/* GUI includes: */
    31 # include "QIFileDialog.h"
    3227# include "QISplitter.h"
    3328# include "UIActionPoolSelector.h"
    34 # include "UIDesktopServices.h"
    3529# include "UIErrorString.h"
    3630# include "UIExtraDataManager.h"
    3731# include "UIChooser.h"
    38 # include "UIHostNetworkManager.h"
    39 # include "UIMedium.h"
    40 # include "UIMediumManager.h"
    41 # include "UIMessageCenter.h"
    42 # include "UIModalWindowManager.h"
    4332# include "UIVirtualBoxManager.h"
    44 # include "UISettingsDialogSpecific.h"
     33# include "UIVirtualBoxManagerWidget.h"
    4534# include "UISlidingWidget.h"
    4635# include "UITabBar.h"
    4736# include "UIToolBar.h"
    48 # include "UIVMLogViewerDialog.h"
    4937# include "UIVirtualMachineItem.h"
    50 # include "UIToolPaneMachine.h"
    5138# include "UIToolbarTools.h"
    52 # ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    53 #  include "UIUpdateManager.h"
    54 # endif
    55 # include "UIVirtualBoxEventHandler.h"
    56 # include "UIWizardCloneVM.h"
    57 # include "UIWizardExportApp.h"
    58 # include "UIWizardImportApp.h"
    59 # ifdef VBOX_WS_MAC
    60 #  include "UIImageTools.h"
    61 #  include "UIWindowMenuManager.h"
    62 #  include "VBoxUtils.h"
    63 # endif
    64 # ifdef VBOX_WS_X11
    65 #  include "UIDesktopWidgetWatchdog.h"
    66 # endif
    6739# ifndef VBOX_WS_MAC
    6840#  include "UIMenuBar.h"
    6941# endif
    7042
    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_X11
    78 #  include <iprt/env.h>
    79 # endif /* VBOX_WS_X11 */
    80 
    8143#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    8244
    8345
    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()
     46UIVirtualBoxManagerWidget::UIVirtualBoxManagerWidget(UIVirtualBoxManager *pParent)
    11847    : m_fPolished(false)
    119     , m_fFirstMediumEnumerationHandled(false)
    120     , m_pActionPool(0)
     48    , m_pActionPool(pParent->actionPool())
    12149    , m_pSlidingWidget(0)
    12250    , m_pSplitter(0)
     
    13058    , m_pPaneToolsMachine(0)
    13159    , 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
     64UIVirtualBoxManagerWidget::~UIVirtualBoxManagerWidget()
     65{
     66    cleanup();
     67}
     68
     69UIVirtualMachineItem *UIVirtualBoxManagerWidget::currentItem() const
     70{
     71    return m_pPaneChooser->currentItem();
     72}
     73
     74QList<UIVirtualMachineItem*> UIVirtualBoxManagerWidget::currentItems() const
     75{
     76    return m_pPaneChooser->currentItems();
     77}
     78
     79bool UIVirtualBoxManagerWidget::isGroupSavingInProgress() const
     80{
     81    return m_pPaneChooser->isGroupSavingInProgress();
     82}
     83
     84bool UIVirtualBoxManagerWidget::isAllItemsOfOneGroupSelected() const
     85{
     86    return m_pPaneChooser->isAllItemsOfOneGroupSelected();
     87}
     88
     89bool UIVirtualBoxManagerWidget::isSingleGroupSelected() const
     90{
     91    return m_pPaneChooser->isSingleGroupSelected();
     92}
     93
     94bool UIVirtualBoxManagerWidget::isToolOpened(ToolTypeMachine enmType) const
     95{
     96    return m_pPaneToolsMachine->isToolOpened(enmType);
     97}
     98
     99bool UIVirtualBoxManagerWidget::isToolOpened(ToolTypeGlobal enmType) const
     100{
     101    return m_pPaneToolsGlobal->isToolOpened(enmType);
     102}
     103
     104void UIVirtualBoxManagerWidget::switchToTool(ToolTypeMachine enmType)
     105{
     106    sltHandleToolOpenedMachine(enmType);
     107}
     108
     109void UIVirtualBoxManagerWidget::switchToTool(ToolTypeGlobal enmType)
     110{
     111    sltHandleToolOpenedGlobal(enmType);
     112}
     113
     114void 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
     151void UIVirtualBoxManagerWidget::retranslateUi()
     152{
    194153    /* Make sure chosen item fetched: */
    195154    sltHandleChooserPaneIndexChange(false /* update details? */, false /* update snapshots? */, false /* update the logviewer? */);
     
    205164}
    206165
    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     }
     166void UIVirtualBoxManagerWidget::showEvent(QShowEvent *pEvent)
     167{
    268168    /* 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);
    276170
    277171    /* Is polishing required? */
     
    285179}
    286180
    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: */
     181void UIVirtualBoxManagerWidget::polishEvent(QShowEvent *)
     182{
     183    /* Call for async polishing finally: */
    294184    QMetaObject::invokeMethod(this, "sltHandlePolishEvent", Qt::QueuedConnection);
    295185}
    296186
    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()
     187void UIVirtualBoxManagerWidget::sltHandlePolishEvent()
    307188{
    308189    /* Get current item: */
     
    328209}
    329210
    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 {
     211void UIVirtualBoxManagerWidget::sltHandleChooserPaneIndexChange(bool fUpdateDetails /* = true */,
     212                                                                bool fUpdateSnapshots /* = true */,
     213                                                                bool fUpdateLogViewer /* = true */)
     214{
     215    /* Let the parent know: */
     216    emit sigChooserPaneIndexChange();
     217
    400218    /* Get current item: */
    401219    UIVirtualMachineItem *pItem = currentItem();
    402 
    403     /* Update action visibility: */
    404     updateActionsVisibility();
    405     /* Update action appearance: */
    406     updateActionsAppearance();
    407220
    408221    /* Update Tools-pane: */
     
    458271}
    459272
    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()
     273void UIVirtualBoxManagerWidget::sltHandleToolsTypeSwitch()
    1323274{
    1324275    /* If Machine tool button is checked => go backward: */
     
    1333284
    1334285    /* Update action visibility: */
    1335     updateActionsVisibility();
     286    emit sigToolsTypeSwitch();
    1336287
    1337288    /* Make sure chosen item fetched: */
     
    1339290}
    1340291
    1341 void UIVirtualBoxManager::sltHandleShowTabBarMachine()
     292void UIVirtualBoxManagerWidget::sltHandleShowTabBarMachine()
    1342293{
    1343294    m_pActionTabBarGlobal->setVisible(false);
     
    1345296}
    1346297
    1347 void UIVirtualBoxManager::sltHandleShowTabBarGlobal()
     298void UIVirtualBoxManagerWidget::sltHandleShowTabBarGlobal()
    1348299{
    1349300    m_pActionTabBarMachine->setVisible(false);
     
    1351302}
    1352303
    1353 void UIVirtualBoxManager::sltHandleToolOpenedMachine(ToolTypeMachine enmType)
     304void UIVirtualBoxManagerWidget::sltHandleToolOpenedMachine(ToolTypeMachine enmType)
    1354305{
    1355306    /* First, make sure corresponding tool set opened: */
     
    1372323}
    1373324
    1374 void UIVirtualBoxManager::sltHandleToolOpenedGlobal(ToolTypeGlobal enmType)
     325void UIVirtualBoxManagerWidget::sltHandleToolOpenedGlobal(ToolTypeGlobal enmType)
    1375326{
    1376327    /* First, make sure corresponding tool set opened: */
     
    1383334}
    1384335
    1385 void UIVirtualBoxManager::sltHandleToolClosedMachine(ToolTypeMachine enmType)
     336void UIVirtualBoxManagerWidget::sltHandleToolClosedMachine(ToolTypeMachine enmType)
    1386337{
    1387338    /* Close corresponding tool: */
     
    1389340}
    1390341
    1391 void UIVirtualBoxManager::sltHandleToolClosedGlobal(ToolTypeGlobal enmType)
     342void UIVirtualBoxManagerWidget::sltHandleToolClosedGlobal(ToolTypeGlobal enmType)
    1392343{
    1393344    /* Close corresponding tool: */
     
    1395346}
    1396347
    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 
     348void UIVirtualBoxManagerWidget::prepare()
     349{
    1423350    /* Prepare: */
    1424     prepareIcon();
    1425     prepareMenuBar();
    1426     prepareStatusBar();
    1427351    prepareToolbar();
    1428352    prepareWidgets();
     
    1435359    retranslateUi();
    1436360
    1437 #ifdef VBOX_WS_MAC
    1438     /* 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 
    1452361    /* Make sure current Chooser-pane index fetched: */
    1453362    sltHandleChooserPaneIndexChange();
    1454363}
    1455364
    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()
     365void UIVirtualBoxManagerWidget::prepareToolbar()
    1883366{
    1884367    /* Create Main toolbar: */
    1885368    m_pToolBar = new UIToolBar(this);
    1886     AssertPtrReturnVoid(m_pToolBar);
     369    if (m_pToolBar)
    1887370    {
    1888371        /* Configure toolbar: */
     
    1914397        /* Create Machine tab-bar: */
    1915398        m_pTabBarMachine = new UITabBar;
    1916         AssertPtrReturnVoid(m_pTabBarMachine);
     399        if (m_pTabBarMachine)
    1917400        {
    1918401            /* Configure tab-bar: */
     
    1927410        /* Create Global tab-bar: */
    1928411        m_pTabBarGlobal = new UITabBar;
    1929         AssertPtrReturnVoid(m_pTabBarGlobal);
     412        if (m_pTabBarGlobal)
    1930413        {
    1931414            /* Configure tab-bar: */
     
    1945428            m_pToolbarTools->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
    1946429            connect(m_pToolbarTools, &UIToolbarTools::sigShowTabBarMachine,
    1947                     this, &UIVirtualBoxManager::sltHandleShowTabBarMachine);
     430                    this, &UIVirtualBoxManagerWidget::sltHandleShowTabBarMachine);
    1948431            connect(m_pToolbarTools, &UIToolbarTools::sigShowTabBarGlobal,
    1949                     this, &UIVirtualBoxManager::sltHandleShowTabBarGlobal);
     432                    this, &UIVirtualBoxManagerWidget::sltHandleShowTabBarGlobal);
    1950433            m_pToolbarTools->setTabBars(m_pTabBarMachine, m_pTabBarGlobal);
    1951434
    1952435            /* Create exclusive action-group: */
    1953436            QActionGroup *pActionGroupTools = new QActionGroup(m_pToolbarTools);
    1954             AssertPtrReturnVoid(pActionGroupTools);
     437            if (pActionGroupTools)
    1955438            {
    1956439                /* Configure action-group: */
     
    1977460}
    1978461
    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);
     462void 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)
    1991478        {
    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
    2000519            /* 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);
    2051521        }
    2052522    }
     
    2056526}
    2057527
    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()));
     528void 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);
    2128541
    2129542    /* 'Tools' actions connections: */
    2130543    connect(actionPool()->action(UIActionIndexST_M_Tools_T_Machine), &UIAction::toggled,
    2131             this, &UIVirtualBoxManager::sltHandleToolsTypeSwitch);
     544            this, &UIVirtualBoxManagerWidget::sltHandleToolsTypeSwitch);
    2132545    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
     565void UIVirtualBoxManagerWidget::loadSettings()
     566{
    2176567    /* Restore splitter handle position: */
    2177568    {
     
    2189580    }
    2190581
    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    {
    2204584        m_pToolBar->setToolButtonStyle(gEDataManager->selectorWindowToolBarTextVisible()
    2205585                                       ? Qt::ToolButtonTextUnderIcon : Qt::ToolButtonIconOnly);
     
    2228608}
    2229609
    2230 void UIVirtualBoxManager::saveSettings()
     610void UIVirtualBoxManagerWidget::saveSettings()
    2231611{
    2232612    /* Save toolbar Machine/Global tools orders: */
     
    2236616    }
    2237617
    2238     /* Save toolbar and statusbar visibility: */
     618    /* Save toolbar visibility: */
    2239619    {
    2240620        gEDataManager->setSelectorWindowToolBarVisible(!m_pToolBar->isHidden());
     
    2246626        gEDataManager->setSelectorWindowSplitterHints(m_pSplitter->sizes());
    2247627    }
    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
     630void UIVirtualBoxManagerWidget::cleanup()
     631{
    2286632    /* Save settings: */
    2287633    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  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIVirtualBoxManager class declaration.
     3 * VBox Qt GUI - UIVirtualBoxManagerWidget class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef ___UIVirtualBoxManager_h___
    19 #define ___UIVirtualBoxManager_h___
     18#ifndef ___UIVirtualBoxManagerWidget_h___
     19#define ___UIVirtualBoxManagerWidget_h___
    2020
    2121/* Qt includes: */
    22 #include <QUrl>
     22#include <QWidget>
    2323
    2424/* GUI includes: */
    25 #include "QIMainWindow.h"
    2625#include "QIWithRetranslateUI.h"
    2726#include "UIToolPaneGlobal.h"
    2827#include "UIToolPaneMachine.h"
    29 #include "VBoxGlobal.h"
    3028
    3129/* Forward declarations: */
    32 class QMenu;
    33 class QIManagerDialog;
    3430class QISplitter;
    35 class UIAction;
    3631class UIActionPool;
    3732class UIChooser;
     
    4035class UIToolBar;
    4136class UIToolbarTools;
     37class UIVirtualBoxManager;
    4238class UIVirtualMachineItem;
    4339
    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. */
     41class UIVirtualBoxManagerWidget : public QIWithRetranslateUI<QWidget>
    4942{
    5043    Q_OBJECT;
     
    5245signals:
    5346
    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();
    5657
    5758public:
    5859
    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
     92public slots:
     93
     94    /** @name Common stuff.
     95      * @{ */
     96        /** Handles context-menu request for passed @a position. */
     97        void sltHandleContextMenuRequest(const QPoint &position);
     98    /** @} */
    6899
    69100protected:
    70101
    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 
    79102    /** @name Event handling stuff.
    80103      * @{ */
    81 #ifdef VBOX_WS_MAC
    82         /** Mac OS X: Preprocesses any @a pEvent for passed @a pObject. */
    83         virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */;
    84 #endif
    85 
    86104        /** Handles translation event. */
    87105        virtual void retranslateUi() /* override */;
    88106
    89         /** Handles any Qt @a pEvent. */
    90         virtual bool event(QEvent *pEvent) /* override */;
    91107        /** Handles show @a pEvent. */
    92108        virtual void showEvent(QShowEvent *pEvent) /* override */;
    93109        /** Handles first show @a pEvent. */
    94110        virtual void polishEvent(QShowEvent *pEvent) /* override */;
    95         /** Handles close @a pEvent. */
    96         virtual void closeEvent(QCloseEvent *pEvent) /* override */;
    97111    /** @} */
    98112
     
    104118        void sltHandlePolishEvent();
    105119
    106 #if QT_VERSION == 0
    107         /** Stupid moc does not warn if it cannot find headers! */
    108         void QT_VERSION_NOT_DEFINED
    109 #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 
    117120        /** Handles signal about Chooser-pane index change.
    118121          * @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. */
    120124        void sltHandleChooserPaneIndexChange(bool fUpdateDetails = true,
    121125                                             bool fUpdateSnapshots = true,
    122126                                             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(); }
    233129    /** @} */
    234130
     
    256152private:
    257153
    258     /** Returns current-item. */
    259     UIVirtualMachineItem *currentItem() const;
    260     /** Returns a list of current-items. */
    261     QList<UIVirtualMachineItem*> currentItems() const;
    262 
    263154    /** @name Prepare/Cleanup cascade.
    264155      * @{ */
    265156        /** Prepares window. */
    266157        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();
    287158        /** Prepares toolbar. */
    288159        void prepareToolbar();
     
    296167        /** Saves settings. */
    297168        void saveSettings();
    298         /** Cleanups connections. */
    299         void cleanupConnections();
    300         /** Cleanups menu-bar. */
    301         void cleanupMenuBar();
    302169        /** Cleanups window. */
    303170        void cleanup();
    304171    /** @} */
    305172
    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 
    352173    /** 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;
    356175
    357176    /** Holds the action-pool instance. */
     
    390209    /** Holds the Global Tools-pane instance. */
    391210    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;
    409211};
    410212
    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  
    2929# include "UIChooserModel.h"
    3030# include "UIChooserView.h"
    31 # include "UIVirtualBoxManager.h"
     31# include "UIVirtualBoxManagerWidget.h"
    3232# include "VBoxGlobal.h"
    3333
     
    3535
    3636
    37 UIChooser::UIChooser(UIVirtualBoxManager *pParent)
     37UIChooser::UIChooser(UIVirtualBoxManagerWidget *pParent)
    3838    : QWidget(pParent)
    39     , m_pSelectorWindow(pParent)
     39    , m_pManagerWidget(pParent)
    4040    , m_pMainLayout(0)
    4141    , m_pChooserModel(0)
     
    6969UIActionPool* UIChooser::actionPool() const
    7070{
    71     return selector()->actionPool();
     71    return managerWidget()->actionPool();
    7272}
    7373
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h

    r73424 r73492  
    2828class UIVirtualMachineItem;
    2929class QVBoxLayout;
    30 class UIVirtualBoxManager;
     30class UIVirtualBoxManagerWidget;
    3131class UIActionPool;
    3232class UIChooserModel;
     
    5757
    5858    /* Constructor/destructor: */
    59     UIChooser(UIVirtualBoxManager *pParent);
     59    UIChooser(UIVirtualBoxManagerWidget *pParent);
    6060    ~UIChooser();
    6161
    62     /** Returns the selector-window reference. */
    63     UIVirtualBoxManager* selector() const { return m_pSelectorWindow; }
     62    /** Returns the manager-widget reference. */
     63    UIVirtualBoxManagerWidget *managerWidget() const { return m_pManagerWidget; }
    6464    /** Returns the action-pool reference. */
    6565    UIActionPool* actionPool() const;
     
    9292    void save();
    9393
    94     /** Holds the selector-window reference. */
    95     UIVirtualBoxManager* m_pSelectorWindow;
     94    /** Holds the manager-widget reference. */
     95    UIVirtualBoxManagerWidget *m_pManagerWidget;
    9696
    9797    /* Variables: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r73424 r73492  
    4545# include "UIChooserHandlerKeyboard.h"
    4646# include "UIWizardNewVM.h"
    47 # include "UIVirtualBoxManager.h"
     47# include "UIVirtualBoxManagerWidget.h"
    4848# include "UIVirtualBoxEventHandler.h"
    4949# include "UIModalWindowManager.h"
     
    928928
    929929    /* 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());
    931931    UISafePointerWizardNewVM pWizard = new UIWizardNewVM(pWizardParent, strGroupName);
    932932    windowManager().registerNewParent(pWizard, pWizardParent);
Note: See TracChangeset for help on using the changeset viewer.

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