VirtualBox

Changeset 68175 in vbox for trunk/src


Ignore:
Timestamp:
Jul 29, 2017 2:41:24 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
117267
Message:

FE/Qt: bugref:8900: Selector UI: Replace segmented buttons with Tools toolbar which contains Machine tools for now; Will be extended with Global tools later.

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

Legend:

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

    r68167 r68175  
    380380        src/selector/UISnapshotDetailsWidget.h \
    381381        src/selector/UISnapshotPane.h \
    382         src/selector/UIToolsPane.h \
     382        src/selector/UIToolsPaneMachine.h \
    383383        src/selector/UIToolsToolbar.h \
    384384        src/selector/graphics/chooser/UIGChooser.h \
     
    697697        src/selector/UISnapshotDetailsWidget.cpp \
    698698        src/selector/UISnapshotPane.cpp \
    699         src/selector/UIToolsPane.cpp \
     699        src/selector/UIToolsPaneMachine.cpp \
    700700        src/selector/UIToolsToolbar.cpp \
    701701        src/selector/graphics/chooser/UIGChooser.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox2.qrc

    r67923 r68175  
    186186        <file alias="statusbar_settings_16px.png">images/statusbar_settings_16px.png</file>
    187187        <file alias="statusbar_settings_disabled_16px.png">images/statusbar_settings_disabled_16px.png</file>
     188        <file alias="tools_machine_32px.png">images/tools_machine_32px.png</file>
    188189        <file alias="tpixel.png">images/tpixel.png</file>
    189190        <file alias="usb_16px.png">images/usb_16px.png</file>
  • trunk/src/VBox/Frontends/VirtualBox/VirtualBox2_hidpi.qrc

    r67923 r68175  
    195195        <file alias="statusbar_settings_16px_hidpi.png">images/hidpi/statusbar_settings_16px_hidpi.png</file>
    196196        <file alias="statusbar_settings_disabled_16px_hidpi.png">images/hidpi/statusbar_settings_disabled_16px_hidpi.png</file>
     197        <file alias="tools_machine_32px_hidpi.png">images/hidpi/tools_machine_32px_hidpi.png</file>
    197198        <file alias="usb_16px_hidpi.png">images/hidpi/usb_16px_hidpi.png</file>
    198199        <file alias="usb_24px_hidpi.png">images/hidpi/usb_24px_hidpi.png</file>
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r68172 r68175  
    2222/* Qt includes: */
    2323# include <QMenuBar>
     24# include <QResizeEvent>
     25# include <QStandardPaths>
    2426# include <QStatusBar>
    25 # include <QResizeEvent>
    26 # include <QStackedWidget>
    2727# include <QToolButton>
    2828# include <QTimer>
    29 # if QT_VERSION >= 0x050000
    30 #  include <QStandardPaths>
    31 # else /* QT_VERSION < 0x050000 */
    32 #  include <QDesktopServices>
    33 # endif /* QT_VERSION < 0x050000 */
    3429
    3530/* GUI includes: */
     31# include "QIFileDialog.h"
    3632# include "QISplitter.h"
    37 # include "QIFileDialog.h"
     33# include "UIActionPoolSelector.h"
    3834# include "UIBar.h"
     35# include "UIDesktopServices.h"
     36# include "UIExtraDataManager.h"
     37# include "UIGChooser.h"
     38# include "UIGlobalSettingsExtension.h"
     39# include "UIHostNetworkManager.h"
     40# include "UIMedium.h"
     41# include "UIMediumManager.h"
     42# include "UIMessageCenter.h"
     43# include "UIModalWindowManager.h"
     44# include "UISelectorWindow.h"
     45# include "UISettingsDialogSpecific.h"
     46# include "UISpacerWidgets.h"
     47# include "UIToolBar.h"
     48# include "UIVMLogViewer.h"
     49# include "UIVMItem.h"
     50# include "UIToolsPaneMachine.h"
     51# include "UIToolsToolbar.h"
     52# include "UIVirtualBoxEventHandler.h"
     53# include "UIWizardCloneVM.h"
     54# include "UIWizardExportApp.h"
     55# include "UIWizardImportApp.h"
    3956# ifdef VBOX_GUI_WITH_NETWORK_MANAGER
    4057#  include "UINetworkManager.h"
    4158#  include "UINetworkManagerIndicator.h"
    42 #  include "UIUpdateManager.h"
    43 #  include "UIDownloaderUserManual.h"
    44 #  include "UIDownloaderExtensionPack.h"
    4559# endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
    46 # include "UIIconPool.h"
    47 # include "UIWizardCloneVM.h"
    48 # include "UIWizardExportApp.h"
    49 # include "UIWizardImportApp.h"
    50 # include "UIDesktopPane.h"
    51 # include "UIVirtualBoxEventHandler.h"
    52 # include "UIHostNetworkManager.h"
    53 # include "UIMediumManager.h"
    54 # include "UIMedium.h"
    55 # include "UIMessageCenter.h"
    56 # include "UISelectorWindow.h"
    57 # include "UISettingsDialogSpecific.h"
    58 # include "UISpacerWidgets.h"
    59 # include "UISpecialControls.h"
    60 # include "UIToolBar.h"
    61 # include "UIVMLogViewer.h"
    62 # include "UIDesktopServices.h"
    63 # include "UIGlobalSettingsExtension.h"
    64 # include "UIActionPoolSelector.h"
    65 # include "UIGChooser.h"
    66 # include "UIGDetails.h"
    67 # include "UIVMItem.h"
    68 # include "UIExtraDataManager.h"
    69 # include "UIDesktopWidgetWatchdog.h"
    70 # include "UIModalWindowManager.h"
    7160# ifdef VBOX_WS_MAC
     61#  include "UIImageTools.h"
     62#  include "UIWindowMenuManager.h"
    7263#  include "VBoxUtils.h"
    73 #  include "UIWindowMenuManager.h"
    74 #  include "UIImageTools.h"
    7564# endif /* VBOX_WS_MAC */
     65# ifdef VBOX_WS_X11
     66#  include "UIDesktopWidgetWatchdog.h"
     67# endif
    7668
    7769/* Other VBox stuff: */
     
    122114#ifndef VBOX_WS_MAC
    123115    , m_pBar(0)
    124 #endif /* !VBOX_WS_MAC */
     116#endif
    125117    , m_pToolBar(0)
    126     , m_pSegmentedButton(0)
    127     , m_pContainerDetails(0)
     118    , m_pToolbarTools(0)
    128119    , m_pPaneChooser(0)
    129     , m_pPaneDetails(0)
    130     , m_pPaneDesktop(0)
    131     , m_pPaneTools(0)
     120    , m_pPaneToolsMachine(0)
    132121    , m_pGroupMenuAction(0)
    133122    , m_pMachineMenuAction(0)
     
    239228
    240229    /* Update Details-pane: */
    241     if (fUpdateDetails)
    242         m_pPaneDetails->setItems(currentItems());
     230    if (   fUpdateDetails
     231        && m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))
     232        m_pPaneToolsMachine->setItems(currentItems());
    243233
    244234    /* If current item exists & accessible: */
    245235    if (pItem && pItem->accessible())
    246236    {
    247         /* Make sure at least Details-pane raised: */
    248         if (m_pContainerDetails->currentWidget() == m_pPaneDesktop)
    249             sltPerformSegmentedButtonSwitch(SegmentType_Details);
    250 
    251         /* Refresh Tools-pane if requested: */
    252         if (fUpdateTools)
    253             m_pPaneTools->setMachine(pItem->machine());
     237        /* Make sure Machine Tools-pane raised: */
     238        if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))
     239            m_pPaneToolsMachine->openTool(ToolTypeMachine_Details);
     240        else
     241        if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Snapshots))
     242            m_pPaneToolsMachine->openTool(ToolTypeMachine_Snapshots);
     243
     244        /* Refresh Machine Tools-pane if requested: */
     245        if (   fUpdateTools
     246            && m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Snapshots))
     247            m_pPaneToolsMachine->setMachine(pItem->machine());
    254248    }
    255249    else
    256250    {
    257251        /* Make sure Desktop-pane raised: */
    258         if (m_pContainerDetails->currentWidget() != m_pPaneDesktop)
    259             sltPerformSegmentedButtonSwitch(SegmentType_None);
     252        m_pPaneToolsMachine->openTool(ToolTypeMachine_Desktop);
    260253
    261254        /* Note that the machine becomes inaccessible (or if the last VM gets
     
    264257        {
    265258            /* The VM is inaccessible: */
    266             m_pPaneDesktop->updateDetailsError(UIMessageCenter::formatErrorInfo(pItem->accessError()));
     259            m_pPaneToolsMachine->setDetailsError(UIMessageCenter::formatErrorInfo(pItem->accessError()));
    267260        }
    268261        else
    269262        {
    270263            /* Default HTML support in Qt is terrible so just try to get something really simple: */
    271             m_pPaneDesktop->updateDetailsText(
     264            m_pPaneToolsMachine->setDetailsText(
    272265                tr("<h3>Welcome to VirtualBox!</h3>"
    273266                   "<p>The left part of this window is  "
     
    287280
    288281        /* Refresh Tools-pane in any case: */
    289         m_pPaneTools->setMachine(CMachine());
     282        if (m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Snapshots))
     283            m_pPaneToolsMachine->setMachine(CMachine());
    290284    }
    291285}
     
    301295
    302296    /* Make sure MM window is not opened: */
    303     if (   m_pManagerVirtualMedia
    304         || m_pPaneTools->isToolOpened(ToolType_VirtualMediaManager))
     297    if (m_pManagerVirtualMedia)
    305298        return;
    306299
     
    407400void UISelectorWindow::sltOpenVirtualMediumManagerWindow()
    408401{
    409     /* First check if instance of widget opened embedded: */
    410     if (m_pPaneTools->isToolOpened(ToolType_VirtualMediaManager))
    411     {
    412         sltPerformSegmentedButtonSwitch(SegmentType_Tools);
    413         m_pPaneTools->setCurrentTool(ToolType_VirtualMediaManager);
    414         return;
    415     }
    416 
    417402    /* Create instance if not yet created: */
    418403    if (!m_pManagerVirtualMedia)
     
    441426void UISelectorWindow::sltOpenHostNetworkManagerWindow()
    442427{
    443     /* First check if instance of widget opened embedded: */
    444     if (m_pPaneTools->isToolOpened(ToolType_HostNetworkManager))
    445     {
    446         sltPerformSegmentedButtonSwitch(SegmentType_Tools);
    447         m_pPaneTools->setCurrentTool(ToolType_HostNetworkManager);
    448         return;
    449     }
    450 
    451428    /* Create instance if not yet created: */
    452429    if (!m_pManagerHostNetwork)
     
    10481025}
    10491026
    1050 void UISelectorWindow::sltHandleSegmentedButtonSwitch(int iSegment)
    1051 {
    1052     /* Get current item: */
    1053     const UIVMItem *pItem = currentItem();
    1054 
    1055     /* If current item exists & accessible: */
    1056     if (pItem && pItem->accessible())
    1057     {
    1058         /* Raise the required widget: */
    1059         switch (iSegment)
    1060         {
    1061             case SegmentType_Details: m_pContainerDetails->setCurrentWidget(m_pPaneDetails); break;
    1062             case SegmentType_Tools:   m_pContainerDetails->setCurrentWidget(m_pPaneTools); break;
    1063             default:                  break;
    1064         }
    1065     }
    1066     else
    1067     {
    1068         /* Raise the Desktop-pane with welcome text or error details: */
    1069         m_pContainerDetails->setCurrentWidget(m_pPaneDesktop);
    1070     }
    1071 
    1072 #ifdef VBOX_WS_MAC
    1073     // WORKAROUND:
    1074     // Qt 5.6.x has weird bug:
    1075     // When some cocoa widget being focused for a first time
    1076     // previously focused Qt widget being erased unless
    1077     // someone calls for it's update directly or
    1078     // indirectly (like with mouse hovering).
    1079     // Doing that directly for Chooser pane.
    1080     m_pPaneChooser->update();
    1081 #endif
    1082 }
    1083 
    1084 void UISelectorWindow::sltPerformSegmentedButtonSwitch(int iSegment)
    1085 {
    1086     /* Perform silent segmented-button switch: */
    1087     if (iSegment >= 0 && iSegment < m_pSegmentedButton->count())
    1088         m_pSegmentedButton->setSelected(iSegment);
    1089     /* Manually handle that switch as well: */
    1090     sltHandleSegmentedButtonSwitch(iSegment);
    1091 }
    1092 
    1093 void UISelectorWindow::sltHandleToolsPaneToolOpened(ToolType enmType)
    1094 {
    1095     switch (enmType)
    1096     {
    1097         case ToolType_VirtualMediaManager: sltCloseVirtualMediumManagerWindow(); break;
    1098         case ToolType_HostNetworkManager:  sltCloseHostNetworkManagerWindow(); break;
    1099         default:                           break;
    1100     }
     1027void UISelectorWindow::sltHandleToolOpenedMachine(ToolTypeMachine enmType)
     1028{
     1029    /* Open corresponding tool: */
     1030    m_pPaneToolsMachine->openTool(enmType);
     1031    /* If that was 'Details' => pass there current items: */
     1032    if (   enmType == ToolTypeMachine_Details
     1033        && m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Details))
     1034        m_pPaneToolsMachine->setItems(currentItems());
     1035    /* If that was 'Snapshot' => pass there current or null machine: */
     1036    if (   enmType == ToolTypeMachine_Snapshots
     1037        && m_pPaneToolsMachine->isToolOpened(ToolTypeMachine_Snapshots))
     1038    {
     1039        UIVMItem *pItem = currentItem();
     1040        m_pPaneToolsMachine->setMachine(pItem ? pItem->machine() : CMachine());
     1041    }
     1042}
     1043
     1044void UISelectorWindow::sltHandleToolClosedMachine(ToolTypeMachine enmType)
     1045{
     1046    /* Close corresponding tool: */
     1047    m_pPaneToolsMachine->closeTool(enmType);
    11011048}
    11021049
     
    11251072    setWindowTitle(strTitle);
    11261073
    1127     /* Translate segmented-button: */
    1128     // TODO: Move that NLS from UIDesktopPane to UISelectorWindow context.
    1129     m_pSegmentedButton->setTitle(SegmentType_Details, QApplication::translate("UIDesktopPane", "&Details"));
    1130     m_pSegmentedButton->setTitle(SegmentType_Tools, QApplication::translate("UIDesktopPane", "&Tools"));
     1074    /* Translate Machine Tools welcome screen: */
     1075    m_pPaneToolsMachine->setDetailsText(
     1076        tr("<h3>Welcome to VirtualBox!</h3>"
     1077           "<p>The left part of this window is a list of all virtual machines "
     1078           "and virtual machine groups on your computer. "
     1079           "<img src=:/welcome.png align=right/></p>"
     1080           "<p>The right part of this window represents a set of tools "
     1081           "you have opened for the currently chosen machine. "
     1082           "For more tools check the corresponding menu at the right side "
     1083           "of the main tool bar located at the top of the window.</p>"
     1084           "<p>You can press the <b>%1</b> key to get instant help, "
     1085           "or visit "
     1086           "<a href=https://www.virtualbox.org>www.virtualbox.org</a> "
     1087           "for the latest information and news.</p>")
     1088           .arg(QKeySequence(QKeySequence::HelpContents).toString(QKeySequence::NativeText)));
    11311089
    11321090    /* Make sure details and snapshot panes are updated: */
     
    12751233    prepareConnections();
    12761234
     1235    /* Make sure at least 'Details' Machine tool is opened at startup: */
     1236    actionPool()->action(UIActionIndexST_M_Tools_M_Machine_Details)->trigger();
     1237
    12771238    /* Load settings: */
    12781239    loadSettings();
     
    12951256    qApp->installEventFilter(this);
    12961257#endif /* VBOX_WS_MAC */
    1297 
    1298     /* Switch segmented-button to Details-pane: */
    1299     sltPerformSegmentedButtonSwitchToDetails();
    13001258
    13011259    /* Make sure current Chooser-pane index fetched: */
     
    17551713        m_pToolBar->addWidget(new UIHorizontalSpacerWidget);
    17561714
    1757         /* Create/add segmented-button: */
    1758         m_pSegmentedButton = new UITexturedSegmentedButton(this, 2);
    1759         m_pSegmentedButton->setIcon(SegmentType_Details, UIIconPool::iconSet(":/edataman_16px.png",
    1760                                                                              ":/edataman_16px.png"));
    1761         m_pSegmentedButton->setIcon(SegmentType_Tools, UIIconPool::iconSet(":/guesttools_16px.png",
    1762                                                                            ":/guesttools_disabled_16px.png"));
    1763         m_pToolBar->addWidget(m_pSegmentedButton);
     1715        /* Create Tools toolbar: */
     1716        m_pToolbarTools = new UIToolsToolbar(actionPool());
     1717        if (m_pToolbarTools)
     1718        {
     1719            /* Configure toolbar: */
     1720            m_pToolbarTools->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
     1721
     1722            /* Create exclusive action-group: */
     1723            QActionGroup *pActionGroupTools = new QActionGroup(m_pToolbarTools);
     1724            AssertPtrReturnVoid(pActionGroupTools);
     1725            {
     1726                /* Configure action-group: */
     1727                pActionGroupTools->setExclusive(true);
     1728
     1729                /* Add 'Tools' actions into action-group: */
     1730                pActionGroupTools->addAction(actionPool()->action(UIActionIndexST_M_Tools_T_Machine));
     1731            }
     1732
     1733            /* Add into toolbar: */
     1734            m_pToolBar->addWidget(m_pToolbarTools);
     1735        }
    17641736
    17651737        /* Create/add horizontal spacer widget of fixed size for the beta label: */
     
    17701742                pSpace->setFixedSize(28, 1);
    17711743            else
    1772                 pSpace->setFixedSize(10, 1);
     1744                pSpace->setFixedSize(1, 1);
    17731745            m_pToolBar->addWidget(pSpace);
    17741746        }
     
    18401812                }
    18411813
    1842                 /* Create container: */
    1843                 m_pContainerDetails = new QStackedWidget;
    1844                 AssertPtrReturnVoid(m_pContainerDetails);
     1814                /* Prepare Machine Tools-pane: */
     1815                m_pPaneToolsMachine = new UIToolsPaneMachine(actionPool());
     1816                AssertPtrReturnVoid(m_pPaneToolsMachine);
    18451817                {
    1846                     /* Prepare Details-pane: */
    1847                     m_pPaneDetails = new UIGDetails(this);
    1848                     AssertPtrReturnVoid(m_pPaneDetails);
    1849                     {
    1850                         /* Add into container: */
    1851                         m_pContainerDetails->addWidget(m_pPaneDetails);
    1852                     }
    1853 
    1854                     /* Prepare Desktop-pane: */
    1855                     m_pPaneDesktop = new UIDesktopPane(actionPool()->action(UIActionIndexST_M_Group_S_Refresh));
    1856                     AssertPtrReturnVoid(m_pPaneDesktop);
    1857                     {
    1858                         /* Add into container: */
    1859                         m_pContainerDetails->addWidget(m_pPaneDesktop);
    1860                     }
    1861 
    1862                     /* Prepare Tools-pane: */
    1863                     m_pPaneTools = new UIToolsPane;
    1864                     AssertPtrReturnVoid(m_pPaneTools);
    1865                     {
    1866                         /* Add into container: */
    1867                         m_pContainerDetails->addWidget(m_pPaneTools);
    1868                     }
    1869 
    18701818                    /* Add into splitter: */
    1871                     m_pSplitter->addWidget(m_pContainerDetails);
     1819                    m_pSplitter->addWidget(m_pPaneToolsMachine);
    18721820                }
    18731821
    18741822                /* Adjust splitter colors according to main widgets it splits: */
    18751823                m_pSplitter->configureColors(m_pPaneChooser->palette().color(QPalette::Active, QPalette::Window),
    1876                                              m_pPaneDetails->palette().color(QPalette::Active, QPalette::Window));
     1824                                             m_pPaneToolsMachine->palette().color(QPalette::Active, QPalette::Window));
    18771825                /* Set the initial distribution. The right site is bigger. */
    18781826                m_pSplitter->setStretchFactor(0, 2);
     
    19651913    /* Graphics VM chooser connections: */
    19661914    connect(m_pPaneChooser, SIGNAL(sigSelectionChanged()), this, SLOT(sltHandleChooserPaneIndexChange()));
    1967     connect(m_pPaneChooser, SIGNAL(sigSlidingStarted()), m_pPaneDetails, SIGNAL(sigSlidingStarted()));
    1968     connect(m_pPaneChooser, SIGNAL(sigToggleStarted()), m_pPaneDetails, SIGNAL(sigToggleStarted()));
    1969     connect(m_pPaneChooser, SIGNAL(sigToggleFinished()), m_pPaneDetails, SIGNAL(sigToggleFinished()));
     1915    connect(m_pPaneChooser, SIGNAL(sigSlidingStarted()), m_pPaneToolsMachine, SIGNAL(sigSlidingStarted()));
     1916    connect(m_pPaneChooser, SIGNAL(sigToggleStarted()), m_pPaneToolsMachine, SIGNAL(sigToggleStarted()));
     1917    connect(m_pPaneChooser, SIGNAL(sigToggleFinished()), m_pPaneToolsMachine, SIGNAL(sigToggleFinished()));
    19701918    connect(m_pPaneChooser, SIGNAL(sigGroupSavingStateChanged()), this, SLOT(sltHandleGroupSavingProgressChange()));
    19711919
     
    19771925    ::darwinRegisterForUnifiedToolbarContextMenuEvents(this);
    19781926#endif /* VBOX_WS_MAC */
    1979 
    1980     /* Segmented-button connections: */
    1981     connect(m_pSegmentedButton, SIGNAL(clicked(int)), this, SLOT(sltHandleSegmentedButtonSwitch(int)));
     1927    connect(m_pToolbarTools, &UIToolsToolbar::sigToolOpenedMachine, this, &UISelectorWindow::sltHandleToolOpenedMachine);
     1928    connect(m_pToolbarTools, &UIToolsToolbar::sigToolClosedMachine, this, &UISelectorWindow::sltHandleToolClosedMachine);
    19821929
    19831930    /* VM desktop connections: */
    1984     connect(m_pPaneDetails, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)),
     1931    connect(m_pPaneToolsMachine, SIGNAL(sigLinkClicked(const QString&, const QString&, const QString&)),
    19851932            this, SLOT(sltOpenMachineSettingsDialog(const QString&, const QString&, const QString&)));
    1986     connect(m_pPaneTools, &UIToolsPane::sigToolOpened, this, &UISelectorWindow::sltHandleToolsPaneToolOpened);
     1933
    19871934
    19881935    /* Global event handlers: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.h

    r68172 r68175  
    2525#include "QIMainWindow.h"
    2626#include "QIWithRetranslateUI.h"
    27 #include "UIToolsPane.h"
     27#include "UIToolsPaneMachine.h"
    2828#include "VBoxGlobal.h"
    2929
    3030/* Forward declarations: */
    3131class QMenu;
    32 class QStackedWidget;
    3332class QIManagerDialog;
    3433class QISplitter;
    3534class UIAction;
    3635class UIActionPool;
    37 class UIDesktopPane;
    3836class UIGChooser;
    39 class UIGDetails;
    4037#ifndef VBOX_WS_MAC
    4138class UIMainBar;
    4239#endif
    43 class UITexturedSegmentedButton;
    4440class UIToolBar;
     41class UIToolsToolbar;
    4542class UIVMItem;
    4643
     
    5148{
    5249    Q_OBJECT;
    53 
    54     /** Segmented-button segment types. */
    55     enum SegmentType
    56     {
    57         SegmentType_Details,
    58         SegmentType_Tools,
    59         SegmentType_None,
    60     };
    6150
    6251public:
     
    194183    /** @} */
    195184
    196     /** @name Segmented-button stuff.
    197       * @{ */
    198         /** Handles segmented-button switch. */
    199         void sltHandleSegmentedButtonSwitch(int iSegment);
    200         /** Performs segmented-button switch. */
    201         void sltPerformSegmentedButtonSwitch(int iSegment);
    202         /** Performs segmented-button switch to details pane. */
    203         void sltPerformSegmentedButtonSwitchToDetails() { sltPerformSegmentedButtonSwitch(SegmentType_Details); }
    204     /** @} */
    205 
    206185    /** @name Tools-pane stuff.
    207186      * @{ */
    208         void sltHandleToolsPaneToolOpened(ToolType enmType);
     187        /** Handles rquest to open Machine tool of passed @a enmType. */
     188        void sltHandleToolOpenedMachine(ToolTypeMachine enmType);
     189
     190        /** Handles rquest to close Machine tool of passed @a enmType. */
     191        void sltHandleToolClosedMachine(ToolTypeMachine enmType);
    209192    /** @} */
    210193
     
    333316#ifndef VBOX_WS_MAC
    334317    /** Holds the main bar instance. */
    335     UIMainBar *m_pBar;
    336 #endif /* !VBOX_WS_MAC */
     318    UIMainBar      *m_pBar;
     319#endif
    337320    /** Holds the main toolbar instance. */
    338     UIToolBar *m_pToolBar;
    339 
    340     /** Holds the segmented-button instance. */
    341     UITexturedSegmentedButton *m_pSegmentedButton;
    342 
    343     /** Holds the Details-container instance. */
    344     QStackedWidget *m_pContainerDetails;
     321    UIToolBar      *m_pToolBar;
     322    /** Holds the Tools-toolbar instance. */
     323    UIToolsToolbar *m_pToolbarTools;
    345324
    346325    /** Holds the Chooser-pane instance. */
    347     UIGChooser *m_pPaneChooser;
    348     /** Holds the Details-pane instance. */
    349     UIGDetails *m_pPaneDetails;
    350     /** Holds the Desktop-pane instance. */
    351     UIDesktopPane *m_pPaneDesktop;
     326    UIGChooser         *m_pPaneChooser;
    352327    /** Holds the Tools-pane instance. */
    353     UIToolsPane *m_pPaneTools;
     328    UIToolsPaneMachine *m_pPaneToolsMachine;
    354329
    355330    /** Holds the list of Group menu actions. */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsPaneMachine.cpp

    r68155 r68175  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIToolsPane class implementation.
     3 * VBox Qt GUI - UIToolsPaneMachine class implementation.
    44 */
    55
     
    2222/* Qt includes: */
    2323# include <QStackedLayout>
    24 # include <QTabBar>
    2524
    2625/* GUI includes */
    27 # include "QIToolButton.h"
    28 # include "UIHostNetworkManager.h"
    29 # include "UIIconPool.h"
    30 # include "UIMediumManager.h"
    31 # include "UIMenuToolBar.h"
     26# include "UIActionPoolSelector.h"
     27# include "UIDesktopPane.h"
     28# include "UIGDetails.h"
    3229# include "UISnapshotPane.h"
    33 # include "UIToolsPane.h"
     30# include "UIToolsPaneMachine.h"
    3431
    3532/* Other VBox includes: */
     
    3936
    4037
    41 UIToolsPane::UIToolsPane(QWidget *pParent /* = 0 */)
    42     : QIWithRetranslateUI<QWidget>(pParent)
    43     , m_pLayoutMain(0)
    44     , m_pStackedLayout(0)
     38UIToolsPaneMachine::UIToolsPaneMachine(UIActionPool *pActionPool, QWidget *pParent /* = 0 */)
     39    : QWidget(pParent)
     40    , m_pActionPool(pActionPool)
     41    , m_pLayout(0)
     42    , m_pPaneDesktop(0)
     43    , m_pPaneDetails(0)
    4544    , m_pPaneSnapshots(0)
    46     , m_pLayoutControls(0)
    47     , m_pTabBar(0)
    48     , m_pMenuToolbar(0)
    49     , m_pMenu(0)
    5045{
    5146    /* Prepare: */
     
    5348}
    5449
    55 UIToolsPane::~UIToolsPane()
     50UIToolsPaneMachine::~UIToolsPaneMachine()
    5651{
    5752    /* Cleanup: */
     
    5954}
    6055
    61 bool UIToolsPane::isToolOpened(ToolType enmType) const
    62 {
    63     for (int iTabIndex = 0; iTabIndex < m_pTabBar->count(); ++iTabIndex)
    64         if (m_pTabBar->tabData(iTabIndex).value<ToolType>() == enmType)
     56bool UIToolsPaneMachine::isToolOpened(ToolTypeMachine enmType) const
     57{
     58    /* Search through the stacked widgets: */
     59    for (int iIndex = 0; iIndex < m_pLayout->count(); ++iIndex)
     60        if (m_pLayout->widget(iIndex)->property("ToolType").value<ToolTypeMachine>() == enmType)
    6561            return true;
    6662    return false;
    6763}
    6864
    69 void UIToolsPane::setCurrentTool(ToolType enmType)
    70 {
    71     activateTabBarTab(enmType, true);
    72 }
    73 
    74 void UIToolsPane::setMachine(const CMachine &comMachine)
     65void UIToolsPaneMachine::openTool(ToolTypeMachine enmType)
     66{
     67    /* Search through the stacked widgets: */
     68    int iActualIndex = -1;
     69    for (int iIndex = 0; iIndex < m_pLayout->count(); ++iIndex)
     70        if (m_pLayout->widget(iIndex)->property("ToolType").value<ToolTypeMachine>() == enmType)
     71            iActualIndex = iIndex;
     72
     73    /* If widget with such type exists: */
     74    if (iActualIndex != -1)
     75    {
     76        /* Activate corresponding index: */
     77        m_pLayout->setCurrentIndex(iActualIndex);
     78    }
     79    /* Otherwise: */
     80    else
     81    {
     82        /* Create, remember, append corresponding stacked widget: */
     83        switch (enmType)
     84        {
     85            case ToolTypeMachine_Desktop:
     86            {
     87                /* Create Desktop pane: */
     88                m_pPaneDesktop = new UIDesktopPane(m_pActionPool->action(UIActionIndexST_M_Group_S_Refresh));
     89                AssertPtrReturnVoid(m_pPaneDesktop);
     90                {
     91                    /* Configure pane: */
     92                    m_pPaneDesktop->setProperty("ToolType", QVariant::fromValue(ToolTypeMachine_Desktop));
     93
     94                    /* Add into layout: */
     95                    m_pLayout->addWidget(m_pPaneDesktop);
     96                    m_pLayout->setCurrentWidget(m_pPaneDesktop);
     97                }
     98                break;
     99            }
     100            case ToolTypeMachine_Details:
     101            {
     102                /* Create Details pane: */
     103                m_pPaneDetails = new UIGDetails;
     104                AssertPtrReturnVoid(m_pPaneDetails);
     105                {
     106                    /* Configure pane: */
     107                    m_pPaneDetails->setProperty("ToolType", QVariant::fromValue(ToolTypeMachine_Details));
     108                    connect(this, &UIToolsPaneMachine::sigSlidingStarted, m_pPaneDetails, &UIGDetails::sigSlidingStarted);
     109                    connect(this, &UIToolsPaneMachine::sigToggleStarted,  m_pPaneDetails, &UIGDetails::sigToggleStarted);
     110                    connect(this, &UIToolsPaneMachine::sigToggleFinished, m_pPaneDetails, &UIGDetails::sigToggleFinished);
     111                    connect(m_pPaneDetails, &UIGDetails::sigLinkClicked,  this, &UIToolsPaneMachine::sigLinkClicked);
     112
     113                    /* Add into layout: */
     114                    m_pLayout->addWidget(m_pPaneDetails);
     115                    m_pLayout->setCurrentWidget(m_pPaneDetails);
     116                }
     117                break;
     118            }
     119            case ToolTypeMachine_Snapshots:
     120            {
     121                /* Create Snapshots pane: */
     122                m_pPaneSnapshots = new UISnapshotPane;
     123                AssertPtrReturnVoid(m_pPaneSnapshots);
     124                {
     125                    /* Configure pane: */
     126                    m_pPaneSnapshots->setProperty("ToolType", QVariant::fromValue(ToolTypeMachine_Snapshots));
     127
     128                    /* Add into layout: */
     129                    m_pLayout->addWidget(m_pPaneSnapshots);
     130                    m_pLayout->setCurrentWidget(m_pPaneSnapshots);
     131                }
     132                break;
     133            }
     134            default:
     135                AssertFailedReturnVoid();
     136        }
     137    }
     138}
     139
     140void UIToolsPaneMachine::closeTool(ToolTypeMachine enmType)
     141{
     142    /* Search through the stacked widgets: */
     143    int iActualIndex = -1;
     144    for (int iIndex = 0; iIndex < m_pLayout->count(); ++iIndex)
     145        if (m_pLayout->widget(iIndex)->property("ToolType").value<ToolTypeMachine>() == enmType)
     146            iActualIndex = iIndex;
     147
     148    /* If widget with such type doesn't exist: */
     149    if (iActualIndex != -1)
     150    {
     151        /* Forget corresponding widget: */
     152        switch (enmType)
     153        {
     154            case ToolTypeMachine_Desktop:   m_pPaneDesktop = 0; break;
     155            case ToolTypeMachine_Details:   m_pPaneDetails = 0; break;
     156            case ToolTypeMachine_Snapshots: m_pPaneSnapshots = 0; break;
     157            default: break;
     158        }
     159        /* Delete corresponding widget: */
     160        QWidget *pWidget = m_pLayout->widget(iActualIndex);
     161        m_pLayout->removeWidget(pWidget);
     162        delete pWidget;
     163    }
     164}
     165
     166void UIToolsPaneMachine::setDetailsText(const QString &strText)
     167{
     168    /* Update desktop pane: */
     169    AssertPtrReturnVoid(m_pPaneDesktop);
     170    m_pPaneDesktop->updateDetailsText(strText);
     171}
     172
     173void UIToolsPaneMachine::setDetailsError(const QString &strError)
     174{
     175    /* Update desktop pane: */
     176    AssertPtrReturnVoid(m_pPaneDesktop);
     177    m_pPaneDesktop->updateDetailsError(strError);
     178}
     179
     180void UIToolsPaneMachine::setItems(const QList<UIVMItem*> &items)
     181{
     182    /* Update details pane: */
     183    AssertPtrReturnVoid(m_pPaneDetails);
     184    m_pPaneDetails->setItems(items);
     185}
     186
     187void UIToolsPaneMachine::setMachine(const CMachine &comMachine)
    75188{
    76189    /* Update snapshots pane: */
     
    79192}
    80193
    81 void UIToolsPane::retranslateUi()
    82 {
    83     /* Translate menu: */
    84     m_pMenu->setTitle(tr("More Tools"));
    85     m_pMenu->setToolTip(tr("Holds a list of tools"));
    86 
    87     /* Translate actions: */
    88     m_actions[ToolType_SnapshotManager]->setText(tr("Snapshot Manager"));
    89     m_actions[ToolType_VirtualMediaManager]->setText(tr("Virtual Media Manager"));
    90     m_actions[ToolType_HostNetworkManager]->setText(tr("Host Network Manager"));
    91 
    92     /* Translate tab-bar: */
    93     for (int iTabIndex = 0; iTabIndex < m_pTabBar->count(); ++iTabIndex)
    94     {
    95         const ToolType enmType = m_pTabBar->tabData(iTabIndex).value<ToolType>();
    96         m_pTabBar->setTabText(iTabIndex, m_actions.value(enmType)->text());
    97     }
    98 }
    99 
    100 void UIToolsPane::sltHandleMenuToolbarTrigger()
    101 {
    102     /* Get the sender: */
    103     QAction *pAction = sender() ? qobject_cast<QAction*>(sender()) : 0;
    104     AssertPtrReturnVoid(pAction);
    105 
    106     /* Acquire sender's type: */
    107     const ToolType enmType = pAction->property("ToolType").value<ToolType>();
    108     AssertReturnVoid(enmType != ToolType_Invalid);
    109 
    110     /* Activate corresponding tab: */
    111     activateTabBarTab(enmType, true);
    112 }
    113 
    114 void UIToolsPane::sltHandleTabBarTabMoved(int iFrom, int iTo)
    115 {
    116     /* Swap stack-widget pages as well: */
    117     QWidget *pWidget = m_pStackedLayout->widget(iFrom);
    118     m_pStackedLayout->removeWidget(pWidget);
    119     m_pStackedLayout->insertWidget(iTo, pWidget);
    120 }
    121 
    122 void UIToolsPane::sltHandleTabBarCurrentChange(int iIndex)
    123 {
    124     /* Activate corresponding indexes: */
    125     m_pStackedLayout->setCurrentIndex(iIndex);
    126 }
    127 
    128 void UIToolsPane::sltHandleTabBarButtonClick()
    129 {
    130     /* Get the sender: */
    131     QIToolButton *pButton = sender() ? qobject_cast<QIToolButton*>(sender()) : 0;
    132     AssertPtrReturnVoid(pButton);
    133 
    134     /* Acquire sender's type: */
    135     const ToolType enmType = pButton->property("ToolType").value<ToolType>();
    136     AssertReturnVoid(enmType != ToolType_Invalid);
    137 
    138     /* Search for the tab with such type: */
    139     int iActualTabIndex = -1;
    140     for (int iTabIndex = 0; iTabIndex < m_pTabBar->count(); ++iTabIndex)
    141         if (m_pTabBar->tabData(iTabIndex).value<ToolType>() == enmType)
    142             iActualTabIndex = iTabIndex;
    143     AssertReturnVoid(iActualTabIndex != -1);
    144 
    145     /* Delete the tab and corresponding widget: */
    146     m_pTabBar->removeTab(iActualTabIndex);
    147     QWidget *pWidget = m_pStackedLayout->widget(iActualTabIndex);
    148     m_pStackedLayout->removeWidget(pWidget);
    149     delete pWidget;
    150 
    151     /* Make sure action is unchecked: */
    152     m_actions[enmType]->blockSignals(true);
    153     m_actions[enmType]->setChecked(false);
    154     m_actions[enmType]->blockSignals(false);
    155 }
    156 
    157 void UIToolsPane::prepare()
    158 {
    159     /* Create main layout: */
    160     m_pLayoutMain = new QVBoxLayout(this);
    161     AssertPtrReturnVoid(m_pLayoutMain);
     194void UIToolsPaneMachine::prepare()
     195{
     196    /* Create stacked-layout: */
     197    m_pLayout = new QStackedLayout(this);
     198    AssertPtrReturnVoid(m_pLayout);
    162199    {
    163200        /* Configure layout: */
    164         m_pLayoutMain->setSpacing(0);
    165         m_pLayoutMain->setContentsMargins(3, 4, 5, 0);
    166 
    167         /* Prepare stacked-layout: */
    168         prepareStackedLayout();
    169 
    170         /* Create controls layout: */
    171         m_pLayoutControls = new QHBoxLayout;
    172         AssertPtrReturnVoid(m_pLayoutControls);
    173         {
    174             /* Configure layout: */
    175             m_pLayoutControls->setSpacing(0);
    176             m_pLayoutControls->setContentsMargins(0, 0, 0, 0);
    177 
    178             /* Prepare tab-bar: */
    179             prepareTabBar();
    180 
    181             /* Add stretch: */
    182             m_pLayoutControls->addStretch();
    183 
    184             /* Prepare menu-toolbar: */
    185             prepareMenuToolbar();
    186 
    187             /* Add and activate snapshots pane: */
    188             activateTabBarTab(ToolType_SnapshotManager, false);
    189 
    190             /* Add into layout: */
    191             m_pLayoutMain->addLayout(m_pLayoutControls);
    192         }
    193     }
    194 
    195     /* Apply language settings: */
    196     retranslateUi();
    197 }
    198 
    199 void UIToolsPane::prepareStackedLayout()
    200 {
    201     /* Create stacked-layout: */
    202     m_pStackedLayout = new QStackedLayout;
    203     AssertPtrReturnVoid(m_pStackedLayout);
    204     {
    205         /* Add into layout: */
    206         m_pLayoutMain->addLayout(m_pStackedLayout);
    207     }
    208 }
    209 
    210 void UIToolsPane::prepareTabBar()
    211 {
    212     /* Create tab-bar: */
    213     m_pTabBar = new QTabBar;
    214     AssertPtrReturnVoid(m_pTabBar);
    215     {
    216         /* Configure tab-bar: */
    217         const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.375;
    218         m_pTabBar->setIconSize(QSize(iIconMetric, iIconMetric));
    219         m_pTabBar->setMovable(true);
    220 #ifdef VBOX_WS_MAC
    221         /* Snapshots pane tab looks quite alone under macOS: */
    222         m_pTabBar->setAutoHide(true);
    223 #endif
    224         m_pTabBar->setDrawBase(false);
    225         m_pTabBar->setExpanding(false);
    226         m_pTabBar->setShape(QTabBar::RoundedSouth);
    227         m_pTabBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    228         connect(m_pTabBar, &QTabBar::tabMoved, this, &UIToolsPane::sltHandleTabBarTabMoved);
    229         connect(m_pTabBar, &QTabBar::currentChanged, this, &UIToolsPane::sltHandleTabBarCurrentChange);
    230 
    231         /* Add into layout: */
    232         m_pLayoutControls->addWidget(m_pTabBar);
    233     }
    234 }
    235 
    236 void UIToolsPane::prepareMenuToolbar()
    237 {
    238     /* Create menu-toolbar: */
    239     m_pMenuToolbar = new UIMenuToolBar;
    240     AssertPtrReturnVoid(m_pMenuToolbar);
    241     {
    242         /* Configure menu-toolbar: */
    243         const int iIconMetric = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
    244         m_pMenuToolbar->setIconSize(QSize(iIconMetric, iIconMetric));
    245         m_pMenuToolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    246         m_pMenuToolbar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    247         m_pMenuToolbar->setAlignmentType(UIMenuToolBar::AlignmentType_BottomRight);
    248 
    249         /* Prepare menu: */
    250         prepareMenu();
    251 
    252         /* Add into layout: */
    253         m_pLayoutControls->addWidget(m_pMenuToolbar);
    254     }
    255 }
    256 
    257 void UIToolsPane::prepareMenu()
    258 {
    259     /* Create menu: */
    260     m_pMenu = new QMenu(m_pMenuToolbar);
    261     AssertPtrReturnVoid(m_pMenu);
    262     {
    263         /* Configure menus: */
    264         m_pMenu->setIcon(UIIconPool::iconSet(":/guesttools_16px.png"));
    265 
    266         /* Create SnapShot manager action: */
    267         m_actions[ToolType_SnapshotManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/snapshot_manager_22px.png",
    268                                                                                           ":/snapshot_manager_16px.png"),
    269                                                                   QString(), this, &UIToolsPane::sltHandleMenuToolbarTrigger);
    270         {
    271             m_actions[ToolType_SnapshotManager]->setCheckable(true);
    272             m_actions[ToolType_SnapshotManager]->
    273                 setProperty("ToolType", QVariant::fromValue(ToolType_SnapshotManager));
    274         }
    275 
    276         /* Create Virtual Media manager action: */
    277         m_actions[ToolType_VirtualMediaManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/diskimage_22px.png",
    278                                                                                               ":/diskimage_16px.png"),
    279                                                                       QString(), this, &UIToolsPane::sltHandleMenuToolbarTrigger);
    280         {
    281             m_actions[ToolType_VirtualMediaManager]->setCheckable(true);
    282             m_actions[ToolType_VirtualMediaManager]->
    283                 setProperty("ToolType", QVariant::fromValue(ToolType_VirtualMediaManager));
    284         }
    285 
    286         /* Create Host Network manager action: */
    287         m_actions[ToolType_HostNetworkManager] = m_pMenu->addAction(UIIconPool::iconSetFull(":/host_iface_manager_22px.png",
    288                                                                                              ":/host_iface_manager_16px.png"),
    289                                                                      QString(), this, &UIToolsPane::sltHandleMenuToolbarTrigger);
    290         {
    291             m_actions[ToolType_HostNetworkManager]->setCheckable(true);
    292             m_actions[ToolType_HostNetworkManager]->
    293                 setProperty("ToolType", QVariant::fromValue(ToolType_HostNetworkManager));
    294         }
    295 
    296         /* Add as tool-button into tool-bar: */
    297         m_pMenuToolbar->setMenuAction(m_pMenu->menuAction());
    298     }
    299 }
    300 
    301 void UIToolsPane::cleanup()
    302 {
    303     /* Remove all tab prematurelly: */
    304     while (m_pTabBar->count())
    305     {
    306         m_pTabBar->removeTab(0);
    307         QWidget *pWidget = m_pStackedLayout->widget(0);
    308         m_pStackedLayout->removeWidget(pWidget);
     201        m_pLayout->setSpacing(0);
     202        m_pLayout->setContentsMargins(3, 4, 5, 0);
     203    }
     204
     205    /* Create desktop pane: */
     206    openTool(ToolTypeMachine_Desktop);
     207}
     208
     209void UIToolsPaneMachine::cleanup()
     210{
     211    /* Remove all widgets prematurelly: */
     212    while (m_pLayout->count())
     213    {
     214        QWidget *pWidget = m_pLayout->widget(0);
     215        m_pLayout->removeWidget(pWidget);
    309216        delete pWidget;
    310217    }
    311218}
    312219
    313 void UIToolsPane::activateTabBarTab(ToolType enmType, bool fCloseable)
    314 {
    315     /* Search for a tab with such type: */
    316     int iActualTabIndex = -1;
    317     for (int iTabIndex = 0; iTabIndex < m_pTabBar->count(); ++iTabIndex)
    318         if (m_pTabBar->tabData(iTabIndex).value<ToolType>() == enmType)
    319             iActualTabIndex = iTabIndex;
    320 
    321     /* If tab with such type doesn't exist: */
    322     m_pTabBar->blockSignals(true);
    323     if (iActualTabIndex == -1)
    324     {
    325         /* Append stack-widget with corresponding page: */
    326         switch (enmType)
    327         {
    328             case ToolType_SnapshotManager:
    329                 m_pPaneSnapshots = new UISnapshotPane;
    330                 m_pStackedLayout->addWidget(m_pPaneSnapshots);
    331                 break;
    332             case ToolType_VirtualMediaManager:
    333                 m_pStackedLayout->addWidget(new UIMediumManagerWidget(EmbedTo_Stack));
    334                 break;
    335             case ToolType_HostNetworkManager:
    336                 m_pStackedLayout->addWidget(new UIHostNetworkManagerWidget(EmbedTo_Stack));
    337                 break;
    338             default:
    339                 AssertFailedReturnVoid();
    340         }
    341 
    342         /* Append tab-bar with corresponding tab: */
    343         iActualTabIndex = m_pTabBar->addTab(m_actions.value(enmType)->icon(), m_actions.value(enmType)->text());
    344         {
    345             /* Create close button if requested: */
    346             if (fCloseable)
    347             {
    348                 QIToolButton *pButtonClose = new QIToolButton;
    349                 AssertPtrReturnVoid(pButtonClose);
    350                 {
    351                     /* Configure button: */
    352 #ifdef VBOX_WS_MAC
    353                     /* Close buttons should be a bit smaller on macOS: */
    354                     pButtonClose->setIconSize(QSize(12, 12));
    355 #endif
    356                     pButtonClose->setIcon(UIIconPool::iconSet(":/close_16px.png"));
    357                     pButtonClose->setProperty("ToolType", QVariant::fromValue(enmType));
    358                     connect(pButtonClose, &QIToolButton::clicked, this, &UIToolsPane::sltHandleTabBarButtonClick);
    359                     /* Add into tab-bar: */
    360                     m_pTabBar->setTabButton(iActualTabIndex, QTabBar::RightSide, pButtonClose);
    361                 }
    362             }
    363 #ifdef VBOX_WS_MAC
    364             /* Create placeholder of the same height if on macOS: */
    365             else
    366             {
    367                 QWidget *pWidget = new QWidget;
    368                 pWidget->setFixedSize(1, 26);
    369                 m_pTabBar->setTabButton(iActualTabIndex, QTabBar::RightSide, pWidget);
    370             }
    371 #endif
    372             /* Store the data: */
    373             m_pTabBar->setTabData(iActualTabIndex, QVariant::fromValue(enmType));
    374         }
    375 
    376         /* Notify listeners: */
    377         emit sigToolOpened(enmType);
    378     }
    379 
    380     /* Activate corresponding indexes: */
    381     m_pStackedLayout->setCurrentIndex(iActualTabIndex);
    382     m_pTabBar->setCurrentIndex(iActualTabIndex);
    383     m_pTabBar->blockSignals(false);
    384 
    385     /* Make sure action is checked: */
    386     m_actions[enmType]->blockSignals(true);
    387     m_actions[enmType]->setChecked(true);
    388     m_actions[enmType]->blockSignals(false);
    389 }
    390 
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsPaneMachine.h

    r68055 r68175  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIToolsPane class declaration.
     3 * VBox Qt GUI - UIToolsPaneMachine class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef ___UIToolsPane_h___
    19 #define ___UIToolsPane_h___
     18#ifndef ___UIToolsPaneMachine_h___
     19#define ___UIToolsPaneMachine_h___
    2020
    2121/* Qt includes: */
    2222#include <QWidget>
    2323
    24 /* GUI includes: */
    25 #include "QIWithRetranslateUI.h"
    26 
    2724/* Forward declarations: */
    28 class QAction;
    2925class QHBoxLayout;
    30 class QMenu;
    3126class QStackedLayout;
    32 class QTabBar;
    3327class QVBoxLayout;
    34 class UIMenuToolBar;
     28class UIActionPool;
     29class UIDesktopPane;
     30class UIGDetails;
    3531class UISnapshotPane;
     32class UIVMItem;
    3633class CMachine;
    3734
    3835
    39 /** Tool types. */
    40 enum ToolType
     36/** Machine tool types. */
     37enum ToolTypeMachine
    4138{
    42     ToolType_Invalid,
    43     ToolType_SnapshotManager,
    44     ToolType_VirtualMediaManager,
    45     ToolType_HostNetworkManager,
     39    ToolTypeMachine_Invalid,
     40    ToolTypeMachine_Desktop,
     41    ToolTypeMachine_Details,
     42    ToolTypeMachine_Snapshots,
    4643};
    4744
    48 /* Make sure QVariant can eat ToolType: */
    49 Q_DECLARE_METATYPE(ToolType);
     45/* Make sure QVariant can eat ToolTypeMachine: */
     46Q_DECLARE_METATYPE(ToolTypeMachine);
    5047
    5148
    5249/** QWidget subclass representing container for tool panes. */
    53 class UIToolsPane : public QIWithRetranslateUI<QWidget>
     50class UIToolsPaneMachine : public QWidget
    5451{
    5552    Q_OBJECT;
     
    5754signals:
    5855
    59     /** Notifies listeners about tool of particular @a enmType is opened. */
    60     void sigToolOpened(ToolType enmType);
     56    /** Redirects signal from UISelectorWindow to UIGDetails. */
     57    void sigSlidingStarted();
     58    /** Redirects signal from UISelectorWindow to UIGDetails. */
     59    void sigToggleStarted();
     60    /** Redirects signal from UISelectorWindow to UIGDetails. */
     61    void sigToggleFinished();
     62    /** Redirects signal from UIGDetails to UISelectorWindow. */
     63    void sigLinkClicked(const QString &strCategory, const QString &strControl, const QString &strId);
    6164
    6265public:
    6366
    6467    /** Constructs tools pane passing @a pParent to the base-class. */
    65     UIToolsPane(QWidget *pParent = 0);
     68    UIToolsPaneMachine(UIActionPool *pActionPool, QWidget *pParent = 0);
    6669    /** Destructs tools pane. */
    67     virtual ~UIToolsPane() /* override */;
     70    virtual ~UIToolsPaneMachine() /* override */;
    6871
    6972    /** Returns whether tool of particular @a enmType is opened. */
    70     bool isToolOpened(ToolType enmType) const;
    71     /** Activates tool of particular @a enmType, creates new one if necessary. */
    72     void setCurrentTool(ToolType enmType);
     73    bool isToolOpened(ToolTypeMachine enmType) const;
     74    /** Activates tool of passed @a enmType, creates new one if necessary. */
     75    void openTool(ToolTypeMachine enmType);
     76    /** Closes tool of passed @a enmType, deletes one if exists. */
     77    void closeTool(ToolTypeMachine enmType);
     78
     79    /** Defines @a strText and switches to text details pane. */
     80    void setDetailsText(const QString &strText);
     81    /** Defines @a strError and switches to error details pane. */
     82    void setDetailsError(const QString &strError);
     83
     84    /** Defines the machine @a items. */
     85    void setItems(const QList<UIVMItem*> &items);
    7386
    7487    /** Defines the @a comMachine object. */
    7588    void setMachine(const CMachine &comMachine);
    76 
    77 protected:
    78 
    79     /** Handles translation event. */
    80     virtual void retranslateUi() /* override */;
    81 
    82 private slots:
    83 
    84     /** Handles menu-toolbar trigger. */
    85     void sltHandleMenuToolbarTrigger();
    86 
    87     /** Handles Tools tab-bar tab movement. */
    88     void sltHandleTabBarTabMoved(int iFrom, int iTo);
    89     /** Handles Tools tab-bar current tab change. */
    90     void sltHandleTabBarCurrentChange(int iIndex);
    91     /** Handles Tools tab-bar button click. */
    92     void sltHandleTabBarButtonClick();
    9389
    9490private:
     
    9894    /** Prepares stacked-layout. */
    9995    void prepareStackedLayout();
    100     /** Prepares tab-bar. */
    101     void prepareTabBar();
    102     /** Prepares menu-toolbar. */
    103     void prepareMenuToolbar();
    104     /** Prepares menu. */
    105     void prepareMenu();
    10696    /** Cleanups all. */
    10797    void cleanup();
    10898
    109     /** Activates corresponding tab-bar tab, adds new if necessary. */
    110     void activateTabBarTab(ToolType enmType, bool fCloseable);
     99    /** Holds the action pool reference. */
     100    UIActionPool *m_pActionPool;
    111101
    112     /** Holds the main layout isntance. */
    113     QVBoxLayout               *m_pLayoutMain;
    114102    /** Holds the stacked-layout instance. */
    115     QStackedLayout            *m_pStackedLayout;
    116     /** Holds the snapshot pane. */
    117     UISnapshotPane            *m_pPaneSnapshots;
    118     /** Holds the controls layout instance. */
    119     QHBoxLayout               *m_pLayoutControls;
    120     /** Holds the tab-bar instance. */
    121     QTabBar                   *m_pTabBar;
    122     /** Holds the menu-toolbar instance. */
    123     UIMenuToolBar             *m_pMenuToolbar;
    124     /** Holds the menu instance. */
    125     QMenu                     *m_pMenu;
    126     /** Holds the menu action instances. */
    127     QMap<ToolType, QAction*>  m_actions;
     103    QStackedLayout *m_pLayout;
     104    /** Holds the Desktop pane instance. */
     105    UIDesktopPane  *m_pPaneDesktop;
     106    /** Holds the Details pane instance. */
     107    UIGDetails     *m_pPaneDetails;
     108    /** Holds the Snapshots pane instance. */
     109    UISnapshotPane *m_pPaneSnapshots;
    128110};
    129111
    130 #endif /* !___UIToolsPane_h___ */
     112#endif /* !___UIToolsPaneMachine_h___ */
    131113
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsToolbar.cpp

    r68171 r68175  
    161161
    162162        /* Create stacked layout: */
    163         m_pLayoutStacked = new QStackedLayout;
     163        m_pLayoutStacked = new QStackedLayout(m_pLayoutMain);
    164164        AssertPtrReturnVoid(m_pLayoutStacked);
    165165        {
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UIToolsToolbar.h

    r68169 r68175  
    2424#include <QWidget>
    2525
     26/* GUI includes: */
     27#include "UIToolsPaneMachine.h"
     28
    2629/* Forward declarations: */
    2730class QAction;
     
    3538class UIActionPool;
    3639class UITabBar;
    37 
    38 
    39 /** Machine tool types. */
    40 enum ToolTypeMachine
    41 {
    42     ToolTypeMachine_Invalid,
    43     ToolTypeMachine_Desktop,
    44     ToolTypeMachine_Details,
    45     ToolTypeMachine_Snapshots,
    46 };
    47 
    48 /* Make sure QVariant can eat ToolTypeMachine: */
    49 Q_DECLARE_METATYPE(ToolTypeMachine);
    5040
    5141
Note: See TracChangeset for help on using the changeset viewer.

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