VirtualBox

Changeset 90427 in vbox for trunk/src


Ignore:
Timestamp:
Jul 30, 2021 1:38:15 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996. Fixes on the new vd expert page.

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

Legend:

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

    r90356 r90427  
    3030
    3131/* GUI includes: */
     32#include "UIWizardDiskEditors.h"
    3233#include "UIConverter.h"
    3334#include "UIWizardNewVDPageExpert.h"
     
    4041#include "QILineEdit.h"
    4142#include "UIMediumSizeEditor.h"
     43#include "UIWizardNewVDPageSizeLocation.h"
    4244
    4345/* COM includes: */
     
    4547
    4648
    47 UIWizardNewVDPageExpert::UIWizardNewVDPageExpert(const QString &/*strDefaultName*/, const QString &/*strDefaultPath*/, qulonglong /*uDefaultSize*/)
     49UIWizardNewVDPageExpert::UIWizardNewVDPageExpert(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize)
    4850    : UINativeWizardPage()
    49     , m_pFormatGroupBox(0)
    50     , m_pVariantGroupBox(0)
    51     , m_pLocationGroupBox(0)
    52     , m_pSizeGroupBox(0)
    53 {
    54     /* Get default extension for new virtual-disk: */
    55     /* Create widgets: */
    56 //     QGridLayout *pMainLayout = new QGridLayout(this);
    57 //     {
    58 //         m_pLocationGroupBox = new QGroupBox(this);
    59 //         {
    60 //             m_pLocationGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    61 //             QHBoxLayout *pLocationGroupBoxLayout = new QHBoxLayout(m_pLocationGroupBox);
    62 //             {
    63 //                 m_pLocationEditor = new QLineEdit(m_pLocationGroupBox);
    64 //                 m_pLocationOpenButton = new QIToolButton(m_pLocationGroupBox);
    65 //                 {
    66 //                     m_pLocationOpenButton->setAutoRaise(true);
    67 //                     m_pLocationOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_disabled_16px.png"));
    68 //                 }
    69 //                 pLocationGroupBoxLayout->addWidget(m_pLocationEditor);
    70 //                 pLocationGroupBoxLayout->addWidget(m_pLocationOpenButton);
    71 //             }
    72 //         }
    73 //         m_pSizeGroupBox = new QGroupBox(this);
    74 //         {
    75 //             m_pSizeGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    76 //             QVBoxLayout *pSizeGroupBoxLayout = new QVBoxLayout(m_pSizeGroupBox);
    77 //             {
    78 //                 m_pMediumSizeEditor = new UIMediumSizeEditor;
    79 //                 {
    80 //                     pSizeGroupBoxLayout->addWidget(m_pMediumSizeEditor);
    81 //                 }
    82 //             }
    83 //         }
    84 //         m_pFormatGroupBox = new QGroupBox(this);
    85 //         {
    86 //             m_pFormatGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    87 //             QVBoxLayout *pFormatGroupBoxLayout = new QVBoxLayout(m_pFormatGroupBox);
    88 //             pFormatGroupBoxLayout->addWidget(createFormatButtonGroup(true));
    89 //         }
    90 //         m_pVariantGroupBox = new QGroupBox(this);
    91 //         {
    92 //             m_pVariantGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    93 //             QVBoxLayout *pVariantGroupBoxLayout = new QVBoxLayout(m_pVariantGroupBox);
    94 //             {
    95 //                 m_pFixedCheckBox = new QCheckBox;
    96 //                 m_pSplitBox = new QCheckBox(m_pVariantGroupBox);
    97 //                 pVariantGroupBoxLayout->addWidget(m_pFixedCheckBox);
    98 //                 pVariantGroupBoxLayout->addWidget(m_pSplitBox);
    99 //             }
    100 //         }
    101 //         pMainLayout->addWidget(m_pLocationGroupBox, 0, 0, 1, 2);
    102 //         pMainLayout->addWidget(m_pSizeGroupBox, 1, 0, 1, 2);
    103 //         pMainLayout->addWidget(m_pFormatGroupBox, 2, 0, Qt::AlignTop);
    104 //         pMainLayout->addWidget(m_pVariantGroupBox, 2, 1, Qt::AlignTop);
    105 //         setMediumSize(uDefaultSize);
    106 //         sltMediumFormatChanged();
    107 //     }
    108 
    109 //     /* Setup connections: */
    110 //     connect(m_pFormatButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
    111 //             this, &UIWizardNewVDPageExpert::sltMediumFormatChanged);
     51    , m_pSizeAndPathGroup(0)
     52    , m_pFormatGroup(0)
     53    , m_pVariantGroup(0)
     54    , m_strDefaultName(strDefaultName)
     55    , m_strDefaultPath(strDefaultPath)
     56    , m_uDefaultSize(uDefaultSize)
     57    , m_uMediumSizeMin(_4M)
     58    , m_uMediumSizeMax(uiCommon().virtualBox().GetSystemProperties().GetInfoVDSize())
     59{
     60    prepare();
     61}
     62
     63void UIWizardNewVDPageExpert::prepare()
     64{
     65    QGridLayout *pMainLayout = new QGridLayout(this);
     66    m_pSizeAndPathGroup = new UIMediumSizeAndPathGroupBox(true /* fExpertMode */, 0);
     67    m_pFormatGroup = new UIDiskFormatsGroupBox(true /* fExpertMode */, 0);
     68    m_pVariantGroup = new UIDiskVariantGroupBox(true /* fExpertMode */, 0);
     69
     70    pMainLayout->addWidget(m_pSizeAndPathGroup, 0, 0, 2, 2);
     71    pMainLayout->addWidget(m_pFormatGroup, 2, 0, 6, 1);
     72    pMainLayout->addWidget(m_pVariantGroup, 2, 1, 6, 1);
     73
     74    connect(m_pFormatGroup, &UIDiskFormatsGroupBox::sigMediumFormatChanged,
     75            this, &UIWizardNewVDPageExpert::sltMediumFormatChanged);
    11276//     connect(m_pFixedCheckBox, &QAbstractButton::toggled,
    11377//             this, &UIWizardNewVDPageExpert::completeChanged);
     
    11680//     connect(m_pLocationEditor, &QLineEdit::textChanged,
    11781//             this, &UIWizardNewVDPageExpert::completeChanged);
    118 //     connect(m_pLocationOpenButton, &QIToolButton::clicked,
    119 //             this, &UIWizardNewVDPageExpert::sltSelectLocationButtonClicked);
     82    connect(m_pSizeAndPathGroup, &UIMediumSizeAndPathGroupBox::sigMediumLocationButtonClicked,
     83            this, &UIWizardNewVDPageExpert::sltSelectLocationButtonClicked);
    12084//     connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
    12185//             this, &UIWizardNewVDPageExpert::completeChanged);
    12286
    123 //     /* Register classes: */
    124 //     qRegisterMetaType<CMediumFormat>();
    125 //     /* Register fields: */
    126 //     registerField("mediumFormat", this, "mediumFormat");
    127 //     registerField("mediumVariant", this, "mediumVariant");
    128 //     registerField("mediumPath", this, "mediumPath");
    129 //     registerField("mediumSize", this, "mediumSize");
     87
     88    retranslateUi();
     89
    13090}
    13191
    13292void UIWizardNewVDPageExpert::sltMediumFormatChanged()
    13393{
    134     // CMediumFormat comMediumFormat = mediumFormat();
    135     // if (comMediumFormat.isNull())
    136     // {
    137     //     AssertMsgFailed(("No medium format set!"));
    138     //     return;
    139     // }
    140     // updateMediumVariantWidgetsAfterFormatChange(comMediumFormat);
    141     // updateLocationEditorAfterFormatChange(comMediumFormat, m_formatExtensions);
    142 
    143     // /* Broadcast complete-change: */
    144     // completeChanged();
     94    AssertReturnVoid(m_pFormatGroup);
     95    newVDWizardPropertySet(MediumFormat, m_pFormatGroup->mediumFormat());
     96    updateDiskWidgetsAfterMediumFormatChange();
     97    completeChanged();
    14598}
    14699
    147100void UIWizardNewVDPageExpert::sltSelectLocationButtonClicked()
    148101{
    149     /* Call to base-class: */
    150     //onSelectLocationButtonClicked();
     102    UIWizardNewVD *pWizard = qobject_cast<UIWizardNewVD*>(wizard());
     103    AssertReturnVoid(pWizard);
     104    QString strSelectedPath = UIWizardNewVDSizeLocation::selectNewMediumLocation(pWizard);
     105    if (strSelectedPath.isEmpty())
     106        return;
     107    QString strMediumPath =
     108        UIDiskEditorGroupBox::appendExtension(strSelectedPath,
     109                                              UIDiskEditorGroupBox::defaultExtensionForMediumFormat(pWizard->mediumFormat()));
     110    QFileInfo mediumPath(strMediumPath);
     111    m_pSizeAndPathGroup->setMediumPath(QDir::toNativeSeparators(mediumPath.absoluteFilePath()));
    151112}
    152113
     
    181142void UIWizardNewVDPageExpert::initializePage()
    182143{
    183     // /* Get default extension for new virtual-disk: */
    184     // m_strDefaultExtension = defaultExtension(field("mediumFormat").value<CMediumFormat>());
    185     // /* Set default name as text for location editor: */
    186     // if (m_pLocationEditor)
    187     //     m_pLocationEditor->setText(absoluteFilePath(m_strDefaultName, m_strDefaultPath, m_strDefaultExtension));
    188 
    189 
    190     // /* Translate page: */
    191     // retranslateUi();
     144    /* First set the medium format of the wizard: */
     145    AssertReturnVoid(m_pFormatGroup);
     146    const CMediumFormat &comMediumFormat = m_pFormatGroup->mediumFormat();
     147    AssertReturnVoid(!comMediumFormat.isNull());
     148    newVDWizardPropertySet(MediumFormat, comMediumFormat);
     149
     150    QString strExtension = UIDiskEditorGroupBox::defaultExtensionForMediumFormat(comMediumFormat);
     151    QString strMediumFilePath =
     152        UIDiskEditorGroupBox::constructMediumFilePath(UIDiskVariantGroupBox::appendExtension(m_strDefaultName,
     153                                                                                             strExtension), m_strDefaultPath);
     154    m_pSizeAndPathGroup->blockSignals(true);
     155    m_pSizeAndPathGroup->setMediumPath(strMediumFilePath);
     156    m_pSizeAndPathGroup->blockSignals(false);
     157    newVDWizardPropertySet(MediumPath, m_pSizeAndPathGroup->mediumPath());
     158
     159    m_pSizeAndPathGroup->blockSignals(true);
     160    m_pSizeAndPathGroup->setMediumSize(m_uDefaultSize > m_uMediumSizeMin && m_uDefaultSize < m_uMediumSizeMax ? m_uDefaultSize : m_uMediumSizeMin);
     161    m_pSizeAndPathGroup->blockSignals(false);
     162    newVDWizardPropertySet(MediumSize, m_pSizeAndPathGroup->mediumSize());
     163
     164    m_pVariantGroup->blockSignals(true);
     165    m_pVariantGroup->updateMediumVariantWidgetsAfterFormatChange(comMediumFormat);
     166    m_pVariantGroup->blockSignals(false);
     167
     168    newVDWizardPropertySet(MediumVariant, m_pVariantGroup->mediumVariant());
     169
     170    retranslateUi();
    192171}
    193172
     
    237216    return fResult;
    238217}
     218
     219void UIWizardNewVDPageExpert::updateDiskWidgetsAfterMediumFormatChange()
     220{
     221    UIWizardNewVD *pWizard = qobject_cast<UIWizardNewVD*>(wizard());
     222    AssertReturnVoid(pWizard && m_pVariantGroup && m_pSizeAndPathGroup && m_pFormatGroup);
     223    const CMediumFormat &comMediumFormat = pWizard->mediumFormat();
     224    AssertReturnVoid(!comMediumFormat.isNull());
     225
     226    /* Block signals of the updated widgets to avoid calling corresponding slots since they add the parameters to m_userModifiedParameters: */
     227    m_pVariantGroup->blockSignals(true);
     228    m_pVariantGroup->updateMediumVariantWidgetsAfterFormatChange(comMediumFormat);
     229    m_pVariantGroup->blockSignals(false);
     230
     231    m_pSizeAndPathGroup->blockSignals(true);
     232    m_pSizeAndPathGroup->updateMediumPath(comMediumFormat, m_pFormatGroup->formatExtensions());
     233    m_pSizeAndPathGroup->blockSignals(false);
     234    /* Update the wizard parameters explicitly since we blocked th signals: */
     235    newVDWizardPropertySet(MediumPath, m_pSizeAndPathGroup->mediumPath());
     236    newVDWizardPropertySet(MediumVariant, m_pVariantGroup->mediumVariant());
     237}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageExpert.h

    r90356 r90427  
    2727/* Forward declarations: */
    2828class QGroupBox;
     29class UIDiskFormatsGroupBox;
     30class UIDiskVariantGroupBox;
     31class UIMediumSizeAndPathGroupBox;
    2932
    3033/* Expert page of the New Virtual Hard Drive wizard: */
     
    3538public:
    3639
    37     /* Constructor: */
    3840    UIWizardNewVDPageExpert(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize);
    3941
     
    4345private slots:
    4446
    45     /* Medium format stuff: */
    4647    void sltMediumFormatChanged();
    47 
    48     /* Location editors stuff: */
    4948    void sltSelectLocationButtonClicked();
    5049
     
    5554
    5655    /* Prepare stuff: */
     56    void prepare();
    5757    void initializePage();
    5858
     
    6060    bool isComplete() const;
    6161    bool validatePage();
     62    void updateDiskWidgetsAfterMediumFormatChange();
     63
    6264
    6365    /* Widgets: */
    64     QGroupBox *m_pFormatGroupBox;
    65     QGroupBox *m_pVariantGroupBox;
    66     QGroupBox *m_pLocationGroupBox;
    67     QGroupBox *m_pSizeGroupBox;
     66    UIMediumSizeAndPathGroupBox *m_pSizeAndPathGroup;
     67    UIDiskFormatsGroupBox *m_pFormatGroup;
     68    UIDiskVariantGroupBox *m_pVariantGroup;
     69
     70    QString m_strDefaultName;
     71    QString m_strDefaultPath;
     72    qulonglong m_uDefaultSize;
     73    qulonglong m_uMediumSizeMin;
     74    qulonglong m_uMediumSizeMax;
    6875};
    6976
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageSizeLocation.cpp

    r90413 r90427  
    2121
    2222/* GUI includes: */
     23#include "QIFileDialog.h"
    2324#include "UIWizardNewVDPageSizeLocation.h"
    2425#include "UIWizardNewVD.h"
     
    2930/* COM includes: */
    3031#include "CSystemProperties.h"
     32
     33
     34QString UIWizardNewVDSizeLocation::selectNewMediumLocation(UIWizardNewVD *pWizard)
     35{
     36    AssertReturn(pWizard, QString());
     37    QString strChosenFilePath;
     38    /* Get current folder and filename: */
     39    QFileInfo fullFilePath(pWizard->mediumPath());
     40    QDir folder = fullFilePath.path();
     41    QString strFileName = fullFilePath.fileName();
     42
     43    /* Set the first parent folder that exists as the current: */
     44    while (!folder.exists() && !folder.isRoot())
     45    {
     46        QFileInfo folderInfo(folder.absolutePath());
     47        if (folder == QDir(folderInfo.absolutePath()))
     48            break;
     49        folder = folderInfo.absolutePath();
     50    }
     51    AssertReturn(folder.exists() && !folder.isRoot(), strChosenFilePath);
     52
     53    QVector<QString> fileExtensions;
     54    QVector<KDeviceType> deviceTypes;
     55    CMediumFormat mediumFormat = pWizard->mediumFormat();
     56    mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes);
     57    QStringList validExtensionList;
     58    for (int i = 0; i < fileExtensions.size(); ++i)
     59        if (deviceTypes[i] == KDeviceType_HardDisk)
     60            validExtensionList << QString("*.%1").arg(fileExtensions[i]);
     61    /* Compose full filter list: */
     62    QString strBackendsList = QString("%1 (%2)").arg(mediumFormat.GetName()).arg(validExtensionList.join(" "));
     63
     64    strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName),
     65                                                              strBackendsList, pWizard,
     66                                                              UICommon::tr("Please choose a location for new virtual hard disk file"));
     67    return strChosenFilePath;
     68}
     69
    3170
    3271UIWizardNewVDPageSizeLocation::UIWizardNewVDPageSizeLocation(const QString &strDefaultName,
     
    61100void UIWizardNewVDPageSizeLocation::sltSelectLocationButtonClicked()
    62101{
     102
    63103}
    64104
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVDPageSizeLocation.h

    r90407 r90427  
    2828class CMediumFormat;
    2929class UIMediumSizeAndPathGroupBox;
     30class UIWizardNewVD;
     31
     32namespace UIWizardNewVDSizeLocation
     33{
     34    QString selectNewMediumLocation(UIWizardNewVD *pWizard);
     35}
    3036
    3137class SHARED_LIBRARY_STUFF UIWizardNewVDPageSizeLocation : public UINativeWizardPage
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPageBasic.cpp

    r90413 r90427  
    9191                                                              strBackendsList, pWizard,
    9292                                                              UICommon::tr("Please choose a location for new virtual hard disk file"));
    93 
    94     // if (!strChosenFilePath.isEmpty())
    95     // {
    96     //     /* If valid file extension is missed, append it: */
    97     //     if (QFileInfo(strChosenFilePath).suffix().isEmpty())
    98     //          strChosenFilePath += QString(".%1").arg(m_strDefaultExtension);
    99     // }
    10093    return strChosenFilePath;
    101     //     if (m_pLocationEditor)
    102     //     {
    103     //         m_pLocationEditor->setText(QDir::toNativeSeparators(strChosenFilePath));
    104     //         m_pLocationEditor->selectAll();
    105     //         m_pLocationEditor->setFocus();
    106     //     }
    107     // }
    108 }
    109 
     94}
    11095
    11196UIWizardNewVMDiskPageBasic::UIWizardNewVMDiskPageBasic()
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