VirtualBox

Changeset 90755 in vbox for trunk


Ignore:
Timestamp:
Aug 19, 2021 4:33:03 PM (3 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. Refactoring medium format and medium variant pages of the clone vd wizard.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/wizards
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVD.cpp

    r90748 r90755  
    3535    , m_comSourceVirtualDisk(comSourceVirtualDisk)
    3636    , m_enmSourceVirtualDiskDeviceType(m_comSourceVirtualDisk.GetDeviceType())
     37    , m_iMediumVariantPageIndex(-1)
    3738{
    3839#ifndef VBOX_WS_MAC
     
    104105        {
    105106            addPage(new UIWizardCloneVDPageBasic1(m_enmSourceVirtualDiskDeviceType));
    106             addPage(new UIWizardCloneVDPageBasic2(m_enmSourceVirtualDiskDeviceType));
     107            m_iMediumVariantPageIndex = addPage(new UIWizardCloneVDPageBasic2(m_enmSourceVirtualDiskDeviceType));
    107108            addPage(new UIWizardCloneVDPageBasic3);
    108109            break;
     
    120121    }
    121122}
     123
     124const CMediumFormat &UIWizardCloneVD::mediumFormat() const
     125{
     126    return m_comMediumFormat;
     127}
     128
     129void UIWizardCloneVD::setMediumFormat(const CMediumFormat &comMediumFormat)
     130{
     131    m_comMediumFormat = comMediumFormat;
     132    if (mode() == WizardMode_Basic)
     133        setMediumVariantPageVisibility();
     134}
     135
     136qulonglong UIWizardCloneVD::mediumVariant() const
     137{
     138    return m_uMediumVariant;
     139}
     140
     141void UIWizardCloneVD::setMediumVariant(qulonglong uMediumVariant)
     142{
     143    m_uMediumVariant = uMediumVariant;
     144}
     145
     146void UIWizardCloneVD::setMediumVariantPageVisibility()
     147{
     148    AssertReturnVoid(!m_comMediumFormat.isNull());
     149    ULONG uCapabilities = 0;
     150    QVector<KMediumFormatCapabilities> capabilities;
     151    capabilities = m_comMediumFormat.GetCapabilities();
     152    for (int i = 0; i < capabilities.size(); i++)
     153        uCapabilities |= capabilities[i];
     154
     155    int cTest = 0;
     156    if (uCapabilities & KMediumFormatCapabilities_CreateDynamic)
     157        ++cTest;
     158    if (uCapabilities & KMediumFormatCapabilities_CreateFixed)
     159        ++cTest;
     160    if (uCapabilities & KMediumFormatCapabilities_CreateSplit2G)
     161        ++cTest;
     162    setPageVisible(m_iMediumVariantPageIndex, cTest > 1);
     163}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVD.h

    r90748 r90755  
    2828#include "COMEnums.h"
    2929#include "CMedium.h"
     30#include "CMediumFormat.h"
    3031
    3132
     
    4950    bool copyVirtualDisk();
    5051
     52    const CMediumFormat &mediumFormat() const;
     53    void setMediumFormat(const CMediumFormat &comMediumFormat);
     54
     55    qulonglong mediumVariant() const;
     56    void setMediumVariant(qulonglong uMediumVariant);
     57
    5158protected:
    5259
     
    5764    /** Handles translation event. */
    5865    virtual void retranslateUi() /* override */;
     66    void setMediumVariantPageVisibility();
    5967
     68    CMediumFormat m_comMediumFormat;
     69    qulonglong m_uMediumVariant;
    6070    /** Holds the source virtual disk wrapper. */
    6171    CMedium m_comSourceVirtualDisk;
     
    6373    /** Holds the source virtual-disk device type. */
    6474    KDeviceType m_enmSourceVirtualDiskDeviceType;
     75    int m_iMediumVariantPageIndex;
    6576};
    6677
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic1.cpp

    r90748 r90755  
    160160    {
    161161        pMainLayout->addWidget(m_pFormatGroupBox);
    162         // connect(m_pFormatButtonGroup, &UIDiskFormatsGroupBox::sigMediumFormatChanged,
    163         //         this, &UIWizardCloneVDPageBasic1::sltMediumFormatChanged);
     162        connect(m_pFormatGroupBox, &UIDiskFormatsGroupBox::sigMediumFormatChanged,
     163                this, &UIWizardCloneVDPageBasic1::sltMediumFormatChanged);
    164164    }
    165165    pMainLayout->addStretch();
     
    189189    /* Translate page: */
    190190    retranslateUi();
     191    if (!m_userModifiedParameters.contains("MediumFormat"))
     192    {
     193        if (cloneWizard() && m_pFormatGroupBox)
     194            cloneWizard()->setMediumFormat(m_pFormatGroupBox->mediumFormat());
     195    }
    191196}
    192197
     
    196201    //return !mediumFormat().isNull();
    197202    return true;
     203}
     204
     205void UIWizardCloneVDPageBasic1::sltMediumFormatChanged()
     206{
     207    if (cloneWizard() && m_pFormatGroupBox)
     208        cloneWizard()->setMediumFormat(m_pFormatGroupBox->mediumFormat());
     209    m_userModifiedParameters << "MediumFormat";
     210    emit completeChanged();
    198211}
    199212
     
    227240//     return UIWizardCloneVD::Page3;
    228241// }
     242
     243UIWizardCloneVD *UIWizardCloneVDPageBasic1::cloneWizard() const
     244{
     245    return qobject_cast<UIWizardCloneVD*>(wizard());
     246}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic1.h

    r90748 r90755  
    2222#endif
    2323
     24/* Qt includes: */
     25#include <QSet>
     26
    2427/* GUI includes: */
    2528#include "UINativeWizardPage.h"
     
    3235class QIRichTextLabel;
    3336class UIDiskFormatsGroupBox;
    34 
     37class UIWizardCloneVD;
    3538
    3639// /** 1st page of the Clone Virtual Disk Image wizard (base part): */
     
    7982    UIWizardCloneVDPageBasic1(KDeviceType enmDeviceType);
    8083
     84private slots:
     85
     86    void sltMediumFormatChanged();
     87
    8188private:
     89
     90    UIWizardCloneVD *cloneWizard() const;
    8291
    8392    /** Handles translation event. */
     
    94103    QIRichTextLabel *m_pLabel;
    95104    UIDiskFormatsGroupBox *m_pFormatGroupBox;
     105
     106    QSet<QString> m_userModifiedParameters;
    96107};
    97108
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.cpp

    r90748 r90755  
    2323
    2424/* GUI includes: */
     25#include "UIWizardDiskEditors.h"
    2526#include "UIWizardCloneVDPageBasic2.h"
    2627#include "UIWizardCloneVD.h"
     
    7374
    7475UIWizardCloneVDPageBasic2::UIWizardCloneVDPageBasic2(KDeviceType /*enmDeviceType*/)
     76    : m_pDescriptionLabel(0)
     77    , m_pDynamicLabel(0)
     78    , m_pFixedLabel(0)
     79    , m_pSplitLabel(0)
     80    , m_pVariantGroupBox(0)
    7581{
    7682    prepare();
     
    7884    // QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    7985    // {
    80     //     m_pDescriptionLabel = new QIRichTextLabel(this);
    81     //     m_pDynamicLabel = new QIRichTextLabel(this);
    82     //     m_pFixedLabel = new QIRichTextLabel(this);
    83     //     m_pSplitLabel = new QIRichTextLabel(this);
    8486    //     QVBoxLayout *pVariantLayout = new QVBoxLayout;
    8587    //     {
     
    125127{
    126128    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    127     Q_UNUSED(pMainLayout);
     129    m_pDescriptionLabel = new QIRichTextLabel(this);
     130    if (m_pDescriptionLabel)
     131        pMainLayout->addWidget(m_pDescriptionLabel);
     132    m_pDynamicLabel = new QIRichTextLabel(this);
     133    if (m_pDynamicLabel)
     134        pMainLayout->addWidget(m_pDynamicLabel);
     135    m_pFixedLabel = new QIRichTextLabel(this);
     136    if (m_pFixedLabel)
     137        pMainLayout->addWidget(m_pFixedLabel);
     138    m_pSplitLabel = new QIRichTextLabel(this);
     139    if (m_pSplitLabel)
     140        pMainLayout->addWidget(m_pSplitLabel);
     141    m_pVariantGroupBox = new UIDiskVariantGroupBox(false /* expert mode */, 0);
     142    if (m_pVariantGroupBox)
     143        pMainLayout->addWidget(m_pVariantGroupBox);
     144    retranslateUi();
    128145}
    129146
     
    134151    setTitle(UIWizardCloneVD::tr("Storage on physical hard disk"));
    135152
    136 //     /* Translate widgets: */
    137 //     m_pDescriptionLabel->setText(UIWizardCloneVD::tr("Please choose whether the new virtual disk image file should grow as it is used "
    138 //                                                      "(dynamically allocated) or if it should be created at its maximum size (fixed size)."));
    139 //     m_pDynamicLabel->setText(UIWizardCloneVD::tr("<p>A <b>dynamically allocated</b> disk image file will only use space "
    140 //                                                  "on your physical hard disk as it fills up (up to a maximum <b>fixed size</b>), "
    141 //                                                  "although it will not shrink again automatically when space on it is freed.</p>"));
    142 //     m_pFixedLabel->setText(UIWizardCloneVD::tr("<p>A <b>fixed size</b> disk image file may take longer to create on some "
    143 //                                                "systems but is often faster to use.</p>"));
    144 //     m_pSplitLabel->setText(UIWizardCloneVD::tr("<p>You can also choose to <b>split</b> the disk image file into several files "
    145 //                                                "of up to two gigabytes each. This is mainly useful if you wish to store the "
    146 //                                                "virtual machine on removable USB devices or old systems, some of which cannot "
    147 //                                                "handle very large files."));
    148 //     m_pDynamicalButton->setText(UIWizardCloneVD::tr("&Dynamically allocated"));
    149 //     m_pFixedButton->setText(UIWizardCloneVD::tr("&Fixed size"));
    150 //     m_pSplitBox->setText(UIWizardCloneVD::tr("&Split into files of less than 2GB"));
     153    /* Translate widgets: */
     154    m_pDescriptionLabel->setText(UIWizardCloneVD::tr("Please choose whether the new virtual disk image file should grow as it is used "
     155                                                     "(dynamically allocated) or if it should be created at its maximum size (fixed size)."));
     156    m_pDynamicLabel->setText(UIWizardCloneVD::tr("<p>A <b>dynamically allocated</b> disk image file will only use space "
     157                                                 "on your physical hard disk as it fills up (up to a maximum <b>fixed size</b>), "
     158                                                 "although it will not shrink again automatically when space on it is freed.</p>"));
     159    m_pFixedLabel->setText(UIWizardCloneVD::tr("<p>A <b>fixed size</b> disk image file may take longer to create on some "
     160                                               "systems but is often faster to use.</p>"));
     161    m_pSplitLabel->setText(UIWizardCloneVD::tr("<p>You can also choose to <b>split</b> the disk image file into several files "
     162                                               "of up to two gigabytes each. This is mainly useful if you wish to store the "
     163                                               "virtual machine on removable USB devices or old systems, some of which cannot "
     164                                               "handle very large files."));
    151165}
    152166
    153167void UIWizardCloneVDPageBasic2::initializePage()
    154168{
     169    AssertReturnVoid(cloneWizard());
    155170    /* Translate page: */
    156171    retranslateUi();
    157172
     173    setWidgetVisibility(cloneWizard()->mediumFormat());
     174    if (m_pVariantGroupBox)
     175        cloneWizard()->setMediumVariant(m_pVariantGroupBox->mediumVariant());
    158176    // /* Setup visibility: */
    159177    // CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
     
    181199    // return mediumVariant() != (qulonglong)KMediumVariant_Max;
    182200}
     201
     202UIWizardCloneVD *UIWizardCloneVDPageBasic2::cloneWizard() const
     203{
     204    return qobject_cast<UIWizardCloneVD*>(wizard());
     205}
     206
     207void UIWizardCloneVDPageBasic2::setWidgetVisibility(const CMediumFormat &mediumFormat)
     208{
     209    AssertReturnVoid(m_pVariantGroupBox);
     210
     211    m_pVariantGroupBox->updateMediumVariantWidgetsAfterFormatChange(mediumFormat, true /* hide disabled widgets*/);
     212
     213    if (m_pDynamicLabel)
     214        m_pDynamicLabel->setHidden(!m_pVariantGroupBox->isCreateDynamicPossible());
     215    if (m_pFixedLabel)
     216        m_pFixedLabel->setHidden(!m_pVariantGroupBox->isCreateFixedPossible());
     217    if (m_pSplitLabel)
     218        m_pSplitLabel->setHidden(!m_pVariantGroupBox->isCreateSplitPossible());
     219}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevd/UIWizardCloneVDPageBasic2.h

    r90748 r90755  
    3333class QCheckBox;
    3434class QIRichTextLabel;
    35 
     35class UIWizardCloneVD;
     36class CMediumFormat;
     37class UIDiskVariantGroupBox;
    3638
    3739// /** 3rd page of the Clone Virtual Disk Image wizard (base part): */
     
    7375    virtual void retranslateUi() /* override */;
    7476    void prepare();
     77    UIWizardCloneVD *cloneWizard() const;
    7578
    7679    /** Prepares the page. */
     
    7982    /** Returns whether the page is complete. */
    8083    virtual bool isComplete() const /* override */;
     84    void setWidgetVisibility(const CMediumFormat &mediumFormat);
    8185
    8286    /** Holds the description label instance. */
     
    8892    /** Holds the 'Split to 2GB files' description label instance. */
    8993    QIRichTextLabel *m_pSplitLabel;
     94
     95    UIDiskVariantGroupBox *m_pVariantGroupBox;
    9096};
    9197
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.cpp

    r90748 r90755  
    410410        m_pSplitBox->setHidden(!m_pSplitBox->isEnabled());
    411411    }
     412    /* Deselect split box if it is disabled: */
     413    if (!m_pSplitBox->isEnabled())
     414        m_pSplitBox->setChecked(false);
    412415    emit sigMediumVariantChanged(mediumVariant());
    413416}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardDiskEditors.h

    r90748 r90755  
    5050#include "CMediumFormat.h"
    5151
     52/** Base class for disk related group boxes. */
    5253class SHARED_LIBRARY_STUFF UIDiskEditorGroupBox : public QIWithRetranslateUI<QGroupBox>
    5354{
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