VirtualBox

Changeset 84861 in vbox


Ignore:
Timestamp:
Jun 17, 2020 10:30:14 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9515. Adding an additional page to guided new vm wizard to enable unattended install.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
4 edited
2 copied

Legend:

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

    r84790 r84861  
    681681        src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.h \
    682682        src/wizards/newvm/UIWizardNewVM.h \
     683        src/wizards/newvm/UIWizardNewVMPageBasic0.h \
    683684        src/wizards/newvm/UIWizardNewVMPageBasic1.h \
    684685        src/wizards/newvm/UIWizardNewVMPageBasic2.h \
     
    11391140        src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.cpp \
    11401141        src/wizards/newvm/UIWizardNewVM.cpp \
     1142        src/wizards/newvm/UIWizardNewVMPageBasic0.cpp \
    11411143        src/wizards/newvm/UIWizardNewVMPageBasic1.cpp \
    11421144        src/wizards/newvm/UIWizardNewVMPageBasic2.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r84595 r84861  
    598598        /* Execute wizard: */
    599599        pWizard->exec();
     600
     601
    600602        delete pWizard;
    601603    }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r82968 r84861  
    1919#include "UICommon.h"
    2020#include "UIWizardNewVM.h"
     21#include "UIWizardNewVMPageBasic0.h"
    2122#include "UIWizardNewVMPageBasic1.h"
    2223#include "UIWizardNewVMPageBasic2.h"
     
    6869        case WizardMode_Basic:
    6970        {
    70             setPage(Page1, new UIWizardNewVMPageBasic1(m_strGroup));
    71             setPage(Page2, new UIWizardNewVMPageBasic2);
    72             setPage(Page3, new UIWizardNewVMPageBasic3);
     71            setPage(Page1, new UIWizardNewVMPageBasic0);
     72            setPage(Page2, new UIWizardNewVMPageBasic1(m_strGroup));
     73            setPage(Page3, new UIWizardNewVMPageBasic2);
     74            setPage(Page4, new UIWizardNewVMPageBasic3);
    7375            break;
    7476        }
     
    456458    return strControllerName;
    457459}
     460
     461QString UIWizardNewVM::unattendedISOFilePath() const
     462{
     463    QVariant fieldValue = field("ISOFilePath");
     464    if (fieldValue.isNull() || !fieldValue.isValid() || !fieldValue.canConvert(QMetaType::QString))
     465        return QString();
     466    return fieldValue.toString();
     467}
     468
     469bool UIWizardNewVM::isUnattendedInstallEnabled() const
     470{
     471    QVariant fieldValue = field("isUnattendedEnabled");
     472    if (fieldValue.isNull() || !fieldValue.isValid() || !fieldValue.canConvert(QMetaType::Bool))
     473        return false;
     474    return fieldValue.toBool();
     475}
     476
     477bool UIWizardNewVM::startHeadless() const
     478{
     479    QVariant fieldValue = field("startHeadless");
     480    if (fieldValue.isNull() || !fieldValue.isValid() || !fieldValue.canConvert(QMetaType::Bool))
     481        return false;
     482    return fieldValue.toBool();
     483}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h

    r82968 r84861  
    4141        Page1,
    4242        Page2,
    43         Page3
     43        Page3,
     44        Page4
    4445    };
    4546
     
    7273    friend class UIWizardNewVMPageExpert;
    7374
     75    QString unattendedISOFilePath() const;
     76    bool isUnattendedInstallEnabled() const;
     77    bool startHeadless() const;
     78
     79
    7480private slots:
    7581
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic0.cpp

    r84828 r84861  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewVMPageBasic1 class implementation.
     3 * VBox Qt GUI - UIWizardNewVMPageBasic0 class implementation.
    44 */
    55
     
    1717
    1818/* Qt includes: */
    19 #include <QDir>
     19#include <QCheckBox>
     20#include <QFileInfo>
     21#include <QLabel>
    2022#include <QLineEdit>
    2123#include <QHBoxLayout>
    22 #include <QVBoxLayout>
     24#include <QGridLayout>
    2325
    2426/* GUI includes: */
    2527#include "QIRichTextLabel.h"
    2628#include "UICommon.h"
     29#include "UIFilePathSelector.h"
    2730#include "UIMessageCenter.h"
    2831#include "UINameAndSystemEditor.h"
    29 #include "UIWizardNewVMPageBasic1.h"
     32#include "UIWizardNewVMPageBasic0.h"
    3033#include "UIWizardNewVM.h"
    3134
     
    3538
    3639
    37 /* Defines some patterns to guess the right OS type. Should be in sync with
    38  * VirtualBox-settings-common.xsd in Main. The list is sorted by priority. The
    39  * first matching string found, will be used. */
    40 struct osTypePattern
     40UIWizardNewVMPage0::UIWizardNewVMPage0()
     41    : m_pUnattendedCheckBox(0)
     42    , m_pStartHeadlessCheckBox(0)
     43    , m_pISOFilePathSelector(0)
    4144{
    42     QRegExp pattern;
    43     const char *pcstId;
    44 };
    45 
    46 static const osTypePattern gs_OSTypePattern[] =
    47 {
    48     /* DOS: */
    49     { QRegExp("DOS", Qt::CaseInsensitive), "DOS" },
    50 
    51     /* Windows: */
    52     { QRegExp(  "Wi.*98",                         Qt::CaseInsensitive), "Windows98" },
    53     { QRegExp(  "Wi.*95",                         Qt::CaseInsensitive), "Windows95" },
    54     { QRegExp(  "Wi.*Me",                         Qt::CaseInsensitive), "WindowsMe" },
    55     { QRegExp( "(Wi.*NT)|(NT[-._v]*4)",           Qt::CaseInsensitive), "WindowsNT4" },
    56     { QRegExp( "NT[-._v]*3[.,]*[51x]",            Qt::CaseInsensitive), "WindowsNT3x" },
    57     /* Note: Do not automatically set WindowsXP_64 on 64-bit hosts, as Windows XP 64-bit
    58      *       is extremely rare -- most users never heard of it even. So always default to 32-bit. */
    59     { QRegExp("((Wi.*XP)|(XP)).*",                Qt::CaseInsensitive), "WindowsXP" },
    60     { QRegExp("((Wi.*2003)|(W2K3)|(Win2K3)).*64", Qt::CaseInsensitive), "Windows2003_64" },
    61     { QRegExp("((Wi.*2003)|(W2K3)|(Win2K3)).*32", Qt::CaseInsensitive), "Windows2003" },
    62     { QRegExp("((Wi.*Vis)|(Vista)).*64",          Qt::CaseInsensitive), "WindowsVista_64" },
    63     { QRegExp("((Wi.*Vis)|(Vista)).*32",          Qt::CaseInsensitive), "WindowsVista" },
    64     { QRegExp( "(Wi.*2016)|(W2K16)|(Win2K16)",    Qt::CaseInsensitive), "Windows2016_64" },
    65     { QRegExp( "(Wi.*2012)|(W2K12)|(Win2K12)",    Qt::CaseInsensitive), "Windows2012_64" },
    66     { QRegExp("((Wi.*2008)|(W2K8)|(Win2k8)).*64", Qt::CaseInsensitive), "Windows2008_64" },
    67     { QRegExp("((Wi.*2008)|(W2K8)|(Win2K8)).*32", Qt::CaseInsensitive), "Windows2008" },
    68     { QRegExp( "(Wi.*2000)|(W2K)|(Win2K)",        Qt::CaseInsensitive), "Windows2000" },
    69     { QRegExp( "(Wi.*7.*64)|(W7.*64)",            Qt::CaseInsensitive), "Windows7_64" },
    70     { QRegExp( "(Wi.*7.*32)|(W7.*32)",            Qt::CaseInsensitive), "Windows7" },
    71     { QRegExp( "(Wi.*8.*1.*64)|(W8.*64)",         Qt::CaseInsensitive), "Windows81_64" },
    72     { QRegExp( "(Wi.*8.*1.*32)|(W8.*32)",         Qt::CaseInsensitive), "Windows81" },
    73     { QRegExp( "(Wi.*8.*64)|(W8.*64)",            Qt::CaseInsensitive), "Windows8_64" },
    74     { QRegExp( "(Wi.*8.*32)|(W8.*32)",            Qt::CaseInsensitive), "Windows8" },
    75     { QRegExp( "(Wi.*10.*64)|(W10.*64)",          Qt::CaseInsensitive), "Windows10_64" },
    76     { QRegExp( "(Wi.*10.*32)|(W10.*32)",          Qt::CaseInsensitive), "Windows10" },
    77     { QRegExp(  "Wi.*3.*1",                       Qt::CaseInsensitive), "Windows31" },
    78     /* Set Windows 7 as default for "Windows". */
    79     { QRegExp(  "Wi.*64",                         Qt::CaseInsensitive), "Windows7_64" },
    80     { QRegExp(  "Wi.*32",                         Qt::CaseInsensitive), "Windows7" },
    81     /* ReactOS wants to be considered as Windows 2003 */
    82     { QRegExp(  "Reac.*",                         Qt::CaseInsensitive), "Windows2003" },
    83 
    84     /* Solaris: */
    85     { QRegExp("Sol.*11",                                                  Qt::CaseInsensitive), "Solaris11_64" },
    86     { QRegExp("((Op.*Sol)|(os20[01][0-9])|(Sol.*10)|(India)|(Neva)).*64", Qt::CaseInsensitive), "OpenSolaris_64" },
    87     { QRegExp("((Op.*Sol)|(os20[01][0-9])|(Sol.*10)|(India)|(Neva)).*32", Qt::CaseInsensitive), "OpenSolaris" },
    88     { QRegExp("Sol.*64",                                                  Qt::CaseInsensitive), "Solaris_64" },
    89     { QRegExp("Sol.*32",                                                  Qt::CaseInsensitive), "Solaris" },
    90 
    91     /* OS/2: */
    92     { QRegExp( "OS[/|!-]{,1}2.*W.*4.?5",    Qt::CaseInsensitive), "OS2Warp45" },
    93     { QRegExp( "OS[/|!-]{,1}2.*W.*4",       Qt::CaseInsensitive), "OS2Warp4" },
    94     { QRegExp( "OS[/|!-]{,1}2.*W",          Qt::CaseInsensitive), "OS2Warp3" },
    95     { QRegExp("(OS[/|!-]{,1}2.*e)|(eCS.*)", Qt::CaseInsensitive), "OS2eCS" },
    96     { QRegExp( "OS[/|!-]{,1}2",             Qt::CaseInsensitive), "OS2" },
    97     { QRegExp( "eComS.*",                   Qt::CaseInsensitive), "OS2eCS" },
    98 
    99     /* Other: Must come before Ubuntu/Maverick and before Linux??? */
    100     { QRegExp("QN", Qt::CaseInsensitive), "QNX" },
    101 
    102     /* Mac OS X: Must come before Ubuntu/Maverick and before Linux: */
    103     { QRegExp("((mac.*10[.,]{0,1}4)|(os.*x.*10[.,]{0,1}4)|(mac.*ti)|(os.*x.*ti)|(Tig)).64",     Qt::CaseInsensitive), "MacOS_64" },
    104     { QRegExp("((mac.*10[.,]{0,1}4)|(os.*x.*10[.,]{0,1}4)|(mac.*ti)|(os.*x.*ti)|(Tig)).32",     Qt::CaseInsensitive), "MacOS" },
    105     { QRegExp("((mac.*10[.,]{0,1}5)|(os.*x.*10[.,]{0,1}5)|(mac.*leo)|(os.*x.*leo)|(Leop)).*64", Qt::CaseInsensitive), "MacOS_64" },
    106     { QRegExp("((mac.*10[.,]{0,1}5)|(os.*x.*10[.,]{0,1}5)|(mac.*leo)|(os.*x.*leo)|(Leop)).*32", Qt::CaseInsensitive), "MacOS" },
    107     { QRegExp("((mac.*10[.,]{0,1}6)|(os.*x.*10[.,]{0,1}6)|(mac.*SL)|(os.*x.*SL)|(Snow L)).*64", Qt::CaseInsensitive), "MacOS106_64" },
    108     { QRegExp("((mac.*10[.,]{0,1}6)|(os.*x.*10[.,]{0,1}6)|(mac.*SL)|(os.*x.*SL)|(Snow L)).*32", Qt::CaseInsensitive), "MacOS106" },
    109     { QRegExp( "(mac.*10[.,]{0,1}7)|(os.*x.*10[.,]{0,1}7)|(mac.*ML)|(os.*x.*ML)|(Mount)",       Qt::CaseInsensitive), "MacOS108_64" },
    110     { QRegExp( "(mac.*10[.,]{0,1}8)|(os.*x.*10[.,]{0,1}8)|(Lion)",                              Qt::CaseInsensitive), "MacOS107_64" },
    111     { QRegExp( "(mac.*10[.,]{0,1}9)|(os.*x.*10[.,]{0,1}9)|(mac.*mav)|(os.*x.*mav)|(Mavericks)", Qt::CaseInsensitive), "MacOS109_64" },
    112     { QRegExp( "(mac.*yos)|(os.*x.*yos)|(Yosemite)",                                            Qt::CaseInsensitive), "MacOS1010_64" },
    113     { QRegExp( "(mac.*cap)|(os.*x.*capit)|(Capitan)",                                           Qt::CaseInsensitive), "MacOS1011_64" },
    114     { QRegExp( "(mac.*hig)|(os.*x.*high.*sierr)|(High Sierra)",                                 Qt::CaseInsensitive), "MacOS1013_64" },
    115     { QRegExp( "(mac.*sie)|(os.*x.*sierr)|(Sierra)",                                            Qt::CaseInsensitive), "MacOS1012_64" },
    116     { QRegExp("((Mac)|(Tig)|(Leop)|(Yose)|(os[ ]*x)).*64",                                      Qt::CaseInsensitive), "MacOS_64" },
    117     { QRegExp("((Mac)|(Tig)|(Leop)|(Yose)|(os[ ]*x)).*32",                                      Qt::CaseInsensitive), "MacOS" },
    118 
    119     /* Code names for Linux distributions: */
    120     { QRegExp("((bianca)|(cassandra)|(celena)|(daryna)|(elyssa)|(felicia)|(gloria)|(helena)|(isadora)|(julia)|(katya)|(lisa)|(maya)|(nadia)|(olivia)|(petra)|(qiana)|(rebecca)|(rafaela)|(rosa)).*64", Qt::CaseInsensitive), "Ubuntu_64" },
    121     { QRegExp("((bianca)|(cassandra)|(celena)|(daryna)|(elyssa)|(felicia)|(gloria)|(helena)|(isadora)|(julia)|(katya)|(lisa)|(maya)|(nadia)|(olivia)|(petra)|(qiana)|(rebecca)|(rafaela)|(rosa)).*32", Qt::CaseInsensitive), "Ubuntu" },
    122     { QRegExp("((edgy)|(feisty)|(gutsy)|(hardy)|(intrepid)|(jaunty)|(karmic)|(lucid)|(maverick)|(natty)|(oneiric)|(precise)|(quantal)|(raring)|(saucy)|(trusty)|(utopic)|(vivid)|(wily)|(xenial)|(yakkety)|(zesty)).*64", Qt::CaseInsensitive), "Ubuntu_64" },
    123     { QRegExp("((edgy)|(feisty)|(gutsy)|(hardy)|(intrepid)|(jaunty)|(karmic)|(lucid)|(maverick)|(natty)|(oneiric)|(precise)|(quantal)|(raring)|(saucy)|(trusty)|(utopic)|(vivid)|(wily)|(xenial)|(yakkety)|(zesty)).*32", Qt::CaseInsensitive), "Ubuntu" },
    124     { QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(stretch)|(buster)|(sid)).*64", Qt::CaseInsensitive), "Debian_64" },
    125     { QRegExp("((sarge)|(etch)|(lenny)|(squeeze)|(wheezy)|(jessie)|(stretch)|(buster)|(sid)).*32", Qt::CaseInsensitive), "Debian" },
    126     { QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*64", Qt::CaseInsensitive), "Fedora_64" },
    127     { QRegExp("((moonshine)|(werewolf)|(sulphur)|(cambridge)|(leonidas)|(constantine)|(goddard)|(laughlin)|(lovelock)|(verne)|(beefy)|(spherical)).*32", Qt::CaseInsensitive), "Fedora" },
    128 
    129     /* Regular names of Linux distributions: */
    130     { QRegExp("Arc.*64",                           Qt::CaseInsensitive), "ArchLinux_64" },
    131     { QRegExp("Arc.*32",                           Qt::CaseInsensitive), "ArchLinux" },
    132     { QRegExp("Deb.*64",                           Qt::CaseInsensitive), "Debian_64" },
    133     { QRegExp("Deb.*32",                           Qt::CaseInsensitive), "Debian" },
    134     { QRegExp("((SU)|(Nov)|(SLE)).*64",            Qt::CaseInsensitive), "OpenSUSE_64" },
    135     { QRegExp("((SU)|(Nov)|(SLE)).*32",            Qt::CaseInsensitive), "OpenSUSE" },
    136     { QRegExp("Fe.*64",                            Qt::CaseInsensitive), "Fedora_64" },
    137     { QRegExp("Fe.*32",                            Qt::CaseInsensitive), "Fedora" },
    138     { QRegExp("((Gen)|(Sab)).*64",                 Qt::CaseInsensitive), "Gentoo_64" },
    139     { QRegExp("((Gen)|(Sab)).*32",                 Qt::CaseInsensitive), "Gentoo" },
    140     { QRegExp("((Man)|(Mag)).*64",                 Qt::CaseInsensitive), "Mandriva_64" },
    141     { QRegExp("((Man)|(Mag)).*32",                 Qt::CaseInsensitive), "Mandriva" },
    142     { QRegExp("((Red)|(rhel)|(cen)).*64",          Qt::CaseInsensitive), "RedHat_64" },
    143     { QRegExp("((Red)|(rhel)|(cen)).*32",          Qt::CaseInsensitive), "RedHat" },
    144     { QRegExp("Tur.*64",                           Qt::CaseInsensitive), "Turbolinux_64" },
    145     { QRegExp("Tur.*32",                           Qt::CaseInsensitive), "Turbolinux" },
    146     { QRegExp("(Ub)|(Min).*64",                    Qt::CaseInsensitive), "Ubuntu_64" },
    147     { QRegExp("(Ub)|(Min).*32",                    Qt::CaseInsensitive), "Ubuntu" },
    148     { QRegExp("Xa.*64",                            Qt::CaseInsensitive), "Xandros_64" },
    149     { QRegExp("Xa.*32",                            Qt::CaseInsensitive), "Xandros" },
    150     { QRegExp("((Or)|(oel)|(ol)).*64",             Qt::CaseInsensitive), "Oracle_64" },
    151     { QRegExp("((Or)|(oel)|(ol)).*32",             Qt::CaseInsensitive), "Oracle" },
    152     { QRegExp("Knoppix",                           Qt::CaseInsensitive), "Linux26" },
    153     { QRegExp("Dsl",                               Qt::CaseInsensitive), "Linux24" },
    154     { QRegExp("((Lin)|(lnx)).*2.?2",               Qt::CaseInsensitive), "Linux22" },
    155     { QRegExp("((Lin)|(lnx)).*2.?4.*64",           Qt::CaseInsensitive), "Linux24_64" },
    156     { QRegExp("((Lin)|(lnx)).*2.?4.*32",           Qt::CaseInsensitive), "Linux24" },
    157     { QRegExp("((((Lin)|(lnx)).*2.?6)|(LFS)).*64", Qt::CaseInsensitive), "Linux26_64" },
    158     { QRegExp("((((Lin)|(lnx)).*2.?6)|(LFS)).*32", Qt::CaseInsensitive), "Linux26" },
    159     { QRegExp("((Lin)|(lnx)).*64",                 Qt::CaseInsensitive), "Linux26_64" },
    160     { QRegExp("((Lin)|(lnx)).*32",                 Qt::CaseInsensitive), "Linux26" },
    161 
    162     /* Other: */
    163     { QRegExp("L4",                   Qt::CaseInsensitive), "L4" },
    164     { QRegExp("((Fr.*B)|(fbsd)).*64", Qt::CaseInsensitive), "FreeBSD_64" },
    165     { QRegExp("((Fr.*B)|(fbsd)).*32", Qt::CaseInsensitive), "FreeBSD" },
    166     { QRegExp("Op.*B.*64",            Qt::CaseInsensitive), "OpenBSD_64" },
    167     { QRegExp("Op.*B.*32",            Qt::CaseInsensitive), "OpenBSD" },
    168     { QRegExp("Ne.*B.*64",            Qt::CaseInsensitive), "NetBSD_64" },
    169     { QRegExp("Ne.*B.*32",            Qt::CaseInsensitive), "NetBSD" },
    170     { QRegExp("Net",                  Qt::CaseInsensitive), "Netware" },
    171     { QRegExp("Rocki",                Qt::CaseInsensitive), "JRockitVE" },
    172     { QRegExp("bs[23]{0,1}-",         Qt::CaseInsensitive), "VBoxBS_64" }, /* bootsector tests */
    173     { QRegExp("Ot",                   Qt::CaseInsensitive), "Other" },
    174 };
    175 
    176 UIWizardNewVMPage1::UIWizardNewVMPage1(const QString &strGroup)
    177     : m_pNameAndSystemEditor(0)
    178     , m_strGroup(strGroup)
    179 
    180 {
    181     CHost host = uiCommon().host();
    182     m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
    183     m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);
    18445}
    18546
    186 void UIWizardNewVMPage1::onNameChanged(QString strNewName)
     47QString UIWizardNewVMPage0::ISOFilePath() const
    18748{
    188     /* Do not forget about achitecture bits, if not yet specified: */
    189     if (!strNewName.contains("32") && !strNewName.contains("64"))
    190         strNewName += ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode ? "64" : "32";
    191 
    192     /* Search for a matching OS type based on the string the user typed already. */
    193     for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)
    194         if (strNewName.contains(gs_OSTypePattern[i].pattern))
    195         {
    196             if (m_pNameAndSystemEditor)
    197             {
    198                 m_pNameAndSystemEditor->blockSignals(true);
    199                 m_pNameAndSystemEditor->setType(uiCommon().vmGuestOSType(gs_OSTypePattern[i].pcstId));
    200                 m_pNameAndSystemEditor->blockSignals(false);
    201             }
    202             break;
    203         }
     49    if (!m_pISOFilePathSelector)
     50        return QString();
     51    return m_pISOFilePathSelector->path();
    20452}
    20553
    206 void UIWizardNewVMPage1::onOsTypeChanged()
     54bool UIWizardNewVMPage0::isUnattendedEnabled() const
    20755{
    208     /* If the user manually edited the OS type, we didn't want our automatic OS type guessing anymore.
    209      * So simply disconnect the text-edit signal. */
    210     if (m_pNameAndSystemEditor)
    211         m_pNameAndSystemEditor->disconnect(SIGNAL(sigNameChanged(const QString &)), thisImp(), SLOT(sltNameChanged(const QString &)));
     56    if (!m_pUnattendedCheckBox)
     57        return false;
     58    return m_pUnattendedCheckBox->isChecked();
    21259}
    21360
    214 void UIWizardNewVMPage1::composeMachineFilePath()
     61bool UIWizardNewVMPage0::startHeadless() const
    21562{
    216     if (!m_pNameAndSystemEditor)
    217         return;
    218     if (m_pNameAndSystemEditor->name().isEmpty() || m_pNameAndSystemEditor->path().isEmpty())
    219         return;
    220     /* Get VBox: */
    221     CVirtualBox vbox = uiCommon().virtualBox();
    222 
    223     /* Compose machine filename: */
    224     m_strMachineFilePath = vbox.ComposeMachineFilename(m_pNameAndSystemEditor->name(),
    225                                                        m_strGroup,
    226                                                        QString(),
    227                                                        m_pNameAndSystemEditor->path());
    228     /* Compose machine folder/basename: */
    229     const QFileInfo fileInfo(m_strMachineFilePath);
    230     m_strMachineFolder = fileInfo.absolutePath();
    231     m_strMachineBaseName = fileInfo.completeBaseName();
     63    if (!m_pStartHeadlessCheckBox)
     64        return false;
     65    return m_pStartHeadlessCheckBox->isChecked();
    23266}
    23367
    234 bool UIWizardNewVMPage1::createMachineFolder()
    235 {
    236     if (!m_pNameAndSystemEditor)
    237         return false;
    238     /* Cleanup previosly created folder if any: */
    239     if (!cleanupMachineFolder())
    240     {
    241         msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp());
    242         return false;
    243     }
    244 
    245     composeMachineFilePath();
    246 
    247     /* Check if the folder already exists and check if it has been created by this wizard */
    248     if (QDir(m_strMachineFolder).exists())
    249     {
    250         /* Looks like we have already created this folder for this run of the wizard. Just return */
    251         if (m_strCreatedFolder == m_strMachineFolder)
    252             return true;
    253         /* The folder is there but not because of this wizard. Avoid overwriting a existing machine's folder */
    254         else
    255         {
    256             msgCenter().cannotRewriteMachineFolder(m_strMachineFolder, thisImp());
    257             return false;
    258         }
    259     }
    260 
    261     /* Try to create new folder (and it's predecessors): */
    262     bool fMachineFolderCreated = QDir().mkpath(m_strMachineFolder);
    263     if (!fMachineFolderCreated)
    264     {
    265         msgCenter().cannotCreateMachineFolder(m_strMachineFolder, thisImp());
    266         return false;
    267     }
    268     m_strCreatedFolder = m_strMachineFolder;
    269     return true;
    270 }
    271 
    272 bool UIWizardNewVMPage1::cleanupMachineFolder(bool fWizardCancel /* = false */)
    273 {
    274     /* Make sure folder was previosly created: */
    275     if (m_strCreatedFolder.isEmpty())
    276         return true;
    277     /* Clean this folder if the machine folder has been changed by the user or we are cancelling the wizard: */
    278     if (m_strCreatedFolder != m_strMachineFolder || fWizardCancel)
    279     {
    280         /* Try to cleanup folder (and it's predecessors): */
    281         bool fMachineFolderRemoved = QDir().rmpath(m_strCreatedFolder);
    282         /* Reset machine folder value: */
    283         if (fMachineFolderRemoved)
    284             m_strCreatedFolder = QString();
    285         /* Return cleanup result: */
    286         return fMachineFolderRemoved;
    287     }
    288     return true;
    289 }
    290 
    291 QString UIWizardNewVMPage1::machineFilePath() const
    292 {
    293     return m_strMachineFilePath;
    294 }
    295 
    296 void UIWizardNewVMPage1::setMachineFilePath(const QString &strMachineFilePath)
    297 {
    298     m_strMachineFilePath = strMachineFilePath;
    299 }
    300 
    301 QString UIWizardNewVMPage1::machineFolder() const
    302 {
    303     return m_strMachineFolder;
    304 }
    305 
    306 void UIWizardNewVMPage1::setMachineFolder(const QString &strMachineFolder)
    307 {
    308     m_strMachineFolder = strMachineFolder;
    309 }
    310 
    311 QString UIWizardNewVMPage1::machineBaseName() const
    312 {
    313     return m_strMachineBaseName;
    314 }
    315 
    316 void UIWizardNewVMPage1::setMachineBaseName(const QString &strMachineBaseName)
    317 {
    318     m_strMachineBaseName = strMachineBaseName;
    319 }
    320 
    321 UIWizardNewVMPageBasic1::UIWizardNewVMPageBasic1(const QString &strGroup)
    322     : UIWizardNewVMPage1(strGroup)
     68UIWizardNewVMPageBasic0::UIWizardNewVMPageBasic0()
     69    : UIWizardNewVMPage0()
    32370{
    32471    /* Create widgets: */
     
    32673    {
    32774        m_pLabel = new QIRichTextLabel(this);
    328         m_pNameAndSystemEditor = new UINameAndSystemEditor(this, true, true, true);
     75        m_pUnattendedCheckBox = new QCheckBox;
     76        connect(m_pUnattendedCheckBox, &QCheckBox::toggled, this, &UIWizardNewVMPageBasic0::sltUnattendedCheckBoxToggle);
     77        m_pISOSelectorLabel = new QLabel;
     78        {
     79            m_pISOSelectorLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
     80            m_pISOSelectorLabel->setEnabled(false);
     81        }
     82        m_pISOFilePathSelector = new UIFilePathSelector;
     83        {
     84            m_pISOFilePathSelector->setResetEnabled(false);
     85            m_pISOFilePathSelector->setMode(UIFilePathSelector::Mode_File_Open);
     86            m_pISOFilePathSelector->setFileDialogFilters("*.iso *.ISO");
     87            m_pISOFilePathSelector->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
     88            m_pISOFilePathSelector->setEnabled(false);
     89            connect(m_pISOFilePathSelector, &UIFilePathSelector::pathChanged, this, &UIWizardNewVMPageBasic0::sltPathChanged);
     90        }
     91        m_pStartHeadlessCheckBox = new QCheckBox;
     92        {
     93            m_pStartHeadlessCheckBox->setEnabled(false);
     94        }
    32995        pMainLayout->addWidget(m_pLabel);
    330         pMainLayout->addWidget(m_pNameAndSystemEditor);
     96
     97        QGridLayout *pISOSelectorLayout = new QGridLayout;
     98        pISOSelectorLayout->addWidget(m_pUnattendedCheckBox, 0, 0, 1, 5);
     99        pISOSelectorLayout->addWidget(m_pISOSelectorLabel, 1, 1, 1, 1);
     100        pISOSelectorLayout->addWidget(m_pISOFilePathSelector, 1, 2, 1, 4);
     101        pISOSelectorLayout->addWidget(m_pStartHeadlessCheckBox, 2, 2, 1, 5);
     102
     103        pMainLayout->addLayout(pISOSelectorLayout);
    331104        pMainLayout->addStretch();
    332105    }
    333106
    334     /* Setup connections: */
    335     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged, this, &UIWizardNewVMPageBasic1::sltNameChanged);
    336     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMPageBasic1::sltPathChanged);
    337     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMPageBasic1::sltOsTypeChanged);
    338107
    339108    /* Register fields: */
    340     registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
    341     registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
    342     registerField("machineFilePath", this, "machineFilePath");
    343     registerField("machineFolder", this, "machineFolder");
    344     registerField("machineBaseName", this, "machineBaseName");
     109    registerField("ISOFilePath", this, "ISOFilePath");
     110    registerField("isUnattendedEnabled", this, "isUnattendedEnabled");
     111    registerField("startHeadless", this, "startHeadless");
    345112}
    346113
    347 void UIWizardNewVMPageBasic1::sltNameChanged(const QString &strNewName)
     114bool UIWizardNewVMPageBasic0::isComplete() const
    348115{
    349     /* Call to base-class: */
    350     onNameChanged(strNewName);
    351     composeMachineFilePath();
     116    bool fISOFileOK = checkISOFile();
     117    //emit completeChanged();
     118    return fISOFileOK;
    352119}
    353120
    354 void UIWizardNewVMPageBasic1::sltPathChanged(const QString &strNewPath)
     121void UIWizardNewVMPageBasic0::sltUnattendedCheckBoxToggle(bool fEnabled)
    355122{
    356     Q_UNUSED(strNewPath);
    357     composeMachineFilePath();
     123    if (m_pISOSelectorLabel)
     124        m_pISOSelectorLabel->setEnabled(fEnabled);
     125    if (m_pISOFilePathSelector)
     126        m_pISOFilePathSelector->setEnabled(fEnabled);
     127    if (m_pStartHeadlessCheckBox)
     128        m_pStartHeadlessCheckBox->setEnabled(fEnabled);
     129    emit completeChanged();
    358130}
    359131
    360 void UIWizardNewVMPageBasic1::sltOsTypeChanged()
     132void UIWizardNewVMPageBasic0::sltPathChanged(const QString &strPath)
    361133{
    362     /* Call to base-class: */
    363     onOsTypeChanged();
     134    Q_UNUSED(strPath);
     135    emit completeChanged();
    364136}
    365137
    366 void UIWizardNewVMPageBasic1::retranslateUi()
     138void UIWizardNewVMPageBasic0::retranslateUi()
    367139{
    368140    /* Translate page: */
    369     setTitle(UIWizardNewVM::tr("Name and operating system"));
     141    setTitle(UIWizardNewVM::tr("Unattended Guest OS Install"));
    370142
    371143    /* Translate widgets: */
    372     m_pLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new virtual machine "
    373                                         "and select the type of operating system you intend to install on it. "
    374                                         "The name you choose will be used throughout VirtualBox "
    375                                         "to identify this machine."));
     144    m_pLabel->setText(UIWizardNewVM::tr("You can enable the unattended (automated) guest OS install "
     145                                        "and select an installation medium. The guest OS will be "
     146                                        "installed after this window is closed. "));
     147    m_pUnattendedCheckBox->setText(UIWizardNewVM::tr("Enable unattended guest OS Install"));
     148    m_pISOSelectorLabel->setText(UIWizardNewVM::tr("ISO:"));
     149    if (m_pStartHeadlessCheckBox)
     150    {
     151        m_pStartHeadlessCheckBox->setText(UIWizardNewVM::tr("Start VM Headless"));
     152        m_pStartHeadlessCheckBox->setToolTip(UIWizardNewVM::tr("When checked the unattended will start the virtual machine headless"));
     153    }
    376154}
    377155
    378 void UIWizardNewVMPageBasic1::initializePage()
     156bool UIWizardNewVMPageBasic0::checkISOFile() const
     157{
     158    if (m_pUnattendedCheckBox && m_pUnattendedCheckBox->isChecked())
     159    {
     160        QString strISOFilePath = m_pISOFilePathSelector ? m_pISOFilePathSelector->path() : QString();
     161        if (!QFileInfo(strISOFilePath).exists())
     162            return false;
     163    }
     164    return true;
     165}
     166
     167void UIWizardNewVMPageBasic0::initializePage()
    379168{
    380169    /* Translate page: */
    381170    retranslateUi();
    382     if (m_pNameAndSystemEditor)
    383         m_pNameAndSystemEditor->setFocus();
     171    if (m_pUnattendedCheckBox)
     172        m_pUnattendedCheckBox->setFocus();
    384173}
    385174
    386 void UIWizardNewVMPageBasic1::cleanupPage()
     175void UIWizardNewVMPageBasic0::cleanupPage()
    387176{
    388     /* Cleanup: */
    389     cleanupMachineFolder();
    390     /* Call to base-class: */
    391177    UIWizardPage::cleanupPage();
    392178}
    393179
    394 bool UIWizardNewVMPageBasic1::validatePage()
     180bool UIWizardNewVMPageBasic0::validatePage()
    395181{
    396     /* Try to create machine folder: */
    397     return createMachineFolder();
     182    return checkISOFile();
    398183}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic0.h

    r84828 r84861  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewVMPageBasic1 class declaration.
     3 * VBox Qt GUI - UIWizardNewVMPageBasic0 class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic1_h
    19 #define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic1_h
     18#ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic0_h
     19#define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic0_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2828class UINameAndSystemEditor;
    2929class QIRichTextLabel;
     30class QCheckBox;
     31class QLabel;
     32class UIFilePathSelector;
    3033
    3134/* 1st page of the New Virtual Machine wizard (base part): */
    32 class UIWizardNewVMPage1 : public UIWizardPageBase
     35class UIWizardNewVMPage0 : public UIWizardPageBase
    3336{
    3437protected:
    3538
    3639    /* Constructor: */
    37     UIWizardNewVMPage1(const QString &strGroup);
     40    UIWizardNewVMPage0();
    3841
    39     /* Handlers: */
    40     void onNameChanged(QString strNewName);
    41     void onOsTypeChanged();
     42    QString ISOFilePath() const;
     43    bool isUnattendedEnabled() const;
     44    bool startHeadless() const;
    4245
    43     bool createMachineFolder();
    44     /** Removes a previously created folder (if exists) before creating a new one.
    45      *  used during page cleanup and new folder creation. Called upon page Next/Back and
    46      *  wizard cancel */
    47     bool cleanupMachineFolder(bool fWizardCancel = false);
    48 
    49     QString machineFilePath() const;
    50     void setMachineFilePath(const QString &strMachineFilePath);
    51 
    52     QString machineFolder() const;
    53     void setMachineFolder(const QString &strMachineFolder);
    54 
    55     QString machineBaseName() const;
    56     void setMachineBaseName(const QString &strMachineBaseName);
    57 
    58     /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */
    59     void composeMachineFilePath();
    60 
    61     /** Provides a path selector and a line edit field for path and name entry. */
    62     UINameAndSystemEditor *m_pNameAndSystemEditor;
     46    QCheckBox *m_pUnattendedCheckBox;
     47    QCheckBox *m_pStartHeadlessCheckBox;
     48    QLabel *m_pISOSelectorLabel;
     49    UIFilePathSelector *m_pISOFilePathSelector;
    6350
    6451private:
    6552
    66     /** Full path (including the file name) of the machine's configuration file. */
    67     QString m_strMachineFilePath;
    68     /** Path of the folder hosting the machine's configuration file. Generated from m_strMachineFilePath. */
    69     QString m_strMachineFolder;
    70     /** Path of the folder created by this wizard page. Used to remove previously created
    71      *  folder. see cleanupMachineFolder();*/
    72     QString m_strCreatedFolder;
    73     /** Base name of the machine is generated from the m_strMachineFilePath. */
    74     QString m_strMachineBaseName;
    75 
    76 
    77     QString m_strGroup;
    78     bool m_fSupportsHWVirtEx;
    79     bool m_fSupportsLongMode;
    8053    friend class UIWizardNewVM;
    8154};
    8255
    8356/* 1st page of the New Virtual Machine wizard (basic extension): */
    84 class UIWizardNewVMPageBasic1 : public UIWizardPage, public UIWizardNewVMPage1
     57class UIWizardNewVMPageBasic0 : public UIWizardPage, public UIWizardNewVMPage0
    8558{
    8659    Q_OBJECT;
    87     Q_PROPERTY(QString machineFilePath READ machineFilePath WRITE setMachineFilePath);
    88     Q_PROPERTY(QString machineFolder READ machineFolder WRITE setMachineFolder);
    89     Q_PROPERTY(QString machineBaseName READ machineBaseName WRITE setMachineBaseName);
     60    Q_PROPERTY(QString ISOFilePath READ ISOFilePath);
     61    Q_PROPERTY(bool isUnattendedEnabled READ isUnattendedEnabled);
     62    Q_PROPERTY(bool startHeadless READ startHeadless);
    9063
    9164public:
    9265
    9366    /* Constructor: */
    94     UIWizardNewVMPageBasic1(const QString &strGroup);
     67    UIWizardNewVMPageBasic0();
     68    virtual bool isComplete() const; /* override */
    9569
    9670protected:
     
    10175private slots:
    10276
    103     /* Handlers: */
    104     void sltNameChanged(const QString &strNewText);
    105     void sltPathChanged(const QString &strNewPath);
    106     void sltOsTypeChanged();
     77    void sltUnattendedCheckBoxToggle(bool fEnabled);
     78    void sltPathChanged(const QString &strPath);
    10779
    10880private:
     81
     82    /** Returns false if user selects unattended install and does not provide a valid ISO file path. Else returns true. */
     83    bool checkISOFile() const;
    10984
    11085    /* Translation stuff: */
     
    12297};
    12398
    124 #endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic1_h */
     99#endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageBasic0_h */
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