VirtualBox

Changeset 37331 in vbox


Ignore:
Timestamp:
Jun 6, 2011 4:30:51 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72091
Message:

FE/Qt: 4908: Beef up new HD wizard: Initial commit.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
6 edited
1 copied
6 moved

Legend:

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

    r37200 r37331  
    320320        src/settings/machine/UIMachineSettingsSFDetails.h \
    321321        src/wizards/newvm/UINewVMWzd.h \
    322         src/wizards/newhd/UINewHDWzd.h \
     322        src/wizards/newhd/UINewHDWizard.h \
    323323        src/wizards/firstrun/UIFirstRunWzd.h \
    324324        src/wizards/exportappliance/UIExportApplianceWzd.h \
     
    394394        src/runtime/UIIndicatorsPool.cpp \
    395395        src/runtime/UIMachine.cpp \
    396         src/runtime/UIMachineMenuBar.cpp
     396        src/runtime/UIMachineMenuBar.cpp \
     397        src/wizards/newhd/UINewHDWizard.cpp
    397398
    398399VirtualBox_QT_MOCSRCS.darwin += \
     
    485486        src/settings/machine/UIMachineSettingsSFDetails.cpp \
    486487        src/wizards/newvm/UINewVMWzd.cpp \
    487         src/wizards/newhd/UINewHDWzd.cpp \
     488        src/wizards/newhd/UINewHDWizard.cpp \
    488489        src/wizards/firstrun/UIFirstRunWzd.cpp \
    489490        src/wizards/exportappliance/UIExportApplianceWzd.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro

    r34543 r37331  
    5353    src/wizards/newvm/UINewVMWzdPage4.ui \
    5454    src/wizards/newvm/UINewVMWzdPage5.ui \
    55     src/wizards/newhd/UINewHDWzdPage1.ui \
    56     src/wizards/newhd/UINewHDWzdPage2.ui \
    57     src/wizards/newhd/UINewHDWzdPage3.ui \
    58     src/wizards/newhd/UINewHDWzdPage4.ui \
     55    src/wizards/newhd/UINewHDWizardPageWelcome.ui \
     56    src/wizards/newhd/UINewHDWizardPageFormat.ui \
     57    src/wizards/newhd/UINewHDWizardPageVariant.ui \
     58    src/wizards/newhd/UINewHDWizardPageOptions.ui \
     59    src/wizards/newhd/UINewHDWizardPageSummary.ui \
    5960    src/wizards/firstrun/UIFirstRunWzdPage1.ui \
    6061    src/wizards/firstrun/UIFirstRunWzdPage2.ui \
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxMediaManagerDlg.cpp

    r34983 r37331  
    3737#include "VBoxGlobal.h"
    3838#include "VBoxMediaManagerDlg.h"
    39 #include "UINewHDWzd.h"
     39#include "UINewHDWizard.h"
    4040#include "VBoxProblemReporter.h"
    4141#include "UIToolBar.h"
     
    952952    AssertReturnVoid (currentTreeWidgetType() == VBoxDefs::MediumType_HardDisk);
    953953
    954     UINewHDWzd dlg (this);
     954    UINewHDWizard dlg (this);
    955955
    956956    if (dlg.exec() == QDialog::Accepted)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.h

    r35638 r37331  
    633633    // constructors & destructor
    634634
    635     CInterface() 
     635    CInterface()
    636636    {
    637637        clear();
     
    639639
    640640    CInterface (const CInterface &that) : B (that)
    641     {   
    642         clear(); 
     641    {
     642        clear();
    643643        mIface = that.mIface;
    644644        addref(ptr());
    645645    }
    646646
    647     CInterface (I *aIface) 
    648     { 
     647    CInterface (I *aIface)
     648    {
    649649        clear();
    650650        setPtr (aIface);
    651         addref (aIface); 
    652     }
    653 
    654     virtual ~CInterface() 
    655     { 
     651        addref (aIface);
     652    }
     653
     654    virtual ~CInterface()
     655    {
    656656        detach();
    657657#ifdef DEBUG
     
    677677                                                  (void **) &pObj);
    678678#endif
    679              
     679
    680680            if (SUCCEEDED (B::mRC))
    681681               setPtr(pObj);
    682682            else
    683683               setPtr(NULL);
    684            
     684
    685685            /* fetch error info, but don't assert if it's missing -- many other
    686686             * reasons can lead to an error (w/o providing error info), not only
     
    732732
    733733    /** Detaches from the underlying interface pointer. */
    734     void detach() 
    735     { 
     734    void detach()
     735    {
    736736#ifdef DEBUG
    737737       Assert(!mDead);
    738738#endif
    739        release (ptr()); 
    740        setPtr(NULL); 
     739       release (ptr());
     740       setPtr(NULL);
    741741    }
    742742
    743743    /** Returns @c true if not attached to any interface pointer. */
    744     bool isNull() const 
    745     { 
     744    bool isNull() const
     745    {
    746746#ifdef DEBUG
    747747       Assert(!mDead);
    748748#endif
    749        return mIface == NULL; 
     749       return mIface == NULL;
    750750    }
    751751
     
    786786     * else but in generated wrappers and for debugging. You've been warned.
    787787     */
    788     I *raw() const 
     788    I *raw() const
    789789    {
    790790       return ptr();
     
    819819    void clear()
    820820    {
    821        mIface = NULL;       
     821       mIface = NULL;
    822822#ifdef DEBUG
    823823       mDead = false;
     
    910910Q_DECLARE_METATYPE(CConsole);
    911911Q_DECLARE_METATYPE(CHostNetworkInterface);
     912Q_DECLARE_METATYPE(CMediumFormat);
    912913
    913914/** @} */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r37168 r37331  
    2121#include "QIWidgetValidator.h"
    2222#include "UIIconPool.h"
    23 #include "UINewHDWzd.h"
     23#include "UINewHDWizard.h"
    2424#include "VBoxGlobal.h"
    2525#include "QIFileDialog.h"
     
    29182918QString UIMachineSettingsStorage::getWithNewHDWizard()
    29192919{
    2920     /* Run New HD Wizard */
    2921     UINewHDWzd dlg(this);
    29222920    /* Initialize variables: */
    29232921    CGuestOSType guestOSType = vboxGlobal().virtualBox().GetGuestOSType(m_strMachineGuestOSTypeId);
    2924     dlg.setRecommendedSize(guestOSType.GetRecommendedHDD());
    29252922    QFileInfo fileInfo(m_strMachineSettingsFilePath);
    2926     dlg.setDefaultPath(fileInfo.absolutePath());
     2923    /* Run New HD Wizard: */
     2924    UINewHDWizard dlg(this, QString(), fileInfo.absolutePath(), guestOSType.GetRecommendedHDD());
    29272925
    29282926    return dlg.exec() == QDialog::Accepted ? dlg.hardDisk().GetId() : QString();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizard.cpp

    r37181 r37331  
    33 *
    44 * VBox frontends: Qt4 GUI ("VirtualBox"):
    5  * UINewHDWzd class implementation
     5 * UINewHDWizard class implementation
    66 */
    77
    88/*
    9  * Copyright (C) 2006-2010 Oracle Corporation
     9 * Copyright (C) 2006-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1818 */
    1919
    20 /* Local includes */
    21 #include "UIIconPool.h"
    22 #include "UINewHDWzd.h"
     20/* Global includes: */
     21#include <QCheckBox>
     22#include <QRadioButton>
     23#include <QRegExpValidator>
     24
     25/* Local includes: */
    2326#include "VBoxGlobal.h"
    2427#include "VBoxProblemReporter.h"
    25 
    26 /* Global includes */
     28#include "QIFileDialog.h"
     29#include "UIIconPool.h"
     30#include "UINewHDWizard.h"
    2731#include "iprt/path.h"
    28 #include <QFileDialog>
    29 #include <QRegExpValidator>
    30 
    31 
    32 UINewHDWzd::UINewHDWzd(QWidget *pParent) : QIWizard(pParent)
    33 {
    34     /* Create & add pages */
    35     addPage(new UINewHDWzdPage1);
    36     addPage(new UINewHDWzdPage2);
    37     addPage(new UINewHDWzdPage3);
    38     addPage(new UINewHDWzdPage4);
    39 
    40     /* Initial translate */
     32
     33/* Class to manage page variants: */
     34class UIExclusivenessManager : public QObject
     35{
     36    Q_OBJECT;
     37
     38public:
     39
     40    /* Constructor: */
     41    UIExclusivenessManager(QWidget *pParent) : QObject(pParent) {}
     42
     43    /* Wrapper for adding different children: */
     44    void addWidget(QWidget *pWidget, const QVariant &data)
     45    {
     46        /* Add radio-button: */
     47        if (QRadioButton *pRadioButton = qobject_cast<QRadioButton*>(pWidget))
     48            addRadioButton(pRadioButton, data);
     49        /* Add check-box: */
     50        if (QCheckBox *pCheckBox = qobject_cast<QCheckBox*>(pWidget))
     51            addCheckBox(pCheckBox, data);
     52    }
     53
     54    /* Wrapper for different children data: */
     55    QVariant data(QWidget *pWidget) const
     56    {
     57        /* Return data for radio-button: */
     58        if (QRadioButton *pRadioButton = qobject_cast<QRadioButton*>(pWidget))
     59            return dataOfRadioButton(pRadioButton);
     60        /* Return data for check-box: */
     61        if (QCheckBox *pCheckBox = qobject_cast<QCheckBox*>(pWidget))
     62            return dataOfCheckBox(pCheckBox);
     63        /* Return empty data: */
     64        return QVariant();
     65    }
     66
     67    void reset()
     68    {
     69        /* Make sure all radio-buttons are unchecked: */
     70        QList<QRadioButton*> radioButtons = m_radioButtons.keys();
     71        for (int i = 0; i < radioButtons.size(); ++i)
     72        {
     73            if (radioButtons[i]->isChecked())
     74            {
     75                radioButtons[i]->setAutoExclusive(false);
     76                radioButtons[i]->setChecked(false);
     77                radioButtons[i]->setAutoExclusive(true);
     78            }
     79        }
     80        /* Make sure all check-boxes are unchecked: */
     81        QList<QCheckBox*> checkBoxes = m_checkBoxes.keys();
     82        for (int i = 0; i < checkBoxes.size(); ++i)
     83        {
     84            if (checkBoxes[i]->isChecked())
     85                checkBoxes[i]->setChecked(false);
     86        }
     87    }
     88
     89signals:
     90
     91    void sigNotifyAboutStateChange(QVariant exclusiveData, QList<QVariant> optionsData);
     92
     93private slots:
     94
     95    void sltRadioButtonToggled()
     96    {
     97        recalculateState();
     98    }
     99
     100    void sltCheckBoxToggled()
     101    {
     102        recalculateState();
     103    }
     104
     105private:
     106
     107    void addRadioButton(QRadioButton *pRadioButton, const QVariant &exclusiveData)
     108    {
     109        /* Setup the connections: */
     110        connect(pRadioButton, SIGNAL(toggled(bool)), this, SLOT(sltRadioButtonToggled()));
     111        /* Add radio-button into corresponding list: */
     112        m_radioButtons.insert(pRadioButton, exclusiveData);
     113    }
     114
     115    void addCheckBox(QCheckBox *pCheckBox, const QVariant &optionData)
     116    {
     117        /* Setup the connections: */
     118        connect(pCheckBox, SIGNAL(toggled(bool)), this, SLOT(sltCheckBoxToggled()));
     119        /* Add check-box into corresponding list: */
     120        m_checkBoxes.insert(pCheckBox, optionData);
     121    }
     122
     123    QVariant dataOfRadioButton(QRadioButton *pRadioButton) const
     124    {
     125        /* Return radio-button data if present: */
     126        if (m_radioButtons.contains(pRadioButton))
     127            return m_radioButtons[pRadioButton];
     128        /* Return empty data: */
     129        return QVariant();
     130    }
     131
     132    QVariant dataOfCheckBox(QCheckBox *pCheckBox) const
     133    {
     134        /* Return check-box data if present: */
     135        if (m_checkBoxes.contains(pCheckBox))
     136            return m_checkBoxes[pCheckBox];
     137        /* Return empty data: */
     138        return QVariant();
     139    }
     140
     141    void recalculateState()
     142    {
     143        /* Prepare current state: */
     144        QList<bool> currentState;
     145        /* Get the list of radio-buttons: */
     146        QList<QRadioButton*> radioButtons = m_radioButtons.keys();
     147        /* Get the list of check-boxes: */
     148        QList<QCheckBox*> checkBoxes = m_checkBoxes.keys();
     149
     150        /* Calculate current state: */
     151        for (int i = 0; i < radioButtons.size(); ++i)
     152            currentState << radioButtons[i]->isChecked();
     153        for (int i = 0; i < checkBoxes.size(); ++i)
     154            currentState << checkBoxes[i]->isChecked();
     155
     156        /* Check if state was changed: */
     157        if (m_state == currentState)
     158            return;
     159
     160        /* Search for exclusive data: */
     161        QVariant exclusiveData;
     162        for (int i = 0; i < radioButtons.size(); ++i)
     163        {
     164            if (radioButtons[i]->isChecked())
     165            {
     166                exclusiveData = m_radioButtons[radioButtons[i]];
     167                break;
     168            }
     169        }
     170
     171        /* Search for options data: */
     172        QList<QVariant> optionsData;
     173        for (int i = 0; i < checkBoxes.size(); ++i)
     174        {
     175            if (checkBoxes[i]->isChecked())
     176                optionsData << m_checkBoxes[checkBoxes[i]];
     177        }
     178
     179        /* Notify listeners about state-change: */
     180        emit sigNotifyAboutStateChange(exclusiveData, optionsData);
     181    }
     182
     183    QMap<QRadioButton*, QVariant> m_radioButtons;
     184    QMap<QCheckBox*, QVariant> m_checkBoxes;
     185    QList<bool> m_state;
     186};
     187
     188UINewHDWizard::UINewHDWizard(QWidget *pParent, const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize)
     189    : QIWizard(pParent)
     190{
     191    /* Create & add pages: */
     192    addPage(new UINewHDWizardPageWelcome);
     193    addPage(new UINewHDWizardPageFormat);
     194    addPage(new UINewHDWizardPageVariant);
     195    addPage(new UINewHDWizardPageOptions(strDefaultName, strDefaultPath, uDefaultSize));
     196    addPage(new UINewHDWizardPageSummary);
     197
     198    /* Translate wizard: */
    41199    retranslateUi();
    42200
    43     /* Initial translate all pages */
     201    /* Translate wizard pages: */
    44202    retranslateAllPages();
    45203
    46     /* Resize to 'golden ratio' */
     204    /* Resize wizard to 'golden ratio': */
    47205    resizeToGoldenRatio();
    48206
    49207#ifdef Q_WS_MAC
    50     /* Assign background image */
     208    /* Assign background image: */
    51209    assignBackground(":/vmw_new_harddisk_bg.png");
    52210#else /* Q_WS_MAC */
    53     /* Assign watermark */
     211    /* Assign watermark: */
    54212    assignWatermark(":/vmw_new_harddisk.png");
    55213#endif /* Q_WS_MAC */
    56214}
    57215
    58 CMedium UINewHDWzd::hardDisk() const
    59 {
    60     /* Get 'hardDisk' field value from page 4 */
     216CMedium UINewHDWizard::hardDisk() const
     217{
     218    /* Return 'hardDisk' field value from 'summary' page: */
    61219    return field("hardDisk").value<CMedium>();
    62220}
    63221
    64 void UINewHDWzd::setRecommendedName(const QString &strName)
    65 {
    66     /* Set 'initialName' field value for page 3 */
    67     setField("initialName", strName);
    68 }
    69 
    70 void UINewHDWzd::setRecommendedSize(qulonglong uSize)
    71 {
    72     /* Set 'initialSize' field value for page 3 */
    73     setField("initialSize", uSize);
    74 }
    75 
    76 void UINewHDWzd::setDefaultPath(const QString &strDefaultPath)
    77 {
    78     m_strDefaultPath = strDefaultPath;
    79 }
    80 
    81 QString UINewHDWzd::absoluteFilePath(const QString &strFileName)
    82 {
    83     /* Wrap file-info around received file name: */
    84     QFileInfo fi(strFileName);
    85     /* If there is no path info at all or its relative: */
    86     if (fi.fileName() == strFileName || fi.isRelative())
    87     {
    88         /* Resolve path on the basis of m_strDefaultPath: */
    89         fi = QFileInfo(m_strDefaultPath, strFileName);
    90     }
    91     /* Return full absolute hard disk file path: */
    92     return QDir::toNativeSeparators(fi.absoluteFilePath());
    93 }
    94 
    95 void UINewHDWzd::retranslateUi()
    96 {
    97     /* Wizard title */
     222void UINewHDWizard::retranslateUi()
     223{
     224    /* Assign wizard title: */
    98225    setWindowTitle(tr("Create New Virtual Disk"));
    99226}
    100227
    101 UINewHDWzdPage1::UINewHDWzdPage1()
    102 {
    103     /* Decorate page */
    104     Ui::UINewHDWzdPage1::setupUi(this);
    105 }
    106 
    107 void UINewHDWzdPage1::retranslateUi()
    108 {
    109     /* Translate uic generated strings */
    110     Ui::UINewHDWzdPage1::retranslateUi(this);
    111 
    112     /* Wizard page 1 title */
    113     setTitle(tr("Welcome to the Create New Virtual Disk Wizard!"));
    114 
    115 
    116     m_pPage1Text1->setText(tr("<p>This wizard will help you to create a new virtual hard disk "
    117                               "for your virtual machine.</p><p>%1</p>")
    118                            .arg(standardHelpText()));
    119 }
    120 
    121 void UINewHDWzdPage1::initializePage()
    122 {
    123     /* Fill and translate */
     228UINewHDWizardPageWelcome::UINewHDWizardPageWelcome()
     229{
     230    /* Decorate page: */
     231    Ui::UINewHDWizardPageWelcome::setupUi(this);
     232}
     233
     234void UINewHDWizardPageWelcome::retranslateUi()
     235{
     236    /* Translate uic generated strings: */
     237    Ui::UINewHDWizardPageWelcome::retranslateUi(this);
     238
     239    /* Set 'welcome' page title: */
     240    setTitle(tr("Welcome to the virtual disk creation wizard"));
     241
     242    /* Append page text with common part: */
     243    QString strCommonPart = QString("<p>%1</p>").arg(standardHelpText());
     244    m_pLabel->setText(m_pLabel->text() + strCommonPart);
     245}
     246
     247void UINewHDWizardPageWelcome::initializePage()
     248{
     249    /* Retranslate page: */
    124250    retranslateUi();
    125251}
    126252
    127 UINewHDWzdPage2::UINewHDWzdPage2()
    128     : m_strType(QString())
    129     , m_bFixed(false)
    130 {
    131     /* Decorate page */
    132     Ui::UINewHDWzdPage2::setupUi(this);
    133 
    134     /* Register 'type', 'fixed' fields */
    135     registerField("type*", this, "type");
    136     registerField("fixed", this, "fixed");
    137 
    138     /* Setup connections */
    139     connect (m_pTypeDynamic, SIGNAL(clicked(bool)), this, SLOT(onTypeChanged()));
    140     connect (m_pTypeFixed, SIGNAL(clicked(bool)), this, SLOT(onTypeChanged()));
    141 }
    142 
    143 void UINewHDWzdPage2::retranslateUi()
    144 {
    145     /* Translate uic generated strings */
    146     Ui::UINewHDWzdPage2::retranslateUi(this);
    147 
    148     /* Wizard page 2 title */
    149     setTitle(tr("Hard Disk Storage Type"));
    150 }
    151 
    152 void UINewHDWzdPage2::initializePage()
    153 {
    154     /* Fill and translate */
     253UINewHDWizardPageFormat::UINewHDWizardPageFormat()
     254    : m_pExclusivenessManager(0)
     255    , m_pDefaultButton(0)
     256{
     257    /* Decorate page: */
     258    Ui::UINewHDWizardPageFormat::setupUi(this);
     259
     260    /* Register extended metatypes: */
     261    qRegisterMetaType<CMediumFormat>();
     262
     263    /* Register 'mediumFormat' field: */
     264    registerField("mediumFormat", this, "mediumFormat");
     265
     266    /* Create exclusiveness manager: */
     267    m_pExclusivenessManager = new UIExclusivenessManager(this);
     268    connect(m_pExclusivenessManager, SIGNAL(sigNotifyAboutStateChange(QVariant, QList<QVariant>)), this, SLOT(sltUpdateFormat(QVariant)));
     269
     270    /* Enumerate supportable formats: */
     271    CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
     272    QVector<CMediumFormat> mediumFormats = systemProperties.GetMediumFormats();
     273    for (int iMediumFormatIndex = 0; iMediumFormatIndex < mediumFormats.size(); ++iMediumFormatIndex)
     274    {
     275        /* Get iterated medium format: */
     276        CMediumFormat mediumFormat = mediumFormats[iMediumFormatIndex];
     277
     278        /* Check that medium format supports creation: */
     279        ULONG uFormatCapabilities = mediumFormat.GetCapabilities();
     280        if (!(uFormatCapabilities & MediumFormatCapabilities_CreateFixed ||
     281              uFormatCapabilities & MediumFormatCapabilities_CreateDynamic))
     282            continue;
     283
     284        /* Check that medium format supports creation of hard-disks: */
     285        QVector<QString> fileExtensions;
     286        QVector<KDeviceType> deviceTypes;
     287        mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
     288        if (!deviceTypes.contains(KDeviceType_HardDisk))
     289            continue;
     290
     291        /* Create corresponding radio-button: */
     292        QRadioButton *pFormatButton = new QRadioButton(m_pFormatContainer);
     293        m_pExclusivenessManager->addWidget(pFormatButton, QVariant::fromValue(mediumFormat));
     294        if (mediumFormat.GetName().toLower() == "vdi")
     295        {
     296            m_pFormatsLayout->insertWidget(0, pFormatButton);
     297            m_pDefaultButton = pFormatButton;
     298        }
     299        else
     300            m_pFormatsLayout->addWidget(pFormatButton);
     301    }
     302}
     303
     304/* static */
     305QString UINewHDWizardPageFormat::fullFormatName(const QString &strBaseFormatName)
     306{
     307    if (strBaseFormatName == "VDI")
     308        return tr("&VDI (VirtualBox hard disk file)");
     309    else if (strBaseFormatName == "VHD")
     310        return tr("V&HD");
     311    else if (strBaseFormatName == "VMDK")
     312        return tr("V&MDK");
     313    return strBaseFormatName;
     314}
     315
     316void UINewHDWizardPageFormat::sltUpdateFormat(QVariant formatData)
     317{
     318    /* Get medium format: */
     319    CMediumFormat mediumFormat = formatData.value<CMediumFormat>();
     320
     321    /* Check if medium format was changed: */
     322    if (m_mediumFormat == mediumFormat)
     323        return;
     324
     325    /* Update medium format: */
     326    m_mediumFormat = mediumFormat;
     327
     328    /* Notify wizard sub-system about complete status changed: */
     329    emit completeChanged();
     330}
     331
     332void UINewHDWizardPageFormat::retranslateUi()
     333{
     334    /* Translate uic generated strings: */
     335    Ui::UINewHDWizardPageFormat::retranslateUi(this);
     336
     337    /* Set 'format' page title: */
     338    setTitle(tr("Virtual disk file type"));
     339
     340    /* Translate 'format' buttons: */
     341    QList<QRadioButton*> formatButtons = findChildren<QRadioButton*>();
     342    for (int i = 0; i < formatButtons.size(); ++i)
     343    {
     344        QRadioButton *pFormatButton = formatButtons[i];
     345        CMediumFormat mediumFormat = m_pExclusivenessManager->data(pFormatButton).value<CMediumFormat>();
     346        pFormatButton->setText(fullFormatName(mediumFormat.GetName()));
     347    }
     348}
     349
     350void UINewHDWizardPageFormat::initializePage()
     351{
     352    /* Retranslate page: */
    155353    retranslateUi();
    156354
    157     /* Prepare initial choice */
    158     m_pTypeDynamic->click();
    159 
    160     /* 'Dynamic' choice should have focus initially */
    161     m_pTypeDynamic->setFocus();
    162 }
    163 
    164 void UINewHDWzdPage2::onTypeChanged()
    165 {
    166     if (m_pTypeDynamic->isChecked())
    167     {
    168         /* 'Dynamic' storage type */
    169         m_strType = VBoxGlobal::removeAccelMark(m_pTypeDynamic->text());
    170         m_bFixed = false;
    171     }
    172     else if (m_pTypeFixed->isChecked())
    173     {
    174         /* 'Fixed' storage type */
    175         m_strType = VBoxGlobal::removeAccelMark(m_pTypeFixed->text());
    176         m_bFixed = true;
    177     }
    178     else
    179     {
    180         /* Not complete */
    181         m_strType.clear();
    182         m_bFixed = false;
    183     }
     355    /* Make sure first of buttons (default) is checked: */
     356    m_pDefaultButton->setChecked(true);
     357    m_pDefaultButton->setFocus();
     358}
     359
     360void UINewHDWizardPageFormat::cleanupPage()
     361{
     362    /* Reset exclusiveness manager: */
     363    m_pExclusivenessManager->reset();
     364    /* Call for base-class: */
     365    UINewHDWizardPage::cleanupPage();
     366}
     367
     368bool UINewHDWizardPageFormat::isComplete() const
     369{
     370    return !m_mediumFormat.isNull();
     371}
     372
     373UINewHDWizardPageVariant::UINewHDWizardPageVariant()
     374    : m_pExclusivenessManager(0)
     375    , m_pDynamicalButton(0), m_pFixedButton(0), m_pSplitBox(0)
     376    , m_uMediumVariant(KMediumVariant_Max)
     377{
     378    /* Decorate page: */
     379    Ui::UINewHDWizardPageVariant::setupUi(this);
     380
     381    /* Register 'mediumVariant' field: */
     382    registerField("mediumVariant", this, "mediumVariant");
     383
     384    /* Unfortuanelly, KMediumVariant is very messy,
     385     * so we can't enumerate it to make sure GUI will not hard-code its values,
     386     * we can only use hard-coded values that we need: */
     387
     388    /* Create exclusiveness manager: */
     389    m_pExclusivenessManager = new UIExclusivenessManager(this);
     390    connect(m_pExclusivenessManager, SIGNAL(sigNotifyAboutStateChange(QVariant, QList<QVariant>)), this, SLOT(sltUpdateVariant(QVariant, QList<QVariant>)));
     391
     392    /* Create 'dynamical' (standard) variant radio-button: */
     393    m_pDynamicalButton = new QRadioButton(m_pVariantContainer);
     394    m_pVariantsLayout->addWidget(m_pDynamicalButton);
     395    m_pExclusivenessManager->addWidget(m_pDynamicalButton, QVariant((qulonglong)KMediumVariant_Standard));
     396
     397    /* Create 'fixed' variant radio-button: */
     398    m_pFixedButton = new QRadioButton(m_pVariantContainer);
     399    m_pVariantsLayout->addWidget(m_pFixedButton);
     400    m_pExclusivenessManager->addWidget(m_pFixedButton, QVariant((qulonglong)(KMediumVariant_Standard | KMediumVariant_Fixed)));
     401
     402    /* Create '2GByte' variant check-box: */
     403    m_pSplitBox = new QCheckBox(m_pVariantContainer);
     404    m_pVariantsLayout->addWidget(m_pSplitBox);
     405    m_pExclusivenessManager->addWidget(m_pSplitBox, QVariant((qulonglong)(KMediumVariant_VmdkSplit2G)));
     406}
     407
     408/* static */
     409QString UINewHDWizardPageVariant::variantToString(qulonglong uMediumVariant)
     410{
     411    switch (uMediumVariant)
     412    {
     413        case (qulonglong)KMediumVariant_Standard:
     414            return tr("Dynamically expanding storage");
     415        case (qulonglong)(KMediumVariant_Standard | KMediumVariant_Fixed):
     416            return tr("Fixed size storage");
     417        case (qulonglong)(KMediumVariant_Standard | KMediumVariant_VmdkSplit2G):
     418            return tr("Dynamically expanding storage split into files of less than 2GB");
     419        case (qulonglong)(KMediumVariant_Standard | KMediumVariant_Fixed | KMediumVariant_VmdkSplit2G):
     420            return tr("Fixed size storage split into files of less than 2GB");
     421        default:
     422            break;
     423    }
     424    return QString();
     425}
     426
     427void UINewHDWizardPageVariant::sltUpdateVariant(QVariant exclusiveData, QList<QVariant> optionsData)
     428{
     429    /* Gather new data: */
     430    qulonglong uMediumVariant = exclusiveData.isNull() ? (qulonglong)KMediumVariant_Max : exclusiveData.toULongLong();
     431    for (int i = 0; i < optionsData.size(); ++i)
     432        uMediumVariant |= optionsData[i].toULongLong();
     433
     434    /* Check if medium variant was changed: */
     435    if (m_uMediumVariant == uMediumVariant)
     436        return;
     437
     438    /* Update medium variant: */
     439    m_uMediumVariant = uMediumVariant;
     440
     441    /* Notify wizard sub-system about complete status changed: */
    184442    emit completeChanged();
    185443}
    186444
    187 UINewHDWzdPage3::UINewHDWzdPage3()
    188     : m_strInitialName("NewHardDisk1.vdi")
    189     , m_strCurrentName(QString())
    190     , m_strLocation(QString())
    191     , m_uInitialSize(2 * _1K)
    192     , m_uCurrentSize(0)
    193     , m_uMinVDISize(_4M)
    194     , m_uMaxVDISize(vboxGlobal().virtualBox().GetSystemProperties().GetInfoVDSize())
     445void UINewHDWizardPageVariant::retranslateUi()
     446{
     447    /* Translate uic generated strings: */
     448    Ui::UINewHDWizardPageVariant::retranslateUi(this);
     449
     450    /* Set 'variant' page title: */
     451    setTitle(tr("Virtual disk storage details"));
     452
     453    /* Translate other text: */
     454    QString strText = m_pLabel->text();
     455    CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
     456    if (mediumFormat.isNull() || (mediumFormat.GetCapabilities() & KMediumFormatCapabilities_CreateDynamic))
     457        strText += tr("<p>A <b>dynamically expanding</b> virtual disk file will only use space on your physical hard disk as it fills up, "
     458                      "although it will not shrink again automatically when space on it is freed.</p>");
     459    if (mediumFormat.isNull() || (mediumFormat.GetCapabilities() & KMediumFormatCapabilities_CreateFixed))
     460        strText += tr("<p>A <b>fixed size</b> virtual disk file may take longer to create on some systems but is often faster to use.</p>");
     461    if (mediumFormat.isNull() || (mediumFormat.GetCapabilities() & KMediumFormatCapabilities_CreateSplit2G))
     462        strText += tr("<p>You can also choose to <b>split</b> the virtual disk into several files of up to two gigabytes each. "
     463                      "This is mainly useful if you wish to store the virtual machine on removable USB devices or old systems, "
     464                      "some of which cannot handle very large files.");
     465    m_pLabel->setText(strText);
     466
     467    /* Translate buttons: */
     468    m_pDynamicalButton->setText(tr("&Dynamically expanding"));
     469    m_pFixedButton->setText(tr("&Fixed size"));
     470    m_pSplitBox->setText(tr("&Split into files of less than 2GB"));
     471}
     472
     473void UINewHDWizardPageVariant::initializePage()
     474{
     475    /* Retranslate page: */
     476    retranslateUi();
     477
     478    /* Setup visibility: */
     479    CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
     480    ULONG uCapabilities = mediumFormat.GetCapabilities();
     481    m_pDynamicalButton->setVisible(uCapabilities & KMediumFormatCapabilities_CreateDynamic);
     482    m_pFixedButton->setVisible(uCapabilities & KMediumFormatCapabilities_CreateFixed);
     483    m_pSplitBox->setVisible(uCapabilities & KMediumFormatCapabilities_CreateSplit2G);
     484    /* Make sure first of buttons (default) is checked if visible: */
     485    if (!m_pDynamicalButton->isHidden())
     486    {
     487        m_pDynamicalButton->setChecked(true);
     488        m_pDynamicalButton->setFocus();
     489    }
     490}
     491
     492void UINewHDWizardPageVariant::cleanupPage()
     493{
     494    /* Reset exclusiveness manager: */
     495    m_pExclusivenessManager->reset();
     496    /* Call for base-class: */
     497    UINewHDWizardPage::cleanupPage();
     498}
     499
     500bool UINewHDWizardPageVariant::isComplete() const
     501{
     502    return m_uMediumVariant != KMediumVariant_Max;
     503}
     504
     505UINewHDWizardPageOptions::UINewHDWizardPageOptions(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize)
     506    : m_strDefaultPath(strDefaultPath)
     507    , m_strMediumName(strDefaultName.isEmpty() ? QString("NewHardDisk1") : strDefaultName)
     508    , m_uMediumSize(uDefaultSize == 0 ? (qulonglong)_1G * 2 : uDefaultSize)
     509    , m_uMediumSizeMin(_4M)
     510    , m_uMediumSizeMax(vboxGlobal().virtualBox().GetSystemProperties().GetInfoVDSize())
    195511    , m_iSliderScale(0)
    196512{
    197     /* Decorate page */
    198     Ui::UINewHDWzdPage3::setupUi(this);
    199 
    200     /* Register 'initialName', 'currentName', 'location' &
    201      * 'initialSize', 'currentSize' fields */
    202     registerField("initialName", this, "initialName");
    203     registerField("currentName", this, "currentName");
    204     registerField("location", this, "location");
    205     registerField("initialSize", this, "initialSize");
    206     registerField("currentSize", this, "currentSize");
     513    /* Decorate page: */
     514    Ui::UINewHDWizardPageOptions::setupUi(this);
     515
     516    /* Register 'mediumName', 'mediumPath', 'mediumSize' fields: */
     517    registerField("mediumName", this, "mediumName");
     518    registerField("mediumPath", this, "mediumPath");
     519    registerField("mediumSize", this, "mediumSize");
    207520
    208521    /* Detect how many steps to recognize between adjacent powers of 2
    209      * to ensure that the last slider step is exactly m_uMaxVDISize */
    210     int iPower = log2i(m_uMaxVDISize);
     522     * to ensure that the last slider step is exactly m_uMediumSizeMax: */
     523    int iPower = log2i(m_uMediumSizeMax);
    211524    qulonglong uTickMB = qulonglong (1) << iPower;
    212     if (uTickMB < m_uMaxVDISize)
     525    if (uTickMB < m_uMediumSizeMax)
    213526    {
    214527        qulonglong uTickMBNext = qulonglong (1) << (iPower + 1);
    215         qulonglong uGap = uTickMBNext - m_uMaxVDISize;
     528        qulonglong uGap = uTickMBNext - m_uMediumSizeMax;
    216529        m_iSliderScale = (int)((uTickMBNext - uTickMB) / uGap);
    217530    }
    218531    m_iSliderScale = qMax(m_iSliderScale, 8);
    219532
    220     /* Setup size-editor field */
     533    /* Setup size-editor field: */
    221534    m_pSizeEditor->setFixedWidthByText("88888.88 MB");
    222535    m_pSizeEditor->setAlignment(Qt::AlignRight);
    223536    m_pSizeEditor->setValidator(new QRegExpValidator(QRegExp(vboxGlobal().sizeRegexp()), this));
    224537
    225     /* Setup size-slider */
     538    /* Setup size-slider: */
    226539    m_pSizeSlider->setFocusPolicy(Qt::StrongFocus);
    227540    m_pSizeSlider->setPageStep(m_iSliderScale);
    228541    m_pSizeSlider->setSingleStep(m_iSliderScale / 8);
    229542    m_pSizeSlider->setTickInterval(0);
    230     m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMinVDISize, m_iSliderScale));
    231     m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMaxVDISize, m_iSliderScale));
    232     m_pSizeMin->setText(vboxGlobal().formatSize(m_uMinVDISize));
    233     m_pSizeMax->setText(vboxGlobal().formatSize(m_uMaxVDISize));
    234 
    235     /* Attach button icon */
    236     m_pLocationSelector->setIcon(UIIconPool::iconSet(":/select_file_16px.png",
    237                                                      "select_file_dis_16px.png"));
    238 
    239     /* Setup page connections */
    240     connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SLOT(onLocationEditorTextChanged(const QString &)));
    241     connect(m_pLocationSelector, SIGNAL(clicked()), this, SLOT(onSelectLocationButtonClicked()));
    242     connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(onSizeSliderValueChanged(int)));
    243     connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(onSizeEditorTextChanged(const QString &)));
    244 }
    245 
    246 void UINewHDWzdPage3::retranslateUi()
    247 {
    248     /* Translate uic generated strings */
    249     Ui::UINewHDWzdPage3::retranslateUi(this);
    250 
    251     /* Wizard page 3 title */
    252     setTitle(tr("Virtual Disk Location and Size"));
    253 }
    254 
    255 void UINewHDWzdPage3::initializePage()
    256 {
    257     /* Fill and translate */
     543    m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMediumSizeMin, m_iSliderScale));
     544    m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMediumSizeMax, m_iSliderScale));
     545    m_pSizeMin->setText(vboxGlobal().formatSize(m_uMediumSizeMin));
     546    m_pSizeMax->setText(vboxGlobal().formatSize(m_uMediumSizeMax));
     547
     548    /* Attach button icon: */
     549    m_pLocationSelector->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png"));
     550
     551    /* Setup page connections: */
     552    connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltLocationEditorTextChanged(const QString &)));
     553    connect(m_pLocationSelector, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked()));
     554    connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(sltSizeSliderValueChanged(int)));
     555    connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltSizeEditorTextChanged(const QString &)));
     556}
     557
     558void UINewHDWizardPageOptions::retranslateUi()
     559{
     560    /* Translate uic generated strings: */
     561    Ui::UINewHDWizardPageOptions::retranslateUi(this);
     562
     563    /* Set 'options' page title: */
     564    setTitle(tr("Virtual disk file location and size"));
     565}
     566
     567void UINewHDWizardPageOptions::initializePage()
     568{
     569    /* Retranslate page: */
    258570    retranslateUi();
    259571
    260     /* Initialise location */
    261     m_pLocationEditor->setText(m_strInitialName);
    262 
    263     /* Initialise size */
    264     m_pSizeSlider->setValue(sizeMBToSlider(m_uInitialSize, m_iSliderScale));
    265 
    266     /* 'Size' editor should have focus initially */
     572    /* Initialize name: */
     573    m_pLocationEditor->setText(m_strMediumName);
     574    /* Initialize size: */
     575    m_pSizeSlider->setValue(sizeMBToSlider(m_uMediumSize, m_iSliderScale));
     576    /* 'Size' editor should have focus initially: */
    267577    m_pSizeEditor->setFocus();
    268 }
    269 
    270 void UINewHDWzdPage3::cleanupPage()
    271 {
    272     /* Do not call superclass method! */
    273 }
    274 
    275 bool UINewHDWzdPage3::isComplete() const
    276 {
    277     /* Check what 'currentSize' field value feats the bounds &
    278      *       what 'currentName' field text is not empty! */
    279     return field("currentSize").toULongLong() >= m_uMinVDISize &&
    280            field("currentSize").toULongLong() <= m_uMaxVDISize &&
    281            !field("currentName").toString().trimmed().isEmpty();
    282 }
    283 
    284 bool UINewHDWzdPage3::validatePage()
    285 {
    286     QString location = qobject_cast<UINewHDWzd*>(wizard())->absoluteFilePath(m_strLocation);
    287     if (QFileInfo(location).exists())
    288     {
    289         vboxProblem().sayCannotOverwriteHardDiskStorage(this, location);
     578    /* Get default extension: */
     579    m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>());
     580    m_strMediumPath = absoluteFilePath(toFileName(m_strMediumName, m_strDefaultExtension), m_strDefaultPath);
     581}
     582
     583void UINewHDWizardPageOptions::cleanupPage()
     584{
     585    /* Reset widgets: */
     586    m_pLocationEditor->clear();
     587    m_pSizeSlider->setValue(0);
     588    /* Call for base-class: */
     589    UINewHDWizardPage::cleanupPage();
     590}
     591
     592bool UINewHDWizardPageOptions::isComplete() const
     593{
     594    /* Check what current size feats the bounds & current name is not empty! */
     595    return m_uMediumSize >= m_uMediumSizeMin && m_uMediumSize <= m_uMediumSizeMax &&
     596           !m_strMediumName.trimmed().isEmpty();
     597}
     598
     599bool UINewHDWizardPageOptions::validatePage()
     600{
     601    if (QFileInfo(m_strMediumPath).exists())
     602    {
     603        vboxProblem().sayCannotOverwriteHardDiskStorage(this, m_strMediumPath);
    290604        return false;
    291605    }
     
    293607}
    294608
    295 void UINewHDWzdPage3::onLocationEditorTextChanged(const QString &strText)
    296 {
    297     /* Set current name */
    298     m_strCurrentName = strText;
    299 
    300     /* Set current fileName */
    301     m_strLocation = toFileName(strText);
     609void UINewHDWizardPageOptions::sltLocationEditorTextChanged(const QString &strText)
     610{
     611    /* Set current medium name: */
     612    m_strMediumName = strText;
     613    /* Set current medium path: */
     614    m_strMediumPath = absoluteFilePath(toFileName(m_strMediumName, m_strDefaultExtension), m_strDefaultPath);
    302615
    303616    /* Notify wizard sub-system about complete status changed: */
     
    305618}
    306619
    307 void UINewHDWzdPage3::onSelectLocationButtonClicked()
    308 {
    309     /* Get parent wizard: */
    310     UINewHDWzd *pWizard = qobject_cast<UINewHDWzd*>(wizard());
    311 
     620void UINewHDWizardPageOptions::sltSelectLocationButtonClicked()
     621{
    312622    /* Get current folder and filename: */
    313     QFileInfo fullFilePath(pWizard->absoluteFilePath(m_strLocation));
     623    QFileInfo fullFilePath(m_strMediumPath);
    314624    QDir folder = fullFilePath.path();
    315625    QString strFileName = fullFilePath.fileName();
    316626
    317     /* Set the first parent foler that exists as the current: */
     627    /* Set the first parent folder that exists as the current: */
    318628    while (!folder.exists() && !folder.isRoot())
    319         folder = QFileInfo(folder.absolutePath()).dir();
     629    {
     630        QFileInfo folderInfo(folder.absolutePath());
     631        if (folder == QDir(folderInfo.absolutePath()))
     632            break;
     633        folder = folderInfo.absolutePath();
     634    }
    320635
    321636    /* But if it doesn't exists at all: */
     
    323638    {
    324639        /* Use recommended one folder: */
    325         QFileInfo defaultFilePath(pWizard->absoluteFilePath(strFileName));
     640        QFileInfo defaultFilePath(absoluteFilePath(strFileName, m_strDefaultPath));
    326641        folder = defaultFilePath.path();
    327642    }
    328643
    329     QString selected = QFileDialog::getSaveFileName(this, tr("Select a file for the new hard disk image file"),
    330                                                     folder.absoluteFilePath(strFileName), tr("Hard disk images (*.vdi)"));
    331 
    332     if (!selected.isEmpty())
    333     {
    334         if (QFileInfo(selected).completeSuffix().isEmpty())
    335             selected += ".vdi";
    336         m_pLocationEditor->setText(QDir::toNativeSeparators(selected));
     644    /* Prepare backends list: */
     645    CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
     646    QVector<QString> fileExtensions;
     647    QVector<KDeviceType> deviceTypes;
     648    mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
     649    QStringList validExtensionList;
     650    for (int i = 0; i < fileExtensions.size(); ++i)
     651        if (deviceTypes[i] == KDeviceType_HardDisk)
     652            validExtensionList << QString("*.%1").arg(fileExtensions[i]);
     653    /* Compose full filter list: */
     654    QString strBackendsList = QString("%1 (%2)").arg(mediumFormat.GetName()).arg(validExtensionList.join(" "));
     655
     656    /* Open corresponding file-dialog: */
     657    QString strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName),
     658                                                              strBackendsList, this,
     659                                                              tr("Select a file for the new hard disk image file"));
     660
     661    /* If there was something really chosen: */
     662    if (!strChosenFilePath.isEmpty())
     663    {
     664        /* If valid file extension is missed, append it: */
     665        if (QFileInfo(strChosenFilePath).completeSuffix().isEmpty())
     666            strChosenFilePath += QString(".%1").arg(m_strDefaultExtension);
     667        m_pLocationEditor->setText(QDir::toNativeSeparators(strChosenFilePath));
    337668        m_pLocationEditor->selectAll();
    338669        m_pLocationEditor->setFocus();
     
    340671}
    341672
    342 void UINewHDWzdPage3::onSizeSliderValueChanged(int iValue)
     673void UINewHDWizardPageOptions::sltSizeSliderValueChanged(int iValue)
    343674{
    344675    /* Update currently stored size: */
    345     m_uCurrentSize = sliderToSizeMB(iValue, m_iSliderScale);
     676    m_uMediumSize = sliderToSizeMB(iValue, m_iSliderScale);
    346677    /* Update tooltip: */
    347     updateSizeToolTip(m_uCurrentSize);
     678    updateSizeToolTip(m_uMediumSize);
    348679    /* Notify size-editor about size had changed preventing callback: */
    349680    m_pSizeEditor->blockSignals(true);
    350     m_pSizeEditor->setText(vboxGlobal().formatSize(m_uCurrentSize));
     681    m_pSizeEditor->setText(vboxGlobal().formatSize(m_uMediumSize));
    351682    m_pSizeEditor->blockSignals(false);
     683
    352684    /* Notify wizard sub-system about complete status changed: */
    353685    emit completeChanged();
    354686}
    355687
    356 void UINewHDWzdPage3::onSizeEditorTextChanged(const QString &strValue)
     688void UINewHDWizardPageOptions::sltSizeEditorTextChanged(const QString &strValue)
    357689{
    358690    /* Update currently stored size: */
    359     m_uCurrentSize = vboxGlobal().parseSize(strValue);
     691    m_uMediumSize = vboxGlobal().parseSize(strValue);
    360692    /* Update tooltip: */
    361     updateSizeToolTip(m_uCurrentSize);
     693    updateSizeToolTip(m_uMediumSize);
    362694    /* Notify size-slider about size had changed preventing callback: */
    363695    m_pSizeSlider->blockSignals(true);
    364     m_pSizeSlider->setValue(sizeMBToSlider(m_uCurrentSize, m_iSliderScale));
     696    m_pSizeSlider->setValue(sizeMBToSlider(m_uMediumSize, m_iSliderScale));
    365697    m_pSizeSlider->blockSignals(false);
     698
    366699    /* Notify wizard sub-system about complete status changed: */
    367700    emit completeChanged();
    368701}
    369702
    370 QString UINewHDWzdPage3::toFileName(const QString &strName)
    371 {
    372     QString fileName = QDir::toNativeSeparators(strName);
    373 
    374     /* Remove all trailing dots to avoid multiple dots before .vdi */
    375     int len;
    376     while (len = fileName.length(), len > 0 && fileName [len - 1] == '.')
    377         fileName.truncate(len - 1);
    378 
    379     QString ext = QFileInfo(fileName).completeSuffix();
    380 
    381     if (RTPathCompare(ext.toUtf8(), "vdi") != 0)
    382         fileName += ".vdi";
    383 
    384     return fileName;
    385 }
    386 
    387 int UINewHDWzdPage3::log2i(qulonglong uValue)
     703/* static */
     704QString UINewHDWizardPageOptions::absoluteFilePath(const QString &strFileName, const QString &strDefaultPath)
     705{
     706    /* Wrap file-info around received file name: */
     707    QFileInfo fileInfo(strFileName);
     708    /* If path-info is relative or there is no path-info at all: */
     709    if (fileInfo.fileName() == strFileName || fileInfo.isRelative())
     710    {
     711        /* Resolve path on the basis of default path we have: */
     712        fileInfo = QFileInfo(strDefaultPath, strFileName);
     713    }
     714    /* Return full absolute hard disk file path: */
     715    return QDir::toNativeSeparators(fileInfo.absoluteFilePath());
     716}
     717
     718/* static */
     719QString UINewHDWizardPageOptions::toFileName(const QString &strName, const QString &strExtension)
     720{
     721    /* Convert passed name to native separators (it can be full, actually): */
     722    QString strFileName = QDir::toNativeSeparators(strName);
     723
     724    /* Remove all trailing dots to avoid multiple dots before extension: */
     725    int iLen;
     726    while (iLen = strFileName.length(), iLen > 0 && strFileName[iLen - 1] == '.')
     727        strFileName.truncate(iLen - 1);
     728
     729    /* Add passed extension if its not done yet: */
     730    if (QFileInfo(strFileName).completeSuffix().toLower() != strExtension)
     731        strFileName += QString(".%1").arg(strExtension);
     732
     733    /* Return result: */
     734    return strFileName;
     735}
     736
     737/* static */
     738QString UINewHDWizardPageOptions::defaultExtension(CMediumFormat mediumFormat)
     739{
     740    /* Load extension / device list: */
     741    QVector<QString> fileExtensions;
     742    QVector<KDeviceType> deviceTypes;
     743    mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
     744    for (int i = 0; i < fileExtensions.size(); ++i)
     745        if (deviceTypes[i] == KDeviceType_HardDisk)
     746            return fileExtensions[i].toLower();
     747    AssertMsgFailed(("Extension can't be NULL!\n"));
     748    return QString();
     749}
     750
     751/* static */
     752int UINewHDWizardPageOptions::log2i(qulonglong uValue)
    388753{
    389754    int iPower = -1;
    390755    while (uValue)
    391756    {
    392         ++ iPower;
     757        ++iPower;
    393758        uValue >>= 1;
    394759    }
     
    396761}
    397762
    398 int UINewHDWzdPage3::sizeMBToSlider(qulonglong uValue, int iSliderScale)
     763/* static */
     764int UINewHDWizardPageOptions::sizeMBToSlider(qulonglong uValue, int iSliderScale)
    399765{
    400766    int iPower = log2i(uValue);
     
    405771}
    406772
    407 qulonglong UINewHDWzdPage3::sliderToSizeMB(int uValue, int iSliderScale)
     773/* static */
     774qulonglong UINewHDWizardPageOptions::sliderToSizeMB(int uValue, int iSliderScale)
    408775{
    409776    int iPower = uValue / iSliderScale;
     
    414781}
    415782
    416 void UINewHDWzdPage3::updateSizeToolTip(qulonglong uSize)
     783void UINewHDWizardPageOptions::updateSizeToolTip(qulonglong uSize)
    417784{
    418785    QString strToolTip = tr("<nobr>%1 (%2 B)</nobr>").arg(vboxGlobal().formatSize(uSize)).arg(uSize);
     
    421788}
    422789
    423 UINewHDWzdPage4::UINewHDWzdPage4()
    424 {
    425     /* Decorate page */
    426     Ui::UINewHDWzdPage4::setupUi(this);
    427 
    428     /* Register CMedium class */
     790UINewHDWizardPageSummary::UINewHDWizardPageSummary()
     791{
     792    /* Decorate page: */
     793    Ui::UINewHDWizardPageSummary::setupUi(this);
     794
     795    /* Register CMedium class: */
    429796    qRegisterMetaType<CMedium>();
    430797
    431     /* Register 'hardDisk' field */
     798    /* Register 'hardDisk' field: */
    432799    registerField("hardDisk", this, "hardDisk");
    433800
    434     /* Disable the background painting of the summary widget */
    435     m_pSummaryText->viewport()->setAutoFillBackground (false);
    436     /* Make the summary field read-only */
    437     m_pSummaryText->setReadOnly (true);
    438 }
    439 
    440 void UINewHDWzdPage4::retranslateUi()
    441 {
    442     /* Translate uic generated strings */
    443     Ui::UINewHDWzdPage4::retranslateUi(this);
    444 
    445     /* Wizard page 4 title */
     801    /* Disable the background painting of the summary widget: */
     802    m_pSummaryText->viewport()->setAutoFillBackground(false);
     803}
     804
     805void UINewHDWizardPageSummary::retranslateUi()
     806{
     807    /* Translate uic generated strings: */
     808    Ui::UINewHDWizardPageSummary::retranslateUi(this);
     809
     810    /* Set 'summary' page title: */
    446811    setTitle(tr("Summary"));
    447812
    448     /* Compose common summary */
    449     QString summary;
    450 
    451     QString type = field("type").toString();
    452     QString location = qobject_cast<UINewHDWzd*>(wizard())->absoluteFilePath(field("location").toString());
    453     QString sizeFormatted = VBoxGlobal::formatSize(field("currentSize").toULongLong());
    454     QString sizeUnformatted = tr("%1 B").arg(field("currentSize").toULongLong());
    455 
    456     summary += QString
     813    /* Compose common summary: */
     814    QString strSummary;
     815
     816    CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
     817    qulonglong uVariant = field("mediumVariant").toULongLong();
     818    QString strMediumPath = field("mediumPath").toString();
     819    QString sizeFormatted = VBoxGlobal::formatSize(field("mediumSize").toULongLong());
     820    QString sizeUnformatted = tr("%1 B").arg(field("mediumSize").toULongLong());
     821
     822    strSummary += QString
    457823    (
    458824        "<tr><td><nobr>%1: </nobr></td><td><nobr>%2</nobr></td></tr>"
    459825        "<tr><td><nobr>%3: </nobr></td><td><nobr>%4</nobr></td></tr>"
    460         "<tr><td><nobr>%5: </nobr></td><td><nobr>%6 (%7)</nobr></td></tr>"
     826        "<tr><td><nobr>%5: </nobr></td><td><nobr>%6</nobr></td></tr>"
     827        "<tr><td><nobr>%7: </nobr></td><td><nobr>%8 (%9)</nobr></td></tr>"
    461828    )
    462     .arg (tr("Type", "summary"), type)
    463     .arg (tr("Location", "summary"), location)
    464     .arg (tr("Size", "summary"), sizeFormatted, sizeUnformatted)
    465     ;
    466     /* Feat summary to 3 lines */
    467     setSummaryFieldLinesNumber(m_pSummaryText, 3);
    468 
    469     m_pSummaryText->setText("<table cellspacing=0 cellpadding=0>" + summary + "</table>");
    470 
    471     m_pPage4Text2->setText(tr("If the above settings are correct, press the <b>%1</b> button. "
    472                               "Once you press it, a new hard disk will be created.")
    473                            .arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton)))));
    474 }
    475 
    476 void UINewHDWzdPage4::initializePage()
    477 {
    478     /* Fill and translate */
     829    .arg(tr("File type", "summary"), mediumFormat.isNull() ? QString() : VBoxGlobal::removeAccelMark(UINewHDWizardPageFormat::fullFormatName(mediumFormat.GetName())))
     830    .arg(tr("Details", "summary"), UINewHDWizardPageVariant::variantToString(uVariant))
     831    .arg(tr("Location", "summary"), strMediumPath)
     832    .arg(tr("Size", "summary"), sizeFormatted, sizeUnformatted);
     833
     834    /* Feat summary to 4 lines: */
     835    setSummaryFieldLinesNumber(m_pSummaryText, 4);
     836
     837    m_pSummaryText->setText("<table cellspacing=0 cellpadding=0>" + strSummary + "</table>");
     838
     839    m_pLabel2->setText(tr("If the above settings are correct, press the <b>%1</b> button. "
     840                          "Once you press it a new virtual disk file will be created.")
     841                          .arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton)))));
     842}
     843
     844void UINewHDWizardPageSummary::initializePage()
     845{
     846    /* Retranslate page: */
    479847    retranslateUi();
    480848
    481     /* Summary should have focus initially */
     849    /* Summary should have focus initially: */
    482850    m_pSummaryText->setFocus();
    483851}
    484852
    485 bool UINewHDWzdPage4::validatePage()
    486 {
     853bool UINewHDWizardPageSummary::validatePage()
     854{
     855    /* Start performing long-time operation: */
    487856    startProcessing();
    488     /* Try to construct hard disk */
     857    /* Try to construct hard disk: */
    489858    bool fResult = createHardDisk();
     859    /* Finish performing long-time operation: */
    490860    endProcessing();
     861    /* Return operation result: */
    491862    return fResult;
    492863}
    493864
    494 bool UINewHDWzdPage4::createHardDisk()
    495 {
    496     KMediumVariant variant = KMediumVariant_Standard;
    497     QString location = qobject_cast<UINewHDWzd*>(wizard())->absoluteFilePath(field("location").toString());
    498     qulonglong size = field("currentSize").toULongLong();
    499     bool isFixed = field("fixed").toBool();
    500 
    501     AssertReturn(!location.isNull(), false);
    502     AssertReturn(size > 0, false);
     865bool UINewHDWizardPageSummary::createHardDisk()
     866{
     867    /* Gather attributes: */
     868    CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
     869    qulonglong uVariant = field("mediumVariant").toULongLong();
     870    QString strMediumPath = field("mediumPath").toString();
     871    qulonglong uSize = field("mediumSize").toULongLong();
     872
     873    AssertReturn(!strMediumPath.isNull(), false);
     874    AssertReturn(uSize > 0, false);
    503875
    504876    CVirtualBox vbox = vboxGlobal().virtualBox();
     
    506878    CProgress progress;
    507879
    508     CMedium hardDisk = vbox.CreateHardDisk(QString("VDI"), location);
     880    CMedium hardDisk = vbox.CreateHardDisk(mediumFormat.GetName(), strMediumPath);
    509881
    510882    if (!vbox.isOk())
    511883    {
    512         vboxProblem().cannotCreateHardDiskStorage(this, vbox, location, hardDisk, progress);
     884        vboxProblem().cannotCreateHardDiskStorage(this, vbox, strMediumPath, hardDisk, progress);
    513885        return false;
    514886    }
    515887
    516     if (isFixed)
    517         variant = (KMediumVariant)(KMediumVariant_Standard | KMediumVariant_Fixed);
    518 
    519     progress = hardDisk.CreateBaseStorage(size, variant);
     888    progress = hardDisk.CreateBaseStorage(uSize, uVariant);
    520889
    521890    if (!hardDisk.isOk())
    522891    {
    523         vboxProblem().cannotCreateHardDiskStorage(this, vbox, location, hardDisk, progress);
     892        vboxProblem().cannotCreateHardDiskStorage(this, vbox, strMediumPath, hardDisk, progress);
    524893        return false;
    525894    }
     
    532901    if (!progress.isOk() || progress.GetResultCode() != 0)
    533902    {
    534         vboxProblem().cannotCreateHardDiskStorage(this, vbox, location, hardDisk, progress);
     903        vboxProblem().cannotCreateHardDiskStorage(this, vbox, strMediumPath, hardDisk, progress);
    535904        return false;
    536905    }
    537906
    538     /* Inform everybody there is a new medium */
     907    /* Inform everybody there is a new medium: */
    539908    vboxGlobal().addMedium(VBoxMedium(CMedium(hardDisk), VBoxDefs::MediumType_HardDisk, KMediumState_Created));
    540909
     
    543912}
    544913
     914#include "UINewHDWizard.moc"
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizard.h

    r37181 r37331  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * UINewHDWzd class declaration
     4 * UINewHDWizard class declaration
    55 */
    66
    77/*
    8  * Copyright (C) 2006-2010 Oracle Corporation
     8 * Copyright (C) 2006-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1717 */
    1818
    19 #ifndef __UINewHDWzd_h__
    20 #define __UINewHDWzd_h__
    21 
    22 /* Local includes */
     19#ifndef __UINewHDWizard_h__
     20#define __UINewHDWizard_h__
     21
     22/* Local includes: */
    2323#include "QIWizard.h"
    2424#include "COMDefs.h"
    2525
    26 /* Generated includes */
    27 #include "UINewHDWzdPage1.gen.h"
    28 #include "UINewHDWzdPage2.gen.h"
    29 #include "UINewHDWzdPage3.gen.h"
    30 #include "UINewHDWzdPage4.gen.h"
    31 
    32 class UINewHDWzd : public QIWizard
    33 {
    34     Q_OBJECT;
    35 
    36 public:
    37 
    38     UINewHDWzd(QWidget *pParent);
    39 
     26/* Generated includes: */
     27#include "UINewHDWizardPageWelcome.gen.h"
     28#include "UINewHDWizardPageFormat.gen.h"
     29#include "UINewHDWizardPageVariant.gen.h"
     30#include "UINewHDWizardPageOptions.gen.h"
     31#include "UINewHDWizardPageSummary.gen.h"
     32
     33/* Forward declarations: */
     34class QRadioButton;
     35class QCheckBox;
     36class UIExclusivenessManager;
     37
     38/* New hard disk wizard class: */
     39class UINewHDWizard : public QIWizard
     40{
     41    Q_OBJECT;
     42
     43public:
     44
     45    /* Constructor: */
     46    UINewHDWizard(QWidget *pParent, const QString &strDefaultName = QString(), const QString &strDefaultPath = QString(), qulonglong uDefaultSize = 0);
     47
     48    /* Returns created hard disk: */
    4049    CMedium hardDisk() const;
    4150
    42     void setRecommendedName(const QString &strName);
    43     void setRecommendedSize(qulonglong uSize);
    44 
    45     void setDefaultPath(const QString &strPath);
    46     QString absoluteFilePath(const QString &strFileName);
     51private:
     52
     53    /* Translation stuff: */
     54    void retranslateUi();
     55};
     56
     57/* Base wrapper for the wizard page
     58 * of the new hard disk wizard class: */
     59class UINewHDWizardPage : public QIWizardPage
     60{
     61    Q_OBJECT;
     62
     63public:
     64
     65    /* Constructor: */
     66    UINewHDWizardPage() {}
    4767
    4868protected:
    4969
    50     void retranslateUi();
    51 
    52 private:
    53 
    54     QString m_strDefaultPath;
    55 };
    56 
    57 class UINewHDWzdPage1 : public QIWizardPage, public Ui::UINewHDWzdPage1
    58 {
    59     Q_OBJECT;
    60 
    61 public:
    62 
    63     UINewHDWzdPage1();
     70    /* Returns parent wizard object: */
     71    UINewHDWizard* wizard() { return qobject_cast<UINewHDWizard*>(QIWizardPage::wizard()); }
     72};
     73
     74/* Welcome page of the new hard-disk wizard: */
     75class UINewHDWizardPageWelcome : public UINewHDWizardPage, public Ui::UINewHDWizardPageWelcome
     76{
     77    Q_OBJECT;
     78
     79public:
     80
     81    /* Constructor: */
     82    UINewHDWizardPageWelcome();
     83
     84private:
     85
     86    /* Translation stuff: */
     87    void retranslateUi();
     88
     89    /* Prepare page: */
     90    void initializePage();
     91};
     92
     93/* Format page of the new hard-disk wizard: */
     94class UINewHDWizardPageFormat : public UINewHDWizardPage, public Ui::UINewHDWizardPageFormat
     95{
     96    Q_OBJECT;
     97    Q_PROPERTY(CMediumFormat mediumFormat READ mediumFormat WRITE setMediumFormat);
     98
     99public:
     100
     101    /* Constructor: */
     102    UINewHDWizardPageFormat();
     103
     104    /* Returns full medium format name: */
     105    static QString fullFormatName(const QString &strBaseFormatName);
     106
     107private slots:
     108
     109    /* Handler for the 'format'-change signal: */
     110    void sltUpdateFormat(QVariant formatData);
     111
     112private:
     113
     114    /* Translation stuff: */
     115    void retranslateUi();
     116
     117    /* Prepare page: */
     118    void initializePage();
     119    /* Cleanup page: */
     120    void cleanupPage();
     121
     122    /* Completeness validator: */
     123    bool isComplete() const;
     124
     125    /* Exclusiveness manager: */
     126    UIExclusivenessManager *m_pExclusivenessManager;
     127
     128    /* Defaut format (VDI) button: */
     129    QRadioButton *m_pDefaultButton;
     130
     131    /* Stuff for 'mediumFormat' field: */
     132    CMediumFormat mediumFormat() const { return m_mediumFormat; }
     133    void setMediumFormat(const CMediumFormat &mediumFormat) { m_mediumFormat = mediumFormat; }
     134    CMediumFormat m_mediumFormat;
     135};
     136
     137/* Variant page of the new hard-disk wizard: */
     138class UINewHDWizardPageVariant : public UINewHDWizardPage, public Ui::UINewHDWizardPageVariant
     139{
     140    Q_OBJECT;
     141    Q_PROPERTY(qulonglong mediumVariant READ mediumVariant WRITE setMediumVariant);
     142
     143public:
     144
     145    /* Constructor: */
     146    UINewHDWizardPageVariant();
     147
     148    /* Returns the name of passed medium variant: */
     149    static QString variantToString(qulonglong uMediumVariant);
     150
     151private slots:
     152
     153    /* Handler for the 'variant'-change signal: */
     154    void sltUpdateVariant(QVariant exclusiveData, QList<QVariant> optionsData);
     155
     156private:
     157
     158    /* Translation stuff: */
     159    void retranslateUi();
     160
     161    /* Prepare page: */
     162    void initializePage();
     163    /* Cleanup page: */
     164    void cleanupPage();
     165
     166    /* Completeness validator: */
     167    bool isComplete() const;
     168
     169    /* Exclusiveness manager: */
     170    UIExclusivenessManager *m_pExclusivenessManager;
     171
     172    /* Defaut variant (dynamic) button: */
     173    QRadioButton *m_pDynamicalButton;
     174    QRadioButton *m_pFixedButton;
     175    QCheckBox *m_pSplitBox;
     176
     177    /* Stuff for 'variant' field: */
     178    qulonglong mediumVariant() const { return m_uMediumVariant; }
     179    void setMediumVariant(qulonglong uMediumVariant) { m_uMediumVariant = uMediumVariant; }
     180    qulonglong m_uMediumVariant;
     181};
     182
     183/* Options page of the new hard-disk wizard: */
     184class UINewHDWizardPageOptions : public UINewHDWizardPage, public Ui::UINewHDWizardPageOptions
     185{
     186    Q_OBJECT;
     187    Q_PROPERTY(QString mediumName READ mediumName WRITE setMediumName);
     188    Q_PROPERTY(QString mediumPath READ mediumPath WRITE setMediumPath);
     189    Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize);
     190
     191public:
     192
     193    /* Constructor: */
     194    UINewHDWizardPageOptions(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize);
    64195
    65196protected:
    66197
    67     void retranslateUi();
    68 
    69     void initializePage();
    70 };
    71 
    72 class UINewHDWzdPage2 : public QIWizardPage, public Ui::UINewHDWzdPage2
    73 {
    74     Q_OBJECT;
    75     Q_PROPERTY(QString type READ type WRITE setType);
    76     Q_PROPERTY(bool fixed READ fixed WRITE setFixed);
    77 
    78 public:
    79 
    80     UINewHDWzdPage2();
    81 
    82 protected:
    83 
    84     void retranslateUi();
    85 
    86     void initializePage();
     198    /* Translation stuff: */
     199    void retranslateUi();
     200
     201    /* Prepare page: */
     202    void initializePage();
     203    /* Cleanup page: */
     204    void cleanupPage();
     205
     206    /* Completeness validator: */
     207    bool isComplete() const;
     208    /* Completeness finisher: */
     209    bool validatePage();
    87210
    88211private slots:
    89212
    90     void onTypeChanged();
    91 
    92 private:
    93 
    94     QString type() const { return m_strType; }
    95     void setType(const QString &strType) { m_strType = strType; }
    96     QString m_strType;
    97 
    98     bool fixed() const { return m_bFixed; }
    99     void setFixed(bool bFixed) { m_bFixed = bFixed; }
    100     bool m_bFixed;
    101 };
    102 
    103 class UINewHDWzdPage3 : public QIWizardPage, public Ui::UINewHDWzdPage3
    104 {
    105     Q_OBJECT;
    106     Q_PROPERTY(QString initialName READ initialName WRITE setInitialName);
    107     Q_PROPERTY(QString currentName READ currentName WRITE setCurrentName);
    108     Q_PROPERTY(QString location READ location WRITE setLocation);
    109     Q_PROPERTY(qulonglong initialSize READ initialSize WRITE setInitialSize);
    110     Q_PROPERTY(qulonglong currentSize READ currentSize WRITE setCurrentSize);
    111 
    112 public:
    113 
    114     UINewHDWzdPage3();
    115 
    116 protected:
    117 
    118     void retranslateUi();
    119 
    120     void initializePage();
    121     void cleanupPage();
    122 
    123     bool isComplete() const;
    124     bool validatePage();
    125 
    126 private slots:
    127 
    128     void onLocationEditorTextChanged(const QString &strName);
    129     void onSelectLocationButtonClicked();
    130 
    131     void onSizeSliderValueChanged(int iValue);
    132     void onSizeEditorTextChanged(const QString &strValue);
    133 
    134 private:
    135 
    136     static QString toFileName(const QString &strName);
    137 
     213    /* Location editors stuff: */
     214    void sltLocationEditorTextChanged(const QString &strName);
     215    void sltSelectLocationButtonClicked();
     216
     217    /* Size editors stuff: */
     218    void sltSizeSliderValueChanged(int iValue);
     219    void sltSizeEditorTextChanged(const QString &strValue);
     220
     221private:
     222
     223    /* Returns 'file name' for the passed 'name': */
     224    static QString toFileName(const QString &strName, const QString &strExtension);
     225    /* Returns 'absolute file path' for the passed 'file name': */
     226    static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath);
     227    /* Returns default extension for the passed medium format: */
     228    static QString defaultExtension(CMediumFormat mediumFormat);
     229
     230    /* Size editors stuff: */
    138231    static int log2i(qulonglong uValue);
    139232    static int sizeMBToSlider(qulonglong uValue, int iSliderScale);
    140233    static qulonglong sliderToSizeMB(int uValue, int iSliderScale);
    141 
    142234    void updateSizeToolTip(qulonglong uSize);
    143235
    144     QString initialName() const { return m_strInitialName; }
    145     void setInitialName(const QString &strInitialName) { m_strInitialName = strInitialName; }
    146     QString m_strInitialName;
    147 
    148     QString currentName() const { return m_strCurrentName; }
    149     void setCurrentName(const QString &strCurrentName) { m_strCurrentName = strCurrentName; }
    150     QString m_strCurrentName;
    151 
    152     QString location() const { return m_strLocation; }
    153     void setLocation(const QString &strLocation) { m_strLocation = strLocation; }
    154     QString m_strLocation;
    155 
    156     qulonglong initialSize() const { return m_uInitialSize; }
    157     void setInitialSize(qulonglong uInitialSize) { m_uInitialSize = uInitialSize; }
    158     qulonglong m_uInitialSize;
    159 
    160     qulonglong currentSize() const { return m_uCurrentSize; }
    161     void setCurrentSize(qulonglong uCurrentSize) { m_uCurrentSize = uCurrentSize; }
    162     qulonglong m_uCurrentSize;
    163 
    164     qulonglong m_uMinVDISize;
    165     qulonglong m_uMaxVDISize;
     236    /* The default extension for the hard disk file: */
     237    QString m_strDefaultExtension;
     238
     239    /* The default path for the hard disk file: */
     240    QString m_strDefaultPath;
     241
     242    /* Stuff for 'mediumName' field: */
     243    QString mediumName() const { return m_strMediumName; }
     244    void setMediumName(const QString &strMediumName) { m_strMediumName = strMediumName; }
     245    QString m_strMediumName;
     246
     247    /* Stuff for 'mediumPath' field: */
     248    QString mediumPath() const { return m_strMediumPath; }
     249    void setMediumPath(const QString &strMediumPath) { m_strMediumPath = strMediumPath; }
     250    QString m_strMediumPath;
     251
     252    /* Stuff for 'mediumSize' field: */
     253    qulonglong mediumSize() const { return m_uMediumSize; }
     254    void setMediumSize(qulonglong uMediumSize) { m_uMediumSize = uMediumSize; }
     255    qulonglong m_uMediumSize;
     256
     257    /* Other size editors stuff: */
     258    qulonglong m_uMediumSizeMin;
     259    qulonglong m_uMediumSizeMax;
    166260    int m_iSliderScale;
    167261};
    168262
    169 class UINewHDWzdPage4 : public QIWizardPage, public Ui::UINewHDWzdPage4
     263/* Summary page of the new hard-disk wizard: */
     264class UINewHDWizardPageSummary : public UINewHDWizardPage, public Ui::UINewHDWizardPageSummary
    170265{
    171266    Q_OBJECT;
     
    174269public:
    175270
    176     UINewHDWzdPage4();
     271    /* Constructor: */
     272    UINewHDWizardPageSummary();
    177273
    178274protected:
    179275
    180     void retranslateUi();
    181 
    182     void initializePage();
    183 
     276    /* Translation stuff: */
     277    void retranslateUi();
     278
     279    /* Prepare page: */
     280    void initializePage();
     281
     282    /* Completeness finisher: */
    184283    bool validatePage();
    185284
    186285private:
    187286
     287    /* Creates hard disk: */
    188288    bool createHardDisk();
    189289
     290    /* Stuff for 'hardDisk' field: */
    190291    CMedium hardDisk() const { return m_HardDisk; }
    191292    void setHardDisk(const CMedium &hardDisk) { m_HardDisk = hardDisk; }
     
    195296Q_DECLARE_METATYPE(CMedium);
    196297
    197 #endif // __UINewHDWzd_h__
    198 
     298#endif // __UINewHDWizard_h__
     299
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageFormat.ui

    r37181 r37331  
    44 VBox frontends: Qt4 GUI ("VirtualBox"):
    55
    6      Copyright (C) 2009-2010 Oracle Corporation
     6     Copyright (C) 2009-2011 Oracle Corporation
    77
    88     This file is part of VirtualBox Open Source Edition (OSE), as
     
    1414     hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1515 </comment>
    16  <class>UINewHDWzdPage2</class>
    17  <widget class="QWidget" name="UINewHDWzdPage2">
     16 <class>UINewHDWizardPageFormat</class>
     17 <widget class="QWidget" name="UINewHDWizardPageFormat">
    1818  <property name="geometry">
    1919   <rect>
     
    3030   </sizepolicy>
    3131  </property>
    32   <layout class="QVBoxLayout" name="m_pLayout1">
     32  <layout class="QVBoxLayout" name="m_pMainLayout">
    3333   <property name="bottomMargin" >
    3434    <number>0</number>
    3535   </property>
    3636   <item>
    37     <widget class="QILabel" name="m_pPage2Text1">
    38      <property name="text">
    39       <string>&lt;p&gt;Select the type of virtual hard disk you want to create.&lt;/p&gt;&lt;p&gt;A &lt;b&gt;dynamically expanding storage&lt;/b&gt; initially occupies a very small amount of space on your physical hard disk. It will grow dynamically (up to the size specified) as the Guest OS claims disk space.&lt;/p&gt;&lt;p&gt;A &lt;b&gt;fixed-size storage&lt;/b&gt; does not grow. It is stored in a file of approximately the same size as the size of the virtual hard disk. The creation of a fixed-size storage may take a long time depending on the storage size and the write performance of your harddisk.&lt;/p&gt;</string>
    40      </property>
     37    <widget class="QILabel" name="m_pLabel">
    4138     <property name="wordWrap">
    4239      <bool>true</bool>
     40     </property>
     41     <property name="text">
     42      <string>&lt;p&gt;Please choose the type of file that you would like to use for the new virtual disk. If you do not need to use this virtual machine with other virtualization software you can leave this setting unchanged.&lt;/p&gt;</string>
    4343     </property>
    4444    </widget>
    4545   </item>
    4646   <item>
    47     <widget class="QGroupBox" name="m_pTypeCnt">
     47    <widget class="QGroupBox" name="m_pFormatContainer">
    4848     <property name="title">
    49       <string>Storage Type</string>
     49      <string>File type</string>
    5050     </property>
    51      <layout class="QVBoxLayout" name="m_pLayout2">
    52       <item>
    53        <widget class="QRadioButton" name="m_pTypeDynamic">
    54         <property name="text">
    55          <string>&amp;Dynamically expanding storage</string>
    56         </property>
    57        </widget>
    58       </item>
    59       <item>
    60        <widget class="QRadioButton" name="m_pTypeFixed">
    61         <property name="text">
    62          <string>&amp;Fixed-size storage</string>
    63         </property>
    64        </widget>
    65       </item>
    66      </layout>
     51     <layout class="QVBoxLayout" name="m_pFormatsLayout"/>
    6752    </widget>
    6853   </item>
    6954   <item>
    70     <spacer name="m_pSpacer1">
     55    <spacer name="m_pSpacer">
    7156     <property name="sizeHint" stdset="0">
    7257      <size>
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageOptions.ui

    r37181 r37331  
    44 VBox frontends: Qt4 GUI ("VirtualBox"):
    55
    6      Copyright (C) 2009-2010 Oracle Corporation
     6     Copyright (C) 2009-2011 Oracle Corporation
    77
    88     This file is part of VirtualBox Open Source Edition (OSE), as
     
    1414     hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1515 </comment>
    16  <class>UINewHDWzdPage3</class>
    17  <widget class="QWidget" name="UINewHDWzdPage3">
     16 <class>UINewHDWizardPageOptions</class>
     17 <widget class="QWidget" name="UINewHDWizardPageOptions">
    1818  <property name="geometry">
    1919   <rect>
     
    3030   </sizepolicy>
    3131  </property>
    32   <layout class="QVBoxLayout" name="m_pLayout1">
     32  <layout class="QVBoxLayout" name="m_pMainLayout">
    3333   <property name="bottomMargin" >
    3434    <number>0</number>
    3535   </property>
    3636   <item>
    37     <widget class="QILabel" name="m_pPage3Text1">
    38      <property name="text">
    39       <string>&lt;p&gt;Press the &lt;b&gt;Select&lt;/b&gt; button to select the location of a file to store the hard disk data or type a file name in the entry field.&lt;/p&gt;</string>
    40      </property>
     37    <widget class="QILabel" name="m_pLabel1">
    4138     <property name="wordWrap">
    4239      <bool>true</bool>
     40     </property>
     41     <property name="text">
     42      <string>&lt;p&gt;Press the &lt;b&gt;Select&lt;/b&gt; button to select the location of a file to store the virtual disk data or type a file name in the entry field.&lt;/p&gt;</string>
    4343     </property>
    4444    </widget>
     
    4949      <string>&amp;Location</string>
    5050     </property>
    51      <layout class="QHBoxLayout" name="m_pLayout2">
     51     <layout class="QHBoxLayout" name="m_pOptionsLayout">
    5252      <item>
    5353       <widget class="QLineEdit" name="m_pLocationEditor"/>
     
    6464   </item>
    6565   <item>
    66     <widget class="QILabel" name="m_pPage3Text2">
    67      <property name="text">
    68       <string>&lt;p&gt;Select the size of the virtual hard disk in megabytes. This size will be reported to the Guest OS as the maximum size of this hard disk.&lt;/p&gt;</string>
    69      </property>
     66    <widget class="QILabel" name="m_pLabel2">
    7067     <property name="wordWrap">
    7168      <bool>true</bool>
     69     </property>
     70     <property name="text">
     71      <string>&lt;p&gt;Select the size of the virtual disk in megabytes. This size will be reported to the Guest OS as the maximum size of this virtual disk.&lt;/p&gt;</string>
    7272     </property>
    7373    </widget>
     
    7878      <string>&amp;Size</string>
    7979     </property>
    80      <layout class="QGridLayout" name="m_pLayout3">
     80     <layout class="QGridLayout" name="m_pSizeLayout">
    8181      <item row="0" column="0" colspan="3">
    8282       <widget class="QSlider" name="m_pSizeSlider">
     
    116116      </item>
    117117      <item row="1" column="1">
    118        <spacer name="m_pSpacer1">
     118       <spacer name="m_pSizeSpacer">
    119119        <property name="orientation">
    120120         <enum>Qt::Horizontal</enum>
     
    142142   </item>
    143143   <item>
    144     <spacer name="m_pSpacer2">
     144    <spacer name="m_pSpacer">
    145145     <property name="sizeHint" stdset="0">
    146146      <size>
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageSummary.ui

    r37181 r37331  
    44 VBox frontends: Qt4 GUI ("VirtualBox"):
    55
    6      Copyright (C) 2009-2010 Oracle Corporation
     6     Copyright (C) 2009-2011 Oracle Corporation
    77
    88     This file is part of VirtualBox Open Source Edition (OSE), as
     
    1414     hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1515 </comment>
    16  <class>UINewHDWzdPage4</class>
    17  <widget class="QWidget" name="UINewHDWzdPage4">
     16 <class>UINewHDWizardPageSummary</class>
     17 <widget class="QWidget" name="UINewHDWizardPageSummary">
    1818  <property name="geometry">
    1919   <rect>
     
    3030   </sizepolicy>
    3131  </property>
    32   <layout class="QVBoxLayout" name="m_pLayout1">
     32  <layout class="QVBoxLayout" name="m_pMainLayout">
    3333   <property name="bottomMargin" >
    3434    <number>0</number>
    3535   </property>
    3636   <item>
    37     <widget class="QILabel" name="m_pPage4Text1">
    38      <property name="text">
    39       <string>You are going to create a new virtual hard disk with the following parameters:</string>
    40      </property>
     37    <widget class="QILabel" name="m_pLabel1">
    4138     <property name="wordWrap">
    4239      <bool>true</bool>
     40     </property>
     41     <property name="text">
     42      <string>You are going to create a new virtual disk with the following parameters:</string>
    4343     </property>
    4444    </widget>
     
    6767   </item>
    6868   <item>
    69     <widget class="QILabel" name="m_pPage4Text2">
     69    <widget class="QILabel" name="m_pLabel2">
    7070     <property name="wordWrap">
    7171      <bool>true</bool>
     
    7474   </item>
    7575   <item>
    76     <spacer name="m_pSpacer1">
     76    <spacer name="m_pSpacer">
    7777     <property name="sizeHint" stdset="0">
    7878      <size>
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageVariant.ui

    r37181 r37331  
    44 VBox frontends: Qt4 GUI ("VirtualBox"):
    55
    6      Copyright (C) 2009-2010 Oracle Corporation
     6     Copyright (C) 2009-2011 Oracle Corporation
    77
    88     This file is part of VirtualBox Open Source Edition (OSE), as
     
    1414     hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1515 </comment>
    16  <class>UINewHDWzdPage2</class>
    17  <widget class="QWidget" name="UINewHDWzdPage2">
     16 <class>UINewHDWizardPageVariant</class>
     17 <widget class="QWidget" name="UINewHDWizardPageVariant">
    1818  <property name="geometry">
    1919   <rect>
     
    3030   </sizepolicy>
    3131  </property>
    32   <layout class="QVBoxLayout" name="m_pLayout1">
     32  <layout class="QVBoxLayout" name="m_pMainLayout">
    3333   <property name="bottomMargin" >
    3434    <number>0</number>
    3535   </property>
    3636   <item>
    37     <widget class="QILabel" name="m_pPage2Text1">
    38      <property name="text">
    39       <string>&lt;p&gt;Select the type of virtual hard disk you want to create.&lt;/p&gt;&lt;p&gt;A &lt;b&gt;dynamically expanding storage&lt;/b&gt; initially occupies a very small amount of space on your physical hard disk. It will grow dynamically (up to the size specified) as the Guest OS claims disk space.&lt;/p&gt;&lt;p&gt;A &lt;b&gt;fixed-size storage&lt;/b&gt; does not grow. It is stored in a file of approximately the same size as the size of the virtual hard disk. The creation of a fixed-size storage may take a long time depending on the storage size and the write performance of your harddisk.&lt;/p&gt;</string>
    40      </property>
     37    <widget class="QILabel" name="m_pLabel">
    4138     <property name="wordWrap">
    4239      <bool>true</bool>
     40     </property>
     41     <property name="text">
     42      <string>&lt;p&gt;Please choose whether the new virtual disk file should expand as it is used or be created fully expanded.&lt;/p&gt;</string>
    4343     </property>
    4444    </widget>
    4545   </item>
    4646   <item>
    47     <widget class="QGroupBox" name="m_pTypeCnt">
     47    <widget class="QGroupBox" name="m_pVariantContainer">
    4848     <property name="title">
    49       <string>Storage Type</string>
     49      <string>Storage details</string>
    5050     </property>
    51      <layout class="QVBoxLayout" name="m_pLayout2">
    52       <item>
    53        <widget class="QRadioButton" name="m_pTypeDynamic">
    54         <property name="text">
    55          <string>&amp;Dynamically expanding storage</string>
    56         </property>
    57        </widget>
    58       </item>
    59       <item>
    60        <widget class="QRadioButton" name="m_pTypeFixed">
    61         <property name="text">
    62          <string>&amp;Fixed-size storage</string>
    63         </property>
    64        </widget>
    65       </item>
    66      </layout>
     51     <layout class="QVBoxLayout" name="m_pVariantsLayout"/>
    6752    </widget>
    6853   </item>
    6954   <item>
    70     <spacer name="m_pSpacer1">
     55    <spacer name="m_pSpacer">
    7156     <property name="sizeHint" stdset="0">
    7257      <size>
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newhd/UINewHDWizardPageWelcome.ui

    r37181 r37331  
    44 VBox frontends: Qt4 GUI ("VirtualBox"):
    55
    6      Copyright (C) 2009-2010 Oracle Corporation
     6     Copyright (C) 2009-2011 Oracle Corporation
    77
    88     This file is part of VirtualBox Open Source Edition (OSE), as
     
    1414     hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1515 </comment>
    16  <class>UINewHDWzdPage1</class>
    17  <widget class="QWidget" name="UINewHDWzdPage1">
     16 <class>UINewHDWizardPageWelcome</class>
     17 <widget class="QWidget" name="UINewHDWizardPageWelcome">
    1818  <property name="geometry">
    1919   <rect>
     
    3030   </sizepolicy>
    3131  </property>
    32   <layout class="QVBoxLayout" name="m_pLayout1">
     32  <layout class="QVBoxLayout" name="m_pMainLayout">
    3333   <property name="bottomMargin" >
    3434    <number>0</number>
    3535   </property>
    3636   <item>
    37     <widget class="QILabel" name="m_pPage1Text1">
     37    <widget class="QILabel" name="m_pLabel">
    3838     <property name="wordWrap">
    3939      <bool>true</bool>
     40     </property>
     41     <property name="text">
     42      <string>&lt;p&gt;This wizard will help you to create a new virtual disk for your virtual machine.&lt;/p&gt;</string>
    4043     </property>
    4144    </widget>
    4245   </item>
    4346   <item>
    44     <spacer name="m_pSpacer1">
     47    <spacer name="m_pSpacer">
    4548     <property name="sizeHint" stdset="0">
    4649      <size>
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp

    r37296 r37331  
    2323/* Local includes */
    2424#include "UIIconPool.h"
    25 #include "UINewHDWzd.h"
     25#include "UINewHDWizard.h"
    2626#include "UINewVMWzd.h"
    2727#include "QIFileDialog.h"
     
    561561bool UINewVMWzdPage4::getWithNewHardDiskWizard()
    562562{
    563     UINewHDWzd dlg(this);
    564     dlg.setRecommendedName(field("name").toString());
    565     dlg.setRecommendedSize(field("type").value<CGuestOSType>().GetRecommendedHDD());
    566     dlg.setDefaultPath(field("machineFolder").toString());
     563    UINewHDWizard dlg(this, field("name").toString(), field("machineFolder").toString(), field("type").value<CGuestOSType>().GetRecommendedHDD());
    567564
    568565    if (dlg.exec() == QDialog::Accepted)
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