VirtualBox

Ignore:
Timestamp:
Oct 24, 2017 11:28:50 AM (7 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9025: Reworking clone VD to copy any kind of virtual disk images, not just virtual hard disks.

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

Legend:

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

    r68721 r69200  
    16271627}
    16281628
     1629void UIMessageCenter::cannotCreateMediumStorage(const CVirtualBox &comVBox, const QString &strLocation, QWidget *pParent /* = 0 */) const
     1630{
     1631    error(pParent, MessageType_Error,
     1632          tr("Failed to create the virtual disk image storage <nobr><b>%1</b>.</nobr>")
     1633             .arg(strLocation),
     1634          UIErrorString::formatErrorInfo(comVBox));
     1635}
     1636
     1637void UIMessageCenter::cannotCreateMediumStorage(const CMedium &comMedium, const QString &strLocation, QWidget *pParent /* = 0 */) const
     1638{
     1639    error(pParent, MessageType_Error,
     1640          tr("Failed to create the virtual disk image storage <nobr><b>%1</b>.</nobr>")
     1641             .arg(strLocation),
     1642          UIErrorString::formatErrorInfo(comMedium));
     1643}
     1644
     1645void UIMessageCenter::cannotCreateMediumStorage(const CProgress &comProgress, const QString &strLocation, QWidget *pParent /* = 0 */) const
     1646{
     1647    error(pParent, MessageType_Error,
     1648          tr("Failed to create the virtual disk image storage <nobr><b>%1</b>.</nobr>")
     1649             .arg(strLocation),
     1650          UIErrorString::formatErrorInfo(comProgress));
     1651}
     1652
    16291653void UIMessageCenter::cannotRemoveMachineFolder(const QString &strFolderName, QWidget *pParent /* = 0*/) const
    16301654{
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r68721 r69200  
    283283    void cannotCreateHardDiskStorage(const CMedium &medium, const QString &strLocation, QWidget *pParent = 0) const;
    284284    void cannotCreateHardDiskStorage(const CProgress &progress, const QString &strLocation, QWidget *pParent = 0) const;
     285    void cannotCreateMediumStorage(const CVirtualBox &comVBox, const QString &strLocation, QWidget *pParent = 0) const;
     286    void cannotCreateMediumStorage(const CMedium &comMedium, const QString &strLocation, QWidget *pParent = 0) const;
     287    void cannotCreateMediumStorage(const CProgress &comProgress, const QString &strLocation, QWidget *pParent = 0) const;
    285288    void cannotRemoveMachineFolder(const QString &strFolderName, QWidget *pParent = 0) const;
    286289    void cannotRewriteMachineFolder(const QString &strFolderName, QWidget *pParent = 0) const;
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r69130 r69200  
    7373
    7474    /** Copies UIMedium wrapped by <i>this</i> item. */
    75     virtual bool copy() = 0;
     75    virtual bool copy();
    7676    /** Moves UIMedium wrapped by <i>this</i> item. */
    7777    virtual bool move();
     
    163163protected:
    164164
    165     /** Copies UIMedium wrapped by <i>this</i> item. */
    166     virtual bool copy() /* override */;
    167165    /** Removes UIMedium wrapped by <i>this</i> item. */
    168166    virtual bool remove() /* override */;
     
    188186protected:
    189187
    190     /** Copies UIMedium wrapped by <i>this</i> item. */
    191     virtual bool copy() /* override */;
    192188    /** Removes UIMedium wrapped by <i>this</i> item. */
    193189    virtual bool remove() /* override */;
     
    208204protected:
    209205
    210     /** Copies UIMedium wrapped by <i>this</i> item. */
    211     virtual bool copy() /* override */;
    212206    /** Removes UIMedium wrapped by <i>this</i> item. */
    213207    virtual bool remove() /* override */;
     
    376370}
    377371
     372bool UIMediumItem::copy()
     373{
     374    /* Show Clone VD wizard: */
     375    UISafePointerWizard pWizard = new UIWizardCloneVD(treeWidget(), medium().medium());
     376    pWizard->prepare();
     377    pWizard->exec();
     378
     379    /* Delete if still exists: */
     380    if (pWizard)
     381        delete pWizard;
     382
     383    /* True by default: */
     384    return true;
     385}
     386
    378387bool UIMediumItem::release()
    379388{
     
    546555    : UIMediumItem(guiMedium, pParent)
    547556{
    548 }
    549 
    550 bool UIMediumItemHD::copy()
    551 {
    552     /* Show Clone VD wizard: */
    553     UISafePointerWizard pWizard = new UIWizardCloneVD(treeWidget(), medium().medium());
    554     pWizard->prepare();
    555     pWizard->exec();
    556 
    557     /* Delete if still exists: */
    558     if (pWizard)
    559         delete pWizard;
    560 
    561     /* True by default: */
    562     return true;
    563557}
    564558
     
    685679}
    686680
    687 bool UIMediumItemCD::copy()
    688 {
    689     AssertMsgFailedReturn(("That functionality in not supported!\n"), false);
    690 }
    691 
    692681bool UIMediumItemCD::remove()
    693682{
     
    754743    : UIMediumItem(guiMedium, pParent)
    755744{
    756 }
    757 
    758 bool UIMediumItemFD::copy()
    759 {
    760     AssertMsgFailedReturn(("That functionality in not supported!\n"), false);
    761745}
    762746
     
    17871771    if (m_pActionCopy)
    17881772    {
    1789         bool fActionEnabledCopy = currentMediumType() == UIMediumType_HardDisk &&
    1790                                   fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Copy);
     1773        bool fActionEnabledCopy = fNotInEnumeration && pMediumItem && checkMediumFor(pMediumItem, Action_Copy);
    17911774        m_pActionCopy->setEnabled(fActionEnabledCopy);
    17921775    }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVD.cpp

    r69198 r69200  
    3939    : UIWizard(pParent, WizardType_CloneVD)
    4040    , m_comSourceVirtualDisk(comSourceVirtualDisk)
     41    , m_enmSourceVirtualDiskDeviceType(m_comSourceVirtualDisk.GetDeviceType())
    4142{
    4243#ifndef VBOX_WS_MAC
     
    6465    CVirtualBox comVBox = vboxGlobal().virtualBox();
    6566
    66     /* Create new virtual hard-disk: */
    67     CMedium comVirtualDisk = comVBox.CreateMedium(comMediumFormat.GetName(), strMediumPath, KAccessMode_ReadWrite, KDeviceType_HardDisk);
     67    /* Create new virtual disk image: */
     68    CMedium comVirtualDisk = comVBox.CreateMedium(comMediumFormat.GetName(), strMediumPath, KAccessMode_ReadWrite, m_enmSourceVirtualDiskDeviceType);
    6869    if (!comVBox.isOk())
    6970    {
    70         msgCenter().cannotCreateHardDiskStorage(comVBox, strMediumPath, this);
     71        msgCenter().cannotCreateMediumStorage(comVBox, strMediumPath, this);
    7172        return false;
    7273    }
     
    8182    }
    8283
    83     /* Copy existing virtual-disk to the new virtual-disk: */
     84    /* Copy source image to new one: */
    8485    CProgress comProgress = comSourceVirtualDisk.CloneTo(comVirtualDisk, variants, CMedium());
    8586    if (!comSourceVirtualDisk.isOk())
    8687    {
    87         msgCenter().cannotCreateHardDiskStorage(comSourceVirtualDisk, strMediumPath, this);
     88        msgCenter().cannotCreateMediumStorage(comSourceVirtualDisk, strMediumPath, this);
    8889        return false;
    8990    }
     
    9596    if (!comProgress.isOk() || comProgress.GetResultCode() != 0)
    9697    {
    97         msgCenter().cannotCreateHardDiskStorage(comProgress, strMediumPath, this);
     98        msgCenter().cannotCreateMediumStorage(comProgress, strMediumPath, this);
    9899        return false;
    99100    }
    100101
    101     /* Remember created virtual-disk: */
     102    /* Save created image as target one: */
    102103    m_comTargetVirtualDisk = comVirtualDisk;
    103104
    104     /* Just close the created medium, it is not necessary yet: */
     105    /* Just close the created image, it is not required anymore: */
    105106    m_comTargetVirtualDisk.Close();
    106107
     
    114115
    115116    /* Translate wizard: */
    116     setWindowTitle(tr("Copy Virtual Hard Disk"));
     117    setWindowTitle(tr("Copy Virtual Disk Image"));
    117118    setButtonText(QWizard::FinishButton, tr("Copy"));
    118119}
     
    125126        case WizardMode_Basic:
    126127        {
    127             setPage(Page1, new UIWizardCloneVDPageBasic1(m_comSourceVirtualDisk));
    128             setPage(Page2, new UIWizardCloneVDPageBasic2);
    129             setPage(Page3, new UIWizardCloneVDPageBasic3);
     128            setPage(Page1, new UIWizardCloneVDPageBasic1(m_comSourceVirtualDisk,
     129                                                         m_enmSourceVirtualDiskDeviceType));
     130            setPage(Page2, new UIWizardCloneVDPageBasic2(m_enmSourceVirtualDiskDeviceType));
     131            setPage(Page3, new UIWizardCloneVDPageBasic3(m_enmSourceVirtualDiskDeviceType));
    130132            setPage(Page4, new UIWizardCloneVDPageBasic4);
    131133            break;
     
    133135        case WizardMode_Expert:
    134136        {
    135             setPage(PageExpert, new UIWizardCloneVDPageExpert(m_comSourceVirtualDisk));
     137            setPage(PageExpert, new UIWizardCloneVDPageExpert(m_comSourceVirtualDisk,
     138                                                              m_enmSourceVirtualDiskDeviceType));
    136139            break;
    137140        }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVD.h

    r69198 r69200  
    5757    CMedium targetVirtualDisk() const { return m_comTargetVirtualDisk; }
    5858
     59    /** Returns the source virtual-disk device type. */
     60    KDeviceType sourceVirtualDiskDeviceType() const { return m_enmSourceVirtualDiskDeviceType; }
     61
    5962    /** Makes a copy of source virtual-disk. */
    6063    bool copyVirtualDisk();
     
    7275    /** Holds the target virtual disk wrapper. */
    7376    CMedium m_comTargetVirtualDisk;
     77
     78    /** Holds the source virtual-disk device type. */
     79    KDeviceType m_enmSourceVirtualDiskDeviceType;
    7480};
    7581
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic1.cpp

    r69197 r69200  
    4242void UIWizardCloneVDPage1::onHandleOpenSourceDiskClick()
    4343{
     44    /* Get current virtual-disk medium type: */
     45    const UIMediumType enmMediumType = UIMediumDefs::mediumTypeToLocal(sourceVirtualDisk().GetDeviceType());
    4446    /* Get source virtual-disk using file-open dialog: */
    45     QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(UIMediumType_HardDisk, thisImp());
     47    QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(enmMediumType, thisImp());
    4648    if (!strMediumId.isNull())
    4749    {
     
    6365}
    6466
    65 UIWizardCloneVDPageBasic1::UIWizardCloneVDPageBasic1(const CMedium &comSourceVirtualDisk)
     67UIWizardCloneVDPageBasic1::UIWizardCloneVDPageBasic1(const CMedium &comSourceVirtualDisk, KDeviceType enmDeviceType)
    6668{
    6769    /* Create widgets: */
     
    7476            {
    7577                m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
    76                 m_pSourceDiskSelector->setType(UIMediumType_HardDisk);
     78                m_pSourceDiskSelector->setType(UIMediumDefs::mediumTypeToLocal(enmDeviceType));
    7779                m_pSourceDiskSelector->setCurrentItem(comSourceVirtualDisk.GetId());
    7880                m_pSourceDiskSelector->repopulate();
     
    113115{
    114116    /* Translate page: */
    115     setTitle(UIWizardCloneVD::tr("Hard disk to copy"));
     117    setTitle(UIWizardCloneVD::tr("Disk image to copy"));
    116118
    117119    /* Translate widgets: */
    118     m_pLabel->setText(UIWizardCloneVD::tr("<p>Please select the virtual hard disk file that you would like to copy "
     120    m_pLabel->setText(UIWizardCloneVD::tr("<p>Please select the virtual disk image file that you would like to copy "
    119121                                          "if it is not already selected. You can either choose one from the list "
    120122                                          "or use the folder icon beside the list to select one.</p>"));
    121     m_pSourceDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file to copy..."));
     123    m_pSourceDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual disk image file to copy..."));
    122124}
    123125
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic1.h

    r69197 r69200  
    6565    /** Constructs basic page.
    6666      * @param  comSourceVirtualDisk  Brings the initial source disk to make copy from. */
    67     UIWizardCloneVDPageBasic1(const CMedium &comSourceVirtualDisk);
     67    UIWizardCloneVDPageBasic1(const CMedium &comSourceVirtualDisk, KDeviceType enmDeviceType);
    6868
    6969protected:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.cpp

    r69197 r69200  
    4141}
    4242
    43 void UIWizardCloneVDPage2::addFormatButton(QWidget *pParent, QVBoxLayout *pFormatLayout, CMediumFormat comMediumFormat, bool fPreferred /* = false */)
     43void UIWizardCloneVDPage2::addFormatButton(QWidget *pParent, QVBoxLayout *pFormatLayout, KDeviceType enmDeviceType, CMediumFormat comMediumFormat, bool fPreferred /* = false */)
    4444{
    4545    /* Check that medium format supports creation: */
     
    5454        return;
    5555
    56     /* Check that medium format supports creation of virtual hard-disks: */
     56    /* Check that medium format supports creation of virtual disk images: */
    5757    QVector<QString> fileExtensions;
    5858    QVector<KDeviceType> deviceTypes;
    5959    comMediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    60     if (!deviceTypes.contains(KDeviceType_HardDisk))
     60    if (!deviceTypes.contains(enmDeviceType))
    6161        return;
    6262
     
    9494}
    9595
    96 UIWizardCloneVDPageBasic2::UIWizardCloneVDPageBasic2()
     96UIWizardCloneVDPageBasic2::UIWizardCloneVDPageBasic2(KDeviceType enmDeviceType)
    9797{
    9898    /* Create widgets: */
     
    107107                CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
    108108                const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
    109                 QMap<QString, CMediumFormat> vdi, preferred;
     109                QMap<QString, CMediumFormat> vdi, preferred, others;
    110110                foreach (const CMediumFormat &format, formats)
    111111                {
     
    119119                        if (capabilities.contains(KMediumFormatCapabilities_Preferred))
    120120                            preferred[format.GetId()] = format;
     121                        /* Then others: */
     122                        else
     123                            others[format.GetId()] = format;
    121124                    }
    122125                }
     
    124127                /* Create buttons for VDI and preferred: */
    125128                foreach (const QString &strId, vdi.keys())
    126                     addFormatButton(this, pFormatLayout, vdi.value(strId));
     129                    addFormatButton(this, pFormatLayout, enmDeviceType, vdi.value(strId));
    127130                foreach (const QString &strId, preferred.keys())
    128                     addFormatButton(this, pFormatLayout, preferred.value(strId));
     131                    addFormatButton(this, pFormatLayout, enmDeviceType, preferred.value(strId));
     132                if (enmDeviceType == KDeviceType_DVD || enmDeviceType == KDeviceType_Floppy)
     133                    foreach (const QString &strId, others.keys())
     134                        addFormatButton(this, pFormatLayout, enmDeviceType, others.value(strId));
    129135
    130136                if (!m_pFormatButtonGroup->buttons().isEmpty())
     
    152158{
    153159    /* Translate page: */
    154     setTitle(UIWizardCloneVD::tr("Hard disk file type"));
     160    setTitle(UIWizardCloneVD::tr("Disk image file type"));
    155161
    156162    /* Translate widgets: */
    157163    m_pLabel->setText(UIWizardCloneVD::tr("Please choose the type of file that you would like to use "
    158                                           "for the new virtual hard disk. If you do not need to use it "
     164                                          "for the new virtual disk image. If you do not need to use it "
    159165                                          "with other virtualization software you can leave this setting unchanged."));
    160166    QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.h

    r69197 r69200  
    4444      * @param  pParent          Brings the parent to add button to.
    4545      * @param  pFormatsLayout   Brings the layout to insert button to.
     46      * @param  enmDeviceType    Brings the device type all buttons should be restricted to.
    4647      * @param  comMediumFormat  Brings the medium format object to acquire format from.
    4748      * @param  fPreferred       Brings whether curretn format is preferred or not. */
    4849    void addFormatButton(QWidget *pParent,
    4950                         QVBoxLayout *pFormatsLayout,
     51                         KDeviceType enmDeviceType,
    5052                         CMediumFormat comMediumFormat,
    5153                         bool fPreferred = false);
     
    7375public:
    7476
    75     /** Constructs basic page. */
    76     UIWizardCloneVDPageBasic2();
     77    /** Constructs basic page.
     78      * @param  enmDeviceType  Brings the device type to limit format to. */
     79    UIWizardCloneVDPageBasic2(KDeviceType enmDeviceType);
    7780
    7881private:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic3.cpp

    r69187 r69200  
    7878}
    7979
    80 UIWizardCloneVDPageBasic3::UIWizardCloneVDPageBasic3()
     80UIWizardCloneVDPageBasic3::UIWizardCloneVDPageBasic3(KDeviceType enmDeviceType)
    8181{
    8282    /* Create widgets: */
     
    9292            {
    9393                m_pDynamicalButton = new QRadioButton(this);
     94                if (enmDeviceType == KDeviceType_HardDisk)
    9495                {
    9596                    m_pDynamicalButton->click();
     
    9798                }
    9899                m_pFixedButton = new QRadioButton(this);
     100                if (   enmDeviceType == KDeviceType_DVD
     101                    || enmDeviceType == KDeviceType_Floppy)
     102                {
     103                    m_pFixedButton->click();
     104                    m_pFixedButton->setFocus();
     105                }
    99106                m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
    100107                m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
     
    127134
    128135    /* Translate widgets: */
    129     m_pDescriptionLabel->setText(UIWizardCloneVD::tr("Please choose whether the new virtual hard disk file should grow as it is used "
     136    m_pDescriptionLabel->setText(UIWizardCloneVD::tr("Please choose whether the new virtual disk image file should grow as it is used "
    130137                                                     "(dynamically allocated) or if it should be created at its maximum size (fixed size)."));
    131     m_pDynamicLabel->setText(UIWizardCloneVD::tr("<p>A <b>dynamically allocated</b> hard disk file will only use space "
     138    m_pDynamicLabel->setText(UIWizardCloneVD::tr("<p>A <b>dynamically allocated</b> disk image file will only use space "
    132139                                                 "on your physical hard disk as it fills up (up to a maximum <b>fixed size</b>), "
    133140                                                 "although it will not shrink again automatically when space on it is freed.</p>"));
    134     m_pFixedLabel->setText(UIWizardCloneVD::tr("<p>A <b>fixed size</b> hard disk file may take longer to create on some "
     141    m_pFixedLabel->setText(UIWizardCloneVD::tr("<p>A <b>fixed size</b> disk image file may take longer to create on some "
    135142                                               "systems but is often faster to use.</p>"));
    136     m_pSplitLabel->setText(UIWizardCloneVD::tr("<p>You can also choose to <b>split</b> the hard disk file into several files "
     143    m_pSplitLabel->setText(UIWizardCloneVD::tr("<p>You can also choose to <b>split</b> the disk image file into several files "
    137144                                               "of up to two gigabytes each. This is mainly useful if you wish to store the "
    138145                                               "virtual machine on removable USB devices or old systems, some of which cannot "
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic3.h

    r69197 r69200  
    2121/* GUI includes: */
    2222#include "UIWizardPage.h"
     23
     24/* COM includes: */
     25#include "COMEnums.h"
    2326
    2427/* Forward declarations: */
     
    6265
    6366    /** Constructs basic page. */
    64     UIWizardCloneVDPageBasic3();
     67    UIWizardCloneVDPageBasic3(KDeviceType enmDeviceType);
    6568
    6669private:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic4.cpp

    r69199 r69200  
    7777    QStringList validExtensionList;
    7878    for (int i = 0; i < fileExtensions.size(); ++i)
    79         if (deviceTypes[i] == KDeviceType_HardDisk)
     79        if (deviceTypes[i] == static_cast<UIWizardCloneVD*>(wizardImp())->sourceVirtualDiskDeviceType())
    8080            validExtensionList << QString("*.%1").arg(fileExtensions[i]);
    8181    /* Compose full filter list: */
     
    8585    QString strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName),
    8686                                                              strBackendsList, thisImp(),
    87                                                               UIWizardCloneVD::tr("Please choose a location for new virtual hard disk file"));
     87                                                              UIWizardCloneVD::tr("Please choose a location for new virtual disk image file"));
    8888
    8989    /* If there was something really chosen: */
     
    129129        fileInfo = QFileInfo(strDefaultPath, strFileName);
    130130    }
    131     /* Return full absolute hard disk file path: */
     131    /* Return full absolute disk image file path: */
    132132    return QDir::toNativeSeparators(fileInfo.absoluteFilePath());
    133133}
    134134
    135135/* static */
    136 void UIWizardCloneVDPage4::acquireExtensions(const CMediumFormat &comMediumFormat,
     136void UIWizardCloneVDPage4::acquireExtensions(const CMediumFormat &comMediumFormat, KDeviceType enmDeviceType,
    137137                                             QStringList &aAllowedExtensions, QString &strDefaultExtension)
    138138{
     
    143143    mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    144144    for (int i = 0; i < fileExtensions.size(); ++i)
    145         if (deviceTypes[i] == KDeviceType_HardDisk)
     145        if (deviceTypes[i] == enmDeviceType)
    146146            aAllowedExtensions << fileExtensions[i].toLower();
    147147    AssertReturnVoid(!aAllowedExtensions.isEmpty());
     
    208208{
    209209    /* Translate page: */
    210     setTitle(UIWizardCloneVD::tr("New hard disk to create"));
     210    setTitle(UIWizardCloneVD::tr("New disk image to create"));
    211211
    212212    /* Translate widgets: */
    213     m_pLabel->setText(UIWizardCloneVD::tr("Please type the name of the new virtual hard disk file into the box below or "
     213    m_pLabel->setText(UIWizardCloneVD::tr("Please type the name of the new virtual disk image file into the box below or "
    214214                                          "click on the folder icon to select a different folder to create the file in."));
    215     m_pDestinationDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a location for new virtual hard disk file..."));
     215    m_pDestinationDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a location for new virtual disk image file..."));
    216216}
    217217
     
    227227    /* Get default extension for virtual-disk copy: */
    228228    acquireExtensions(field("mediumFormat").value<CMediumFormat>(),
     229                      static_cast<UIWizardCloneVD*>(wizardImp())->sourceVirtualDiskDeviceType(),
    229230                      m_aAllowedExtensions, m_strDefaultExtension);
    230231    /* Compose default-name for virtual-disk copy: */
    231     QString strMediumName = UIWizardCloneVD::tr("%1_copy", "copied virtual hard drive name").arg(sourceFileInfo.baseName());
     232    QString strMediumName = UIWizardCloneVD::tr("%1_copy", "copied virtual disk image name").arg(sourceFileInfo.baseName());
    232233    /* Set default-name as text for location editor: */
    233234    m_pDestinationDiskEditor->setText(strMediumName);
     
    256257        startProcessing();
    257258
    258         /* Try to copy virtual hard drive file: */
     259        /* Try to copy virtual disk image file: */
    259260        fResult = qobject_cast<UIWizardCloneVD*>(wizard())->copyVirtualDisk();
    260261
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic4.h

    r69199 r69200  
    2525#include "UIWizardPage.h"
    2626
     27/* COM includes: */
     28#include "COMEnums.h"
     29
    2730/* Forward declarations: */
    2831class CMediumFormat;
     
    4851    static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath);
    4952    /** Acquires the list of @a aAllowedExtensions and @a strDefaultExtension
    50       * on the basis of incoming @a comMediumFormat. */
    51     static void acquireExtensions(const CMediumFormat &comMediumFormat,
     53      * on the basis of incoming @a comMediumFormat and @a enmDeviceType. */
     54    static void acquireExtensions(const CMediumFormat &comMediumFormat, KDeviceType enmDeviceType,
    5255                                  QStringList &aAllowedExtensions, QString &strDefaultExtension);
    5356
     
    8689protected:
    8790
     91    /** Allows to access 'wizard()' from base part. */
     92    UIWizard* wizardImp() { return wizard(); }
    8893    /** Allows to access 'this' from base part. */
    8994    UIWizardPage* thisImp() { return this; }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageExpert.cpp

    r69199 r69200  
    4444
    4545
    46 UIWizardCloneVDPageExpert::UIWizardCloneVDPageExpert(const CMedium &comSourceVirtualDisk)
     46UIWizardCloneVDPageExpert::UIWizardCloneVDPageExpert(const CMedium &comSourceVirtualDisk, KDeviceType enmDeviceType)
    4747{
    4848    /* Create widgets: */
     
    5959                {
    6060                    m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
    61                     m_pSourceDiskSelector->setType(UIMediumType_HardDisk);
     61                    m_pSourceDiskSelector->setType(UIMediumDefs::mediumTypeToLocal(enmDeviceType));
    6262                    m_pSourceDiskSelector->setCurrentItem(comSourceVirtualDisk.GetId());
    6363                    m_pSourceDiskSelector->repopulate();
     
    117117                    /* Create buttons for VDI, preferred and others: */
    118118                    foreach (const QString &strId, vdi.keys())
    119                         addFormatButton(this, pFormatCntLayout, vdi.value(strId), true);
     119                        addFormatButton(this, pFormatCntLayout, enmDeviceType, vdi.value(strId), true);
    120120                    foreach (const QString &strId, preferred.keys())
    121                         addFormatButton(this, pFormatCntLayout, preferred.value(strId), true);
     121                        addFormatButton(this, pFormatCntLayout, enmDeviceType, preferred.value(strId), true);
    122122                    foreach (const QString &strId, others.keys())
    123                         addFormatButton(this, pFormatCntLayout, others.value(strId));
     123                        addFormatButton(this, pFormatCntLayout, enmDeviceType, others.value(strId));
    124124
    125125                    if (!m_pFormatButtonGroup->buttons().isEmpty())
     
    139139                {
    140140                    m_pDynamicalButton = new QRadioButton(m_pVariantCnt);
     141                    if (enmDeviceType == KDeviceType_HardDisk)
    141142                    {
    142143                        m_pDynamicalButton->click();
     
    144145                    }
    145146                    m_pFixedButton = new QRadioButton(m_pVariantCnt);
     147                    if (   enmDeviceType == KDeviceType_DVD
     148                        || enmDeviceType == KDeviceType_Floppy)
     149                    {
     150                        m_pFixedButton->click();
     151                        m_pFixedButton->setFocus();
     152                    }
    146153                    m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
    147154                    m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
     
    157164        pMainLayout->addWidget(m_pFormatCnt, 2, 0, Qt::AlignTop);
    158165        pMainLayout->addWidget(m_pVariantCnt, 2, 1, Qt::AlignTop);
    159         sltHandleSourceDiskChange();
    160         sltMediumFormatChanged();
    161166    }
    162167
     
    188193    m_strDefaultPath = sourceFileInfo.absolutePath();
    189194    /* Compose name for virtual-disk copy: */
    190     QString strMediumName = UIWizardCloneVD::tr("%1_copy", "copied virtual hard drive name").arg(sourceFileInfo.baseName());
     195    QString strMediumName = UIWizardCloneVD::tr("%1_copy", "copied virtual disk image name").arg(sourceFileInfo.baseName());
    191196    /* Set text to location editor: */
    192197    m_pDestinationDiskEditor->setText(strMediumName);
     
    230235
    231236    /* Compose virtual-disk extension: */
    232     acquireExtensions(mf, m_aAllowedExtensions, m_strDefaultExtension);
     237    acquireExtensions(mf, static_cast<UIWizardCloneVD*>(wizardImp())->sourceVirtualDiskDeviceType(),
     238                      m_aAllowedExtensions, m_strDefaultExtension);
    233239
    234240    /* Broadcast complete-change: */
     
    245251{
    246252    /* Translate widgets: */
    247     m_pSourceDiskCnt->setTitle(UIWizardCloneVD::tr("Hard disk to &copy"));
    248     m_pSourceDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file to copy..."));
    249     m_pDestinationCnt->setTitle(UIWizardCloneVD::tr("&New hard disk to create"));
    250     m_pDestinationDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a location for new virtual hard disk file..."));
    251     m_pFormatCnt->setTitle(UIWizardCloneVD::tr("Hard disk file &type"));
     253    m_pSourceDiskCnt->setTitle(UIWizardCloneVD::tr("Disk image to &copy"));
     254    m_pSourceDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual disk image file to copy..."));
     255    m_pDestinationCnt->setTitle(UIWizardCloneVD::tr("&New disk image to create"));
     256    m_pDestinationDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a location for new virtual disk image file..."));
     257    m_pFormatCnt->setTitle(UIWizardCloneVD::tr("Disk image file &type"));
    252258    QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons();
    253259    for (int i = 0; i < buttons.size(); ++i)
     
    266272    /* Translate page: */
    267273    retranslateUi();
     274
     275    sltHandleSourceDiskChange();
     276    sltMediumFormatChanged();
    268277}
    269278
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageExpert.h

    r69197 r69200  
    4646
    4747    /** Constructs basic page.
    48       * @param  comSourceVirtualDisk  Brings the initial source disk to make copy from. */
    49     UIWizardCloneVDPageExpert(const CMedium &comSourceVirtualDisk);
     48      * @param  comSourceVirtualDisk  Brings the initial source disk to make copy from.
     49      * @param  enmDeviceType         Brings the device type to limit format to. */
     50    UIWizardCloneVDPageExpert(const CMedium &comSourceVirtualDisk, KDeviceType enmDeviceType);
    5051
    5152protected:
    5253
     54    /** Allows to access 'wizard()' from base part. */
     55    UIWizard* wizardImp() { return wizard(); }
    5356    /** Allows to access 'this' from base part. */
    5457    UIWizardPage* thisImp() { return this; }
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