VirtualBox

Changeset 33670 in vbox


Ignore:
Timestamp:
Nov 2, 2010 3:53:37 AM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: 5302: Reworking Machine settings / Storage page for VBox config 4.0.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.cpp

    r33558 r33670  
    12971297}
    12981298
    1299 int VBoxProblemReporter::confirmRunNewHDWzdOrVDM (KDeviceType aDeviceType)
     1299int VBoxProblemReporter::confirmRunNewHDWzdOrOFD (KDeviceType aDeviceType)
    13001300{
    13011301    switch (aDeviceType)
     
    13031303        case KDeviceType_HardDisk:
    13041304            return message (QApplication::activeWindow(), Info,
    1305                             tr ("<p>There are no unused media available for the newly "
     1305                            tr ("<p>There are no unused medium available for the newly "
    13061306                                "created attachment.</p>"
    13071307                                "<p>Press the <b>Create</b> button to start the <i>New "
    13081308                                "Virtual Disk</i> wizard and create a new medium, "
    1309                                 "or press the <b>Select</b> if you wish to open the <i>Virtual "
    1310                                 "Media Manager</i>.</p>"),
     1309                                "or press the <b>Select</b> if you wish to open existing "
     1310                                "medium using file-open dialog.</p>"),
    13111311                            0, /* aAutoConfirmId */
    13121312                            QIMessageBox::Yes,
     
    13171317        default:
    13181318            return message (QApplication::activeWindow(), Info,
    1319                             tr ("<p>There are no unused media available for the newly "
     1319                            tr ("<p>There are no unused medium available for the newly "
    13201320                                "created attachment.</p>"
    1321                                 "<p>Press the <b>Select</b> if you wish to open the <i>Virtual "
    1322                                 "Media Manager</i>.</p>"),
     1321                                "<p>Press the <b>Select</b> if you wish to open existing "
     1322                                "medium using file-open dialog.</p>"),
    13231323                            0, /* aAutoConfirmId */
    13241324                            QIMessageBox::No | QIMessageBox::Default,
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxProblemReporter.h

    r33540 r33670  
    256256    int confirmDetachAddControllerSlots (QWidget *aParent) const;
    257257    int confirmChangeAddControllerSlots (QWidget *aParent) const;
    258     int confirmRunNewHDWzdOrVDM (KDeviceType aDeviceType);
     258    int confirmRunNewHDWzdOrOFD (KDeviceType aDeviceType);
    259259
    260260    int confirmRemovingOfLastDVDDevice() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsHD.cpp

    r33632 r33670  
    2323#include "UINewHDWzd.h"
    2424#include "VBoxGlobal.h"
    25 #include "VBoxMediaManagerDlg.h"
     25#include "QIFileDialog.h"
    2626#include "VBoxProblemReporter.h"
    2727#include "VBoxVMSettingsHD.h"
     
    17161716
    17171717    /* Vmm Button */
    1718     mTbVmm->setIcon(UIIconPool::iconSet(PixmapPool::pool()->pixmap (PixmapPool::VMMEn),
     1718    mTbOpen->setIcon(UIIconPool::iconSet(PixmapPool::pool()->pixmap (PixmapPool::VMMEn),
    17191719                                        PixmapPool::pool()->pixmap (PixmapPool::VMMDis)));
     1720    mTbNew->setIcon(UIIconPool::iconSet(PixmapPool::pool()->pixmap (PixmapPool::HDAttachmentAddEn),
     1721                                        PixmapPool::pool()->pixmap (PixmapPool::HDAttachmentAddDis)));
    17201722
    17211723    /* Info Pane initialization */
     
    17671769    connect (mCbIoCache, SIGNAL (stateChanged (int)), this, SLOT (setInformation()));
    17681770    connect (mCbVdi, SIGNAL (activated (int)), this, SLOT (setInformation()));
    1769     connect (mTbVmm, SIGNAL (clicked (bool)), this, SLOT (onVmmInvoked()));
     1771    connect (mTbOpen, SIGNAL (clicked (bool)), this, SLOT (sltOpenMedium()));
     1772    connect (mTbNew, SIGNAL (clicked (bool)), this, SLOT (sltNewMedium()));
    17701773    connect (mCbShowDiffs, SIGNAL (stateChanged (int)), this, SLOT (setInformation()));
    17711774    connect (mCbPassthrough, SIGNAL (stateChanged (int)), this, SLOT (setInformation()));
     
    22902293                {
    22912294                    case KDeviceType_HardDisk:
    2292                         mLbVdi->setText (tr ("Hard &Disk:"));
     2295                        mLbVdi->setText(tr("Hard &Disk:"));
     2296                        mTbOpen->setWhatsThis(tr("Open hard disk image file using file-open dialog."));
     2297                        mTbOpen->setToolTip(tr("Open hard disk image file"));
     2298                        mTbNew->setVisible(true);
    22932299                        break;
    22942300                    case KDeviceType_DVD:
    2295                         mLbVdi->setText (tr ("&CD/DVD Device:"));
     2301                        mLbVdi->setText(tr("&CD/DVD Device:"));
     2302                        mTbOpen->setWhatsThis(tr("Open CD/DVD image file using file-open dialog."));
     2303                        mTbOpen->setToolTip(tr("Open CD/DVD image file"));
     2304                        mTbNew->setVisible(false);
    22962305                        break;
    22972306                    case KDeviceType_Floppy:
    2298                         mLbVdi->setText (tr ("&Floppy Device:"));
     2307                        mLbVdi->setText(tr("&Floppy Device:"));
     2308                        mTbOpen->setWhatsThis(tr("Open floppy image file using file-open dialog."));
     2309                        mTbOpen->setToolTip(tr("Open floppy image file"));
     2310                        mTbNew->setVisible(false);
    22992311                        break;
    23002312                    default:
     
    23892401}
    23902402
    2391 void VBoxVMSettingsHD::onVmmInvoked()
    2392 {
    2393     QString id = getWithMediaManager (mCbVdi->type());
     2403void VBoxVMSettingsHD::sltOpenMedium()
     2404{
     2405    QString id = getWithOpenFileDialog(mCbVdi->type());
     2406    if (!id.isNull())
     2407        mCbVdi->setCurrentItem (id);
     2408}
     2409
     2410void VBoxVMSettingsHD::sltNewMedium()
     2411{
     2412    QString id = getWithNewHDWizard();
    23942413    if (!id.isNull())
    23952414        mCbVdi->setCurrentItem (id);
     
    24492468                /* Ask the user for the method to select medium */
    24502469                KDeviceType deviceType = mStorageModel->data (index, StorageModel::R_AttDevice).value <KDeviceType>();
    2451                 int askResult = vboxProblem().confirmRunNewHDWzdOrVDM (deviceType);
     2470                int askResult = vboxProblem().confirmRunNewHDWzdOrOFD (deviceType);
    24522471                QString mediumId = askResult == QIMessageBox::Yes ? getWithNewHDWizard() :
    2453                                    askResult == QIMessageBox::No ? getWithMediaManager (typeToLocal (deviceType)) : QString();
     2472                                   askResult == QIMessageBox::No ? getWithOpenFileDialog(typeToLocal (deviceType)) : QString();
    24542473                if (mediumId.isNull())
    24552474                    mediumId = firstAvailableId;
     
    27332752}
    27342753
     2754QString VBoxVMSettingsHD::getWithOpenFileDialog (VBoxDefs::MediumType aMediumType)
     2755{
     2756    /* Initialize variables: */
     2757    CVirtualBox vbox = vboxGlobal().virtualBox();
     2758    QString strHomeFolder = vbox.GetHomeFolder();
     2759    QList < QPair <QString, QString> > filters;
     2760    QStringList backends;
     2761    QStringList prefixes;
     2762    QString strFilter;
     2763    QString strTitle;
     2764    QString allType;
     2765    KDeviceType type;
     2766    switch (aMediumType)
     2767    {
     2768        case VBoxDefs::MediumType_HardDisk:
     2769        {
     2770            filters = vboxGlobal().HDDBackends();
     2771            strTitle = tr ("Select a hard disk image file");
     2772            allType = tr ("hard disk");
     2773            type = KDeviceType_HardDisk;
     2774            break;
     2775        }
     2776        case VBoxDefs::MediumType_DVD:
     2777        {
     2778            filters = vboxGlobal().DVDBackends();
     2779            strTitle = tr ("Select a CD/DVD-ROM disk image file");
     2780            allType = tr ("CD/DVD-ROM disk");
     2781            type = KDeviceType_DVD;
     2782            break;
     2783        }
     2784        case VBoxDefs::MediumType_Floppy:
     2785        {
     2786            filters = vboxGlobal().FloppyBackends();
     2787            strTitle = tr ("Select a floppy disk image file");
     2788            allType = tr ("floppy disk");
     2789            type = KDeviceType_Floppy;
     2790            break;
     2791        }
     2792        default:
     2793            break;
     2794    }
     2795
     2796    /* Prepare filters and backends: */
     2797    for (int i = 0; i < filters.count(); ++i)
     2798    {
     2799        /* Get iterated filter: */
     2800        QPair <QString, QString> item = filters.at(i);
     2801        /* Create one backend filter string: */
     2802        backends << QString("%1 (%2)").arg(item.first).arg(item.second);
     2803        /* Save the suffix's for the "All" entry: */
     2804        prefixes << item.second;
     2805    }
     2806    if (!prefixes.isEmpty())
     2807        backends.insert(0, tr("All %1 images (%2)").arg(allType).arg(prefixes.join(" ").trimmed()));
     2808    backends << tr("All files (*)");
     2809    strFilter = backends.join(";;").trimmed();
     2810
     2811    /* Create open file dialog: */
     2812    QStringList files = QIFileDialog::getOpenFileNames(strHomeFolder, strFilter, this, strTitle, 0, true, true);
     2813    if (!files.empty() && !files[0].isEmpty())
     2814    {
     2815        /* Get location: */
     2816        QString strLocation = files[0];
     2817
     2818        /* Open corresponding medium: */
     2819        CMedium comMedium = vbox.OpenMedium(strLocation, type, KAccessMode_ReadWrite);
     2820
     2821        if (vbox.isOk())
     2822        {
     2823            /* Prepare vbox medium wrapper: */
     2824            VBoxMedium vboxMedium;
     2825
     2826            /* First of all we should test if that medium already opened: */
     2827            if (!vboxGlobal().findMedium(comMedium, vboxMedium))
     2828            {
     2829                /* And create new otherwise: */
     2830                vboxMedium = VBoxMedium(CMedium(comMedium), aMediumType, KMediumState_Created);
     2831                vboxGlobal().addMedium(vboxMedium);
     2832            }
     2833
     2834            /* Return vboxMedium id: */
     2835            return vboxMedium.id();
     2836        }
     2837        else
     2838            vboxProblem().cannotOpenMedium(this, vbox, aMediumType, strLocation);
     2839    }
     2840
     2841    /* Return null string: */
     2842    return QString();
     2843}
     2844
    27352845QString VBoxVMSettingsHD::getWithNewHDWizard()
    27362846{
    27372847    /* Run New HD Wizard */
    2738     UINewHDWzd dlg (this);
     2848    UINewHDWzd dlg(this);
     2849    /* Initialize variables: */
     2850    CGuestOSType guestOSType = vboxGlobal().virtualBox().GetGuestOSType(m_machine.GetOSTypeId());
     2851    dlg.setRecommendedSize(guestOSType.GetRecommendedHDD());
     2852    QString strMachineSettingsFilepath = m_machine.GetSettingsFilePath();
     2853    QFileInfo fileInfo(strMachineSettingsFilepath);
     2854    dlg.setDefaultPath(fileInfo.absolutePath());
    27392855
    27402856    return dlg.exec() == QDialog::Accepted ? dlg.hardDisk().GetId() : QString();
    2741 }
    2742 
    2743 QString VBoxVMSettingsHD::getWithMediaManager (VBoxDefs::MediumType aMediumType)
    2744 {
    2745     /* Run Media Manager */
    2746     VBoxMediaManagerDlg dlg (this);
    2747     dlg.setup (aMediumType,
    2748                true /* do select? */,
    2749                false /* do refresh? */,
    2750                m_machine,
    2751                mCbVdi->id(),
    2752                mCbShowDiffs->isChecked());
    2753 
    2754     return dlg.exec() == QDialog::Accepted ? dlg.selectedId() : QString();
    27552857}
    27562858
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsHD.h

    r33631 r33670  
    616616    void setInformation();
    617617
    618     void onVmmInvoked();
     618    void sltOpenMedium();
     619    void sltNewMedium();
    619620
    620621    void updateActionsState();
     
    637638    void addAttachmentWrapper (KDeviceType aDevice);
    638639
     640    QString getWithOpenFileDialog (VBoxDefs::MediumType aMediumType);
    639641    QString getWithNewHDWizard();
    640     QString getWithMediaManager (VBoxDefs::MediumType aMediumType);
    641642
    642643    void updateAdditionalObjects (KDeviceType aType);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsHD.ui

    r32760 r33670  
    248248         <number>0</number>
    249249        </property>
    250         <item row="0" column="0" colspan="4" >
     250        <item row="0" column="0" colspan="3" >
    251251         <widget class="QILabelSeparator" native="1" name="mLsAttributes" >
    252252          <property name="text" >
     
    268268         </widget>
    269269        </item>
    270         <item row="1" column="2" colspan="2" >
     270        <item row="1" column="2" >
    271271         <widget class="QComboBox" name="mCbSlot" >
    272272          <property name="whatsThis" >
     
    292292        </item>
    293293        <item row="2" column="2" >
    294          <widget class="VBoxMediaComboBox" native="1" name="mCbVdi" >
    295           <property name="whatsThis" >
    296            <string>Selects the virtual disk image or the host drive used by this attachment.</string>
    297           </property>
    298           <property name="sizePolicy" >
    299            <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
    300             <horstretch>0</horstretch>
    301             <verstretch>0</verstretch>
    302            </sizepolicy>
    303           </property>
    304          </widget>
    305         </item>
    306         <item row="2" column="3" >
    307          <widget class="QIToolButton" name="mTbVmm" >
    308           <property name="whatsThis" >
    309            <string>Opens the Virtual Media Manager to select a virtual image for this attachment.</string>
    310           </property>
    311           <property name="toolTip" >
    312            <string>Open Virtual Media Manager</string>
    313           </property>
    314           <property name="text" >
    315            <string/>
    316           </property>
    317           <property name="autoRaise" >
    318            <bool>true</bool>
    319           </property>
    320          </widget>
    321         </item>
    322         <item row="3" column="2" colspan="2" >
     294         <widget class="QWidget" name="mWtContainer" >
     295          <layout class="QHBoxLayout" name="mLtContainer" >
     296           <property name="leftMargin" >
     297            <number>0</number>
     298           </property>
     299           <property name="topMargin" >
     300            <number>0</number>
     301            </property>
     302           <property name="rightMargin" >
     303            <number>0</number>
     304           </property>
     305           <property name="bottomMargin" >
     306            <number>0</number>
     307           </property>
     308           <property name="spacing" >
     309            <number>0</number>
     310           </property>
     311           <item>
     312            <widget class="VBoxMediaComboBox" native="1" name="mCbVdi" >
     313             <property name="whatsThis" >
     314              <string>Selects the virtual disk image or the host drive used by this attachment.</string>
     315             </property>
     316             <property name="sizePolicy" >
     317              <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
     318               <horstretch>0</horstretch>
     319               <verstretch>0</verstretch>
     320              </sizepolicy>
     321             </property>
     322            </widget>
     323           </item>
     324           <item>
     325            <widget class="QIToolButton" name="mTbOpen" >
     326             <property name="text" >
     327              <string/>
     328             </property>
     329             <property name="autoRaise" >
     330              <bool>true</bool>
     331             </property>
     332            </widget>
     333           </item>
     334           <item>
     335            <widget class="QIToolButton" name="mTbNew" >
     336             <property name="whatsThis" >
     337              <string>Create hard disk image file using New Hard Disk wizard.</string>
     338             </property>
     339             <property name="toolTip" >
     340              <string>Create hard disk image file</string>
     341             </property>
     342             <property name="text" >
     343              <string/>
     344             </property>
     345             <property name="autoRaise" >
     346              <bool>true</bool>
     347             </property>
     348            </widget>
     349           </item>
     350          </layout>
     351         </widget>
     352        </item>
     353        <item row="3" column="2" >
    323354         <widget class="QCheckBox" name="mCbShowDiffs">
    324355          <property name="sizePolicy" >
     
    336367         </widget>
    337368        </item>
    338         <item row="4" column="2" colspan="2" >
     369        <item row="4" column="2" >
    339370         <widget class="QCheckBox" name="mCbPassthrough" >
    340371          <property name="sizePolicy" >
     
    352383         </widget>
    353384        </item>
    354         <item row="5" column="0" colspan="4" >
     385        <item row="5" column="0" colspan="3" >
    355386         <widget class="QILabelSeparator" native="1" name="mLsInformation" >
    356387          <property name="text" >
     
    369400         </widget>
    370401        </item>
    371         <item row="6" column="2" colspan="2" >
     402        <item row="6" column="2" >
    372403         <widget class="QILabel" name="mLbHDVirtualSizeValue" >
    373404          <property name="sizePolicy" >
     
    389420         </widget>
    390421        </item>
    391         <item row="7" column="2" colspan="2" >
     422        <item row="7" column="2" >
    392423         <widget class="QILabel" name="mLbHDActualSizeValue" >
    393424          <property name="sizePolicy" >
     
    409440         </widget>
    410441        </item>
    411         <item row="8" column="2" colspan="2" >
     442        <item row="8" column="2" >
    412443         <widget class="QILabel" name="mLbSizeValue" >
    413444          <property name="sizePolicy" >
     
    429460         </widget>
    430461        </item>
    431         <item row="9" column="2" colspan="2" >
     462        <item row="9" column="2" >
    432463         <widget class="QILabel" name="mLbLocationValue" >
    433464          <property name="sizePolicy" >
     
    449480         </widget>
    450481        </item>
    451         <item row="10" column="2" colspan="2" >
     482        <item row="10" column="2" >
    452483         <widget class="QILabel" name="mLbHDFormatValue" >
    453484          <property name="sizePolicy" >
     
    469500         </widget>
    470501        </item>
    471         <item row="11" column="2" colspan="2" >
     502        <item row="11" column="2" >
    472503         <widget class="QILabel" name="mLbUsageValue" >
    473504          <property name="sizePolicy" >
     
    479510         </widget>
    480511        </item>
    481         <item row="12" column="0" colspan="4" >
     512        <item row="12" column="0" colspan="3" >
    482513         <spacer name="mSp6" >
    483514          <property name="orientation" >
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp

    r33668 r33670  
    566566        QString strLocation = files[0];
    567567
    568         /* Prepare GUI medium wrapper: */
    569         VBoxMedium vboxMedium;
    570 
    571568        /* Open corresponding medium: */
    572569        CMedium comMedium = vbox.OpenMedium(strLocation, KDeviceType_HardDisk, KAccessMode_ReadWrite);
     570
    573571        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);
     572        {
     573            /* Prepare vbox medium wrapper: */
     574            VBoxMedium vboxMedium;
     575
     576            /* First of all we should test if that medium already opened: */
     577            if (!vboxGlobal().findMedium(comMedium, vboxMedium))
     578            {
     579                /* And create new otherwise: */
     580                vboxMedium = VBoxMedium(CMedium(comMedium), VBoxDefs::MediumType_HardDisk, KMediumState_Created);
     581                vboxGlobal().addMedium(vboxMedium);
     582            }
     583
     584            /* Ask medium combobox to select newly added medium: */
     585            m_pDiskSelector->setCurrentItem(vboxMedium.id());
     586
     587            /* Update hard disk source: */
     588            hardDiskSourceChanged();
     589
     590            m_pDiskSelector->setFocus();
     591        }
    579592        else
    580593            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();
    589594    }
    590595}
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