VirtualBox

Changeset 33668 in vbox


Ignore:
Timestamp:
Nov 2, 2010 1:43:28 AM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: 5302: Reworking New HD wizard for VBox config 4.0 (part 2).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp

    r33667 r33668  
    2525#include "UINewHDWzd.h"
    2626#include "UINewVMWzd.h"
    27 #include "VBoxMediaManagerDlg.h"
     27#include "QIFileDialog.h"
    2828#include "VBoxProblemReporter.h"
    2929#include "VBoxVMSettingsHD.h"
     
    417417    connect(m_pDiskPresent, SIGNAL(toggled(bool)), this, SLOT(hardDiskSourceChanged()));
    418418    connect(m_pDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(hardDiskSourceChanged()));
    419     connect(m_pVMMButton, SIGNAL(clicked()), this, SLOT(getWithMediaManager()));
     419    connect(m_pVMMButton, SIGNAL(clicked()), this, SLOT(getWithFileOpenDialog()));
    420420
    421421    /* Initialise page connections */
     
    532532}
    533533
    534 void UINewVMWzdPage4::getWithMediaManager()
    535 {
    536     VBoxMediaManagerDlg dlg(this);
    537     dlg.setup(VBoxDefs::MediumType_HardDisk, true);
    538 
    539     if (dlg.exec() == QDialog::Accepted)
    540     {
    541         QString newId = dlg.selectedId();
    542         if (m_pDiskSelector->id() != newId)
    543             m_pDiskSelector->setCurrentItem(newId);
    544     }
    545 
    546     hardDiskSourceChanged();
    547 
    548     m_pDiskSelector->setFocus();
     534void UINewVMWzdPage4::getWithFileOpenDialog()
     535{
     536    /* Initialize variables: */
     537    CVirtualBox vbox = vboxGlobal().virtualBox();
     538    QString strHomeFolder = vbox.GetHomeFolder();
     539    QString title = m_pVMMButton->toolTip();
     540    QList < QPair <QString, QString> > filters = vboxGlobal().HDDBackends();
     541    QString allType = tr("hard disk");
     542    QString strFilter;
     543    QStringList backends;
     544    QStringList prefixes;
     545
     546    /* Prepare filters and backends: */
     547    for (int i = 0; i < filters.count(); ++i)
     548    {
     549        /* Get iterated filter: */
     550        QPair <QString, QString> item = filters.at(i);
     551        /* Create one backend filter string: */
     552        backends << QString("%1 (%2)").arg(item.first).arg(item.second);
     553        /* Save the suffix's for the "All" entry: */
     554        prefixes << item.second;
     555    }
     556    if (!prefixes.isEmpty())
     557        backends.insert(0, tr("All %1 images (%2)").arg(allType).arg(prefixes.join(" ").trimmed()));
     558    backends << tr("All files (*)");
     559    strFilter = backends.join(";;").trimmed();
     560
     561    /* Create open file dialog: */
     562    QStringList files = QIFileDialog::getOpenFileNames(strHomeFolder, strFilter, this, title, 0, true, true);
     563    if (!files.empty() && !files[0].isEmpty())
     564    {
     565        /* Get location: */
     566        QString strLocation = files[0];
     567
     568        /* Prepare GUI medium wrapper: */
     569        VBoxMedium vboxMedium;
     570
     571        /* Open corresponding medium: */
     572        CMedium comMedium = vbox.OpenMedium(strLocation, KDeviceType_HardDisk, KAccessMode_ReadWrite);
     573        if (vbox.isOk())
     574            vboxMedium = VBoxMedium(CMedium(comMedium), VBoxDefs::MediumType_HardDisk, KMediumState_Created);
     575
     576        /* Add medium to GUI list: */
     577        if (vbox.isOk())
     578            vboxGlobal().addMedium(vboxMedium);
     579        else
     580            vboxProblem().cannotOpenMedium(this, vbox, VBoxDefs::MediumType_HardDisk, strLocation);
     581
     582        /* Ask medium combobox to select newly added medium: */
     583        m_pDiskSelector->setCurrentItem(vboxMedium.id());
     584
     585        /* Update hard disk source: */
     586        hardDiskSourceChanged();
     587
     588        m_pDiskSelector->setFocus();
     589    }
    549590}
    550591
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.h

    r33667 r33668  
    144144    void ensureNewHardDiskDeleted();
    145145    void hardDiskSourceChanged();
    146     void getWithMediaManager();
     146    void getWithFileOpenDialog();
    147147
    148148private:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzdPage4.ui

    r29001 r33668  
    9191         <bool>true</bool>
    9292        </property>
     93        <property name="toolTip">
     94         <string>Select a hard disk image file</string>
     95        </property>
    9396       </widget>
    9497      </item>
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