VirtualBox

Changeset 90599 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 10, 2021 1:18:31 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. More work on the first page of the clone vm wizard.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.cpp

    r90589 r90599  
    199199void UIWizardCloneVMPageBasic1::retranslateUi()
    200200{
    201     // /* Translate page: */
    202201    setTitle(UIWizardCloneVM::tr("New machine name and path"));
    203202
     
    206205                                                  "The new machine will be a clone of the machine <b>%1</b>.</p>")
    207206                              .arg(m_strOriginalName));
     207
     208    int iMaxWidth = 0;
     209    if (m_pNamePathEditor)
     210        iMaxWidth = qMax(iMaxWidth, m_pNamePathEditor->firstColumnWidth());
     211    if (m_pAdditionalOptionsEditor)
     212        iMaxWidth = qMax(iMaxWidth, m_pAdditionalOptionsEditor->firstColumnWidth());
     213
     214    if (m_pNamePathEditor)
     215        m_pNamePathEditor->setFirstColumnWidth(iMaxWidth);
     216    if (m_pAdditionalOptionsEditor)
     217        m_pAdditionalOptionsEditor->setFirstColumnWidth(iMaxWidth);
    208218}
    209219
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/clonevm/UIWizardCloneVMPageBasic1.h

    r90589 r90599  
    7979//     QLabel      *m_pMACComboBoxLabel;
    8080//     QComboBox   *m_pMACComboBox;
    81 //     QCheckBox   *m_pKeepDiskNamesCheckBox;
    82 //     QCheckBox   *m_pKeepHWUUIDsCheckBox;
    8381// };
    8482
     
    115113    QIRichTextLabel *m_pMainLabel;
    116114    // QGridLayout     *m_pContainerLayout;
    117     // QLabel          *m_pAdditionalOptionsLabel;
    118115
    119116    UICloneVMNamePathEditor *m_pNamePathEditor;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.cpp

    r90589 r90599  
    1818/* Qt includes: */
    1919// #include <QButtonGroup>
    20 // #include <QCheckBox>
     20#include <QCheckBox>
    2121#include <QComboBox>
    2222// #include <QDir>
     
    5555UICloneVMNamePathEditor::UICloneVMNamePathEditor(const QString &strOriginalName, const QString &strDefaultPath, QWidget *pParent /* = 0 */)
    5656    :QIWithRetranslateUI<QGroupBox>(pParent)
     57    , m_pContainerLayout(0)
    5758    , m_pNameLineEdit(0)
    5859    , m_pPathSelector(0)
     
    6566}
    6667
     68void UICloneVMNamePathEditor::setFirstColumnWidth(int iWidth)
     69{
     70    if (m_pContainerLayout)
     71        m_pContainerLayout->setColumnMinimumWidth(0, iWidth);
     72}
     73
     74int UICloneVMNamePathEditor::firstColumnWidth() const
     75{
     76    int iMaxWidth = 0;
     77    if (m_pNameLabel)
     78        iMaxWidth = qMax(iMaxWidth, m_pNameLabel->minimumSizeHint().width());
     79    if (m_pPathLabel)
     80        iMaxWidth = qMax(iMaxWidth, m_pPathLabel->minimumSizeHint().width());
     81    return iMaxWidth;
     82}
     83
    6784void UICloneVMNamePathEditor::prepare()
    6885{
    69     QGridLayout *pContainerLayout = new QGridLayout(this);
    70     pContainerLayout->setContentsMargins(0, 0, 0, 0);
     86    m_pContainerLayout = new QGridLayout(this);
     87    m_pContainerLayout->setContentsMargins(0, 0, 0, 0);
    7188
    7289    m_pNameLabel = new QLabel;
     
    7592        m_pNameLabel->setAlignment(Qt::AlignRight);
    7693        m_pNameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    77         pContainerLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);
     94        m_pContainerLayout->addWidget(m_pNameLabel, 0, 0, 1, 1);
    7895    }
    7996
     
    8198    if (m_pNameLineEdit)
    8299    {
    83         pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
     100        m_pContainerLayout->addWidget(m_pNameLineEdit, 0, 1, 1, 1);
    84101        m_pNameLineEdit->setText(tr("%1 Clone").arg(m_strOriginalName));
    85102    }
     
    90107        m_pPathLabel->setAlignment(Qt::AlignRight);
    91108        m_pPathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    92         pContainerLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
     109        m_pContainerLayout->addWidget(m_pPathLabel, 1, 0, 1, 1);
    93110    }
    94111
     
    96113    if (m_pPathSelector)
    97114    {
    98         pContainerLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);
     115        m_pContainerLayout->addWidget(m_pPathSelector, 1, 1, 1, 1);
    99116        m_pPathSelector->setPath(m_strDefaultPath);
    100117    }
     118
    101119    retranslateUi();
    102120}
     
    110128        m_pPathLabel->setText(tr("Path:"));
    111129}
     130
    112131
    113132
     
    119138UICloneVMAdditionalOptionsEditor::UICloneVMAdditionalOptionsEditor(QWidget *pParent /* = 0 */)
    120139    :QIWithRetranslateUI<QGroupBox>(pParent)
     140    , m_pContainerLayout(0)
    121141    , m_pMACComboBoxLabel(0)
    122142    , m_pMACComboBox(0)
     143    , m_pAdditionalOptionsLabel(0)
     144    , m_pKeepDiskNamesCheckBox(0)
     145    , m_pKeepHWUUIDsCheckBox(0)
    123146{
    124147    prepare();
     148}
     149
     150void UICloneVMAdditionalOptionsEditor::setFirstColumnWidth(int iWidth)
     151{
     152    if (m_pContainerLayout)
     153        m_pContainerLayout->setColumnMinimumWidth(0, iWidth);
     154}
     155
     156int UICloneVMAdditionalOptionsEditor::firstColumnWidth() const
     157{
     158    int iMaxWidth = 0;
     159    if (m_pMACComboBoxLabel)
     160        iMaxWidth = qMax(iMaxWidth, m_pMACComboBoxLabel->minimumSizeHint().width());
     161    if (m_pAdditionalOptionsLabel)
     162        iMaxWidth = qMax(iMaxWidth, m_pAdditionalOptionsLabel->minimumSizeHint().width());
     163    return iMaxWidth;
    125164}
    126165
     
    139178void UICloneVMAdditionalOptionsEditor::prepare()
    140179{
    141     QGridLayout *pContainerLayout = new QGridLayout(this);
    142     pContainerLayout->setContentsMargins(0, 0, 0, 0);
     180    m_pContainerLayout = new QGridLayout(this);
     181    m_pContainerLayout->setContentsMargins(0, 0, 0, 0);
    143182
    144183    m_pMACComboBoxLabel = new QLabel;
     
    147186        m_pMACComboBoxLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
    148187        m_pMACComboBoxLabel->setBuddy(m_pMACComboBox);
    149         pContainerLayout->addWidget(m_pMACComboBoxLabel, 2, 0, 1, 1);
     188        m_pContainerLayout->addWidget(m_pMACComboBoxLabel, 2, 0, 1, 1);
    150189    }
    151190
    152191    m_pMACComboBox = new QComboBox;
    153192    if (m_pMACComboBox)
    154         pContainerLayout->addWidget(m_pMACComboBox, 2, 1, 1, 1);
     193        m_pContainerLayout->addWidget(m_pMACComboBox, 2, 1, 1, 1);
    155194    populateMACAddressClonePolicies();
     195
     196
     197    /* Load currently supported clone options: */
     198    CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties();
     199    const QVector<KCloneOptions> supportedOptions = comProperties.GetSupportedCloneOptions();
     200    /* Check whether we support additional clone options at all: */
     201    int iVerticalPosition = 3;
     202    const bool fSupportedKeepDiskNames = supportedOptions.contains(KCloneOptions_KeepDiskNames);
     203    const bool fSupportedKeepHWUUIDs = supportedOptions.contains(KCloneOptions_KeepHwUUIDs);
     204    if (fSupportedKeepDiskNames || fSupportedKeepHWUUIDs)
     205    {
     206        m_pAdditionalOptionsLabel = new QLabel;
     207        if (m_pAdditionalOptionsLabel)
     208        {
     209            m_pAdditionalOptionsLabel->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
     210            m_pContainerLayout->addWidget(m_pAdditionalOptionsLabel, iVerticalPosition, 0, 1, 1);
     211        }
     212    }
     213    if (fSupportedKeepDiskNames)
     214    {
     215        m_pKeepDiskNamesCheckBox = new QCheckBox;
     216        if (m_pKeepDiskNamesCheckBox)
     217            m_pContainerLayout->addWidget(m_pKeepDiskNamesCheckBox, iVerticalPosition++, 1, 1, 1);
     218    }
     219    if (fSupportedKeepHWUUIDs)
     220    {
     221        m_pKeepHWUUIDsCheckBox = new QCheckBox;
     222        if (m_pKeepHWUUIDsCheckBox)
     223            m_pContainerLayout->addWidget(m_pKeepHWUUIDsCheckBox, iVerticalPosition++, 1, 1, 1);
     224    }
     225
     226
    156227    retranslateUi();
    157228}
     
    187258        }
    188259    }
     260
     261    if (m_pAdditionalOptionsLabel)
     262        m_pAdditionalOptionsLabel->setText(tr("Additional Options:"));
     263    if (m_pKeepDiskNamesCheckBox)
     264    {
     265        m_pKeepDiskNamesCheckBox->setToolTip(tr("Don't change the disk names during cloning."));
     266        m_pKeepDiskNamesCheckBox->setText(tr("Keep &Disk Names"));
     267    }
     268    if (m_pKeepHWUUIDsCheckBox)
     269    {
     270        m_pKeepHWUUIDsCheckBox->setToolTip(tr("Don't change hardware UUIDs during cloning."));
     271        m_pKeepHWUUIDsCheckBox->setText(tr("Keep &Hardware UUIDs"));
     272    }
     273
    189274}
    190275
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/editors/UIWizardCloneVMEditors.h

    r90589 r90599  
    3333// class CMediumFormat;
    3434// class QButtonGroup;
    35 // class QCheckBox;
    36 // class QGridLayout;
     35class QCheckBox;
     36class QGridLayout;
    3737class QComboBox;
    3838class QLabel;
     
    7474    UICloneVMNamePathEditor(const QString &strOriginalName, const QString &strDefaultPath, QWidget *pParent = 0);
    7575
     76    void setFirstColumnWidth(int iWidth);
     77    int firstColumnWidth() const;
     78
    7679    QString name() const;
    7780    void setName(const QString &strName);
     
    8184    bool isComplete();
    8285
     86
    8387private:
    8488
     
    8690    virtual void retranslateUi() /* override final */;
    8791
     92    QGridLayout *m_pContainerLayout;
    8893    QILineEdit  *m_pNameLineEdit;
    8994    UIFilePathSelector *m_pPathSelector;
     
    111116    MACAddressClonePolicy macAddressClonePolicy() const;
    112117    void setMACAddressClonePolicy(MACAddressClonePolicy enmMACAddressClonePolicy);
     118    void setFirstColumnWidth(int iWidth);
     119    int firstColumnWidth() const;
    113120
    114121private:
     
    118125    void populateMACAddressClonePolicies();
    119126
     127    QGridLayout *m_pContainerLayout;
    120128    QLabel *m_pMACComboBoxLabel;
    121129    QComboBox *m_pMACComboBox;
    122 
     130    QLabel *m_pAdditionalOptionsLabel;
     131    QCheckBox   *m_pKeepDiskNamesCheckBox;
     132    QCheckBox   *m_pKeepHWUUIDsCheckBox;
    123133};
    124134
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