VirtualBox

Changeset 85042 in vbox for trunk


Ignore:
Timestamp:
Jul 3, 2020 6:10:45 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9515. Merging first two pages

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

Legend:

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

    r85035 r85042  
    651651        src/wizards/newvm/UIWizardNewVM.h \
    652652        src/wizards/newvm/UIWizardNewVMPageBasicUserNameHostname.h \
    653         src/wizards/newvm/UIWizardNewVMPageBasicUnattended.h \
    654653        src/wizards/newvm/UIWizardNewVMPageBasicNameType.h \
    655654        src/wizards/newvm/UIWizardNewVMPageBasicGAInstall.h \
     
    11171116        src/wizards/newvm/UIWizardNewVM.cpp \
    11181117        src/wizards/newvm/UIWizardNewVMPageBasicUserNameHostname.cpp \
    1119         src/wizards/newvm/UIWizardNewVMPageBasicUnattended.cpp \
    11201118        src/wizards/newvm/UIWizardNewVMPageBasicNameType.cpp \
    11211119        src/wizards/newvm/UIWizardNewVMPageBasicGAInstall.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r85001 r85042  
    7878        case WizardMode_Basic:
    7979        {
    80             UIWizardNewVMPageBasicUnattended *pUnattendedPage =
    81                 new UIWizardNewVMPageBasicUnattended;
    82             connect(pUnattendedPage, &UIWizardNewVMPageBasicUnattended::sigDetectedOSTypeChanged,
    83                     this, &UIWizardNewVM::sltHandleDetectedOSTypeChange);
    84             setPage(PageUnattended, pUnattendedPage);
     80            // UIWizardNewVMPageBasicUnattended *pUnattendedPage =
     81            //     new UIWizardNewVMPageBasicUnattended;
     82            // connect(pUnattendedPage, &UIWizardNewVMPageBasicUnattended::sigDetectedOSTypeChanged,
     83            //         this, &UIWizardNewVM::sltHandleDetectedOSTypeChange);
     84            // setPage(PageUnattended, pUnattendedPage);
    8585            setPage(PageNameType, new UIWizardNewVMPageBasicNameType(m_strGroup));
    8686            setPage(PageUserNameHostname, new UIWizardNewVMPageBasicUserNameHostname);
     
    531531    m_unattendedInstallData.m_strPassword = getStringFieldValue("password");
    532532    m_unattendedInstallData.m_strDetectedOSTypeId = getStringFieldValue("detectedOSTypeId");
    533     m_unattendedInstallData.m_strDetectedOSVersion = getStringFieldValue("detectedOSVersion");
    534     m_unattendedInstallData.m_strDetectedOSFlavor = getStringFieldValue("detectedOSFlavor");
    535     m_unattendedInstallData.m_strDetectedOSLanguages = getStringFieldValue("detectedOSLanguages");
    536     m_unattendedInstallData.m_strDetectedOSHints = getStringFieldValue("detectedOSHints");
     533    // m_unattendedInstallData.m_strDetectedOSVersion = getStringFieldValue("detectedOSVersion");
     534    // m_unattendedInstallData.m_strDetectedOSFlavor = getStringFieldValue("detectedOSFlavor");
     535    // m_unattendedInstallData.m_strDetectedOSLanguages = getStringFieldValue("detectedOSLanguages");
     536    // m_unattendedInstallData.m_strDetectedOSHints = getStringFieldValue("detectedOSHints");
    537537    m_unattendedInstallData.m_strProductKey = getStringFieldValue("productKey");
    538538    m_unattendedInstallData.m_strGuestAdditionsISOPath = getStringFieldValue("guestAdditionsISOPath");
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasicNameType.cpp

    r85001 r85042  
    1717
    1818/* Qt includes: */
     19#include <QCheckBox>
    1920#include <QDir>
    20 #include <QLineEdit>
     21#include <QLabel>
    2122#include <QHBoxLayout>
    2223#include <QVBoxLayout>
     
    2526#include "QIRichTextLabel.h"
    2627#include "UICommon.h"
     28#include "UIFilePathSelector.h"
    2729#include "UIMessageCenter.h"
    2830#include "UINameAndSystemEditor.h"
     
    3335#include "CHost.h"
    3436#include "CSystemProperties.h"
    35 
     37#include "CUnattended.h"
    3638
    3739/* Defines some patterns to guess the right OS type. Should be in sync with
     
    176178UIWizardNewVMPageNameType::UIWizardNewVMPageNameType(const QString &strGroup)
    177179    : m_pNameAndSystemEditor(0)
     180    , m_pUnattendedCheckBox(0)
     181    , m_pStartHeadlessCheckBox(0)
     182    , m_pISOSelectorLabel(0)
     183    , m_pISOFilePathSelector(0)
    178184    , m_strGroup(strGroup)
    179 
    180185{
    181186    CHost host = uiCommon().host();
     
    212217}
    213218
     219bool UIWizardNewVMPageNameType::determineOSType(const QString &strISOPath)
     220{
     221    QFileInfo isoFileInfo(strISOPath);
     222    if (!isoFileInfo.exists())
     223    {
     224        m_strDetectedOSTypeId.clear();
     225        // m_strDetectedOSVersion.clear();
     226        // m_strDetectedOSFlavor.clear();
     227        // m_strDetectedOSLanguages.clear();
     228        // m_strDetectedOSHints.clear();
     229        // updateStatusLabel();
     230        return false;
     231    }
     232
     233    CUnattended comUnatteded = uiCommon().virtualBox().CreateUnattendedInstaller();
     234    comUnatteded.SetIsoPath(strISOPath);
     235    comUnatteded.DetectIsoOS();
     236
     237    m_strDetectedOSTypeId = comUnatteded.GetDetectedOSTypeId();
     238    // m_strDetectedOSVersion = comUnatteded.GetDetectedOSVersion();
     239    // m_strDetectedOSFlavor = comUnatteded.GetDetectedOSFlavor();
     240    // m_strDetectedOSLanguages = comUnatteded.GetDetectedOSLanguages();
     241    // m_strDetectedOSHints = comUnatteded.GetDetectedOSHints();
     242
     243    //updateStatusLabel();
     244    return true;
     245}
     246
    214247void UIWizardNewVMPageNameType::composeMachineFilePath()
    215248{
     
    232265}
    233266
     267bool UIWizardNewVMPageNameType::checkISOFile() const
     268{
     269    if (m_pUnattendedCheckBox && m_pUnattendedCheckBox->isChecked())
     270    {
     271        QString strISOFilePath = m_pISOFilePathSelector ? m_pISOFilePathSelector->path() : QString();
     272        if (!QFileInfo(strISOFilePath).exists())
     273            return false;
     274    }
     275    return true;
     276}
     277
    234278bool UIWizardNewVMPageNameType::createMachineFolder()
    235279{
     
    326370}
    327371
     372QString UIWizardNewVMPageNameType::ISOFilePath() const
     373{
     374    if (!m_pISOFilePathSelector)
     375        return QString();
     376    return m_pISOFilePathSelector->path();
     377}
     378
     379bool UIWizardNewVMPageNameType::isUnattendedEnabled() const
     380{
     381    if (!m_pUnattendedCheckBox)
     382        return false;
     383    return m_pUnattendedCheckBox->isChecked();
     384}
     385
     386bool UIWizardNewVMPageNameType::startHeadless() const
     387{
     388    if (!m_pStartHeadlessCheckBox)
     389        return false;
     390    return m_pStartHeadlessCheckBox->isChecked();
     391}
     392
     393const QString &UIWizardNewVMPageNameType::detectedOSTypeId() const
     394{
     395    return m_strDetectedOSTypeId;
     396}
     397
    328398UIWizardNewVMPageBasicNameType::UIWizardNewVMPageBasicNameType(const QString &strGroup)
    329399    : UIWizardNewVMPageNameType(strGroup)
    330400{
    331     /* Create widgets: */
    332     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    333     {
    334         m_pLabel = new QIRichTextLabel(this);
    335         m_pNameAndSystemEditor = new UINameAndSystemEditor(this, true, true, true);
    336         pMainLayout->addWidget(m_pLabel);
    337         pMainLayout->addWidget(m_pNameAndSystemEditor);
    338         pMainLayout->addStretch();
    339     }
     401    prepare();
     402}
     403
     404void UIWizardNewVMPageBasicNameType::prepare()
     405{
     406    QGridLayout *pMainLayout = new QGridLayout(this);
     407    if (!pMainLayout)
     408        return;
     409
     410
     411    m_pLabel = new QIRichTextLabel(this);
     412    m_pUnattendedCheckBox = new QCheckBox;
     413    if (m_pUnattendedCheckBox)
     414    {
     415        m_pUnattendedCheckBox->setLayoutDirection(Qt::RightToLeft);
     416        //m_pUnattendedCheckBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
     417        connect(m_pUnattendedCheckBox, &QCheckBox::toggled, this, &UIWizardNewVMPageBasicNameType::sltUnattendedCheckBoxToggle);
     418    }
     419    m_pStartHeadlessCheckBox = new QCheckBox;
     420    if (m_pStartHeadlessCheckBox)
     421    {
     422        m_pStartHeadlessCheckBox->setLayoutDirection(Qt::RightToLeft);
     423        m_pStartHeadlessCheckBox->setEnabled(false);
     424    }
     425
     426    m_pISOSelectorLabel = new QLabel;
     427    if (m_pISOSelectorLabel)
     428    {
     429        m_pISOSelectorLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
     430        m_pISOSelectorLabel->setEnabled(false);
     431    }
     432
     433    m_pISOFilePathSelector = new UIFilePathSelector;
     434    if (m_pISOFilePathSelector)
     435    {
     436        m_pISOFilePathSelector->setResetEnabled(false);
     437        m_pISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
     438        m_pISOFilePathSelector->setFileDialogFilters("*.iso *.ISO");
     439        m_pISOFilePathSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
     440        m_pISOFilePathSelector->setEnabled(false);
     441        connect(m_pISOFilePathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardNewVMPageBasicNameType::sltISOPathChanged);
     442    }
     443
     444    m_pNameAndSystemEditor = new UINameAndSystemEditor(this, true, true, true);
     445
     446    pMainLayout->addWidget(m_pLabel, 0, 0, 1, 4);
     447    pMainLayout->addWidget(m_pUnattendedCheckBox, 1, 0, 1, 1, Qt::AlignLeft);
     448    pMainLayout->addWidget(m_pStartHeadlessCheckBox, 2, 1, 1, 1, Qt::AlignLeft);
     449
     450    pMainLayout->addWidget(m_pISOSelectorLabel, 3, 1, 1, 1, Qt::AlignLeft);
     451    pMainLayout->addWidget(m_pISOFilePathSelector, 3, 2, 1, 3, Qt::AlignLeft);
     452    pMainLayout->addWidget(m_pNameAndSystemEditor, 4, 0, 1, 5);
    340453
    341454    /* Setup connections: */
     
    351464    registerField("machineBaseName", this, "machineBaseName");
    352465    registerField("guestOSFamiyId", this, "guestOSFamiyId");
     466    registerField("ISOFilePath", this, "ISOFilePath");
     467    registerField("isUnattendedEnabled", this, "isUnattendedEnabled");
     468    registerField("startHeadless", this, "startHeadless");
     469    registerField("detectedOSTypeId", this, "detectedOSTypeId");
    353470}
    354471
     
    367484}
    368485
     486bool UIWizardNewVMPageBasicNameType::isComplete() const
     487{
     488    if (m_pNameAndSystemEditor->name().isEmpty())
     489        return false;
     490    return checkISOFile();
     491}
     492
    369493void UIWizardNewVMPageBasicNameType::sltNameChanged(const QString &strNewName)
    370494{
     
    385509}
    386510
     511void UIWizardNewVMPageBasicNameType::sltISOPathChanged(const QString &strPath)
     512{
     513    determineOSType(strPath);
     514    setTypeByISODetectedOSType(m_strDetectedOSTypeId);
     515    emit completeChanged();
     516}
     517
     518void UIWizardNewVMPageBasicNameType::sltUnattendedCheckBoxToggle(bool fEnabled)
     519{
     520    if (m_pISOSelectorLabel)
     521        m_pISOSelectorLabel->setEnabled(fEnabled);
     522    if (m_pISOFilePathSelector)
     523        m_pISOFilePathSelector->setEnabled(fEnabled);
     524    if (m_pStartHeadlessCheckBox)
     525        m_pStartHeadlessCheckBox->setEnabled(fEnabled);
     526    // if (m_pStatusLabel)
     527    //     m_pStatusLabel->setEnabled(fEnabled);
     528    emit completeChanged();
     529}
     530
     531
    387532void UIWizardNewVMPageBasicNameType::retranslateUi()
    388533{
     
    390535    setTitle(UIWizardNewVM::tr("Name and operating system"));
    391536
    392     /* Translate widgets: */
    393     m_pLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new virtual machine "
    394                                         "and select the type of operating system you intend to install on it. "
    395                                         "The name you choose will be used throughout VirtualBox "
    396                                         "to identify this machine."));
     537    if (m_pLabel)
     538        m_pLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new virtual machine "
     539                                            "and select the type of operating system you intend to install on it. "
     540                                            "The name you choose will be used throughout VirtualBox "
     541                                            "to identify this machine."));
     542
     543
     544    if (m_pUnattendedCheckBox)
     545    {
     546        m_pUnattendedCheckBox->setText(UIWizardNewVM::tr("Unattended Install"));
     547        m_pUnattendedCheckBox->setToolTip(UIWizardNewVM::tr("When checkedan unattended guest OS will be initialized after this wizard is closed"));
     548    }
     549    if (m_pISOSelectorLabel)
     550        m_pISOSelectorLabel->setText(UIWizardNewVM::tr("Installation medium:"));
     551    if (m_pStartHeadlessCheckBox)
     552    {
     553        m_pStartHeadlessCheckBox->setText(UIWizardNewVM::tr("Start VM Headless"));
     554        m_pStartHeadlessCheckBox->setToolTip(UIWizardNewVM::tr("When checked the unattended install will start the virtual machine headless"));
     555    }
    397556}
    398557
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasicNameType.h

    r84961 r85042  
    2727/* Forward declarations: */
    2828class UINameAndSystemEditor;
     29class QCheckBox;
     30class QLabel;
    2931class QIRichTextLabel;
     32class UIFilePathSelector;
    3033
    3134/* 1st page of the New Virtual Machine wizard (base part): */
     
    4750    bool cleanupMachineFolder(bool fWizardCancel = false);
    4851
    49     QString machineFilePath() const;
    50     void setMachineFilePath(const QString &strMachineFilePath);
     52    /** @name Property getters/setters
     53      * @{ */
     54        QString machineFilePath() const;
     55        void setMachineFilePath(const QString &strMachineFilePath);
    5156
    52     QString machineFolder() const;
    53     void setMachineFolder(const QString &strMachineFolder);
     57        QString machineFolder() const;
     58        void setMachineFolder(const QString &strMachineFolder);
    5459
    55     QString machineBaseName() const;
    56     void setMachineBaseName(const QString &strMachineBaseName);
     60        QString machineBaseName() const;
     61        void setMachineBaseName(const QString &strMachineBaseName);
    5762
    58     QString guestOSFamiyId() const;
     63        QString guestOSFamiyId() const;
     64        QString ISOFilePath() const;
     65        bool isUnattendedEnabled() const;
     66        bool startHeadless() const;
     67        const QString &detectedOSTypeId() const;
     68    /** @} */
    5969
     70
     71    bool determineOSType(const QString &strISOPath);
    6072    /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */
    6173    void composeMachineFilePath();
     74    bool checkISOFile() const;
     75
    6276
    6377    /** Provides a path selector and a line edit field for path and name entry. */
    6478    UINameAndSystemEditor *m_pNameAndSystemEditor;
     79    QCheckBox *m_pUnattendedCheckBox;
     80    QCheckBox *m_pStartHeadlessCheckBox;
     81    QLabel *m_pISOSelectorLabel;
     82    UIFilePathSelector *m_pISOFilePathSelector;
     83    QString m_strDetectedOSTypeId;
    6584
    6685private:
     86
    6787
    6888    /** Full path (including the file name) of the machine's configuration file. */
     
    80100    bool m_fSupportsHWVirtEx;
    81101    bool m_fSupportsLongMode;
     102
     103
    82104    friend class UIWizardNewVM;
    83105};
     
    91113    Q_PROPERTY(QString machineBaseName READ machineBaseName WRITE setMachineBaseName);
    92114    Q_PROPERTY(QString guestOSFamiyId READ guestOSFamiyId);
     115    Q_PROPERTY(QString ISOFilePath READ ISOFilePath);
     116    Q_PROPERTY(bool isUnattendedEnabled READ isUnattendedEnabled);
     117    Q_PROPERTY(bool startHeadless READ startHeadless);
     118    Q_PROPERTY(QString detectedOSTypeId READ detectedOSTypeId);
    93119
    94120
     
    99125    virtual int nextId() const /* override */;
    100126    void setTypeByISODetectedOSType(const QString &strDetectedOSType);
     127    virtual bool isComplete() const; /* override */
    101128
    102129protected:
     
    111138    void sltPathChanged(const QString &strNewPath);
    112139    void sltOsTypeChanged();
     140    void sltISOPathChanged(const QString &strPath);
     141    void sltUnattendedCheckBoxToggle(bool fEnabled);
    113142
    114143private:
    115144
     145    void prepare();
    116146    /* Translation stuff: */
    117147    void retranslateUi();
     
    126156    /* Widgets: */
    127157    QIRichTextLabel *m_pLabel;
     158
    128159};
    129160
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasicUnattended.cpp

    r85039 r85042  
    126126    if (m_pStatusLabel)
    127127    {
    128         m_pStatusLabel->setText(QString("<b>%1:</b> %2<br/><b>%3:</b> %4<br/><b>%5</b>: %6")
     128        m_pStatusLabel->setText(QString("%1: %2<br/>%3: %4<br/>%5: %6")
    129129                                .arg(UIWizardNewVM::tr("Detected OS Type")).arg(m_strDetectedOSTypeId)
    130130                                .arg(UIWizardNewVM::tr("Detected OS Version")).arg(m_strDetectedOSVersion)
     
    143143        connect(m_pUnattendedCheckBox, &QCheckBox::toggled, this, &UIWizardNewVMPageBasicUnattended::sltUnattendedCheckBoxToggle);
    144144        m_pISOSelectorLabel = new QLabel;
     145        if (m_pISOSelectorLabel)
    145146        {
    146147            m_pISOSelectorLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
     
    148149        }
    149150        m_pISOFilePathSelector = new UIFilePathSelector;
     151        if (m_pISOFilePathSelector)
    150152        {
    151153            m_pISOFilePathSelector->setResetEnabled(false);
     
    157159        }
    158160        m_pStartHeadlessCheckBox = new QCheckBox;
    159         m_pStartHeadlessCheckBox->setEnabled(false);
    160         m_pStatusLabel = new QLabel;
    161         m_pStatusLabel->setEnabled(false);
     161        if (m_pStartHeadlessCheckBox)
     162        {
     163            m_pStartHeadlessCheckBox->setEnabled(false);
     164            m_pStatusLabel = new QLabel;
     165            m_pStatusLabel->setEnabled(false);
     166        }
     167
     168        QGridLayout *pISOSelectorLayout = new QGridLayout;
     169        if (pISOSelectorLayout)
     170        {
     171            pISOSelectorLayout->addWidget(m_pUnattendedCheckBox, 0, 0, 1, 5);
     172            pISOSelectorLayout->addWidget(m_pISOSelectorLabel, 1, 1, 1, 1);
     173            pISOSelectorLayout->addWidget(m_pISOFilePathSelector, 1, 2, 1, 4);
     174            pISOSelectorLayout->addWidget(m_pStartHeadlessCheckBox, 2, 2, 1, 1);
     175            pISOSelectorLayout->addWidget(m_pStatusLabel, 3, 2, 1, 1);
     176        }
     177
    162178        pMainLayout->addWidget(m_pLabel);
    163 
    164         QGridLayout *pISOSelectorLayout = new QGridLayout;
    165         pISOSelectorLayout->addWidget(m_pUnattendedCheckBox, 0, 0, 1, 5);
    166         pISOSelectorLayout->addWidget(m_pISOSelectorLabel, 1, 1, 1, 1);
    167         pISOSelectorLayout->addWidget(m_pISOFilePathSelector, 1, 2, 1, 4);
    168         pISOSelectorLayout->addWidget(m_pStartHeadlessCheckBox, 2, 2, 1, 1);
    169         pISOSelectorLayout->addWidget(m_pStatusLabel, 3, 2, 1, 1);
    170 
    171179        pMainLayout->addLayout(pISOSelectorLayout);
    172180        pMainLayout->addStretch();
     
    227235    {
    228236        m_pStartHeadlessCheckBox->setText(UIWizardNewVM::tr("Start VM Headless"));
    229         m_pStartHeadlessCheckBox->setToolTip(UIWizardNewVM::tr("When checked the unattended will start the virtual machine headless"));
     237        m_pStartHeadlessCheckBox->setToolTip(UIWizardNewVM::tr("When checked the unattended install will start the virtual machine headless"));
    230238    }
    231239    m_pISOFilePathSelector->setToolTip(UIWizardNewVM::tr("Please select an installation medium (ISO file) "
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