VirtualBox

Changeset 41021 in vbox


Ignore:
Timestamp:
Apr 23, 2012 11:02:30 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: 6123: Initial implementation of expert-mode for VirtualBox wizards.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
77 edited
14 copied

Legend:

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

    r40872 r41021  
    365365        src/wizards/newvm/UIWizardNewVMPageBasic4.h \
    366366        src/wizards/newvm/UIWizardNewVMPageBasic5.h \
     367        src/wizards/newvm/UIWizardNewVMPageExpert.h \
    367368        src/wizards/newvd/UIWizardNewVD.h \
    368369        src/wizards/newvd/UIWizardNewVDPageBasic1.h \
     
    370371        src/wizards/newvd/UIWizardNewVDPageBasic3.h \
    371372        src/wizards/newvd/UIWizardNewVDPageBasic4.h \
     373        src/wizards/newvd/UIWizardNewVDPageExpert.h \
    372374        src/wizards/clonevm/UIWizardCloneVM.h \
    373375        src/wizards/clonevm/UIWizardCloneVMPageBasic1.h \
    374376        src/wizards/clonevm/UIWizardCloneVMPageBasic2.h \
    375377        src/wizards/clonevm/UIWizardCloneVMPageBasic3.h \
     378        src/wizards/clonevm/UIWizardCloneVMPageExpert.h \
    376379        src/wizards/clonevd/UIWizardCloneVD.h \
    377380        src/wizards/clonevd/UIWizardCloneVDPageBasic1.h \
     
    380383        src/wizards/clonevd/UIWizardCloneVDPageBasic4.h \
    381384        src/wizards/clonevd/UIWizardCloneVDPageBasic5.h \
     385        src/wizards/clonevd/UIWizardCloneVDPageExpert.h \
    382386        src/wizards/exportappliance/UIWizardExportApp.h \
    383387        src/wizards/exportappliance/UIWizardExportAppPageBasic1.h \
     
    385389        src/wizards/exportappliance/UIWizardExportAppPageBasic3.h \
    386390        src/wizards/exportappliance/UIWizardExportAppPageBasic4.h \
     391        src/wizards/exportappliance/UIWizardExportAppPageExpert.h \
    387392        src/wizards/importappliance/UIWizardImportApp.h \
    388393        src/wizards/importappliance/UIWizardImportAppPageBasic1.h \
    389394        src/wizards/importappliance/UIWizardImportAppPageBasic2.h \
     395        src/wizards/importappliance/UIWizardImportAppPageExpert.h \
    390396        src/wizards/firstrun/UIWizardFirstRun.h \
    391397        src/wizards/firstrun/UIWizardFirstRunPageBasic1.h \
    392398        src/wizards/firstrun/UIWizardFirstRunPageBasic2.h \
    393         src/wizards/firstrun/UIWizardFirstRunPageBasic3.h
     399        src/wizards/firstrun/UIWizardFirstRunPageBasic3.h \
     400        src/wizards/firstrun/UIWizardFirstRunPageExpert.h
    394401
    395402VirtualBox_QT_MOCHDRS.darwin += \
     
    574581        src/wizards/newvm/UIWizardNewVMPageBasic4.cpp \
    575582        src/wizards/newvm/UIWizardNewVMPageBasic5.cpp \
     583        src/wizards/newvm/UIWizardNewVMPageExpert.cpp \
    576584        src/wizards/newvd/UIWizardNewVD.cpp \
    577585        src/wizards/newvd/UIWizardNewVDPageBasic1.cpp \
     
    579587        src/wizards/newvd/UIWizardNewVDPageBasic3.cpp \
    580588        src/wizards/newvd/UIWizardNewVDPageBasic4.cpp \
     589        src/wizards/newvd/UIWizardNewVDPageExpert.cpp \
    581590        src/wizards/clonevm/UIWizardCloneVM.cpp \
    582591        src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp \
    583592        src/wizards/clonevm/UIWizardCloneVMPageBasic2.cpp \
    584593        src/wizards/clonevm/UIWizardCloneVMPageBasic3.cpp \
     594        src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp \
    585595        src/wizards/clonevd/UIWizardCloneVD.cpp \
    586596        src/wizards/clonevd/UIWizardCloneVDPageBasic1.cpp \
     
    589599        src/wizards/clonevd/UIWizardCloneVDPageBasic4.cpp \
    590600        src/wizards/clonevd/UIWizardCloneVDPageBasic5.cpp \
     601        src/wizards/clonevd/UIWizardCloneVDPageExpert.cpp \
    591602        src/wizards/exportappliance/UIWizardExportApp.cpp \
    592603        src/wizards/exportappliance/UIWizardExportAppPageBasic1.cpp \
     
    594605        src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp \
    595606        src/wizards/exportappliance/UIWizardExportAppPageBasic4.cpp \
     607        src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp \
    596608        src/wizards/importappliance/UIWizardImportApp.cpp \
    597609        src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp \
    598610        src/wizards/importappliance/UIWizardImportAppPageBasic2.cpp \
     611        src/wizards/importappliance/UIWizardImportAppPageExpert.cpp \
    599612        src/wizards/firstrun/UIWizardFirstRun.cpp \
    600613        src/wizards/firstrun/UIWizardFirstRunPageBasic1.cpp \
    601614        src/wizards/firstrun/UIWizardFirstRunPageBasic2.cpp \
    602         src/wizards/firstrun/UIWizardFirstRunPageBasic3.cpp
     615        src/wizards/firstrun/UIWizardFirstRunPageBasic3.cpp \
     616        src/wizards/firstrun/UIWizardFirstRunPageExpert.cpp
    603617
    604618VirtualBox_SOURCES.win += \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.cpp

    r40002 r41021  
    4343const char* VBoxDefs::GUI_AutoresizeGuest = "GUI/AutoresizeGuest";
    4444const char* VBoxDefs::GUI_FirstRun = "GUI/FirstRun";
     45const char* VBoxDefs::GUI_HideDescriptionForWizards = "GUI/HideDescriptionForWizards";
    4546const char* VBoxDefs::GUI_SaveMountedAtRuntime = "GUI/SaveMountedAtRuntime";
    4647const char* VBoxDefs::GUI_ShowMiniToolBar = "GUI/ShowMiniToolBar";
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxDefs.h

    r40002 r41021  
    123123    static const char* GUI_AutoresizeGuest;
    124124    static const char* GUI_FirstRun;
     125    static const char* GUI_HideDescriptionForWizards;
    125126    static const char* GUI_SaveMountedAtRuntime;
    126127    static const char* GUI_ShowMiniToolBar;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/UISelectorWindow.cpp

    r40870 r41021  
    216216    QString strTmpFile = strFileName;
    217217#endif /* !Q_WS_MAC */
    218     UIWizardImportApp wizard(strTmpFile, this);
     218    UIWizardImportApp wizard(this, strTmpFile);
    219219    if (strFileName.isEmpty() || wizard.isValid())
    220220        wizard.exec();
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxFilePathSelectorWidget.cpp

    r33778 r41021  
    678678}
    679679
     680void VBoxEmptyFileSelector::setChooseButtonText(const QString &strText)
     681{
     682    mSelectButton->setText(strText);
     683}
     684
     685QString VBoxEmptyFileSelector::chooseButtonText() const
     686{
     687    return mSelectButton->text();
     688}
     689
    680690void VBoxEmptyFileSelector::setFileDialogTitle (const QString& aTitle)
    681691{
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/VBoxFilePathSelectorWidget.h

    r33778 r41021  
    161161    bool isModified () const { return mIsModified; }
    162162    void resetModified () { mIsModified = false; }
     163
     164    void setChooseButtonText(const QString &aText);
     165    QString chooseButtonText() const;
    163166
    164167    void setFileDialogTitle (const QString& aTitle);
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizard.cpp

    r40870 r41021  
    2929#include "QIRichTextLabel.h"
    3030
    31 UIWizard::UIWizard(QWidget *pParent)
     31int     UIWizard::exec()
     32{
     33    /* Prepare wizard: */
     34    prepare();
     35    /* Call to base-class: */
     36    return QWizard::exec();
     37}
     38
     39void UIWizard::sltCurrentIdChanged(int iId)
     40{
     41    /* Enable 1st button (Hide/Show Description) for 1st page only: */
     42    setOption(QWizard::HaveCustomButton1, iId == 0);
     43}
     44
     45void UIWizard::sltCustomButtonClicked(int iId)
     46{
     47    /* Handle 1st button: */
     48    if (iId == CustomButton1)
     49    {
     50        /* Cleanup: */
     51        cleanup();
     52
     53        /* Compose wizard's name: */
     54        QString strWizardName = nameForType(m_type);
     55        /* Load mode settings: */
     56        QStringList wizards = vboxGlobal().virtualBox().GetExtraDataStringList(VBoxDefs::GUI_HideDescriptionForWizards);
     57
     58        /* Switch mode: */
     59        switch (m_mode)
     60        {
     61            case UIWizardMode_Basic:
     62            {
     63                m_mode = UIWizardMode_Expert;
     64                if (!wizards.contains(strWizardName))
     65                    wizards << strWizardName;
     66                break;
     67            }
     68            case UIWizardMode_Expert:
     69            {
     70                m_mode = UIWizardMode_Basic;
     71                if (wizards.contains(strWizardName))
     72                    wizards.removeAll(strWizardName);
     73                break;
     74            }
     75        }
     76
     77        /* Save mode settings: */
     78        vboxGlobal().virtualBox().SetExtraDataStringList(VBoxDefs::GUI_HideDescriptionForWizards, wizards);
     79
     80        /* Prepare: */
     81        prepare();
     82    }
     83}
     84
     85UIWizard::UIWizard(QWidget *pParent, UIWizardType type)
    3286    : QIWithRetranslateUI<QWizard>(pParent)
    33 {
    34 #if 0 // This is VERY important change, have to discuss first!
    35     /* Qt have a bug-o-feature which silently fallbacks complex-wizard-style
    36      * to more simple in case it failed to initialize that complex-wizard-style.
    37      * Further wizard's look-n-feel may partially corresponds to both:
    38      * complex-wizard-style and falled-back-one, we have to be sure which we are using. */
    39     setWizardStyle(wizardStyle());
    40 #endif
     87    , m_type(type)
     88    , m_mode(loadModeForType(m_type))
     89{
     90#ifdef Q_WS_WIN
     91    /* Hide window icon: */
     92    setWindowIcon(QIcon());
     93#endif /* Q_WS_WIN */
    4194
    4295#ifdef Q_WS_MAC
    43     /* I'm really not sure why there shouldn't be any default button on Mac OS
    44      * X. This prevents the using of Enter to jump to the next page. */
     96    /* I'm really not sure why there shouldn't be any default button on Mac OS X.
     97     * This prevents the using of Enter to jump to the next page. */
    4598    setOptions(options() ^ QWizard::NoDefaultButton);
    4699#endif /* Q_WS_MAC */
    47 }
    48 
    49 int     UIWizard::addPage(UIWizardPage *pPage)
     100
     101    /* Setup connections: */
     102    connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(sltCurrentIdChanged(int)));
     103    connect(this, SIGNAL(customButtonClicked(int)), this, SLOT(sltCustomButtonClicked(int)));
     104}
     105
     106void UIWizard::retranslateUi()
     107{
     108    /* Translate basic/expert button: */
     109    switch (m_mode)
     110    {
     111        case UIWizardMode_Basic: setButtonText(QWizard::CustomButton1, tr("Hide Description")); break;
     112        case UIWizardMode_Expert: setButtonText(QWizard::CustomButton1, tr("Show Description")); break;
     113    }
     114}
     115
     116void UIWizard::retranslatePages()
     117{
     118    /* Translate all the pages: */
     119    QList<int> ids = pageIds();
     120    for (int i = 0; i < ids.size(); ++i)
     121        qobject_cast<UIWizardPage*>(page(ids[i]))->retranslate();
     122}
     123
     124void UIWizard::setPage(int iId, UIWizardPage *pPage)
    50125{
    51126    /* Configure page first: */
    52127    configurePage(pPage);
    53 
    54     /* Add page finally: */
    55     return QWizard::addPage(pPage);
    56 }
    57 
    58 void UIWizard::setPage(int iId, UIWizardPage *pPage)
    59 {
    60     /* Configure page first: */
    61     configurePage(pPage);
    62 
    63128    /* Add page finally: */
    64129    QWizard::setPage(iId, pPage);
    65130}
    66131
    67 void UIWizard::retranslateAllPages()
    68 {
    69     QList<UIWizardPage*> pages = findChildren<UIWizardPage*>();
    70     for(int i = 0; i < pages.size(); ++i)
    71         qobject_cast<UIWizardPage*>(pages.at((i)))->retranslate();
    72 }
    73 
    74 void UIWizard::resizeToGoldenRatio(UIWizardType wizardType)
    75 {
    76     /* Get corresponding ratio: */
    77     double dRatio = ratioForWizardType(wizardType);
    78 
    79     /* Use some small (!) initial QIRichTextLabel width: */
    80     int iInitialLabelWidth = 200;
    81 
    82     /* Resize wizard according that initial width,
    83      * actually there could be other content
    84      * which wants to be wider than that initial width. */
    85     resizeAccordingLabelWidth(iInitialLabelWidth);
    86 
    87     /* Get all the pages: */
    88     QList<UIWizardPage*> pages = findChildren<UIWizardPage*>();
    89     /* Get some (first) of those pages: */
    90     UIWizardPage *pSomePage = pages[0];
    91 
    92     /* Calculate actual label width: */
    93     int iPageWidth = pSomePage->width();
    94     int iLeft, iTop, iRight, iBottom;
    95     pSomePage->layout()->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
    96     int iCurrentLabelWidth = iPageWidth - iLeft - iRight;
    97 
    98     /* Calculate summary margin length, including margins of the page and wizard: */
    99     int iMarginsLength = width() - iCurrentLabelWidth;
    100 
    101     /* Calculating nearest to 'golden ratio' label width: */
    102     int iCurrentWizardWidth = width();
    103     int iCurrentWizardHeight = height();
     132void UIWizard::prepare()
     133{
     134    /* Translate wizard: */
     135    retranslateUi();
     136    /* Translate wizard pages: */
     137    retranslatePages();
     138
     139    /* Resize wizard to 'golden ratio': */
     140    resizeToGoldenRatio();
     141
     142    /* Notify pages they are ready: */
     143    QList<int> ids = pageIds();
     144    for (int i = 0; i < ids.size(); ++i)
     145        qobject_cast<UIWizardPage*>(page(ids[i]))->markReady();
     146
     147    /* Make sure custom buttons shown even if final page is first to show: */
     148    sltCurrentIdChanged(startId());
     149}
     150
     151void UIWizard::cleanup()
     152{
     153    /* Remove all the pages: */
     154    QList<int> ids = pageIds();
     155    for (int i = ids.size() - 1; i >= 0 ; --i)
     156    {
     157        /* Get enumerated page ID: */
     158        int iId = ids[i];
     159        /* Get corresponding page: */
     160        QWizardPage *pWizardPage = page(iId);
     161
     162        /* Remove page from the wizard: */
     163        removePage(iId);
     164        /* Delete page finally: */
     165        delete pWizardPage;
     166    }
     167
    104168#ifndef Q_WS_MAC
    105     /* We should take into account watermar thought its not assigned yet: */
    106     QPixmap watermarkPixmap(m_strWatermarkName);
    107     int iWatermarkWidth = watermarkPixmap.width();
    108     iCurrentWizardWidth += iWatermarkWidth;
     169    /* Cleanup watermark: */
     170    if (!m_strWatermarkName.isEmpty())
     171        setPixmap(QWizard::WatermarkPixmap, QPixmap());
    109172#endif /* !Q_WS_MAC */
    110     int iGoldenRatioWidth = (int)qSqrt(dRatio * iCurrentWizardWidth * iCurrentWizardHeight);
    111     int iProposedLabelWidth = iGoldenRatioWidth - iMarginsLength;
     173}
     174
     175void UIWizard::resizeToGoldenRatio()
     176{
     177    /* Check if wizard is in basic or expert mode: */
     178    if (m_mode == UIWizardMode_Expert)
     179    {
     180        /* Unfortunately QWizard hides some of useful API in private part,
     181         * and also have few layouting bugs which could be easy fixed
     182         * by that API, so we will use QWizard::restart() method
     183         * to call the same functionality indirectly...
     184         * Early call restart() which is usually goes on show()! */
     185        restart();
     186
     187        /* Now we have correct label size-hint(s) for all the pages.
     188         * We have to make sure all the pages uses maximum available size-hint. */
     189        QSize maxOfSizeHints;
     190        QList<UIWizardPage*> pages = findChildren<UIWizardPage*>();
     191        /* Search for the maximum available size-hint: */
     192        foreach (UIWizardPage *pPage, pages)
     193        {
     194            maxOfSizeHints.rwidth() = pPage->sizeHint().width() > maxOfSizeHints.width() ?
     195                                      pPage->sizeHint().width() : maxOfSizeHints.width();
     196            maxOfSizeHints.rheight() = pPage->sizeHint().height() > maxOfSizeHints.height() ?
     197                                       pPage->sizeHint().height() : maxOfSizeHints.height();
     198        }
     199        /* Minimum height to 350pix: */
     200        if (maxOfSizeHints.height() < 350)
     201            maxOfSizeHints.setHeight(350);
     202        /* Feat corresponding height: */
     203        maxOfSizeHints.setWidth(qMax((int)(1.5 * maxOfSizeHints.height()), maxOfSizeHints.width()));
     204        /* Use that size-hint for all the pages: */
     205        foreach (UIWizardPage *pPage, pages)
     206            pPage->setMinimumSize(maxOfSizeHints);
     207
     208        /* Relayout widgets: */
     209        QList<QLayout*> layouts = findChildren<QLayout*>();
     210        foreach(QLayout *pLayout, layouts)
     211            pLayout->activate();
     212
     213        /* Unfortunately QWizard hides some of useful API in private part,
     214         * BUT it also have few layouting bugs which could be easy fixed
     215         * by that API, so we will use QWizard::restart() method
     216         * to call the same functionality indirectly...
     217         * And now we call restart() after layout activation procedure! */
     218        restart();
     219
     220        /* Resize it to minimum size: */
     221        resize(QSize(0, 0));
     222    }
     223    else
     224    {
     225        /* Use some small (!) initial QIRichTextLabel width: */
     226        int iInitialLabelWidth = 200;
     227
     228        /* Resize wizard according that initial width,
     229         * actually there could be other content
     230         * which wants to be wider than that initial width. */
     231        resizeAccordingLabelWidth(iInitialLabelWidth);
     232
     233        /* Get some (first) of those pages: */
     234        UIWizardPage *pPage = qobject_cast<UIWizardPage*>(page(0));
     235        /* Calculate actual label width: */
     236        int iPageWidth = pPage->minimumWidth();
     237        int iLeft, iTop, iRight, iBottom;
     238        pPage->layout()->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom);
     239        int iCurrentLabelWidth = iPageWidth - iLeft - iRight;
     240        /* Calculate summary margin length,
     241         * including margins of the page and the wizard: */
     242        int iMarginsLength = width() - iCurrentLabelWidth;
     243
     244        /* Get current wizard width and height: */
     245        int iCurrentWizardWidth = width();
     246        int iCurrentWizardHeight = height();
    112247#ifndef Q_WS_MAC
    113     /* We should take into account watermar thought its not assigned yet: */
    114     iProposedLabelWidth -= iWatermarkWidth;
     248        /* We should take into account watermark like its assigned already: */
     249        QPixmap watermarkPixmap(m_strWatermarkName);
     250        int iWatermarkWidth = watermarkPixmap.width();
     251        iCurrentWizardWidth += iWatermarkWidth;
    115252#endif /* !Q_WS_MAC */
    116 
    117     /* Choose maximum between current and proposed label width: */
    118     int iNewLabelWidth = qMax(iCurrentLabelWidth, iProposedLabelWidth);
    119 
    120     /* Finally resize wizard according new label width,
    121      * taking into account all the content and 'golden ratio' rule: */
    122     resizeAccordingLabelWidth(iNewLabelWidth);
     253        /* Calculating nearest to 'golden ratio' label width: */
     254        int iGoldenRatioWidth = (int)qSqrt(ratio() * iCurrentWizardWidth * iCurrentWizardHeight);
     255        int iProposedLabelWidth = iGoldenRatioWidth - iMarginsLength;
     256#ifndef Q_WS_MAC
     257        /* We should take into account watermark like its assigned already: */
     258        iProposedLabelWidth -= iWatermarkWidth;
     259#endif /* !Q_WS_MAC */
     260
     261        /* Choose maximum between current and proposed label width: */
     262        int iNewLabelWidth = qMax(iCurrentLabelWidth, iProposedLabelWidth);
     263
     264        /* Finally resize wizard according new label width,
     265         * taking into account all the content and 'golden ratio' rule: */
     266        resizeAccordingLabelWidth(iNewLabelWidth);
     267    }
    123268
    124269#ifndef Q_WS_MAC
     
    221366}
    222367
    223 double UIWizard::ratioForWizardType(UIWizardType wizardType)
     368double UIWizard::ratio()
    224369{
    225370    /* Default value: */
     
    247392#endif /* Q_WS_WIN */
    248393
    249     switch (wizardType)
     394    switch (m_type)
    250395    {
    251396        /* New VM wizard much wider than others, fixing: */
     
    273418     * 1. wizard-layout top-margin (for modern style),
    274419     * 2. wizard-header height,
    275      * 3. margin between wizard-header and wizard-page,
     420     * 3. spacing between wizard-header and wizard-page,
    276421     * 4. wizard-page height,
    277422     * 5. wizard-layout bottom-margin (for modern style). */
     
    282427    /* Acquire wizard-layout top-margin: */
    283428    int iTopMargin = 0;
    284     if (wizardStyle() == QWizard::ModernStyle)
    285         iTopMargin = pStyle->pixelMetric(QStyle::PM_LayoutTopMargin);
    286 
    287     /* We have no direct access to QWizardHeader inside QWizard private data...
    288      * From Qt sources it seems title font is hardcoded as current font point-size + 4: */
    289     QFont titleFont(QApplication::font());
    290     titleFont.setPointSize(titleFont.pointSize() + 4);
    291     QFontMetrics titleFontMetrics(titleFont);
    292     int iTitleHeight = titleFontMetrics.height();
    293 
    294     /* We have no direct access to margin between QWizardHeader and wizard-pages...
    295      * From Qt sources it seems its hardcoded as just 7 pixels: */
    296     int iMarginBetweenTitleAndPage = 7;
    297 
    298     /* Also we should get any page height: */
    299     QList<UIWizardPage*> pages = findChildren<UIWizardPage*>();
    300     int iPageHeight = pages[0]->height();
     429    if (m_mode == UIWizardMode_Basic)
     430    {
     431        if (wizardStyle() == QWizard::ModernStyle)
     432            iTopMargin = pStyle->pixelMetric(QStyle::PM_LayoutTopMargin);
     433    }
     434
     435    /* Acquire wizard-header height: */
     436    int iTitleHeight = 0;
     437    if (m_mode == UIWizardMode_Basic)
     438    {
     439        /* We have no direct access to QWizardHeader inside QWizard private data...
     440         * From Qt sources it seems title font is hardcoded as current font point-size + 4: */
     441        QFont titleFont(QApplication::font());
     442        titleFont.setPointSize(titleFont.pointSize() + 4);
     443        QFontMetrics titleFontMetrics(titleFont);
     444        iTitleHeight = titleFontMetrics.height();
     445    }
     446
     447    /* Acquire spacing between wizard-header and wizard-page: */
     448    int iMarginBetweenTitleAndPage = 0;
     449    if (m_mode == UIWizardMode_Basic)
     450    {
     451        /* We have no direct access to margin between QWizardHeader and wizard-pages...
     452         * From Qt sources it seems its hardcoded as just 7 pixels: */
     453        iMarginBetweenTitleAndPage = 7;
     454    }
     455
     456    /* Acquire wizard-page height: */
     457    int iPageHeight = 0;
     458    if (page(0))
     459    {
     460        iPageHeight = page(0)->minimumSize().height();
     461    }
    301462
    302463    /* Acquire wizard-layout bottom-margin: */
     
    320481    /* Create final image on the basis of incoming, applying the rules: */
    321482    QImage imgWatermarkNew(imgWatermark.width(), qMax(imgWatermark.height(), proposedWatermarkHeight()), imgWatermark.format());
    322     for (int y = 0; y < imgWatermarkNew.height(); ++ y)
    323     {
    324         for (int x = 0; x < imgWatermarkNew.width(); ++ x)
     483    for (int y = 0; y < imgWatermarkNew.height(); ++y)
     484    {
     485        for (int x = 0; x < imgWatermarkNew.width(); ++x)
    325486        {
    326487            /* Border rule 1 - draw border for ClassicStyle */
     
    351512#endif /* !Q_WS_MAC */
    352513
     514/* static */
     515QString UIWizard::nameForType(UIWizardType type)
     516{
     517    QString strName;
     518    switch (type)
     519    {
     520        case UIWizardType_NewVM: strName = "NewVM"; break;
     521        case UIWizardType_CloneVM: strName = "CloneVM"; break;
     522        case UIWizardType_ExportAppliance: strName = "ExportAppliance"; break;
     523        case UIWizardType_ImportAppliance: strName = "ImportAppliance"; break;
     524        case UIWizardType_FirstRun: strName = "FirstRun"; break;
     525        case UIWizardType_NewVD: strName = "NewVD"; break;
     526        case UIWizardType_CloneVD: strName = "CloneVD"; break;
     527    }
     528    return strName;
     529}
     530
     531/* static */
     532UIWizardMode UIWizard::loadModeForType(UIWizardType type)
     533{
     534    /* Default mode is Basic: */
     535    UIWizardMode mode = UIWizardMode_Basic;
     536    /* Get mode from extra-data: */
     537    QStringList wizards = vboxGlobal().virtualBox().GetExtraDataStringList(VBoxDefs::GUI_HideDescriptionForWizards);
     538    if (wizards.contains(nameForType(type)))
     539        mode = UIWizardMode_Expert;
     540    /* Return mode: */
     541    return mode;
     542}
     543
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizard.h

    r40870 r41021  
    2929class UIWizardPage;
    3030
     31/* Wizard type: */
     32enum UIWizardType
     33{
     34    UIWizardType_NewVM,
     35    UIWizardType_CloneVM,
     36    UIWizardType_ExportAppliance,
     37    UIWizardType_ImportAppliance,
     38    UIWizardType_FirstRun,
     39    UIWizardType_NewVD,
     40    UIWizardType_CloneVD
     41};
     42
     43/* Wizard mode: */
     44enum UIWizardMode
     45{
     46    UIWizardMode_Basic,
     47    UIWizardMode_Expert
     48};
     49
    3150/* QWizard class reimplementation with extended funtionality. */
    3251class UIWizard : public QIWithRetranslateUI<QWizard>
     
    3453    Q_OBJECT;
    3554
    36 public:
     55public slots:
    3756
    38     /* Constructor: */
    39     UIWizard(QWidget *pParent);
     57    /* Exec slot: */
     58    int exec();
     59
     60protected slots:
     61
     62    /* Page change handler: */
     63    virtual void sltCurrentIdChanged(int iId);
     64    /* Custom button 1 click handler: */
     65    virtual void sltCustomButtonClicked(int iId);
    4066
    4167protected:
    4268
    43     /* Wizard type: */
    44     enum UIWizardType
    45     {
    46         UIWizardType_NewVM,
    47         UIWizardType_CloneVM,
    48         UIWizardType_ExportAppliance,
    49         UIWizardType_ImportAppliance,
    50         UIWizardType_FirstRun,
    51         UIWizardType_NewVD,
    52         UIWizardType_CloneVD
    53     };
     69    /* Constructor: */
     70    UIWizard(QWidget *pParent, UIWizardType type);
     71
     72    /* Translation stuff: */
     73    void retranslateUi();
     74    void retranslatePages();
     75
     76    /* Mode related stuff: */
     77    UIWizardMode mode() { return m_mode; }
    5478
    5579    /* Page related methods: */
    56     int addPage(UIWizardPage *pPage);
    5780    void setPage(int iId, UIWizardPage *pPage);
    58 
    59     /* Translation stuff: */
    60     void retranslateAllPages();
     81    virtual void prepare();
     82    void cleanup();
    6183
    6284    /* Adjusting stuff: */
    63     void resizeToGoldenRatio(UIWizardType wizardType);
     85    void resizeToGoldenRatio();
    6486
    6587    /* Design stuff: */
     
    78100    void configurePage(UIWizardPage *pPage);
    79101    void resizeAccordingLabelWidth(int iLabelWidth);
    80     double ratioForWizardType(UIWizardType wizardType);
     102    double ratio();
    81103#ifndef Q_WS_MAC
    82104    int proposedWatermarkHeight();
    83105    void assignWatermarkHelper();
     106#endif /* !Q_WS_MAC */
     107    static QString nameForType(UIWizardType type);
     108    static UIWizardMode loadModeForType(UIWizardType type);
     109
     110    /* Variables: */
     111    UIWizardType m_type;
     112    UIWizardMode m_mode;
     113#ifndef Q_WS_MAC
    84114    QString m_strWatermarkName;
    85115#endif /* !Q_WS_MAC */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizardPage.cpp

    r40870 r41021  
    2626#include "VBoxGlobal.h"
    2727
     28UIWizard* UIWizardPageBase::wizardImp()
     29{
     30    /* Should be reimplemented in sub-class to enable access to wizard! */
     31    AssertMsgFailed(("UIWizardPageBase::wizardImp() should be reimplemented!"));
     32    return 0;
     33}
     34
     35UIWizardPage* UIWizardPageBase::thisImp()
     36{
     37    /* Should be reimplemented in sub-class to enable access to wizard page! */
     38    AssertMsgFailed(("UIWizardPageBase::thisImp() should be reimplemented!"));
     39    return 0;
     40}
     41
     42QVariant UIWizardPageBase::fieldImp(const QString &) const
     43{
     44    /* Should be reimplemented in sub-class to enable access to wizard field! */
     45    AssertMsgFailed(("UIWizardPageBase::fieldImp(const QString &) should be reimplemented!"));
     46    return QVariant();
     47}
     48
    2849UIWizardPage::UIWizardPage()
     50    : m_fReady(false)
    2951{
     52}
     53
     54void UIWizardPage::markReady()
     55{
     56    m_fReady = true;
     57    QWizardPage::setTitle(m_strTitle);
     58}
     59
     60void UIWizardPage::setTitle(const QString &strTitle)
     61{
     62    m_strTitle = strTitle;
     63    if (m_fReady)
     64        QWizardPage::setTitle(m_strTitle);
    3065}
    3166
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizardPage.h

    r40870 r41021  
    2121
    2222/* Global includes: */
     23#include <QVariant>
    2324#include <QWizardPage>
    2425
     
    2829/* Forward declarations: */
    2930class UIWizard;
     31class UIWizardPage;
    3032
    31 /* QWizardPage class reimplementation with extended funtionality. */
     33/* One of interfaces for wizard page,
     34 * providing API for basic/expert pages. */
     35class UIWizardPageBase
     36{
     37protected:
     38
     39    /* Helpers: */
     40    virtual UIWizard* wizardImp();
     41    virtual UIWizardPage* thisImp();
     42    virtual QVariant fieldImp(const QString &strFieldName) const;
     43};
     44
     45/* One of interfaces for wizard page,
     46 * QWizardPage class reimplementation with extended funtionality. */
    3247class UIWizardPage : public QIWithRetranslateUI<QWizardPage>
    3348{
     
    4257    void retranslate() { retranslateUi(); }
    4358
     59    /* Prepare stuff: */
     60    void markReady();
     61
     62    /* Title stuff: */
     63    void setTitle(const QString &strTitle);
     64
    4465protected:
    4566
     
    4970    void startProcessing();
    5071    void endProcessing();
     72
     73    /* Variables: */
     74    bool m_fReady;
     75    QString m_strTitle;
    5176};
    5277
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVD.cpp

    r40870 r41021  
    2828#include "UIWizardCloneVDPageBasic4.h"
    2929#include "UIWizardCloneVDPageBasic5.h"
     30#include "UIWizardCloneVDPageExpert.h"
    3031#include "VBoxGlobal.h"
    3132#include "UIMessageCenter.h"
    3233
    3334UIWizardCloneVD::UIWizardCloneVD(QWidget *pParent, const CMedium &sourceVirtualDisk)
    34     : UIWizard(pParent)
     35    : UIWizard(pParent, UIWizardType_CloneVD)
     36    , m_sourceVirtualDisk(sourceVirtualDisk)
    3537{
    36 #ifdef Q_WS_WIN
    37     /* Hide window icon: */
    38     setWindowIcon(QIcon());
    39 #endif /* Q_WS_WIN */
    40 
    41     /* Create & add pages: */
    42     setPage(Page1, new UIWizardCloneVDPageBasic1(sourceVirtualDisk));
    43     setPage(Page2, new UIWizardCloneVDPageBasic2);
    44     setPage(Page3, new UIWizardCloneVDPageBasic3);
    45     setPage(Page4, new UIWizardCloneVDPageBasic4);
    46     setPage(Page5, new UIWizardCloneVDPageBasic5);
    47 
    48     /* Translate wizard: */
    49     retranslateUi();
    50 
    51     /* Translate wizard pages: */
    52     retranslateAllPages();
    53 
    5438#ifndef Q_WS_MAC
    5539    /* Assign watermark: */
     
    5943    assignBackground(":/vmw_new_harddisk_bg.png");
    6044#endif /* Q_WS_MAC */
    61 
    62     /* Resize wizard to 'golden ratio': */
    63     resizeToGoldenRatio(UIWizardType_CloneVD);
    6445}
    6546
     
    135116void UIWizardCloneVD::retranslateUi()
    136117{
     118    /* Call to base-class: */
     119    UIWizard::retranslateUi();
     120
    137121    /* Translate wizard: */
    138122    setWindowTitle(tr("Copy Virtual Disk"));
     
    140124}
    141125
     126void UIWizardCloneVD::prepare()
     127{
     128    /* Create corresponding pages: */
     129    switch (mode())
     130    {
     131        case UIWizardMode_Basic:
     132        {
     133            setPage(Page1, new UIWizardCloneVDPageBasic1(m_sourceVirtualDisk));
     134            setPage(Page2, new UIWizardCloneVDPageBasic2);
     135            setPage(Page3, new UIWizardCloneVDPageBasic3);
     136            setPage(Page4, new UIWizardCloneVDPageBasic4);
     137            setPage(Page5, new UIWizardCloneVDPageBasic5);
     138            break;
     139        }
     140        case UIWizardMode_Expert:
     141        {
     142            setPage(PageExpert, new UIWizardCloneVDPageExpert(m_sourceVirtualDisk));
     143            break;
     144        }
     145    }
     146    /* Call to base-class: */
     147    UIWizard::prepare();
     148}
     149
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVD.h

    r40870 r41021  
    4141    };
    4242
     43    /* Page IDs: */
     44    enum
     45    {
     46        PageExpert
     47    };
     48
    4349    /* Constructor: */
    4450    UIWizardCloneVD(QWidget *pParent, const CMedium &sourceVirtualDisk);
     
    5763    /* Who will be able to copy virtual-disk: */
    5864    friend class UIWizardCloneVDPageBasic5;
     65    friend class UIWizardCloneVDPageExpert;
    5966
    6067private:
     
    6370    void retranslateUi();
    6471
     72    /* Pages related stuff: */
     73    void prepare();
     74
    6575    /* Variables: */
     76    CMedium m_sourceVirtualDisk;
    6677    CMedium m_virtualDisk;
    6778};
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic1.cpp

    r40870 r41021  
    3131#include "QIToolButton.h"
    3232
    33 UIWizardCloneVDPageBasic1::UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk)
     33UIWizardCloneVDPage1::UIWizardCloneVDPage1()
    3434{
    35     /* Create widgets: */
    36     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    37         m_pLabel = new QIRichTextLabel(this);
    38         m_pSourceDiskContainer = new QGroupBox(this);
    39             m_pSourceDiskContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    40             QHBoxLayout *pSourceDiskLayout = new QHBoxLayout(m_pSourceDiskContainer);
    41                 m_pSourceDiskSelector = new VBoxMediaComboBox(m_pSourceDiskContainer);
    42                     m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
    43                     m_pSourceDiskSelector->setType(VBoxDefs::MediumType_HardDisk);
    44                     m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());
    45                     m_pSourceDiskSelector->repopulate();
    46                 m_pOpenSourceDiskButton = new QIToolButton(m_pSourceDiskContainer);
    47                     m_pOpenSourceDiskButton->setAutoRaise(true);
    48                     m_pOpenSourceDiskButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png"));
    49             pSourceDiskLayout->addWidget(m_pSourceDiskSelector);
    50             pSourceDiskLayout->addWidget(m_pOpenSourceDiskButton);
    51     pMainLayout->addWidget(m_pLabel);
    52     pMainLayout->addWidget(m_pSourceDiskContainer);
    53     pMainLayout->addStretch();
    54 
    55     /* Setup connections: */
    56     connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged()));
    57     connect(m_pOpenSourceDiskButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick()));
    58 
    59     /* Register CMedium class: */
    60     qRegisterMetaType<CMedium>();
    61     /* Register 'sourceVirtualDisk' field: */
    62     registerField("sourceVirtualDisk", this, "sourceVirtualDisk");
    6335}
    6436
    65 void UIWizardCloneVDPageBasic1::sltHandleOpenSourceDiskClick()
     37void UIWizardCloneVDPage1::onHandleOpenSourceDiskClick()
    6638{
    6739    /* Get source virtual-disk using file-open dialog: */
    68     QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, this);
     40    QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, thisImp());
    6941    if (!strMediumId.isNull())
    7042    {
     
    7648}
    7749
     50CMedium UIWizardCloneVDPage1::sourceVirtualDisk() const
     51{
     52    return vboxGlobal().findMedium(m_pSourceDiskSelector->id()).medium();
     53}
     54
     55void UIWizardCloneVDPage1::setSourceVirtualDisk(const CMedium &sourceVirtualDisk)
     56{
     57    m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());
     58}
     59
     60UIWizardCloneVDPageBasic1::UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk)
     61{
     62    /* Create widgets: */
     63    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     64    {
     65        m_pLabel = new QIRichTextLabel(this);
     66        m_pSourceDiskCnt = new QGroupBox(this);
     67        {
     68            m_pSourceDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     69            QHBoxLayout *pSourceDiskCntLayout = new QHBoxLayout(m_pSourceDiskCnt);
     70            {
     71                m_pSourceDiskSelector = new VBoxMediaComboBox(m_pSourceDiskCnt);
     72                {
     73                    m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
     74                    m_pSourceDiskSelector->setType(VBoxDefs::MediumType_HardDisk);
     75                    m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());
     76                    m_pSourceDiskSelector->repopulate();
     77                }
     78                m_pSourceDiskOpenButton = new QIToolButton(m_pSourceDiskCnt);
     79                {
     80                    m_pSourceDiskOpenButton->setAutoRaise(true);
     81                    m_pSourceDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png"));
     82                }
     83                pSourceDiskCntLayout->addWidget(m_pSourceDiskSelector);
     84                pSourceDiskCntLayout->addWidget(m_pSourceDiskOpenButton);
     85            }
     86        }
     87        pMainLayout->addWidget(m_pLabel);
     88        pMainLayout->addWidget(m_pSourceDiskCnt);
     89        pMainLayout->addStretch();
     90    }
     91
     92    /* Setup connections: */
     93    connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged()));
     94    connect(m_pSourceDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick()));
     95
     96    /* Register classes: */
     97    qRegisterMetaType<CMedium>();
     98    /* Register fields: */
     99    registerField("sourceVirtualDisk", this, "sourceVirtualDisk");
     100}
     101
     102void UIWizardCloneVDPageBasic1::sltHandleOpenSourceDiskClick()
     103{
     104    /* Call to base-class: */
     105    onHandleOpenSourceDiskClick();
     106}
     107
    78108void UIWizardCloneVDPageBasic1::retranslateUi()
    79109{
    80110    /* Translate page: */
    81     setTitle(UIWizardCloneVD::tr("Welcome to the virtual disk copying wizard"));
     111    setTitle(UIWizardCloneVD::tr("Welcome to the Copy Virtual Disk wizard!"));
    82112
    83113    /* Translate widgets: */
    84     m_pSourceDiskContainer->setTitle(UIWizardCloneVD::tr("Virtual disk to copy"));
    85     m_pOpenSourceDiskButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file..."));
    86114    m_pLabel->setText(UIWizardCloneVD::tr("<p>This wizard will help you to copy a virtual disk.</p>"));
    87115    m_pLabel->setText(m_pLabel->text() + QString("<p>%1</p>").arg(standardHelpText()));
     
    90118                                                             "choose one from the list or use the folder icon "
    91119                                                             "beside the list to select a virtual disk file."));
     120    m_pSourceDiskCnt->setTitle(UIWizardCloneVD::tr("Virtual disk to copy"));
     121    m_pSourceDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file..."));
    92122}
    93123
     
    100130bool UIWizardCloneVDPageBasic1::isComplete() const
    101131{
    102     /* Check what source virtual-disk feats the rules: */
     132    /* Make sure source virtual-disk feats the rules: */
    103133    return !sourceVirtualDisk().isNull();
    104134}
    105135
    106 CMedium UIWizardCloneVDPageBasic1::sourceVirtualDisk() const
    107 {
    108     return vboxGlobal().findMedium(m_pSourceDiskSelector->id()).medium();
    109 }
    110 
    111 void UIWizardCloneVDPageBasic1::setSourceVirtualDisk(const CMedium &sourceVirtualDisk)
    112 {
    113     m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());
    114 }
    115 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic1.h

    r40870 r41021  
    2525
    2626/* Forward declarations: */
    27 class QIRichTextLabel;
    2827class QGroupBox;
    2928class VBoxMediaComboBox;
    3029class QIToolButton;
     30class QIRichTextLabel;
    3131
    32 /* 1st page of the Clone Virtual Disk wizard: */
    33 class UIWizardCloneVDPageBasic1 : public UIWizardPage
     32/* 1st page of the Clone Virtual Disk wizard (base part): */
     33class UIWizardCloneVDPage1 : public UIWizardPageBase
     34{
     35protected:
     36
     37    /* Constructor: */
     38    UIWizardCloneVDPage1();
     39
     40    /* Handlers: */
     41    void onHandleOpenSourceDiskClick();
     42
     43    /* Stuff for 'sourceVirtualDisk' field: */
     44    CMedium sourceVirtualDisk() const;
     45    void setSourceVirtualDisk(const CMedium &sourceVirtualDisk);
     46
     47    /* Widgets: */
     48    QGroupBox *m_pSourceDiskCnt;
     49    VBoxMediaComboBox *m_pSourceDiskSelector;
     50    QIToolButton *m_pSourceDiskOpenButton;
     51};
     52
     53/* 1st page of the Clone Virtual Disk wizard (basic extension): */
     54class UIWizardCloneVDPageBasic1 : public UIWizardPage, public UIWizardCloneVDPage1
    3455{
    3556    Q_OBJECT;
     
    4061    /* Constructor: */
    4162    UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk);
     63
     64protected:
     65
     66    /* Wrapper to access 'this' from base part: */
     67    UIWizardPage* thisImp() { return this; }
    4268
    4369private slots:
     
    5783    bool isComplete() const;
    5884
    59     /* Stuff for 'sourceVirtualDisk' field: */
    60     CMedium sourceVirtualDisk() const;
    61     void setSourceVirtualDisk(const CMedium &sourceVirtualDisk);
    62 
    6385    /* Widgets: */
    6486    QIRichTextLabel *m_pLabel;
    65     QGroupBox *m_pSourceDiskContainer;
    66     VBoxMediaComboBox *m_pSourceDiskSelector;
    67     QIToolButton *m_pOpenSourceDiskButton;
    6887};
    6988
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.cpp

    r40870 r41021  
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QButtonGroup>
     23#include <QGroupBox>
    2224#include <QRadioButton>
    23 #include <QGroupBox>
    24 #include <QButtonGroup>
    2525
    2626/* Local includes: */
     
    3030#include "QIRichTextLabel.h"
    3131
    32 UIWizardCloneVDPageBasic2::UIWizardCloneVDPageBasic2()
    33     : m_pDefaultButton(0)
     32UIWizardCloneVDPage2::UIWizardCloneVDPage2()
    3433{
    35     /* Create widgets: */
    36     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    37         m_pLabel = new QIRichTextLabel(this);
    38         m_pFormatContainer = new QGroupBox(this);
    39             m_pFormatContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    40             QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatContainer);
    41     pMainLayout->addWidget(m_pLabel);
    42     pMainLayout->addWidget(m_pFormatContainer);
    43     pMainLayout->addStretch();
    44 
    45     /* Greate button group: */
    46     m_pButtonGroup = new QButtonGroup(this);
    47 
    48     /* Enumerate supportable formats: */
    49     CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
    50     const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
    51     /* Search for default (VDI) format first: */
    52     for (int i = 0; i < medFormats.size(); ++i)
    53     {
    54         /* Get iterated medium format: */
    55         const CMediumFormat &medFormat = medFormats[i];
    56         QString strFormatName(medFormat.GetName());
    57         if (strFormatName == "VDI")
    58         {
    59             QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
    60             if (pButton)
    61             {
    62                 m_formats << medFormat;
    63                 m_formatNames << strFormatName;
    64                 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1);
    65                 m_pDefaultButton = pButton;
    66             }
    67         }
    68     }
    69     /* Look for other formats: */
    70     for (int i = 0; i < medFormats.size(); ++i)
    71     {
    72         /* Get iterated medium format: */
    73         const CMediumFormat &medFormat = medFormats[i];
    74         QString strFormatName(medFormat.GetName());
    75         if (strFormatName != "VDI")
    76         {
    77             QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
    78             if (pButton)
    79             {
    80                 m_formats << medFormat;
    81                 m_formatNames << strFormatName;
    82                 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1);
    83             }
    84         }
    85     }
    86     /* Check/focus default button: */
    87     m_pDefaultButton->setChecked(true);
    88     m_pDefaultButton->setFocus();
    89 
    90     /* Setup connections: */
    91     connect(m_pButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(completeChanged()));
    92 
    93     /* Register CMediumFormat class: */
    94     qRegisterMetaType<CMediumFormat>();
    95     /* Register 'mediumFormat' field: */
    96     registerField("mediumFormat", this, "mediumFormat");
    9734}
    9835
    99 void UIWizardCloneVDPageBasic2::retranslateUi()
    100 {
    101     /* Translate page: */
    102     setTitle(UIWizardCloneVD::tr("Virtual disk file type"));
    103 
    104     /* Translate widgets: */
    105     m_pLabel->setText(UIWizardCloneVD::tr("Please choose the type of file that you would like "
    106                                           "to use for the new virtual disk. If you do not need "
    107                                           "to use it with other virtualization software you can "
    108                                           "leave this setting unchanged."));
    109     m_pFormatContainer->setTitle(UIWizardCloneVD::tr("File type"));
    110 
    111     /* Translate 'format' buttons: */
    112     QList<QAbstractButton*> buttons = m_pButtonGroup->buttons();
    113     for (int i = 0; i < buttons.size(); ++i)
    114     {
    115         QAbstractButton *pButton = buttons[i];
    116         pButton->setText(UIWizardCloneVD::fullFormatName(m_formatNames[m_pButtonGroup->id(pButton)]));
    117     }
    118 }
    119 
    120 void UIWizardCloneVDPageBasic2::initializePage()
    121 {
    122     /* Translate page: */
    123     retranslateUi();
    124 }
    125 
    126 bool UIWizardCloneVDPageBasic2::isComplete() const
    127 {
    128     return !mediumFormat().isNull();
    129 }
    130 
    131 int UIWizardCloneVDPageBasic2::nextId() const
    132 {
    133     CMediumFormat medFormat = mediumFormat();
    134     ULONG uCapabilities = medFormat.GetCapabilities();
    135     int cTest = 0;
    136     if (uCapabilities & KMediumFormatCapabilities_CreateDynamic)
    137         ++cTest;
    138     if (uCapabilities & KMediumFormatCapabilities_CreateFixed)
    139         ++cTest;
    140     if (uCapabilities & KMediumFormatCapabilities_CreateSplit2G)
    141         ++cTest;
    142     if (cTest > 1)
    143         return UIWizardCloneVD::Page3;
    144     return UIWizardCloneVD::Page4;
    145 }
    146 
    147 QRadioButton* UIWizardCloneVDPageBasic2::addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat medFormat)
     36QRadioButton* UIWizardCloneVDPage2::addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat medFormat)
    14837{
    14938    /* Check that medium format supports creation: */
     
    16150
    16251    /* Create/add corresponding radio-button: */
    163     QRadioButton *pFormatButton = new QRadioButton(m_pFormatContainer);
     52    QRadioButton *pFormatButton = new QRadioButton(m_pFormatCnt);
    16453    pFormatsLayout->addWidget(pFormatButton);
    16554    return pFormatButton;
    16655}
    16756
    168 CMediumFormat UIWizardCloneVDPageBasic2::mediumFormat() const
     57CMediumFormat UIWizardCloneVDPage2::mediumFormat() const
    16958{
    170     return m_pButtonGroup->checkedButton() ? m_formats[m_pButtonGroup->checkedId()] : CMediumFormat();
     59    return m_pFormatButtonGroup->checkedButton() ? m_formats[m_pFormatButtonGroup->checkedId()] : CMediumFormat();
    17160}
    17261
    173 void UIWizardCloneVDPageBasic2::setMediumFormat(const CMediumFormat &mediumFormat)
     62void UIWizardCloneVDPage2::setMediumFormat(const CMediumFormat &mediumFormat)
    17463{
    17564    int iPosition = m_formats.indexOf(mediumFormat);
    17665    if (iPosition >= 0)
    17766    {
    178         m_pButtonGroup->button(iPosition)->click();
    179         m_pButtonGroup->button(iPosition)->setFocus();
     67        m_pFormatButtonGroup->button(iPosition)->click();
     68        m_pFormatButtonGroup->button(iPosition)->setFocus();
    18069    }
    18170}
    18271
     72UIWizardCloneVDPageBasic2::UIWizardCloneVDPageBasic2()
     73{
     74    /* Create widgets: */
     75    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     76    {
     77        m_pLabel = new QIRichTextLabel(this);
     78        m_pFormatCnt = new QGroupBox(this);
     79        {
     80            m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     81            QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatCnt);
     82            {
     83                m_pFormatButtonGroup = new QButtonGroup(this);
     84                {
     85                    CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
     86                    const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
     87                    for (int i = 0; i < medFormats.size(); ++i)
     88                    {
     89                        const CMediumFormat &medFormat = medFormats[i];
     90                        QString strFormatName(medFormat.GetName());
     91                        if (strFormatName == "VDI")
     92                        {
     93                            QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
     94                            if (pButton)
     95                            {
     96                                m_formats << medFormat;
     97                                m_formatNames << strFormatName;
     98                                m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     99                            }
     100                        }
     101                    }
     102                    for (int i = 0; i < medFormats.size(); ++i)
     103                    {
     104                        const CMediumFormat &medFormat = medFormats[i];
     105                        QString strFormatName(medFormat.GetName());
     106                        if (strFormatName != "VDI")
     107                        {
     108                            QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
     109                            if (pButton)
     110                            {
     111                                m_formats << medFormat;
     112                                m_formatNames << strFormatName;
     113                                m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     114                            }
     115                        }
     116                    }
     117                    m_pFormatButtonGroup->button(0)->click();
     118                    m_pFormatButtonGroup->button(0)->setFocus();
     119                }
     120            }
     121        }
     122        pMainLayout->addWidget(m_pLabel);
     123        pMainLayout->addWidget(m_pFormatCnt);
     124        pMainLayout->addStretch();
     125    }
     126
     127    /* Setup connections: */
     128    connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged()));
     129
     130    /* Register classes: */
     131    qRegisterMetaType<CMediumFormat>();
     132    /* Register fields: */
     133    registerField("mediumFormat", this, "mediumFormat");
     134}
     135
     136void UIWizardCloneVDPageBasic2::retranslateUi()
     137{
     138    /* Translate page: */
     139    setTitle(UIWizardCloneVD::tr("Virtual disk file type"));
     140
     141    /* Translate widgets: */
     142    m_pLabel->setText(UIWizardCloneVD::tr("Please choose the type of file that you would like "
     143                                          "to use for the new virtual disk. If you do not need "
     144                                          "to use it with other virtualization software you can "
     145                                          "leave this setting unchanged."));
     146    m_pFormatCnt->setTitle(UIWizardCloneVD::tr("File type"));
     147    QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons();
     148    for (int i = 0; i < buttons.size(); ++i)
     149    {
     150        QAbstractButton *pButton = buttons[i];
     151        pButton->setText(UIWizardCloneVD::fullFormatName(m_formatNames[m_pFormatButtonGroup->id(pButton)]));
     152    }
     153}
     154
     155void UIWizardCloneVDPageBasic2::initializePage()
     156{
     157    /* Translate page: */
     158    retranslateUi();
     159}
     160
     161bool UIWizardCloneVDPageBasic2::isComplete() const
     162{
     163    /* Make sure medium format is correct: */
     164    return !mediumFormat().isNull();
     165}
     166
     167int UIWizardCloneVDPageBasic2::nextId() const
     168{
     169    /* Show variant page only if there is something to show: */
     170    CMediumFormat medFormat = mediumFormat();
     171    ULONG uCapabilities = medFormat.GetCapabilities();
     172    int cTest = 0;
     173    if (uCapabilities & KMediumFormatCapabilities_CreateDynamic)
     174        ++cTest;
     175    if (uCapabilities & KMediumFormatCapabilities_CreateFixed)
     176        ++cTest;
     177    if (uCapabilities & KMediumFormatCapabilities_CreateSplit2G)
     178        ++cTest;
     179    if (cTest > 1)
     180        return UIWizardCloneVD::Page3;
     181    /* Skip otherwise: */
     182    return UIWizardCloneVD::Page4;
     183}
     184
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.h

    r40870 r41021  
    2626/* Forward declarations: */
    2727class QVBoxLayout;
     28class QGroupBox;
     29class QButtonGroup;
    2830class QRadioButton;
    2931class QIRichTextLabel;
    30 class QGroupBox;
    31 class QButtonGroup;
    3232
    33 /* 2nd page of the Clone Virtual Disk wizard: */
    34 class UIWizardCloneVDPageBasic2 : public UIWizardPage
     33/* 2nd page of the Clone Virtual Disk wizard (base part): */
     34class UIWizardCloneVDPage2 : public UIWizardPageBase
     35{
     36protected:
     37
     38    /* Constructor: */
     39    UIWizardCloneVDPage2();
     40
     41    /* Helping stuff: */
     42    QRadioButton* addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mediumFormat);
     43
     44    /* Stuff for 'mediumFormat' field: */
     45    CMediumFormat mediumFormat() const;
     46    void setMediumFormat(const CMediumFormat &mediumFormat);
     47
     48    /* Variables: */
     49    QButtonGroup *m_pFormatButtonGroup;
     50    QList<CMediumFormat> m_formats;
     51    QStringList m_formatNames;
     52
     53    /* Widgets: */
     54    QGroupBox *m_pFormatCnt;
     55};
     56
     57/* 2nd page of the Clone Virtual Disk wizard (basic extension): */
     58class UIWizardCloneVDPageBasic2 : public UIWizardPage, public UIWizardCloneVDPage2
    3559{
    3660    Q_OBJECT;
     
    5680    int nextId() const;
    5781
    58     /* Helping stuff: */
    59     QRadioButton* addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mediumFormat);
    60 
    61     /* Stuff for 'mediumFormat' field: */
    62     CMediumFormat mediumFormat() const;
    63     void setMediumFormat(const CMediumFormat &mediumFormat);
    64 
    65     /* Variables: */
    66     QRadioButton *m_pDefaultButton;
    67     QButtonGroup *m_pButtonGroup;
    68     QList<CMediumFormat> m_formats;
    69     QStringList m_formatNames;
    70 
    7182    /* Widgets: */
    7283    QIRichTextLabel *m_pLabel;
    73     QGroupBox *m_pFormatContainer;
    7484};
    7585
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic3.cpp

    r40870 r41021  
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QGroupBox>
     23#include <QButtonGroup>
    2224#include <QRadioButton>
    2325#include <QCheckBox>
    24 #include <QGroupBox>
    2526
    2627/* Local includes: */
     
    3031#include "QIRichTextLabel.h"
    3132
     33UIWizardCloneVDPage3::UIWizardCloneVDPage3()
     34{
     35}
     36
     37qulonglong UIWizardCloneVDPage3::mediumVariant() const
     38{
     39    /* Initial value: */
     40    qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max;
     41
     42    /* Exclusive options: */
     43    if (m_pDynamicalButton->isChecked())
     44        uMediumVariant = (qulonglong)KMediumVariant_Standard;
     45    else if (m_pFixedButton->isChecked())
     46        uMediumVariant = (qulonglong)KMediumVariant_Fixed;
     47
     48    /* Additional options: */
     49    if (m_pSplitBox->isChecked())
     50        uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G;
     51
     52    /* Return options: */
     53    return uMediumVariant;
     54}
     55
     56void UIWizardCloneVDPage3::setMediumVariant(qulonglong uMediumVariant)
     57{
     58    /* Exclusive options: */
     59    if (uMediumVariant & (qulonglong)KMediumVariant_Fixed)
     60    {
     61        m_pFixedButton->click();
     62        m_pFixedButton->setFocus();
     63    }
     64    else
     65    {
     66        m_pDynamicalButton->click();
     67        m_pDynamicalButton->setFocus();
     68    }
     69
     70    /* Additional options: */
     71    m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G);
     72}
     73
    3274UIWizardCloneVDPageBasic3::UIWizardCloneVDPageBasic3()
    33     : m_pDynamicalButton(0), m_pFixedButton(0), m_pSplitBox(0)
    3475{
    3576    /* Create widgets: */
    3677    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     78    {
    3779        m_pDescriptionLabel = new QIRichTextLabel(this);
    3880        m_pDynamicLabel = new QIRichTextLabel(this);
    3981        m_pFixedLabel = new QIRichTextLabel(this);
    4082        m_pSplitLabel = new QIRichTextLabel(this);
    41         m_pVariantContainer = new QGroupBox(this);
    42             m_pVariantContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    43             QVBoxLayout *pVariantsLayout = new QVBoxLayout(m_pVariantContainer);
    44                 m_pDynamicalButton = new QRadioButton(m_pVariantContainer);
    45                     m_pDynamicalButton->click();
    46                     m_pDynamicalButton->setFocus();
    47                 m_pFixedButton = new QRadioButton(m_pVariantContainer);
    48                 m_pSplitBox = new QCheckBox(m_pVariantContainer);
    49             pVariantsLayout->addWidget(m_pDynamicalButton);
    50             pVariantsLayout->addWidget(m_pFixedButton);
    51             pVariantsLayout->addWidget(m_pSplitBox);
    52     pMainLayout->addWidget(m_pDescriptionLabel);
    53     pMainLayout->addWidget(m_pDynamicLabel);
    54     pMainLayout->addWidget(m_pFixedLabel);
    55     pMainLayout->addWidget(m_pSplitLabel);
    56     pMainLayout->addWidget(m_pVariantContainer);
    57     pMainLayout->addStretch();
     83        m_pVariantCnt = new QGroupBox(this);
     84        {
     85            m_pVariantCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     86            QVBoxLayout *pVariantCntLayout = new QVBoxLayout(m_pVariantCnt);
     87            {
     88                m_pVariantButtonGroup = new QButtonGroup(m_pVariantCnt);
     89                {
     90                    m_pDynamicalButton = new QRadioButton(m_pVariantCnt);
     91                    {
     92                        m_pDynamicalButton->click();
     93                        m_pDynamicalButton->setFocus();
     94                    }
     95                    m_pFixedButton = new QRadioButton(m_pVariantCnt);
     96                    m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
     97                    m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
     98                }
     99                m_pSplitBox = new QCheckBox(m_pVariantCnt);
     100                pVariantCntLayout->addWidget(m_pDynamicalButton);
     101                pVariantCntLayout->addWidget(m_pFixedButton);
     102                pVariantCntLayout->addWidget(m_pSplitBox);
     103            }
     104        }
     105        pMainLayout->addWidget(m_pDescriptionLabel);
     106        pMainLayout->addWidget(m_pDynamicLabel);
     107        pMainLayout->addWidget(m_pFixedLabel);
     108        pMainLayout->addWidget(m_pSplitLabel);
     109        pMainLayout->addWidget(m_pVariantCnt);
     110        pMainLayout->addStretch();
     111    }
    58112
    59113    /* Setup connections: */
    60     connect(m_pDynamicalButton, SIGNAL(clicked(bool)), this, SIGNAL(completeChanged()));
    61     connect(m_pFixedButton, SIGNAL(clicked(bool)), this, SIGNAL(completeChanged()));
     114    connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged()));
    62115    connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged()));
    63116
    64     /* Register 'mediumVariant' field: */
     117    /* Register fields: */
    65118    registerField("mediumVariant", this, "mediumVariant");
    66119}
     
    83136                                               "virtual machine on removable USB devices or old systems, some of which cannot "
    84137                                               "handle very large files."));
    85     m_pVariantContainer->setTitle(UIWizardCloneVD::tr("Storage details"));
    86138
    87     /* Translate buttons: */
     139    m_pVariantCnt->setTitle(UIWizardCloneVD::tr("Storage details"));
    88140    m_pDynamicalButton->setText(UIWizardCloneVD::tr("&Dynamically allocated"));
    89141    m_pFixedButton->setText(UIWizardCloneVD::tr("&Fixed size"));
     
    112164bool UIWizardCloneVDPageBasic3::isComplete() const
    113165{
     166    /* Make sure medium variant is correct: */
    114167    return mediumVariant() != (qulonglong)KMediumVariant_Max;
    115168}
    116169
    117 qulonglong UIWizardCloneVDPageBasic3::mediumVariant() const
    118 {
    119     /* Initial value: */
    120     qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max;
    121 
    122     /* Exclusive options: */
    123     if (m_pDynamicalButton->isChecked())
    124         uMediumVariant = (qulonglong)KMediumVariant_Standard;
    125     else if (m_pFixedButton->isChecked())
    126         uMediumVariant = (qulonglong)KMediumVariant_Fixed;
    127 
    128     /* Additional options: */
    129     if (m_pSplitBox->isChecked())
    130         uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G;
    131 
    132     /* Return options: */
    133     return uMediumVariant;
    134 }
    135 
    136 void UIWizardCloneVDPageBasic3::setMediumVariant(qulonglong uMediumVariant)
    137 {
    138     /* Exclusive options: */
    139     if (uMediumVariant & (qulonglong)KMediumVariant_Fixed)
    140     {
    141         m_pFixedButton->click();
    142         m_pFixedButton->setFocus();
    143     }
    144     else
    145     {
    146         m_pDynamicalButton->click();
    147         m_pDynamicalButton->setFocus();
    148     }
    149 
    150     /* Additional options: */
    151     m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G);
    152 }
    153 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic3.h

    r40870 r41021  
    2424
    2525/* Forward declarations: */
     26class QGroupBox;
     27class QButtonGroup;
    2628class QRadioButton;
    2729class QCheckBox;
    2830class QIRichTextLabel;
    29 class QGroupBox;
    3031
    31 /* 3rd page of the Clone Virtual Disk wizard: */
    32 class UIWizardCloneVDPageBasic3 : public UIWizardPage
     32/* 3rd page of the Clone Virtual Disk wizard (base part): */
     33class UIWizardCloneVDPage3 : public UIWizardPageBase
     34{
     35protected:
     36
     37    /* Constructor: */
     38    UIWizardCloneVDPage3();
     39
     40    /* Stuff for 'variant' field: */
     41    qulonglong mediumVariant() const;
     42    void setMediumVariant(qulonglong uMediumVariant);
     43
     44    /* Widgets: */
     45    QGroupBox *m_pVariantCnt;
     46    QButtonGroup *m_pVariantButtonGroup;
     47    QRadioButton *m_pDynamicalButton;
     48    QRadioButton *m_pFixedButton;
     49    QCheckBox *m_pSplitBox;
     50};
     51
     52/* 3rd page of the Clone Virtual Disk wizard (basic extension): */
     53class UIWizardCloneVDPageBasic3 : public UIWizardPage, public UIWizardCloneVDPage3
    3354{
    3455    Q_OBJECT;
     
    5172    bool isComplete() const;
    5273
    53     /* Stuff for 'variant' field: */
    54     qulonglong mediumVariant() const;
    55     void setMediumVariant(qulonglong uMediumVariant);
    56 
    57     /* Variables: */
    58     QRadioButton *m_pDynamicalButton;
    59     QRadioButton *m_pFixedButton;
    60     QCheckBox *m_pSplitBox;
    61 
    6274    /* Widgets: */
    6375    QIRichTextLabel *m_pDescriptionLabel;
     
    6577    QIRichTextLabel *m_pFixedLabel;
    6678    QIRichTextLabel *m_pSplitLabel;
    67     QGroupBox *m_pVariantContainer;
    6879};
    6980
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic4.cpp

    r40870 r41021  
    2929#include "UIWizardCloneVD.h"
    3030#include "COMDefs.h"
     31#include "VBoxGlobal.h"
    3132#include "UIMessageCenter.h"
    3233#include "UIIconPool.h"
     
    3435#include "QIRichTextLabel.h"
    3536#include "QIToolButton.h"
    36 #include "iprt/path.h"
    37 
    38 UIWizardCloneVDPageBasic4::UIWizardCloneVDPageBasic4()
    39     : m_uMediumSize(0)
    40 {
    41     /* Create widgets: */
    42     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    43         m_pLabel = new QIRichTextLabel(this);
    44         m_pLocationCnt = new QGroupBox(this);
    45             m_pLocationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    46             QHBoxLayout *pOptionsLayout = new QHBoxLayout(m_pLocationCnt);
    47                 m_pLocationEditor = new QLineEdit(m_pLocationCnt);
    48                 m_pLocationSelector = new QIToolButton(m_pLocationCnt);
    49                     m_pLocationSelector->setAutoRaise(true);
    50                     m_pLocationSelector->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png"));
    51             pOptionsLayout->addWidget(m_pLocationEditor);
    52             pOptionsLayout->addWidget(m_pLocationSelector);
    53     pMainLayout->addWidget(m_pLabel);
    54     pMainLayout->addWidget(m_pLocationCnt);
    55     pMainLayout->addStretch();
    56 
    57     /* Setup page connections: */
    58     connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltLocationEditorTextChanged(const QString &)));
    59     connect(m_pLocationSelector, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked()));
    60 
    61     /* Register 'mediumPath', 'mediumSize' fields: */
    62     registerField("mediumPath", this, "mediumPath");
    63     registerField("mediumSize", this, "mediumSize");
    64 }
    65 
    66 void UIWizardCloneVDPageBasic4::sltLocationEditorTextChanged(const QString &strMediumName)
    67 {
    68     /* Compose new medium path: */
    69     m_strMediumPath = absoluteFilePath(toFileName(strMediumName, m_strDefaultExtension), m_strDefaultPath);
    70     /* Notify wizard sub-system about complete status changed: */
    71     emit completeChanged();
    72 }
    73 
    74 void UIWizardCloneVDPageBasic4::sltSelectLocationButtonClicked()
     37
     38UIWizardCloneVDPage4::UIWizardCloneVDPage4()
     39{
     40}
     41
     42void UIWizardCloneVDPage4::onSelectLocationButtonClicked()
    7543{
    7644    /* Get current folder and filename: */
    77     QFileInfo fullFilePath(m_strMediumPath);
     45    QFileInfo fullFilePath(mediumPath());
    7846    QDir folder = fullFilePath.path();
    7947    QString strFileName = fullFilePath.fileName();
     
    9765
    9866    /* Prepare backends list: */
    99     CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
    10067    QVector<QString> fileExtensions;
    10168    QVector<KDeviceType> deviceTypes;
     69    CMediumFormat mediumFormat = fieldImp("mediumFormat").value<CMediumFormat>();
    10270    mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    10371    QStringList validExtensionList;
     
    11078    /* Open corresponding file-dialog: */
    11179    QString strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName),
    112                                                               strBackendsList, this,
    113                                                               UIWizardCloneVD::tr("Select a file for the new hard disk image file"));
     80                                                              strBackendsList, thisImp(),
     81                                                              VBoxGlobal::tr("Choose a virtual hard disk file"));
    11482
    11583    /* If there was something really chosen: */
     
    11987        if (QFileInfo(strChosenFilePath).suffix().isEmpty())
    12088            strChosenFilePath += QString(".%1").arg(m_strDefaultExtension);
    121         m_pLocationEditor->setText(QDir::toNativeSeparators(strChosenFilePath));
    122         m_pLocationEditor->selectAll();
    123         m_pLocationEditor->setFocus();
    124     }
    125 }
    126 
    127 void UIWizardCloneVDPageBasic4::retranslateUi()
    128 {
    129     /* Translate page: */
    130     setTitle(UIWizardCloneVD::tr("Virtual disk file location"));
    131 
    132     /* Translate widgets: */
    133     m_pLabel->setText(UIWizardCloneVD::tr("Please type the name of the new virtual disk file into the box below or "
    134                                           "click on the folder icon to select a different folder to create the file in."));
    135     m_pLocationCnt->setTitle(UIWizardCloneVD::tr("&Location"));
    136 }
    137 
    138 void UIWizardCloneVDPageBasic4::initializePage()
    139 {
    140     /* Translate page: */
    141     retranslateUi();
    142 
    143     /* Get source virtual-disk: */
    144     const CMedium &sourceVirtualDisk = field("sourceVirtualDisk").value<CMedium>();
    145     /* Get default path: */
    146     m_strDefaultPath = QFileInfo(sourceVirtualDisk.GetLocation()).absolutePath();
    147     /* Get default name: */
    148     QString strMediumName = UIWizardCloneVD::tr("%1_copy", "copied virtual disk name")
    149                                                .arg(QFileInfo(sourceVirtualDisk.GetLocation()).baseName());
    150     /* Get virtual-disk size: */
    151     m_uMediumSize = sourceVirtualDisk.GetLogicalSize();
    152     /* Get virtual-disk extension: */
    153     m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>());
    154     /* Compose path for cloned virtual-disk: */
    155     m_strMediumPath = absoluteFilePath(toFileName(strMediumName, m_strDefaultExtension), m_strDefaultPath);
    156     /* Set text to location editor: */
    157     m_pLocationEditor->setText(strMediumName);
    158 }
    159 
    160 bool UIWizardCloneVDPageBasic4::isComplete() const
    161 {
    162     /* Check what current name is not empty! */
    163     return !m_pLocationEditor->text().trimmed().isEmpty();
    164 }
    165 
    166 bool UIWizardCloneVDPageBasic4::validatePage()
    167 {
    168     if (QFileInfo(m_strMediumPath).exists())
    169     {
    170         msgCenter().sayCannotOverwriteHardDiskStorage(this, m_strMediumPath);
    171         return false;
    172     }
    173     return true;
     89        m_pDestinationDiskEditor->setText(QDir::toNativeSeparators(strChosenFilePath));
     90        m_pDestinationDiskEditor->selectAll();
     91        m_pDestinationDiskEditor->setFocus();
     92    }
    17493}
    17594
    17695/* static */
    177 QString UIWizardCloneVDPageBasic4::toFileName(const QString &strName, const QString &strExtension)
     96QString UIWizardCloneVDPage4::toFileName(const QString &strName, const QString &strExtension)
    17897{
    17998    /* Convert passed name to native separators (it can be full, actually): */
     
    194113
    195114/* static */
    196 QString UIWizardCloneVDPageBasic4::absoluteFilePath(const QString &strFileName, const QString &strDefaultPath)
     115QString UIWizardCloneVDPage4::absoluteFilePath(const QString &strFileName, const QString &strDefaultPath)
    197116{
    198117    /* Wrap file-info around received file name: */
     
    209128
    210129/* static */
    211 QString UIWizardCloneVDPageBasic4::defaultExtension(const CMediumFormat &mediumFormatRef)
     130QString UIWizardCloneVDPage4::defaultExtension(const CMediumFormat &mediumFormatRef)
    212131{
    213132    /* Load extension / device list: */
     
    223142}
    224143
     144QString UIWizardCloneVDPage4::mediumPath() const
     145{
     146    return absoluteFilePath(toFileName(m_pDestinationDiskEditor->text(), m_strDefaultExtension), m_strDefaultPath);
     147}
     148
     149qulonglong UIWizardCloneVDPage4::mediumSize() const
     150{
     151    const CMedium &sourceVirtualDisk = fieldImp("sourceVirtualDisk").value<CMedium>();
     152    return sourceVirtualDisk.isNull() ? 0 : sourceVirtualDisk.GetLogicalSize();
     153}
     154
     155UIWizardCloneVDPageBasic4::UIWizardCloneVDPageBasic4()
     156{
     157    /* Create widgets: */
     158    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     159    {
     160        m_pLabel = new QIRichTextLabel(this);
     161        m_pDestinationCnt = new QGroupBox(this);
     162        {
     163            m_pDestinationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     164            QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pDestinationCnt);
     165            {
     166                m_pDestinationDiskEditor = new QLineEdit(m_pDestinationCnt);
     167                m_pDestinationDiskOpenButton = new QIToolButton(m_pDestinationCnt);
     168                {
     169                    m_pDestinationDiskOpenButton->setAutoRaise(true);
     170                    m_pDestinationDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png"));
     171                }
     172                pLocationCntLayout->addWidget(m_pDestinationDiskEditor);
     173                pLocationCntLayout->addWidget(m_pDestinationDiskOpenButton);
     174            }
     175        }
     176        pMainLayout->addWidget(m_pLabel);
     177        pMainLayout->addWidget(m_pDestinationCnt);
     178        pMainLayout->addStretch();
     179    }
     180
     181    /* Setup page connections: */
     182    connect(m_pDestinationDiskEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
     183    connect(m_pDestinationDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked()));
     184
     185    /* Register fields: */
     186    registerField("mediumPath", this, "mediumPath");
     187    registerField("mediumSize", this, "mediumSize");
     188}
     189
     190void UIWizardCloneVDPageBasic4::sltSelectLocationButtonClicked()
     191{
     192    /* Call to base-class: */
     193    onSelectLocationButtonClicked();
     194}
     195
     196void UIWizardCloneVDPageBasic4::retranslateUi()
     197{
     198    /* Translate page: */
     199    setTitle(UIWizardCloneVD::tr("Virtual disk file location"));
     200
     201    /* Translate widgets: */
     202    m_pLabel->setText(UIWizardCloneVD::tr("Please type the name of the new virtual disk file into the box below or "
     203                                          "click on the folder icon to select a different folder to create the file in."));
     204    m_pDestinationCnt->setTitle(UIWizardCloneVD::tr("&Location"));
     205    m_pDestinationDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file..."));
     206}
     207
     208void UIWizardCloneVDPageBasic4::initializePage()
     209{
     210    /* Translate page: */
     211    retranslateUi();
     212
     213    /* Get source virtual-disk file-information: */
     214    QFileInfo sourceFileInfo(field("sourceVirtualDisk").value<CMedium>().GetLocation());
     215    /* Get default path for virtual-disk copy: */
     216    m_strDefaultPath = sourceFileInfo.absolutePath();
     217    /* Get default extension for virtual-disk copy: */
     218    m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>());
     219    /* Compose default-name for virtual-disk copy: */
     220    QString strMediumName = UIWizardCloneVD::tr("%1_copy", "copied virtual disk name").arg(sourceFileInfo.baseName());
     221    /* Set default-name as text for location editor: */
     222    m_pDestinationDiskEditor->setText(strMediumName);
     223}
     224
     225bool UIWizardCloneVDPageBasic4::isComplete() const
     226{
     227    /* Make sure current name is not empty: */
     228    return !m_pDestinationDiskEditor->text().trimmed().isEmpty();
     229}
     230
     231bool UIWizardCloneVDPageBasic4::validatePage()
     232{
     233    /* Make sure such virtual-disk doesn't exists already: */
     234    QString strMediumPath(mediumPath());
     235    if (QFileInfo(strMediumPath).exists())
     236    {
     237        msgCenter().sayCannotOverwriteHardDiskStorage(this, strMediumPath);
     238        return false;
     239    }
     240    return true;
     241}
     242
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic4.h

    r40870 r41021  
    2020#define __UIWizardCloneVDPageBasic4_h__
    2121
     22/* Global includes: */
     23#include <QVariant>
     24
    2225/* Local includes: */
    2326#include "UIWizardPage.h"
     
    2528
    2629/* Forward declarations: */
    27 class QIRichTextLabel;
     30class CMediumFormat;
    2831class QGroupBox;
    2932class QLineEdit;
    3033class QIToolButton;
    31 class CMediumFormat;
     34class QIRichTextLabel;
    3235
    33 /* 4th page of the Clone Virtual Disk wizard: */
    34 class UIWizardCloneVDPageBasic4 : public UIWizardPage
     36/* 4th page of the Clone Virtual Disk wizard (base part): */
     37class UIWizardCloneVDPage4 : public UIWizardPageBase
     38{
     39protected:
     40
     41    /* Constructor: */
     42    UIWizardCloneVDPage4();
     43
     44    /* Handlers: */
     45    void onSelectLocationButtonClicked();
     46
     47    /* Location-editors stuff: */
     48    static QString toFileName(const QString &strName, const QString &strExtension);
     49    static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath);
     50    static QString defaultExtension(const CMediumFormat &mediumFormatRef);
     51
     52    /* Stuff for 'mediumPath' field: */
     53    QString mediumPath() const;
     54
     55    /* Stuff for 'mediumSize' field: */
     56    qulonglong mediumSize() const;
     57
     58    /* Variables: */
     59    QString m_strDefaultPath;
     60    QString m_strDefaultExtension;
     61
     62    /* Widgets: */
     63    QGroupBox *m_pDestinationCnt;
     64    QLineEdit *m_pDestinationDiskEditor;
     65    QIToolButton *m_pDestinationDiskOpenButton;
     66};
     67
     68/* 4th page of the Clone Virtual Disk wizard (basic extension): */
     69class UIWizardCloneVDPageBasic4 : public UIWizardPage, public UIWizardCloneVDPage4
    3570{
    3671    Q_OBJECT;
    37     Q_PROPERTY(QString mediumPath READ mediumPath WRITE setMediumPath);
    38     Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize);
     72    Q_PROPERTY(QString mediumPath READ mediumPath);
     73    Q_PROPERTY(qulonglong mediumSize READ mediumSize);
    3974
    4075public:
     
    4378    UIWizardCloneVDPageBasic4();
    4479
     80protected:
     81
     82    /* Wrapper to access 'this' from base part: */
     83    UIWizardPage* thisImp() { return this; }
     84    /* Wrapper to access 'wizard-field' from base part: */
     85    QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
     86
    4587private slots:
    4688
    47     /* Location editors stuff: */
    48     void sltLocationEditorTextChanged(const QString &strMediumName);
     89    /* Location editor stuff: */
    4990    void sltSelectLocationButtonClicked();
    5091
     
    61102    bool validatePage();
    62103
    63     /* Location-editors stuff: */
    64     static QString toFileName(const QString &strName, const QString &strExtension);
    65     static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath);
    66     static QString defaultExtension(const CMediumFormat &mediumFormatRef);
    67 
    68     /* Stuff for 'mediumPath' field: */
    69     QString mediumPath() const { return m_strMediumPath; }
    70     void setMediumPath(const QString &strMediumPath) { m_strMediumPath = strMediumPath; }
    71     QString m_strMediumPath;
    72 
    73     /* Stuff for 'mediumSize' field: */
    74     qulonglong mediumSize() const { return m_uMediumSize; }
    75     void setMediumSize(qulonglong uMediumSize) { m_uMediumSize = uMediumSize; }
    76     qulonglong m_uMediumSize;
    77 
    78     /* Location-editors variables: */
    79     QString m_strDefaultPath;
    80     QString m_strDefaultExtension;
    81 
    82104    /* Widgets: */
    83105    QIRichTextLabel *m_pLabel;
    84     QGroupBox *m_pLocationCnt;
    85     QLineEdit *m_pLocationEditor;
    86     QIToolButton *m_pLocationSelector;
    87106};
    88107
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic5.cpp

    r40870 r41021  
    2424#include "QIRichTextLabel.h"
    2525
     26UIWizardCloneVDPage5::UIWizardCloneVDPage5()
     27{
     28}
     29
    2630UIWizardCloneVDPageBasic5::UIWizardCloneVDPageBasic5()
    2731{
    2832    /* Create widgets: */
    2933    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     34    {
    3035        m_pLabel1 = new QIRichTextLabel(this);
    3136        m_pSummaryText = new QIRichTextLabel(this);
    3237        m_pLabel2 = new QIRichTextLabel(this);
    33     pMainLayout->addWidget(m_pLabel1);
    34     pMainLayout->addWidget(m_pSummaryText);
    35     pMainLayout->addWidget(m_pLabel2);
    36     pMainLayout->addStretch();
     38        pMainLayout->addWidget(m_pLabel1);
     39        pMainLayout->addWidget(m_pSummaryText);
     40        pMainLayout->addWidget(m_pLabel2);
     41        pMainLayout->addStretch();
     42    }
    3743}
    3844
     
    8187bool UIWizardCloneVDPageBasic5::validatePage()
    8288{
     89    /* Initial result: */
     90    bool fResult = true;
     91
     92    /* Lock finish button: */
     93    startProcessing();
     94
    8395    /* Try to copy virtual-disk: */
    84     startProcessing();
    85     bool fResult = qobject_cast<UIWizardCloneVD*>(wizard())->copyVirtualDisk();
     96    if (fResult)
     97        fResult = qobject_cast<UIWizardCloneVD*>(wizard())->copyVirtualDisk();
     98
     99    /* Unlock finish button: */
    86100    endProcessing();
     101
     102    /* Return result: */
    87103    return fResult;
    88104}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic5.h

    r40870 r41021  
    2727class QIRichTextLabel;
    2828
    29 /* 5th page of the Clone Virtual Disk wizard: */
    30 class UIWizardCloneVDPageBasic5 : public UIWizardPage
     29/* 5th page of the Clone Virtual Disk wizard (base part): */
     30class UIWizardCloneVDPage5 : public UIWizardPageBase
     31{
     32protected:
     33
     34    /* Constructor: */
     35    UIWizardCloneVDPage5();
     36};
     37
     38/* 5th page of the Clone Virtual Disk wizard (basic extension): */
     39class UIWizardCloneVDPageBasic5 : public UIWizardPage, public UIWizardCloneVDPage5
    3140{
    3241    Q_OBJECT;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageExpert.cpp

    r40929 r41021  
    33 *
    44 * VBox frontends: Qt4 GUI ("VirtualBox"):
    5  * UIWizardCloneVDPageBasic1 class implementation
     5 * UIWizardCloneVDPageExpert class implementation
    66 */
    77
     
    1919
    2020/* Global includes: */
     21#include <QGridLayout>
    2122#include <QVBoxLayout>
    2223#include <QHBoxLayout>
     24#include <QButtonGroup>
    2325#include <QGroupBox>
     26#include <QRadioButton>
     27#include <QCheckBox>
     28#include <QLineEdit>
    2429
    2530/* Local includes: */
    26 #include "UIWizardCloneVDPageBasic1.h"
     31#include "UIWizardCloneVDPageExpert.h"
    2732#include "UIWizardCloneVD.h"
     33#include "UIMessageCenter.h"
    2834#include "UIIconPool.h"
    29 #include "QIRichTextLabel.h"
    3035#include "VBoxMediaComboBox.h"
    3136#include "QIToolButton.h"
    3237
    33 UIWizardCloneVDPageBasic1::UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk)
     38UIWizardCloneVDPageExpert::UIWizardCloneVDPageExpert(const CMedium &sourceVirtualDisk)
    3439{
    3540    /* Create widgets: */
    36     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    37         m_pLabel = new QIRichTextLabel(this);
    38         m_pSourceDiskContainer = new QGroupBox(this);
    39             m_pSourceDiskContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    40             QHBoxLayout *pSourceDiskLayout = new QHBoxLayout(m_pSourceDiskContainer);
    41                 m_pSourceDiskSelector = new VBoxMediaComboBox(m_pSourceDiskContainer);
     41    QGridLayout *pMainLayout = new QGridLayout(this);
     42    {
     43        pMainLayout->setContentsMargins(8, 6, 8, 6);
     44        m_pSourceDiskCnt = new QGroupBox(this);
     45        {
     46            m_pSourceDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     47            QHBoxLayout *pSourceDiskCntLayout = new QHBoxLayout(m_pSourceDiskCnt);
     48            {
     49                m_pSourceDiskSelector = new VBoxMediaComboBox(m_pSourceDiskCnt);
     50                {
    4251                    m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
    4352                    m_pSourceDiskSelector->setType(VBoxDefs::MediumType_HardDisk);
    4453                    m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());
    4554                    m_pSourceDiskSelector->repopulate();
    46                 m_pOpenSourceDiskButton = new QIToolButton(m_pSourceDiskContainer);
    47                     m_pOpenSourceDiskButton->setAutoRaise(true);
    48                     m_pOpenSourceDiskButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png"));
    49             pSourceDiskLayout->addWidget(m_pSourceDiskSelector);
    50             pSourceDiskLayout->addWidget(m_pOpenSourceDiskButton);
    51     pMainLayout->addWidget(m_pLabel);
    52     pMainLayout->addWidget(m_pSourceDiskContainer);
    53     pMainLayout->addStretch();
     55                }
     56                m_pSourceDiskOpenButton = new QIToolButton(m_pSourceDiskCnt);
     57                {
     58                    m_pSourceDiskOpenButton->setAutoRaise(true);
     59                    m_pSourceDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png"));
     60                }
     61                pSourceDiskCntLayout->addWidget(m_pSourceDiskSelector);
     62                pSourceDiskCntLayout->addWidget(m_pSourceDiskOpenButton);
     63            }
     64        }
     65        m_pDestinationCnt = new QGroupBox(this);
     66        {
     67            m_pDestinationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     68            QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pDestinationCnt);
     69            {
     70                m_pDestinationDiskEditor = new QLineEdit(m_pDestinationCnt);
     71                m_pDestinationDiskOpenButton = new QIToolButton(m_pDestinationCnt);
     72                {
     73                    m_pDestinationDiskOpenButton->setAutoRaise(true);
     74                    m_pDestinationDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png"));
     75                }
     76            }
     77            pLocationCntLayout->addWidget(m_pDestinationDiskEditor);
     78            pLocationCntLayout->addWidget(m_pDestinationDiskOpenButton);
     79        }
     80        QVBoxLayout *pFormatWrappingLayout = new QVBoxLayout;
     81        {
     82            m_pFormatCnt = new QGroupBox(this);
     83            {
     84                m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     85                QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatCnt);
     86                {
     87                    m_pFormatButtonGroup = new QButtonGroup(this);
     88                    {
     89                        CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
     90                        const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
     91                        for (int i = 0; i < medFormats.size(); ++i)
     92                        {
     93                            const CMediumFormat &medFormat = medFormats[i];
     94                            QString strFormatName(medFormat.GetName());
     95                            if (strFormatName == "VDI")
     96                            {
     97                                QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
     98                                if (pButton)
     99                                {
     100                                    m_formats << medFormat;
     101                                    m_formatNames << strFormatName;
     102                                    m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     103                                }
     104                            }
     105                        }
     106                        for (int i = 0; i < medFormats.size(); ++i)
     107                        {
     108                            const CMediumFormat &medFormat = medFormats[i];
     109                            QString strFormatName(medFormat.GetName());
     110                            if (strFormatName != "VDI")
     111                            {
     112                                QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
     113                                if (pButton)
     114                                {
     115                                    m_formats << medFormat;
     116                                    m_formatNames << strFormatName;
     117                                    m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     118                                }
     119                            }
     120                        }
     121                        m_pFormatButtonGroup->button(0)->click();
     122                        m_pFormatButtonGroup->button(0)->setFocus();
     123                    }
     124                }
     125            }
     126            QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
     127            pFormatWrappingLayout->addWidget(m_pFormatCnt);
     128            pFormatWrappingLayout->addItem(m_pSizeSpacer);
     129        }
     130        QVBoxLayout *pVariantWrappingLayout = new QVBoxLayout;
     131        {
     132            m_pVariantCnt = new QGroupBox(this);
     133            {
     134                m_pVariantCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     135                QVBoxLayout *pVariantCntLayout = new QVBoxLayout(m_pVariantCnt);
     136                {
     137                    m_pVariantButtonGroup = new QButtonGroup(m_pVariantCnt);
     138                    {
     139                        m_pDynamicalButton = new QRadioButton(m_pVariantCnt);
     140                        {
     141                            m_pDynamicalButton->click();
     142                            m_pDynamicalButton->setFocus();
     143                        }
     144                        m_pFixedButton = new QRadioButton(m_pVariantCnt);
     145                        m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
     146                        m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
     147                    }
     148                    m_pSplitBox = new QCheckBox(m_pVariantCnt);
     149                    pVariantCntLayout->addWidget(m_pDynamicalButton);
     150                    pVariantCntLayout->addWidget(m_pFixedButton);
     151                    pVariantCntLayout->addWidget(m_pSplitBox);
     152                }
     153            }
     154            QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
     155            pVariantWrappingLayout->addWidget(m_pVariantCnt);
     156            pVariantWrappingLayout->addItem(m_pSizeSpacer);
     157        }
     158        pMainLayout->addWidget(m_pSourceDiskCnt, 0, 0, 1, 2);
     159        pMainLayout->addWidget(m_pDestinationCnt, 1, 0, 1, 2);
     160        pMainLayout->addLayout(pFormatWrappingLayout, 2, 0);
     161        pMainLayout->addLayout(pVariantWrappingLayout, 2, 1);
     162        sltHandleSourceDiskChange();
     163        sltMediumFormatChanged();
     164    }
    54165
    55166    /* Setup connections: */
    56     connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged()));
    57     connect(m_pOpenSourceDiskButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick()));
    58 
    59     /* Register CMedium class: */
     167    connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(sltHandleSourceDiskChange()));
     168    connect(m_pSourceDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick()));
     169    connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(sltMediumFormatChanged()));
     170    connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged()));
     171    connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged()));
     172    connect(m_pDestinationDiskEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
     173    connect(m_pDestinationDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked()));
     174
     175    /* Register classes: */
    60176    qRegisterMetaType<CMedium>();
    61     /* Register 'sourceVirtualDisk' field: */
     177    qRegisterMetaType<CMediumFormat>();
     178    /* Register fields: */
    62179    registerField("sourceVirtualDisk", this, "sourceVirtualDisk");
    63 }
    64 
    65 void UIWizardCloneVDPageBasic1::sltHandleOpenSourceDiskClick()
    66 {
    67     /* Get source virtual-disk using file-open dialog: */
    68     QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, this);
    69     if (!strMediumId.isNull())
     180    registerField("mediumFormat", this, "mediumFormat");
     181    registerField("mediumVariant", this, "mediumVariant");
     182    registerField("mediumPath", this, "mediumPath");
     183    registerField("mediumSize", this, "mediumSize");
     184}
     185
     186void UIWizardCloneVDPageExpert::sltHandleSourceDiskChange()
     187{
     188    /* Get source virtual-disk file-information: */
     189    QFileInfo sourceFileInfo(sourceVirtualDisk().GetLocation());
     190    /* Get default path for virtual-disk copy: */
     191    m_strDefaultPath = sourceFileInfo.absolutePath();
     192    /* Compose name for virtual-disk copy: */
     193    QString strMediumName = UIWizardCloneVD::tr("%1_copy", "copied virtual disk name").arg(sourceFileInfo.baseName());
     194    /* Set text to location editor: */
     195    m_pDestinationDiskEditor->setText(strMediumName);
     196
     197    /* Broadcast complete-change: */
     198    emit completeChanged();
     199}
     200
     201void UIWizardCloneVDPageExpert::sltHandleOpenSourceDiskClick()
     202{
     203    /* Call to base-class: */
     204    onHandleOpenSourceDiskClick();
     205}
     206
     207void UIWizardCloneVDPageExpert::sltMediumFormatChanged()
     208{
     209    /* Get medium format: */
     210    CMediumFormat mf = mediumFormat();
     211
     212    /* Enable/disable widgets: */
     213    ULONG uCapabilities = mf.GetCapabilities();
     214    bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic;
     215    bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed;
     216    bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G;
     217    m_pDynamicalButton->setEnabled(fIsCreateDynamicPossible);
     218    m_pFixedButton->setEnabled(fIsCreateFixedPossible);
     219    m_pSplitBox->setEnabled(fIsCreateSplitPossible);
     220
     221    /* Compose virtual-disk extension: */
     222    m_strDefaultExtension = defaultExtension(mf);
     223
     224    /* Broadcast complete-change: */
     225    emit completeChanged();
     226}
     227
     228void UIWizardCloneVDPageExpert::sltSelectLocationButtonClicked()
     229{
     230    /* Call to base-class: */
     231    onSelectLocationButtonClicked();
     232}
     233
     234void UIWizardCloneVDPageExpert::retranslateUi()
     235{
     236    /* Translate widgets: */
     237    m_pSourceDiskCnt->setTitle(UIWizardCloneVD::tr("&Source virtual disk"));
     238    m_pSourceDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file..."));
     239    m_pDestinationCnt->setTitle(UIWizardCloneVD::tr("&Destination virtual disk"));
     240    m_pDestinationDiskOpenButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file..."));
     241    m_pFormatCnt->setTitle(UIWizardCloneVD::tr("File type"));
     242    QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons();
     243    for (int i = 0; i < buttons.size(); ++i)
    70244    {
    71         /* Update medium-combo if necessary: */
    72         m_pSourceDiskSelector->setCurrentItem(strMediumId);
    73         /* Focus on virtual-disk combo: */
    74         m_pSourceDiskSelector->setFocus();
     245        QAbstractButton *pButton = buttons[i];
     246        pButton->setText(UIWizardCloneVD::fullFormatName(m_formatNames[m_pFormatButtonGroup->id(pButton)]));
    75247    }
    76 }
    77 
    78 void UIWizardCloneVDPageBasic1::retranslateUi()
    79 {
    80     /* Translate page: */
    81     setTitle(UIWizardCloneVD::tr("Welcome to the virtual disk copying wizard"));
    82 
    83     /* Translate widgets: */
    84     m_pSourceDiskContainer->setTitle(UIWizardCloneVD::tr("Virtual disk to copy"));
    85     m_pOpenSourceDiskButton->setToolTip(UIWizardCloneVD::tr("Choose a virtual hard disk file..."));
    86     m_pLabel->setText(UIWizardCloneVD::tr("<p>This wizard will help you to copy a virtual disk.</p>"));
    87     m_pLabel->setText(m_pLabel->text() + QString("<p>%1</p>").arg(standardHelpText()));
    88     m_pLabel->setText(m_pLabel->text() + UIWizardCloneVD::tr("Please select the virtual disk which you would like "
    89                                                              "to copy if it is not already selected. You can either "
    90                                                              "choose one from the list or use the folder icon "
    91                                                              "beside the list to select a virtual disk file."));
    92 }
    93 
    94 void UIWizardCloneVDPageBasic1::initializePage()
     248    m_pVariantCnt->setTitle(UIWizardCloneVD::tr("Storage details"));
     249    m_pDynamicalButton->setText(UIWizardCloneVD::tr("&Dynamically allocated"));
     250    m_pFixedButton->setText(UIWizardCloneVD::tr("&Fixed size"));
     251    m_pSplitBox->setText(UIWizardCloneVD::tr("&Split into files of less than 2GB"));
     252}
     253
     254void UIWizardCloneVDPageExpert::initializePage()
    95255{
    96256    /* Translate page: */
     
    98258}
    99259
    100 bool UIWizardCloneVDPageBasic1::isComplete() const
    101 {
    102     /* Check what source virtual-disk feats the rules: */
    103     return !sourceVirtualDisk().isNull();
    104 }
    105 
    106 CMedium UIWizardCloneVDPageBasic1::sourceVirtualDisk() const
    107 {
    108     return vboxGlobal().findMedium(m_pSourceDiskSelector->id()).medium();
    109 }
    110 
    111 void UIWizardCloneVDPageBasic1::setSourceVirtualDisk(const CMedium &sourceVirtualDisk)
    112 {
    113     m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());
    114 }
    115 
     260bool UIWizardCloneVDPageExpert::isComplete() const
     261{
     262    /* Check what source virtual-disk feats the rules,
     263     * medium format/variant is correct,
     264     * current name is not empty: */
     265    return !sourceVirtualDisk().isNull() &&
     266           !mediumFormat().isNull() &&
     267           mediumVariant() != (qulonglong)KMediumVariant_Max &&
     268           !m_pDestinationDiskEditor->text().trimmed().isEmpty();
     269}
     270
     271bool UIWizardCloneVDPageExpert::validatePage()
     272{
     273    /* Initial result: */
     274    bool fResult = true;
     275
     276    /* Lock finish button: */
     277    startProcessing();
     278
     279    /* Make sure such virtual-disk doesn't exists already: */
     280    QString strMediumPath(mediumPath());
     281    if (fResult && QFileInfo(strMediumPath).exists())
     282    {
     283        msgCenter().sayCannotOverwriteHardDiskStorage(this, strMediumPath);
     284        fResult = false;
     285    }
     286
     287    /* Try to copy virtual-disk: */
     288    if (fResult)
     289        fResult = qobject_cast<UIWizardCloneVD*>(wizard())->copyVirtualDisk();
     290
     291    /* Unlock finish button: */
     292    endProcessing();
     293
     294    /* Return result: */
     295    return fResult;
     296}
     297
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageExpert.h

    r40929 r41021  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * UIWizardCloneVDPageBasic1 class declaration
     4 * UIWizardCloneVDPageExpert class declaration
    55 */
    66
     
    1717 */
    1818
    19 #ifndef __UIWizardCloneVDPageBasic1_h__
    20 #define __UIWizardCloneVDPageBasic1_h__
     19#ifndef __UIWizardCloneVDPageExpert_h__
     20#define __UIWizardCloneVDPageExpert_h__
    2121
    2222/* Local includes: */
    23 #include "UIWizardPage.h"
    24 #include "COMDefs.h"
     23#include "UIWizardCloneVDPageBasic1.h"
     24#include "UIWizardCloneVDPageBasic2.h"
     25#include "UIWizardCloneVDPageBasic3.h"
     26#include "UIWizardCloneVDPageBasic4.h"
     27#include "UIWizardCloneVDPageBasic5.h"
    2528
    26 /* Forward declarations: */
    27 class QIRichTextLabel;
    28 class QGroupBox;
    29 class VBoxMediaComboBox;
    30 class QIToolButton;
    31 
    32 /* 1st page of the Clone Virtual Disk wizard: */
    33 class UIWizardCloneVDPageBasic1 : public UIWizardPage
     29/* Expert page of the Clone Virtual Disk wizard: */
     30class UIWizardCloneVDPageExpert : public UIWizardPage,
     31                                  public UIWizardCloneVDPage1,
     32                                  public UIWizardCloneVDPage2,
     33                                  public UIWizardCloneVDPage3,
     34                                  public UIWizardCloneVDPage4,
     35                                  public UIWizardCloneVDPage5
    3436{
    3537    Q_OBJECT;
    3638    Q_PROPERTY(CMedium sourceVirtualDisk READ sourceVirtualDisk WRITE setSourceVirtualDisk);
     39    Q_PROPERTY(CMediumFormat mediumFormat READ mediumFormat WRITE setMediumFormat);
     40    Q_PROPERTY(qulonglong mediumVariant READ mediumVariant WRITE setMediumVariant);
     41    Q_PROPERTY(QString mediumPath READ mediumPath);
     42    Q_PROPERTY(qulonglong mediumSize READ mediumSize);
    3743
    3844public:
    3945
    4046    /* Constructor: */
    41     UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk);
     47    UIWizardCloneVDPageExpert(const CMedium &sourceVirtualDisk);
     48
     49protected:
     50
     51    /* Wrapper to access 'this' from base part: */
     52    UIWizardPage* thisImp() { return this; }
     53    /* Wrapper to access 'wizard-field' from base part: */
     54    QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
    4255
    4356private slots:
    4457
    45     /* Handlers for source virtual-disk change: */
     58    /* Source virtual-disk stuff: */
     59    void sltHandleSourceDiskChange();
    4660    void sltHandleOpenSourceDiskClick();
     61
     62    /* Medium format stuff: */
     63    void sltMediumFormatChanged();
     64
     65    /* Location editor stuff: */
     66    void sltSelectLocationButtonClicked();
    4767
    4868private:
     
    5676    /* Validation stuff: */
    5777    bool isComplete() const;
    58 
    59     /* Stuff for 'sourceVirtualDisk' field: */
    60     CMedium sourceVirtualDisk() const;
    61     void setSourceVirtualDisk(const CMedium &sourceVirtualDisk);
    62 
    63     /* Widgets: */
    64     QIRichTextLabel *m_pLabel;
    65     QGroupBox *m_pSourceDiskContainer;
    66     VBoxMediaComboBox *m_pSourceDiskSelector;
    67     QIToolButton *m_pOpenSourceDiskButton;
     78    bool validatePage();
    6879};
    6980
    70 #endif // __UIWizardCloneVDPageBasic1_h__
     81#endif // __UIWizardCloneVDPageExpert_h__
    7182
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.cpp

    r40870 r41021  
    2323#include "UIWizardCloneVMPageBasic2.h"
    2424#include "UIWizardCloneVMPageBasic3.h"
     25#include "UIWizardCloneVMPageExpert.h"
    2526#include "VBoxGlobal.h"
    2627#include "UIMessageCenter.h"
    2728
    2829UIWizardCloneVM::UIWizardCloneVM(QWidget *pParent, const CMachine &machine, CSnapshot snapshot /* = CSnapshot() */)
    29     : UIWizard(pParent)
     30    : UIWizard(pParent, UIWizardType_CloneVM)
    3031    , m_machine(machine)
    3132    , m_snapshot(snapshot)
    3233{
    33 #ifdef Q_WS_WIN
    34     /* Hide window icon: */
    35     setWindowIcon(QIcon());
    36 #endif /* Q_WS_WIN */
    37 
    38     /* Create & add pages: */
    39     setPage(Page1, new UIWizardCloneVMPageBasic1(m_machine.GetName()));
    40     /* If we are having a snapshot we can show the "Linked" option. */
    41     setPage(Page2, new UIWizardCloneVMPageBasic2(snapshot.isNull()));
    42     /* If the machine has no snapshots, we don't bother the user about options for it. */
    43     if (m_machine.GetSnapshotCount() > 0)
    44         setPage(Page3, new UIWizardCloneVMPageBasic3(snapshot.isNull() ? false : snapshot.GetChildrenCount() > 0));
    45 
    46     /* Translate wizard: */
    47     retranslateUi();
    48 
    49     /* Translate wizard pages: */
    50     retranslateAllPages();
    51 
    5234#ifndef Q_WS_MAC
    5335    /* Assign watermark: */
     
    5840    assignBackground(":/vmw_clone_bg.png");
    5941#endif /* Q_WS_MAC */
    60 
    61     /* Resize wizard to 'golden ratio': */
    62     resizeToGoldenRatio(UIWizardType_CloneVM);
    63 }
    64 
    65 void UIWizardCloneVM::retranslateUi()
    66 {
    67     /* Translate wizard: */
    68     setWindowTitle(tr("Clone Virtual Machine"));
    69     setButtonText(QWizard::FinishButton, tr("Clone"));
    7042}
    7143
     
    7951    bool fLinked = field("linkedClone").toBool();
    8052    /* Get clone mode: */
    81     KCloneMode mode = page(Page3) ? field("cloneMode").value<KCloneMode>() : KCloneMode_MachineState;
     53    KCloneMode cloneMode = (mode() == UIWizardMode_Basic && page(Page3)) ||
     54                           (mode() == UIWizardMode_Expert && page(PageExpert)) ?
     55                           field("cloneMode").value<KCloneMode>() : KCloneMode_MachineState;
    8256
     57    /* Get VBox object: */
    8358    CVirtualBox vbox = vboxGlobal().virtualBox();
    84     const QString &strSettingsFile = vbox.ComposeMachineFilename(strName, QString::null);
    8559
     60    /* Prepare machine for cloning: */
    8661    CMachine srcMachine = m_machine;
     62
    8763    /* If the user like to create a linked clone from the current machine, we
    8864     * have to take a little bit more action. First we create an snapshot, so
     
    9167    if (fLinked && m_snapshot.isNull())
    9268    {
    93         const QString &strId = m_machine.GetId();
    94         CSession session = vboxGlobal().openSession(strId);
     69        /* Open session: */
     70        CSession session = vboxGlobal().openSession(m_machine.GetId());
    9571        if (session.isNull())
    9672            return false;
     73
     74        /* Prepare console: */
    9775        CConsole console = session.GetConsole();
    9876
     
    132110
    133111    /* Create a new machine object. */
     112    const QString &strSettingsFile = vbox.ComposeMachineFilename(strName, QString::null);
    134113    CMachine cloneMachine = vbox.CreateMachine(strSettingsFile, strName, QString::null, QString::null, false);
    135114    if (!vbox.isOk())
     
    148127
    149128    /* Start cloning. */
    150     CProgress progress = srcMachine.CloneTo(cloneMachine, mode, options);
     129    CProgress progress = srcMachine.CloneTo(cloneMachine, cloneMode, options);
    151130    if (!srcMachine.isOk())
    152131    {
     
    176155}
    177156
     157void UIWizardCloneVM::retranslateUi()
     158{
     159    /* Call to base-class: */
     160    UIWizard::retranslateUi();
     161
     162    /* Translate wizard: */
     163    setWindowTitle(tr("Clone Virtual Machine"));
     164    setButtonText(QWizard::FinishButton, tr("Clone"));
     165}
     166
     167void UIWizardCloneVM::prepare()
     168{
     169    /* Create corresponding pages: */
     170    switch (mode())
     171    {
     172        case UIWizardMode_Basic:
     173        {
     174            setPage(Page1, new UIWizardCloneVMPageBasic1(m_machine.GetName()));
     175            setPage(Page2, new UIWizardCloneVMPageBasic2(m_snapshot.isNull()));
     176            if (m_machine.GetSnapshotCount() > 0)
     177                setPage(Page3, new UIWizardCloneVMPageBasic3(m_snapshot.isNull() ? false : m_snapshot.GetChildrenCount() > 0));
     178            break;
     179        }
     180        case UIWizardMode_Expert:
     181        {
     182            setPage(PageExpert, new UIWizardCloneVMPageExpert(m_machine.GetName(),
     183                                                              m_snapshot.isNull(),
     184                                                              m_snapshot.isNull() ? false : m_snapshot.GetChildrenCount() > 0));
     185            break;
     186        }
     187    }
     188    /* Call to base-class: */
     189    UIWizard::prepare();
     190}
     191
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVM.h

    r40870 r41021  
    3939    };
    4040
     41    /* Page IDs: */
     42    enum
     43    {
     44        PageExpert
     45    };
     46
    4147    /* Constructor: */
    4248    UIWizardCloneVM(QWidget *pParent, const CMachine &machine, CSnapshot snapshot = CSnapshot());
     
    5157    friend class UIWizardCloneVMPageBasic2;
    5258    friend class UIWizardCloneVMPageBasic3;
     59    friend class UIWizardCloneVMPageExpert;
    5360
    5461private:
     
    5663    /* Translation stuff: */
    5764    void retranslateUi();
     65
     66    /* Pages related stuff: */
     67    void prepare();
    5868
    5969    /* Variables: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp

    r40870 r41021  
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QGroupBox>
    2223#include <QLineEdit>
    2324#include <QCheckBox>
     
    2930#include "QIRichTextLabel.h"
    3031
     32UIWizardCloneVMPage1::UIWizardCloneVMPage1(const QString &strOriginalName)
     33    : m_strOriginalName(strOriginalName)
     34{
     35}
     36
     37QString UIWizardCloneVMPage1::cloneName() const
     38{
     39    return m_pNameEditor->text();
     40}
     41
     42void UIWizardCloneVMPage1::setCloneName(const QString &strName)
     43{
     44    m_pNameEditor->setText(strName);
     45}
     46
     47bool UIWizardCloneVMPage1::isReinitMACsChecked() const
     48{
     49    return m_pReinitMACsCheckBox->isChecked();
     50}
     51
    3152UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName)
    32     : m_strOriginalName(strOriginalName)
     53    : UIWizardCloneVMPage1(strOriginalName)
    3354{
    3455    /* Create widgets: */
    3556    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     57    {
    3658        m_pLabel1 = new QIRichTextLabel(this);
    3759        m_pLabel2 = new QIRichTextLabel(this);
    38         m_pNameEditor = new QLineEdit(this);
    39             m_pNameEditor->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
     60        m_pNameCnt = new QGroupBox(this);
     61        {
     62            QVBoxLayout *pNameCntLayout = new QVBoxLayout(m_pNameCnt);
     63            {
     64                m_pNameEditor = new QLineEdit(m_pNameCnt);
     65                {
     66                    m_pNameEditor->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
     67                }
     68                pNameCntLayout->addWidget(m_pNameEditor);
     69            }
     70        }
    4071        m_pReinitMACsCheckBox = new QCheckBox(this);
    41     pMainLayout->addWidget(m_pLabel1);
    42     pMainLayout->addWidget(m_pLabel2);
    43     pMainLayout->addWidget(m_pNameEditor);
    44     pMainLayout->addWidget(m_pReinitMACsCheckBox);
    45     pMainLayout->addStretch();
     72        pMainLayout->addWidget(m_pLabel1);
     73        pMainLayout->addWidget(m_pLabel2);
     74        pMainLayout->addWidget(m_pNameCnt);
     75        pMainLayout->addWidget(m_pReinitMACsCheckBox);
     76        pMainLayout->addStretch();
     77    }
    4678
    4779    /* Setup connections: */
    48     connect(m_pNameEditor, SIGNAL(textChanged(const QString&)), this, SIGNAL(completeChanged()));
     80    connect(m_pNameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
    4981
    5082    /* Register fields: */
     
    5688{
    5789    /* Translate page: */
    58     setTitle(UIWizardCloneVM::tr("Welcome to the virtual machine clone wizard"));
     90    setTitle(UIWizardCloneVM::tr("Welcome to the Clone Virtual Machine wizard!"));
    5991
    6092    /* Translate widgets: */
    6193    m_pLabel1->setText(UIWizardCloneVM::tr("<p>This wizard will help you to create a clone of your virtual machine.</p>"));
     94    m_pLabel1->setText(m_pLabel1->text() + QString("<p>%1</p>").arg(standardHelpText()));
    6295    m_pLabel2->setText(UIWizardCloneVM::tr("<p>Please choose a name for the new virtual machine:</p>"));
     96    m_pNameCnt->setTitle(UIWizardCloneVM::tr("&Name"));
    6397    m_pReinitMACsCheckBox->setToolTip(UIWizardCloneVM::tr("When checked a new unique MAC address will be assigned to all configured network cards."));
    6498    m_pReinitMACsCheckBox->setText(UIWizardCloneVM::tr("&Reinitialize the MAC address of all network cards"));
    65 
    66     /* Append page text with common part: */
    67     QString strCommonPart = QString("<p>%1</p>").arg(standardHelpText());
    68     m_pLabel1->setText(m_pLabel1->text() + strCommonPart);
    6999}
    70100
     
    77107bool UIWizardCloneVMPageBasic1::isComplete() const
    78108{
     109    /* Make sure VM name feat the rules: */
    79110    QString strName = m_pNameEditor->text().trimmed();
    80111    return !strName.isEmpty() && strName != m_strOriginalName;
    81112}
    82113
    83 bool UIWizardCloneVMPageBasic1::validatePage()
    84 {
    85     if (isFinalPage())
    86     {
    87         /* Try to create the clone: */
    88         startProcessing();
    89         bool fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
    90         endProcessing();
    91         return fResult;
    92     }
    93     else
    94         return true;
    95 }
    96 
    97 QString UIWizardCloneVMPageBasic1::cloneName() const
    98 {
    99     return m_pNameEditor->text();
    100 }
    101 
    102 void UIWizardCloneVMPageBasic1::setCloneName(const QString &strName)
    103 {
    104     m_pNameEditor->setText(strName);
    105 }
    106 
    107 bool UIWizardCloneVMPageBasic1::isReinitMACsChecked() const
    108 {
    109     return m_pReinitMACsCheckBox->isChecked();
    110 }
    111 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.h

    r40870 r41021  
    2424
    2525/* Forward declarations: */
    26 class QIRichTextLabel;
     26class QGroupBox;
    2727class QLineEdit;
    2828class QCheckBox;
     29class QIRichTextLabel;
    2930
    30 /* 1st page of the Clone Virtual Machine wizard: */
    31 class UIWizardCloneVMPageBasic1 : public UIWizardPage
     31/* 1st page of the Clone Virtual Machine wizard (base part): */
     32class UIWizardCloneVMPage1 : public UIWizardPageBase
     33{
     34protected:
     35
     36    /* Constructor: */
     37    UIWizardCloneVMPage1(const QString &strOriginalName);
     38
     39    /* Stuff for 'cloneName' field: */
     40    QString cloneName() const;
     41    void setCloneName(const QString &strName);
     42
     43    /* Stuff for 'reinitMACs' field: */
     44    bool isReinitMACsChecked() const;
     45
     46    /* Variables: */
     47    QString m_strOriginalName;
     48
     49    /* Widgets: */
     50    QGroupBox *m_pNameCnt;
     51    QLineEdit *m_pNameEditor;
     52    QCheckBox *m_pReinitMACsCheckBox;
     53};
     54
     55/* 1st page of the Clone Virtual Machine wizard (basic extension): */
     56class UIWizardCloneVMPageBasic1 : public UIWizardPage, public UIWizardCloneVMPage1
    3257{
    3358    Q_OBJECT;
     
    5075    /* Validation stuff: */
    5176    bool isComplete() const;
    52     bool validatePage();
    53 
    54     /* Stuff for 'cloneName' field: */
    55     QString cloneName() const;
    56     void setCloneName(const QString &strName);
    57 
    58     /* Stuff for 'reinitMACs' field: */
    59     bool isReinitMACsChecked() const;
    60 
    61     /* Variables: */
    62     QString m_strOriginalName;
    6377
    6478    /* Widgets: */
    6579    QIRichTextLabel *m_pLabel1;
    6680    QIRichTextLabel *m_pLabel2;
    67     QLineEdit *m_pNameEditor;
    68     QCheckBox *m_pReinitMACsCheckBox;
    6981};
    7082
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic2.cpp

    r40870 r41021  
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QGroupBox>
    2223#include <QRadioButton>
    2324#include <QButtonGroup>
     
    2930#include "QIRichTextLabel.h"
    3031
     32UIWizardCloneVMPage2::UIWizardCloneVMPage2(bool fAdditionalInfo)
     33    : m_fAdditionalInfo(fAdditionalInfo)
     34{
     35}
     36
     37bool UIWizardCloneVMPage2::isLinkedClone() const
     38{
     39    return m_pLinkedCloneRadio->isChecked();
     40}
     41
    3142UIWizardCloneVMPageBasic2::UIWizardCloneVMPageBasic2(bool fAdditionalInfo)
    32     : m_fAdditionalInfo(fAdditionalInfo)
     43    : UIWizardCloneVMPage2(fAdditionalInfo)
    3344{
    3445    /* Create widgets: */
    3546    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     47    {
    3648        m_pLabel = new QIRichTextLabel(this);
    37         m_pFullCloneRadio = new QRadioButton(this);
    38             m_pFullCloneRadio->setChecked(true);
    39         m_pLinkedCloneRadio = new QRadioButton(this);
    40     pMainLayout->addWidget(m_pLabel);
    41     pMainLayout->addWidget(m_pFullCloneRadio);
    42     pMainLayout->addWidget(m_pLinkedCloneRadio);
    43     pMainLayout->addStretch();
    44 
    45     /* Create button-group: */
    46     QButtonGroup *pButtonGroup = new QButtonGroup(this);
    47     pButtonGroup->addButton(m_pFullCloneRadio);
    48     pButtonGroup->addButton(m_pLinkedCloneRadio);
     49        m_pCloneTypeCnt = new QGroupBox(this);
     50        {
     51            m_pButtonGroup = new QButtonGroup(m_pCloneTypeCnt);
     52            {
     53                QVBoxLayout *pCloneTypeCntLayout = new QVBoxLayout(m_pCloneTypeCnt);
     54                {
     55                    m_pFullCloneRadio = new QRadioButton(m_pCloneTypeCnt);
     56                    {
     57                        m_pFullCloneRadio->setChecked(true);
     58                    }
     59                    m_pLinkedCloneRadio = new QRadioButton(m_pCloneTypeCnt);
     60                    pCloneTypeCntLayout->addWidget(m_pFullCloneRadio);
     61                    pCloneTypeCntLayout->addWidget(m_pLinkedCloneRadio);
     62                }
     63                m_pButtonGroup->addButton(m_pFullCloneRadio);
     64                m_pButtonGroup->addButton(m_pLinkedCloneRadio);
     65            }
     66        }
     67        pMainLayout->addWidget(m_pLabel);
     68        pMainLayout->addWidget(m_pCloneTypeCnt);
     69        pMainLayout->addStretch();
     70    }
    4971
    5072    /* Setup connections: */
    51     connect(pButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
     73    connect(m_pButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(sltButtonClicked(QAbstractButton *)));
    5274
    5375    /* Register fields: */
     
    5577}
    5678
    57 void UIWizardCloneVMPageBasic2::buttonClicked(QAbstractButton *pButton)
     79void UIWizardCloneVMPageBasic2::sltButtonClicked(QAbstractButton *pButton)
    5880{
    5981    setFinalPage(pButton != m_pFullCloneRadio);
     
    7294
    7395    /* Translate widgets: */
    74     m_pFullCloneRadio->setText(UIWizardCloneVM::tr("Full Clone"));
    75     m_pLinkedCloneRadio->setText(UIWizardCloneVM::tr("Linked Clone"));
    76 
    77     /* Set label text: */
    7896    QString strLabel = UIWizardCloneVM::tr("<p>Please select the type of the clone.</p><p>If you choose <b>Full Clone</b> an exact copy "
    7997                                           "(including all virtual disk images) of the original VM will be created. If you select <b>Linked Clone</b>, "
     
    82100        strLabel += UIWizardCloneVM::tr("<p>Note that a new snapshot within the source VM is created in case you select <b>Linked Clone</b>.</p>");
    83101    m_pLabel->setText(strLabel);
     102
     103    m_pCloneTypeCnt->setTitle(UIWizardCloneVM::tr("&Type"));
     104    m_pFullCloneRadio->setText(UIWizardCloneVM::tr("Full Clone"));
     105    m_pLinkedCloneRadio->setText(UIWizardCloneVM::tr("Linked Clone"));
    84106}
    85107
     
    92114bool UIWizardCloneVMPageBasic2::validatePage()
    93115{
     116    /* This page could be final: */
    94117    if (isFinalPage())
    95118    {
    96         /* Try to create the clone: */
     119        /* Initial result: */
     120        bool fResult = true;
     121
     122        /* Lock finish button: */
    97123        startProcessing();
    98         bool fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
     124
     125        /* Trying to clone VM: */
     126        if (fResult)
     127            fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
     128
     129        /* Unlock finish button: */
    99130        endProcessing();
     131
     132        /* Return result: */
    100133        return fResult;
    101134    }
     
    109142}
    110143
    111 bool UIWizardCloneVMPageBasic2::isLinkedClone() const
    112 {
    113     return m_pLinkedCloneRadio->isChecked();
    114 }
    115 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic2.h

    r40870 r41021  
    2424
    2525/* Forward declarations: */
     26class QGroupBox;
     27class QButtonGroup;
     28class QRadioButton;
    2629class QIRichTextLabel;
    27 class QRadioButton;
    2830
    29 /* 2nd page of the Clone Virtual Machine wizard: */
    30 class UIWizardCloneVMPageBasic2 : public UIWizardPage
     31/* 2nd page of the Clone Virtual Machine wizard (base part): */
     32class UIWizardCloneVMPage2 : public UIWizardPageBase
     33{
     34protected:
     35
     36    /* Constructor: */
     37    UIWizardCloneVMPage2(bool fAdditionalInfo);
     38
     39    /* Stuff for 'linkedClone' field: */
     40    bool isLinkedClone() const;
     41
     42    /* Variables: */
     43    bool m_fAdditionalInfo;
     44
     45    /* Widgets: */
     46    QGroupBox *m_pCloneTypeCnt;
     47    QButtonGroup *m_pButtonGroup;
     48    QRadioButton *m_pFullCloneRadio;
     49    QRadioButton *m_pLinkedCloneRadio;
     50};
     51
     52/* 2nd page of the Clone Virtual Machine wizard (basic extension): */
     53class UIWizardCloneVMPageBasic2 : public UIWizardPage, public UIWizardCloneVMPage2
    3154{
    3255    Q_OBJECT;
     
    4164
    4265    /* Button click handler: */
    43     void buttonClicked(QAbstractButton *pButton);
     66    void sltButtonClicked(QAbstractButton *pButton);
    4467
    4568private:
     
    5780    int nextId() const;
    5881
    59     /* Stuff for 'linkedClone' field: */
    60     bool isLinkedClone() const;
    61 
    62     /* Variables: */
    63     bool m_fAdditionalInfo;
    64 
    6582    /* Widgets: */
    6683    QIRichTextLabel *m_pLabel;
    67     QRadioButton *m_pFullCloneRadio;
    68     QRadioButton *m_pLinkedCloneRadio;
    6984};
    7085
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic3.cpp

    r40870 r41021  
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QGroupBox>
    2223#include <QRadioButton>
    2324
     
    2728#include "QIRichTextLabel.h"
    2829
    29 UIWizardCloneVMPageBasic3::UIWizardCloneVMPageBasic3(bool fShowChildsOption /* = true */)
     30UIWizardCloneVMPage3::UIWizardCloneVMPage3(bool fShowChildsOption)
    3031    : m_fShowChildsOption(fShowChildsOption)
     32{
     33}
     34
     35KCloneMode UIWizardCloneVMPage3::cloneMode() const
     36{
     37    if (m_pMachineAndChildsRadio->isChecked())
     38        return KCloneMode_MachineAndChildStates;
     39    else if (m_pAllRadio->isChecked())
     40        return KCloneMode_AllStates;
     41    return KCloneMode_MachineState;
     42}
     43
     44void UIWizardCloneVMPage3::setCloneMode(KCloneMode cloneMode)
     45{
     46    switch (cloneMode)
     47    {
     48        case KCloneMode_MachineState: m_pMachineRadio->setChecked(true); break;
     49        case KCloneMode_MachineAndChildStates: m_pMachineAndChildsRadio->setChecked(true); break;
     50        case KCloneMode_AllStates: m_pAllRadio->setChecked(true); break;
     51    }
     52}
     53
     54UIWizardCloneVMPageBasic3::UIWizardCloneVMPageBasic3(bool fShowChildsOption)
     55    : UIWizardCloneVMPage3(fShowChildsOption)
    3156{
    3257    /* Create widgets: */
    3358    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     59    {
    3460        m_pLabel = new QIRichTextLabel(this);
    35         m_pMachineRadio = new QRadioButton(this);
    36             m_pMachineRadio->setChecked(true);
    37         m_pMachineAndChildsRadio = new QRadioButton(this);
    38             if (!m_fShowChildsOption)
    39                m_pMachineAndChildsRadio->hide();
    40         m_pAllRadio = new QRadioButton(this);
    41     pMainLayout->addWidget(m_pLabel);
    42     pMainLayout->addWidget(m_pMachineRadio);
    43     pMainLayout->addWidget(m_pMachineAndChildsRadio);
    44     pMainLayout->addWidget(m_pAllRadio);
    45     pMainLayout->addStretch();
     61        m_pCloneModeCnt = new QGroupBox(this);
     62        {
     63            QVBoxLayout *pCloneModeCntLayout = new QVBoxLayout(m_pCloneModeCnt);
     64            {
     65                m_pMachineRadio = new QRadioButton(m_pCloneModeCnt);
     66                {
     67                    m_pMachineRadio->setChecked(true);
     68                }
     69                m_pMachineAndChildsRadio = new QRadioButton(m_pCloneModeCnt);
     70                {
     71                    if (!m_fShowChildsOption)
     72                       m_pMachineAndChildsRadio->hide();
     73                }
     74                m_pAllRadio = new QRadioButton(m_pCloneModeCnt);
     75                pCloneModeCntLayout->addWidget(m_pMachineRadio);
     76                pCloneModeCntLayout->addWidget(m_pMachineAndChildsRadio);
     77                pCloneModeCntLayout->addWidget(m_pAllRadio);
     78            }
     79        }
     80        pMainLayout->addWidget(m_pLabel);
     81        pMainLayout->addWidget(m_pCloneModeCnt);
     82        pMainLayout->addStretch();
     83    }
    4684
    47     /* Register KCloneMode class: */
     85    /* Register classes: */
    4886    qRegisterMetaType<KCloneMode>();
     87    /* Register fields: */
    4988    registerField("cloneMode", this, "cloneMode");
    5089}
     
    5695
    5796    /* Translate widgets: */
    58     m_pMachineRadio->setText(UIWizardCloneVM::tr("Current machine state"));
    59     m_pMachineAndChildsRadio->setText(UIWizardCloneVM::tr("Current machine and all child states"));
    60     m_pAllRadio->setText(UIWizardCloneVM::tr("All states"));
    61 
    6297    const QString strGeneral = UIWizardCloneVM::tr("Please choose which parts of the virtual machine should be cloned.");
    6398    const QString strOpt1    = UIWizardCloneVM::tr("If you select <b>Current machine state</b>, only the current state "
     
    78113                          .arg(strOpt1)
    79114                          .arg(strOpt3));
     115
     116    m_pCloneModeCnt->setTitle(UIWizardCloneVM::tr("&Mode"));
     117    m_pMachineRadio->setText(UIWizardCloneVM::tr("Current machine state"));
     118    m_pMachineAndChildsRadio->setText(UIWizardCloneVM::tr("Current machine and all child states"));
     119    m_pAllRadio->setText(UIWizardCloneVM::tr("All states"));
    80120}
    81121
     
    88128bool UIWizardCloneVMPageBasic3::validatePage()
    89129{
     130    /* Initial result: */
     131    bool fResult = true;
     132
     133    /* Lock finish button: */
     134    startProcessing();
     135
    90136    /* Try to clone VM: */
    91     startProcessing();
    92     bool fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
     137    if (fResult)
     138        fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
     139
     140    /* Unlock finish button: */
    93141    endProcessing();
     142
     143    /* Return result: */
    94144    return fResult;
    95145}
    96146
    97 KCloneMode UIWizardCloneVMPageBasic3::cloneMode() const
    98 {
    99     if (m_pMachineAndChildsRadio->isChecked())
    100         return KCloneMode_MachineAndChildStates;
    101     else if (m_pAllRadio->isChecked())
    102         return KCloneMode_AllStates;
    103     return KCloneMode_MachineState;
    104 }
    105 
    106 void UIWizardCloneVMPageBasic3::setCloneMode(KCloneMode cloneMode)
    107 {
    108     switch (cloneMode)
    109     {
    110         case KCloneMode_MachineState: m_pMachineRadio->setChecked(true); break;
    111         case KCloneMode_MachineAndChildStates: m_pMachineAndChildsRadio->setChecked(true); break;
    112         case KCloneMode_AllStates: m_pAllRadio->setChecked(true); break;
    113     }
    114 }
    115 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic3.h

    r40870 r41021  
    2525
    2626/* Forward declaration: */
     27class QGroupBox;
     28class QRadioButton;
    2729class QIRichTextLabel;
    28 class QRadioButton;
    2930
    30 /* 3rd page of the Clone Virtual Machine wizard: */
    31 class UIWizardCloneVMPageBasic3 : public UIWizardPage
     31/* 3rd page of the Clone Virtual Machine wizard (base part): */
     32class UIWizardCloneVMPage3 : public UIWizardPageBase
     33{
     34protected:
     35
     36    /* Constructor: */
     37    UIWizardCloneVMPage3(bool fShowChildsOption);
     38
     39    /* Stuff for 'cloneMode' field: */
     40    KCloneMode cloneMode() const;
     41    void setCloneMode(KCloneMode cloneMode);
     42
     43    /* Variables: */
     44    bool m_fShowChildsOption;
     45
     46    /* Widgets: */
     47    QGroupBox *m_pCloneModeCnt;
     48    QRadioButton *m_pMachineRadio;
     49    QRadioButton *m_pMachineAndChildsRadio;
     50    QRadioButton *m_pAllRadio;
     51};
     52
     53/* 3rd page of the Clone Virtual Machine wizard (basic extension): */
     54class UIWizardCloneVMPageBasic3 : public UIWizardPage, public UIWizardCloneVMPage3
    3255{
    3356    Q_OBJECT;
     
    3760
    3861    /* Constructor: */
    39     UIWizardCloneVMPageBasic3(bool fShowChildsOption = true);
     62    UIWizardCloneVMPageBasic3(bool fShowChildsOption);
    4063
    4164private:
     
    5073    bool validatePage();
    5174
    52     /* Stuff for 'cloneMode' field: */
    53     KCloneMode cloneMode() const;
    54     void setCloneMode(KCloneMode cloneMode);
    55 
    56     /* Variables: */
    57     bool m_fShowChildsOption;
    58 
    5975    /* Widgets: */
    6076    QIRichTextLabel *m_pLabel;
    61     QRadioButton *m_pMachineRadio;
    62     QRadioButton *m_pMachineAndChildsRadio;
    63     QRadioButton *m_pAllRadio;
    6477};
    6578
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.cpp

    r40929 r41021  
    33 *
    44 * VBox frontends: Qt4 GUI ("VirtualBox"):
    5  * UIWizardCloneVMPageBasic1 class implementation
     5 * UIWizardCloneVMPageExpert class implementation
    66 */
    77
     
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QButtonGroup>
     23#include <QGroupBox>
    2224#include <QLineEdit>
    2325#include <QCheckBox>
     26#include <QRadioButton>
    2427
    2528/* Local includes: */
    26 #include "UIWizardCloneVMPageBasic1.h"
     29#include "UIWizardCloneVMPageExpert.h"
    2730#include "UIWizardCloneVM.h"
    28 #include "COMDefs.h"
    29 #include "QIRichTextLabel.h"
    3031
    31 UIWizardCloneVMPageBasic1::UIWizardCloneVMPageBasic1(const QString &strOriginalName)
    32     : m_strOriginalName(strOriginalName)
     32UIWizardCloneVMPageExpert::UIWizardCloneVMPageExpert(const QString &strOriginalName, bool fAdditionalInfo, bool fShowChildsOption)
     33    : UIWizardCloneVMPage1(strOriginalName)
     34    , UIWizardCloneVMPage2(fAdditionalInfo)
     35    , UIWizardCloneVMPage3(fShowChildsOption)
    3336{
    3437    /* Create widgets: */
    3538    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    36         m_pLabel1 = new QIRichTextLabel(this);
    37         m_pLabel2 = new QIRichTextLabel(this);
    38         m_pNameEditor = new QLineEdit(this);
    39             m_pNameEditor->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
     39    {
     40        pMainLayout->setContentsMargins(8, 6, 8, 6);
     41        m_pNameCnt = new QGroupBox(this);
     42        {
     43            QVBoxLayout *pNameCntLayout = new QVBoxLayout(m_pNameCnt);
     44            {
     45                m_pNameEditor = new QLineEdit(m_pNameCnt);
     46                {
     47                    m_pNameEditor->setText(UIWizardCloneVM::tr("%1 Clone").arg(m_strOriginalName));
     48                }
     49                pNameCntLayout->addWidget(m_pNameEditor);
     50            }
     51        }
     52        m_pCloneTypeCnt = new QGroupBox(this);
     53        {
     54            m_pButtonGroup = new QButtonGroup(m_pCloneTypeCnt);
     55            {
     56                QVBoxLayout *pCloneTypeCntLayout = new QVBoxLayout(m_pCloneTypeCnt);
     57                {
     58                    m_pFullCloneRadio = new QRadioButton(m_pCloneTypeCnt);
     59                    {
     60                        m_pFullCloneRadio->setChecked(true);
     61                    }
     62                    m_pLinkedCloneRadio = new QRadioButton(m_pCloneTypeCnt);
     63                    pCloneTypeCntLayout->addWidget(m_pFullCloneRadio);
     64                    pCloneTypeCntLayout->addWidget(m_pLinkedCloneRadio);
     65                }
     66                m_pButtonGroup->addButton(m_pFullCloneRadio);
     67                m_pButtonGroup->addButton(m_pLinkedCloneRadio);
     68            }
     69        }
     70        m_pCloneModeCnt = new QGroupBox(this);
     71        {
     72            QVBoxLayout *pCloneModeCntLayout = new QVBoxLayout(m_pCloneModeCnt);
     73            {
     74                m_pMachineRadio = new QRadioButton(m_pCloneModeCnt);
     75                {
     76                    m_pMachineRadio->setChecked(true);
     77                }
     78                m_pMachineAndChildsRadio = new QRadioButton(m_pCloneModeCnt);
     79                {
     80                    if (!m_fShowChildsOption)
     81                       m_pMachineAndChildsRadio->hide();
     82                }
     83                m_pAllRadio = new QRadioButton(m_pCloneModeCnt);
     84                pCloneModeCntLayout->addWidget(m_pMachineRadio);
     85                pCloneModeCntLayout->addWidget(m_pMachineAndChildsRadio);
     86                pCloneModeCntLayout->addWidget(m_pAllRadio);
     87            }
     88        }
    4089        m_pReinitMACsCheckBox = new QCheckBox(this);
    41     pMainLayout->addWidget(m_pLabel1);
    42     pMainLayout->addWidget(m_pLabel2);
    43     pMainLayout->addWidget(m_pNameEditor);
    44     pMainLayout->addWidget(m_pReinitMACsCheckBox);
    45     pMainLayout->addStretch();
     90        pMainLayout->addWidget(m_pNameCnt);
     91        pMainLayout->addWidget(m_pCloneTypeCnt);
     92        pMainLayout->addWidget(m_pCloneModeCnt);
     93        pMainLayout->addWidget(m_pReinitMACsCheckBox);
     94        pMainLayout->addStretch();
     95        sltButtonClicked(m_pFullCloneRadio);
     96    }
    4697
    4798    /* Setup connections: */
    48     connect(m_pNameEditor, SIGNAL(textChanged(const QString&)), this, SIGNAL(completeChanged()));
     99    connect(m_pNameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
     100    connect(m_pButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(sltButtonClicked(QAbstractButton *)));
    49101
     102    /* Register classes: */
     103    qRegisterMetaType<KCloneMode>();
    50104    /* Register fields: */
    51105    registerField("cloneName", this, "cloneName");
    52106    registerField("reinitMACs", this, "reinitMACs");
     107    registerField("linkedClone", this, "linkedClone");
     108    registerField("cloneMode", this, "cloneMode");
    53109}
    54110
    55 void UIWizardCloneVMPageBasic1::retranslateUi()
     111void UIWizardCloneVMPageExpert::sltButtonClicked(QAbstractButton *pButton)
    56112{
    57     /* Translate page: */
    58     setTitle(UIWizardCloneVM::tr("Welcome to the virtual machine clone wizard"));
     113    /* Enabled/disable mode container: */
     114    m_pCloneModeCnt->setEnabled(pButton == m_pFullCloneRadio);
     115}
    59116
     117void UIWizardCloneVMPageExpert::retranslateUi()
     118{
    60119    /* Translate widgets: */
    61     m_pLabel1->setText(UIWizardCloneVM::tr("<p>This wizard will help you to create a clone of your virtual machine.</p>"));
    62     m_pLabel2->setText(UIWizardCloneVM::tr("<p>Please choose a name for the new virtual machine:</p>"));
     120    m_pNameCnt->setTitle(UIWizardCloneVM::tr("&Name"));
     121    m_pCloneTypeCnt->setTitle(UIWizardCloneVM::tr("&Type"));
     122    m_pFullCloneRadio->setText(UIWizardCloneVM::tr("Full Clone"));
     123    m_pLinkedCloneRadio->setText(UIWizardCloneVM::tr("Linked Clone"));
     124    m_pCloneModeCnt->setTitle(UIWizardCloneVM::tr("&Mode"));
     125    m_pMachineRadio->setText(UIWizardCloneVM::tr("Current machine state"));
     126    m_pMachineAndChildsRadio->setText(UIWizardCloneVM::tr("Current machine and all child states"));
     127    m_pAllRadio->setText(UIWizardCloneVM::tr("All states"));
    63128    m_pReinitMACsCheckBox->setToolTip(UIWizardCloneVM::tr("When checked a new unique MAC address will be assigned to all configured network cards."));
    64129    m_pReinitMACsCheckBox->setText(UIWizardCloneVM::tr("&Reinitialize the MAC address of all network cards"));
    65 
    66     /* Append page text with common part: */
    67     QString strCommonPart = QString("<p>%1</p>").arg(standardHelpText());
    68     m_pLabel1->setText(m_pLabel1->text() + strCommonPart);
    69130}
    70131
    71 void UIWizardCloneVMPageBasic1::initializePage()
     132void UIWizardCloneVMPageExpert::initializePage()
    72133{
    73134    /* Translate page: */
     
    75136}
    76137
    77 bool UIWizardCloneVMPageBasic1::isComplete() const
     138bool UIWizardCloneVMPageExpert::isComplete() const
    78139{
     140    /* Make sure VM name feat the rules: */
    79141    QString strName = m_pNameEditor->text().trimmed();
    80142    return !strName.isEmpty() && strName != m_strOriginalName;
    81143}
    82144
    83 bool UIWizardCloneVMPageBasic1::validatePage()
     145bool UIWizardCloneVMPageExpert::validatePage()
    84146{
    85     if (isFinalPage())
    86     {
    87         /* Try to create the clone: */
    88         startProcessing();
    89         bool fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
    90         endProcessing();
    91         return fResult;
    92     }
    93     else
    94         return true;
     147    /* Initial result: */
     148    bool fResult = true;
     149
     150    /* Lock finish button: */
     151    startProcessing();
     152
     153    /* Trying to clone VM: */
     154    if (fResult)
     155        fResult = qobject_cast<UIWizardCloneVM*>(wizard())->cloneVM();
     156
     157    /* Unlock finish button: */
     158    endProcessing();
     159
     160    /* Return result: */
     161    return fResult;
    95162}
    96163
    97 QString UIWizardCloneVMPageBasic1::cloneName() const
    98 {
    99     return m_pNameEditor->text();
    100 }
    101 
    102 void UIWizardCloneVMPageBasic1::setCloneName(const QString &strName)
    103 {
    104     m_pNameEditor->setText(strName);
    105 }
    106 
    107 bool UIWizardCloneVMPageBasic1::isReinitMACsChecked() const
    108 {
    109     return m_pReinitMACsCheckBox->isChecked();
    110 }
    111 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageExpert.h

    r40929 r41021  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * UIWizardCloneVMPageBasic1 class declaration
     4 * UIWizardCloneVMPageExpert class declaration
    55 */
    66
     
    1717 */
    1818
    19 #ifndef __UIWizardCloneVMPageBasic1_h__
    20 #define __UIWizardCloneVMPageBasic1_h__
     19#ifndef __UIWizardCloneVMPageExpert_h__
     20#define __UIWizardCloneVMPageExpert_h__
    2121
    2222/* Local includes: */
    23 #include "UIWizardPage.h"
     23#include "UIWizardCloneVMPageBasic1.h"
     24#include "UIWizardCloneVMPageBasic2.h"
     25#include "UIWizardCloneVMPageBasic3.h"
    2426
    25 /* Forward declarations: */
    26 class QIRichTextLabel;
    27 class QLineEdit;
    28 class QCheckBox;
    29 
    30 /* 1st page of the Clone Virtual Machine wizard: */
    31 class UIWizardCloneVMPageBasic1 : public UIWizardPage
     27/* Expert page of the Clone Virtual Machine wizard: */
     28class UIWizardCloneVMPageExpert : public UIWizardPage,
     29                                  public UIWizardCloneVMPage1,
     30                                  public UIWizardCloneVMPage2,
     31                                  public UIWizardCloneVMPage3
    3232{
    3333    Q_OBJECT;
    3434    Q_PROPERTY(QString cloneName READ cloneName WRITE setCloneName);
    3535    Q_PROPERTY(bool reinitMACs READ isReinitMACsChecked);
     36    Q_PROPERTY(bool linkedClone READ isLinkedClone);
     37    Q_PROPERTY(KCloneMode cloneMode READ cloneMode WRITE setCloneMode);
    3638
    3739public:
    3840
    3941    /* Constructor: */
    40     UIWizardCloneVMPageBasic1(const QString &strOriginalName);
     42    UIWizardCloneVMPageExpert(const QString &strOriginalName, bool fAdditionalInfo, bool fShowChildsOption);
     43
     44private slots:
     45
     46    /* Button click handler: */
     47    void sltButtonClicked(QAbstractButton *pButton);
    4148
    4249private:
     
    5158    bool isComplete() const;
    5259    bool validatePage();
    53 
    54     /* Stuff for 'cloneName' field: */
    55     QString cloneName() const;
    56     void setCloneName(const QString &strName);
    57 
    58     /* Stuff for 'reinitMACs' field: */
    59     bool isReinitMACsChecked() const;
    60 
    61     /* Variables: */
    62     QString m_strOriginalName;
    63 
    64     /* Widgets: */
    65     QIRichTextLabel *m_pLabel1;
    66     QIRichTextLabel *m_pLabel2;
    67     QLineEdit *m_pNameEditor;
    68     QCheckBox *m_pReinitMACsCheckBox;
    6960};
    7061
    71 #endif // __UIWizardCloneVMPageBasic1_h__
     62#endif // __UIWizardCloneVMPageExpert_h__
    7263
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.cpp

    r40870 r41021  
    2929#include "UIWizardExportAppPageBasic3.h"
    3030#include "UIWizardExportAppPageBasic4.h"
     31#include "UIWizardExportAppPageExpert.h"
    3132#include "COMDefs.h"
    3233#include "UIMessageCenter.h"
    3334
    3435UIWizardExportApp::UIWizardExportApp(QWidget *pParent, const QStringList &selectedVMNames)
    35     : UIWizard(pParent)
    36 {
    37     /* Create & add pages */
    38     setPage(Page1, new UIWizardExportAppPageBasic1(selectedVMNames));
    39     setPage(Page2, new UIWizardExportAppPageBasic2);
    40     setPage(Page3, new UIWizardExportAppPageBasic3);
    41     setPage(Page4, new UIWizardExportAppPageBasic4);
    42 
    43     /* Translate wizard: */
    44     retranslateUi();
    45 
    46     /* Translate wizard pages: */
    47     retranslateAllPages();
    48 
     36    : UIWizard(pParent, UIWizardType_ExportAppliance)
     37    , m_selectedVMNames(selectedVMNames)
     38{
    4939#ifndef Q_WS_MAC
    5040    /* Assign watermark: */
     
    5444    assignBackground(":/vmw_ovf_export_bg.png");
    5545#endif /* Q_WS_MAC */
    56 
    57     /* Resize wizard to 'golden ratio': */
    58     resizeToGoldenRatio(UIWizardType_ExportAppliance);
    59 
    60     /* Setup connections: */
    61     AssertMsg(!field("applianceWidget").value<ExportAppliancePointer>().isNull(), ("Appliance Widget is not set!\n"));
    62     connect(this, SIGNAL(customButtonClicked(int)), field("applianceWidget").value<ExportAppliancePointer>(), SLOT(restoreDefaults()));
    63     connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(sltCurrentIdChanged(int)));
    6446}
    6547
     
    219201}
    220202
     203void UIWizardExportApp::sltCurrentIdChanged(int iId)
     204{
     205    /* Call to base-class: */
     206    UIWizard::sltCurrentIdChanged(iId);
     207    /* Enable 2nd button (Reset to Defaults) for 4th and Expert pages only! */
     208    setOption(QWizard::HaveCustomButton2, (mode() == UIWizardMode_Basic && iId == Page4) ||
     209                                          (mode() == UIWizardMode_Expert && iId == PageExpert));
     210}
     211
     212void UIWizardExportApp::sltCustomButtonClicked(int iId)
     213{
     214    /* Call to base-class: */
     215    UIWizard::sltCustomButtonClicked(iId);
     216
     217    /* Handle 2nd button: */
     218    if (iId == CustomButton2)
     219    {
     220        /* Get appliance widget: */
     221        ExportAppliancePointer pApplianceWidget = field("applianceWidget").value<ExportAppliancePointer>();
     222        AssertMsg(!pApplianceWidget.isNull(), ("Appliance Widget is not set!\n"));
     223        /* Reset it to default: */
     224        pApplianceWidget->restoreDefaults();
     225    }
     226}
     227
    221228void UIWizardExportApp::retranslateUi()
    222229{
     230    /* Call to base-class: */
     231    UIWizard::retranslateUi();
     232
    223233    /* Translate wizard: */
    224234    setWindowTitle(tr("Appliance Export Wizard"));
    225     setButtonText(QWizard::CustomButton1, tr("Restore Defaults"));
     235    setButtonText(QWizard::CustomButton2, tr("Restore Defaults"));
    226236    setButtonText(QWizard::FinishButton, tr("Export"));
    227237}
    228238
    229 void UIWizardExportApp::sltCurrentIdChanged(int iId)
    230 {
    231     setOption(QWizard::HaveCustomButton1, iId == Page4);
    232 }
    233 
     239void UIWizardExportApp::prepare()
     240{
     241    /* Create corresponding pages: */
     242    switch (mode())
     243    {
     244        case UIWizardMode_Basic:
     245        {
     246            setPage(Page1, new UIWizardExportAppPageBasic1(m_selectedVMNames));
     247            setPage(Page2, new UIWizardExportAppPageBasic2);
     248            setPage(Page3, new UIWizardExportAppPageBasic3);
     249            setPage(Page4, new UIWizardExportAppPageBasic4);
     250            break;
     251        }
     252        case UIWizardMode_Expert:
     253        {
     254            setPage(PageExpert, new UIWizardExportAppPageExpert(m_selectedVMNames));
     255            break;
     256        }
     257    }
     258    /* Call to base-class: */
     259    UIWizard::prepare();
     260}
     261
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportApp.h

    r40870 r41021  
    4242    };
    4343
     44    /* Page IDs: */
     45    enum
     46    {
     47        PageExpert
     48    };
     49
    4450    /* Constructor: */
    4551    UIWizardExportApp(QWidget *pParent, const QStringList &selectedVMNames = QStringList());
     
    5359
    5460    /* Who will be able to export appliance: */
     61    friend class UIWizardExportAppPage4;
    5562    friend class UIWizardExportAppPageBasic4;
     63    friend class UIWizardExportAppPageExpert;
    5664
    5765private slots:
     
    5967    /* Page change handler: */
    6068    void sltCurrentIdChanged(int iId);
     69    /* Custom button 2 click handler: */
     70    void sltCustomButtonClicked(int iId);
    6171
    6272private:
     
    6474    /* Translation stuff: */
    6575    void retranslateUi();
     76
     77    /* Pages related stuff: */
     78    void prepare();
     79
     80    /* Variables: */
     81    QStringList m_selectedVMNames;
    6682};
    6783
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppDefs.h

    r40870 r41021  
    2323#include <QMetaType>
    2424#include <QPointer>
     25#include <QListWidget>
    2526
    2627/* Local includes: */
     
    3536Q_DECLARE_METATYPE(ExportAppliancePointer);
    3637
     38class VMListWidgetItem : public QListWidgetItem
     39{
     40public:
     41
     42    VMListWidgetItem(QPixmap &pixIcon, QString &strText, QString strUuid, bool fInSaveState, QListWidget *pParent)
     43        : QListWidgetItem(pixIcon, strText, pParent)
     44        , m_strUuid(strUuid)
     45        , m_fInSaveState(fInSaveState)
     46    {
     47    }
     48
     49    bool operator<(const QListWidgetItem &other) const
     50    {
     51        return text().toLower() < other.text().toLower();
     52    }
     53
     54    QString uuid() { return m_strUuid; }
     55    bool isInSaveState() { return m_fInSaveState; }
     56
     57private:
     58
     59    QString m_strUuid;
     60    bool m_fInSaveState;
     61};
     62
    3763#endif /* __UIWizardExportAppDefs_h__ */
    3864
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic1.cpp

    r40870 r41021  
    2020/* Global includes: */
    2121#include <QVBoxLayout>
    22 #include <QListWidget>
    2322
    2423/* Local includes: */
    2524#include "UIWizardExportAppPageBasic1.h"
    2625#include "UIWizardExportApp.h"
     26#include "UIWizardExportAppDefs.h"
    2727#include "VBoxGlobal.h"
    2828#include "UIMessageCenter.h"
     29#include "QILabelSeparator.h"
    2930#include "QIRichTextLabel.h"
    3031
    31 class VMListWidgetItems : public QListWidgetItem
     32UIWizardExportAppPage1::UIWizardExportAppPage1()
    3233{
    33 public:
    34 
    35     VMListWidgetItems(QPixmap &pixIcon, QString &strText, QString strUuid, bool fInSaveState, QListWidget *pParent)
    36         : QListWidgetItem(pixIcon, strText, pParent)
    37         , m_strUuid(strUuid)
    38         , m_fInSaveState(fInSaveState)
    39     {
    40     }
    41 
    42     bool operator<(const QListWidgetItem &other) const
    43     {
    44         return text().toLower() < other.text().toLower();
    45     }
    46 
    47     QString uuid() { return m_strUuid; }
    48     bool isInSaveState() { return m_fInSaveState; }
    49 
    50 private:
    51 
    52     QString m_strUuid;
    53     bool m_fInSaveState;
    54 };
    55 
    56 UIWizardExportAppPageBasic1::UIWizardExportAppPageBasic1(const QStringList &selectedVMNames)
    57     : m_selectedVMNames(selectedVMNames)
    58 {
    59     /* Create widgets: */
    60     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    61         m_pLabel = new QIRichTextLabel(this);
    62         m_pVMSelector = new QListWidget(this);
    63             m_pVMSelector->setAlternatingRowColors(true);
    64             m_pVMSelector->setSelectionMode(QAbstractItemView::ExtendedSelection);
    65             populateVMSelectorItems();
    66     pMainLayout->addWidget(m_pLabel);
    67     pMainLayout->addWidget(m_pVMSelector);
    68 
    69     /* Choose initially selected items (if passed): */
    70     for (int i = 0; i < m_selectedVMNames.size(); ++i)
    71     {
    72         QList<QListWidgetItem*> list = m_pVMSelector->findItems(m_selectedVMNames[i], Qt::MatchExactly);
    73         if (list.size() > 0)
    74         {
    75             if (m_pVMSelector->selectedItems().isEmpty())
    76                 m_pVMSelector->setCurrentItem(list.first());
    77             else
    78                 list.first()->setSelected(true);
    79         }
    80     }
    81 
    82     /* Setup connections: */
    83     connect(m_pVMSelector, SIGNAL(itemSelectionChanged()), this, SIGNAL(completeChanged()));
    84 
    85     /* Register 'machineNames', 'machineIDs' fields! */
    86     registerField("machineNames", this, "machineNames");
    87     registerField("machineIDs", this, "machineIDs");
    8834}
    8935
    90 void UIWizardExportAppPageBasic1::retranslateUi()
    91 {
    92     /* Translate page: */
    93     setTitle(UIWizardExportApp::tr("Welcome to the Appliance Export Wizard!"));
    94 
    95     /* Translate widgets: */
    96     m_pLabel->setText(UIWizardExportApp::tr("<p>This wizard will guide you through the process of "
    97                                             "exporting an appliance.</p><p>%1</p><p>Please select "
    98                                             "the virtual machines that should be added to the "
    99                                             "appliance. You can select more than one. Please note "
    100                                             "that these machines have to be turned off before they "
    101                                             "can be exported.</p>")
    102                                             .arg(standardHelpText()));
    103 }
    104 
    105 void UIWizardExportAppPageBasic1::initializePage()
    106 {
    107     /* Translate page: */
    108     retranslateUi();
    109 }
    110 
    111 bool UIWizardExportAppPageBasic1::isComplete() const
    112 {
    113     /* There should be at least one vm selected! */
    114     return m_pVMSelector->selectedItems().size() > 0;
    115 }
    116 
    117 bool UIWizardExportAppPageBasic1::validatePage()
    118 {
    119     /* Ask user machines which are in save state currently. */
    120     QStringList savedMachines;
    121     QList<QListWidgetItem*> pItems = m_pVMSelector->selectedItems();
    122     for (int i=0; i < pItems.size(); ++i)
    123     {
    124         if (static_cast<VMListWidgetItems*>(pItems.at(i))->isInSaveState())
    125             savedMachines << pItems.at(i)->text();
    126     }
    127 
    128     if (!savedMachines.isEmpty())
    129         return msgCenter().confirmExportMachinesInSaveState(savedMachines, this);
    130 
    131     return true;
    132 }
    133 
    134 int UIWizardExportAppPageBasic1::nextId() const
    135 {
    136     /* Skip next (2nd, Storage-type) page for now! */
    137     return UIWizardExportApp::Page3;
    138 }
    139 
    140 void UIWizardExportAppPageBasic1::populateVMSelectorItems()
     36void UIWizardExportAppPage1::populateVMSelectorItems(const QStringList &selectedVMNames)
    14137{
    14238    /* Add all VM items into 'VM Selector': */
     
    16359            pixIcon = QPixmap(":/os_other.png").scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    16460        }
    165         QListWidgetItem *pItem = new VMListWidgetItems(pixIcon, strName, strUuid, fInSaveState, m_pVMSelector);
     61        QListWidgetItem *pItem = new VMListWidgetItem(pixIcon, strName, strUuid, fInSaveState, m_pVMSelector);
    16662        if (!fEnabled)
    16763            pItem->setFlags(0);
     
    16965    }
    17066    m_pVMSelector->sortItems();
     67
     68    /* Choose initially selected items (if passed): */
     69    for (int i = 0; i < selectedVMNames.size(); ++i)
     70    {
     71        QList<QListWidgetItem*> list = m_pVMSelector->findItems(selectedVMNames[i], Qt::MatchExactly);
     72        if (list.size() > 0)
     73        {
     74            if (m_pVMSelector->selectedItems().isEmpty())
     75                m_pVMSelector->setCurrentItem(list.first());
     76            else
     77                list.first()->setSelected(true);
     78        }
     79    }
    17180}
    17281
    173 QStringList UIWizardExportAppPageBasic1::machineNames() const
     82QStringList UIWizardExportAppPage1::machineNames() const
    17483{
    17584    /* Prepare list: */
     
    18291}
    18392
    184 QStringList UIWizardExportAppPageBasic1::machineIDs() const
     93QStringList UIWizardExportAppPage1::machineIDs() const
    18594{
    18695    /* Prepare list: */
     
    18897    /* Iterate over all the selected items: */
    18998    foreach (QListWidgetItem *pItem, m_pVMSelector->selectedItems())
    190         machineIDs << static_cast<VMListWidgetItems*>(pItem)->uuid();
     99        machineIDs << static_cast<VMListWidgetItem*>(pItem)->uuid();
    191100    /* Return result list: */
    192101    return machineIDs;
    193102}
    194103
     104UIWizardExportAppPageBasic1::UIWizardExportAppPageBasic1(const QStringList &selectedVMNames)
     105{
     106    /* Create widgets: */
     107    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     108    {
     109        m_pLabel = new QIRichTextLabel(this);
     110        m_pVMSelectorLabel = new QILabelSeparator(this);
     111        {
     112            m_pVMSelectorLabel->hide();
     113        }
     114        m_pVMSelector = new QListWidget(this);
     115        {
     116            m_pVMSelector->setAlternatingRowColors(true);
     117            m_pVMSelector->setSelectionMode(QAbstractItemView::ExtendedSelection);
     118            m_pVMSelectorLabel->setBuddy(m_pVMSelector);
     119        }
     120        pMainLayout->addWidget(m_pLabel);
     121        pMainLayout->addWidget(m_pVMSelectorLabel);
     122        pMainLayout->addWidget(m_pVMSelector);
     123        populateVMSelectorItems(selectedVMNames);
     124    }
     125
     126    /* Setup connections: */
     127    connect(m_pVMSelector, SIGNAL(itemSelectionChanged()), this, SIGNAL(completeChanged()));
     128
     129    /* Register fields: */
     130    registerField("machineNames", this, "machineNames");
     131    registerField("machineIDs", this, "machineIDs");
     132}
     133
     134void UIWizardExportAppPageBasic1::retranslateUi()
     135{
     136    /* Translate page: */
     137    setTitle(UIWizardExportApp::tr("Welcome to the Appliance Export wizard!"));
     138
     139    /* Translate widgets: */
     140    m_pLabel->setText(UIWizardExportApp::tr("<p>This wizard will guide you through the process of "
     141                                            "exporting an appliance.</p><p>%1</p><p>Please select "
     142                                            "the virtual machines that should be added to the "
     143                                            "appliance. You can select more than one. Please note "
     144                                            "that these machines have to be turned off before they "
     145                                            "can be exported.</p>")
     146                                            .arg(standardHelpText()));
     147    m_pVMSelectorLabel->setText(UIWizardExportApp::tr("VM &List"));
     148}
     149
     150void UIWizardExportAppPageBasic1::initializePage()
     151{
     152    /* Translate page: */
     153    retranslateUi();
     154}
     155
     156bool UIWizardExportAppPageBasic1::isComplete() const
     157{
     158    /* There should be at least one vm selected: */
     159    return m_pVMSelector->selectedItems().size() > 0;
     160}
     161
     162bool UIWizardExportAppPageBasic1::validatePage()
     163{
     164    /* Initial result: */
     165    bool fResult = true;
     166
     167    /* Ask user about machines which are in save state currently: */
     168    QStringList savedMachines;
     169    QList<QListWidgetItem*> pItems = m_pVMSelector->selectedItems();
     170    for (int i=0; i < pItems.size(); ++i)
     171    {
     172        if (static_cast<VMListWidgetItem*>(pItems.at(i))->isInSaveState())
     173            savedMachines << pItems.at(i)->text();
     174    }
     175    if (!savedMachines.isEmpty())
     176        fResult = msgCenter().confirmExportMachinesInSaveState(savedMachines, this);
     177
     178    /* Return result: */
     179    return fResult;
     180}
     181
     182int UIWizardExportAppPageBasic1::nextId() const
     183{
     184    /* Skip next (2nd, storage-type) page for now! */
     185    return UIWizardExportApp::Page3;
     186}
     187
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic1.h

    r40870 r41021  
    2424
    2525/* Forward declarations: */
     26class QILabelSeparator;
     27class QListWidget;
    2628class QIRichTextLabel;
    27 class QListWidget;
    2829
    29 /* 1st page of the Export Appliance wizard: */
    30 class UIWizardExportAppPageBasic1 : public UIWizardPage
     30/* 1st page of the Export Appliance wizard (base part): */
     31class UIWizardExportAppPage1 : public UIWizardPageBase
     32{
     33protected:
     34
     35    /* Constructor: */
     36    UIWizardExportAppPage1();
     37
     38    /* Helping stuff: */
     39    void populateVMSelectorItems(const QStringList &selectedVMNames);
     40
     41    /* Stuff for 'machineNames' field: */
     42    QStringList machineNames() const;
     43
     44    /* Stuff for 'machineIDs' field: */
     45    QStringList machineIDs() const;
     46
     47    /* Widgets: */
     48    QILabelSeparator *m_pVMSelectorLabel;
     49    QListWidget *m_pVMSelector;
     50};
     51
     52/* 1st page of the Export Appliance wizard (basic extension): */
     53class UIWizardExportAppPageBasic1 : public UIWizardPage, public UIWizardExportAppPage1
    3154{
    3255    Q_OBJECT;
     
    5477    int nextId() const;
    5578
    56     /* Helping stuff: */
    57     void populateVMSelectorItems();
    58 
    59     /* Stuff for 'machineNames' field: */
    60     QStringList machineNames() const;
    61 
    62     /* Stuff for 'machineIDs' field: */
    63     QStringList machineIDs() const;
    64 
    65     /* Variables: */
    66     QStringList m_selectedVMNames;
    67 
    6879    /* Widgets: */
    6980    QIRichTextLabel *m_pLabel;
    70     QListWidget *m_pVMSelector;
    7181};
    7282
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.cpp

    r40870 r41021  
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QGroupBox>
    2223#include <QRadioButton>
    2324
     
    2728#include "QIRichTextLabel.h"
    2829
    29 UIWizardExportAppPageBasic2::UIWizardExportAppPageBasic2()
     30UIWizardExportAppPage2::UIWizardExportAppPage2()
    3031{
    31     /* Create widgets: */
    32     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    33         m_pLabel = new QIRichTextLabel(this);
    34         m_pTypeLocalFilesystem = new QRadioButton(this);
    35         m_pTypeSunCloud = new QRadioButton(this);
    36         m_pTypeSimpleStorageSystem = new QRadioButton(this);
    37     pMainLayout->addWidget(m_pLabel);
    38     pMainLayout->addWidget(m_pTypeLocalFilesystem);
    39     pMainLayout->addWidget(m_pTypeSunCloud);
    40     pMainLayout->addWidget(m_pTypeSimpleStorageSystem);
    41     pMainLayout->addStretch();
     32}
    4233
     34void UIWizardExportAppPage2::chooseDefaultStorageType()
     35{
    4336    /* Select default storage type: */
    4437#if 0
     
    5245    setStorageType(Filesystem);
    5346#endif
    54 
    55     /* Setup connections: */
    56     connect(m_pTypeLocalFilesystem, SIGNAL(clicked()), this, SIGNAL(completeChanged()));
    57     connect(m_pTypeSunCloud, SIGNAL(clicked()), this, SIGNAL(completeChanged()));
    58     connect(m_pTypeSimpleStorageSystem, SIGNAL(clicked()), this, SIGNAL(completeChanged()));
    59 
    60     /* Register StorageType class: */
    61     qRegisterMetaType<StorageType>();
    62     /* Register 'storageType' field! */
    63     registerField("storageType", this, "storageType");
    6447}
    6548
    66 void UIWizardExportAppPageBasic2::retranslateUi()
    67 {
    68     /* Translate page: */
    69     setTitle(UIWizardExportApp::tr("Appliance Export Settings"));
    70 
    71     /* Translate widgets: */
    72     m_pLabel->setText(UIWizardExportApp::tr("Please specify the target for the OVF export. "
    73                                             "You can choose between a local file system export, "
    74                                             "uploading the OVF to the Sun Cloud service "
    75                                             "or an S3 storage server."));
    76     m_pTypeLocalFilesystem->setText(UIWizardExportApp::tr("&Local Filesystem "));
    77     m_pTypeSunCloud->setText(UIWizardExportApp::tr("Sun &Cloud"));
    78     m_pTypeSimpleStorageSystem->setText(UIWizardExportApp::tr("&Simple Storage System (S3)"));
    79 }
    80 
    81 void UIWizardExportAppPageBasic2::initializePage()
    82 {
    83     /* Translate page: */
    84     retranslateUi();
    85 }
    86 
    87 StorageType UIWizardExportAppPageBasic2::storageType() const
     49StorageType UIWizardExportAppPage2::storageType() const
    8850{
    8951    if (m_pTypeSunCloud->isChecked())
     
    9456}
    9557
    96 void UIWizardExportAppPageBasic2::setStorageType(StorageType storageType)
     58void UIWizardExportAppPage2::setStorageType(StorageType storageType)
    9759{
    9860    switch (storageType)
     
    11375}
    11476
     77UIWizardExportAppPageBasic2::UIWizardExportAppPageBasic2()
     78{
     79    /* Create widgets: */
     80    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     81    {
     82        m_pLabel = new QIRichTextLabel(this);
     83        m_pTypeCnt = new QGroupBox(this);
     84        {
     85            QVBoxLayout *pTypeCntLayout = new QVBoxLayout(m_pTypeCnt);
     86            {
     87                m_pTypeLocalFilesystem = new QRadioButton(m_pTypeCnt);
     88                m_pTypeSunCloud = new QRadioButton(m_pTypeCnt);
     89                m_pTypeSimpleStorageSystem = new QRadioButton(m_pTypeCnt);
     90                pTypeCntLayout->addWidget(m_pTypeLocalFilesystem);
     91                pTypeCntLayout->addWidget(m_pTypeSunCloud);
     92                pTypeCntLayout->addWidget(m_pTypeSimpleStorageSystem);
     93            }
     94        }
     95        pMainLayout->addWidget(m_pLabel);
     96        pMainLayout->addWidget(m_pTypeCnt);
     97        pMainLayout->addStretch();
     98        chooseDefaultStorageType();
     99    }
     100
     101    /* Setup connections: */
     102    connect(m_pTypeLocalFilesystem, SIGNAL(clicked()), this, SIGNAL(completeChanged()));
     103    connect(m_pTypeSunCloud, SIGNAL(clicked()), this, SIGNAL(completeChanged()));
     104    connect(m_pTypeSimpleStorageSystem, SIGNAL(clicked()), this, SIGNAL(completeChanged()));
     105
     106    /* Register classes: */
     107    qRegisterMetaType<StorageType>();
     108    /* Register fields: */
     109    registerField("storageType", this, "storageType");
     110}
     111
     112void UIWizardExportAppPageBasic2::retranslateUi()
     113{
     114    /* Translate page: */
     115    setTitle(UIWizardExportApp::tr("Appliance Export Settings"));
     116
     117    /* Translate widgets: */
     118    m_pLabel->setText(UIWizardExportApp::tr("Please specify the target for the OVF export. "
     119                                            "You can choose between a local file system export, "
     120                                            "uploading the OVF to the Sun Cloud service "
     121                                            "or an S3 storage server."));
     122    m_pTypeCnt->setTitle(UIWizardExportApp::tr("&Destination"));
     123    m_pTypeLocalFilesystem->setText(UIWizardExportApp::tr("&Local Filesystem "));
     124    m_pTypeSunCloud->setText(UIWizardExportApp::tr("Sun &Cloud"));
     125    m_pTypeSimpleStorageSystem->setText(UIWizardExportApp::tr("&Simple Storage System (S3)"));
     126}
     127
     128void UIWizardExportAppPageBasic2::initializePage()
     129{
     130    /* Translate page: */
     131    retranslateUi();
     132}
     133
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic2.h

    r40870 r41021  
    2525
    2626/* Forward declarations: */
     27class QGroupBox;
     28class QRadioButton;
    2729class QIRichTextLabel;
    28 class QRadioButton;
    2930
    30 /* 2nd page of the Export Appliance wizard: */
    31 class UIWizardExportAppPageBasic2 : public UIWizardPage
     31/* 2nd page of the Export Appliance wizard (base part): */
     32class UIWizardExportAppPage2 : public UIWizardPageBase
     33{
     34protected:
     35
     36    /* Constructor: */
     37    UIWizardExportAppPage2();
     38
     39    /* Helpers: */
     40    void chooseDefaultStorageType();
     41
     42    /* Stuff for 'storageType' field: */
     43    StorageType storageType() const;
     44    void setStorageType(StorageType storageType);
     45
     46    /* Widgets: */
     47    QGroupBox *m_pTypeCnt;
     48    QRadioButton *m_pTypeLocalFilesystem;
     49    QRadioButton *m_pTypeSunCloud;
     50    QRadioButton *m_pTypeSimpleStorageSystem;
     51};
     52
     53/* 2nd page of the Export Appliance wizard (basic extension): */
     54class UIWizardExportAppPageBasic2 : public UIWizardPage, public UIWizardExportAppPage2
    3255{
    3356    Q_OBJECT;
     
    4770    void initializePage();
    4871
    49     /* Stuff for 'storageType' field: */
    50     StorageType storageType() const;
    51     void setStorageType(StorageType storageType);
    52 
    5372    /* Widgets: */
    5473    QIRichTextLabel *m_pLabel;
    55     QRadioButton *m_pTypeLocalFilesystem;
    56     QRadioButton *m_pTypeSunCloud;
    57     QRadioButton *m_pTypeSimpleStorageSystem;
    5874};
    5975
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp

    r40870 r41021  
    3131#include "UIWizardExportAppDefs.h"
    3232#include "VBoxGlobal.h"
     33#include "VBoxFilePathSelectorWidget.h"
    3334#include "QIRichTextLabel.h"
    34 #include "VBoxFilePathSelectorWidget.h"
     35
     36UIWizardExportAppPage3::UIWizardExportAppPage3()
     37{
     38}
     39
     40void UIWizardExportAppPage3::chooseDefaultSettings()
     41{
     42    /* Select default settings: */
     43#if 0
     44    m_pUsernameEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Username));
     45    m_pHostnameEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Hostname));
     46    m_pBucketEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Bucket));
     47#else
     48    /* Do nothing for now... */
     49#endif
     50}
     51
     52void UIWizardExportAppPage3::refreshCurrentSettings()
     53{
     54    /* Setup components for chosen storage-type: */
     55    StorageType storageType = fieldImp("storageType").value<StorageType>();
     56    switch (storageType)
     57    {
     58        case Filesystem:
     59        {
     60            m_pUsernameLabel->setVisible(false);
     61            m_pUsernameEditor->setVisible(false);
     62            m_pPasswordLabel->setVisible(false);
     63            m_pPasswordEditor->setVisible(false);
     64            m_pHostnameLabel->setVisible(false);
     65            m_pHostnameEditor->setVisible(false);
     66            m_pBucketLabel->setVisible(false);
     67            m_pBucketEditor->setVisible(false);
     68            m_pOVF09Checkbox->setVisible(true);
     69            m_pFileSelector->setChooserVisible(true);
     70            break;
     71        }
     72        case SunCloud:
     73        {
     74            m_pUsernameLabel->setVisible(true);
     75            m_pUsernameEditor->setVisible(true);
     76            m_pPasswordLabel->setVisible(true);
     77            m_pPasswordEditor->setVisible(true);
     78            m_pHostnameLabel->setVisible(false);
     79            m_pHostnameEditor->setVisible(false);
     80            m_pBucketLabel->setVisible(true);
     81            m_pBucketEditor->setVisible(true);
     82            m_pOVF09Checkbox->setVisible(false);
     83            m_pOVF09Checkbox->setChecked(false);
     84            m_pFileSelector->setChooserVisible(false);
     85            break;
     86        }
     87        case S3:
     88        {
     89            m_pUsernameLabel->setVisible(true);
     90            m_pUsernameEditor->setVisible(true);
     91            m_pPasswordLabel->setVisible(true);
     92            m_pPasswordEditor->setVisible(true);
     93            m_pHostnameLabel->setVisible(true);
     94            m_pHostnameEditor->setVisible(true);
     95            m_pBucketLabel->setVisible(true);
     96            m_pBucketEditor->setVisible(true);
     97            m_pOVF09Checkbox->setVisible(true);
     98            m_pFileSelector->setChooserVisible(false);
     99            break;
     100        }
     101    }
     102
     103    /* Use the default filename: */
     104    QString strName = m_strDefaultApplianceName;
     105    /* If it is one VM only, we use the VM name as filename: */
     106    if (fieldImp("machineNames").toStringList().size() == 1)
     107        strName = fieldImp("machineNames").toStringList()[0];
     108    strName += ".ova";
     109    if (storageType == Filesystem)
     110        strName = QDir::toNativeSeparators(QString("%1/%2").arg(vboxGlobal().documentsPath()).arg(strName));
     111    m_pFileSelector->setPath(strName);
     112}
     113
     114bool UIWizardExportAppPage3::isOVF09Selected() const
     115{
     116    return m_pOVF09Checkbox->isChecked();
     117}
     118
     119void UIWizardExportAppPage3::setOVF09Selected(bool fChecked)
     120{
     121    m_pOVF09Checkbox->setChecked(fChecked);
     122}
     123
     124bool UIWizardExportAppPage3::isManifestSelected() const
     125{
     126    return m_pManifestCheckbox->isChecked();
     127}
     128
     129void UIWizardExportAppPage3::setManifestSelected(bool fChecked)
     130{
     131    m_pManifestCheckbox->setChecked(fChecked);
     132}
     133
     134QString UIWizardExportAppPage3::username() const
     135{
     136    return m_pUsernameEditor->text();
     137}
     138
     139void UIWizardExportAppPage3::setUserName(const QString &strUserName)
     140{
     141    m_pUsernameEditor->setText(strUserName);
     142}
     143
     144QString UIWizardExportAppPage3::password() const
     145{
     146    return m_pPasswordEditor->text();
     147}
     148
     149void UIWizardExportAppPage3::setPassword(const QString &strPassword)
     150{
     151    m_pPasswordEditor->setText(strPassword);
     152}
     153
     154QString UIWizardExportAppPage3::hostname() const
     155{
     156    return m_pHostnameEditor->text();
     157}
     158
     159void UIWizardExportAppPage3::setHostname(const QString &strHostname)
     160{
     161    m_pHostnameEditor->setText(strHostname);
     162}
     163
     164QString UIWizardExportAppPage3::bucket() const
     165{
     166    return m_pBucketEditor->text();
     167}
     168
     169void UIWizardExportAppPage3::setBucket(const QString &strBucket)
     170{
     171    m_pBucketEditor->setText(strBucket);
     172}
     173
     174QString UIWizardExportAppPage3::path() const
     175{
     176    return m_pFileSelector->path();
     177}
     178
     179void UIWizardExportAppPage3::setPath(const QString &strPath)
     180{
     181    m_pFileSelector->setPath(strPath);
     182}
    35183
    36184UIWizardExportAppPageBasic3::UIWizardExportAppPageBasic3()
     
    38186    /* Create widgets: */
    39187    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     188    {
    40189        m_pLabel = new QIRichTextLabel(this);
    41190        QGridLayout *pSettingsLayout = new QGridLayout;
     191        {
    42192            m_pUsernameEditor = new QLineEdit(this);
    43                 //m_pUsernameEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Username));
    44193            m_pUsernameLabel = new QLabel(this);
     194            {
    45195                m_pUsernameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    46196                m_pUsernameLabel->setBuddy(m_pUsernameEditor);
     197            }
    47198            m_pPasswordEditor = new QLineEdit(this);
     199            {
    48200                m_pPasswordEditor->setEchoMode(QLineEdit::Password);
     201            }
    49202            m_pPasswordLabel = new QLabel(this);
     203            {
    50204                m_pPasswordLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    51205                m_pPasswordLabel->setBuddy(m_pPasswordEditor);
     206            }
    52207            m_pHostnameEditor = new QLineEdit(this);
    53                 //m_pHostnameEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Hostname));
    54208            m_pHostnameLabel = new QLabel(this);
     209            {
    55210                m_pHostnameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    56211                m_pHostnameLabel->setBuddy(m_pHostnameEditor);
     212            }
    57213            m_pBucketEditor = new QLineEdit(this);
    58                 //m_pBucketEditor->setText(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_Export_Bucket));
    59214            m_pBucketLabel = new QLabel(this);
     215            {
    60216                m_pBucketLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    61217                m_pBucketLabel->setBuddy(m_pBucketEditor);
     218            }
    62219            m_pFileSelector = new VBoxEmptyFileSelector(this);
     220            {
    63221                m_pFileSelector->setMode(VBoxFilePathSelectorWidget::Mode_File_Save);
    64222                m_pFileSelector->setEditable(true);
    65223                m_pFileSelector->setButtonPosition(VBoxEmptyFileSelector::RightPosition);
    66224                m_pFileSelector->setDefaultSaveExt("ova");
     225            }
    67226            m_pFileSelectorLabel = new QLabel(this);
     227            {
    68228                m_pFileSelectorLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
    69229                m_pFileSelectorLabel->setBuddy(m_pFileSelector);
    70         pSettingsLayout->addWidget(m_pUsernameLabel, 0, 0);
    71         pSettingsLayout->addWidget(m_pUsernameEditor, 0, 1);
    72         pSettingsLayout->addWidget(m_pPasswordLabel, 1, 0);
    73         pSettingsLayout->addWidget(m_pPasswordEditor, 1, 1);
    74         pSettingsLayout->addWidget(m_pHostnameLabel, 2, 0);
    75         pSettingsLayout->addWidget(m_pHostnameEditor, 2, 1);
    76         pSettingsLayout->addWidget(m_pBucketLabel, 3, 0);
    77         pSettingsLayout->addWidget(m_pBucketEditor, 3, 1);
    78         pSettingsLayout->addWidget(m_pFileSelectorLabel, 4, 0);
    79         pSettingsLayout->addWidget(m_pFileSelector, 4, 1);
     230            }
     231            pSettingsLayout->addWidget(m_pUsernameLabel, 0, 0);
     232            pSettingsLayout->addWidget(m_pUsernameEditor, 0, 1);
     233            pSettingsLayout->addWidget(m_pPasswordLabel, 1, 0);
     234            pSettingsLayout->addWidget(m_pPasswordEditor, 1, 1);
     235            pSettingsLayout->addWidget(m_pHostnameLabel, 2, 0);
     236            pSettingsLayout->addWidget(m_pHostnameEditor, 2, 1);
     237            pSettingsLayout->addWidget(m_pBucketLabel, 3, 0);
     238            pSettingsLayout->addWidget(m_pBucketEditor, 3, 1);
     239            pSettingsLayout->addWidget(m_pFileSelectorLabel, 4, 0);
     240            pSettingsLayout->addWidget(m_pFileSelector, 4, 1);
     241        }
    80242        m_pOVF09Checkbox = new QCheckBox(this);
    81243        m_pManifestCheckbox = new QCheckBox(this);
    82     pMainLayout->addWidget(m_pLabel);
    83     pMainLayout->addLayout(pSettingsLayout);
    84     pMainLayout->addWidget(m_pOVF09Checkbox);
    85     pMainLayout->addWidget(m_pManifestCheckbox);
    86     pMainLayout->addStretch();
     244        pMainLayout->addWidget(m_pLabel);
     245        pMainLayout->addLayout(pSettingsLayout);
     246        pMainLayout->addWidget(m_pOVF09Checkbox);
     247        pMainLayout->addWidget(m_pManifestCheckbox);
     248        pMainLayout->addStretch();
     249        chooseDefaultSettings();
     250    }
    87251
    88252    /* Setup connections: */
     
    108272    setTitle(UIWizardExportApp::tr("Appliance Export Settings"));
    109273
    110     /* Translate defaults: */
     274    /* Translate objects: */
    111275    m_strDefaultApplianceName = UIWizardExportApp::tr("Appliance");
    112276    /* Translate widgets: */
     
    130294    retranslateUi();
    131295
    132     /* Setup components for chosen storage-type */
     296    /* Refresh current settings: */
     297    refreshCurrentSettings();
     298}
     299
     300bool UIWizardExportAppPageBasic3::isComplete() const
     301{
     302    /* Initial result: */
     303    bool fResult = true;
     304
     305    /* Check storage-type attributes: */
     306    if (fResult)
     307    {
     308        const QString &strFile = m_pFileSelector->path().toLower();
     309        fResult = VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts);
     310        if (fResult)
     311        {
     312            StorageType storageType = field("storageType").value<StorageType>();
     313            switch (storageType)
     314            {
     315                case Filesystem:
     316                    break;
     317                case SunCloud:
     318                    fResult &= !m_pUsernameEditor->text().isEmpty() &&
     319                               !m_pPasswordEditor->text().isEmpty() &&
     320                               !m_pBucketEditor->text().isEmpty();
     321                    break;
     322                case S3:
     323                    fResult &= !m_pUsernameEditor->text().isEmpty() &&
     324                               !m_pPasswordEditor->text().isEmpty() &&
     325                               !m_pHostnameEditor->text().isEmpty() &&
     326                               !m_pBucketEditor->text().isEmpty();
     327                    break;
     328            }
     329        }
     330    }
     331
     332    /* Return result: */
     333    return fResult;
     334}
     335
     336void UIWizardExportAppPageBasic3::refreshCurrentSettings()
     337{
     338    /* Refresh base-class settings: */
     339    UIWizardExportAppPage3::refreshCurrentSettings();
     340
     341    /* Setup components for chosen storage-type: */
    133342    StorageType storageType = field("storageType").value<StorageType>();
    134343    switch (storageType)
     
    141350                                 "If you use an <i>ovf</i> extension, several files "
    142351                                 "will be written separately. Other extensions are not allowed."));
    143             m_pUsernameLabel->setVisible(false);
    144             m_pUsernameEditor->setVisible(false);
    145             m_pPasswordLabel->setVisible(false);
    146             m_pPasswordEditor->setVisible(false);
    147             m_pHostnameLabel->setVisible(false);
    148             m_pHostnameEditor->setVisible(false);
    149             m_pBucketLabel->setVisible(false);
    150             m_pBucketEditor->setVisible(false);
    151             m_pOVF09Checkbox->setVisible(true);
    152             m_pFileSelector->setChooserVisible(true);
    153352            m_pFileSelector->setFocus();
    154353            break;
     
    158357            m_pLabel->setText(tr("Please complete the additional fields like the username, password "
    159358                                 "and the bucket, and provide a filename for the OVF target."));
    160             m_pUsernameLabel->setVisible(true);
    161             m_pUsernameEditor->setVisible(true);
    162             m_pPasswordLabel->setVisible(true);
    163             m_pPasswordEditor->setVisible(true);
    164             m_pHostnameLabel->setVisible(false);
    165             m_pHostnameEditor->setVisible(false);
    166             m_pBucketLabel->setVisible(true);
    167             m_pBucketEditor->setVisible(true);
    168             m_pOVF09Checkbox->setVisible(false);
    169             m_pOVF09Checkbox->setChecked(false);
    170             m_pFileSelector->setChooserVisible(false);
    171359            m_pUsernameEditor->setFocus();
    172360            break;
     
    176364            m_pLabel->setText(tr("Please complete the additional fields like the username, password, "
    177365                                 "hostname and the bucket, and provide a filename for the OVF target."));
    178             m_pUsernameLabel->setVisible(true);
    179             m_pUsernameEditor->setVisible(true);
    180             m_pPasswordLabel->setVisible(true);
    181             m_pPasswordEditor->setVisible(true);
    182             m_pHostnameLabel->setVisible(true);
    183             m_pHostnameEditor->setVisible(true);
    184             m_pBucketLabel->setVisible(true);
    185             m_pBucketEditor->setVisible(true);
    186             m_pOVF09Checkbox->setVisible(true);
    187             m_pFileSelector->setChooserVisible(false);
    188366            m_pUsernameEditor->setFocus();
    189367            break;
    190368        }
    191369    }
    192 
    193     if (!m_pFileSelector->path().isEmpty())
    194     {
    195         QFileInfo fi(m_pFileSelector->path());
    196         QString strName = fi.fileName();
    197         if (storageType == Filesystem)
    198             strName = QDir::toNativeSeparators(QString("%1/%2").arg(vboxGlobal().documentsPath()).arg(strName));
    199         m_pFileSelector->setPath(strName);
    200     }
    201 
    202     if (m_pFileSelector->path().isEmpty())
    203     {
    204         /* Set the default filename: */
    205         QString strName = m_strDefaultApplianceName;
    206         /* If it is one VM only, we use the VM name as file name: */
    207         if (field("machineNames").toStringList().size() == 1)
    208             strName = field("machineNames").toStringList()[0];
    209 
    210         strName += ".ova";
    211 
    212         if (storageType == Filesystem)
    213             strName = QDir::toNativeSeparators(QString("%1/%2").arg(vboxGlobal().documentsPath()).arg(strName));
    214         m_pFileSelector->setPath(strName);
    215     }
    216 }
    217 
    218 bool UIWizardExportAppPageBasic3::isComplete() const
    219 {
    220     const QString &strFile = m_pFileSelector->path().toLower();
    221     bool bComplete = VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts);
    222     StorageType storageType = field("storageType").value<StorageType>();
    223     switch (storageType)
    224     {
    225         case Filesystem:
    226             break;
    227         case SunCloud:
    228             bComplete &= !m_pUsernameEditor->text().isEmpty() && !m_pPasswordEditor->text().isEmpty() &&
    229                          !m_pBucketEditor->text().isEmpty();
    230             break;
    231         case S3:
    232             bComplete &= !m_pUsernameEditor->text().isEmpty() && !m_pPasswordEditor->text().isEmpty() &&
    233                          !m_pHostnameEditor->text().isEmpty() && !m_pBucketEditor->text().isEmpty();
    234             break;
    235     }
    236     return bComplete;
    237 }
    238 
    239 bool UIWizardExportAppPageBasic3::isOVF09Selected() const
    240 {
    241     return m_pOVF09Checkbox->isChecked();
    242 }
    243 
    244 void UIWizardExportAppPageBasic3::setOVF09Selected(bool fChecked)
    245 {
    246     m_pOVF09Checkbox->setChecked(fChecked);
    247 }
    248 
    249 bool UIWizardExportAppPageBasic3::isManifestSelected() const
    250 {
    251     return m_pManifestCheckbox->isChecked();
    252 }
    253 
    254 void UIWizardExportAppPageBasic3::setManifestSelected(bool fChecked)
    255 {
    256     m_pManifestCheckbox->setChecked(fChecked);
    257 }
    258 
    259 QString UIWizardExportAppPageBasic3::username() const
    260 {
    261     return m_pUsernameEditor->text();
    262 }
    263 
    264 void UIWizardExportAppPageBasic3::setUserName(const QString &strUserName)
    265 {
    266     m_pUsernameEditor->setText(strUserName);
    267 }
    268 
    269 QString UIWizardExportAppPageBasic3::password() const
    270 {
    271     return m_pPasswordEditor->text();
    272 }
    273 
    274 void UIWizardExportAppPageBasic3::setPassword(const QString &strPassword)
    275 {
    276     m_pPasswordEditor->setText(strPassword);
    277 }
    278 
    279 QString UIWizardExportAppPageBasic3::hostname() const
    280 {
    281     return m_pHostnameEditor->text();
    282 }
    283 
    284 void UIWizardExportAppPageBasic3::setHostname(const QString &strHostname)
    285 {
    286     m_pHostnameEditor->setText(strHostname);
    287 }
    288 
    289 QString UIWizardExportAppPageBasic3::bucket() const
    290 {
    291     return m_pBucketEditor->text();
    292 }
    293 
    294 void UIWizardExportAppPageBasic3::setBucket(const QString &strBucket)
    295 {
    296     m_pBucketEditor->setText(strBucket);
    297 }
    298 
    299 QString UIWizardExportAppPageBasic3::path() const
    300 {
    301     return m_pFileSelector->path();
    302 }
    303 
    304 void UIWizardExportAppPageBasic3::setPath(const QString &strPath)
    305 {
    306     m_pFileSelector->setPath(strPath);
    307 }
    308 
     370}
     371
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.h

    r40870 r41021  
    2020#define __UIWizardExportAppPageBasic3_h__
    2121
     22/* Global includes: */
     23#include <QVariant>
     24
    2225/* Local includes: */
    2326#include "UIWizardPage.h"
    2427
    2528/* Forward declarations: */
    26 class QIRichTextLabel;
    2729class QLabel;
    2830class QLineEdit;
    2931class VBoxEmptyFileSelector;
    3032class QCheckBox;
     33class QIRichTextLabel;
    3134
    32 /* 3rd page of the Export Appliance wizard: */
    33 class UIWizardExportAppPageBasic3 : public UIWizardPage
     35/* 3rd page of the Export Appliance wizard (base part): */
     36class UIWizardExportAppPage3 : public UIWizardPageBase
    3437{
    35     Q_OBJECT;
    36     Q_PROPERTY(bool OVF09Selected READ isOVF09Selected WRITE setOVF09Selected);
    37     Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected);
    38     Q_PROPERTY(QString username READ username WRITE setUserName);
    39     Q_PROPERTY(QString password READ password WRITE setPassword);
    40     Q_PROPERTY(QString hostname READ hostname WRITE setHostname);
    41     Q_PROPERTY(QString bucket READ bucket WRITE setBucket);
    42     Q_PROPERTY(QString path READ path WRITE setPath);
    43 
    44 public:
     38protected:
    4539
    4640    /* Constructor: */
    47     UIWizardExportAppPageBasic3();
     41    UIWizardExportAppPage3();
    4842
    49 private:
    50 
    51     /* Translate stuff: */
    52     void retranslateUi();
    53 
    54     /* Prepare stuff: */
    55     void initializePage();
    56 
    57     /* Validation stuff: */
    58     bool isComplete() const;
     43    /* Helpers: */
     44    void chooseDefaultSettings();
     45    virtual void refreshCurrentSettings();
    5946
    6047    /* Stuff for 'OVF09Selected' field: */
     
    8471
    8572    /* Widgets: */
    86     QIRichTextLabel *m_pLabel;
    8773    QLabel *m_pUsernameLabel;
    8874    QLineEdit *m_pUsernameEditor;
     
    9985};
    10086
     87/* 3rd page of the Export Appliance wizard (basic extension): */
     88class UIWizardExportAppPageBasic3 : public UIWizardPage, public UIWizardExportAppPage3
     89{
     90    Q_OBJECT;
     91    Q_PROPERTY(bool OVF09Selected READ isOVF09Selected WRITE setOVF09Selected);
     92    Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected);
     93    Q_PROPERTY(QString username READ username WRITE setUserName);
     94    Q_PROPERTY(QString password READ password WRITE setPassword);
     95    Q_PROPERTY(QString hostname READ hostname WRITE setHostname);
     96    Q_PROPERTY(QString bucket READ bucket WRITE setBucket);
     97    Q_PROPERTY(QString path READ path WRITE setPath);
     98
     99public:
     100
     101    /* Constructor: */
     102    UIWizardExportAppPageBasic3();
     103
     104protected:
     105
     106    /* Wrapper to access 'wizard-field' from base part: */
     107    QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
     108
     109private:
     110
     111    /* Translate stuff: */
     112    void retranslateUi();
     113
     114    /* Prepare stuff: */
     115    void initializePage();
     116
     117    /* Validation stuff: */
     118    bool isComplete() const;
     119
     120    /* Helpers: */
     121    void refreshCurrentSettings();
     122
     123    /* Widgets: */
     124    QIRichTextLabel *m_pLabel;
     125};
     126
    101127#endif /* __UIWizardExportAppPageBasic3_h__ */
    102128
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic4.cpp

    r40870 r41021  
    2626#include "VBoxGlobal.h"
    2727#include "UIMessageCenter.h"
     28#include "QILabelSeparator.h"
    2829#include "QIRichTextLabel.h"
    2930
    30 UIWizardExportAppPageBasic4::UIWizardExportAppPageBasic4()
     31UIWizardExportAppPage4::UIWizardExportAppPage4()
    3132{
    32     /* Create widgets: */
    33     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    34         m_pLabel = new QIRichTextLabel(this);
    35         m_pApplianceWidget = new UIApplianceExportEditorWidget(this);
    36             m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
    37     pMainLayout->addWidget(m_pLabel);
    38     pMainLayout->addWidget(m_pApplianceWidget);
    39 
    40     /* Register ExportAppliancePointer class: */
    41     qRegisterMetaType<ExportAppliancePointer>();
    42     /* Register 'applianceWidget' field! */
    43     registerField("applianceWidget", this, "applianceWidget");
    4433}
    4534
    46 void UIWizardExportAppPageBasic4::retranslateUi()
     35void UIWizardExportAppPage4::refreshApplianceSettingsWidget()
    4736{
    48     /* Translate page: */
    49     setTitle(UIWizardExportApp::tr("Appliance Export Settings"));
    50 
    51     /* Translate widgets: */
    52     m_pLabel->setText(UIWizardExportApp::tr("Here you can change additional configuration "
    53                                             "values of the selected virtual machines. "
    54                                             "You can modify most of the properties shown "
    55                                             "by double-clicking on the items."));
    56 }
    57 
    58 void UIWizardExportAppPageBasic4::initializePage()
    59 {
    60     /* Translate page: */
    61     retranslateUi();
    62 
    63     /* Prepare settings widget: */
     37    /* Refresh settings widget: */
    6438    CVirtualBox vbox = vboxGlobal().virtualBox();
    6539    CAppliance *pAppliance = m_pApplianceWidget->init();
     
    6842    {
    6943        /* Iterate over all the selected machine ids: */
    70         QStringList uuids = field("machineIDs").toStringList();
     44        QStringList uuids = fieldImp("machineIDs").toStringList();
    7145        foreach (const QString &uuid, uuids)
    7246        {
     
    7751            {
    7852                /* Add the export description to our appliance object: */
    79                 CVirtualSystemDescription vsd = machine.Export(*pAppliance, qobject_cast<UIWizardExportApp*>(wizard())->uri());
     53                CVirtualSystemDescription vsd = machine.Export(*pAppliance, qobject_cast<UIWizardExportApp*>(wizardImp())->uri());
    8054                fResult = machine.isOk();
    8155                if (!fResult)
    8256                {
    83                     msgCenter().cannotExportAppliance(machine, pAppliance, this);
     57                    msgCenter().cannotExportAppliance(machine, pAppliance, thisImp());
    8458                    return;
    8559                }
     
    9973    }
    10074    if (!fResult)
    101         msgCenter().cannotExportAppliance(pAppliance, this);
     75        msgCenter().cannotExportAppliance(pAppliance, thisImp());
     76}
     77
     78UIWizardExportAppPageBasic4::UIWizardExportAppPageBasic4()
     79{
     80    /* Create widgets: */
     81    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     82    {
     83        m_pLabel = new QIRichTextLabel(this);
     84        m_pVMApplianceLabel = new QILabelSeparator(this);
     85        {
     86            m_pVMApplianceLabel->hide();
     87        }
     88        m_pApplianceWidget = new UIApplianceExportEditorWidget(this);
     89        {
     90            m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
     91            m_pVMApplianceLabel->setBuddy(m_pApplianceWidget);
     92        }
     93        pMainLayout->addWidget(m_pLabel);
     94        pMainLayout->addWidget(m_pVMApplianceLabel);
     95        pMainLayout->addWidget(m_pApplianceWidget);
     96    }
     97
     98    /* Register classes: */
     99    qRegisterMetaType<ExportAppliancePointer>();
     100    /* Register fields: */
     101    registerField("applianceWidget", this, "applianceWidget");
     102}
     103
     104void UIWizardExportAppPageBasic4::retranslateUi()
     105{
     106    /* Translate page: */
     107    setTitle(UIWizardExportApp::tr("Appliance Export Settings"));
     108
     109    /* Translate widgets: */
     110    m_pLabel->setText(UIWizardExportApp::tr("Here you can change additional configuration "
     111                                            "values of the selected virtual machines. "
     112                                            "You can modify most of the properties shown "
     113                                            "by double-clicking on the items."));
     114    m_pVMApplianceLabel->setText(UIWizardExportApp::tr("&Settings"));
     115}
     116
     117void UIWizardExportAppPageBasic4::initializePage()
     118{
     119    /* Translate page: */
     120    retranslateUi();
     121
     122    /* Refresh appliance settings widget: */
     123    refreshApplianceSettingsWidget();
    102124}
    103125
    104126bool UIWizardExportAppPageBasic4::validatePage()
    105127{
     128    /* Initial result: */
     129    bool fResult = true;
     130
     131    /* Lock finish button: */
     132    startProcessing();
     133
    106134    /* Try to export appliance: */
    107     startProcessing();
    108     bool fResult = qobject_cast<UIWizardExportApp*>(wizard())->exportAppliance();
     135    if (fResult)
     136        fResult = qobject_cast<UIWizardExportApp*>(wizard())->exportAppliance();
     137
     138    /* Unlock finish button: */
    109139    endProcessing();
     140
     141    /* Return result: */
    110142    return fResult;
    111143}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic4.h

    r40870 r41021  
    2020#define __UIWizardExportAppPageBasic4_h__
    2121
     22/* Global includes: */
     23#include <QVariant>
     24
    2225/* Local includes: */
    2326#include "UIWizardPage.h"
     
    2528
    2629/* Forward declarations: */
     30class QILabelSeparator;
     31class UIWizardExportApp;
    2732class QIRichTextLabel;
    2833
    29 /* 4th page of the Export Appliance wizard: */
    30 class UIWizardExportAppPageBasic4 : public UIWizardPage
     34/* 4th page of the Export Appliance wizard (base part): */
     35class UIWizardExportAppPage4 : public UIWizardPageBase
     36{
     37protected:
     38
     39    /* Constructor: */
     40    UIWizardExportAppPage4();
     41
     42    /* Helpers: */
     43    void refreshApplianceSettingsWidget(    );
     44
     45    /* Stuff for 'applianceWidget' field: */
     46    ExportAppliancePointer applianceWidget() const { return m_pApplianceWidget; }
     47
     48    /* Widgets: */
     49    QILabelSeparator *m_pVMApplianceLabel;
     50    UIApplianceExportEditorWidget *m_pApplianceWidget;
     51};
     52
     53/* 4th page of the Export Appliance wizard (basic extension): */
     54class UIWizardExportAppPageBasic4 : public UIWizardPage, public UIWizardExportAppPage4
    3155{
    3256    Q_OBJECT;
     
    3761    /* Constructor: */
    3862    UIWizardExportAppPageBasic4();
     63
     64protected:
     65
     66    /* Wrapper to access 'wizard' from base part: */
     67    UIWizard* wizardImp() { return UIWizardPage::wizard(); }
     68    /* Wrapper to access 'this' from base part: */
     69    UIWizardPage* thisImp() { return this; }
     70    /* Wrapper to access 'wizard-field' from base part: */
     71    QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
    3972
    4073private:
     
    4982    bool validatePage();
    5083
    51     /* Stuff for 'applianceWidget' field: */
    52     ExportAppliancePointer applianceWidget() const { return m_pApplianceWidget; }
    53 
    5484    /* Widgets: */
    5585    QIRichTextLabel *m_pLabel;
    56     UIApplianceExportEditorWidget *m_pApplianceWidget;
    5786};
    5887
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.cpp

    r40929 r41021  
    33 *
    44 * VBox frontends: Qt4 GUI ("VirtualBox"):
    5  * UIWizardExportAppPageBasic1 class implementation
     5 * UIWizardExportAppPageExpert class implementation
    66 */
    77
     
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QGridLayout>
    2223#include <QListWidget>
     24#include <QGroupBox>
     25#include <QRadioButton>
     26#include <QLineEdit>
     27#include <QLabel>
     28#include <QCheckBox>
    2329
    2430/* Local includes: */
    25 #include "UIWizardExportAppPageBasic1.h"
     31#include "UIWizardExportAppPageExpert.h"
    2632#include "UIWizardExportApp.h"
     33#include "UIWizardExportAppDefs.h"
    2734#include "VBoxGlobal.h"
    2835#include "UIMessageCenter.h"
    29 #include "QIRichTextLabel.h"
    30 
    31 class VMListWidgetItems : public QListWidgetItem
    32 {
    33 public:
    34 
    35     VMListWidgetItems(QPixmap &pixIcon, QString &strText, QString strUuid, bool fInSaveState, QListWidget *pParent)
    36         : QListWidgetItem(pixIcon, strText, pParent)
    37         , m_strUuid(strUuid)
    38         , m_fInSaveState(fInSaveState)
     36#include "QILabelSeparator.h"
     37#include "VBoxFilePathSelectorWidget.h"
     38#include "UIApplianceExportEditorWidget.h"
     39
     40UIWizardExportAppPageExpert::UIWizardExportAppPageExpert(const QStringList &selectedVMNames)
     41{
     42    /* Create widgets: */
     43    QGridLayout *pMainLayout = new QGridLayout(this);
    3944    {
    40     }
    41 
    42     bool operator<(const QListWidgetItem &other) const
    43     {
    44         return text().toLower() < other.text().toLower();
    45     }
    46 
    47     QString uuid() { return m_strUuid; }
    48     bool isInSaveState() { return m_fInSaveState; }
    49 
    50 private:
    51 
    52     QString m_strUuid;
    53     bool m_fInSaveState;
    54 };
    55 
    56 UIWizardExportAppPageBasic1::UIWizardExportAppPageBasic1(const QStringList &selectedVMNames)
    57     : m_selectedVMNames(selectedVMNames)
    58 {
    59     /* Create widgets: */
    60     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    61         m_pLabel = new QIRichTextLabel(this);
     45        pMainLayout->setContentsMargins(8, 6, 8, 6);
     46        m_pVMSelectorLabel = new QILabelSeparator(this);
    6247        m_pVMSelector = new QListWidget(this);
     48        {
    6349            m_pVMSelector->setAlternatingRowColors(true);
    6450            m_pVMSelector->setSelectionMode(QAbstractItemView::ExtendedSelection);
    65             populateVMSelectorItems();
    66     pMainLayout->addWidget(m_pLabel);
    67     pMainLayout->addWidget(m_pVMSelector);
    68 
    69     /* Choose initially selected items (if passed): */
    70     for (int i = 0; i < m_selectedVMNames.size(); ++i)
    71     {
    72         QList<QListWidgetItem*> list = m_pVMSelector->findItems(m_selectedVMNames[i], Qt::MatchExactly);
    73         if (list.size() > 0)
    74         {
    75             if (m_pVMSelector->selectedItems().isEmpty())
    76                 m_pVMSelector->setCurrentItem(list.first());
    77             else
    78                 list.first()->setSelected(true);
    79         }
     51            m_pVMSelectorLabel->setBuddy(m_pVMSelector);
     52        }
     53        m_pVMApplianceLabel = new QILabelSeparator(this);
     54        m_pApplianceWidget = new UIApplianceExportEditorWidget(this);
     55        {
     56            m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
     57            m_pVMApplianceLabel->setBuddy(m_pApplianceWidget);
     58        }
     59        m_pTypeCnt = new QGroupBox(this);
     60        {
     61            m_pTypeCnt->hide();
     62            QVBoxLayout *pTypeCntLayout = new QVBoxLayout(m_pTypeCnt);
     63            {
     64                m_pTypeLocalFilesystem = new QRadioButton(m_pTypeCnt);
     65                m_pTypeSunCloud = new QRadioButton(m_pTypeCnt);
     66                m_pTypeSimpleStorageSystem = new QRadioButton(m_pTypeCnt);
     67                pTypeCntLayout->addWidget(m_pTypeLocalFilesystem);
     68                pTypeCntLayout->addWidget(m_pTypeSunCloud);
     69                pTypeCntLayout->addWidget(m_pTypeSimpleStorageSystem);
     70            }
     71        }
     72        QGridLayout *pSettingsLayout = new QGridLayout;
     73        {
     74            m_pUsernameEditor = new QLineEdit(this);
     75            m_pUsernameLabel = new QLabel(this);
     76            {
     77                m_pUsernameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
     78                m_pUsernameLabel->setBuddy(m_pUsernameEditor);
     79            }
     80            m_pPasswordEditor = new QLineEdit(this);
     81            {
     82                m_pPasswordEditor->setEchoMode(QLineEdit::Password);
     83            }
     84            m_pPasswordLabel = new QLabel(this);
     85            {
     86                m_pPasswordLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
     87                m_pPasswordLabel->setBuddy(m_pPasswordEditor);
     88            }
     89            m_pHostnameEditor = new QLineEdit(this);
     90            m_pHostnameLabel = new QLabel(this);
     91            {
     92                m_pHostnameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
     93                m_pHostnameLabel->setBuddy(m_pHostnameEditor);
     94            }
     95            m_pBucketEditor = new QLineEdit(this);
     96            m_pBucketLabel = new QLabel(this);
     97            {
     98                m_pBucketLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
     99                m_pBucketLabel->setBuddy(m_pBucketEditor);
     100            }
     101            m_pFileSelector = new VBoxEmptyFileSelector(this);
     102            {
     103                m_pFileSelector->setMode(VBoxFilePathSelectorWidget::Mode_File_Save);
     104                m_pFileSelector->setEditable(true);
     105                m_pFileSelector->setButtonPosition(VBoxEmptyFileSelector::RightPosition);
     106                m_pFileSelector->setDefaultSaveExt("ova");
     107            }
     108            m_pFileSelectorLabel = new QLabel(this);
     109            {
     110                m_pFileSelectorLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
     111                m_pFileSelectorLabel->setBuddy(m_pFileSelector);
     112            }
     113            pSettingsLayout->addWidget(m_pUsernameLabel, 0, 0);
     114            pSettingsLayout->addWidget(m_pUsernameEditor, 0, 1);
     115            pSettingsLayout->addWidget(m_pPasswordLabel, 1, 0);
     116            pSettingsLayout->addWidget(m_pPasswordEditor, 1, 1);
     117            pSettingsLayout->addWidget(m_pHostnameLabel, 2, 0);
     118            pSettingsLayout->addWidget(m_pHostnameEditor, 2, 1);
     119            pSettingsLayout->addWidget(m_pBucketLabel, 3, 0);
     120            pSettingsLayout->addWidget(m_pBucketEditor, 3, 1);
     121            pSettingsLayout->addWidget(m_pFileSelectorLabel, 4, 0);
     122            pSettingsLayout->addWidget(m_pFileSelector, 4, 1);
     123        }
     124        m_pOVF09Checkbox = new QCheckBox(this);
     125        m_pManifestCheckbox = new QCheckBox(this);
     126        pMainLayout->addWidget(m_pVMSelectorLabel, 0, 0);
     127        pMainLayout->addWidget(m_pVMApplianceLabel, 0, 1);
     128        pMainLayout->addWidget(m_pVMSelector, 1, 0);
     129        pMainLayout->addWidget(m_pApplianceWidget, 1, 1);
     130        pMainLayout->addWidget(m_pTypeCnt, 2, 0, 1, 2);
     131        pMainLayout->addLayout(pSettingsLayout, 3, 0, 1, 2);
     132        pMainLayout->addWidget(m_pOVF09Checkbox, 4, 0, 1, 2);
     133        pMainLayout->addWidget(m_pManifestCheckbox, 5, 0, 1, 2);
     134        populateVMSelectorItems(selectedVMNames);
     135        chooseDefaultStorageType();
     136        chooseDefaultSettings();
    80137    }
    81138
    82139    /* Setup connections: */
    83     connect(m_pVMSelector, SIGNAL(itemSelectionChanged()), this, SIGNAL(completeChanged()));
    84 
    85     /* Register 'machineNames', 'machineIDs' fields! */
     140    connect(m_pVMSelector, SIGNAL(itemSelectionChanged()), this, SLOT(sltVMSelectionChangeHandler()));
     141    connect(m_pTypeLocalFilesystem, SIGNAL(clicked()), this, SLOT(sltStorageTypeChangeHandler()));
     142    connect(m_pTypeSunCloud, SIGNAL(clicked()), this, SLOT(sltStorageTypeChangeHandler()));
     143    connect(m_pTypeSimpleStorageSystem, SIGNAL(clicked()), this, SLOT(sltStorageTypeChangeHandler()));
     144    connect(m_pUsernameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
     145    connect(m_pPasswordEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
     146    connect(m_pHostnameEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
     147    connect(m_pBucketEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
     148    connect(m_pFileSelector, SIGNAL(pathChanged(const QString &)), this, SIGNAL(completeChanged()));
     149
     150    /* Register classes: */
     151    qRegisterMetaType<StorageType>();
     152    qRegisterMetaType<ExportAppliancePointer>();
     153    /* Register fields: */
    86154    registerField("machineNames", this, "machineNames");
    87155    registerField("machineIDs", this, "machineIDs");
    88 }
    89 
    90 void UIWizardExportAppPageBasic1::retranslateUi()
    91 {
    92     /* Translate page: */
    93     setTitle(UIWizardExportApp::tr("Welcome to the Appliance Export Wizard!"));
    94 
     156    registerField("storageType", this, "storageType");
     157    registerField("OVF09Selected", this, "OVF09Selected");
     158    registerField("manifestSelected", this, "manifestSelected");
     159    registerField("username", this, "username");
     160    registerField("password", this, "password");
     161    registerField("hostname", this, "hostname");
     162    registerField("bucket", this, "bucket");
     163    registerField("path", this, "path");
     164    registerField("applianceWidget", this, "applianceWidget");
     165}
     166
     167void UIWizardExportAppPageExpert::sltVMSelectionChangeHandler()
     168{
     169    /* Call to base-class: */
     170    refreshApplianceSettingsWidget();
     171    refreshCurrentSettings();
     172
     173    /* Broadcast complete-change: */
     174    emit completeChanged();
     175}
     176
     177void UIWizardExportAppPageExpert::sltStorageTypeChangeHandler()
     178{
     179    /* Call to base-class: */
     180    refreshCurrentSettings();
     181
     182    /* Broadcast complete-change: */
     183    emit completeChanged();
     184}
     185
     186void UIWizardExportAppPageExpert::retranslateUi()
     187{
     188    /* Translate objects: */
     189    m_strDefaultApplianceName = UIWizardExportApp::tr("Appliance");
    95190    /* Translate widgets: */
    96     m_pLabel->setText(UIWizardExportApp::tr("<p>This wizard will guide you through the process of "
    97                                             "exporting an appliance.</p><p>%1</p><p>Please select "
    98                                             "the virtual machines that should be added to the "
    99                                             "appliance. You can select more than one. Please note "
    100                                             "that these machines have to be turned off before they "
    101                                             "can be exported.</p>")
    102                                             .arg(standardHelpText()));
    103 }
    104 
    105 void UIWizardExportAppPageBasic1::initializePage()
     191    m_pVMSelectorLabel->setText(UIWizardExportApp::tr("VM &List"));
     192    m_pVMApplianceLabel->setText(UIWizardExportApp::tr("&Settings"));
     193    m_pTypeCnt->setTitle(UIWizardExportApp::tr("&Destination"));
     194    m_pTypeLocalFilesystem->setText(UIWizardExportApp::tr("&Local Filesystem "));
     195    m_pTypeSunCloud->setText(UIWizardExportApp::tr("Sun &Cloud"));
     196    m_pTypeSimpleStorageSystem->setText(UIWizardExportApp::tr("&Simple Storage System (S3)"));
     197    m_pUsernameLabel->setText(UIWizardExportApp::tr("&Username:"));
     198    m_pPasswordLabel->setText(UIWizardExportApp::tr("&Password:"));
     199    m_pHostnameLabel->setText(UIWizardExportApp::tr("&Hostname:"));
     200    m_pBucketLabel->setText(UIWizardExportApp::tr("&Bucket:"));
     201    m_pFileSelectorLabel->setText(UIWizardExportApp::tr("&File:"));
     202    m_pFileSelector->setFileDialogTitle(UIWizardExportApp::tr("Select a file to export into"));
     203    m_pFileSelector->setFileFilters(UIWizardExportApp::tr("Open Virtualization Format Archive (%1)").arg("*.ova") + ";;" +
     204                                    UIWizardExportApp::tr("Open Virtualization Format (%1)").arg("*.ovf"));
     205    m_pOVF09Checkbox->setToolTip(UIWizardExportApp::tr("Write in legacy OVF 0.9 format for compatibility with other virtualization products."));
     206    m_pOVF09Checkbox->setText(UIWizardExportApp::tr("&Write legacy OVF 0.9"));
     207    m_pManifestCheckbox->setToolTip(UIWizardExportApp::tr("Create a Manifest file for automatic data integrity checks on import."));
     208    m_pManifestCheckbox->setText(UIWizardExportApp::tr("Write &Manifest file"));
     209}
     210
     211void UIWizardExportAppPageExpert::initializePage()
    106212{
    107213    /* Translate page: */
    108214    retranslateUi();
    109 }
    110 
    111 bool UIWizardExportAppPageBasic1::isComplete() const
    112 {
    113     /* There should be at least one vm selected! */
    114     return m_pVMSelector->selectedItems().size() > 0;
    115 }
    116 
    117 bool UIWizardExportAppPageBasic1::validatePage()
    118 {
    119     /* Ask user machines which are in save state currently. */
     215
     216    /* Call to base-class: */
     217    refreshApplianceSettingsWidget();
     218    refreshCurrentSettings();
     219}
     220
     221bool UIWizardExportAppPageExpert::isComplete() const
     222{
     223    /* Initial result: */
     224    bool fResult = true;
     225
     226    /* There should be at least one vm selected: */
     227    if (fResult)
     228        fResult = (m_pVMSelector->selectedItems().size() > 0);
     229
     230    /* Check storage-type attributes: */
     231    if (fResult)
     232    {
     233        const QString &strFile = m_pFileSelector->path().toLower();
     234        fResult = VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts);
     235        if (fResult)
     236        {
     237            StorageType st = storageType();
     238            switch (st)
     239            {
     240                case Filesystem:
     241                    break;
     242                case SunCloud:
     243                    fResult &= !m_pUsernameEditor->text().isEmpty() &&
     244                               !m_pPasswordEditor->text().isEmpty() &&
     245                               !m_pBucketEditor->text().isEmpty();
     246                    break;
     247                case S3:
     248                    fResult &= !m_pUsernameEditor->text().isEmpty() &&
     249                               !m_pPasswordEditor->text().isEmpty() &&
     250                               !m_pHostnameEditor->text().isEmpty() &&
     251                               !m_pBucketEditor->text().isEmpty();
     252                    break;
     253            }
     254        }
     255    }
     256
     257    /* Return result: */
     258    return fResult;
     259}
     260
     261bool UIWizardExportAppPageExpert::validatePage()
     262{
     263    /* Initial result: */
     264    bool fResult = true;
     265
     266    /* Lock finish button: */
     267    startProcessing();
     268
     269    /* Ask user about machines which are in save state currently: */
    120270    QStringList savedMachines;
    121271    QList<QListWidgetItem*> pItems = m_pVMSelector->selectedItems();
    122272    for (int i=0; i < pItems.size(); ++i)
    123273    {
    124         if (static_cast<VMListWidgetItems*>(pItems.at(i))->isInSaveState())
     274        if (static_cast<VMListWidgetItem*>(pItems.at(i))->isInSaveState())
    125275            savedMachines << pItems.at(i)->text();
    126276    }
    127 
    128277    if (!savedMachines.isEmpty())
    129         return msgCenter().confirmExportMachinesInSaveState(savedMachines, this);
    130 
    131     return true;
    132 }
    133 
    134 int UIWizardExportAppPageBasic1::nextId() const
    135 {
    136     /* Skip next (2nd, Storage-type) page for now! */
    137     return UIWizardExportApp::Page3;
    138 }
    139 
    140 void UIWizardExportAppPageBasic1::populateVMSelectorItems()
    141 {
    142     /* Add all VM items into 'VM Selector': */
    143     foreach (const CMachine &machine, vboxGlobal().virtualBox().GetMachines())
    144     {
    145         QPixmap pixIcon;
    146         QString strName;
    147         QString strUuid;
    148         bool fInSaveState = false;
    149         bool fEnabled = false;
    150         if (machine.GetAccessible())
    151         {
    152             pixIcon = vboxGlobal().vmGuestOSTypeIcon(machine.GetOSTypeId()).scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    153             strName = machine.GetName();
    154             strUuid = machine.GetId();
    155             fEnabled = machine.GetSessionState() == KSessionState_Unlocked;
    156             fInSaveState = machine.GetState() == KMachineState_Saved;
    157         }
    158         else
    159         {
    160             QString settingsFile = machine.GetSettingsFilePath();
    161             QFileInfo fi(settingsFile);
    162             strName = VBoxGlobal::hasAllowedExtension(fi.completeSuffix(), VBoxDefs::VBoxFileExts) ? fi.completeBaseName() : fi.fileName();
    163             pixIcon = QPixmap(":/os_other.png").scaled(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    164         }
    165         QListWidgetItem *pItem = new VMListWidgetItems(pixIcon, strName, strUuid, fInSaveState, m_pVMSelector);
    166         if (!fEnabled)
    167             pItem->setFlags(0);
    168         m_pVMSelector->addItem(pItem);
    169     }
    170     m_pVMSelector->sortItems();
    171 }
    172 
    173 QStringList UIWizardExportAppPageBasic1::machineNames() const
    174 {
    175     /* Prepare list: */
    176     QStringList machineNames;
    177     /* Iterate over all the selected items: */
    178     foreach (QListWidgetItem *pItem, m_pVMSelector->selectedItems())
    179         machineNames << pItem->text();
    180     /* Return result list: */
    181     return machineNames;
    182 }
    183 
    184 QStringList UIWizardExportAppPageBasic1::machineIDs() const
    185 {
    186     /* Prepare list: */
    187     QStringList machineIDs;
    188     /* Iterate over all the selected items: */
    189     foreach (QListWidgetItem *pItem, m_pVMSelector->selectedItems())
    190         machineIDs << static_cast<VMListWidgetItems*>(pItem)->uuid();
    191     /* Return result list: */
    192     return machineIDs;
    193 }
    194 
     278        fResult = msgCenter().confirmExportMachinesInSaveState(savedMachines, this);
     279
     280    /* Try to export appliance: */
     281    if (fResult)
     282        fResult = qobject_cast<UIWizardExportApp*>(wizard())->exportAppliance();
     283
     284    /* Unlock finish button: */
     285    endProcessing();
     286
     287    /* Return result: */
     288    return fResult;
     289}
     290
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageExpert.h

    r40929 r41021  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * UIWizardExportAppPageBasic1 class declaration
     4 * UIWizardExportAppPageExpert class declaration
    55 */
    66
     
    1717 */
    1818
    19 #ifndef __UIWizardExportAppPageBasic1_h__
    20 #define __UIWizardExportAppPageBasic1_h__
     19#ifndef __UIWizardExportAppPageExpert_h__
     20#define __UIWizardExportAppPageExpert_h__
    2121
    2222/* Local includes: */
    23 #include "UIWizardPage.h"
     23#include "UIWizardExportAppPageBasic1.h"
     24#include "UIWizardExportAppPageBasic2.h"
     25#include "UIWizardExportAppPageBasic3.h"
     26#include "UIWizardExportAppPageBasic4.h"
    2427
    25 /* Forward declarations: */
    26 class QIRichTextLabel;
    27 class QListWidget;
    28 
    29 /* 1st page of the Export Appliance wizard: */
    30 class UIWizardExportAppPageBasic1 : public UIWizardPage
     28/* Expert page of the Export Appliance wizard: */
     29class UIWizardExportAppPageExpert : public UIWizardPage,
     30                                    public UIWizardExportAppPage1,
     31                                    public UIWizardExportAppPage2,
     32                                    public UIWizardExportAppPage3,
     33                                    public UIWizardExportAppPage4
    3134{
    3235    Q_OBJECT;
    3336    Q_PROPERTY(QStringList machineNames READ machineNames);
    3437    Q_PROPERTY(QStringList machineIDs READ machineIDs);
     38    Q_PROPERTY(StorageType storageType READ storageType WRITE setStorageType);
     39    Q_PROPERTY(bool OVF09Selected READ isOVF09Selected WRITE setOVF09Selected);
     40    Q_PROPERTY(bool manifestSelected READ isManifestSelected WRITE setManifestSelected);
     41    Q_PROPERTY(QString username READ username WRITE setUserName);
     42    Q_PROPERTY(QString password READ password WRITE setPassword);
     43    Q_PROPERTY(QString hostname READ hostname WRITE setHostname);
     44    Q_PROPERTY(QString bucket READ bucket WRITE setBucket);
     45    Q_PROPERTY(QString path READ path WRITE setPath);
     46    Q_PROPERTY(ExportAppliancePointer applianceWidget READ applianceWidget);
    3547
    3648public:
    3749
    3850    /* Constructor: */
    39     UIWizardExportAppPageBasic1(const QStringList &selectedVMNames);
     51    UIWizardExportAppPageExpert(const QStringList &selectedVMNames);
     52
     53protected:
     54
     55    /* Wrapper to access 'wizard' from base part: */
     56    UIWizard* wizardImp() { return UIWizardPage::wizard(); }
     57    /* Wrapper to access 'this' from base part: */
     58    UIWizardPage* thisImp() { return this; }
     59    /* Wrapper to access 'wizard-field' from base part: */
     60    QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
     61
     62private slots:
     63
     64    /* VM Selector selection change handler: */
     65    void sltVMSelectionChangeHandler();
     66
     67    /* Storage-type change handler: */
     68    void sltStorageTypeChangeHandler();
    4069
    4170private:
     71
     72    /* Field API: */
     73    QVariant field(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
    4274
    4375    /* Translate stuff: */
     
    5082    bool isComplete() const;
    5183    bool validatePage();
    52 
    53     /* Navigation stuff: */
    54     int nextId() const;
    55 
    56     /* Helping stuff: */
    57     void populateVMSelectorItems();
    58 
    59     /* Stuff for 'machineNames' field: */
    60     QStringList machineNames() const;
    61 
    62     /* Stuff for 'machineIDs' field: */
    63     QStringList machineIDs() const;
    64 
    65     /* Variables: */
    66     QStringList m_selectedVMNames;
    67 
    68     /* Widgets: */
    69     QIRichTextLabel *m_pLabel;
    70     QListWidget *m_pVMSelector;
    7184};
    7285
    73 #endif /* __UIWizardExportAppPageBasic1_h__ */
     86#endif /* __UIWizardExportAppPageExpert_h__ */
    7487
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRun.cpp

    r40870 r41021  
    2323#include "UIWizardFirstRunPageBasic2.h"
    2424#include "UIWizardFirstRunPageBasic3.h"
     25#include "UIWizardFirstRunPageExpert.h"
    2526#include "VBoxGlobal.h"
    2627#include "UIMessageCenter.h"
    2728
    2829UIWizardFirstRun::UIWizardFirstRun(QWidget *pParent, const CMachine &machine)
    29     : UIWizard(pParent)
     30    : UIWizard(pParent, UIWizardType_FirstRun)
    3031    , m_machine(machine)
     32    , m_fHardDiskWasSet(isBootHardDiskAttached(m_machine))
    3133{
    32     /* Check if boot hard disk was set: */
    33     bool fHardDiskWasSet = isBootHardDiskAttached(machine);
    34 
    35     /* Create & add pages: */
    36     setPage(Page1, new UIWizardFirstRunPageBasic1(fHardDiskWasSet));
    37     setPage(Page2, new UIWizardFirstRunPageBasic2(machine, fHardDiskWasSet));
    38     setPage(Page3, new UIWizardFirstRunPageBasic3(fHardDiskWasSet));
    39 
    40     /* Translate wizard: */
    41     retranslateUi();
    42 
    43     /* Translate wizard pages: */
    44     retranslateAllPages();
    45 
    4634#ifndef Q_WS_MAC
    4735    /* Assign watermark: */
     
    5139    assignBackground(":/vmw_first_run_bg.png");
    5240#endif /* Q_WS_MAC */
    53 
    54     /* Resize to 'golden ratio': */
    55     resizeToGoldenRatio(UIWizardType_FirstRun);
    5641}
    5742
     
    10388void UIWizardFirstRun::retranslateUi()
    10489{
     90    /* Call to base-class: */
     91    UIWizard::retranslateUi();
     92
    10593    /* Translate wizard: */
    10694    setWindowTitle(tr("First Run Wizard"));
    10795    setButtonText(QWizard::FinishButton, tr("Start"));
     96}
     97
     98void UIWizardFirstRun::prepare()
     99{
     100    /* Create corresponding pages: */
     101    switch (mode())
     102    {
     103        case UIWizardMode_Basic:
     104        {
     105            setPage(Page1, new UIWizardFirstRunPageBasic1(m_fHardDiskWasSet));
     106            setPage(Page2, new UIWizardFirstRunPageBasic2(m_machine.GetId(), m_fHardDiskWasSet));
     107            setPage(Page3, new UIWizardFirstRunPageBasic3(m_fHardDiskWasSet));
     108            break;
     109        }
     110        case UIWizardMode_Expert:
     111        {
     112            setPage(PageExpert, new UIWizardFirstRunPageExpert(m_machine.GetId(), m_fHardDiskWasSet));
     113            break;
     114        }
     115    }
     116    /* Call to base-class: */
     117    UIWizard::prepare();
    108118}
    109119
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRun.h

    r40870 r41021  
    3939    };
    4040
     41    /* Page IDs: */
     42    enum
     43    {
     44        PageExpert
     45    };
     46
    4147    /* Constructor: */
    4248    UIWizardFirstRun(QWidget *pParent, const CMachine &machine);
     
    4955    /* Who will be able to export appliance: */
    5056    friend class UIWizardFirstRunPageBasic3;
     57    friend class UIWizardFirstRunPageExpert;
    5158
    5259private:
     
    5562    void retranslateUi();
    5663
     64    /* Pages related stuff: */
     65    void prepare();
     66
    5767    /* Helping stuff: */
    5868    static bool isBootHardDiskAttached(const CMachine &machine);
     
    6070    /* Variables: */
    6171    CMachine m_machine;
     72    bool m_fHardDiskWasSet;
    6273};
    6374
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic1.cpp

    r40870 r41021  
    2626#include "QIRichTextLabel.h"
    2727
     28UIWizardFirstRunPage1::UIWizardFirstRunPage1(bool fBootHardDiskWasSet)
     29    : m_fBootHardDiskWasSet(fBootHardDiskWasSet)
     30{
     31}
     32
    2833UIWizardFirstRunPageBasic1::UIWizardFirstRunPageBasic1(bool fBootHardDiskWasSet)
    29     : m_fBootHardDiskWasSet(fBootHardDiskWasSet)
     34    : UIWizardFirstRunPage1(fBootHardDiskWasSet)
    3035{
    3136    /* Create widgets: */
    3237    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     38    {
    3339        m_pLabel = new QIRichTextLabel(this);
    34     pMainLayout->addWidget(m_pLabel);
    35     pMainLayout->addStretch();
     40        pMainLayout->addWidget(m_pLabel);
     41        pMainLayout->addStretch();
     42    }
    3643}
    3744
     
    3946{
    4047    /* Translate page: */
    41     setTitle(UIWizardFirstRun::tr("Welcome to the First Run Wizard!"));
     48    setTitle(UIWizardFirstRun::tr("Welcome to the First Run wizard!"));
    4249
    4350    /* Translate widgets: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic1.h

    r40870 r41021  
    2626class QIRichTextLabel;
    2727
    28 /* 1st page of the First Run wizard: */
    29 class UIWizardFirstRunPageBasic1 : public UIWizardPage
     28/* 1st page of the First Run wizard (base part): */
     29class UIWizardFirstRunPage1 : public UIWizardPageBase
     30{
     31protected:
     32
     33    /* Constructor: */
     34    UIWizardFirstRunPage1(bool fBootHardDiskWasSet);
     35
     36    /* Variables: */
     37    bool m_fBootHardDiskWasSet;
     38};
     39
     40/* 1st page of the First Run wizard (basic extension): */
     41class UIWizardFirstRunPageBasic1 : public UIWizardPage, public UIWizardFirstRunPage1
    3042{
    3143    Q_OBJECT;
     
    4456    void initializePage();
    4557
    46     /* Variables: */
    47     bool m_fBootHardDiskWasSet;
    48 
    4958    /* Widgets: */
    5059    QIRichTextLabel *m_pLabel;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic2.cpp

    r40870 r41021  
    2828#include "COMDefs.h"
    2929#include "UIIconPool.h"
     30#include "VBoxGlobal.h"
    3031#include "UIMessageCenter.h"
    31 #include "QIRichTextLabel.h"
    3232#include "VBoxMediaComboBox.h"
    3333#include "QIToolButton.h"
     34#include "QIRichTextLabel.h"
    3435
    35 UIWizardFirstRunPageBasic2::UIWizardFirstRunPageBasic2(const CMachine &machine, bool fBootHardDiskWasSet)
     36UIWizardFirstRunPage2::UIWizardFirstRunPage2(bool fBootHardDiskWasSet)
    3637    : m_fBootHardDiskWasSet(fBootHardDiskWasSet)
     38{
     39}
     40
     41void UIWizardFirstRunPage2::onOpenMediumWithFileOpenDialog()
     42{
     43    /* Get opened vboxMedium id: */
     44    QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(m_pMediaSelector->type(), thisImp());
     45    /* Update medium-combo if necessary: */
     46    if (!strMediumId.isNull())
     47        m_pMediaSelector->setCurrentItem(strMediumId);
     48}
     49
     50QString UIWizardFirstRunPage2::id() const
     51{
     52    return m_pMediaSelector->id();
     53}
     54
     55void UIWizardFirstRunPage2::setId(const QString &strId)
     56{
     57    m_pMediaSelector->setCurrentItem(strId);
     58}
     59
     60UIWizardFirstRunPageBasic2::UIWizardFirstRunPageBasic2(const QString &strMachineId, bool fBootHardDiskWasSet)
     61    : UIWizardFirstRunPage2(fBootHardDiskWasSet)
    3762{
    3863    /* Create widgets: */
    3964    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     65    {
    4066        m_pLabel = new QIRichTextLabel(this);
    41         m_pCntSource = new QGroupBox(this);
    42             m_pCntSource->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    43             QHBoxLayout *pSourceLayout = new QHBoxLayout(m_pCntSource);
    44                 m_pMediaSelector = new VBoxMediaComboBox(m_pCntSource);
    45                     m_pMediaSelector->setMachineId(machine.GetId());
     67        m_pSourceCnt = new QGroupBox(this);
     68        {
     69            m_pSourceCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     70            QHBoxLayout *pSourceCntLayout = new QHBoxLayout(m_pSourceCnt);
     71            {
     72                m_pMediaSelector = new VBoxMediaComboBox(m_pSourceCnt);
     73                {
     74                    m_pMediaSelector->setMachineId(strMachineId);
    4675                    m_pMediaSelector->setType(VBoxDefs::MediumType_DVD);
    4776                    m_pMediaSelector->repopulate();
    48                 m_pSelectMediaButton = new QIToolButton(m_pCntSource);
     77                }
     78                m_pSelectMediaButton = new QIToolButton(m_pSourceCnt);
     79                {
    4980                    m_pSelectMediaButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png"));
    5081                    m_pSelectMediaButton->setAutoRaise(true);
    51             pSourceLayout->addWidget(m_pMediaSelector);
    52             pSourceLayout->addWidget(m_pSelectMediaButton);
    53     pMainLayout->addWidget(m_pLabel);
    54     pMainLayout->addWidget(m_pCntSource);
    55     pMainLayout->addStretch();
     82                }
     83                pSourceCntLayout->addWidget(m_pMediaSelector);
     84                pSourceCntLayout->addWidget(m_pSelectMediaButton);
     85            }
     86        }
     87        pMainLayout->addWidget(m_pLabel);
     88        pMainLayout->addWidget(m_pSourceCnt);
     89        pMainLayout->addStretch();
     90    }
    5691
    5792    /* Setup connections: */
    5893    connect(m_pMediaSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged()));
    59     connect(m_pSelectMediaButton, SIGNAL(clicked()), this, SLOT(sltOpenWithFileOpenDialog()));
     94    connect(m_pSelectMediaButton, SIGNAL(clicked()), this, SLOT(sltOpenMediumWithFileOpenDialog()));
    6095
    6196    /* Register fields: */
     
    6499}
    65100
    66 void UIWizardFirstRunPageBasic2::sltOpenWithFileOpenDialog()
     101void UIWizardFirstRunPageBasic2::sltOpenMediumWithFileOpenDialog()
    67102{
    68     /* Get opened vboxMedium id: */
    69     QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(m_pMediaSelector->type(), this);
    70     /* Update medium-combo if necessary: */
    71     if (!strMediumId.isNull())
    72         m_pMediaSelector->setCurrentItem(strMediumId);
     103    /* Call to base-class: */
     104    onOpenMediumWithFileOpenDialog();
    73105}
    74106
     
    87119                                               "you want to work with. This media must be bootable, "
    88120                                               "otherwise the operating system will not be able to start.</p>"));
    89     m_pCntSource->setTitle(UIWizardFirstRun::tr("Media Source"));
     121    m_pSourceCnt->setTitle(UIWizardFirstRun::tr("Media Source"));
     122    m_pSelectMediaButton->setToolTip(VBoxGlobal::tr("Choose a virtual CD/DVD disk file"));
    90123}
    91124
     
    94127    /* Translate page: */
    95128    retranslateUi();
    96 
    97     /* Media selector should have focus initially: */
    98     m_pMediaSelector->setFocus();
    99129}
    100130
    101131bool UIWizardFirstRunPageBasic2::isComplete() const
    102132{
     133    /* Make sure valid medium chosen: */
    103134    return !vboxGlobal().findMedium(id()).isNull();
    104135}
     
    109140}
    110141
    111 QString UIWizardFirstRunPageBasic2::id() const
    112 {
    113     return m_pMediaSelector->id();
    114 }
    115 
    116 void UIWizardFirstRunPageBasic2::setId(const QString &strId)
    117 {
    118     m_pMediaSelector->setCurrentItem(strId);
    119 }
    120 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic2.h

    r40870 r41021  
    2525/* Forward declarations: */
    2626class CMachine;
    27 class QIRichTextLabel;
    2827class QGroupBox;
    2928class VBoxMediaComboBox;
    3029class QIToolButton;
     30class QIRichTextLabel;
    3131
    32 /* 2nd page of the First Run wizard: */
    33 class UIWizardFirstRunPageBasic2 : public UIWizardPage
     32/* 2nd page of the First Run wizard (base part): */
     33class UIWizardFirstRunPage2 : public UIWizardPageBase
     34{
     35protected:
     36
     37    /* Constructor: */
     38    UIWizardFirstRunPage2(bool fBootHardDiskWasSet);
     39
     40    /* Handlers: */
     41    void onOpenMediumWithFileOpenDialog();
     42
     43    /* Stuff for 'id' field: */
     44    QString id() const;
     45    void setId(const QString &strId);
     46
     47    /* Variables: */
     48    bool m_fBootHardDiskWasSet;
     49
     50    /* Widgets: */
     51    QGroupBox *m_pSourceCnt;
     52    VBoxMediaComboBox *m_pMediaSelector;
     53    QIToolButton *m_pSelectMediaButton;
     54};
     55
     56/* 2nd page of the First Run wizard (basic extension): */
     57class UIWizardFirstRunPageBasic2 : public UIWizardPage, public UIWizardFirstRunPage2
    3458{
    3559    Q_OBJECT;
     
    4064
    4165    /* Constructor: */
    42     UIWizardFirstRunPageBasic2(const CMachine &machine, bool fBootHardDiskWasSet);
     66    UIWizardFirstRunPageBasic2(const QString &strMachineId, bool fBootHardDiskWasSet);
     67
     68protected:
     69
     70    /* Wrapper to access 'this' from base part: */
     71    UIWizardPage* thisImp() { return this; }
    4372
    4473private slots:
    4574
    4675    /* Open with file-open dialog: */
    47     void sltOpenWithFileOpenDialog();
     76    void sltOpenMediumWithFileOpenDialog();
    4877
    4978private:
     
    6190    QString source() const;
    6291
    63     /* Stuff for 'id' field: */
    64     QString id() const;
    65     void setId(const QString &strId);
    66 
    67     /* Variables: */
    68     bool m_fBootHardDiskWasSet;
    69 
    7092    /* Widgets: */
    7193    QIRichTextLabel *m_pLabel;
    72     QGroupBox *m_pCntSource;
    73     VBoxMediaComboBox *m_pMediaSelector;
    74     QIToolButton *m_pSelectMediaButton;
    7594};
    7695
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic3.cpp

    r40870 r41021  
    2626#include "QIRichTextLabel.h"
    2727
     28UIWizardFirstRunPage3::UIWizardFirstRunPage3(bool fBootHardDiskWasSet)
     29    : m_fBootHardDiskWasSet(fBootHardDiskWasSet)
     30{
     31}
     32
    2833UIWizardFirstRunPageBasic3::UIWizardFirstRunPageBasic3(bool fBootHardDiskWasSet)
    29     : m_fBootHardDiskWasSet(fBootHardDiskWasSet)
     34    : UIWizardFirstRunPage3(fBootHardDiskWasSet)
    3035{
    3136    /* Create widgets: */
    3237    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     38    {
    3339        m_pLabel1 = new QIRichTextLabel(this);
    3440        m_pSummaryText = new QIRichTextLabel(this);
    3541        m_pLabel2 = new QIRichTextLabel(this);
    36     pMainLayout->addWidget(m_pLabel1);
    37     pMainLayout->addWidget(m_pSummaryText);
    38     pMainLayout->addWidget(m_pLabel2);
    39     pMainLayout->addStretch();
     42        pMainLayout->addWidget(m_pLabel1);
     43        pMainLayout->addWidget(m_pSummaryText);
     44        pMainLayout->addWidget(m_pLabel2);
     45        pMainLayout->addStretch();
     46    }
    4047}
    4148
     
    93100bool UIWizardFirstRunPageBasic3::validatePage()
    94101{
    95     /* Insert chosen medium: */
     102    /* Initial result: */
     103    bool fResult = true;
     104
     105    /* Lock finish button: */
    96106    startProcessing();
    97     bool fResult = qobject_cast<UIWizardFirstRun*>(wizard())->insertMedium();
     107
     108    /* Try to insert chosen medium: */
     109    if (fResult)
     110        fResult = qobject_cast<UIWizardFirstRun*>(wizard())->insertMedium();
     111
     112    /* Unlock finish button: */
    98113    endProcessing();
     114
     115    /* Return result: */
    99116    return fResult;
    100117}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageBasic3.h

    r40870 r41021  
    2626class QIRichTextLabel;
    2727
    28 /* 3rd page of the First Run wizard: */
    29 class UIWizardFirstRunPageBasic3 : public UIWizardPage
     28/* 3rd page of the First Run wizard (base part): */
     29class UIWizardFirstRunPage3 : public UIWizardPageBase
     30{
     31protected:
     32
     33    /* Constructor: */
     34    UIWizardFirstRunPage3(bool fBootHardDiskWasSet);
     35
     36    /* Variables: */
     37    bool m_fBootHardDiskWasSet;
     38};
     39
     40/* 3rd page of the First Run wizard (basic extension): */
     41class UIWizardFirstRunPageBasic3 : public UIWizardPage, public UIWizardFirstRunPage3
    3042{
    3143    Q_OBJECT;
     
    4759    bool validatePage();
    4860
    49     /* Variables: */
    50     bool m_fBootHardDiskWasSet;
    51 
    5261    /* Widgets: */
    5362    QIRichTextLabel *m_pLabel1;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageExpert.cpp

    r40929 r41021  
    33 *
    44 * VBox frontends: Qt4 GUI ("VirtualBox"):
    5  * UIWizardFirstRunPageBasic1 class implementation
     5 * UIWizardFirstRunPageExpert class implementation
    66 */
    77
     
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QHBoxLayout>
     23#include <QGroupBox>
    2224
    2325/* Local includes: */
    24 #include "UIWizardFirstRunPageBasic1.h"
     26#include "UIWizardFirstRunPageExpert.h"
    2527#include "UIWizardFirstRun.h"
    26 #include "QIRichTextLabel.h"
     28#include "VBoxGlobal.h"
     29#include "UIIconPool.h"
     30#include "VBoxMediaComboBox.h"
     31#include "QIToolButton.h"
    2732
    28 UIWizardFirstRunPageBasic1::UIWizardFirstRunPageBasic1(bool fBootHardDiskWasSet)
    29     : m_fBootHardDiskWasSet(fBootHardDiskWasSet)
     33UIWizardFirstRunPageExpert::UIWizardFirstRunPageExpert(const QString &strMachineId, bool fBootHardDiskWasSet)
     34    : UIWizardFirstRunPage1(fBootHardDiskWasSet)
     35    , UIWizardFirstRunPage2(fBootHardDiskWasSet)
     36    , UIWizardFirstRunPage3(fBootHardDiskWasSet)
    3037{
    3138    /* Create widgets: */
    3239    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    33         m_pLabel = new QIRichTextLabel(this);
    34     pMainLayout->addWidget(m_pLabel);
    35     pMainLayout->addStretch();
     40    {
     41        pMainLayout->setContentsMargins(8, 6, 8, 6);
     42        m_pSourceCnt = new QGroupBox(this);
     43        {
     44            m_pSourceCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     45            QHBoxLayout *pSourceCntLayout = new QHBoxLayout(m_pSourceCnt);
     46            {
     47                m_pMediaSelector = new VBoxMediaComboBox(m_pSourceCnt);
     48                {
     49                    m_pMediaSelector->setMachineId(strMachineId);
     50                    m_pMediaSelector->setType(VBoxDefs::MediumType_DVD);
     51                    m_pMediaSelector->repopulate();
     52                }
     53                m_pSelectMediaButton = new QIToolButton(m_pSourceCnt);
     54                {
     55                    m_pSelectMediaButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png"));
     56                    m_pSelectMediaButton->setAutoRaise(true);
     57                }
     58                pSourceCntLayout->addWidget(m_pMediaSelector);
     59                pSourceCntLayout->addWidget(m_pSelectMediaButton);
     60            }
     61        }
     62        pMainLayout->addWidget(m_pSourceCnt);
     63        pMainLayout->addStretch();
     64    }
     65
     66    /* Setup connections: */
     67    connect(m_pMediaSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged()));
     68    connect(m_pSelectMediaButton, SIGNAL(clicked()), this, SLOT(sltOpenMediumWithFileOpenDialog()));
     69
     70    /* Register fields: */
     71    registerField("id", this, "id");
    3672}
    3773
    38 void UIWizardFirstRunPageBasic1::retranslateUi()
     74void UIWizardFirstRunPageExpert::sltOpenMediumWithFileOpenDialog()
    3975{
    40     /* Translate page: */
    41     setTitle(UIWizardFirstRun::tr("Welcome to the First Run Wizard!"));
    42 
    43     /* Translate widgets: */
    44     if (m_fBootHardDiskWasSet)
    45         m_pLabel->setText(UIWizardFirstRun::tr("<p>You have started a newly created virtual machine for the "
    46                                                "first time. This wizard will help you to perform the steps "
    47                                                "necessary for installing an operating system of your choice "
    48                                                "onto this virtual machine.</p><p>%1</p>")
    49                                               .arg(standardHelpText()));
    50     else
    51         m_pLabel->setText(UIWizardFirstRun::tr("<p>You have started a newly created virtual machine for the "
    52                                                "first time. This wizard will help you to perform the steps "
    53                                                "necessary for booting an operating system of your choice on "
    54                                                "the virtual machine.</p><p>Note that you will not be able to "
    55                                                "install an operating system into this virtual machine right "
    56                                                "now because you did not attach any hard disk to it. If this "
    57                                                "is not what you want, you can cancel the execution of this "
    58                                                "wizard, select <b>Settings</b> from the <b>Machine</b> menu "
    59                                                "of the main VirtualBox window to access the settings dialog "
    60                                                "of this machine and change the hard disk configuration.</p>"
    61                                                "<p>%1</p>")
    62                                               .arg(standardHelpText()));
     76    /* Call to base-class: */
     77    onOpenMediumWithFileOpenDialog();
    6378}
    6479
    65 void UIWizardFirstRunPageBasic1::initializePage()
     80void UIWizardFirstRunPageExpert::retranslateUi()
     81{
     82    /* Translate widgets: */
     83    m_pSourceCnt->setTitle(UIWizardFirstRun::tr("Media Source"));
     84    m_pSelectMediaButton->setToolTip(VBoxGlobal::tr("Choose a virtual CD/DVD disk file"));
     85}
     86
     87void UIWizardFirstRunPageExpert::initializePage()
    6688{
    6789    /* Translate page: */
     
    6991}
    7092
     93bool UIWizardFirstRunPageExpert::isComplete() const
     94{
     95    /* Make sure valid medium chosen: */
     96    return !vboxGlobal().findMedium(id()).isNull();
     97}
     98
     99bool UIWizardFirstRunPageExpert::validatePage()
     100{
     101    /* Initial result: */
     102    bool fResult = true;
     103
     104    /* Lock finish button: */
     105    startProcessing();
     106
     107    /* Try to insert chosen medium: */
     108    if (fResult)
     109        fResult = qobject_cast<UIWizardFirstRun*>(wizard())->insertMedium();
     110
     111    /* Unlock finish button: */
     112    endProcessing();
     113
     114    /* Return result: */
     115    return fResult;
     116}
     117
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/firstrun/UIWizardFirstRunPageExpert.h

    r40929 r41021  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * UIWizardFirstRunPageBasic1 class declaration
     4 * UIWizardFirstRunPageExpert class declaration
    55 */
    66
     
    1717 */
    1818
    19 #ifndef __UIWizardFirstRunPageBasic1_h__
    20 #define __UIWizardFirstRunPageBasic1_h__
     19#ifndef __UIWizardFirstRunPageExpert_h__
     20#define __UIWizardFirstRunPageExpert_h__
    2121
    2222/* Local includes: */
    23 #include "UIWizardPage.h"
     23#include "UIWizardFirstRunPageBasic1.h"
     24#include "UIWizardFirstRunPageBasic2.h"
     25#include "UIWizardFirstRunPageBasic3.h"
    2426
    25 /* Forward declarations: */
    26 class QIRichTextLabel;
    27 
    28 /* 1st page of the First Run wizard: */
    29 class UIWizardFirstRunPageBasic1 : public UIWizardPage
     27/* Expert page of the First Run wizard: */
     28class UIWizardFirstRunPageExpert : public UIWizardPage,
     29                                   public UIWizardFirstRunPage1,
     30                                   public UIWizardFirstRunPage2,
     31                                   public UIWizardFirstRunPage3
    3032{
    3133    Q_OBJECT;
     34    Q_PROPERTY(QString id READ id WRITE setId);
    3235
    3336public:
    3437
    3538    /* Constructor: */
    36     UIWizardFirstRunPageBasic1(bool fBootHardDiskWasSet);
     39    UIWizardFirstRunPageExpert(const QString &strMachineId, bool fBootHardDiskWasSet);
     40
     41protected:
     42
     43    /* Wrapper to access 'this' from base part: */
     44    UIWizardPage* thisImp() { return this; }
     45
     46private slots:
     47
     48    /* Open with file-open dialog: */
     49    void sltOpenMediumWithFileOpenDialog();
    3750
    3851private:
     
    4457    void initializePage();
    4558
    46     /* Variables: */
    47     bool m_fBootHardDiskWasSet;
    48 
    49     /* Widgets: */
    50     QIRichTextLabel *m_pLabel;
     59    /* Validation stuff: */
     60    bool isComplete() const;
     61    bool validatePage();
    5162};
    5263
    53 #endif // __UIWizardFirstRunPageBasic1_h__
     64#endif // __UIWizardFirstRunPageExpert_h__
    5465
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportApp.cpp

    r40870 r41021  
    2929#include "UIWizardImportAppPageBasic1.h"
    3030#include "UIWizardImportAppPageBasic2.h"
     31#include "UIWizardImportAppPageExpert.h"
    3132#include "VBoxGlobal.h"
    3233#include "QIDialog.h"
     
    134135};
    135136
    136 UIWizardImportApp::UIWizardImportApp(const QString &strFileName /* = QString() */, QWidget *pParent /* = 0 */)
    137     : UIWizard(pParent)
    138 {
    139     /* Create & add pages: */
    140     if (strFileName.isEmpty())
    141         setPage(Page1, new UIWizardImportAppPageBasic1);
    142     setPage(Page2, new UIWizardImportAppPageBasic2(strFileName));
    143 
    144     /* Translate wizard: */
    145     retranslateUi();
    146 
    147     /* Translate wizard pages: */
    148     retranslateAllPages();
    149 
     137UIWizardImportApp::UIWizardImportApp(QWidget *pParent, const QString &strFileName)
     138    : UIWizard(pParent, UIWizardType_ImportAppliance)
     139    , m_strFileName(strFileName)
     140{
    150141#ifndef Q_WS_MAC
    151142    /* Assign watermark: */
     
    155146    assignBackground(":/vmw_ovf_import_bg.png");
    156147#endif /* Q_WS_MAC */
    157 
    158     /* Resize wizard to 'golden ratio': */
    159     resizeToGoldenRatio(UIWizardType_ImportAppliance);
    160 
    161     /* Setup connections: */
    162     AssertMsg(!field("applianceWidget").value<ImportAppliancePointer>().isNull(), ("Appliance Widget is not set!\n"));
    163     connect(this, SIGNAL(customButtonClicked(int)), field("applianceWidget").value<ImportAppliancePointer>(), SLOT(restoreDefaults()));
    164     connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(sltCurrentIdChanged(int)));
    165 
    166     /* Make sure custom button shown even if final page is first to show: */
    167     sltCurrentIdChanged(startId());
    168148}
    169149
     
    174154        fResult = pImportApplianceWidget->isValid();
    175155    return fResult;
    176 }
    177 
    178 void UIWizardImportApp::retranslateUi()
    179 {
    180     /* Translate wizard: */
    181     setWindowTitle(tr("Appliance Import Wizard"));
    182     setButtonText(QWizard::CustomButton1, tr("Restore Defaults"));
    183     setButtonText(QWizard::FinishButton, tr("Import"));
    184 }
    185 
    186 void UIWizardImportApp::sltCurrentIdChanged(int iId)
    187 {
    188     setOption(QWizard::HaveCustomButton1, iId == Page2);
    189156}
    190157
     
    212179}
    213180
     181void UIWizardImportApp::sltCurrentIdChanged(int iId)
     182{
     183    /* Call to base-class: */
     184    UIWizard::sltCurrentIdChanged(iId);
     185    /* Enable 2nd button (Reset to Defaults) for 2nd and Expert pages only! */
     186    setOption(QWizard::HaveCustomButton2, (mode() == UIWizardMode_Basic && iId == Page2) ||
     187                                          (mode() == UIWizardMode_Expert && iId == PageExpert));
     188}
     189
     190void UIWizardImportApp::sltCustomButtonClicked(int iId)
     191{
     192    /* Call to base-class: */
     193    UIWizard::sltCustomButtonClicked(iId);
     194
     195    /* Handle 2nd button: */
     196    if (iId == CustomButton2)
     197    {
     198        /* Get appliance widget: */
     199        ImportAppliancePointer pApplianceWidget = field("applianceWidget").value<ImportAppliancePointer>();
     200        AssertMsg(!pApplianceWidget.isNull(), ("Appliance Widget is not set!\n"));
     201        /* Reset it to default: */
     202        pApplianceWidget->restoreDefaults();
     203    }
     204}
     205
     206void UIWizardImportApp::retranslateUi()
     207{
     208    /* Call to base-class: */
     209    UIWizard::retranslateUi();
     210
     211    /* Translate wizard: */
     212    setWindowTitle(tr("Appliance Import Wizard"));
     213    setButtonText(QWizard::CustomButton2, tr("Restore Defaults"));
     214    setButtonText(QWizard::FinishButton, tr("Import"));
     215}
     216
     217void UIWizardImportApp::prepare()
     218{
     219    /* Create corresponding pages: */
     220    switch (mode())
     221    {
     222        case UIWizardMode_Basic:
     223        {
     224            if (m_strFileName.isEmpty())
     225                setPage(Page1, new UIWizardImportAppPageBasic1);
     226            setPage(Page2, new UIWizardImportAppPageBasic2(m_strFileName));
     227            break;
     228        }
     229        case UIWizardMode_Expert:
     230        {
     231            setPage(PageExpert, new UIWizardImportAppPageExpert(m_strFileName));
     232            break;
     233        }
     234    }
     235    /* Call to base-class: */
     236    UIWizard::prepare();
     237}
     238
    214239#include "UIWizardImportApp.moc"
    215240
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportApp.h

    r40870 r41021  
    3737    };
    3838
     39    /* Page IDs: */
     40    enum
     41    {
     42        PageExpert
     43    };
     44
    3945    /* Constructor: */
    40     UIWizardImportApp(const QString &strFileName = QString(), QWidget *pParent = 0);
     46    UIWizardImportApp(QWidget *pParent, const QString &strFileName);
    4147
    4248    /* Is appliance valid? */
     
    5056    /* Who will be able to import appliance: */
    5157    friend class UIWizardImportAppPageBasic2;
     58    friend class UIWizardImportAppPageExpert;
    5259
    5360private slots:
     
    5562    /* Page change handler: */
    5663    void sltCurrentIdChanged(int iId);
     64    /* Custom button 2 click handler: */
     65    void sltCustomButtonClicked(int iId);
    5766
    5867private:
     
    6069    /* Translation stuff: */
    6170    void retranslateUi();
     71
     72    /* Pages related stuff: */
     73    void prepare();
     74
     75    /* Variables: */
     76    QString m_strFileName;
    6277};
    6378
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.cpp

    r40870 r41021  
    2727#include "UIWizardImportApp.h"
    2828#include "VBoxGlobal.h"
     29#include "VBoxFilePathSelectorWidget.h"
    2930#include "QIRichTextLabel.h"
    30 #include "VBoxFilePathSelectorWidget.h"
     31
     32UIWizardImportAppPage1::UIWizardImportAppPage1()
     33{
     34}
    3135
    3236UIWizardImportAppPageBasic1::UIWizardImportAppPageBasic1()
     
    3438    /* Create widgets: */
    3539    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     40    {
    3641        m_pLabel = new QIRichTextLabel(this);
    3742        m_pFileSelector = new VBoxEmptyFileSelector(this);
     43        {
    3844            m_pFileSelector->setMode(VBoxFilePathSelectorWidget::Mode_File_Open);
    3945            m_pFileSelector->setHomeDir(vboxGlobal().documentsPath());
    40     pMainLayout->addWidget(m_pLabel);
    41     pMainLayout->addWidget(m_pFileSelector);
    42     pMainLayout->addStretch();
     46        }
     47        pMainLayout->addWidget(m_pLabel);
     48        pMainLayout->addWidget(m_pFileSelector);
     49        pMainLayout->addStretch();
     50    }
    4351
    4452    /* Setup connections: */
     
    4957{
    5058    /* Translate page: */
    51     setTitle(UIWizardImportApp::tr("Welcome to the Appliance Import Wizard!"));
     59    setTitle(UIWizardImportApp::tr("Welcome to the Appliance Import wizard!"));
    5260
    5361    /* Translate widgets: */
    54     m_pFileSelector->setFileDialogTitle(UIWizardImportApp::tr("Select an appliance to import"));
    55     m_pFileSelector->setFileFilters(UIWizardImportApp::tr("Open Virtualization Format (%1)").arg("*.ova *.ovf"));
    5662    m_pLabel->setText(UIWizardImportApp::tr("<p>This wizard will guide you through importing an appliance.</p>"
    5763                                            "<p>%1</p><p>VirtualBox currently supports importing appliances "
     
    5965                                            "select the file to import below:</p>")
    6066                                           .arg(standardHelpText()));
     67    m_pFileSelector->setChooseButtonText(UIWizardImportApp::tr("Open appliance..."));
     68    m_pFileSelector->setFileDialogTitle(UIWizardImportApp::tr("Select an appliance to import"));
     69    m_pFileSelector->setFileFilters(UIWizardImportApp::tr("Open Virtualization Format (%1)").arg("*.ova *.ovf"));
    6170}
    6271
     
    6978bool UIWizardImportAppPageBasic1::isComplete() const
    7079{
    71     const QString &strFile = m_pFileSelector->path().toLower();
    72     return VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts) && QFileInfo(m_pFileSelector->path()).exists();
     80    /* Make sure appliance file has allowed extension and exists: */
     81    return VBoxGlobal::hasAllowedExtension(m_pFileSelector->path().toLower(), VBoxDefs::OVFFileExts) &&
     82           QFileInfo(m_pFileSelector->path()).exists();
    7383}
    7484
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic1.h

    r40870 r41021  
    2424
    2525/* Forward declarations: */
     26class VBoxEmptyFileSelector;
    2627class QIRichTextLabel;
    27 class VBoxEmptyFileSelector;
    2828
    29 /* 1st page of the Import Appliance wizard: */
    30 class UIWizardImportAppPageBasic1 : public UIWizardPage
     29/* 1st page of the Import Appliance wizard (base part): */
     30class UIWizardImportAppPage1 : public UIWizardPageBase
     31{
     32protected:
     33
     34    /* Constructor: */
     35    UIWizardImportAppPage1();
     36
     37    /* Widgets: */
     38    VBoxEmptyFileSelector *m_pFileSelector;
     39};
     40
     41/* 1st page of the Import Appliance wizard (basic extension): */
     42class UIWizardImportAppPageBasic1 : public UIWizardPage, public UIWizardImportAppPage1
    3143{
    3244    Q_OBJECT;
     
    5163    /* Widgets: */
    5264    QIRichTextLabel *m_pLabel;
    53     VBoxEmptyFileSelector *m_pFileSelector;
    5465};
    5566
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.cpp

    r40870 r41021  
    2626#include "QIRichTextLabel.h"
    2727
     28UIWizardImportAppPage2::UIWizardImportAppPage2()
     29{
     30}
     31
    2832UIWizardImportAppPageBasic2::UIWizardImportAppPageBasic2(const QString &strFileName)
    2933{
    3034    /* Create widgets: */
    3135    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     36    {
    3237        m_pLabel = new QIRichTextLabel(this);
    3338        m_pApplianceWidget = new UIApplianceImportEditorWidget(this);
     39        {
    3440            m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
    3541            m_pApplianceWidget->setFile(strFileName);
    36     pMainLayout->addWidget(m_pLabel);
    37     pMainLayout->addWidget(m_pApplianceWidget);
     42        }
     43        pMainLayout->addWidget(m_pLabel);
     44        pMainLayout->addWidget(m_pApplianceWidget);
     45    }
    3846
    39     /* Register ImportAppliancePointer class: */
     47    /* Register classes: */
    4048    qRegisterMetaType<ImportAppliancePointer>();
    41     /* Register 'applianceWidget' field! */
     49    /* Register fields: */
    4250    registerField("applianceWidget", this, "applianceWidget");
    4351}
     
    7179bool UIWizardImportAppPageBasic2::validatePage()
    7280{
    73     /* Import appliance: */
     81    /* Initial result: */
     82    bool fResult = true;
     83
     84    /* Lock finish button: */
    7485    startProcessing();
    75     bool fResult = qobject_cast<UIWizardImportApp*>(wizard())->importAppliance();
     86
     87    /* Try to import appliance: */
     88    if (fResult)
     89        fResult = qobject_cast<UIWizardImportApp*>(wizard())->importAppliance();
     90
     91    /* Unlock finish button: */
    7692    endProcessing();
     93
     94    /* Return result: */
    7795    return fResult;
    7896}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageBasic2.h

    r40870 r41021  
    2828class QIRichTextLabel;
    2929
    30 /* 2nd page of the Import Appliance wizard: */
    31 class UIWizardImportAppPageBasic2 : public UIWizardPage
     30/* 2nd page of the Import Appliance wizard (base part): */
     31class UIWizardImportAppPage2 : public UIWizardPageBase
     32{
     33protected:
     34
     35    /* Constructor: */
     36    UIWizardImportAppPage2();
     37
     38    /* Stuff for 'applianceWidget' field: */
     39    ImportAppliancePointer applianceWidget() const { return m_pApplianceWidget; }
     40
     41    /* Widgets: */
     42    ImportAppliancePointer m_pApplianceWidget;
     43};
     44
     45/* 2nd page of the Import Appliance wizard (basic extension): */
     46class UIWizardImportAppPageBasic2 : public UIWizardPage, public UIWizardImportAppPage2
    3247{
    3348    Q_OBJECT;
     
    3651public:
    3752
     53    /* Constructor: */
    3854    UIWizardImportAppPageBasic2(const QString &strFileName);
    3955
     
    5066    bool validatePage();
    5167
    52     /* Stuff for 'applianceWidget' field: */
    53     ImportAppliancePointer applianceWidget() const { return m_pApplianceWidget; }
    54 
    5568    /* Widgets: */
    5669    QIRichTextLabel *m_pLabel;
    57     ImportAppliancePointer m_pApplianceWidget;
    5870};
    5971
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageExpert.cpp

    r40929 r41021  
    33 *
    44 * VBox frontends: Qt4 GUI ("VirtualBox"):
    5  * UIWizardImportAppPageBasic1 class implementation
     5 * UIWizardImportAppPageExpert class implementation
    66 */
    77
     
    2323
    2424/* Local includes: */
    25 #include "UIWizardImportAppPageBasic1.h"
    26 #include "UIWizardImportAppPageBasic2.h"
     25#include "UIWizardImportAppPageExpert.h"
    2726#include "UIWizardImportApp.h"
    2827#include "VBoxGlobal.h"
    29 #include "QIRichTextLabel.h"
    3028#include "VBoxFilePathSelectorWidget.h"
     29#include "UIApplianceImportEditorWidget.h"
    3130
    32 UIWizardImportAppPageBasic1::UIWizardImportAppPageBasic1()
     31UIWizardImportAppPageExpert::UIWizardImportAppPageExpert(const QString &strFileName)
    3332{
    3433    /* Create widgets: */
    3534    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    36         m_pLabel = new QIRichTextLabel(this);
     35    {
     36        pMainLayout->setContentsMargins(8, 6, 8, 6);
    3737        m_pFileSelector = new VBoxEmptyFileSelector(this);
     38        {
    3839            m_pFileSelector->setMode(VBoxFilePathSelectorWidget::Mode_File_Open);
    3940            m_pFileSelector->setHomeDir(vboxGlobal().documentsPath());
    40     pMainLayout->addWidget(m_pLabel);
    41     pMainLayout->addWidget(m_pFileSelector);
    42     pMainLayout->addStretch();
     41        }
     42        m_pApplianceWidget = new UIApplianceImportEditorWidget(this);
     43        {
     44            m_pApplianceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
     45            m_pApplianceWidget->setFile(strFileName);
     46        }
     47        pMainLayout->addWidget(m_pFileSelector);
     48        pMainLayout->addWidget(m_pApplianceWidget);
     49    }
    4350
    4451    /* Setup connections: */
    45     connect(m_pFileSelector, SIGNAL(pathChanged(const QString&)), this, SIGNAL(completeChanged()));
     52    connect(m_pFileSelector, SIGNAL(pathChanged(const QString&)), this, SLOT(sltFilePathChangeHandler()));
     53
     54    /* Register classes: */
     55    qRegisterMetaType<ImportAppliancePointer>();
     56    /* Register fields: */
     57    registerField("applianceWidget", this, "applianceWidget");
    4658}
    4759
    48 void UIWizardImportAppPageBasic1::retranslateUi()
     60void UIWizardImportAppPageExpert::sltFilePathChangeHandler()
    4961{
    50     /* Translate page: */
    51     setTitle(UIWizardImportApp::tr("Welcome to the Appliance Import Wizard!"));
     62    /* Check if set file contains valid appliance: */
     63    if (m_pApplianceWidget->setFile(m_pFileSelector->path()))
     64    {
     65        /* Reset the modified bit if file was correctly set: */
     66        m_pFileSelector->resetModified();
     67    }
    5268
     69    emit completeChanged();
     70}
     71
     72void UIWizardImportAppPageExpert::retranslateUi()
     73{
    5374    /* Translate widgets: */
     75    m_pFileSelector->setChooseButtonText(UIWizardImportApp::tr("Open appliance..."));
    5476    m_pFileSelector->setFileDialogTitle(UIWizardImportApp::tr("Select an appliance to import"));
    5577    m_pFileSelector->setFileFilters(UIWizardImportApp::tr("Open Virtualization Format (%1)").arg("*.ova *.ovf"));
    56     m_pLabel->setText(UIWizardImportApp::tr("<p>This wizard will guide you through importing an appliance.</p>"
    57                                             "<p>%1</p><p>VirtualBox currently supports importing appliances "
    58                                             "saved in the Open Virtualization Format (OVF). To continue, "
    59                                             "select the file to import below:</p>")
    60                                            .arg(standardHelpText()));
    6178}
    6279
    63 void UIWizardImportAppPageBasic1::initializePage()
     80void UIWizardImportAppPageExpert::initializePage()
    6481{
    6582    /* Translate page: */
     
    6784}
    6885
    69 bool UIWizardImportAppPageBasic1::isComplete() const
     86bool UIWizardImportAppPageExpert::isComplete() const
    7087{
    71     const QString &strFile = m_pFileSelector->path().toLower();
    72     return VBoxGlobal::hasAllowedExtension(strFile, VBoxDefs::OVFFileExts) && QFileInfo(m_pFileSelector->path()).exists();
     88    /* Make sure appliance file has allowed extension and exists and appliance widget is valid: */
     89    return VBoxGlobal::hasAllowedExtension(m_pFileSelector->path().toLower(), VBoxDefs::OVFFileExts) &&
     90           QFileInfo(m_pFileSelector->path()).exists() &&
     91           m_pApplianceWidget->isValid();
    7392}
    7493
    75 bool UIWizardImportAppPageBasic1::validatePage()
     94bool UIWizardImportAppPageExpert::validatePage()
    7695{
    77     /* Get import appliance widget: */
    78     ImportAppliancePointer pImportApplianceWidget = field("applianceWidget").value<ImportAppliancePointer>();
    79     AssertMsg(!pImportApplianceWidget.isNull(), ("Appliance Widget is not set!\n"));
     96    /* Initial result: */
     97    bool fResult = true;
    8098
    81     /* If file name was changed: */
    82     if (m_pFileSelector->isModified())
    83     {
    84         /* Check if set file contains valid appliance: */
    85         if (!pImportApplianceWidget->setFile(m_pFileSelector->path()))
    86             return false;
    87         /* Reset the modified bit afterwards: */
    88         m_pFileSelector->resetModified();
    89     }
     99    /* Lock finish button: */
     100    startProcessing();
    90101
    91     /* If we have a valid ovf proceed to the appliance settings page: */
    92     return pImportApplianceWidget->isValid();
     102    /* Try to import appliance: */
     103    if (fResult)
     104        fResult = qobject_cast<UIWizardImportApp*>(wizard())->importAppliance();
     105
     106    /* Unlock finish button: */
     107    endProcessing();
     108
     109    /* Return result: */
     110    return fResult;
    93111}
    94112
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/importappliance/UIWizardImportAppPageExpert.h

    r40929 r41021  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * UIWizardImportAppPageBasic1 class declaration
     4 * UIWizardImportAppPageExpert class declaration
    55 */
    66
     
    1717 */
    1818
    19 #ifndef __UIWizardImportAppPageBasic1_h__
    20 #define __UIWizardImportAppPageBasic1_h__
     19#ifndef __UIWizardImportAppPageExpert_h__
     20#define __UIWizardImportAppPageExpert_h__
    2121
    2222/* Local includes: */
    23 #include "UIWizardPage.h"
     23#include "UIWizardImportAppPageBasic1.h"
     24#include "UIWizardImportAppPageBasic2.h"
    2425
    25 /* Forward declarations: */
    26 class QIRichTextLabel;
    27 class VBoxEmptyFileSelector;
    28 
    29 /* 1st page of the Import Appliance wizard: */
    30 class UIWizardImportAppPageBasic1 : public UIWizardPage
     26/* Expert page of the Import Appliance wizard: */
     27class UIWizardImportAppPageExpert : public UIWizardPage,
     28                                    public UIWizardImportAppPage1,
     29                                    public UIWizardImportAppPage2
    3130{
    3231    Q_OBJECT;
     32    Q_PROPERTY(ImportAppliancePointer applianceWidget READ applianceWidget);
    3333
    3434public:
    3535
    3636    /* Constructor: */
    37     UIWizardImportAppPageBasic1();
     37    UIWizardImportAppPageExpert(const QString &strFileName);
     38
     39private slots:
     40
     41    /* File-path change handler: */
     42    void sltFilePathChangeHandler();
    3843
    3944private:
     
    4853    bool isComplete() const;
    4954    bool validatePage();
    50 
    51     /* Widgets: */
    52     QIRichTextLabel *m_pLabel;
    53     VBoxEmptyFileSelector *m_pFileSelector;
    5455};
    5556
    56 #endif /* __UIWizardImportAppPageBasic1_h__ */
     57#endif /* __UIWizardImportAppPageExpert_h__ */
    5758
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVD.cpp

    r40870 r41021  
    2727#include "UIWizardNewVDPageBasic3.h"
    2828#include "UIWizardNewVDPageBasic4.h"
     29#include "UIWizardNewVDPageExpert.h"
    2930#include "VBoxGlobal.h"
    3031#include "UIMessageCenter.h"
    3132
    3233UIWizardNewVD::UIWizardNewVD(QWidget *pParent, const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize)
    33     : UIWizard(pParent)
     34    : UIWizard(pParent, UIWizardType_NewVD)
     35    , m_strDefaultName(strDefaultName)
     36    , m_strDefaultPath(strDefaultPath)
     37    , m_uDefaultSize(uDefaultSize)
    3438{
    35 #ifdef Q_WS_WIN
    36     /* Hide window icon: */
    37     setWindowIcon(QIcon());
    38 #endif /* Q_WS_WIN */
    39 
    40     /* Create & add pages: */
    41     setPage(Page1, new UIWizardNewVDPageBasic1);
    42     setPage(Page2, new UIWizardNewVDPageBasic2);
    43     setPage(Page3, new UIWizardNewVDPageBasic3(strDefaultName, strDefaultPath, uDefaultSize));
    44     setPage(Page4, new UIWizardNewVDPageBasic4);
    45 
    46     /* Translate wizard: */
    47     retranslateUi();
    48 
    49     /* Translate wizard pages: */
    50     retranslateAllPages();
    51 
    5239#ifndef Q_WS_MAC
    5340    /* Assign watermark: */
     
    5744    assignBackground(":/vmw_new_harddisk_bg.png");
    5845#endif /* Q_WS_MAC */
    59 
    60     /* Resize wizard to 'golden ratio': */
    61     resizeToGoldenRatio(UIWizardType_NewVD);
    6246}
    6347
     
    8771    QString strMediumPath = field("mediumPath").toString();
    8872    qulonglong uSize = field("mediumSize").toULongLong();
    89 
    9073    /* Check attributes: */
    9174    AssertReturn(!strMediumPath.isNull(), false);
     
    10689    /* Create base storage for the new hard disk: */
    10790    progress = virtualDisk.CreateBaseStorage(uSize, uVariant);
    108 
    109     /* Check for errors: */
    11091    if (!virtualDisk.isOk())
    11192    {
     
    11394        return false;
    11495    }
     96
     97    /* Show creation progress: */
    11598    msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_create_90px.png", this, true);
    11699    if (progress.GetCanceled())
     
    122105    }
    123106
    124     /* Assign virtualDisk field value: */
     107    /* Remember created virtual-disk: */
    125108    m_virtualDisk = virtualDisk;
    126109
     
    133116void UIWizardNewVD::retranslateUi()
    134117{
     118    /* Call to base-class: */
     119    UIWizard::retranslateUi();
     120
    135121    /* Translate wizard: */
    136122    setWindowTitle(tr("Create New Virtual Disk"));
     
    138124}
    139125
     126void UIWizardNewVD::prepare()
     127{
     128    /* Create corresponding pages: */
     129    switch (mode())
     130    {
     131        case UIWizardMode_Basic:
     132        {
     133            setPage(Page1, new UIWizardNewVDPageBasic1);
     134            setPage(Page2, new UIWizardNewVDPageBasic2);
     135            setPage(Page3, new UIWizardNewVDPageBasic3(m_strDefaultName, m_strDefaultPath, m_uDefaultSize));
     136            setPage(Page4, new UIWizardNewVDPageBasic4);
     137            break;
     138        }
     139        case UIWizardMode_Expert:
     140        {
     141            setPage(PageExpert, new UIWizardNewVDPageExpert(m_strDefaultName, m_strDefaultPath, m_uDefaultSize));
     142            break;
     143        }
     144    }
     145    /* Call to base-class: */
     146    UIWizard::prepare();
     147}
     148
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVD.h

    r40870 r41021  
    4040    };
    4141
     42    /* Page IDs: */
     43    enum
     44    {
     45        PageExpert
     46    };
     47
    4248    /* Constructor: */
    43     UIWizardNewVD(QWidget *pParent, const QString &strDefaultName,
    44                   const QString &strDefaultPath, qulonglong uDefaultSize);
     49    UIWizardNewVD(QWidget *pParent,
     50                  const QString &strDefaultName, const QString &strDefaultPath,
     51                  qulonglong uDefaultSize);
    4552
    4653    /* Returns virtual-disk: */
     
    5764    /* Who will be able to create virtual-disk: */
    5865    friend class UIWizardNewVDPageBasic4;
     66    friend class UIWizardNewVDPageExpert;
    5967
    6068private:
     
    6371    void retranslateUi();
    6472
     73    /* Pages related stuff: */
     74    void prepare();
     75
    6576    /* Variables: */
     77    QString m_strDefaultName;
     78    QString m_strDefaultPath;
     79    qulonglong m_uDefaultSize;
    6680    CMedium m_virtualDisk;
    6781};
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.cpp

    r40870 r41021  
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QButtonGroup>
     23#include <QGroupBox>
    2224#include <QRadioButton>
    23 #include <QGroupBox>
    24 #include <QButtonGroup>
    2525
    2626/* Local includes: */
     
    3030#include "QIRichTextLabel.h"
    3131
     32UIWizardNewVDPage1::UIWizardNewVDPage1()
     33{
     34}
     35
     36QRadioButton* UIWizardNewVDPage1::addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mf)
     37{
     38    /* Check that medium format supports creation: */
     39    ULONG uFormatCapabilities = mf.GetCapabilities();
     40    if (!(uFormatCapabilities & MediumFormatCapabilities_CreateFixed ||
     41          uFormatCapabilities & MediumFormatCapabilities_CreateDynamic))
     42        return 0;
     43
     44    /* Check that medium format supports creation of virtual hard-disks: */
     45    QVector<QString> fileExtensions;
     46    QVector<KDeviceType> deviceTypes;
     47    mf.DescribeFileExtensions(fileExtensions, deviceTypes);
     48    if (!deviceTypes.contains(KDeviceType_HardDisk))
     49        return 0;
     50
     51    /* Create/add corresponding radio-button: */
     52    QRadioButton *pFormatButton = new QRadioButton(m_pFormatCnt);
     53    pFormatsLayout->addWidget(pFormatButton);
     54    return pFormatButton;
     55}
     56
     57CMediumFormat UIWizardNewVDPage1::mediumFormat() const
     58{
     59    return m_pFormatButtonGroup->checkedButton() ? m_formats[m_pFormatButtonGroup->checkedId()] : CMediumFormat();
     60}
     61
     62void UIWizardNewVDPage1::setMediumFormat(const CMediumFormat &mediumFormat)
     63{
     64    int iPosition = m_formats.indexOf(mediumFormat);
     65    if (iPosition >= 0)
     66    {
     67        m_pFormatButtonGroup->button(iPosition)->click();
     68        m_pFormatButtonGroup->button(iPosition)->setFocus();
     69    }
     70}
     71
    3272UIWizardNewVDPageBasic1::UIWizardNewVDPageBasic1()
    3373{
    3474    /* Create widgets: */
    3575    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     76    {
    3677        m_pLabel = new QIRichTextLabel(this);
    37         m_pFormatContainer = new QGroupBox(this);
    38             m_pFormatContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    39             QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatContainer);
    40     pMainLayout->addWidget(m_pLabel);
    41     pMainLayout->addWidget(m_pFormatContainer);
    42     pMainLayout->addStretch();
    43 
    44     /* Greate button group: */
    45     m_pButtonGroup = new QButtonGroup(this);
    46 
    47     /* Enumerate supportable formats: */
    48     CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
    49     const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
    50     /* Search for default (VDI) format first: */
    51     for (int i = 0; i < medFormats.size(); ++i)
    52     {
    53         /* Get iterated medium format: */
    54         const CMediumFormat &medFormat = medFormats[i];
    55         QString strFormatName(medFormat.GetName());
    56         if (strFormatName == "VDI")
     78        m_pFormatCnt = new QGroupBox(this);
    5779        {
    58             QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
    59             if (pButton)
     80            m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     81            m_pFormatButtonGroup = new QButtonGroup(m_pFormatCnt);
    6082            {
    61                 m_formats << medFormat;
    62                 m_formatNames << strFormatName;
    63                 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     83                QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatCnt);
     84                {
     85                    CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
     86                    const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
     87                    for (int i = 0; i < medFormats.size(); ++i)
     88                    {
     89                        const CMediumFormat &medFormat = medFormats[i];
     90                        QString strFormatName(medFormat.GetName());
     91                        if (strFormatName == "VDI")
     92                        {
     93                            QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
     94                            if (pButton)
     95                            {
     96                                m_formats << medFormat;
     97                                m_formatNames << strFormatName;
     98                                m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     99                            }
     100                        }
     101                    }
     102                    for (int i = 0; i < medFormats.size(); ++i)
     103                    {
     104                        const CMediumFormat &medFormat = medFormats[i];
     105                        QString strFormatName(medFormat.GetName());
     106                        if (strFormatName != "VDI")
     107                        {
     108                            QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
     109                            if (pButton)
     110                            {
     111                                m_formats << medFormat;
     112                                m_formatNames << strFormatName;
     113                                m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     114                            }
     115                        }
     116                    }
     117                }
     118                m_pFormatButtonGroup->button(0)->click();
     119                m_pFormatButtonGroup->button(0)->setFocus();
    64120            }
    65121        }
    66     }
    67     /* Look for other formats: */
    68     for (int i = 0; i < medFormats.size(); ++i)
    69     {
    70         /* Get iterated medium format: */
    71         const CMediumFormat &medFormat = medFormats[i];
    72         QString strFormatName(medFormat.GetName());
    73         if (strFormatName != "VDI")
    74         {
    75             QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
    76             if (pButton)
    77             {
    78                 m_formats << medFormat;
    79                 m_formatNames << strFormatName;
    80                 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1);
    81             }
    82         }
     122        pMainLayout->addWidget(m_pLabel);
     123        pMainLayout->addWidget(m_pFormatCnt);
     124        pMainLayout->addStretch();
    83125    }
    84126
    85127    /* Setup connections: */
    86     connect(m_pButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(completeChanged()));
     128    connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(completeChanged()));
    87129
    88     /* Initialize connections: */
    89     m_pButtonGroup->button(0)->click();
    90     m_pButtonGroup->button(0)->setFocus();
    91 
    92     /* Register CMediumFormat class: */
     130    /* Register classes: */
    93131    qRegisterMetaType<CMediumFormat>();
    94     /* Register 'mediumFormat' field: */
     132    /* Register fields: */
    95133    registerField("mediumFormat", this, "mediumFormat");
    96134}
     
    99137{
    100138    /* Translate page: */
    101     setTitle(UIWizardNewVD::tr("Welcome to the virtual disk creation wizard"));
     139    setTitle(UIWizardNewVD::tr("Welcome to the New Virtual Disk wizard!"));
    102140
    103141    /* Translate widgets: */
     
    108146                                                           "to use it with other virtualization software you can "
    109147                                                           "leave this setting unchanged.</p>"));
    110     m_pFormatContainer->setTitle(UIWizardNewVD::tr("File type"));
    111 
    112     /* Translate 'format' buttons: */
    113     QList<QAbstractButton*> buttons = m_pButtonGroup->buttons();
     148    m_pFormatCnt->setTitle(UIWizardNewVD::tr("File type"));
     149    QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons();
    114150    for (int i = 0; i < buttons.size(); ++i)
    115151    {
    116152        QAbstractButton *pButton = buttons[i];
    117         pButton->setText(UIWizardNewVD::fullFormatName(m_formatNames[m_pButtonGroup->id(pButton)]));
     153        pButton->setText(UIWizardNewVD::fullFormatName(m_formatNames[m_pFormatButtonGroup->id(pButton)]));
    118154    }
    119155}
     
    127163bool UIWizardNewVDPageBasic1::isComplete() const
    128164{
     165    /* Make sure medium format is correct: */
    129166    return !mediumFormat().isNull();
    130167}
     
    132169int UIWizardNewVDPageBasic1::nextId() const
    133170{
    134     CMediumFormat medFormat = mediumFormat();
    135     ULONG uCapabilities = medFormat.GetCapabilities();
     171    /* Show variant page only if there is something to show: */
     172    CMediumFormat mf = mediumFormat();
     173    ULONG uCapabilities = mf.GetCapabilities();
    136174    int cTest = 0;
    137175    if (uCapabilities & KMediumFormatCapabilities_CreateDynamic)
     
    143181    if (cTest > 1)
    144182        return UIWizardNewVD::Page2;
     183    /* Skip otherwise: */
    145184    return UIWizardNewVD::Page3;
    146185}
    147186
    148 QRadioButton* UIWizardNewVDPageBasic1::addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat medFormat)
    149 {
    150     /* Check that medium format supports creation: */
    151     ULONG uFormatCapabilities = medFormat.GetCapabilities();
    152     if (!(uFormatCapabilities & MediumFormatCapabilities_CreateFixed ||
    153           uFormatCapabilities & MediumFormatCapabilities_CreateDynamic))
    154         return 0;
    155 
    156     /* Check that medium format supports creation of virtual hard-disks: */
    157     QVector<QString> fileExtensions;
    158     QVector<KDeviceType> deviceTypes;
    159     medFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    160     if (!deviceTypes.contains(KDeviceType_HardDisk))
    161         return 0;
    162 
    163     /* Create/add corresponding radio-button: */
    164     QRadioButton *pFormatButton = new QRadioButton(m_pFormatContainer);
    165     pFormatsLayout->addWidget(pFormatButton);
    166     return pFormatButton;
    167 }
    168 
    169 CMediumFormat UIWizardNewVDPageBasic1::mediumFormat() const
    170 {
    171     return m_pButtonGroup->checkedButton() ? m_formats[m_pButtonGroup->checkedId()] : CMediumFormat();
    172 }
    173 
    174 void UIWizardNewVDPageBasic1::setMediumFormat(const CMediumFormat &mediumFormat)
    175 {
    176     int iPosition = m_formats.indexOf(mediumFormat);
    177     if (iPosition >= 0)
    178     {
    179         m_pButtonGroup->button(iPosition)->click();
    180         m_pButtonGroup->button(iPosition)->setFocus();
    181     }
    182 }
    183 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic1.h

    r40870 r41021  
    2626/* Forward declarations: */
    2727class QVBoxLayout;
     28class QButtonGroup;
     29class QGroupBox;
    2830class QRadioButton;
    2931class QIRichTextLabel;
    30 class QGroupBox;
    31 class QButtonGroup;
    3232
    33 /* 1st page of the New Virtual Disk wizard: */
    34 class UIWizardNewVDPageBasic1 : public UIWizardPage
     33/* 1st page of the New Virtual Disk wizard (base part): */
     34class UIWizardNewVDPage1 : public UIWizardPageBase
     35{
     36protected:
     37
     38    /* Constructor: */
     39    UIWizardNewVDPage1();
     40
     41    /* Helping stuff: */
     42    QRadioButton* addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mf);
     43
     44    /* Stuff for 'mediumFormat' field: */
     45    CMediumFormat mediumFormat() const;
     46    void setMediumFormat(const CMediumFormat &mediumFormat);
     47
     48    /* Variables: */
     49    QButtonGroup *m_pFormatButtonGroup;
     50    QList<CMediumFormat> m_formats;
     51    QStringList m_formatNames;
     52
     53    /* Widgets: */
     54    QGroupBox *m_pFormatCnt;
     55};
     56
     57/* 1st page of the New Virtual Disk wizard (basic extension): */
     58class UIWizardNewVDPageBasic1 : public UIWizardPage, public UIWizardNewVDPage1
    3559{
    3660    Q_OBJECT;
     
    5680    int nextId() const;
    5781
    58     /* Helping stuff: */
    59     QRadioButton* addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mediumFormat);
    60 
    61     /* Stuff for 'mediumFormat' field: */
    62     CMediumFormat mediumFormat() const;
    63     void setMediumFormat(const CMediumFormat &mediumFormat);
    64 
    65     /* Variables: */
    66     QButtonGroup *m_pButtonGroup;
    67     QList<CMediumFormat> m_formats;
    68     QStringList m_formatNames;
    69 
    7082    /* Widgets: */
    7183    QIRichTextLabel *m_pLabel;
    72     QGroupBox *m_pFormatContainer;
    7384};
    7485
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.cpp

    r40870 r41021  
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QGroupBox>
     23#include <QButtonGroup>
    2224#include <QRadioButton>
    2325#include <QCheckBox>
    24 #include <QGroupBox>
    2526
    2627/* Local includes: */
     
    3031#include "QIRichTextLabel.h"
    3132
     33UIWizardNewVDPage2::UIWizardNewVDPage2()
     34{
     35}
     36
     37qulonglong UIWizardNewVDPage2::mediumVariant() const
     38{
     39    /* Initial value: */
     40    qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max;
     41
     42    /* Exclusive options: */
     43    if (m_pDynamicalButton->isChecked())
     44        uMediumVariant = (qulonglong)KMediumVariant_Standard;
     45    else if (m_pFixedButton->isChecked())
     46        uMediumVariant = (qulonglong)KMediumVariant_Fixed;
     47
     48    /* Additional options: */
     49    if (m_pSplitBox->isChecked())
     50        uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G;
     51
     52    /* Return options: */
     53    return uMediumVariant;
     54}
     55
     56void UIWizardNewVDPage2::setMediumVariant(qulonglong uMediumVariant)
     57{
     58    /* Exclusive options: */
     59    if (uMediumVariant & (qulonglong)KMediumVariant_Fixed)
     60    {
     61        m_pFixedButton->click();
     62        m_pFixedButton->setFocus();
     63    }
     64    else
     65    {
     66        m_pDynamicalButton->click();
     67        m_pDynamicalButton->setFocus();
     68    }
     69
     70    /* Additional options: */
     71    m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G);
     72}
     73
    3274UIWizardNewVDPageBasic2::UIWizardNewVDPageBasic2()
    33     : m_pDynamicalButton(0), m_pFixedButton(0), m_pSplitBox(0)
    3475{
    3576    /* Create widgets: */
    3677    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     78    {
    3779        m_pDescriptionLabel = new QIRichTextLabel(this);
    3880        m_pDynamicLabel = new QIRichTextLabel(this);
    3981        m_pFixedLabel = new QIRichTextLabel(this);
    4082        m_pSplitLabel = new QIRichTextLabel(this);
    41         m_pVariantContainer = new QGroupBox(this);
    42             m_pVariantContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    43             QVBoxLayout *pVariantsLayout = new QVBoxLayout(m_pVariantContainer);
    44                 m_pDynamicalButton = new QRadioButton(m_pVariantContainer);
    45                     m_pDynamicalButton->click();
    46                     m_pDynamicalButton->setFocus();
    47                 m_pFixedButton = new QRadioButton(m_pVariantContainer);
    48                 m_pSplitBox = new QCheckBox(m_pVariantContainer);
    49             pVariantsLayout->addWidget(m_pDynamicalButton);
    50             pVariantsLayout->addWidget(m_pFixedButton);
    51             pVariantsLayout->addWidget(m_pSplitBox);
    52     pMainLayout->addWidget(m_pDescriptionLabel);
    53     pMainLayout->addWidget(m_pDynamicLabel);
    54     pMainLayout->addWidget(m_pFixedLabel);
    55     pMainLayout->addWidget(m_pSplitLabel);
    56     pMainLayout->addWidget(m_pVariantContainer);
    57     pMainLayout->addStretch();
     83        m_pVariantCnt = new QGroupBox(this);
     84        {
     85            m_pVariantCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     86            QVBoxLayout *pVariantCntLayout = new QVBoxLayout(m_pVariantCnt);
     87            {
     88                m_pVariantButtonGroup = new QButtonGroup(m_pVariantCnt);
     89                {
     90                    m_pDynamicalButton = new QRadioButton(m_pVariantCnt);
     91                    {
     92                        m_pDynamicalButton->click();
     93                        m_pDynamicalButton->setFocus();
     94                    }
     95                    m_pFixedButton = new QRadioButton(m_pVariantCnt);
     96                    m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
     97                    m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
     98                }
     99                m_pSplitBox = new QCheckBox(m_pVariantCnt);
     100                pVariantCntLayout->addWidget(m_pDynamicalButton);
     101                pVariantCntLayout->addWidget(m_pFixedButton);
     102                pVariantCntLayout->addWidget(m_pSplitBox);
     103            }
     104        }
     105        pMainLayout->addWidget(m_pDescriptionLabel);
     106        pMainLayout->addWidget(m_pDynamicLabel);
     107        pMainLayout->addWidget(m_pFixedLabel);
     108        pMainLayout->addWidget(m_pSplitLabel);
     109        pMainLayout->addWidget(m_pVariantCnt);
     110        pMainLayout->addStretch();
     111    }
    58112
    59113    /* Setup connections: */
    60     connect(m_pDynamicalButton, SIGNAL(clicked(bool)), this, SIGNAL(completeChanged()));
    61     connect(m_pFixedButton, SIGNAL(clicked(bool)), this, SIGNAL(completeChanged()));
     114    connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged()));
    62115    connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged()));
    63116
    64     /* Register 'mediumVariant' field: */
     117    /* Register fields: */
    65118    registerField("mediumVariant", this, "mediumVariant");
    66119}
     
    83136                                             "virtual machine on removable USB devices or old systems, some of which cannot "
    84137                                             "handle very large files."));
    85     m_pVariantContainer->setTitle(UIWizardNewVD::tr("Storage details"));
    86 
    87     /* Translate buttons: */
     138    m_pVariantCnt->setTitle(UIWizardNewVD::tr("Storage details"));
    88139    m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated"));
    89140    m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size"));
     
    112163bool UIWizardNewVDPageBasic2::isComplete() const
    113164{
     165    /* Make sure medium variant is correct: */
    114166    return mediumVariant() != (qulonglong)KMediumVariant_Max;
    115167}
    116168
    117 qulonglong UIWizardNewVDPageBasic2::mediumVariant() const
    118 {
    119     /* Initial value: */
    120     qulonglong uMediumVariant = (qulonglong)KMediumVariant_Max;
    121 
    122     /* Exclusive options: */
    123     if (m_pDynamicalButton->isChecked())
    124         uMediumVariant = (qulonglong)KMediumVariant_Standard;
    125     else if (m_pFixedButton->isChecked())
    126         uMediumVariant = (qulonglong)KMediumVariant_Fixed;
    127 
    128     /* Additional options: */
    129     if (m_pSplitBox->isChecked())
    130         uMediumVariant |= (qulonglong)KMediumVariant_VmdkSplit2G;
    131 
    132     /* Return options: */
    133     return uMediumVariant;
    134 }
    135 
    136 void UIWizardNewVDPageBasic2::setMediumVariant(qulonglong uMediumVariant)
    137 {
    138     /* Exclusive options: */
    139     if (uMediumVariant & (qulonglong)KMediumVariant_Fixed)
    140     {
    141         m_pFixedButton->click();
    142         m_pFixedButton->setFocus();
    143     }
    144     else
    145     {
    146         m_pDynamicalButton->click();
    147         m_pDynamicalButton->setFocus();
    148     }
    149 
    150     /* Additional options: */
    151     m_pSplitBox->setChecked(uMediumVariant & (qulonglong)KMediumVariant_VmdkSplit2G);
    152 }
    153 
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.h

    r40870 r41021  
    2424
    2525/* Forward declarations: */
     26class QGroupBox;
     27class QButtonGroup;
    2628class QRadioButton;
    2729class QCheckBox;
    2830class QIRichTextLabel;
    29 class QGroupBox;
    3031
    31 /* 2nd page of the New Virtual Disk wizard: */
    32 class UIWizardNewVDPageBasic2 : public UIWizardPage
     32/* 2nd page of the New Virtual Disk wizard (base part): */
     33class UIWizardNewVDPage2 : public UIWizardPageBase
     34{
     35protected:
     36
     37    /* Constructor: */
     38    UIWizardNewVDPage2();
     39
     40    /* Stuff for 'variant' field: */
     41    qulonglong mediumVariant() const;
     42    void setMediumVariant(qulonglong uMediumVariant);
     43
     44    /* Widgets: */
     45    QGroupBox *m_pVariantCnt;
     46    QButtonGroup *m_pVariantButtonGroup;
     47    QRadioButton *m_pDynamicalButton;
     48    QRadioButton *m_pFixedButton;
     49    QCheckBox *m_pSplitBox;
     50};
     51
     52/* 2nd page of the New Virtual Disk wizard (basic extension): */
     53class UIWizardNewVDPageBasic2 : public UIWizardPage, public UIWizardNewVDPage2
    3354{
    3455    Q_OBJECT;
     
    5172    bool isComplete() const;
    5273
    53     /* Stuff for 'variant' field: */
    54     qulonglong mediumVariant() const;
    55     void setMediumVariant(qulonglong uMediumVariant);
    56 
    57     /* Variables: */
    58     QRadioButton *m_pDynamicalButton;
    59     QRadioButton *m_pFixedButton;
    60     QCheckBox *m_pSplitBox;
    61 
    6274    /* Widgets: */
    6375    QIRichTextLabel *m_pDescriptionLabel;
     
    6577    QIRichTextLabel *m_pFixedLabel;
    6678    QIRichTextLabel *m_pSplitLabel;
    67     QGroupBox *m_pVariantContainer;
    6879};
    6980
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.cpp

    r40870 r41021  
    4040#include "QIToolButton.h"
    4141#include "QILineEdit.h"
    42 #include "iprt/path.h"
    43 
    44 UIWizardNewVDPageBasic3::UIWizardNewVDPageBasic3(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize)
     42
     43UIWizardNewVDPage3::UIWizardNewVDPage3(const QString &strDefaultName, const QString &strDefaultPath)
    4544    : m_strDefaultName(strDefaultName.isEmpty() ? QString("NewVirtualDisk1") : strDefaultName)
    4645    , m_strDefaultPath(strDefaultPath)
    4746    , m_uMediumSizeMin(_4M)
    4847    , m_uMediumSizeMax(vboxGlobal().virtualBox().GetSystemProperties().GetInfoVDSize())
    49     , m_iSliderScale(0)
    50 {
    51     /* Detect how many steps to recognize between adjacent powers of 2
    52      * to ensure that the last slider step is exactly that we need: */
    53     int iPower = log2i(m_uMediumSizeMax);
    54     qulonglong uTickMB = qulonglong (1) << iPower;
    55     if (uTickMB < m_uMediumSizeMax)
    56     {
    57         qulonglong uTickMBNext = qulonglong (1) << (iPower + 1);
    58         qulonglong uGap = uTickMBNext - m_uMediumSizeMax;
    59         m_iSliderScale = (int)((uTickMBNext - uTickMB) / uGap);
    60     }
    61     m_iSliderScale = qMax(m_iSliderScale, 8);
    62 
    63     /* Create widgets: */
    64     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    65         m_pLocationLabel = new QIRichTextLabel(this);
    66         m_pLocationCnt = new QGroupBox(this);
    67             m_pLocationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    68             QHBoxLayout *pOptionsLayout = new QHBoxLayout(m_pLocationCnt);
    69                 m_pLocationEditor = new QLineEdit(m_pLocationCnt);
    70                 m_pLocationSelector = new QIToolButton(m_pLocationCnt);
    71                     m_pLocationSelector->setAutoRaise(true);
    72                     m_pLocationSelector->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png"));
    73             pOptionsLayout->addWidget(m_pLocationEditor);
    74             pOptionsLayout->addWidget(m_pLocationSelector);
    75         m_pSizeLabel = new QIRichTextLabel(this);
    76         m_pSizeCnt = new QGroupBox(this);
    77             m_pSizeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    78             QGridLayout *m_pSizeLayout = new QGridLayout(m_pSizeCnt);
    79                 m_pSizeSlider = new QSlider(m_pSizeCnt);
    80                     m_pSizeSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    81                     m_pSizeSlider->setOrientation(Qt::Horizontal);
    82                     m_pSizeSlider->setTickPosition(QSlider::TicksBelow);
    83                     m_pSizeSlider->setFocusPolicy(Qt::StrongFocus);
    84                     m_pSizeSlider->setPageStep(m_iSliderScale);
    85                     m_pSizeSlider->setSingleStep(m_iSliderScale / 8);
    86                     m_pSizeSlider->setTickInterval(0);
    87                     m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMediumSizeMin, m_iSliderScale));
    88                     m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMediumSizeMax, m_iSliderScale));
    89                 m_pSizeEditor = new QILineEdit(m_pSizeCnt);
    90                     m_pSizeEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
    91                     m_pSizeEditor->setFixedWidthByText("88888.88 MB");
    92                     m_pSizeEditor->setAlignment(Qt::AlignRight);
    93                     m_pSizeEditor->setValidator(new QRegExpValidator(QRegExp(vboxGlobal().sizeRegexp()), this));
    94                 QLabel *m_pSizeMin = new QLabel(m_pSizeCnt);
    95                     m_pSizeMin->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
    96                     m_pSizeMin->setText(vboxGlobal().formatSize(m_uMediumSizeMin));
    97                 QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed);
    98                 QLabel *m_pSizeMax = new QLabel(m_pSizeCnt);
    99                     m_pSizeMax->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
    100                     m_pSizeMax->setText(vboxGlobal().formatSize(m_uMediumSizeMax));
    101             m_pSizeLayout->addWidget(m_pSizeSlider, 0, 0, 1, 3);
    102             m_pSizeLayout->addWidget(m_pSizeEditor, 0, 3);
    103             m_pSizeLayout->addWidget(m_pSizeMin, 1, 0);
    104             m_pSizeLayout->addItem(m_pSizeSpacer, 1, 1);
    105             m_pSizeLayout->addWidget(m_pSizeMax, 1, 2);
    106     pMainLayout->addWidget(m_pLocationLabel);
    107     pMainLayout->addWidget(m_pLocationCnt);
    108     pMainLayout->addWidget(m_pSizeLabel);
    109     pMainLayout->addWidget(m_pSizeCnt);
    110     pMainLayout->addStretch();
    111 
    112     /* Setup connections: */
    113     connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltLocationEditorTextChanged(const QString &)));
    114     connect(m_pLocationSelector, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked()));
    115     connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(sltSizeSliderValueChanged(int)));
    116     connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltSizeEditorTextChanged(const QString &)));
    117 
    118     /* Initialize connections: */
    119     setMediumSize(uDefaultSize);
    120 
    121     /* Register 'mediumPath', 'mediumSize' fields: */
    122     registerField("mediumPath", this, "mediumPath");
    123     registerField("mediumSize", this, "mediumSize");
    124 }
    125 
    126 void UIWizardNewVDPageBasic3::sltLocationEditorTextChanged(const QString &strMediumName)
    127 {
    128     /* Compose new medium path: */
    129     m_strMediumPath = absoluteFilePath(toFileName(strMediumName, m_strDefaultExtension), m_strDefaultPath);
    130     /* Notify wizard sub-system about complete status changed: */
    131     emit completeChanged();
    132 }
    133 
    134 void UIWizardNewVDPageBasic3::sltSelectLocationButtonClicked()
     48    , m_iSliderScale(calculateSliderScale(m_uMediumSizeMax))
     49{
     50}
     51
     52void UIWizardNewVDPage3::onSelectLocationButtonClicked()
    13553{
    13654    /* Get current folder and filename: */
    137     QFileInfo fullFilePath(m_strMediumPath);
     55    QFileInfo fullFilePath(mediumPath());
    13856    QDir folder = fullFilePath.path();
    13957    QString strFileName = fullFilePath.fileName();
     
    15775
    15876    /* Prepare backends list: */
    159     CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
    16077    QVector<QString> fileExtensions;
    16178    QVector<KDeviceType> deviceTypes;
     79    CMediumFormat mediumFormat = fieldImp("mediumFormat").value<CMediumFormat>();
    16280    mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    16381    QStringList validExtensionList;
     
    17088    /* Open corresponding file-dialog: */
    17189    QString strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName),
    172                                                               strBackendsList, this,
    173                                                               UIWizardNewVD::tr("Select a file for the new hard disk image file"));
     90                                                              strBackendsList, thisImp(),
     91                                                              VBoxGlobal::tr("Choose a virtual hard disk file"));
    17492
    17593    /* If there was something really chosen: */
     
    185103}
    186104
    187 void UIWizardNewVDPageBasic3::sltSizeSliderValueChanged(int iValue)
     105void UIWizardNewVDPage3::onSizeSliderValueChanged(int iValue)
    188106{
    189107    /* Get full size: */
     
    195113    m_pSizeEditor->setText(vboxGlobal().formatSize(uMediumSize));
    196114    m_pSizeEditor->blockSignals(false);
    197     /* Notify wizard sub-system about complete status changed: */
    198     emit completeChanged();
    199 }
    200 
    201 void UIWizardNewVDPageBasic3::sltSizeEditorTextChanged(const QString &strValue)
     115}
     116
     117void UIWizardNewVDPage3::onSizeEditorTextChanged(const QString &strValue)
    202118{
    203119    /* Get full size: */
     
    209125    m_pSizeSlider->setValue(sizeMBToSlider(uMediumSize, m_iSliderScale));
    210126    m_pSizeSlider->blockSignals(false);
    211     /* Notify wizard sub-system about complete status changed: */
    212     emit completeChanged();
    213 }
    214 
    215 void UIWizardNewVDPageBasic3::retranslateUi()
    216 {
    217     /* Translate page: */
    218     setTitle(UIWizardNewVD::tr("Virtual disk file location and size"));
    219 
    220     /* Translate widgets: */
    221     m_pLocationLabel->setText(UIWizardNewVD::tr("Please type the name of the new virtual disk file into the box below or "
    222                                                 "click on the folder icon to select a different folder to create the file in."));
    223     m_pLocationCnt->setTitle(tr("&Location"));
    224     m_pSizeLabel->setText(UIWizardNewVD::tr("Select the size of the virtual disk in megabytes. This size will be reported "
    225                                             "to the Guest OS as the maximum size of this virtual disk."));
    226     m_pSizeCnt->setTitle(UIWizardNewVD::tr("&Size"));
    227 }
    228 
    229 void UIWizardNewVDPageBasic3::initializePage()
    230 {
    231     /* Translate page: */
    232     retranslateUi();
    233 
    234     /* Reset name to default: */
    235     m_pLocationEditor->setText(m_strDefaultName);
    236     /* Get virtual-disk extension: */
    237     m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>());
    238     /* Compose path for new virtual-disk: */
    239     m_strMediumPath = absoluteFilePath(toFileName(m_strDefaultName, m_strDefaultExtension), m_strDefaultPath);
    240 }
    241 
    242 bool UIWizardNewVDPageBasic3::isComplete() const
    243 {
    244     /* Check what current name is not empty & current size feats the bounds: */
    245     return !m_pLocationEditor->text().trimmed().isEmpty() &&
    246            mediumSize() >= m_uMediumSizeMin && mediumSize() <= m_uMediumSizeMax;
    247 }
    248 
    249 bool UIWizardNewVDPageBasic3::validatePage()
    250 {
    251     if (QFileInfo(m_strMediumPath).exists())
    252     {
    253         msgCenter().sayCannotOverwriteHardDiskStorage(this, m_strMediumPath);
    254         return false;
    255     }
    256     return true;
    257 }
    258 
    259 /* static */
    260 QString UIWizardNewVDPageBasic3::toFileName(const QString &strName, const QString &strExtension)
     127}
     128
     129/* static */
     130QString UIWizardNewVDPage3::toFileName(const QString &strName, const QString &strExtension)
    261131{
    262132    /* Convert passed name to native separators (it can be full, actually): */
     
    277147
    278148/* static */
    279 QString UIWizardNewVDPageBasic3::absoluteFilePath(const QString &strFileName, const QString &strDefaultPath)
     149QString UIWizardNewVDPage3::absoluteFilePath(const QString &strFileName, const QString &strDefaultPath)
    280150{
    281151    /* Wrap file-info around received file name: */
     
    292162
    293163/* static */
    294 QString UIWizardNewVDPageBasic3::defaultExtension(const CMediumFormat &mediumFormatRef)
     164QString UIWizardNewVDPage3::defaultExtension(const CMediumFormat &mediumFormatRef)
    295165{
    296166    /* Load extension / device list: */
     
    307177
    308178/* static */
    309 int UIWizardNewVDPageBasic3::log2i(qulonglong uValue)
     179int UIWizardNewVDPage3::calculateSliderScale(qulonglong uMaximumMediumSize)
     180{
     181    /* Detect how many steps to recognize between adjacent powers of 2
     182     * to ensure that the last slider step is exactly that we need: */
     183    int iSliderScale = 0;
     184    int iPower = log2i(uMaximumMediumSize);
     185    qulonglong uTickMB = (qulonglong)1 << iPower;
     186    if (uTickMB < uMaximumMediumSize)
     187    {
     188        qulonglong uTickMBNext = (qulonglong)1 << (iPower + 1);
     189        qulonglong uGap = uTickMBNext - uMaximumMediumSize;
     190        iSliderScale = (int)((uTickMBNext - uTickMB) / uGap);
     191    }
     192    return qMax(iSliderScale, 8);
     193}
     194
     195/* static */
     196int UIWizardNewVDPage3::log2i(qulonglong uValue)
    310197{
    311198    int iPower = -1;
     
    319206
    320207/* static */
    321 int UIWizardNewVDPageBasic3::sizeMBToSlider(qulonglong uValue, int iSliderScale)
     208int UIWizardNewVDPage3::sizeMBToSlider(qulonglong uValue, int iSliderScale)
    322209{
    323210    int iPower = log2i(uValue);
     
    329216
    330217/* static */
    331 qulonglong UIWizardNewVDPageBasic3::sliderToSizeMB(int uValue, int iSliderScale)
     218qulonglong UIWizardNewVDPage3::sliderToSizeMB(int uValue, int iSliderScale)
    332219{
    333220    int iPower = uValue / iSliderScale;
     
    338225}
    339226
    340 void UIWizardNewVDPageBasic3::updateSizeToolTips(qulonglong uSize)
     227void UIWizardNewVDPage3::updateSizeToolTips(qulonglong uSize)
    341228{
    342229    QString strToolTip = UIWizardNewVD::tr("<nobr>%1 (%2 B)</nobr>").arg(vboxGlobal().formatSize(uSize)).arg(uSize);
     
    345232}
    346233
    347 qulonglong UIWizardNewVDPageBasic3::mediumSize() const
    348 {
    349     /* Return slider value scaled at 'm_iSliderScale': */
     234QString UIWizardNewVDPage3::mediumPath() const
     235{
     236    return absoluteFilePath(toFileName(m_pLocationEditor->text(), m_strDefaultExtension), m_strDefaultPath);
     237}
     238
     239qulonglong UIWizardNewVDPage3::mediumSize() const
     240{
    350241    return sliderToSizeMB(m_pSizeSlider->value(), m_iSliderScale);
    351242}
    352243
    353 void UIWizardNewVDPageBasic3::setMediumSize(qulonglong uMediumSize)
     244void UIWizardNewVDPage3::setMediumSize(qulonglong uMediumSize)
    354245{
    355246    /* Block signals: */
     
    365256}
    366257
     258UIWizardNewVDPageBasic3::UIWizardNewVDPageBasic3(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize)
     259    : UIWizardNewVDPage3(strDefaultName, strDefaultPath)
     260{
     261    /* Create widgets: */
     262    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     263    {
     264        m_pLocationLabel = new QIRichTextLabel(this);
     265        m_pLocationCnt = new QGroupBox(this);
     266        {
     267            m_pLocationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     268            QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pLocationCnt);
     269            {
     270                m_pLocationEditor = new QLineEdit(m_pLocationCnt);
     271                m_pLocationOpenButton = new QIToolButton(m_pLocationCnt);
     272                {
     273                    m_pLocationOpenButton->setAutoRaise(true);
     274                    m_pLocationOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png"));
     275                }
     276                pLocationCntLayout->addWidget(m_pLocationEditor);
     277                pLocationCntLayout->addWidget(m_pLocationOpenButton);
     278            }
     279        }
     280        m_pSizeLabel = new QIRichTextLabel(this);
     281        m_pSizeCnt = new QGroupBox(this);
     282        {
     283            m_pSizeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     284            QGridLayout *m_pSizeCntLayout = new QGridLayout(m_pSizeCnt);
     285            {
     286                m_pSizeSlider = new QSlider(m_pSizeCnt);
     287                {
     288                    m_pSizeSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
     289                    m_pSizeSlider->setOrientation(Qt::Horizontal);
     290                    m_pSizeSlider->setTickPosition(QSlider::TicksBelow);
     291                    m_pSizeSlider->setFocusPolicy(Qt::StrongFocus);
     292                    m_pSizeSlider->setPageStep(m_iSliderScale);
     293                    m_pSizeSlider->setSingleStep(m_iSliderScale / 8);
     294                    m_pSizeSlider->setTickInterval(0);
     295                    m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMediumSizeMin, m_iSliderScale));
     296                    m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMediumSizeMax, m_iSliderScale));
     297                }
     298                m_pSizeEditor = new QILineEdit(m_pSizeCnt);
     299                {
     300                    m_pSizeEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
     301                    m_pSizeEditor->setFixedWidthByText("88888.88 MB");
     302                    m_pSizeEditor->setAlignment(Qt::AlignRight);
     303                    m_pSizeEditor->setValidator(new QRegExpValidator(QRegExp(vboxGlobal().sizeRegexp()), this));
     304                }
     305                QLabel *m_pSizeMin = new QLabel(m_pSizeCnt);
     306                {
     307                    m_pSizeMin->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
     308                    m_pSizeMin->setText(vboxGlobal().formatSize(m_uMediumSizeMin));
     309                }
     310                QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed);
     311                QLabel *m_pSizeMax = new QLabel(m_pSizeCnt);
     312                {
     313                    m_pSizeMax->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
     314                    m_pSizeMax->setText(vboxGlobal().formatSize(m_uMediumSizeMax));
     315                }
     316                m_pSizeCntLayout->addWidget(m_pSizeSlider, 0, 0, 1, 3);
     317                m_pSizeCntLayout->addWidget(m_pSizeEditor, 0, 3);
     318                m_pSizeCntLayout->addWidget(m_pSizeMin, 1, 0);
     319                m_pSizeCntLayout->addItem(m_pSizeSpacer, 1, 1);
     320                m_pSizeCntLayout->addWidget(m_pSizeMax, 1, 2);
     321            }
     322            setMediumSize(uDefaultSize);
     323        }
     324        pMainLayout->addWidget(m_pLocationLabel);
     325        pMainLayout->addWidget(m_pLocationCnt);
     326        pMainLayout->addWidget(m_pSizeLabel);
     327        pMainLayout->addWidget(m_pSizeCnt);
     328        pMainLayout->addStretch();
     329    }
     330
     331    /* Setup connections: */
     332    connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
     333    connect(m_pLocationOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked()));
     334    connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(sltSizeSliderValueChanged(int)));
     335    connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltSizeEditorTextChanged(const QString &)));
     336
     337    /* Register fields: */
     338    registerField("mediumPath", this, "mediumPath");
     339    registerField("mediumSize", this, "mediumSize");
     340}
     341
     342void UIWizardNewVDPageBasic3::sltSelectLocationButtonClicked()
     343{
     344    /* Call to base-class: */
     345    onSelectLocationButtonClicked();
     346}
     347
     348void UIWizardNewVDPageBasic3::sltSizeSliderValueChanged(int iValue)
     349{
     350    /* Call to base-class: */
     351    onSizeSliderValueChanged(iValue);
     352
     353    /* Broadcast complete-change: */
     354    emit completeChanged();
     355}
     356
     357void UIWizardNewVDPageBasic3::sltSizeEditorTextChanged(const QString &strValue)
     358{
     359    /* Call to base-class: */
     360    onSizeEditorTextChanged(strValue);
     361
     362    /* Broadcast complete-change: */
     363    emit completeChanged();
     364}
     365
     366void UIWizardNewVDPageBasic3::retranslateUi()
     367{
     368    /* Translate page: */
     369    setTitle(UIWizardNewVD::tr("Virtual disk file location and size"));
     370
     371    /* Translate widgets: */
     372    m_pLocationLabel->setText(UIWizardNewVD::tr("Please type the name of the new virtual disk file into the box below or "
     373                                                "click on the folder icon to select a different folder to create the file in."));
     374    m_pLocationCnt->setTitle(UIWizardNewVD::tr("&Location"));
     375    m_pSizeLabel->setText(UIWizardNewVD::tr("Select the size of the virtual disk in megabytes. This size will be reported "
     376                                            "to the Guest OS as the maximum size of this virtual disk."));
     377    m_pSizeCnt->setTitle(UIWizardNewVD::tr("&Size"));
     378}
     379
     380void UIWizardNewVDPageBasic3::initializePage()
     381{
     382    /* Translate page: */
     383    retranslateUi();
     384
     385    /* Get default extension for new virtual-disk: */
     386    m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>());
     387    /* Set default name as text for location editor: */
     388    m_pLocationEditor->setText(m_strDefaultName);
     389}
     390
     391bool UIWizardNewVDPageBasic3::isComplete() const
     392{
     393    /* Make sure current name is not empty and current size feats the bounds: */
     394    return !m_pLocationEditor->text().trimmed().isEmpty() &&
     395           mediumSize() >= m_uMediumSizeMin && mediumSize() <= m_uMediumSizeMax;
     396}
     397
     398bool UIWizardNewVDPageBasic3::validatePage()
     399{
     400    /* Make sure such virtual-disk doesn't exists already: */
     401    QString strMediumPath(mediumPath());
     402    if (QFileInfo(strMediumPath).exists())
     403    {
     404        msgCenter().sayCannotOverwriteHardDiskStorage(this, strMediumPath);
     405        return false;
     406    }
     407    return true;
     408}
     409
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic3.h

    r40870 r41021  
    2626/* Forward declarations: */
    2727class CMediumFormat;
    28 class QIRichTextLabel;
    2928class QGroupBox;
    3029class QLineEdit;
     
    3231class QSlider;
    3332class QILineEdit;
     33class QIRichTextLabel;
    3434
    35 /* 3rd page of the New Virtual Disk wizard: */
    36 class UIWizardNewVDPageBasic3 : public UIWizardPage
     35/* 3rd page of the New Virtual Disk wizard (base part): */
     36class UIWizardNewVDPage3 : public UIWizardPageBase
     37{
     38protected:
     39
     40    /* Constructor: */
     41    UIWizardNewVDPage3(const QString &strDefaultName, const QString &strDefaultPath);
     42
     43    /* Handlers: */
     44    void onSelectLocationButtonClicked();
     45    void onSizeSliderValueChanged(int iValue);
     46    void onSizeEditorTextChanged(const QString &strValue);
     47
     48    /* Location-editors stuff: */
     49    static QString toFileName(const QString &strName, const QString &strExtension);
     50    static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath);
     51    static QString defaultExtension(const CMediumFormat &mediumFormatRef);
     52
     53    /* Size-editors stuff: */
     54    static int calculateSliderScale(qulonglong uMaximumMediumSize);
     55    static int log2i(qulonglong uValue);
     56    static int sizeMBToSlider(qulonglong uValue, int iSliderScale);
     57    static qulonglong sliderToSizeMB(int uValue, int iSliderScale);
     58    void updateSizeToolTips(qulonglong uSize);
     59
     60    /* Stuff for 'mediumPath' field: */
     61    QString mediumPath() const;
     62
     63    /* Stuff for 'mediumSize' field: */
     64    qulonglong mediumSize() const;
     65    void setMediumSize(qulonglong uMediumSize);
     66
     67    /* Variables: */
     68    QString m_strDefaultName;
     69    QString m_strDefaultPath;
     70    QString m_strDefaultExtension;
     71    qulonglong m_uMediumSizeMin;
     72    qulonglong m_uMediumSizeMax;
     73    int m_iSliderScale;
     74
     75    /* Widgets: */
     76    QGroupBox *m_pLocationCnt;
     77    QLineEdit *m_pLocationEditor;
     78    QIToolButton *m_pLocationOpenButton;
     79    QGroupBox *m_pSizeCnt;
     80    QSlider *m_pSizeSlider;
     81    QILineEdit *m_pSizeEditor;
     82};
     83
     84/* 3rd page of the New Virtual Disk wizard (basic extension): */
     85class UIWizardNewVDPageBasic3 : public UIWizardPage, public UIWizardNewVDPage3
    3786{
    3887    Q_OBJECT;
    39     Q_PROPERTY(QString mediumPath READ mediumPath WRITE setMediumPath);
     88    Q_PROPERTY(QString mediumPath READ mediumPath);
    4089    Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize);
    4190
     
    4594    UIWizardNewVDPageBasic3(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize);
    4695
     96protected:
     97
     98    /* Wrapper to access 'this' from base part: */
     99    UIWizardPage* thisImp() { return this; }
     100    /* Wrapper to access 'wizard-field' from base part: */
     101    QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
     102
    47103private slots:
    48104
    49105    /* Location editors stuff: */
    50     void sltLocationEditorTextChanged(const QString &strMediumName);
    51106    void sltSelectLocationButtonClicked();
    52107
     
    67122    bool validatePage();
    68123
    69     /* Location-editors stuff: */
    70     static QString toFileName(const QString &strName, const QString &strExtension);
    71     static QString absoluteFilePath(const QString &strFileName, const QString &strDefaultPath);
    72     static QString defaultExtension(const CMediumFormat &mediumFormatRef);
    73 
    74     /* Size-editors stuff: */
    75     static int log2i(qulonglong uValue);
    76     static int sizeMBToSlider(qulonglong uValue, int iSliderScale);
    77     static qulonglong sliderToSizeMB(int uValue, int iSliderScale);
    78     void updateSizeToolTips(qulonglong uSize);
    79 
    80     /* Stuff for 'mediumPath' field: */
    81     QString mediumPath() const { return m_strMediumPath; }
    82     void setMediumPath(const QString &strMediumPath) { m_strMediumPath = strMediumPath; }
    83     QString m_strMediumPath;
    84 
    85     /* Stuff for 'mediumSize' field: */
    86     qulonglong mediumSize() const;
    87     void setMediumSize(qulonglong uMediumSize);
    88 
    89     /* Location-editors variables: */
    90     QString m_strDefaultName;
    91     QString m_strDefaultPath;
    92     QString m_strDefaultExtension;
    93 
    94     /* Size-editors variables: */
    95     qulonglong m_uMediumSizeMin;
    96     qulonglong m_uMediumSizeMax;
    97     int m_iSliderScale;
    98 
    99124    /* Widgets: */
    100125    QIRichTextLabel *m_pLocationLabel;
    101126    QIRichTextLabel *m_pSizeLabel;
    102     QGroupBox *m_pLocationCnt;
    103     QLineEdit *m_pLocationEditor;
    104     QIToolButton *m_pLocationSelector;
    105     QGroupBox *m_pSizeCnt;
    106     QSlider *m_pSizeSlider;
    107     QILineEdit *m_pSizeEditor;
    108127};
    109128
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic4.cpp

    r40870 r41021  
    2424#include "QIRichTextLabel.h"
    2525
     26UIWizardNewVDPage4::UIWizardNewVDPage4()
     27{
     28}
     29
    2630UIWizardNewVDPageBasic4::UIWizardNewVDPageBasic4()
    2731{
    2832    /* Create widgets: */
    2933    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     34    {
    3035        m_pLabel1 = new QIRichTextLabel(this);
    3136        m_pSummaryText = new QIRichTextLabel(this);
    3237        m_pLabel2 = new QIRichTextLabel(this);
    33     pMainLayout->addWidget(m_pLabel1);
    34     pMainLayout->addWidget(m_pSummaryText);
    35     pMainLayout->addWidget(m_pLabel2);
    36     pMainLayout->addStretch();
    37 
    38     /* Register CMedium class: */
    39     qRegisterMetaType<CMedium>();
    40     /* Register 'virtualDisk' field: */
    41     registerField("virtualDisk", this, "virtualDisk");
     38        pMainLayout->addWidget(m_pLabel1);
     39        pMainLayout->addWidget(m_pSummaryText);
     40        pMainLayout->addWidget(m_pLabel2);
     41        pMainLayout->addStretch();
     42    }
    4243}
    4344
     
    8485bool UIWizardNewVDPageBasic4::validatePage()
    8586{
     87    /* Initial result: */
     88    bool fResult = true;
     89
     90    /* Lock finish button: */
     91    startProcessing();
     92
    8693    /* Try to create virtual-disk: */
    87     startProcessing();
    88     bool fResult = qobject_cast<UIWizardNewVD*>(wizard())->createVirtualDisk();
     94    if (fResult)
     95        fResult = qobject_cast<UIWizardNewVD*>(wizard())->createVirtualDisk();
     96
     97    /* Unlock finish button: */
    8998    endProcessing();
     99
     100    /* Return result: */
    90101    return fResult;
    91102}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic4.h

    r40870 r41021  
    2222/* Local includes: */
    2323#include "UIWizardPage.h"
    24 #include "COMDefs.h"
    2524
    2625/* Forward declarations: */
    2726class QIRichTextLabel;
    2827
    29 /* 4th page of the New Virtual Disk wizard: */
    30 class UIWizardNewVDPageBasic4 : public UIWizardPage
     28/* 4th page of the New Virtual Disk wizard (base part): */
     29class UIWizardNewVDPage4 : public UIWizardPageBase
     30{
     31protected:
     32
     33    /* Constructor: */
     34    UIWizardNewVDPage4();
     35};
     36
     37/* 4th page of the New Virtual Disk wizard (basic extension): */
     38class UIWizardNewVDPageBasic4 : public UIWizardPage, public UIWizardNewVDPage4
    3139{
    3240    Q_OBJECT;
    33     Q_PROPERTY(CMedium virtualDisk READ virtualDisk WRITE setVirtualDisk);
    3441
    3542public:
     
    4956    bool validatePage();
    5057
    51     /* Stuff for 'virtualDisk' field: */
    52     CMedium virtualDisk() const { return m_virtualDisk; }
    53     void setVirtualDisk(const CMedium &virtualDisk) { m_virtualDisk = virtualDisk; }
    54     CMedium m_virtualDisk;
    55 
    5658    /* Widgets: */
    5759    QIRichTextLabel *m_pLabel1;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.cpp

    r40929 r41021  
    33 *
    44 * VBox frontends: Qt4 GUI ("VirtualBox"):
    5  * UIWizardNewVDPageBasic1 class implementation
     5 * UIWizardNewVDPageExpert class implementation
    66 */
    77
     
    1919
    2020/* Global includes: */
     21#include <QGridLayout>
    2122#include <QVBoxLayout>
     23#include <QRegExpValidator>
     24#include <QGroupBox>
    2225#include <QRadioButton>
    23 #include <QGroupBox>
     26#include <QCheckBox>
    2427#include <QButtonGroup>
     28#include <QLineEdit>
     29#include <QSlider>
     30#include <QLabel>
    2531
    2632/* Local includes: */
    27 #include "UIWizardNewVDPageBasic1.h"
     33#include "UIWizardNewVDPageExpert.h"
    2834#include "UIWizardNewVD.h"
    2935#include "VBoxGlobal.h"
     36#include "UIMessageCenter.h"
     37#include "UIIconPool.h"
    3038#include "QIRichTextLabel.h"
    31 
    32 UIWizardNewVDPageBasic1::UIWizardNewVDPageBasic1()
     39#include "QIToolButton.h"
     40#include "QILineEdit.h"
     41
     42UIWizardNewVDPageExpert::UIWizardNewVDPageExpert(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize)
     43    : UIWizardNewVDPage3(strDefaultName, strDefaultPath)
    3344{
    3445    /* Create widgets: */
    35     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    36         m_pLabel = new QIRichTextLabel(this);
    37         m_pFormatContainer = new QGroupBox(this);
    38             m_pFormatContainer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    39             QVBoxLayout *pFormatsLayout = new QVBoxLayout(m_pFormatContainer);
    40     pMainLayout->addWidget(m_pLabel);
    41     pMainLayout->addWidget(m_pFormatContainer);
    42     pMainLayout->addStretch();
    43 
    44     /* Greate button group: */
    45     m_pButtonGroup = new QButtonGroup(this);
    46 
    47     /* Enumerate supportable formats: */
    48     CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
    49     const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
    50     /* Search for default (VDI) format first: */
    51     for (int i = 0; i < medFormats.size(); ++i)
     46    QGridLayout *pMainLayout = new QGridLayout(this);
    5247    {
    53         /* Get iterated medium format: */
    54         const CMediumFormat &medFormat = medFormats[i];
    55         QString strFormatName(medFormat.GetName());
    56         if (strFormatName == "VDI")
     48        pMainLayout->setContentsMargins(8, 6, 8, 6);
     49        m_pLocationCnt = new QGroupBox(this);
    5750        {
    58             QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
    59             if (pButton)
     51            m_pLocationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     52            QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pLocationCnt);
    6053            {
    61                 m_formats << medFormat;
    62                 m_formatNames << strFormatName;
    63                 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     54                m_pLocationEditor = new QLineEdit(m_pLocationCnt);
     55                {
     56                    m_pLocationEditor->setText(m_strDefaultName);
     57                }
     58                m_pLocationOpenButton = new QIToolButton(m_pLocationCnt);
     59                {
     60                    m_pLocationOpenButton->setAutoRaise(true);
     61                    m_pLocationOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_dis_16px.png"));
     62                }
     63                pLocationCntLayout->addWidget(m_pLocationEditor);
     64                pLocationCntLayout->addWidget(m_pLocationOpenButton);
    6465            }
    6566        }
    66     }
    67     /* Look for other formats: */
    68     for (int i = 0; i < medFormats.size(); ++i)
    69     {
    70         /* Get iterated medium format: */
    71         const CMediumFormat &medFormat = medFormats[i];
    72         QString strFormatName(medFormat.GetName());
    73         if (strFormatName != "VDI")
     67        m_pSizeCnt = new QGroupBox(this);
    7468        {
    75             QRadioButton *pButton = addFormatButton(pFormatsLayout, medFormat);
    76             if (pButton)
     69            m_pSizeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     70            QGridLayout *m_pSizeCntLayout = new QGridLayout(m_pSizeCnt);
    7771            {
    78                 m_formats << medFormat;
    79                 m_formatNames << strFormatName;
    80                 m_pButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     72                m_pSizeSlider = new QSlider(m_pSizeCnt);
     73                {
     74                    m_pSizeSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
     75                    m_pSizeSlider->setOrientation(Qt::Horizontal);
     76                    m_pSizeSlider->setTickPosition(QSlider::TicksBelow);
     77                    m_pSizeSlider->setFocusPolicy(Qt::StrongFocus);
     78                    m_pSizeSlider->setPageStep(m_iSliderScale);
     79                    m_pSizeSlider->setSingleStep(m_iSliderScale / 8);
     80                    m_pSizeSlider->setTickInterval(0);
     81                    m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMediumSizeMin, m_iSliderScale));
     82                    m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMediumSizeMax, m_iSliderScale));
     83                }
     84                m_pSizeEditor = new QILineEdit(m_pSizeCnt);
     85                {
     86                    m_pSizeEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
     87                    m_pSizeEditor->setFixedWidthByText("88888.88 MB");
     88                    m_pSizeEditor->setAlignment(Qt::AlignRight);
     89                    m_pSizeEditor->setValidator(new QRegExpValidator(QRegExp(vboxGlobal().sizeRegexp()), this));
     90                }
     91                QLabel *m_pSizeMin = new QLabel(m_pSizeCnt);
     92                {
     93                    m_pSizeMin->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
     94                    m_pSizeMin->setText(vboxGlobal().formatSize(m_uMediumSizeMin));
     95                }
     96                QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed);
     97                QLabel *m_pSizeMax = new QLabel(m_pSizeCnt);
     98                {
     99                    m_pSizeMax->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
     100                    m_pSizeMax->setText(vboxGlobal().formatSize(m_uMediumSizeMax));
     101                }
     102                m_pSizeCntLayout->addWidget(m_pSizeSlider, 0, 0, 1, 3);
     103                m_pSizeCntLayout->addWidget(m_pSizeEditor, 0, 3);
     104                m_pSizeCntLayout->addWidget(m_pSizeMin, 1, 0);
     105                m_pSizeCntLayout->addItem(m_pSizeSpacer, 1, 1);
     106                m_pSizeCntLayout->addWidget(m_pSizeMax, 1, 2);
    81107            }
    82108        }
     109        QVBoxLayout *pFormatWrappingLayout = new QVBoxLayout;
     110        {
     111            m_pFormatCnt = new QGroupBox(this);
     112            {
     113                m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     114                QVBoxLayout *pFormatCntLayout = new QVBoxLayout(m_pFormatCnt);
     115                {
     116                    m_pFormatButtonGroup = new QButtonGroup(m_pFormatCnt);
     117                    {
     118                        CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
     119                        const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
     120                        for (int i = 0; i < medFormats.size(); ++i)
     121                        {
     122                            const CMediumFormat &medFormat = medFormats[i];
     123                            QString strFormatName(medFormat.GetName());
     124                            if (strFormatName == "VDI")
     125                            {
     126                                QRadioButton *pButton = addFormatButton(pFormatCntLayout, medFormat);
     127                                if (pButton)
     128                                {
     129                                    m_formats << medFormat;
     130                                    m_formatNames << strFormatName;
     131                                    m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     132                                }
     133                            }
     134                        }
     135                        for (int i = 0; i < medFormats.size(); ++i)
     136                        {
     137                            const CMediumFormat &medFormat = medFormats[i];
     138                            QString strFormatName(medFormat.GetName());
     139                            if (strFormatName != "VDI")
     140                            {
     141                                QRadioButton *pButton = addFormatButton(pFormatCntLayout, medFormat);
     142                                if (pButton)
     143                                {
     144                                    m_formats << medFormat;
     145                                    m_formatNames << strFormatName;
     146                                    m_pFormatButtonGroup->addButton(pButton, m_formatNames.size() - 1);
     147                                }
     148                            }
     149                        }
     150                        m_pFormatButtonGroup->button(0)->click();
     151                        m_pFormatButtonGroup->button(0)->setFocus();
     152                    }
     153                }
     154            }
     155            QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
     156            pFormatWrappingLayout->addWidget(m_pFormatCnt);
     157            pFormatWrappingLayout->addItem(m_pSizeSpacer);
     158        }
     159        QVBoxLayout *pVariantWrappingLayout = new QVBoxLayout;
     160        {
     161            m_pVariantCnt = new QGroupBox(this);
     162            {
     163                m_pVariantCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     164                QVBoxLayout *pVariantsLayout = new QVBoxLayout(m_pVariantCnt);
     165                {
     166                    m_pVariantButtonGroup = new QButtonGroup(m_pVariantCnt);
     167                    {
     168                        m_pDynamicalButton = new QRadioButton(m_pVariantCnt);
     169                        {
     170                            m_pDynamicalButton->click();
     171                            m_pDynamicalButton->setFocus();
     172                        }
     173                        m_pFixedButton = new QRadioButton(m_pVariantCnt);
     174                        m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
     175                        m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
     176                    }
     177                    m_pSplitBox = new QCheckBox(m_pVariantCnt);
     178                    pVariantsLayout->addWidget(m_pDynamicalButton);
     179                    pVariantsLayout->addWidget(m_pFixedButton);
     180                    pVariantsLayout->addWidget(m_pSplitBox);
     181                }
     182            }
     183            QSpacerItem *m_pSizeSpacer = new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
     184            pVariantWrappingLayout->addWidget(m_pVariantCnt);
     185            pVariantWrappingLayout->addItem(m_pSizeSpacer);
     186        }
     187        pMainLayout->addWidget(m_pLocationCnt, 0, 0, 1, 2);
     188        pMainLayout->addWidget(m_pSizeCnt, 1, 0, 1, 2);
     189        pMainLayout->addLayout(pFormatWrappingLayout, 2, 0);
     190        pMainLayout->addLayout(pVariantWrappingLayout, 2, 1);
     191        setMediumSize(uDefaultSize);
     192        sltMediumFormatChanged();
    83193    }
    84194
    85195    /* Setup connections: */
    86     connect(m_pButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(completeChanged()));
    87 
    88     /* Initialize connections: */
    89     m_pButtonGroup->button(0)->click();
    90     m_pButtonGroup->button(0)->setFocus();
    91 
    92     /* Register CMediumFormat class: */
     196    connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(sltMediumFormatChanged()));
     197    connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged()));
     198    connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged()));
     199    connect(m_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
     200    connect(m_pLocationOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked()));
     201    connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(sltSizeSliderValueChanged(int)));
     202    connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltSizeEditorTextChanged(const QString &)));
     203
     204    /* Register classes: */
    93205    qRegisterMetaType<CMediumFormat>();
    94     /* Register 'mediumFormat' field: */
     206    /* Register fields: */
    95207    registerField("mediumFormat", this, "mediumFormat");
    96 }
    97 
    98 void UIWizardNewVDPageBasic1::retranslateUi()
    99 {
    100     /* Translate page: */
    101     setTitle(UIWizardNewVD::tr("Welcome to the virtual disk creation wizard"));
    102 
     208    registerField("mediumVariant", this, "mediumVariant");
     209    registerField("mediumPath", this, "mediumPath");
     210    registerField("mediumSize", this, "mediumSize");
     211}
     212
     213void UIWizardNewVDPageExpert::sltMediumFormatChanged()
     214{
     215    /* Get medium format: */
     216    CMediumFormat mf = mediumFormat();
     217
     218    /* Enable/disable widgets: */
     219    ULONG uCapabilities = mf.GetCapabilities();
     220    bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic;
     221    bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed;
     222    bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G;
     223    m_pDynamicalButton->setEnabled(fIsCreateDynamicPossible);
     224    m_pFixedButton->setEnabled(fIsCreateFixedPossible);
     225    m_pSplitBox->setEnabled(fIsCreateSplitPossible);
     226
     227    /* Compose virtual-disk extension: */
     228    m_strDefaultExtension = defaultExtension(mf);
     229
     230    /* Broadcast complete-change: */
     231    completeChanged();
     232}
     233
     234void UIWizardNewVDPageExpert::sltSelectLocationButtonClicked()
     235{
     236    /* Call to base-class: */
     237    onSelectLocationButtonClicked();
     238}
     239
     240void UIWizardNewVDPageExpert::sltSizeSliderValueChanged(int iValue)
     241{
     242    onSizeSliderValueChanged(iValue);
     243
     244    emit completeChanged();
     245}
     246
     247void UIWizardNewVDPageExpert::sltSizeEditorTextChanged(const QString &strValue)
     248{
     249    onSizeEditorTextChanged(strValue);
     250
     251    emit completeChanged();
     252}
     253
     254void UIWizardNewVDPageExpert::retranslateUi()
     255{
    103256    /* Translate widgets: */
    104     m_pLabel->setText(UIWizardNewVD::tr("<p>This wizard will help you to create a new virtual disk for your virtual machine.</p>"));
    105     m_pLabel->setText(m_pLabel->text() + QString("<p>%1</p>").arg(standardHelpText()));
    106     m_pLabel->setText(m_pLabel->text() + UIWizardNewVD::tr("<p>Please choose the type of file that you would like "
    107                                                            "to use for the new virtual disk. If you do not need "
    108                                                            "to use it with other virtualization software you can "
    109                                                            "leave this setting unchanged.</p>"));
    110     m_pFormatContainer->setTitle(UIWizardNewVD::tr("File type"));
    111 
    112     /* Translate 'format' buttons: */
    113     QList<QAbstractButton*> buttons = m_pButtonGroup->buttons();
     257    m_pLocationCnt->setTitle(UIWizardNewVD::tr("&Location"));
     258    m_pLocationOpenButton->setToolTip(UIWizardNewVD::tr("Choose a virtual hard disk file..."));
     259    m_pSizeCnt->setTitle(UIWizardNewVD::tr("&Size"));
     260    m_pFormatCnt->setTitle(UIWizardNewVD::tr("File type"));
     261    QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons();
    114262    for (int i = 0; i < buttons.size(); ++i)
    115263    {
    116264        QAbstractButton *pButton = buttons[i];
    117         pButton->setText(UIWizardNewVD::fullFormatName(m_formatNames[m_pButtonGroup->id(pButton)]));
     265        pButton->setText(UIWizardNewVD::fullFormatName(m_formatNames[m_pFormatButtonGroup->id(pButton)]));
    118266    }
    119 }
    120 
    121 void UIWizardNewVDPageBasic1::initializePage()
     267    m_pVariantCnt->setTitle(UIWizardNewVD::tr("Storage details"));
     268    m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated"));
     269    m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size"));
     270    m_pSplitBox->setText(UIWizardNewVD::tr("&Split into files of less than 2GB"));
     271}
     272
     273void UIWizardNewVDPageExpert::initializePage()
    122274{
    123275    /* Translate page: */
     
    125277}
    126278
    127 bool UIWizardNewVDPageBasic1::isComplete() const
    128 {
    129     return !mediumFormat().isNull();
    130 }
    131 
    132 int UIWizardNewVDPageBasic1::nextId() const
    133 {
    134     CMediumFormat medFormat = mediumFormat();
    135     ULONG uCapabilities = medFormat.GetCapabilities();
    136     int cTest = 0;
    137     if (uCapabilities & KMediumFormatCapabilities_CreateDynamic)
    138         ++cTest;
    139     if (uCapabilities & KMediumFormatCapabilities_CreateFixed)
    140         ++cTest;
    141     if (uCapabilities & KMediumFormatCapabilities_CreateSplit2G)
    142         ++cTest;
    143     if (cTest > 1)
    144         return UIWizardNewVD::Page2;
    145     return UIWizardNewVD::Page3;
    146 }
    147 
    148 QRadioButton* UIWizardNewVDPageBasic1::addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat medFormat)
    149 {
    150     /* Check that medium format supports creation: */
    151     ULONG uFormatCapabilities = medFormat.GetCapabilities();
    152     if (!(uFormatCapabilities & MediumFormatCapabilities_CreateFixed ||
    153           uFormatCapabilities & MediumFormatCapabilities_CreateDynamic))
    154         return 0;
    155 
    156     /* Check that medium format supports creation of virtual hard-disks: */
    157     QVector<QString> fileExtensions;
    158     QVector<KDeviceType> deviceTypes;
    159     medFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
    160     if (!deviceTypes.contains(KDeviceType_HardDisk))
    161         return 0;
    162 
    163     /* Create/add corresponding radio-button: */
    164     QRadioButton *pFormatButton = new QRadioButton(m_pFormatContainer);
    165     pFormatsLayout->addWidget(pFormatButton);
    166     return pFormatButton;
    167 }
    168 
    169 CMediumFormat UIWizardNewVDPageBasic1::mediumFormat() const
    170 {
    171     return m_pButtonGroup->checkedButton() ? m_formats[m_pButtonGroup->checkedId()] : CMediumFormat();
    172 }
    173 
    174 void UIWizardNewVDPageBasic1::setMediumFormat(const CMediumFormat &mediumFormat)
    175 {
    176     int iPosition = m_formats.indexOf(mediumFormat);
    177     if (iPosition >= 0)
     279bool UIWizardNewVDPageExpert::isComplete() const
     280{
     281    /* Make sure medium format/variant is correct,
     282     * current name is not empty and current size feats the bounds: */
     283    return !mediumFormat().isNull() &&
     284           mediumVariant() != (qulonglong)KMediumVariant_Max &&
     285           !m_pLocationEditor->text().trimmed().isEmpty() &&
     286           mediumSize() >= m_uMediumSizeMin && mediumSize() <= m_uMediumSizeMax;
     287}
     288
     289bool UIWizardNewVDPageExpert::validatePage()
     290{
     291    /* Initial result: */
     292    bool fResult = true;
     293
     294    /* Lock finish button: */
     295    startProcessing();
     296
     297    /* Make sure that virtual-disk doesn't exists: */
     298    QString strMediumPath(mediumPath());
     299    if (fResult && QFileInfo(strMediumPath).exists())
    178300    {
    179         m_pButtonGroup->button(iPosition)->click();
    180         m_pButtonGroup->button(iPosition)->setFocus();
     301        msgCenter().sayCannotOverwriteHardDiskStorage(this, strMediumPath);
     302        fResult = false;
    181303    }
    182 }
    183 
     304
     305    /* Try to create virtual-disk: */
     306    if (fResult)
     307        fResult = qobject_cast<UIWizardNewVD*>(wizard())->createVirtualDisk();
     308
     309    /* Unlock finish button: */
     310    endProcessing();
     311
     312    /* Return result: */
     313    return fResult;
     314}
     315
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.h

    r40929 r41021  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * UIWizardNewVDPageBasic1 class declaration
     4 * UIWizardNewVDPageExpert class declaration
    55 */
    66
     
    1717 */
    1818
    19 #ifndef __UIWizardNewVDPageBasic1_h__
    20 #define __UIWizardNewVDPageBasic1_h__
     19#ifndef __UIWizardNewVDPageExpert_h__
     20#define __UIWizardNewVDPageExpert_h__
    2121
    2222/* Local includes: */
    23 #include "UIWizardPage.h"
    24 #include "COMDefs.h"
     23#include "UIWizardNewVDPageBasic1.h"
     24#include "UIWizardNewVDPageBasic2.h"
     25#include "UIWizardNewVDPageBasic3.h"
     26#include "UIWizardNewVDPageBasic4.h"
    2527
    26 /* Forward declarations: */
    27 class QVBoxLayout;
    28 class QRadioButton;
    29 class QIRichTextLabel;
    30 class QGroupBox;
    31 class QButtonGroup;
    32 
    33 /* 1st page of the New Virtual Disk wizard: */
    34 class UIWizardNewVDPageBasic1 : public UIWizardPage
     28/* Expert page of the New Virtual Disk wizard: */
     29class UIWizardNewVDPageExpert : public UIWizardPage,
     30                                public UIWizardNewVDPage1,
     31                                public UIWizardNewVDPage2,
     32                                public UIWizardNewVDPage3,
     33                                public UIWizardNewVDPage4
    3534{
    3635    Q_OBJECT;
    3736    Q_PROPERTY(CMediumFormat mediumFormat READ mediumFormat WRITE setMediumFormat);
     37    Q_PROPERTY(qulonglong mediumVariant READ mediumVariant WRITE setMediumVariant);
     38    Q_PROPERTY(QString mediumPath READ mediumPath);
     39    Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize);
    3840
    3941public:
    4042
    4143    /* Constructor: */
    42     UIWizardNewVDPageBasic1();
     44    UIWizardNewVDPageExpert(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize);
     45
     46protected:
     47
     48    /* Wrapper to access 'this' from base part: */
     49    UIWizardPage* thisImp() { return this; }
     50    /* Wrapper to access 'wizard-field' from base part: */
     51    QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
     52
     53private slots:
     54
     55    /* Medium format stuff: */
     56    void sltMediumFormatChanged();
     57
     58    /* Location editors stuff: */
     59    void sltSelectLocationButtonClicked();
     60    /* Size editors stuff: */
     61    void sltSizeSliderValueChanged(int iValue);
     62    void sltSizeEditorTextChanged(const QString &strValue);
    4363
    4464private:
     
    5272    /* Validation stuff: */
    5373    bool isComplete() const;
    54 
    55     /* Navigation stuff: */
    56     int nextId() const;
    57 
    58     /* Helping stuff: */
    59     QRadioButton* addFormatButton(QVBoxLayout *pFormatsLayout, CMediumFormat mediumFormat);
    60 
    61     /* Stuff for 'mediumFormat' field: */
    62     CMediumFormat mediumFormat() const;
    63     void setMediumFormat(const CMediumFormat &mediumFormat);
    64 
    65     /* Variables: */
    66     QButtonGroup *m_pButtonGroup;
    67     QList<CMediumFormat> m_formats;
    68     QStringList m_formatNames;
    69 
    70     /* Widgets: */
    71     QIRichTextLabel *m_pLabel;
    72     QGroupBox *m_pFormatContainer;
     74    bool validatePage();
    7375};
    7476
    75 #endif // __UIWizardNewVDPageBasic1_h__
     77#endif // __UIWizardNewVDPageExpert_h__
    7678
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r40870 r41021  
    2525#include "UIWizardNewVMPageBasic4.h"
    2626#include "UIWizardNewVMPageBasic5.h"
     27#include "UIWizardNewVMPageExpert.h"
    2728#include "VBoxDefs.h"
    2829#include "VBoxGlobal.h"
     
    3334
    3435UIWizardNewVM::UIWizardNewVM(QWidget *pParent)
    35     : UIWizard(pParent)
     36    : UIWizard(pParent, UIWizardType_NewVM)
    3637    , m_iIDECount(0)
    3738    , m_iSATACount(0)
     
    4041    , m_iSASCount(0)
    4142{
    42     /* Create & add pages: */
    43     setPage(Page1, new UIWizardNewVMPageBasic1);
    44     setPage(Page2, new UIWizardNewVMPageBasic2);
    45     setPage(Page3, new UIWizardNewVMPageBasic3);
    46     setPage(Page4, new UIWizardNewVMPageBasic4);
    47     setPage(Page5, new UIWizardNewVMPageBasic5);
    48 
    49     /* Translate wizard: */
    50     retranslateUi();
    51 
    52     /* Translate wizard pages: */
    53     retranslateAllPages();
    54 
    5543#ifndef Q_WS_MAC
    5644    /* Assign watermark: */
     
    6048    assignBackground(":/vmw_new_welcome_bg.png");
    6149#endif /* Q_WS_MAC */
    62 
    63     /* Resize wizard to 'golden ratio': */
    64     resizeToGoldenRatio(UIWizardType_NewVM);
    6550}
    6651
     
    273258void UIWizardNewVM::retranslateUi()
    274259{
     260    /* Call to base-class: */
     261    UIWizard::retranslateUi();
     262
    275263    /* Translate wizard: */
    276264    setWindowTitle(tr("Create New Virtual Machine"));
    277265    setButtonText(QWizard::FinishButton, tr("Create"));
     266}
     267
     268void UIWizardNewVM::prepare()
     269{
     270    /* Create corresponding pages: */
     271    switch (mode())
     272    {
     273        case UIWizardMode_Basic:
     274        {
     275            setPage(Page1, new UIWizardNewVMPageBasic1);
     276            setPage(Page2, new UIWizardNewVMPageBasic2);
     277            setPage(Page3, new UIWizardNewVMPageBasic3);
     278            setPage(Page4, new UIWizardNewVMPageBasic4);
     279            setPage(Page5, new UIWizardNewVMPageBasic5);
     280            break;
     281        }
     282        case UIWizardMode_Expert:
     283        {
     284            setPage(PageExpert, new UIWizardNewVMPageExpert);
     285            break;
     286        }
     287    }
     288    /* Call to base-class: */
     289    UIWizard::prepare();
    278290}
    279291
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h

    r40870 r41021  
    4141    };
    4242
     43    /* Page IDs: */
     44    enum
     45    {
     46        PageExpert
     47    };
     48
    4349    /* Constructor: */
    4450    UIWizardNewVM(QWidget *pParent);
     
    5157    /* Who will be able to create virtual-machine: */
    5258    friend class UIWizardNewVMPageBasic5;
     59    friend class UIWizardNewVMPageExpert;
    5360
    5461private:
     
    5663    /* Translation stuff: */
    5764    void retranslateUi();
     65
     66    /* Pages related stuff: */
     67    void prepare();
    5868
    5969    /* Helping stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.cpp

    r40870 r41021  
    2727#include "QIRichTextLabel.h"
    2828
     29UIWizardNewVMPage1::UIWizardNewVMPage1()
     30{
     31}
     32
    2933UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1()
    3034{
    3135    /* Create widgets: */
    3236    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     37    {
    3338        m_pLabel1 = new QIRichTextLabel(this);
     39        {
    3440            /* Register 'message-box warning-icon' image in m_pLabel1 as 'image': */
    3541            QSize wSize(64, 64);
     
    3945            QImage wImage = wPixmap.toImage();
    4046            m_pLabel1->registerImage(wImage, "image");
     47        }
    4148        m_pLabel2 = new QIRichTextLabel(this);
    42     pMainLayout->addWidget(m_pLabel1);
    43     pMainLayout->addWidget(m_pLabel2);
    44     pMainLayout->addStretch();
     49        pMainLayout->addWidget(m_pLabel1);
     50        pMainLayout->addWidget(m_pLabel2);
     51        pMainLayout->addStretch();
     52    }
    4553}
    4654
     
    4856{
    4957    /* Translate page: */
    50     setTitle(UIWizardNewVM::tr("Welcome to the New Virtual Machine Wizard!"));
     58    setTitle(UIWizardNewVM::tr("Welcome to the New Virtual Machine wizard!"));
    5159
    5260    /* Translate widgets: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic1.h

    r40870 r41021  
    2222/* Local includes: */
    2323#include "UIWizardPage.h"
    24 #include "COMDefs.h"
    25 #include "QIWithRetranslateUI.h"
    2624
    2725/* Forward declarations: */
    2826class QIRichTextLabel;
    2927
    30 /* 1st page of the New Virtual Machine wizard: */
    31 class UIWizardNewVMPageBasic1 : public UIWizardPage
     28/* 1st page of the New Virtual Machine wizard (base part): */
     29class UIWizardNewVMPage1 : public UIWizardPageBase
     30{
     31protected:
     32
     33    /* Constructor: */
     34    UIWizardNewVMPage1();
     35};
     36
     37/* 1st page of the New Virtual Machine wizard (basic extension): */
     38class UIWizardNewVMPageBasic1 : public UIWizardPage, public UIWizardNewVMPage1
    3239{
    3340    Q_OBJECT;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.cpp

    r40870 r41021  
    2929#include "UIWizardNewVM.h"
    3030#include "UIMessageCenter.h"
     31#include "VBoxOSTypeSelectorWidget.h"
    3132#include "QIRichTextLabel.h"
    32 #include "VBoxOSTypeSelectorWidget.h"
    3333
    3434/* Defines some patterns to guess the right OS type. Should be in sync with
     
    138138};
    139139
    140 UIWizardNewVMPageBasic2::UIWizardNewVMPageBasic2()
    141 {
    142     /* Create widgets: */
    143     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    144         m_pLabel = new QIRichTextLabel(this);
    145         m_pNameEditorCnt = new QGroupBox(this);
    146             m_pNameEditorCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    147             QHBoxLayout *pNameEditorLayout = new QHBoxLayout(m_pNameEditorCnt);
    148                 m_pNameEditor = new QLineEdit(m_pNameEditorCnt);
    149             pNameEditorLayout->addWidget(m_pNameEditor);
    150         m_pTypeSelectorCnt = new QGroupBox(this);
    151             m_pTypeSelectorCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    152             QHBoxLayout *pTypeSelectorLayout = new QHBoxLayout(m_pTypeSelectorCnt);
    153                 m_pTypeSelector = new VBoxOSTypeSelectorWidget(m_pTypeSelectorCnt);
    154                     m_pTypeSelector->activateLayout();
    155             pTypeSelectorLayout->addWidget(m_pTypeSelector);
    156     pMainLayout->addWidget(m_pLabel);
    157     pMainLayout->addWidget(m_pNameEditorCnt);
    158     pMainLayout->addWidget(m_pTypeSelectorCnt);
    159     pMainLayout->addStretch();
    160 
    161     /* Setup connections: */
    162     connect(m_pNameEditor, SIGNAL(textChanged(const QString&)), this, SLOT(sltNameChanged(const QString&)));
    163     connect(m_pTypeSelector, SIGNAL(osTypeChanged()), this, SLOT(sltOsTypeChanged()));
    164 
    165     /* Register fields: */
    166     registerField("name*", m_pNameEditor);
    167     registerField("type", m_pTypeSelector, "type", SIGNAL(osTypeChanged()));
    168     registerField("machineFolder", this, "machineFolder");
    169     registerField("machineBaseName", this, "machineBaseName");
    170 }
    171 
    172 void UIWizardNewVMPageBasic2::sltNameChanged(const QString &strNewName)
     140UIWizardNewVMPage2::UIWizardNewVMPage2()
     141{
     142}
     143
     144void UIWizardNewVMPage2::onNameChanged(const QString &strNewName)
    173145{
    174146    /* Search for a matching OS type based on the string the user typed already. */
    175     for (size_t i=0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)
     147    for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)
    176148        if (strNewName.contains(gs_OSTypePattern[i].pattern))
    177149        {
     
    183155}
    184156
    185 void UIWizardNewVMPageBasic2::sltOsTypeChanged()
     157void UIWizardNewVMPage2::onOsTypeChanged()
    186158{
    187159    /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore.
    188160     * So simply disconnect the text-edit signal. */
    189     disconnect(m_pNameEditor, SIGNAL(textChanged(const QString&)), this, SLOT(sltNameChanged(const QString&)));
    190 }
    191 
    192 void UIWizardNewVMPageBasic2::retranslateUi()
    193 {
    194     /* Translate page: */
    195     setTitle(UIWizardNewVM::tr("VM Name and OS Type"));
    196 
    197     /* Translate widgets: */
    198     m_pLabel->setText(UIWizardNewVM::tr("<p>Enter a name for the new virtual machine and select the type of the guest operating system "
    199                                         "you plan to install onto the virtual machine.</p><p>The name of the virtual machine usually "
    200                                         "indicates its software and hardware configuration. It will be used by all VirtualBox components "
    201                                         "to identify your virtual machine.</p>"));
    202     m_pNameEditorCnt->setTitle(UIWizardNewVM::tr("N&ame"));
    203     m_pTypeSelectorCnt->setTitle(UIWizardNewVM::tr("OS &Type"));
    204 }
    205 
    206 void UIWizardNewVMPageBasic2::initializePage()
    207 {
    208     /* Translate page: */
    209     retranslateUi();
    210 
    211     /* 'Name' field should have focus initially: */
    212     m_pNameEditor->setFocus();
    213 }
    214 
    215 void UIWizardNewVMPageBasic2::cleanupPage()
    216 {
    217     /* Cleanup: */
    218     cleanupMachineFolder();
    219     /* Call for base-class: */
    220     UIWizardPage::cleanupPage();
    221 }
    222 
    223 bool UIWizardNewVMPageBasic2::validatePage()
    224 {
    225     return createMachineFolder();
    226 }
    227 
    228 bool UIWizardNewVMPageBasic2::machineFolderCreated()
     161    m_pNameEditor->disconnect(thisImp());
     162}
     163
     164bool UIWizardNewVMPage2::machineFolderCreated()
    229165{
    230166    return !m_strMachineFolder.isEmpty();
    231167}
    232168
    233 bool UIWizardNewVMPageBasic2::createMachineFolder()
     169bool UIWizardNewVMPage2::createMachineFolder()
    234170{
    235171    /* Cleanup previosly created folder if any: */
    236172    if (machineFolderCreated() && !cleanupMachineFolder())
    237173    {
    238         msgCenter().warnAboutCannotRemoveMachineFolder(this, m_strMachineFolder);
     174        msgCenter().warnAboutCannotRemoveMachineFolder(thisImp(), m_strMachineFolder);
    239175        return false;
    240176    }
     
    254190    if (QDir(strMachineFolder).exists())
    255191    {
    256         msgCenter().warnAboutCannotRewriteMachineFolder(this, strMachineFolder);
     192        msgCenter().warnAboutCannotRewriteMachineFolder(thisImp(), strMachineFolder);
    257193        return false;
    258194    }
     
    262198    if (!fMachineFolderCreated)
    263199    {
    264         msgCenter().warnAboutCannotCreateMachineFolder(this, strMachineFolder);
     200        msgCenter().warnAboutCannotCreateMachineFolder(thisImp(), strMachineFolder);
    265201        return false;
    266202    }
     
    272208}
    273209
    274 bool UIWizardNewVMPageBasic2::cleanupMachineFolder()
     210bool UIWizardNewVMPage2::cleanupMachineFolder()
    275211{
    276212    /* Make sure folder was previosly created: */
     
    286222}
    287223
    288 QString UIWizardNewVMPageBasic2::machineFolder() const
    289 {
    290     return m_strMachineFolder;
    291 }
    292 
    293 void UIWizardNewVMPageBasic2::setMachineFolder(const QString &strMachineFolder)
    294 {
    295     m_strMachineFolder = strMachineFolder;
    296 }
    297 
    298 QString UIWizardNewVMPageBasic2::machineBaseName() const
    299 {
    300     return m_strMachineBaseName;
    301 }
    302 
    303 void UIWizardNewVMPageBasic2::setMachineBaseName(const QString &strMachineBaseName)
    304 {
    305     m_strMachineBaseName = strMachineBaseName;
    306 }
    307 
     224UIWizardNewVMPageBasic2::UIWizardNewVMPageBasic2()
     225{
     226    /* Create widgets: */
     227    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     228    {
     229        m_pLabel = new QIRichTextLabel(this);
     230        m_pNameCnt = new QGroupBox(this);
     231        {
     232            m_pNameCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     233            QHBoxLayout *pNameCntLayout = new QHBoxLayout(m_pNameCnt);
     234            {
     235                m_pNameEditor = new QLineEdit(m_pNameCnt);
     236                pNameCntLayout->addWidget(m_pNameEditor);
     237            }
     238        }
     239        m_pTypeCnt = new QGroupBox(this);
     240        {
     241            m_pTypeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     242            QHBoxLayout *pTypeSelectorLayout = new QHBoxLayout(m_pTypeCnt);
     243            {
     244                m_pTypeSelector = new VBoxOSTypeSelectorWidget(m_pTypeCnt);
     245                {
     246                    m_pTypeSelector->activateLayout();
     247                }
     248                pTypeSelectorLayout->addWidget(m_pTypeSelector);
     249            }
     250        }
     251        pMainLayout->addWidget(m_pLabel);
     252        pMainLayout->addWidget(m_pNameCnt);
     253        pMainLayout->addWidget(m_pTypeCnt);
     254        pMainLayout->addStretch();
     255    }
     256
     257    /* Setup connections: */
     258    connect(m_pNameEditor, SIGNAL(textChanged(const QString&)), this, SLOT(sltNameChanged(const QString&)));
     259    connect(m_pTypeSelector, SIGNAL(osTypeChanged()), this, SLOT(sltOsTypeChanged()));
     260
     261    /* Register fields: */
     262    registerField("name*", m_pNameEditor);
     263    registerField("type", m_pTypeSelector, "type", SIGNAL(osTypeChanged()));
     264    registerField("machineFolder", this, "machineFolder");
     265    registerField("machineBaseName", this, "machineBaseName");
     266}
     267
     268void UIWizardNewVMPageBasic2::sltNameChanged(const QString &strNewName)
     269{
     270    /* Call to base-class: */
     271    onNameChanged(strNewName);
     272}
     273
     274void UIWizardNewVMPageBasic2::sltOsTypeChanged()
     275{
     276    /* Call to base-class: */
     277    onOsTypeChanged();
     278}
     279
     280void UIWizardNewVMPageBasic2::retranslateUi()
     281{
     282    /* Translate page: */
     283    setTitle(UIWizardNewVM::tr("VM Name and OS Type"));
     284
     285    /* Translate widgets: */
     286    m_pLabel->setText(UIWizardNewVM::tr("<p>Enter a name for the new virtual machine and select the type of the guest operating system "
     287                                        "you plan to install onto the virtual machine.</p><p>The name of the virtual machine usually "
     288                                        "indicates its software and hardware configuration. It will be used by all VirtualBox components "
     289                                        "to identify your virtual machine.</p>"));
     290    m_pNameCnt->setTitle(UIWizardNewVM::tr("&Name"));
     291    m_pTypeCnt->setTitle(UIWizardNewVM::tr("OS &Type"));
     292}
     293
     294void UIWizardNewVMPageBasic2::initializePage()
     295{
     296    /* Translate page: */
     297    retranslateUi();
     298
     299    /* 'Name' field should have focus initially: */
     300    m_pNameEditor->setFocus();
     301}
     302
     303void UIWizardNewVMPageBasic2::cleanupPage()
     304{
     305    /* Cleanup: */
     306    cleanupMachineFolder();
     307    /* Call to base-class: */
     308    UIWizardPage::cleanupPage();
     309}
     310
     311bool UIWizardNewVMPageBasic2::validatePage()
     312{
     313    /* Try to create machine folder: */
     314    return createMachineFolder();
     315}
     316
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic2.h

    r40870 r41021  
    2424
    2525/* Forward declarations: */
    26 class QIRichTextLabel;
    2726class QGroupBox;
    2827class QLineEdit;
    2928class VBoxOSTypeSelectorWidget;
     29class QIRichTextLabel;
    3030
    31 /* 2nd page of the New Virtual Machine wizard: */
    32 class UIWizardNewVMPageBasic2 : public UIWizardPage
     31/* 2nd page of the New Virtual Machine wizard (base part): */
     32class UIWizardNewVMPage2 : public UIWizardPageBase
     33{
     34protected:
     35
     36    /* Constructor: */
     37    UIWizardNewVMPage2();
     38
     39    /* Handlers: */
     40    void onNameChanged(const QString &strNewName);
     41    void onOsTypeChanged();
     42
     43    /* Helping stuff: */
     44    bool machineFolderCreated();
     45    bool createMachineFolder();
     46    bool cleanupMachineFolder();
     47
     48    /* Stuff for 'machineFolder' field: */
     49    QString machineFolder() const { return m_strMachineFolder; }
     50    void setMachineFolder(const QString &strMachineFolder) { m_strMachineFolder = strMachineFolder; }
     51
     52    /* Stuff for 'machineBaseName' field: */
     53    QString machineBaseName() const { return m_strMachineBaseName; }
     54    void setMachineBaseName(const QString &strMachineBaseName) { m_strMachineBaseName = strMachineBaseName; }
     55
     56    /* Variables: */
     57    QString m_strMachineFolder;
     58    QString m_strMachineBaseName;
     59
     60    /* Widgets: */
     61    QGroupBox *m_pNameCnt;
     62    QLineEdit *m_pNameEditor;
     63    QGroupBox *m_pTypeCnt;
     64    VBoxOSTypeSelectorWidget *m_pTypeSelector;
     65};
     66
     67/* 2nd page of the New Virtual Machine wizard (basic extension): */
     68class UIWizardNewVMPageBasic2 : public UIWizardPage, public UIWizardNewVMPage2
    3369{
    3470    Q_OBJECT;
     
    4076    /* Constructor: */
    4177    UIWizardNewVMPageBasic2();
     78
     79protected:
     80
     81    /* Wrapper to access 'this' from base part: */
     82    UIWizardPage* thisImp() { return this; }
    4283
    4384private slots:
     
    59100    bool validatePage();
    60101
    61     /* Helping stuff: */
    62     bool machineFolderCreated();
    63     bool createMachineFolder();
    64     bool cleanupMachineFolder();
    65 
    66     /* Stuff for 'machineFolder' field: */
    67     QString machineFolder() const;
    68     void setMachineFolder(const QString &strMachineFolder);
    69     QString m_strMachineFolder;
    70 
    71     /* Stuff for 'machineBaseName' field: */
    72     QString machineBaseName() const;
    73     void setMachineBaseName(const QString &strMachineBaseName);
    74     QString m_strMachineBaseName;
    75 
    76102    /* Widgets: */
    77103    QIRichTextLabel *m_pLabel;
    78     QGroupBox *m_pNameEditorCnt;
    79     QLineEdit *m_pNameEditor;
    80     QGroupBox *m_pTypeSelectorCnt;
    81     VBoxOSTypeSelectorWidget *m_pTypeSelector;
    82104};
    83105
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic3.cpp

    r40870 r41021  
    3131#include "COMDefs.h"
    3232#include "VBoxGlobal.h"
    33 #include "QIRichTextLabel.h"
    3433#include "VBoxGuestRAMSlider.h"
    3534#include "QILineEdit.h"
     35#include "QIRichTextLabel.h"
     36
     37UIWizardNewVMPage3::UIWizardNewVMPage3()
     38{
     39}
     40
     41void UIWizardNewVMPage3::onRamSliderValueChanged(int iValue)
     42{
     43    /* Update 'ram' field editor connected to slider: */
     44    m_pRamEditor->blockSignals(true);
     45    m_pRamEditor->setText(QString::number(iValue));
     46    m_pRamEditor->blockSignals(false);
     47}
     48
     49void UIWizardNewVMPage3::onRamEditorTextChanged(const QString &strText)
     50{
     51    /* Update 'ram' field slider connected to editor: */
     52    m_pRamSlider->blockSignals(true);
     53    m_pRamSlider->setValue(strText.toInt());
     54    m_pRamSlider->blockSignals(false);
     55}
    3656
    3757UIWizardNewVMPageBasic3::UIWizardNewVMPageBasic3()
     
    3959    /* Create widget: */
    4060    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     61    {
    4162        m_pLabel1 = new QIRichTextLabel(this);
    4263        m_pLabel2 = new QIRichTextLabel(this);
    4364        m_pMemoryCnt = new QGroupBox(this);
     65        {
    4466            m_pMemoryCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    45             QGridLayout *pMemoryLayout = new QGridLayout(m_pMemoryCnt);
     67            QGridLayout *pMemoryCntLayout = new QGridLayout(m_pMemoryCnt);
     68            {
    4669                m_pRamSlider = new VBoxGuestRAMSlider(m_pMemoryCnt);
     70                {
    4771                    m_pRamSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    4872                    m_pRamSlider->setOrientation(Qt::Horizontal);
    4973                    m_pRamSlider->setTickPosition(QSlider::TicksBelow);
     74                }
    5075                m_pRamEditor = new QILineEdit(m_pMemoryCnt);
     76                {
    5177                    m_pRamEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    5278                    m_pRamEditor->setFixedWidthByText("88888");
    5379                    m_pRamEditor->setAlignment(Qt::AlignRight);
    5480                    m_pRamEditor->setValidator(new QIntValidator(m_pRamSlider->minRAM(), m_pRamSlider->maxRAM(), this));
     81                }
    5582                m_pRamUnits = new QLabel(m_pMemoryCnt);
     83                {
    5684                    m_pRamUnits->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     85                }
    5786                m_pRamMin = new QLabel(m_pMemoryCnt);
     87                {
    5888                    m_pRamMin->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     89                }
    5990                QSpacerItem *m_pRamSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding);
    6091                m_pRamMax = new QLabel(m_pMemoryCnt);
     92                {
    6193                    m_pRamMax->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    62             pMemoryLayout->addWidget(m_pRamSlider, 0, 0, 1, 3);
    63             pMemoryLayout->addWidget(m_pRamEditor, 0, 3);
    64             pMemoryLayout->addWidget(m_pRamUnits, 0, 4);
    65             pMemoryLayout->addWidget(m_pRamMin, 1, 0);
    66             pMemoryLayout->addItem(m_pRamSpacer, 1, 1);
    67             pMemoryLayout->addWidget(m_pRamMax, 1, 2);
    68     pMainLayout->addWidget(m_pLabel1);
    69     pMainLayout->addWidget(m_pLabel2);
    70     pMainLayout->addWidget(m_pMemoryCnt);
    71     pMainLayout->addStretch();
     94                }
     95                pMemoryCntLayout->addWidget(m_pRamSlider, 0, 0, 1, 3);
     96                pMemoryCntLayout->addWidget(m_pRamEditor, 0, 3);
     97                pMemoryCntLayout->addWidget(m_pRamUnits, 0, 4);
     98                pMemoryCntLayout->addWidget(m_pRamMin, 1, 0);
     99                pMemoryCntLayout->addItem(m_pRamSpacer, 1, 1);
     100                pMemoryCntLayout->addWidget(m_pRamMax, 1, 2);
     101            }
     102        }
     103        pMainLayout->addWidget(m_pLabel1);
     104        pMainLayout->addWidget(m_pLabel2);
     105        pMainLayout->addWidget(m_pMemoryCnt);
     106        pMainLayout->addStretch();
     107    }
    72108
    73109    /* Setup connections: */
    74     connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(ramSliderValueChanged(int)));
    75     connect(m_pRamEditor, SIGNAL(textChanged(const QString&)), this, SLOT(ramEditorTextChanged(const QString&)));
     110    connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged(int)));
     111    connect(m_pRamEditor, SIGNAL(textChanged(const QString&)), this, SLOT(sltRamEditorTextChanged(const QString&)));
    76112
    77     /* Initialize connections: */
    78     ramSliderValueChanged(m_pRamSlider->value());
    79 
    80     /* Register field: */
    81     registerField("ram*", m_pRamSlider, "value", SIGNAL(valueChanged(int)));
     113    /* Register fields: */
     114    registerField("ram", m_pRamSlider, "value", SIGNAL(valueChanged(int)));
    82115}
    83116
    84 void UIWizardNewVMPageBasic3::ramSliderValueChanged(int iValue)
     117void UIWizardNewVMPageBasic3::sltRamSliderValueChanged(int iValue)
    85118{
    86     /* Update 'ram' field editor connected to slider: */
    87     m_pRamEditor->setText(QString::number(iValue));
     119    /* Call to base-class: */
     120    onRamSliderValueChanged(iValue);
     121
     122    /* Broadcast complete-change: */
     123    emit completeChanged();
    88124}
    89125
    90 void UIWizardNewVMPageBasic3::ramEditorTextChanged(const QString &strText)
     126void UIWizardNewVMPageBasic3::sltRamEditorTextChanged(const QString &strText)
    91127{
    92     /* Update 'ram' field slider connected to editor: */
    93     m_pRamSlider->setValue(strText.toInt());
     128    /* Call to base-class: */
     129    onRamEditorTextChanged(strText);
     130
     131    /* Broadcast complete-change: */
     132    emit completeChanged();
    94133}
    95134
     
    117156    /* Get recommended 'ram' field value: */
    118157    CGuestOSType type = field("type").value<CGuestOSType>();
    119     ramSliderValueChanged(type.GetRecommendedRAM());
     158    m_pRamSlider->setValue(type.GetRecommendedRAM());
     159    m_pRamEditor->setText(QString::number(type.GetRecommendedRAM()));
    120160
    121161    /* 'Ram' field should have focus initially: */
     
    125165bool UIWizardNewVMPageBasic3::isComplete() const
    126166{
    127     /* Check what 'ram' field value feats the bounds: */
     167    /* Make sure 'ram' field feats the bounds: */
    128168    return m_pRamSlider->value() >= qMax(1, (int)m_pRamSlider->minRAM()) &&
    129169           m_pRamSlider->value() <= (int)m_pRamSlider->maxRAM();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic3.h

    r40870 r41021  
    2424
    2525/* Forward declarations: */
    26 class QIRichTextLabel;
    2726class QGroupBox;
    2827class VBoxGuestRAMSlider;
    2928class QILineEdit;
    3029class QLabel;
     30class QIRichTextLabel;
    3131
    32 /* 3rd page of the New Virtual Machine wizard: */
    33 class UIWizardNewVMPageBasic3 : public UIWizardPage
     32/* 3rd page of the New Virtual Machine wizard (base part): */
     33class UIWizardNewVMPage3 : public UIWizardPageBase
     34{
     35protected:
     36
     37    /* Constructor: */
     38    UIWizardNewVMPage3();
     39
     40    /* Handlers: */
     41    void onRamSliderValueChanged(int iValue);
     42    void onRamEditorTextChanged(const QString &strText);
     43
     44    /* Widgets: */
     45    QGroupBox *m_pMemoryCnt;
     46    VBoxGuestRAMSlider *m_pRamSlider;
     47    QILineEdit *m_pRamEditor;
     48    QLabel *m_pRamMin;
     49    QLabel *m_pRamMax;
     50    QLabel *m_pRamUnits;
     51};
     52
     53/* 3rd page of the New Virtual Machine wizard (basic extension): */
     54class UIWizardNewVMPageBasic3 : public UIWizardPage, public UIWizardNewVMPage3
    3455{
    3556    Q_OBJECT;
     
    4364
    4465    /* Handlers: */
    45     void ramSliderValueChanged(int iValue);
    46     void ramEditorTextChanged(const QString &strText);
     66    void sltRamSliderValueChanged(int iValue);
     67    void sltRamEditorTextChanged(const QString &strText);
    4768
    4869private:
     
    6081    QIRichTextLabel *m_pLabel1;
    6182    QIRichTextLabel *m_pLabel2;
    62     QGroupBox *m_pMemoryCnt;
    63     VBoxGuestRAMSlider *m_pRamSlider;
    64     QILineEdit *m_pRamEditor;
    65     QLabel *m_pRamMin;
    66     QLabel *m_pRamMax;
    67     QLabel *m_pRamUnits;
    6883};
    6984
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic4.cpp

    r40870 r41021  
    2828#include "UIWizardNewVMPageBasic4.h"
    2929#include "UIWizardNewVM.h"
     30#include "VBoxDefs.h"
     31#include "UIMessageCenter.h"
    3032#include "UIIconPool.h"
    31 #include "UIMessageCenter.h"
    32 #include "VBoxDefs.h"
    33 #include "QIRichTextLabel.h"
    3433#include "VBoxMediaComboBox.h"
    3534#include "QIToolButton.h"
    3635#include "UIWizardNewVD.h"
     36#include "QIRichTextLabel.h"
     37
     38UIWizardNewVMPage4::UIWizardNewVMPage4()
     39{
     40}
     41
     42void UIWizardNewVMPage4::updateVirtualDiskSource()
     43{
     44    /* Enable/disable controls: */
     45    m_pDiskCreate->setEnabled(m_pDiskCnt->isChecked());
     46    m_pDiskPresent->setEnabled(m_pDiskCnt->isChecked());
     47    m_pDiskSelector->setEnabled(m_pDiskPresent->isEnabled() && m_pDiskPresent->isChecked());
     48    m_pVMMButton->setEnabled(m_pDiskPresent->isEnabled() && m_pDiskPresent->isChecked());
     49
     50    /* Fetch filed values: */
     51    if (m_pDiskCnt->isChecked() && m_pDiskPresent->isChecked())
     52    {
     53        m_strVirtualDiskId = m_pDiskSelector->id();
     54        m_strVirtualDiskName = m_pDiskSelector->currentText();
     55        m_strVirtualDiskLocation = m_pDiskSelector->location();
     56    }
     57    else
     58    {
     59        m_strVirtualDiskId = QString();
     60        m_strVirtualDiskName = QString();
     61        m_strVirtualDiskLocation = QString();
     62    }
     63}
     64
     65void UIWizardNewVMPage4::getWithFileOpenDialog()
     66{
     67    /* Get opened medium id: */
     68    QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, thisImp());
     69    if (!strMediumId.isNull())
     70    {
     71        /* Update medium-combo if necessary: */
     72        m_pDiskSelector->setCurrentItem(strMediumId);
     73        /* Update hard disk source: */
     74        updateVirtualDiskSource();
     75        /* Focus on hard disk combo: */
     76        m_pDiskSelector->setFocus();
     77    }
     78}
     79
     80bool UIWizardNewVMPage4::getWithNewVirtualDiskWizard()
     81{
     82    /* Create New Virtual Disk wizard: */
     83    UIWizardNewVD dlg(thisImp(),
     84                      fieldImp("machineBaseName").toString(),
     85                      fieldImp("machineFolder").toString(),
     86                      fieldImp("type").value<CGuestOSType>().GetRecommendedHDD());
     87    if (dlg.exec() == QDialog::Accepted)
     88    {
     89        m_virtualDisk = dlg.virtualDisk();
     90        m_pDiskSelector->setCurrentItem(m_virtualDisk.GetId());
     91        m_pDiskPresent->click();
     92        return true;
     93    }
     94    return false;
     95}
     96
     97void UIWizardNewVMPage4::ensureNewVirtualDiskDeleted()
     98{
     99    /* Make sure virtual-disk exists: */
     100    if (m_virtualDisk.isNull())
     101        return;
     102
     103    /* Remember virtual-disk ID: */
     104    QString strId = m_virtualDisk.GetId();
     105
     106    /* 1st step: start delete-storage progress: */
     107    CProgress progress = m_virtualDisk.DeleteStorage();
     108    /* Get initial state: */
     109    bool fSuccess = m_virtualDisk.isOk();
     110
     111    /* 2nd step: show delete-storage progress: */
     112    if (fSuccess)
     113    {
     114        msgCenter().showModalProgressDialog(progress, thisImp()->windowTitle(), ":/progress_media_delete_90px.png", thisImp(), true);
     115        fSuccess = progress.isOk() && progress.GetResultCode() == S_OK;
     116    }
     117
     118    /* 3rd step: notify GUI about virtual-disk was deleted or show error if any: */
     119    if (fSuccess)
     120        vboxGlobal().removeMedium(VBoxDefs::MediumType_HardDisk, strId);
     121    else
     122        msgCenter().cannotDeleteHardDiskStorage(thisImp(), m_virtualDisk, progress);
     123
     124    /* Detach virtual-disk finally: */
     125    m_virtualDisk.detach();
     126}
    37127
    38128UIWizardNewVMPageBasic4::UIWizardNewVMPageBasic4()
     
    40130    /* Create widgets: */
    41131    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     132    {
    42133        m_pLabel1 = new QIRichTextLabel(this);
    43134        m_pLabel2 = new QIRichTextLabel(this);
    44         m_pBootHDCnt = new QGroupBox(this);
    45             m_pBootHDCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    46             m_pBootHDCnt->setCheckable(true);
    47             QGridLayout *pDiskLayout = new QGridLayout(m_pBootHDCnt);
    48                 m_pDiskCreate = new QRadioButton(m_pBootHDCnt);
    49                 m_pDiskPresent = new QRadioButton(m_pBootHDCnt);
     135        m_pDiskCnt = new QGroupBox(this);
     136        {
     137            m_pDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     138            m_pDiskCnt->setCheckable(true);
     139            QGridLayout *pDiskLayout = new QGridLayout(m_pDiskCnt);
     140            {
     141                m_pDiskCreate = new QRadioButton(m_pDiskCnt);
     142                m_pDiskPresent = new QRadioButton(m_pDiskCnt);
    50143                QStyleOptionButton options;
    51144                options.initFrom(m_pDiskCreate);
    52                 int wid = m_pDiskCreate->style()->subElementRect(QStyle::SE_RadioButtonIndicator, &options, m_pDiskCreate).width() +
    53                           m_pDiskCreate->style()->pixelMetric(QStyle::PM_RadioButtonLabelSpacing, &options, m_pDiskCreate) -
    54                           pDiskLayout->spacing() - 1;
    55                 QSpacerItem *pSpacer = new QSpacerItem(wid, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
    56                 m_pDiskSelector = new VBoxMediaComboBox(m_pBootHDCnt);
     145                int iWidth = m_pDiskCreate->style()->subElementRect(QStyle::SE_RadioButtonIndicator, &options, m_pDiskCreate).width() +
     146                             m_pDiskCreate->style()->pixelMetric(QStyle::PM_RadioButtonLabelSpacing, &options, m_pDiskCreate) -
     147                             pDiskLayout->spacing() - 1;
     148                QSpacerItem *pSpacer = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
     149                m_pDiskSelector = new VBoxMediaComboBox(m_pDiskCnt);
     150                {
    57151                    m_pDiskSelector->setType(VBoxDefs::MediumType_HardDisk);
    58152                    m_pDiskSelector->repopulate();
    59                 m_pVMMButton = new QIToolButton(m_pBootHDCnt);
     153                }
     154                m_pVMMButton = new QIToolButton(m_pDiskCnt);
     155                {
    60156                    m_pVMMButton->setAutoRaise(true);
    61157                    m_pVMMButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png"));
    62             pDiskLayout->addWidget(m_pDiskCreate, 0, 0, 1, 3);
    63             pDiskLayout->addWidget(m_pDiskPresent, 1, 0, 1, 3);
    64             pDiskLayout->addItem(pSpacer, 2, 0);
    65             pDiskLayout->addWidget(m_pDiskSelector, 2, 1);
    66             pDiskLayout->addWidget(m_pVMMButton, 2, 2);
    67     pMainLayout->addWidget(m_pLabel1);
    68     pMainLayout->addWidget(m_pLabel2);
    69     pMainLayout->addWidget(m_pBootHDCnt);
    70     pMainLayout->addStretch();
     158                }
     159                pDiskLayout->addWidget(m_pDiskCreate, 0, 0, 1, 3);
     160                pDiskLayout->addWidget(m_pDiskPresent, 1, 0, 1, 3);
     161                pDiskLayout->addItem(pSpacer, 2, 0);
     162                pDiskLayout->addWidget(m_pDiskSelector, 2, 1);
     163                pDiskLayout->addWidget(m_pVMMButton, 2, 2);
     164            }
     165        }
     166        pMainLayout->addWidget(m_pLabel1);
     167        pMainLayout->addWidget(m_pLabel2);
     168        pMainLayout->addWidget(m_pDiskCnt);
     169        pMainLayout->addStretch();
     170        updateVirtualDiskSource();
     171    }
    71172
    72173    /* Setup connections: */
    73     connect(m_pBootHDCnt, SIGNAL(toggled(bool)), this, SLOT(virtualDiskSourceChanged()));
    74     connect(m_pDiskCreate, SIGNAL(toggled(bool)), this, SLOT(virtualDiskSourceChanged()));
    75     connect(m_pDiskPresent, SIGNAL(toggled(bool)), this, SLOT(virtualDiskSourceChanged()));
    76     connect(m_pDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualDiskSourceChanged()));
    77     connect(m_pVMMButton, SIGNAL(clicked()), this, SLOT(getWithFileOpenDialog()));
    78 
    79     /* Initialise connections: */
    80     virtualDiskSourceChanged();
    81 
    82     /* Register CMedium class: */
     174    connect(m_pDiskCnt, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
     175    connect(m_pDiskCreate, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
     176    connect(m_pDiskPresent, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
     177    connect(m_pDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(sltVirtualDiskSourceChanged()));
     178    connect(m_pVMMButton, SIGNAL(clicked()), this, SLOT(sltGetWithFileOpenDialog()));
     179
     180    /* Register classes: */
    83181    qRegisterMetaType<CMedium>();
    84182    /* Register fields: */
     
    89187}
    90188
    91 void UIWizardNewVMPageBasic4::ensureNewVirtualDiskDeleted()
    92 {
    93     if (m_virtualDisk.isNull())
    94         return;
    95 
    96     QString strId = m_virtualDisk.GetId();
    97 
    98     bool fSuccess = false;
    99 
    100     CProgress progress = m_virtualDisk.DeleteStorage();
    101     if (m_virtualDisk.isOk())
    102     {
    103         msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_delete_90px.png", this, true);
    104         if (progress.isOk() && progress.GetResultCode() == S_OK)
    105             fSuccess = true;
    106     }
    107 
    108     if (fSuccess)
    109         vboxGlobal().removeMedium(VBoxDefs::MediumType_HardDisk, strId);
    110     else
    111         msgCenter().cannotDeleteHardDiskStorage(this, m_virtualDisk, progress);
    112 
    113     m_virtualDisk.detach();
    114 }
    115 
    116 void UIWizardNewVMPageBasic4::virtualDiskSourceChanged()
    117 {
    118     m_pDiskCreate->setEnabled(m_pBootHDCnt->isChecked());
    119     m_pDiskPresent->setEnabled(m_pBootHDCnt->isChecked());
    120     m_pDiskSelector->setEnabled(m_pDiskPresent->isEnabled() && m_pDiskPresent->isChecked());
    121     m_pVMMButton->setEnabled(m_pDiskPresent->isEnabled() && m_pDiskPresent->isChecked());
    122 
    123     if (m_pBootHDCnt->isChecked() && m_pDiskPresent->isChecked())
    124     {
    125         m_strVirtualDiskId = m_pDiskSelector->id();
    126         m_strVirtualDiskName = m_pDiskSelector->currentText();
    127         m_strVirtualDiskLocation = m_pDiskSelector->location();
    128     }
    129     else
    130     {
    131         m_strVirtualDiskId.clear();
    132         m_strVirtualDiskName.clear();
    133         m_strVirtualDiskLocation.clear();
    134     }
    135 
     189void UIWizardNewVMPageBasic4::sltVirtualDiskSourceChanged()
     190{
     191    /* Call to base-class: */
     192    updateVirtualDiskSource();
     193
     194    /* Broadcast complete-change: */
    136195    emit completeChanged();
    137196}
    138197
    139 void UIWizardNewVMPageBasic4::getWithFileOpenDialog()
    140 {
    141     /* Get opened vboxMedium id: */
    142     QString strMediumId = vboxGlobal().openMediumWithFileOpenDialog(VBoxDefs::MediumType_HardDisk, this);
    143     if (!strMediumId.isNull())
    144     {
    145         /* Update medium-combo if necessary: */
    146         m_pDiskSelector->setCurrentItem(strMediumId);
    147         /* Update hard disk source: */
    148         virtualDiskSourceChanged();
    149         /* Focus on hard disk combo: */
    150         m_pDiskSelector->setFocus();
    151     }
     198void UIWizardNewVMPageBasic4::sltGetWithFileOpenDialog()
     199{
     200    /* Call to base-class: */
     201    getWithFileOpenDialog();
    152202}
    153203
     
    159209    /* Translate widgets: */
    160210    m_pLabel1->setText(UIWizardNewVM::tr("<p>If you wish you can now add a start-up disk to the new machine. "
    161                               "You can either create a new virtual disk or select one from the list "
    162                               "or from another location using the folder icon.</p>"
    163                               "<p>If you need a more complex virtual disk setup you can skip this step "
    164                               "and make the changes to the machine settings once the machine is created.</p>"));
     211                                         "You can either create a new virtual disk or select one from the list "
     212                                         "or from another location using the folder icon.</p>"
     213                                         "<p>If you need a more complex virtual disk setup you can skip this step "
     214                                         "and make the changes to the machine settings once the machine is created.</p>"));
    165215    QString strRecommendedHDD = field("type").value<CGuestOSType>().isNull() ? QString() :
    166216                                VBoxGlobal::formatSize(field("type").value<CGuestOSType>().GetRecommendedHDD());
    167217    m_pLabel2->setText(UIWizardNewVM::tr("The recommended size of the start-up disk is <b>%1</b>.").arg(strRecommendedHDD));
    168     m_pBootHDCnt->setTitle(UIWizardNewVM::tr("Start-up &Disk"));
     218    m_pDiskCnt->setTitle(UIWizardNewVM::tr("Start-up &Disk"));
    169219    m_pDiskCreate->setText(UIWizardNewVM::tr("&Create new hard disk"));
    170220    m_pDiskPresent->setText(UIWizardNewVM::tr("&Use existing hard disk"));
     
    178228
    179229    /* Prepare initial choice: */
    180     m_pBootHDCnt->setChecked(true);
     230    m_pDiskCnt->setChecked(true);
    181231    m_pDiskSelector->setCurrentIndex(0);
    182232    m_pDiskCreate->setChecked(true);
     
    188238void UIWizardNewVMPageBasic4::cleanupPage()
    189239{
    190     /* Clean medium if present */
     240    /* Call to base-class: */
    191241    ensureNewVirtualDiskDeleted();
    192     /* Clean fields of that page */
    193242    UIWizardPage::cleanupPage();
    194243}
     
    196245bool UIWizardNewVMPageBasic4::isComplete() const
    197246{
    198     /* Check what virtualDisk feats the rules: */
    199     return !m_pBootHDCnt->isChecked() ||
     247    /* Make sure 'virtualDisk' field feats the rules: */
     248    return !m_pDiskCnt->isChecked() ||
    200249           !m_pDiskPresent->isChecked() ||
    201250           !vboxGlobal().findMedium(m_pDiskSelector->id()).isNull();
     
    204253bool UIWizardNewVMPageBasic4::validatePage()
    205254{
     255    /* Initial result: */
     256    bool fResult = true;
     257
    206258    /* Ensure unused virtual-disk is deleted: */
    207     if (!m_pBootHDCnt->isChecked() || m_pDiskCreate->isChecked() || (!m_virtualDisk.isNull() && m_strVirtualDiskId != m_virtualDisk.GetId()))
     259    if (!m_pDiskCnt->isChecked() || m_pDiskCreate->isChecked() || (!m_virtualDisk.isNull() && m_strVirtualDiskId != m_virtualDisk.GetId()))
    208260        ensureNewVirtualDiskDeleted();
    209261
    210     /* Ask user about disk-less machine: */
    211     if (!m_pBootHDCnt->isChecked() && !msgCenter().confirmHardDisklessMachine(this))
    212         return false;
    213 
    214     /* Show the New Virtual Disk wizard: */
    215     if (m_pBootHDCnt->isChecked() && m_pDiskCreate->isChecked() && !getWithNewVirtualDiskWizard())
    216         return false;
    217 
    218     return true;
    219 }
    220 
    221 bool UIWizardNewVMPageBasic4::getWithNewVirtualDiskWizard()
    222 {
    223     UIWizardNewVD dlg(this, field("machineBaseName").toString(), field("machineFolder").toString(), field("type").value<CGuestOSType>().GetRecommendedHDD());
    224     if (dlg.exec() == QDialog::Accepted)
    225     {
    226         m_virtualDisk = dlg.virtualDisk();
    227         m_pDiskSelector->setCurrentItem(m_virtualDisk.GetId());
    228         m_pDiskPresent->click();
    229         return true;
    230     }
    231     return false;
    232 }
    233 
    234 CMedium UIWizardNewVMPageBasic4::virtualDisk() const
    235 {
    236     return m_virtualDisk;
    237 }
    238 
    239 void UIWizardNewVMPageBasic4::setVirtualDisk(const CMedium &virtualDisk)
    240 {
    241     m_virtualDisk = virtualDisk;
    242 }
    243 
    244 QString UIWizardNewVMPageBasic4::virtualDiskId() const
    245 {
    246     return m_strVirtualDiskId;
    247 }
    248 
    249 void UIWizardNewVMPageBasic4::setVirtualDiskId(const QString &strVirtualDiskId)
    250 {
    251     m_strVirtualDiskId = strVirtualDiskId;
    252 }
    253 
    254 QString UIWizardNewVMPageBasic4::virtualDiskName() const
    255 {
    256     return m_strVirtualDiskName;
    257 }
    258 
    259 void UIWizardNewVMPageBasic4::setVirtualDiskName(const QString &strVirtualDiskName)
    260 {
    261     m_strVirtualDiskName = strVirtualDiskName;
    262 }
    263 
    264 QString UIWizardNewVMPageBasic4::virtualDiskLocation() const
    265 {
    266     return m_strVirtualDiskLocation;
    267 }
    268 
    269 void UIWizardNewVMPageBasic4::setVirtualDiskLocation(const QString &strVirtualDiskLocation)
    270 {
    271     m_strVirtualDiskLocation = strVirtualDiskLocation;
    272 }
    273 
     262    if (!m_pDiskCnt->isChecked())
     263    {
     264        /* Ask user about disk-less machine: */
     265        fResult = msgCenter().confirmHardDisklessMachine(this);
     266    }
     267    else if (m_pDiskCreate->isChecked())
     268    {
     269        /* Show the New Virtual Disk wizard: */
     270        fResult = getWithNewVirtualDiskWizard();
     271    }
     272
     273    /* Return result: */
     274    return fResult;
     275}
     276
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic4.h

    r40870 r41021  
    2020#define __UIWizardNewVMPageBasic4_h__
    2121
     22/* Global includes: */
     23#include <QVariant>
     24
    2225/* Local includes: */
    2326#include "UIWizardPage.h"
     
    2528
    2629/* Forward declarations: */
    27 class QIRichTextLabel;
    2830class QGroupBox;
    2931class QRadioButton;
    3032class VBoxMediaComboBox;
    3133class QIToolButton;
     34class QIRichTextLabel;
    3235
    33 /* 4th page of the New Virtual Machine wizard: */
    34 class UIWizardNewVMPageBasic4 : public UIWizardPage
     36/* 4th page of the New Virtual Machine wizard (base part): */
     37class UIWizardNewVMPage4 : public UIWizardPageBase
     38{
     39protected:
     40
     41    /* Constructor: */
     42    UIWizardNewVMPage4();
     43
     44    /* Handlers: */
     45    void updateVirtualDiskSource();
     46    void getWithFileOpenDialog();
     47    bool getWithNewVirtualDiskWizard();
     48
     49    /* Stuff for 'virtualDisk' field: */
     50    CMedium virtualDisk() const { return m_virtualDisk; }
     51    void setVirtualDisk(const CMedium &virtualDisk) { m_virtualDisk = virtualDisk; }
     52
     53    /* Stuff for 'virtualDiskId' field: */
     54    QString virtualDiskId() const { return m_strVirtualDiskId; }
     55    void setVirtualDiskId(const QString &strVirtualDiskId) { m_strVirtualDiskId = strVirtualDiskId; }
     56
     57    /* Stuff for 'virtualDiskName' field: */
     58    QString virtualDiskName() const { return m_strVirtualDiskName; }
     59    void setVirtualDiskName(const QString &strVirtualDiskName) { m_strVirtualDiskName = strVirtualDiskName; }
     60
     61    /* Stuff for 'virtualDiskLocation' field: */
     62    QString virtualDiskLocation() const { return m_strVirtualDiskLocation; }
     63    void setVirtualDiskLocation(const QString &strVirtualDiskLocation) { m_strVirtualDiskLocation = strVirtualDiskLocation; }
     64
     65    /* Helpers: */
     66    void ensureNewVirtualDiskDeleted();
     67
     68    /* Variables: */
     69    CMedium m_virtualDisk;
     70    QString m_strVirtualDiskId;
     71    QString m_strVirtualDiskName;
     72    QString m_strVirtualDiskLocation;
     73
     74    /* Widgets: */
     75    QGroupBox *m_pDiskCnt;
     76    QRadioButton *m_pDiskCreate;
     77    QRadioButton *m_pDiskPresent;
     78    VBoxMediaComboBox *m_pDiskSelector;
     79    QIToolButton *m_pVMMButton;
     80};
     81
     82/* 4th page of the New Virtual Machine wizard (basic extension): */
     83class UIWizardNewVMPageBasic4 : public UIWizardPage, public UIWizardNewVMPage4
    3584{
    3685    Q_OBJECT;
     
    4594    UIWizardNewVMPageBasic4();
    4695
     96protected:
     97
     98    /* Wrapper to access 'this' from base part: */
     99    UIWizardPage* thisImp() { return this; }
     100    /* Wrapper to access 'wizard-field' from base part: */
     101    QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
     102
    47103private slots:
    48104
    49105    /* Handlers: */
    50     void ensureNewVirtualDiskDeleted();
    51     void virtualDiskSourceChanged();
    52     void getWithFileOpenDialog();
     106    void sltVirtualDiskSourceChanged();
     107    void sltGetWithFileOpenDialog();
    53108
    54109private:
     
    65120    bool validatePage();
    66121
    67     /* Helpers: */
    68     bool getWithNewVirtualDiskWizard();
    69 
    70     /* Stuff for 'virtualDisk' field: */
    71     CMedium virtualDisk() const;
    72     void setVirtualDisk(const CMedium &virtualDisk);
    73     CMedium m_virtualDisk;
    74 
    75     /* Stuff for 'virtualDiskId' field: */
    76     QString virtualDiskId() const;
    77     void setVirtualDiskId(const QString &strVirtualDiskId);
    78     QString m_strVirtualDiskId;
    79 
    80     /* Stuff for 'virtualDiskName' field: */
    81     QString virtualDiskName() const;
    82     void setVirtualDiskName(const QString &strVirtualDiskName);
    83     QString m_strVirtualDiskName;
    84 
    85     /* Stuff for 'virtualDiskLocation' field: */
    86     QString virtualDiskLocation() const;
    87     void setVirtualDiskLocation(const QString &strVirtualDiskLocation);
    88     QString m_strVirtualDiskLocation;
    89 
    90122    /* Widgets: */
    91123    QIRichTextLabel *m_pLabel1;
    92124    QIRichTextLabel *m_pLabel2;
    93     QGroupBox *m_pBootHDCnt;
    94     QRadioButton *m_pDiskCreate;
    95     QRadioButton *m_pDiskPresent;
    96     VBoxMediaComboBox *m_pDiskSelector;
    97     QIToolButton *m_pVMMButton;
    98125};
    99126
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.cpp

    r40870 r41021  
    2727#include "QIRichTextLabel.h"
    2828
     29UIWizardNewVMPage5::UIWizardNewVMPage5()
     30{
     31}
     32
    2933UIWizardNewVMPageBasic5::UIWizardNewVMPageBasic5()
    3034{
    3135    /* Create widget: */
    3236    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    33         m_pPage5Text1 = new QIRichTextLabel(this);
    34         m_pSummaryText = new QIRichTextLabel(this);
    35         m_pPage5Text2 = new QIRichTextLabel(this);
    36     pMainLayout->addWidget(m_pPage5Text1);
    37     pMainLayout->addWidget(m_pSummaryText);
    38     pMainLayout->addWidget(m_pPage5Text2);
    39     pMainLayout->addStretch();
     37    {
     38        m_pLabel1 = new QIRichTextLabel(this);
     39        m_pSummary = new QIRichTextLabel(this);
     40        m_pLabel2 = new QIRichTextLabel(this);
     41        pMainLayout->addWidget(m_pLabel1);
     42        pMainLayout->addWidget(m_pSummary);
     43        pMainLayout->addWidget(m_pLabel2);
     44        pMainLayout->addStretch();
     45    }
    4046}
    4147
     
    4652
    4753    /* Translate widgets: */
    48     m_pPage5Text1->setText(UIWizardNewVM::tr("<p>You are going to create a new virtual machine with the following parameters:</p>"));
    49     m_pPage5Text2->setText(UIWizardNewVM::tr("<p>If the above is correct press the <b>%1</b> button. Once "
    50                                              "you press it, a new virtual machine will be created. </p><p>Note "
    51                                              "that you can alter these and all other setting of the created "
    52                                              "virtual machine at any time using the <b>Settings</b> dialog "
    53                                              "accessible through the menu of the main window.</p>")
    54                                             .arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton)))));
     54    m_pLabel1->setText(UIWizardNewVM::tr("<p>You are going to create a new virtual machine with the following parameters:</p>"));
     55    m_pLabel2->setText(UIWizardNewVM::tr("<p>If the above is correct press the <b>%1</b> button. Once "
     56                                         "you press it, a new virtual machine will be created. </p><p>Note "
     57                                         "that you can alter these and all other setting of the created "
     58                                         "virtual machine at any time using the <b>Settings</b> dialog "
     59                                         "accessible through the menu of the main window.</p>")
     60                                        .arg(VBoxGlobal::replaceHtmlEntities(VBoxGlobal::removeAccelMark(wizard()->buttonText(QWizard::FinishButton)))));
    5561
    5662    /* Compose common summary: */
     
    7480                             .arg(UIWizardNewVM::tr("Start-up Disk", "summary"), field("virtualDiskName").toString());
    7581    }
    76     m_pSummaryText->setText("<table cellspacing=0 cellpadding=0>" + strSummary + "</table>");
     82    m_pSummary->setText("<table cellspacing=0 cellpadding=0>" + strSummary + "</table>");
    7783}
    7884
     
    8389
    8490    /* Summary should have focus initially: */
    85     m_pSummaryText->setFocus();
     91    m_pSummary->setFocus();
    8692}
    8793
    8894bool UIWizardNewVMPageBasic5::validatePage()
    8995{
     96    /* Initial result: */
     97    bool fResult = true;
     98
     99    /* Lock finish button: */
     100    startProcessing();
     101
    90102    /* Try to create VM: */
    91     startProcessing();
    92     bool fResult = qobject_cast<UIWizardNewVM*>(wizard())->createVM();
     103    if (fResult)
     104        fResult = qobject_cast<UIWizardNewVM*>(wizard())->createVM();
     105
     106    /* Unlock finish button: */
    93107    endProcessing();
     108
     109    /* Return result: */
    94110    return fResult;
    95111}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.h

    r40870 r41021  
    2626class QIRichTextLabel;
    2727
    28 /* 5th page of the New Virtual Machine wizard: */
    29 class UIWizardNewVMPageBasic5 : public UIWizardPage
     28/* 5th page of the New Virtual Machine wizard (base part): */
     29class UIWizardNewVMPage5 : public UIWizardPageBase
     30{
     31protected:
     32
     33    /* Constructor: */
     34    UIWizardNewVMPage5();
     35};
     36
     37/* 5th page of the New Virtual Machine wizard (basic extension): */
     38class UIWizardNewVMPageBasic5 : public UIWizardPage, public UIWizardNewVMPage5
    3039{
    3140    Q_OBJECT;
     
    3645    UIWizardNewVMPageBasic5();
    3746
    38 protected:
     47private:
    3948
    4049    /* Translate stuff: */
     
    4756    bool validatePage();
    4857
    49 private:
    50 
    5158    /* Widgets: */
    52     QIRichTextLabel *m_pPage5Text1;
    53     QIRichTextLabel *m_pSummaryText;
    54     QIRichTextLabel *m_pPage5Text2;
     59    QIRichTextLabel *m_pLabel1;
     60    QIRichTextLabel *m_pSummary;
     61    QIRichTextLabel *m_pLabel2;
    5562};
    5663
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r40929 r41021  
    33 *
    44 * VBox frontends: Qt4 GUI ("VirtualBox"):
    5  * UIWizardNewVMPageBasic1 class implementation
     5 * UIWizardNewVMPageExpert class implementation
    66 */
    77
     
    2020/* Global includes: */
    2121#include <QVBoxLayout>
     22#include <QHBoxLayout>
     23#include <QGroupBox>
     24#include <QGridLayout>
     25#include <QSpacerItem>
     26#include <QLineEdit>
     27#include <QLabel>
     28#include <QRadioButton>
    2229
    2330/* Local includes: */
    24 #include "UIWizardNewVMPageBasic1.h"
     31#include "UIWizardNewVMPageExpert.h"
    2532#include "UIWizardNewVM.h"
    2633#include "UIIconPool.h"
    27 #include "QIRichTextLabel.h"
    28 
    29 UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1()
     34#include "UIMessageCenter.h"
     35#include "VBoxOSTypeSelectorWidget.h"
     36#include "VBoxGuestRAMSlider.h"
     37#include "VBoxMediaComboBox.h"
     38#include "QILineEdit.h"
     39#include "QIToolButton.h"
     40
     41UIWizardNewVMPageExpert::UIWizardNewVMPageExpert()
    3042{
    3143    /* Create widgets: */
    3244    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    33         m_pLabel1 = new QIRichTextLabel(this);
    34             /* Register 'message-box warning-icon' image in m_pLabel1 as 'image': */
    35             QSize wSize(64, 64);
    36             QPixmap wPixmap = UIIconPool::defaultIcon(UIIconPool::MessageBoxWarningIcon).pixmap(wSize);
    37             if (wPixmap.width() != wSize.width())
    38                 wPixmap = wPixmap.scaled(wSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
    39             QImage wImage = wPixmap.toImage();
    40             m_pLabel1->registerImage(wImage, "image");
    41         m_pLabel2 = new QIRichTextLabel(this);
    42     pMainLayout->addWidget(m_pLabel1);
    43     pMainLayout->addWidget(m_pLabel2);
    44     pMainLayout->addStretch();
    45 }
    46 
    47 void UIWizardNewVMPageBasic1::retranslateUi()
    48 {
    49     /* Translate page: */
    50     setTitle(UIWizardNewVM::tr("Welcome to the New Virtual Machine Wizard!"));
    51 
     45    {
     46        pMainLayout->setContentsMargins(8, 6, 8, 6);
     47        m_pNameCnt = new QGroupBox(this);
     48        {
     49            m_pNameCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     50            QHBoxLayout *pNameCntLayout = new QHBoxLayout(m_pNameCnt);
     51            {
     52                m_pNameEditor = new QLineEdit(m_pNameCnt);
     53                pNameCntLayout->addWidget(m_pNameEditor);
     54            }
     55        }
     56        m_pTypeCnt = new QGroupBox(this);
     57        {
     58            m_pTypeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     59            QHBoxLayout *pTypeCntLayout = new QHBoxLayout(m_pTypeCnt);
     60            {
     61                m_pTypeSelector = new VBoxOSTypeSelectorWidget(m_pTypeCnt);
     62                {
     63                    m_pTypeSelector->activateLayout();
     64                }
     65                pTypeCntLayout->addWidget(m_pTypeSelector);
     66            }
     67        }
     68        m_pMemoryCnt = new QGroupBox(this);
     69        {
     70            m_pMemoryCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     71            QGridLayout *pMemoryCntLayout = new QGridLayout(m_pMemoryCnt);
     72            {
     73                m_pRamSlider = new VBoxGuestRAMSlider(m_pMemoryCnt);
     74                {
     75                    m_pRamSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
     76                    m_pRamSlider->setOrientation(Qt::Horizontal);
     77                    m_pRamSlider->setTickPosition(QSlider::TicksBelow);
     78                    m_pRamSlider->setValue(m_pTypeSelector->type().GetRecommendedRAM());
     79                }
     80                m_pRamEditor = new QILineEdit(m_pMemoryCnt);
     81                {
     82                    m_pRamEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
     83                    m_pRamEditor->setFixedWidthByText("88888");
     84                    m_pRamEditor->setAlignment(Qt::AlignRight);
     85                    m_pRamEditor->setValidator(new QIntValidator(m_pRamSlider->minRAM(), m_pRamSlider->maxRAM(), this));
     86                    m_pRamEditor->setText(QString::number(m_pTypeSelector->type().GetRecommendedRAM()));
     87                }
     88                m_pRamUnits = new QLabel(m_pMemoryCnt);
     89                {
     90                    m_pRamUnits->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     91                }
     92                m_pRamMin = new QLabel(m_pMemoryCnt);
     93                {
     94                    m_pRamMin->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     95                }
     96                QSpacerItem *m_pRamSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding);
     97                m_pRamMax = new QLabel(m_pMemoryCnt);
     98                {
     99                    m_pRamMax->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     100                }
     101                pMemoryCntLayout->addWidget(m_pRamSlider, 0, 0, 1, 3);
     102                pMemoryCntLayout->addWidget(m_pRamEditor, 0, 3);
     103                pMemoryCntLayout->addWidget(m_pRamUnits, 0, 4);
     104                pMemoryCntLayout->addWidget(m_pRamMin, 1, 0);
     105                pMemoryCntLayout->addItem(m_pRamSpacer, 1, 1);
     106                pMemoryCntLayout->addWidget(m_pRamMax, 1, 2);
     107            }
     108        }
     109        m_pDiskCnt = new QGroupBox(this);
     110        {
     111            m_pDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
     112            m_pDiskCnt->setCheckable(true);
     113            m_pDiskCnt->setChecked(true);
     114            QGridLayout *pDiskCntLayout = new QGridLayout(m_pDiskCnt);
     115            {
     116                m_pDiskCreate = new QRadioButton(m_pDiskCnt);
     117                {
     118                    m_pDiskCreate->setChecked(true);
     119                }
     120                m_pDiskPresent = new QRadioButton(m_pDiskCnt);
     121                QStyleOptionButton options;
     122                options.initFrom(m_pDiskCreate);
     123                int iWidth = m_pDiskCreate->style()->subElementRect(QStyle::SE_RadioButtonIndicator, &options, m_pDiskCreate).width() +
     124                             m_pDiskCreate->style()->pixelMetric(QStyle::PM_RadioButtonLabelSpacing, &options, m_pDiskCreate) -
     125                             pDiskCntLayout->spacing() - 1;
     126                QSpacerItem *pSpacer = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
     127                m_pDiskSelector = new VBoxMediaComboBox(m_pDiskCnt);
     128                {
     129                    m_pDiskSelector->setType(VBoxDefs::MediumType_HardDisk);
     130                    m_pDiskSelector->repopulate();
     131                }
     132                m_pVMMButton = new QIToolButton(m_pDiskCnt);
     133                {
     134                    m_pVMMButton->setAutoRaise(true);
     135                    m_pVMMButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_dis_16px.png"));
     136                }
     137                pDiskCntLayout->addWidget(m_pDiskCreate, 0, 0, 1, 3);
     138                pDiskCntLayout->addWidget(m_pDiskPresent, 1, 0, 1, 3);
     139                pDiskCntLayout->addItem(pSpacer, 2, 0);
     140                pDiskCntLayout->addWidget(m_pDiskSelector, 2, 1);
     141                pDiskCntLayout->addWidget(m_pVMMButton, 2, 2);
     142            }
     143        }
     144        pMainLayout->addWidget(m_pNameCnt);
     145        pMainLayout->addWidget(m_pTypeCnt);
     146        pMainLayout->addWidget(m_pMemoryCnt);
     147        pMainLayout->addWidget(m_pDiskCnt);
     148        pMainLayout->addStretch();
     149        updateVirtualDiskSource();
     150    }
     151
     152    /* Setup connections: */
     153    connect(m_pNameEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltNameChanged(const QString &)));
     154    connect(m_pTypeSelector, SIGNAL(osTypeChanged()), this, SLOT(sltOsTypeChanged()));
     155    connect(m_pRamSlider, SIGNAL(valueChanged(int)), this, SLOT(sltRamSliderValueChanged(int)));
     156    connect(m_pRamEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltRamEditorTextChanged(const QString &)));
     157    connect(m_pDiskCnt, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
     158    connect(m_pDiskCreate, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
     159    connect(m_pDiskPresent, SIGNAL(toggled(bool)), this, SLOT(sltVirtualDiskSourceChanged()));
     160    connect(m_pDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(sltVirtualDiskSourceChanged()));
     161    connect(m_pVMMButton, SIGNAL(clicked()), this, SLOT(sltGetWithFileOpenDialog()));
     162
     163    /* Register classes: */
     164    qRegisterMetaType<CMedium>();
     165    /* Register fields: */
     166    registerField("name*", m_pNameEditor);
     167    registerField("type", m_pTypeSelector, "type", SIGNAL(osTypeChanged()));
     168    registerField("machineFolder", this, "machineFolder");
     169    registerField("machineBaseName", this, "machineBaseName");
     170    registerField("ram", m_pRamSlider, "value", SIGNAL(valueChanged(int)));
     171    registerField("virtualDisk", this, "virtualDisk");
     172    registerField("virtualDiskId", this, "virtualDiskId");
     173    registerField("virtualDiskLocation", this, "virtualDiskLocation");
     174}
     175
     176void UIWizardNewVMPageExpert::sltNameChanged(const QString &strNewText)
     177{
     178    /* Call to base-class: */
     179    onNameChanged(strNewText);
     180
     181    /* Fetch recommended RAM value: */
     182    CGuestOSType type = m_pTypeSelector->type();
     183    m_pRamSlider->setValue(type.GetRecommendedRAM());
     184    m_pRamEditor->setText(QString::number(type.GetRecommendedRAM()));
     185
     186    /* Broadcast complete-change: */
     187    emit completeChanged();
     188}
     189
     190void UIWizardNewVMPageExpert::sltOsTypeChanged()
     191{
     192    /* Call to base-class: */
     193    onOsTypeChanged();
     194
     195    /* Fetch recommended RAM value: */
     196    CGuestOSType type = m_pTypeSelector->type();
     197    m_pRamSlider->setValue(type.GetRecommendedRAM());
     198    m_pRamEditor->setText(QString::number(type.GetRecommendedRAM()));
     199
     200    /* Broadcast complete-change: */
     201    emit completeChanged();
     202}
     203
     204void UIWizardNewVMPageExpert::sltRamSliderValueChanged(int iValue)
     205{
     206    /* Call to base-class: */
     207    onRamSliderValueChanged(iValue);
     208
     209    /* Broadcast complete-change: */
     210    emit completeChanged();
     211}
     212
     213void UIWizardNewVMPageExpert::sltRamEditorTextChanged(const QString &strText)
     214{
     215    /* Call to base-class: */
     216    onRamEditorTextChanged(strText);
     217
     218    /* Broadcast complete-change: */
     219    emit completeChanged();
     220}
     221
     222void UIWizardNewVMPageExpert::sltVirtualDiskSourceChanged()
     223{
     224    /* Call to base-class: */
     225    updateVirtualDiskSource();
     226
     227    /* Broadcast complete-change: */
     228    emit completeChanged();
     229}
     230
     231void UIWizardNewVMPageExpert::sltGetWithFileOpenDialog()
     232{
     233    /* Call to base-class: */
     234    getWithFileOpenDialog();
     235}
     236
     237void UIWizardNewVMPageExpert::retranslateUi()
     238{
    52239    /* Translate widgets: */
    53     m_pLabel1->setText(tableTemplate().arg("<b>STOP!</b> Before continuing, please understand what you are doing. "
    54                                            "Computer system virtualization involves complex concepts, "
    55                                            "which no user interface can hide. Please make sure that you have read "
    56                                            "the first section of the user manual before continuing "
    57                                            "or seeking out online assistance!"));
    58     m_pLabel2->setText(UIWizardNewVM::tr("<p>This wizard will guide you through the steps that are necessary "
    59                                          "to create a new virtual machine for VirtualBox.</p><p>%1</p>").arg(standardHelpText()));
    60 }
    61 
    62 void UIWizardNewVMPageBasic1::initializePage()
     240    m_pNameCnt->setTitle(UIWizardNewVM::tr("&Name"));
     241    m_pTypeCnt->setTitle(UIWizardNewVM::tr("OS &Type"));
     242    m_pMemoryCnt->setTitle(UIWizardNewVM::tr("Base &Memory Size"));
     243    m_pRamUnits->setText(VBoxGlobal::tr("MB", "size suffix MBytes=1024 KBytes"));
     244    m_pRamMin->setText(QString("%1 %2").arg(m_pRamSlider->minRAM()).arg(VBoxGlobal::tr("MB", "size suffix MBytes=1024 KBytes")));
     245    m_pRamMax->setText(QString("%1 %2").arg(m_pRamSlider->maxRAM()).arg(VBoxGlobal::tr("MB", "size suffix MBytes=1024 KBytes")));
     246    m_pDiskCnt->setTitle(UIWizardNewVM::tr("Start-up &Disk"));
     247    m_pDiskCreate->setText(UIWizardNewVM::tr("&Create new hard disk"));
     248    m_pDiskPresent->setText(UIWizardNewVM::tr("&Use existing hard disk"));
     249    m_pVMMButton->setToolTip(UIWizardNewVM::tr("Choose a virtual hard disk file..."));
     250}
     251
     252void UIWizardNewVMPageExpert::initializePage()
    63253{
    64254    /* Translate page: */
    65255    retranslateUi();
    66 }
    67 
    68 /* static */
    69 QString UIWizardNewVMPageBasic1::tableTemplate()
    70 {
    71     /* Prepare table template: */
    72     QString strTable("<table cellspacing=0 cellpadding=0>%1</table>");
    73     QString strTableRow("<tr>%1</tr>");
    74     QString strTableData("<td>%1</td>");
    75     QString strTableDataCentered("<td valign=middle>%1</td>");
    76     QString strImage("<img src=\"image\"/>");
    77     QString strSpacing("&nbsp;&nbsp;&nbsp;");
    78     QString strTableDataImage(strTableDataCentered.arg(strImage));
    79     QString strTableDataSpacing(strTableData.arg(strSpacing));
    80     return strTable.arg(strTableRow.arg(strTableDataImage + strTableDataSpacing + strTableData));
    81 }
    82 
     256
     257    /* 'Name' field should have focus initially: */
     258    m_pNameEditor->setFocus();
     259}
     260
     261void UIWizardNewVMPageExpert::cleanupPage()
     262{
     263    /* Call to base-class: */
     264    ensureNewVirtualDiskDeleted();
     265    cleanupMachineFolder();
     266}
     267
     268bool UIWizardNewVMPageExpert::isComplete() const
     269{
     270    /* Make sure mandatory fields are complete,
     271     * 'ram' field feats the bounds,
     272     * 'virtualDisk' field feats the rules: */
     273    return UIWizardPage::isComplete() &&
     274           (m_pRamSlider->value() >= qMax(1, (int)m_pRamSlider->minRAM()) && m_pRamSlider->value() <= (int)m_pRamSlider->maxRAM()) &&
     275           (!m_pDiskCnt->isChecked() || !m_pDiskPresent->isChecked() || !vboxGlobal().findMedium(m_pDiskSelector->id()).isNull());
     276}
     277
     278bool UIWizardNewVMPageExpert::validatePage()
     279{
     280    /* Initial result: */
     281    bool fResult = true;
     282
     283    /* Lock finish button: */
     284    startProcessing();
     285
     286    /* Try to create machine folder: */
     287    if (fResult)
     288        fResult = createMachineFolder();
     289
     290    /* Try to assign boot virtual-disk: */
     291    if (fResult)
     292    {
     293        /* Ensure there is no virtual-disk created yet: */
     294        Assert(m_virtualDisk.isNull());
     295        if (fResult)
     296        {
     297            if (!m_pDiskCnt->isChecked())
     298            {
     299                /* Ask user about disk-less machine: */
     300                fResult = msgCenter().confirmHardDisklessMachine(this);
     301            }
     302            else if (m_pDiskCreate->isChecked())
     303            {
     304                /* Show the New Virtual Disk wizard if necessary: */
     305                fResult = getWithNewVirtualDiskWizard();
     306            }
     307        }
     308    }
     309
     310    /* Try to create VM: */
     311    if (fResult)
     312        fResult = qobject_cast<UIWizardNewVM*>(wizard())->createVM();
     313
     314    /* Unlock finish button: */
     315    endProcessing();
     316
     317    /* Return result: */
     318    return fResult;
     319}
     320
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h

    r40929 r41021  
    22 *
    33 * VBox frontends: Qt4 GUI ("VirtualBox"):
    4  * UIWizardNewVMPageBasic1 class declaration
     4 * UIWizardNewVMPageExpert class declaration
    55 */
    66
     
    1717 */
    1818
    19 #ifndef __UIWizardNewVMPageBasic1_h__
    20 #define __UIWizardNewVMPageBasic1_h__
     19#ifndef __UIWizardNewVMPageExpert_h__
     20#define __UIWizardNewVMPageExpert_h__
    2121
    2222/* Local includes: */
    23 #include "UIWizardPage.h"
    24 #include "COMDefs.h"
    25 #include "QIWithRetranslateUI.h"
     23#include "UIWizardNewVMPageBasic1.h"
     24#include "UIWizardNewVMPageBasic2.h"
     25#include "UIWizardNewVMPageBasic3.h"
     26#include "UIWizardNewVMPageBasic4.h"
     27#include "UIWizardNewVMPageBasic5.h"
    2628
    27 /* Forward declarations: */
    28 class QIRichTextLabel;
    29 
    30 /* 1st page of the New Virtual Machine wizard: */
    31 class UIWizardNewVMPageBasic1 : public UIWizardPage
     29/* Expert page of the New Virtual Machine wizard: */
     30class UIWizardNewVMPageExpert : public UIWizardPage,
     31                                public UIWizardNewVMPage1,
     32                                public UIWizardNewVMPage2,
     33                                public UIWizardNewVMPage3,
     34                                public UIWizardNewVMPage4,
     35                                public UIWizardNewVMPage5
    3236{
    3337    Q_OBJECT;
     38    Q_PROPERTY(QString machineFolder READ machineFolder WRITE setMachineFolder);
     39    Q_PROPERTY(QString machineBaseName READ machineBaseName WRITE setMachineBaseName);
     40    Q_PROPERTY(CMedium virtualDisk READ virtualDisk WRITE setVirtualDisk);
     41    Q_PROPERTY(QString virtualDiskId READ virtualDiskId WRITE setVirtualDiskId);
     42    Q_PROPERTY(QString virtualDiskLocation READ virtualDiskLocation WRITE setVirtualDiskLocation);
    3443
    3544public:
    3645
    3746    /* Constructor: */
    38     UIWizardNewVMPageBasic1();
     47    UIWizardNewVMPageExpert();
     48
     49protected:
     50
     51    /* Wrapper to access 'this' from base part: */
     52    UIWizardPage* thisImp() { return this; }
     53    /* Wrapper to access 'wizard-field' from base part: */
     54    QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
     55
     56private slots:
     57
     58    /* Handlers: */
     59    void sltNameChanged(const QString &strNewText);
     60    void sltOsTypeChanged();
     61    void sltRamSliderValueChanged(int iValue);
     62    void sltRamEditorTextChanged(const QString &strText);
     63    void sltVirtualDiskSourceChanged();
     64    void sltGetWithFileOpenDialog();
    3965
    4066private:
     
    4571    /* Prepare stuff: */
    4672    void initializePage();
     73    void cleanupPage();
    4774
    48     /* Helpers: */
    49     static QString tableTemplate();
    50 
    51     /* Widgets: */
    52     QIRichTextLabel *m_pLabel1;
    53     QIRichTextLabel *m_pLabel2;
     75    /* Validation stuff: */
     76    bool isComplete() const;
     77    bool validatePage();
    5478};
    5579
    56 #endif // __UIWizardNewVMPageBasic1_h__
     80#endif // __UIWizardNewVMPageExpert_h__
    5781
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