VirtualBox

Ignore:
Timestamp:
Jun 1, 2018 9:48:31 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt bugref:9183 Introducing a medium selector to machine storage settings

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumItem.cpp

    r72374 r72406  
    5454
    5555UIMediumItem::UIMediumItem(const UIMedium &guiMedium, UIMediumItem *pParent)
     56    : QITreeWidgetItem(pParent)
     57    , m_guiMedium(guiMedium)
     58{
     59    refresh();
     60}
     61
     62UIMediumItem::UIMediumItem(const UIMedium &guiMedium, QITreeWidgetItem *pParent)
    5663    : QITreeWidgetItem(pParent)
    5764    , m_guiMedium(guiMedium)
     
    303310}
    304311
     312UIMediumItemHD::UIMediumItemHD(const UIMedium &guiMedium, QITreeWidgetItem *pParent)
     313    : UIMediumItem(guiMedium, pParent)
     314{
     315}
     316
    305317bool UIMediumItemHD::remove()
    306318{
     
    425437}
    426438
     439UIMediumItemCD::UIMediumItemCD(const UIMedium &guiMedium, QITreeWidgetItem *pParent)
     440    : UIMediumItem(guiMedium, pParent)
     441{
     442}
     443
    427444bool UIMediumItemCD::remove()
    428445{
     
    491508}
    492509
     510UIMediumItemFD::UIMediumItemFD(const UIMedium &guiMedium, QITreeWidgetItem *pParent)
     511    : UIMediumItem(guiMedium, pParent)
     512{
     513}
     514
    493515bool UIMediumItemFD::remove()
    494516{
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumItem.h

    r72374 r72406  
    3737      * @param  pParent    Brings the parent item reference. */
    3838    UIMediumItem(const UIMedium &guiMedium, UIMediumItem *pParent);
     39    /** Constructs sub-level item under a QITreeWidgetItem.
     40      * @param  guiMedium  Brings the medium to wrap around.
     41      * @param  pParent    Brings the parent item reference. */
     42    UIMediumItem(const UIMedium &guiMedium, QITreeWidgetItem *pParent);
    3943
    4044    /** Copies UIMedium wrapped by <i>this</i> item. */
     
    130134      * @param  pParent    Brings the parent item reference. */
    131135    UIMediumItemHD(const UIMedium &guiMedium, UIMediumItem *pParent);
     136    /** Constructs sub-level item under a QITreeWidgetItem.
     137      * @param  guiMedium  Brings the medium to wrap around.
     138      * @param  pParent    Brings the parent item reference. */
     139    UIMediumItemHD(const UIMedium &guiMedium, QITreeWidgetItem *pParent);
    132140
    133141protected:
     
    153161      * @param  pParent    Brings the parent tree reference. */
    154162    UIMediumItemCD(const UIMedium &guiMedium, QITreeWidget *pParent);
     163    /** Constructs sub-level item under a QITreeWidgetItem.
     164      * @param  guiMedium  Brings the medium to wrap around.
     165      * @param  pParent    Brings the parent item reference. */
     166    UIMediumItemCD(const UIMedium &guiMedium, QITreeWidgetItem *pParent);
    155167
    156168protected:
     
    171183      * @param  pParent    Brings the parent tree reference. */
    172184    UIMediumItemFD(const UIMedium &guiMedium, QITreeWidget *pParent);
     185    /** Constructs sub-level item under a QITreeWidgetItem.
     186      * @param  guiMedium  Brings the medium to wrap around.
     187      * @param  pParent    Brings the parent item reference. */
     188    UIMediumItemFD(const UIMedium &guiMedium, QITreeWidgetItem *pParent);
    173189
    174190protected:
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp

    r72374 r72406  
    2121
    2222/* Qt includes: */
    23 # include <QFrame>
    24 # include <QHBoxLayout>
    25 # include <QHeaderView>
    26 # include <QLabel>
    27 # include <QMenuBar>
    28 # include <QProgressBar>
     23# include <QAction>
     24# include <QVBoxLayout>
    2925# include <QPushButton>
    30 # include <QVBoxLayout>
    3126
    3227/* GUI includes: */
    3328# include "QIDialogButtonBox.h"
    34 # include "QIFileDialog.h"
    35 # include "QILabel.h"
    3629# include "QIMessageBox.h"
    3730# include "QITabWidget.h"
    38 # include "QITreeWidget.h"
    3931# include "VBoxGlobal.h"
    4032# include "UIExtraDataManager.h"
    41 # include "UIMediumManager.h"
    4233# include "UIMediumSelector.h"
    43 # include "UIWizardCloneVD.h"
    44 # include "UIMessageCenter.h"
    45 # include "UIToolBar.h"
    4634# include "UIIconPool.h"
    4735# include "UIMedium.h"
    4836# include "UIMediumItem.h"
     37# include "UIToolBar.h"
    4938
    5039/* COM includes: */
     
    6857    , m_pTreeWidget(0)
    6958    , m_enmMediumType(enmMediumType)
     59    , m_pButtonBox(0)
     60    , m_pToolBar(0)
     61    , m_pActionAdd(0)
     62    , m_pActionRefresh(0)
     63    , m_pAttachedSubTreeRoot(0)
     64    , m_pNotAttachedSubTreeRoot(0)
    7065{
    7166    configure();
    7267    finalize();
    73 }
     68    //setAttribute(Qt::WA_DeleteOnClose);
     69}
     70
     71QStringList UIMediumSelector::selectedMediumIds() const
     72{
     73    QStringList selectedIds;
     74    if (!m_pTreeWidget)
     75        return selectedIds;
     76    QList<QTreeWidgetItem*> selectedItems = m_pTreeWidget->selectedItems();
     77    for (int i = 0; i < selectedItems.size(); ++i)
     78    {
     79        UIMediumItem *item = dynamic_cast<UIMediumItem*>(selectedItems.at(i));
     80        if (item)
     81            selectedIds.push_back(item->medium().id());
     82    }
     83    return selectedIds;
     84}
     85
    7486
    7587void UIMediumSelector::retranslateUi()
    7688{
     89    if (m_pActionAdd)
     90    {
     91        m_pActionAdd->setText(QApplication::translate("UIMediumManager", "&Add..."));
     92        m_pActionAdd->setToolTip(QApplication::translate("UIMediumManager", "Add Disk Image File"));
     93        m_pActionAdd->setStatusTip(QApplication::translate("UIMediumManager", "Add disk image file"));
     94    }
     95    if (m_pActionRefresh)
     96    {
     97        m_pActionRefresh->setText(QApplication::translate("UIMediumManager","Re&fresh"));
     98        m_pActionRefresh->setToolTip(QApplication::translate("UIMediumManager","Refresh Disk Image Files (%1)").arg(m_pActionRefresh->shortcut().toString()));
     99        m_pActionRefresh->setStatusTip(QApplication::translate("UIMediumManager","Refresh the list of disk image files"));
     100    }
     101
     102    if (m_pButtonBox)
     103        m_pButtonBox->button(QDialogButtonBox::Ok)->setText("Add Selected");
    77104}
    78105
     
    81108    /* Apply window icons: */
    82109    setWindowIcon(UIIconPool::iconSetFull(":/diskimage_32px.png", ":/diskimage_16px.png"));
     110    prepareActions();
    83111    prepareWidgets();
     112    prepareConnections();
     113}
     114
     115void UIMediumSelector::prepareActions()
     116{
     117    m_pActionAdd = new QAction(this);
     118    if (m_pActionAdd)
     119    {
     120        /* Configure add-action: */
     121        m_pActionAdd->setShortcut(QKeySequence("Ctrl+A"));
     122        QString strPrefix("hd");
     123        switch (m_enmMediumType)
     124        {
     125            case UIMediumType_DVD:
     126                strPrefix = "cd";
     127                break;
     128            case UIMediumType_Floppy:
     129                strPrefix = "fd";
     130                break;
     131            case UIMediumType_HardDisk:
     132            case UIMediumType_All:
     133            case UIMediumType_Invalid:
     134            default:
     135                strPrefix = "hd";
     136                break;
     137        }
     138
     139        m_pActionAdd->setIcon(UIIconPool::iconSetFull(QString(":/%1_add_22px.png").arg(strPrefix),
     140                                                      QString(":/%1_add_16px.png").arg(strPrefix),
     141                                                      QString(":/%1_add_disabled_22px.png").arg(strPrefix),
     142                                                      QString(":/%1_add_disabled_16px.png").arg(strPrefix)));
     143    }
     144
     145    m_pActionRefresh = new QAction(this);
     146    if (m_pActionRefresh)
     147    {
     148        m_pActionRefresh->setShortcut(QKeySequence(QKeySequence::Refresh));
     149        if (m_pActionRefresh && m_pActionRefresh->icon().isNull())
     150            m_pActionRefresh->setIcon(UIIconPool::iconSetFull(":/refresh_22px.png", ":/refresh_16px.png",
     151                                                              ":/refresh_disabled_22px.png", ":/refresh_disabled_16px.png"));
     152    }
     153}
     154
     155void UIMediumSelector::prepareConnections()
     156{
     157    /* Configure medium-enumeration connections: */
     158    connect(&vboxGlobal(), &VBoxGlobal::sigMediumEnumerationStarted,
     159            this, &UIMediumSelector::sltHandleMediumEnumerationStart);
     160    connect(&vboxGlobal(), &VBoxGlobal::sigMediumEnumerated,
     161            this, &UIMediumSelector::sltHandleMediumEnumerated);
     162    connect(&vboxGlobal(), &VBoxGlobal::sigMediumEnumerationFinished,
     163            this, &UIMediumSelector::sltHandleMediumEnumerationFinish);
     164    if (m_pActionAdd)
     165        connect(m_pActionAdd, &QAction::triggered, this, &UIMediumSelector::sltAddMedium);
     166    if (m_pActionRefresh)
     167        connect(m_pActionRefresh, &QAction::triggered, this, &UIMediumSelector::sltHandleRefresh);
     168}
     169
     170UIMediumItem* UIMediumSelector::addTreeItem(const UIMedium &medium, QITreeWidgetItem *pParent)
     171{
     172    if (!pParent)
     173        return 0;
     174    switch (m_enmMediumType)
     175    {
     176        case UIMediumType_DVD:
     177            return new UIMediumItemCD(medium, pParent);
     178            break;
     179        case UIMediumType_Floppy:
     180            return new UIMediumItemFD(medium, pParent);
     181
     182            break;
     183        case UIMediumType_HardDisk:
     184        case UIMediumType_All:
     185        case UIMediumType_Invalid:
     186        default:
     187            return new UIMediumItemHD(medium, pParent);
     188            break;
     189    }
     190
     191    return 0;
     192}
     193
     194void UIMediumSelector::restoreSelection(const QStringList &selectedMediums, QVector<UIMediumItem*> &mediumList)
     195{
     196    if (!m_pTreeWidget)
     197        return;
     198    if (selectedMediums.isEmpty())
     199    {
     200        m_pTreeWidget->setCurrentItem(0);
     201        return;
     202    }
     203    bool selected = false;
     204    for (int i = 0; i < mediumList.size(); ++i)
     205    {
     206        if (!mediumList[i])
     207            continue;
     208        if (selectedMediums.contains(mediumList[i]->medium().id()))
     209        {
     210            mediumList[i]->setSelected(true);
     211            selected = true;
     212        }
     213    }
     214
     215    if (!selected)
     216        m_pTreeWidget->setCurrentItem(0);
     217    return;
    84218}
    85219
     
    89223    if (!m_pMainLayout)
    90224        return;
     225
    91226    setLayout(m_pMainLayout);
     227
     228    m_pToolBar = new UIToolBar(parentWidget());
     229    if (m_pToolBar)
     230    {
     231        /* Configure toolbar: */
     232        const int iIconMetric = (int)(QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize) * 1.375);
     233        m_pToolBar->setIconSize(QSize(iIconMetric, iIconMetric));
     234        m_pToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
     235        /* Add toolbar actions: */
     236        if (m_pActionAdd)
     237            m_pToolBar->addAction(m_pActionAdd);
     238        if (m_pActionRefresh)
     239            m_pToolBar->addAction(m_pActionRefresh);
     240
     241        m_pMainLayout->addWidget(m_pToolBar);
     242    }
    92243
    93244    m_pTreeWidget = new QITreeWidget;
    94245    if (m_pTreeWidget)
    95246    {
     247        m_pTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
     248        //connect(m_pTreeWidget, &QITreeWidget::currentItemChanged, this, &UIMediumSelector::sltHandleCurrentItemChanged);
     249        connect(m_pTreeWidget, &QITreeWidget::itemSelectionChanged, this, &UIMediumSelector::sltHandleItemSelectionChanged);
    96250        m_pMainLayout->addWidget(m_pTreeWidget);
    97251    }
     252
     253        m_pButtonBox = new QIDialogButtonBox;
     254    if (m_pButtonBox)
     255    {
     256        /* Configure button-box: */
     257        m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
     258        m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
     259        // connect(m_pButtonBox, &QIDialogButtonBox::helpRequested, &msgCenter(), &UIMessageCenter::sltShowHelpHelpDialog);
     260        connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIMediumSelector::close);
     261        connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIMediumSelector::accept);
     262
     263        /* Add button-box into main layout: */
     264        m_pMainLayout->addWidget(m_pButtonBox);
     265    }
     266
    98267    repopulateTreeWidget();
    99268    //m_pMainLayout->addWidget(
    100269}
    101270
     271void UIMediumSelector::sltAddMedium()
     272{
     273    QString strDefaultMachineFolder = vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
     274    vboxGlobal().openMediumWithFileOpenDialog(m_enmMediumType, this, strDefaultMachineFolder);
     275}
     276
     277// void UIMediumSelector::sltHandleCurrentItemChanged()
     278// {
     279//     printf("%d\n", m_pTreeWidget->selectedItems().size());
     280//     updateOkButton();
     281
     282// }
     283
     284void UIMediumSelector::sltHandleItemSelectionChanged()
     285{
     286    updateOkButton();
     287}
     288
     289void UIMediumSelector::sltHandleMediumEnumerationStart()
     290{
     291    /* Disable controls. Left Alone button box 'Ok' button. it is handle by tree population: */
     292    if (m_pActionRefresh)
     293        m_pActionRefresh->setEnabled(false);
     294}
     295
     296void UIMediumSelector::sltHandleMediumEnumerated()
     297{
     298}
     299
     300void UIMediumSelector::sltHandleMediumEnumerationFinish()
     301{
     302    repopulateTreeWidget();
     303    if (m_pActionRefresh)
     304        m_pActionRefresh->setEnabled(true);
     305}
     306
     307void UIMediumSelector::sltHandleRefresh()
     308{
     309    /* Initialize media enumation: */
     310    vboxGlobal().startMediumEnumeration();
     311}
     312
     313void UIMediumSelector::updateOkButton()
     314{
     315
     316    if (!m_pTreeWidget || !m_pButtonBox || !m_pButtonBox->button(QDialogButtonBox::Ok))
     317        return;
     318    QList<QTreeWidgetItem*> selectedItems = m_pTreeWidget->selectedItems();
     319    if (selectedItems.isEmpty())
     320    {
     321        m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
     322        return;
     323    }
     324
     325    /* check if at least one of the selected items is a UIMediumItem */
     326    bool mediumItemSelected = false;
     327    for (int i = 0; i < selectedItems.size() && !mediumItemSelected; ++i)
     328    {
     329        if (dynamic_cast<UIMediumItem*>(selectedItems.at(i)))
     330            mediumItemSelected = true;
     331    }
     332    if (mediumItemSelected)
     333        m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
     334    else
     335        m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
     336}
     337
    102338void UIMediumSelector::finalize()
    103339{
     
    108344void UIMediumSelector::repopulateTreeWidget()
    109345{
     346    if (!m_pTreeWidget)
     347        return;
     348
     349    /* Cache the currently selected items: */
     350    QList<QTreeWidgetItem*> selectedItems = m_pTreeWidget->selectedItems();
     351    QStringList selectedMediums = selectedMediumIds();
     352    /* uuid list of selected items: */
     353    /* Reset the related data structure: */
     354    m_pTreeWidget->clear();
     355    m_pAttachedSubTreeRoot = 0;
     356    m_pNotAttachedSubTreeRoot = 0;
     357    QVector<UIMediumItem*> menuItemList;
     358
     359    foreach (const QString &strMediumID, vboxGlobal().mediumIDs())
     360    {
     361        UIMedium medium = vboxGlobal().medium(strMediumID);
     362
     363        if (medium.type() == m_enmMediumType)
     364        {
     365            bool isMediumAttached = !(medium.medium().GetMachineIds().isEmpty());
     366            QITreeWidgetItem *pParent = 0;
     367            if (isMediumAttached)
     368            {
     369                if (!m_pAttachedSubTreeRoot)
     370                {
     371                    QStringList strList;
     372                    strList << "Attached";
     373                    m_pAttachedSubTreeRoot = new QITreeWidgetItem(m_pTreeWidget, strList);
     374                }
     375                pParent = m_pAttachedSubTreeRoot;
     376
     377            }
     378            else
     379            {
     380                if (!m_pNotAttachedSubTreeRoot)
     381                {
     382                    QStringList strList;
     383                    strList << "Not Attached";
     384                    m_pNotAttachedSubTreeRoot = new QITreeWidgetItem(m_pTreeWidget, strList);
     385                }
     386                pParent = m_pNotAttachedSubTreeRoot;
     387            }
     388            menuItemList.push_back(addTreeItem(medium, pParent));
     389        }
     390    }
     391    restoreSelection(selectedMediums, menuItemList);
     392
     393    updateOkButton();
     394    if (m_pAttachedSubTreeRoot)
     395        m_pTreeWidget->expandItem(m_pAttachedSubTreeRoot);
     396
     397    if (m_pNotAttachedSubTreeRoot)
     398        m_pTreeWidget->expandItem(m_pNotAttachedSubTreeRoot);
     399
     400    // QItemSelectionModel *selectionModel = m_pTreeWidget->selectionModel();
     401    // selectionModel->clearSelection();
     402
    110403    // /* Remember current medium-items: */
    111404    // if (UIMediumItem *pMediumItem = mediumItem(UIMediumType_HardDisk))
     
    138431    // /* Create medium-items (do not change current one): */
    139432    // m_fPreventChangeCurrentItem = true;
    140     // foreach (const QString &strMediumID, vboxGlobal().mediumIDs())
    141     // {
    142     //     //sltHandleMediumCreated(strMediumID);
    143     //     UIMedium medium = vboxGlobal().medium(strMediumID);
    144     //     if (medium.type() == m_enmMediumType)
    145     //         printf("%s %s\n", qPrintable(strMediumID), qPrintable(medium.name()));
    146     //     if (m_enmMediumType == UIMediumType_HardDisk)
    147     //     {
    148     //         //new UIMediumItemHD(medium, m_pTreeWidget);
    149     //     }
    150     // }
     433
    151434    // m_fPreventChangeCurrentItem = false;
    152435
     
    161444    //     if (QTreeWidgetItem *pItem = pTreeWidgetFD->topLevelItem(0))
    162445    //         setCurrentItem(pTreeWidgetFD, pItem);
    163 }
     446
     447
     448}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h

    r72374 r72406  
    2727
    2828/* Forward declarations: */
    29 class CheckIfSuitableBy;
    30 class QAbstractButton;
    31 class QLabel;
    32 class QProgressBar;
    33 class QTabWidget;
     29class QAction;
     30class QTreeWidgetItem;
    3431class QITreeWidget;
     32class QITreeWidgetItem;
    3533class QVBoxLayout;
    3634class QIDialogButtonBox;
    37 class QILabel;
    3835class UIMediumItem;
    3936class UIToolBar;
     
    5148
    5249    UIMediumSelector(UIMediumType enmMediumType, QWidget *pParent = 0);
     50    QStringList selectedMediumIds() const;
    5351
    5452private slots:
     53
     54    void sltAddMedium();
     55    //void sltHandleCurrentItemChanged();
     56    void sltHandleItemSelectionChanged();
     57    void sltHandleMediumEnumerationStart();
     58    void sltHandleMediumEnumerated();
     59    void sltHandleMediumEnumerationFinish();
     60    void sltHandleRefresh();
    5561
    5662private:
     
    6672      * @{ */
    6773        /** Configures all. */
    68         void configure();
    69         void prepareWidgets();
     74            void configure();
     75            void prepareWidgets();
     76            void prepareActions();
     77            void prepareConnections();
    7078        /** Perform final preparations. */
    7179        void finalize();
     
    7381
    7482    void repopulateTreeWidget();
     83    /** Disable/enable 'ok' button on the basis of having a selected item */
     84    void updateOkButton();
     85    UIMediumItem* addTreeItem(const UIMedium &medium, QITreeWidgetItem *pParent);
     86    void restoreSelection(const QStringList &selectedMediums, QVector<UIMediumItem*> &mediumList);
    7587
    76     QVBoxLayout  *m_pMainLayout;
    77     QITreeWidget *m_pTreeWidget;
    78     UIMediumType  m_enmMediumType;
     88    QVBoxLayout       *m_pMainLayout;
     89    QITreeWidget      *m_pTreeWidget;
     90    UIMediumType       m_enmMediumType;
     91    QIDialogButtonBox *m_pButtonBox;
     92    UIToolBar         *m_pToolBar;
     93    QAction           *m_pActionAdd;
     94    QAction           *m_pActionRefresh;
     95    /** All the known media that are already attached to some vm are added under the following top level tree item */
     96    QITreeWidgetItem  *m_pAttachedSubTreeRoot;
     97    /** All the known media that are not attached to any vm are added under the following top level tree item */
     98    QITreeWidgetItem  *m_pNotAttachedSubTreeRoot;
    7999};
    80100
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r71453 r72406  
    3939# include "UIMessageCenter.h"
    4040# include "UIMachineSettingsStorage.h"
     41# include "UIMediumSelector.h"
    4142# include "UIConverter.h"
    4243# include "UIMedium.h"
    4344# include "UIExtraDataManager.h"
     45# include "UIModalWindowManager.h"
    4446
    4547/* COM includes: */
     
    37923794}
    37933795
     3796QString UIMachineSettingsStorage::openMediumSelectorDialog(UIMediumType  enmMediumType)
     3797{
     3798    QWidget *pParent = windowManager().realParentWindow(this);
     3799    QPointer<UIMediumSelector> pSelector = new UIMediumSelector(enmMediumType, pParent);
     3800
     3801    if (!pSelector)
     3802        return QString();
     3803    windowManager().registerNewParent(pSelector, pParent);
     3804    if (pSelector->execute(true, false))
     3805    {
     3806        QStringList selectedMediumIds = pSelector->selectedMediumIds();
     3807        delete pSelector;
     3808        /* Currently we only care about the 0th since we support single selection by intention: */
     3809        if (selectedMediumIds.isEmpty())
     3810            return QString();
     3811        else
     3812            return selectedMediumIds[0];
     3813    }
     3814
     3815    delete pSelector;
     3816    return QString();
     3817}
     3818
    37943819void UIMachineSettingsStorage::addAttachmentWrapper(KDeviceType enmDevice)
    37953820{
     
    38093834                strMediumId = getWithNewHDWizard();
    38103835            else if (iAnswer == AlertButton_Choice2)
    3811                 strMediumId = vboxGlobal().openMediumWithFileOpenDialog(UIMediumType_HardDisk, this, strMachineFolder);
     3836                strMediumId = openMediumSelectorDialog(UIMediumType_HardDisk);
    38123837            break;
    38133838        }
     
    38183843                strMediumId = vboxGlobal().medium(strMediumId).id();
    38193844            else if (iAnswer == AlertButton_Choice2)
    3820                 strMediumId = vboxGlobal().openMediumWithFileOpenDialog(UIMediumType_DVD, this, strMachineFolder);
     3845                strMediumId = openMediumSelectorDialog(UIMediumType_DVD);
    38213846            break;
    38223847        }
     
    38273852                strMediumId = vboxGlobal().medium(strMediumId).id();
    38283853            else if (iAnswer == AlertButton_Choice2)
    3829                 strMediumId = vboxGlobal().openMediumWithFileOpenDialog(UIMediumType_Floppy, this, strMachineFolder);
     3854                strMediumId = openMediumSelectorDialog(UIMediumType_Floppy);
    38303855            break;
    38313856        }
     
    44904515
    44914516# include "UIMachineSettingsStorage.moc"
    4492 
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h

    r72109 r72406  
    741741    /** Prepares connections. */
    742742    void prepareConnections();
     743    /** Opens medium selector dialog and retrieves uuid of a selected medium (if any). */
     744    QString openMediumSelectorDialog(UIMediumType  enmMediumType);
    743745    /** Cleanups all. */
    744746    void cleanup();
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