VirtualBox

Changeset 87890 in vbox


Ignore:
Timestamp:
Feb 26, 2021 3:18:33 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9950. Adding medium variant widgets to the page

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.cpp

    r87878 r87890  
    3535    , m_pFixedButton(0)
    3636    , m_pSplitBox(0)
    37 {
     37    , m_pDescriptionLabel(0)
     38    , m_pDynamicLabel(0)
     39    , m_pFixedLabel(0)
     40    , m_pSplitLabel(0)
     41{
     42}
     43
     44QWidget *UIWizardNewVDPage2::createMediumVariantWidgets(bool fWithLabels)
     45{
     46    QWidget *pContainerWidget = new QWidget;
     47    QVBoxLayout *pMainLayout = new QVBoxLayout(pContainerWidget);
     48    if (pMainLayout)
     49    {
     50        if (fWithLabels)
     51        {
     52            m_pDescriptionLabel = new QIRichTextLabel;
     53            m_pDynamicLabel = new QIRichTextLabel;
     54            m_pFixedLabel = new QIRichTextLabel;
     55            m_pSplitLabel = new QIRichTextLabel;
     56        }
     57        QVBoxLayout *pVariantLayout = new QVBoxLayout;
     58        if (pVariantLayout)
     59        {
     60            m_pVariantButtonGroup = new QButtonGroup;
     61            {
     62                m_pDynamicalButton = new QRadioButton;
     63                {
     64                    m_pDynamicalButton->click();
     65                    m_pDynamicalButton->setFocus();
     66                }
     67                m_pFixedButton = new QRadioButton;
     68                m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
     69                m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
     70            }
     71            m_pSplitBox = new QCheckBox;
     72            pVariantLayout->addWidget(m_pDynamicalButton);
     73            pVariantLayout->addWidget(m_pFixedButton);
     74            pVariantLayout->addWidget(m_pSplitBox);
     75        }
     76        if (fWithLabels)
     77        {
     78            pMainLayout->addWidget(m_pDescriptionLabel);
     79            pMainLayout->addWidget(m_pDynamicLabel);
     80            pMainLayout->addWidget(m_pFixedLabel);
     81            pMainLayout->addWidget(m_pSplitLabel);
     82        }
     83        pMainLayout->addLayout(pVariantLayout);
     84        pMainLayout->addStretch();
     85    }
     86    return pContainerWidget;
    3887}
    3988
     
    77126void UIWizardNewVDPage2::retranslateWidgets()
    78127{
    79     m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated"));
    80     m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size"));
    81     m_pSplitBox->setText(UIWizardNewVD::tr("&Split into files of less than 2GB"));
     128    if (m_pDynamicalButton)
     129        m_pDynamicalButton->setText(UIWizardNewVD::tr("&Dynamically allocated"));
     130    if (m_pFixedButton)
     131        m_pFixedButton->setText(UIWizardNewVD::tr("&Fixed size"));
     132    if (m_pSplitBox)
     133        m_pSplitBox->setText(UIWizardNewVD::tr("&Split into files of less than 2GB"));
     134
     135
     136    /* Translate rich text labels: */
     137    if (m_pDescriptionLabel)
     138        m_pDescriptionLabel->setText(UIWizardNewVD::tr("Please choose whether the new virtual hard disk file should grow as it is used "
     139                                                       "(dynamically allocated) or if it should be created at its maximum size (fixed size)."));
     140    if (m_pDynamicLabel)
     141        m_pDynamicLabel->setText(UIWizardNewVD::tr("<p>A <b>dynamically allocated</b> hard disk file will only use space "
     142                                                   "on your physical hard disk as it fills up (up to a maximum <b>fixed size</b>), "
     143                                                   "although it will not shrink again automatically when space on it is freed.</p>"));
     144    if (m_pFixedLabel)
     145        m_pFixedLabel->setText(UIWizardNewVD::tr("<p>A <b>fixed size</b> hard disk file may take longer to create on some "
     146                                                 "systems but is often faster to use.</p>"));
     147    if (m_pSplitLabel)
     148        m_pSplitLabel->setText(UIWizardNewVD::tr("<p>You can also choose to <b>split</b> the hard disk file into several files "
     149                                                 "of up to two gigabytes each. This is mainly useful if you wish to store the "
     150                                                 "virtual machine on removable USB devices or old systems, some of which cannot "
     151                                                 "handle very large files."));
     152}
     153
     154void UIWizardNewVDPage2::setWidgetVisibility(CMediumFormat &mediumFormat)
     155{
     156    ULONG uCapabilities = 0;
     157    QVector<KMediumFormatCapabilities> capabilities;
     158    capabilities = mediumFormat.GetCapabilities();
     159    for (int i = 0; i < capabilities.size(); i++)
     160        uCapabilities |= capabilities[i];
     161
     162    bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic;
     163    bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed;
     164    bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G;
     165    if (m_pDynamicLabel)
     166        m_pDynamicLabel->setHidden(!fIsCreateDynamicPossible);
     167    if (m_pDynamicalButton)
     168        m_pDynamicalButton->setHidden(!fIsCreateDynamicPossible);
     169    if (m_pFixedLabel)
     170        m_pFixedLabel->setHidden(!fIsCreateFixedPossible);
     171    if (m_pFixedButton)
     172        m_pFixedButton->setHidden(!fIsCreateFixedPossible);
     173    if (m_pSplitLabel)
     174        m_pSplitLabel->setHidden(!fIsCreateSplitPossible);
     175    if (m_pSplitBox)
     176        m_pSplitBox->setHidden(!fIsCreateSplitPossible);
    82177}
    83178
     
    86181    /* Create widgets: */
    87182    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    88     {
    89         m_pDescriptionLabel = new QIRichTextLabel(this);
    90         m_pDynamicLabel = new QIRichTextLabel(this);
    91         m_pFixedLabel = new QIRichTextLabel(this);
    92         m_pSplitLabel = new QIRichTextLabel(this);
    93         QVBoxLayout *pVariantLayout = new QVBoxLayout;
    94         {
    95             m_pVariantButtonGroup = new QButtonGroup(this);
    96             {
    97                 m_pDynamicalButton = new QRadioButton(this);
    98                 {
    99                     m_pDynamicalButton->click();
    100                     m_pDynamicalButton->setFocus();
    101                 }
    102                 m_pFixedButton = new QRadioButton(this);
    103                 m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
    104                 m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
    105             }
    106             m_pSplitBox = new QCheckBox(this);
    107             pVariantLayout->addWidget(m_pDynamicalButton);
    108             pVariantLayout->addWidget(m_pFixedButton);
    109             pVariantLayout->addWidget(m_pSplitBox);
    110         }
    111         pMainLayout->addWidget(m_pDescriptionLabel);
    112         pMainLayout->addWidget(m_pDynamicLabel);
    113         pMainLayout->addWidget(m_pFixedLabel);
    114         pMainLayout->addWidget(m_pSplitLabel);
    115         pMainLayout->addLayout(pVariantLayout);
    116         pMainLayout->addStretch();
    117     }
     183    pMainLayout->addWidget(createMediumVariantWidgets(true));
     184    pMainLayout->addStretch();
    118185
    119186    /* Setup connections: */
     
    132199    /* Translate page: */
    133200    setTitle(UIWizardNewVD::tr("Storage on physical hard disk"));
    134 
    135     /* Translate widgets: */
    136     m_pDescriptionLabel->setText(UIWizardNewVD::tr("Please choose whether the new virtual hard disk file should grow as it is used "
    137                                                    "(dynamically allocated) or if it should be created at its maximum size (fixed size)."));
    138     m_pDynamicLabel->setText(UIWizardNewVD::tr("<p>A <b>dynamically allocated</b> hard disk file will only use space "
    139                                                "on your physical hard disk as it fills up (up to a maximum <b>fixed size</b>), "
    140                                                "although it will not shrink again automatically when space on it is freed.</p>"));
    141     m_pFixedLabel->setText(UIWizardNewVD::tr("<p>A <b>fixed size</b> hard disk file may take longer to create on some "
    142                                              "systems but is often faster to use.</p>"));
    143     m_pSplitLabel->setText(UIWizardNewVD::tr("<p>You can also choose to <b>split</b> the hard disk file into several files "
    144                                              "of up to two gigabytes each. This is mainly useful if you wish to store the "
    145                                              "virtual machine on removable USB devices or old systems, some of which cannot "
    146                                              "handle very large files."));
    147201}
    148202
     
    151205    /* Translate page: */
    152206    retranslateUi();
    153 
    154     /* Setup visibility: */
    155207    CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
    156     ULONG uCapabilities = 0;
    157     QVector<KMediumFormatCapabilities> capabilities;
    158     capabilities = mediumFormat.GetCapabilities();
    159     for (int i = 0; i < capabilities.size(); i++)
    160         uCapabilities |= capabilities[i];
    161 
    162     bool fIsCreateDynamicPossible = uCapabilities & KMediumFormatCapabilities_CreateDynamic;
    163     bool fIsCreateFixedPossible = uCapabilities & KMediumFormatCapabilities_CreateFixed;
    164     bool fIsCreateSplitPossible = uCapabilities & KMediumFormatCapabilities_CreateSplit2G;
    165     m_pDynamicLabel->setHidden(!fIsCreateDynamicPossible);
    166     m_pDynamicalButton->setHidden(!fIsCreateDynamicPossible);
    167     m_pFixedLabel->setHidden(!fIsCreateFixedPossible);
    168     m_pFixedButton->setHidden(!fIsCreateFixedPossible);
    169     m_pSplitLabel->setHidden(!fIsCreateSplitPossible);
    170     m_pSplitBox->setHidden(!fIsCreateSplitPossible);
     208    setWidgetVisibility(mediumFormat);
    171209}
    172210
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageBasic2.h

    r87889 r87890  
    2626
    2727/* Forward declarations: */
     28class CMediumFormat;
    2829class QButtonGroup;
    2930class QRadioButton;
     
    3738protected:
    3839
    39     /* Constructor: */
     40    /** Constructor: */
    4041    UIWizardNewVDPage2();
    4142
    42     /* Stuff for 'variant' field: */
     43    QWidget *createMediumVariantWidgets(bool fWithLabels);
    4344    qulonglong mediumVariant() const;
    4445    void setMediumVariant(qulonglong uMediumVariant);
    4546    void retranslateWidgets();
     47    /** Check Medium format capability and decide if certain widgets can be shown. */
     48    void setWidgetVisibility(CMediumFormat &mediumFormat);
     49    /** @name Widgets
     50     * @{ */
     51        QButtonGroup *m_pVariantButtonGroup;
     52        QRadioButton *m_pDynamicalButton;
     53        QRadioButton *m_pFixedButton;
     54        QCheckBox *m_pSplitBox;
     55    /** @} */
    4656
    47     /* Widgets: */
    48     QButtonGroup *m_pVariantButtonGroup;
    49     QRadioButton *m_pDynamicalButton;
    50     QRadioButton *m_pFixedButton;
    51     QCheckBox *m_pSplitBox;
     57    /** @name Rich text labels. Declared/defined here since the are shared in more than one child class
     58     * @{ */
     59        QIRichTextLabel *m_pDescriptionLabel;
     60        QIRichTextLabel *m_pDynamicLabel;
     61        QIRichTextLabel *m_pFixedLabel;
     62        QIRichTextLabel *m_pSplitLabel;
     63    /** @} */
    5264};
    5365
     
    7486    /* Validation stuff: */
    7587    bool isComplete() const;
    76 
    77     /* Widgets: */
    78     QIRichTextLabel *m_pDescriptionLabel;
    79     QIRichTextLabel *m_pDynamicLabel;
    80     QIRichTextLabel *m_pFixedLabel;
    81     QIRichTextLabel *m_pSplitLabel;
    8288};
    8389
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.cpp

    r87889 r87890  
    3535
    3636UIWizardNewVMPageBasic5::UIWizardNewVMPageBasic5()
    37     : m_pLabel(0)
    3837{
    3938    prepare();
     
    6059
    6160    m_strDefaultExtension =  defaultExtension(m_mediumFormat);
     61
     62    /* Since the medium format is static we can decide widget visibility here: */
     63    setWidgetVisibility(m_mediumFormat);
    6264}
    6365
     
    6971void UIWizardNewVMPageBasic5::prepare()
    7072{
     73
     74
    7175    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     76    pMainLayout->addWidget(createMediumVariantWidgets(true));
     77    pMainLayout->addStretch();
    7278
    73     m_pLabel = new QIRichTextLabel(this);
    74     pMainLayout->addWidget(m_pLabel);
     79    // connect(m_pVariantButtonGroup,static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
     80    //         this, &UIWizardNewVDPageBasic2::completeChanged);
     81    // connect(m_pSplitBox, &QCheckBox::stateChanged,
     82    //         this, &UIWizardNewVDPageBasic2::completeChanged);
    7583
    76     pMainLayout->addStretch();
    77     createConnections();
     84    // QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     85
     86
     87    // m_pLabel = new QIRichTextLabel(this);
     88    // pMainLayout->addWidget(m_pLabel);
     89
     90    // pMainLayout->addStretch();
     91    // createConnections();
    7892}
    7993
     
    8498void UIWizardNewVMPageBasic5::retranslateUi()
    8599{
    86     setTitle(UIWizardNewVM::tr("Hardware"));
     100    setTitle(UIWizardNewVM::tr("Storage on physical hard disk"));
     101    UIWizardNewVDPage2::retranslateWidgets();
    87102
    88     if (m_pLabel)
    89         m_pLabel->setText(UIWizardNewVM::tr("<p>You can modify virtual machine's hardware by changing amount of RAM and "
    90                                             "virtual CPU count.</p>"));
    91103
    92104    //retranslateWidgets();
     
    100112    m_strDefaultPath = fieldImp("machineFolder").toString();
    101113    // fieldImp("type").value<CGuestOSType>().GetRecommendedHDD()
     114
    102115    retranslateUi();
    103116}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic5.h

    r87889 r87890  
    8585
    8686
    87     /** Widgets. */
    88     QIRichTextLabel *m_pLabel;
    8987    /** For guided new vm wizard VDI is the only format. Thus we have no UI item for it. */
    9088    CMediumFormat m_mediumFormat;
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