VirtualBox

Changeset 90003 in vbox


Ignore:
Timestamp:
Jul 2, 2021 3:03:13 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9996: Initial overhaul of the new vm wizard code.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
6 edited
8 moved

Legend:

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

    r89960 r90003  
    656656        src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.h \
    657657        src/wizards/newvm/UIWizardNewVM.h \
    658         src/wizards/newvm/UIWizardNewVMPageNameOSType.h \
    659         src/wizards/newvm/UIWizardNewVMPageUnattended.h \
    660         src/wizards/newvm/UIWizardNewVMPageHardware.h \
    661         src/wizards/newvm/UIWizardNewVMPageDisk.h \
     658        src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.h \
     659        src/wizards/newvm/UIWizardNewVMUnattendedPageBasic.h \
     660        src/wizards/newvm/UIWizardNewVMHardwarePageBasic.h \
     661        src/wizards/newvm/UIWizardNewVMDiskPageBasic.h \
    662662        src/wizards/newvm/UIWizardNewVMPageExpert.h \
    663663        src/wizards/clonevm/UIWizardCloneVM.h \
     
    11531153        src/wizards/newcloudvm/UIWizardNewCloudVMPageExpert.cpp \
    11541154        src/wizards/newvm/UIWizardNewVM.cpp \
    1155         src/wizards/newvm/UIWizardNewVMPageNameOSType.cpp \
    1156         src/wizards/newvm/UIWizardNewVMPageUnattended.cpp \
    1157         src/wizards/newvm/UIWizardNewVMPageHardware.cpp \
    1158         src/wizards/newvm/UIWizardNewVMPageDisk.cpp \
     1155        src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.cpp \
     1156        src/wizards/newvm/UIWizardNewVMUnattendedPageBasic.cpp \
     1157        src/wizards/newvm/UIWizardNewVMHardwarePageBasic.cpp \
     1158        src/wizards/newvm/UIWizardNewVMDiskPageBasic.cpp \
    11591159        src/wizards/newvm/UIWizardNewVMPageExpert.cpp \
    11601160        src/wizards/clonevm/UIWizardCloneVM.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r89999 r90003  
    957957void UIVirtualBoxManager::sltOpenNewMachineWizard()
    958958{
     959#if 0
    959960    /* Lock the actions preventing cascade calls: */
    960961    UIQObjectPropertySetter guardBlock(QList<QObject*>() << actionPool()->action(UIActionIndexMN_M_Welcome_S_New)
     
    10131014        delete pWizard;
    10141015    }
     1016#endif
    10151017}
    10161018
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp

    r89914 r90003  
    2323#include "UICommon.h"
    2424#include "UIWizardNewVM.h"
    25 #include "UIWizardNewVMPageNameOSType.h"
    26 #include "UIWizardNewVMPageUnattended.h"
    27 #include "UIWizardNewVMPageHardware.h"
    28 #include "UIWizardNewVMPageDisk.h"
     25#include "UIWizardNewVMNameOSTypePageBasic.h"
     26#include "UIWizardNewVMUnattendedPageBasic.h"
     27#include "UIWizardNewVMHardwarePageBasic.h"
     28#include "UIWizardNewVMDiskPageBasic.h"
    2929#include "UIWizardNewVMPageExpert.h"
    3030#include "UIMessageCenter.h"
     
    5151}
    5252
    53 UIWizardNewVM::UIWizardNewVM(QWidget *pParent, const QString &strGroup /* = QString() */)
    54     : UIWizard(pParent, WizardType_NewVM)
     53UIWizardNewVM::UIWizardNewVM(QWidget *pParent, const QString &strGroup /* = QString() */,
     54                             WizardMode enmMode /* = WizardMode_Auto */)
     55    : UINativeWizard(pParent, WizardType_NewCloudVM, enmMode)
    5556    , m_strGroup(strGroup)
    5657    , m_iIDECount(0)
     
    6364#ifndef VBOX_WS_MAC
    6465    /* Assign watermark: */
    65     assignWatermark(":/wizard_new_welcome.png");
     66    setPixmapName(":/wizard_new_welcome.png");
    6667#else /* VBOX_WS_MAC */
    6768    /* Assign background image: */
    68     assignBackground(":/wizard_new_welcome_bg.png");
     69    setPixmapName(":/wizard_new_welcome_bg.png");
    6970#endif /* VBOX_WS_MAC */
    7071    /* Register classes: */
     
    7677void UIWizardNewVM::prepare()
    7778{
    78     enableHelpButton("gui-createvm");
    79     /* Create corresponding pages: */
     79    // enableHelpButton("gui-createvm");
     80    // /* Create corresponding pages: */
     81    // switch (mode())
     82    // {
     83    //     case WizardMode_Basic:
     84    //     {
     85    //         // setPage(Page1, new UIWizardNewVMPageNameOSType(m_strGroup));
     86    //         // setPage(Page2, new UIWizardNewVMPageUnattended);
     87    //         // setPage(Page3, new UIWizardNewVMPageHardware);
     88    //         // setPage(Page4, new UIWizardNewVMPageDisk);
     89
     90    //         // setStartId(Page1);
     91    //         break;
     92    //     }
     93    //     case WizardMode_Expert:
     94    //     {
     95    //         setPage(PageExpert, new UIWizardNewVMPageExpert(m_strGroup));
     96    //         break;
     97    //     }
     98    //     default:
     99    //     {
     100    //         AssertMsgFailed(("Invalid mode: %d", mode()));
     101    //         break;
     102    //     }
     103    // }
     104    // /* Call to base-class: */
     105    // UIWizard::prepare();
     106}
     107
     108void UIWizardNewVM::populatePages()
     109{
    80110    switch (mode())
    81111    {
    82112        case WizardMode_Basic:
    83113        {
    84             setPage(Page1, new UIWizardNewVMPageNameOSType(m_strGroup));
    85             setPage(Page2, new UIWizardNewVMPageUnattended);
    86             setPage(Page3, new UIWizardNewVMPageHardware);
    87             setPage(Page4, new UIWizardNewVMPageDisk);
    88 
    89             setStartId(Page1);
     114            addPage(new UIWizardNewVMNameOSTypePageBasic(m_strGroup));
     115            addPage(new UIWizardNewVMUnattendedPageBasic);
     116            addPage(new UIWizardNewVMHardwarePageBasic);
     117            addPage(new UIWizardNewVMDiskPageBasic);
    90118            break;
    91119        }
    92120        case WizardMode_Expert:
    93121        {
    94             setPage(PageExpert, new UIWizardNewVMPageExpert(m_strGroup));
     122            // addPage(new UIWizardNewCloudVMPageExpert(m_fFullWizard));
    95123            break;
    96124        }
     
    101129        }
    102130    }
    103     /* Call to base-class: */
    104     UIWizard::prepare();
    105131}
    106132
    107133bool UIWizardNewVM::createVM()
    108134{
    109     /* Get VBox object: */
    110     CVirtualBox vbox = uiCommon().virtualBox();
    111 
    112     /* OS type: */
    113     CGuestOSType type = field("type").value<CGuestOSType>();
    114     QString strTypeId = type.GetId();
    115 
    116     /* Create virtual machine: */
    117     if (m_machine.isNull())
    118     {
    119         QVector<QString> groups;
    120         if (!m_strGroup.isEmpty())
    121             groups << m_strGroup;
    122         m_machine = vbox.CreateMachine(field("machineFilePath").toString(),
    123                                        field("name").toString(),
    124                                        groups, strTypeId, QString());
    125         if (!vbox.isOk())
    126         {
    127             msgCenter().cannotCreateMachine(vbox, this);
    128             return false;
    129         }
    130 
    131         /* The First RUN Wizard is to be shown:
    132          * 1. if we don't attach any virtual hard-drive
    133          * 2. or attach a new (empty) one.
    134          * 3. and if the unattended install is not enabled
    135          * 4. User did not select an ISO image file
    136          * Usually we are assigning extra-data values through UIExtraDataManager,
    137          * but in that special case VM was not registered yet, so UIExtraDataManager is unaware of it: */
    138         if (ISOFilePath().isEmpty() &&
    139             !isUnattendedEnabled() &&
    140             !m_virtualDisk.isNull())
    141             m_machine.SetExtraData(GUI_FirstRun, "yes");
    142     }
    143 
    144 #if 0
    145     /* Configure the newly created vm here in GUI by several calls to API: */
    146     configureVM(strTypeId, type);
    147 #else
    148     /* The newer and less tested way of configuring vms: */
    149     m_machine.ApplyDefaults(QString());
    150     /* Apply user preferences again. IMachine::applyDefaults may have overwritten the user setting: */
    151     m_machine.SetMemorySize(field("baseMemory").toUInt());
    152     int iVPUCount = qMax((unsigned)1, field("VCPUCount").toUInt());
    153     m_machine.SetCPUCount(iVPUCount);
    154     /* Correct the VRAM size since API does not take fullscreen memory requirements into account: */
    155     CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter();
    156     comGraphics.SetVRAMSize(qMax(comGraphics.GetVRAMSize(), (ULONG)(UICommon::requiredVideoMemory(strTypeId) / _1M)));
    157     /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */
    158     if (iVPUCount > 1)
    159         m_machine.GetBIOSSettings().SetIOAPICEnabled(true);
    160 
    161     /* Set recommended firmware type: */
    162     m_machine.SetFirmwareType(getBoolFieldValue("EFIEnabled") ? KFirmwareType_EFI : KFirmwareType_BIOS);
    163 #endif
    164 
    165     /* Register the VM prior to attaching hard disks: */
    166     vbox.RegisterMachine(m_machine);
    167     if (!vbox.isOk())
    168     {
    169         msgCenter().cannotRegisterMachine(vbox, m_machine.GetName(), this);
    170         return false;
    171     }
    172     return attachDefaultDevices(type);
     135//     /* Get VBox object: */
     136//     CVirtualBox vbox = uiCommon().virtualBox();
     137
     138//     /* OS type: */
     139//     CGuestOSType type = field("type").value<CGuestOSType>();
     140//     QString strTypeId = type.GetId();
     141
     142//     /* Create virtual machine: */
     143//     if (m_machine.isNull())
     144//     {
     145//         QVector<QString> groups;
     146//         if (!m_strGroup.isEmpty())
     147//             groups << m_strGroup;
     148//         m_machine = vbox.CreateMachine(field("machineFilePath").toString(),
     149//                                        field("name").toString(),
     150//                                        groups, strTypeId, QString());
     151//         if (!vbox.isOk())
     152//         {
     153//             msgCenter().cannotCreateMachine(vbox, this);
     154//             return false;
     155//         }
     156
     157//         /* The First RUN Wizard is to be shown:
     158//          * 1. if we don't attach any virtual hard-drive
     159//          * 2. or attach a new (empty) one.
     160//          * 3. and if the unattended install is not enabled
     161//          * 4. User did not select an ISO image file
     162//          * Usually we are assigning extra-data values through UIExtraDataManager,
     163//          * but in that special case VM was not registered yet, so UIExtraDataManager is unaware of it: */
     164//         if (ISOFilePath().isEmpty() &&
     165//             !isUnattendedEnabled() &&
     166//             !m_virtualDisk.isNull())
     167//             m_machine.SetExtraData(GUI_FirstRun, "yes");
     168//     }
     169
     170// #if 0
     171//     /* Configure the newly created vm here in GUI by several calls to API: */
     172//     configureVM(strTypeId, type);
     173// #else
     174//     /* The newer and less tested way of configuring vms: */
     175//     m_machine.ApplyDefaults(QString());
     176//     /* Apply user preferences again. IMachine::applyDefaults may have overwritten the user setting: */
     177//     m_machine.SetMemorySize(field("baseMemory").toUInt());
     178//     int iVPUCount = qMax((unsigned)1, field("VCPUCount").toUInt());
     179//     m_machine.SetCPUCount(iVPUCount);
     180//     /* Correct the VRAM size since API does not take fullscreen memory requirements into account: */
     181//     CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter();
     182//     comGraphics.SetVRAMSize(qMax(comGraphics.GetVRAMSize(), (ULONG)(UICommon::requiredVideoMemory(strTypeId) / _1M)));
     183//     /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */
     184//     if (iVPUCount > 1)
     185//         m_machine.GetBIOSSettings().SetIOAPICEnabled(true);
     186
     187//     /* Set recommended firmware type: */
     188//     m_machine.SetFirmwareType(getBoolFieldValue("EFIEnabled") ? KFirmwareType_EFI : KFirmwareType_BIOS);
     189// #endif
     190
     191//     /* Register the VM prior to attaching hard disks: */
     192//     vbox.RegisterMachine(m_machine);
     193//     if (!vbox.isOk())
     194//     {
     195//         msgCenter().cannotRegisterMachine(vbox, m_machine.GetName(), this);
     196//         return false;
     197//     }
     198//     return attachDefaultDevices(type);
     199    return true;
    173200}
    174201
    175202bool UIWizardNewVM::createVirtualDisk()
    176203{
    177     /* Gather attributes: */
    178     CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
    179     /* uVariant is of type KMediumVariant*/
    180     qulonglong uMediumVariant = field("mediumVariant").toULongLong();
    181     QString strMediumPath = field("mediumPath").toString();
    182     qulonglong uSize = field("mediumSize").toULongLong();
    183     /* Check attributes: */
    184     AssertReturn(!strMediumPath.isNull(), false);
    185     AssertReturn(uSize > 0, false);
    186 
    187     /* Get VBox object: */
    188     CVirtualBox vbox = uiCommon().virtualBox();
    189 
    190     /* Create new virtual hard-disk: */
    191     CMedium newVirtualDisk = vbox.CreateMedium(mediumFormat.GetName(), strMediumPath, KAccessMode_ReadWrite, KDeviceType_HardDisk);
    192     if (!vbox.isOk())
    193     {
    194         msgCenter().cannotCreateHardDiskStorage(vbox, strMediumPath, this);
    195         return false;
    196     }
    197 
    198     /* Compose medium-variant: */
    199     QVector<KMediumVariant> variants(sizeof(qulonglong)*8);
    200     for (int i = 0; i < variants.size(); ++i)
    201     {
    202         qulonglong temp = uMediumVariant;
    203         temp &= UINT64_C(1)<<i;
    204         variants[i] = (KMediumVariant)temp;
    205     }
    206 
    207     /* Create base storage for the new virtual-disk: */
    208     CProgress progress = newVirtualDisk.CreateBaseStorage(uSize, variants);
    209     if (!newVirtualDisk.isOk())
    210     {
    211         msgCenter().cannotCreateHardDiskStorage(newVirtualDisk, strMediumPath, this);
    212         return false;
    213     }
    214 
    215     /* Show creation progress: */
    216     msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_create_90px.png", this);
    217     if (progress.GetCanceled())
    218         return false;
    219     if (!progress.isOk() || progress.GetResultCode() != 0)
    220     {
    221         msgCenter().cannotCreateHardDiskStorage(progress, strMediumPath, this);
    222         return false;
    223     }
    224 
    225     /* Inform UICommon about it: */
    226     uiCommon().createMedium(UIMedium(newVirtualDisk, UIMediumDeviceType_HardDisk, KMediumState_Created));
    227 
    228     /* Remember created virtual-disk: */
    229     m_virtualDisk = newVirtualDisk;
     204    // /* Gather attributes: */
     205    // CMediumFormat mediumFormat = field("mediumFormat").value<CMediumFormat>();
     206    // /* uVariant is of type KMediumVariant*/
     207    // qulonglong uMediumVariant = field("mediumVariant").toULongLong();
     208    // QString strMediumPath = field("mediumPath").toString();
     209    // qulonglong uSize = field("mediumSize").toULongLong();
     210    // /* Check attributes: */
     211    // AssertReturn(!strMediumPath.isNull(), false);
     212    // AssertReturn(uSize > 0, false);
     213
     214    // /* Get VBox object: */
     215    // CVirtualBox vbox = uiCommon().virtualBox();
     216
     217    // /* Create new virtual hard-disk: */
     218    // CMedium newVirtualDisk = vbox.CreateMedium(mediumFormat.GetName(), strMediumPath, KAccessMode_ReadWrite, KDeviceType_HardDisk);
     219    // if (!vbox.isOk())
     220    // {
     221    //     msgCenter().cannotCreateHardDiskStorage(vbox, strMediumPath, this);
     222    //     return false;
     223    // }
     224
     225    // /* Compose medium-variant: */
     226    // QVector<KMediumVariant> variants(sizeof(qulonglong)*8);
     227    // for (int i = 0; i < variants.size(); ++i)
     228    // {
     229    //     qulonglong temp = uMediumVariant;
     230    //     temp &= UINT64_C(1)<<i;
     231    //     variants[i] = (KMediumVariant)temp;
     232    // }
     233
     234    // /* Create base storage for the new virtual-disk: */
     235    // CProgress progress = newVirtualDisk.CreateBaseStorage(uSize, variants);
     236    // if (!newVirtualDisk.isOk())
     237    // {
     238    //     msgCenter().cannotCreateHardDiskStorage(newVirtualDisk, strMediumPath, this);
     239    //     return false;
     240    // }
     241
     242    // /* Show creation progress: */
     243    // msgCenter().showModalProgressDialog(progress, windowTitle(), ":/progress_media_create_90px.png", this);
     244    // if (progress.GetCanceled())
     245    //     return false;
     246    // if (!progress.isOk() || progress.GetResultCode() != 0)
     247    // {
     248    //     msgCenter().cannotCreateHardDiskStorage(progress, strMediumPath, this);
     249    //     return false;
     250    // }
     251
     252    // /* Inform UICommon about it: */
     253    // uiCommon().createMedium(UIMedium(newVirtualDisk, UIMediumDeviceType_HardDisk, KMediumState_Created));
     254
     255    // /* Remember created virtual-disk: */
     256    // m_virtualDisk = newVirtualDisk;
    230257
    231258    return true;
     
    258285void UIWizardNewVM::configureVM(const QString &strGuestTypeId, const CGuestOSType &comGuestType)
    259286{
    260     /* Get graphics adapter: */
    261     CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter();
    262 
    263     /* RAM size: */
    264     m_machine.SetMemorySize(field("baseMemory").toInt());
    265 
    266     /* VCPU count: */
    267     int iVPUCount = qMax((unsigned)1, field("VCPUCount").toUInt());
    268     m_machine.SetCPUCount(iVPUCount);
    269 
    270     /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */
    271     if (iVPUCount > 1)
    272         m_machine.GetBIOSSettings().SetIOAPICEnabled(true);
    273 
    274     /* Graphics Controller type: */
    275     comGraphics.SetGraphicsControllerType(comGuestType.GetRecommendedGraphicsController());
    276 
    277     /* VRAM size - select maximum between recommended and minimum for fullscreen: */
    278     comGraphics.SetVRAMSize(qMax(comGuestType.GetRecommendedVRAM(), (ULONG)(UICommon::requiredVideoMemory(strGuestTypeId) / _1M)));
    279 
    280     /* Selecting recommended chipset type: */
    281     m_machine.SetChipsetType(comGuestType.GetRecommendedChipset());
    282 
    283     /* Selecting recommended Audio Controller: */
    284     m_machine.GetAudioAdapter().SetAudioController(comGuestType.GetRecommendedAudioController());
    285     /* And the Audio Codec: */
    286     m_machine.GetAudioAdapter().SetAudioCodec(comGuestType.GetRecommendedAudioCodec());
    287     /* Enabling audio by default: */
    288     m_machine.GetAudioAdapter().SetEnabled(true);
    289     m_machine.GetAudioAdapter().SetEnabledOut(true);
    290 
    291     /* Enable the OHCI and EHCI controller by default for new VMs. (new in 2.2): */
    292     CUSBDeviceFilters usbDeviceFilters = m_machine.GetUSBDeviceFilters();
    293     bool fOhciEnabled = false;
    294     if (!usbDeviceFilters.isNull() && comGuestType.GetRecommendedUSB3() && m_machine.GetUSBProxyAvailable())
    295     {
    296         /* USB 3.0 is only available if the proper ExtPack is installed: */
    297         CExtPackManager extPackManager = uiCommon().virtualBox().GetExtensionPackManager();
    298         if (extPackManager.isNull() || extPackManager.IsExtPackUsable(GUI_ExtPackName))
    299         {
    300             m_machine.AddUSBController("XHCI", KUSBControllerType_XHCI);
    301             /* xHCI includes OHCI */
    302             fOhciEnabled = true;
    303         }
    304     }
    305     if (   !fOhciEnabled
    306         && !usbDeviceFilters.isNull() && comGuestType.GetRecommendedUSB() && m_machine.GetUSBProxyAvailable())
    307     {
    308         m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);
    309         fOhciEnabled = true;
    310         /* USB 2.0 is only available if the proper ExtPack is installed.
    311          * Note. Configuring EHCI here and providing messages about
    312          * the missing extpack isn't exactly clean, but it is a
    313          * necessary evil to patch over legacy compatability issues
    314          * introduced by the new distribution model. */
    315         CExtPackManager extPackManager = uiCommon().virtualBox().GetExtensionPackManager();
    316         if (extPackManager.isNull() || extPackManager.IsExtPackUsable(GUI_ExtPackName))
    317             m_machine.AddUSBController("EHCI", KUSBControllerType_EHCI);
    318     }
    319 
    320     /* Create a floppy controller if recommended: */
    321     QString strFloppyName = getNextControllerName(KStorageBus_Floppy);
    322     if (comGuestType.GetRecommendedFloppy())
    323     {
    324         m_machine.AddStorageController(strFloppyName, KStorageBus_Floppy);
    325         CStorageController flpCtr = m_machine.GetStorageControllerByName(strFloppyName);
    326         flpCtr.SetControllerType(KStorageControllerType_I82078);
    327     }
    328 
    329     /* Create recommended DVD storage controller: */
    330     KStorageBus strDVDBus = comGuestType.GetRecommendedDVDStorageBus();
    331     QString strDVDName = getNextControllerName(strDVDBus);
    332     m_machine.AddStorageController(strDVDName, strDVDBus);
    333 
    334     /* Set recommended DVD storage controller type: */
    335     CStorageController dvdCtr = m_machine.GetStorageControllerByName(strDVDName);
    336     KStorageControllerType dvdStorageControllerType = comGuestType.GetRecommendedDVDStorageController();
    337     dvdCtr.SetControllerType(dvdStorageControllerType);
    338 
    339     /* Create recommended HD storage controller if it's not the same as the DVD controller: */
    340     KStorageBus ctrHDBus = comGuestType.GetRecommendedHDStorageBus();
    341     KStorageControllerType hdStorageControllerType = comGuestType.GetRecommendedHDStorageController();
    342     CStorageController hdCtr;
    343     QString strHDName;
    344     if (ctrHDBus != strDVDBus || hdStorageControllerType != dvdStorageControllerType)
    345     {
    346         strHDName = getNextControllerName(ctrHDBus);
    347         m_machine.AddStorageController(strHDName, ctrHDBus);
    348         hdCtr = m_machine.GetStorageControllerByName(strHDName);
    349         hdCtr.SetControllerType(hdStorageControllerType);
    350     }
    351     else
    352     {
    353         /* The HD controller is the same as DVD: */
    354         hdCtr = dvdCtr;
    355         strHDName = strDVDName;
    356     }
    357 
    358     /* Limit the AHCI port count if it's used because windows has trouble with
    359        too many ports and other guest (OS X in particular) may take extra long
    360        to boot: */
    361     if (hdStorageControllerType == KStorageControllerType_IntelAhci)
    362         hdCtr.SetPortCount(1 + (dvdStorageControllerType == KStorageControllerType_IntelAhci));
    363     else if (dvdStorageControllerType == KStorageControllerType_IntelAhci)
    364         dvdCtr.SetPortCount(1);
    365 
    366     /* Turn on PAE, if recommended: */
    367     m_machine.SetCPUProperty(KCPUPropertyType_PAE, comGuestType.GetRecommendedPAE());
    368 
    369     /* Set the recommended triple fault behavior: */
    370     m_machine.SetCPUProperty(KCPUPropertyType_TripleFaultReset, comGuestType.GetRecommendedTFReset());
    371 
    372     /* Set recommended firmware type: */
    373     m_machine.SetFirmwareType(getBoolFieldValue("EFIEnabled") ? KFirmwareType_EFI : KFirmwareType_BIOS);
    374 
    375     /* Set recommended human interface device types: */
    376     if (comGuestType.GetRecommendedUSBHID())
    377     {
    378         m_machine.SetKeyboardHIDType(KKeyboardHIDType_USBKeyboard);
    379         m_machine.SetPointingHIDType(KPointingHIDType_USBMouse);
    380         if (!fOhciEnabled && !usbDeviceFilters.isNull())
    381             m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);
    382     }
    383 
    384     if (comGuestType.GetRecommendedUSBTablet())
    385     {
    386         m_machine.SetPointingHIDType(KPointingHIDType_USBTablet);
    387         if (!fOhciEnabled && !usbDeviceFilters.isNull())
    388             m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);
    389     }
    390 
    391     /* Set HPET flag: */
    392     m_machine.SetHPETEnabled(comGuestType.GetRecommendedHPET());
    393 
    394     /* Set UTC flags: */
    395     m_machine.SetRTCUseUTC(comGuestType.GetRecommendedRTCUseUTC());
    396 
    397     /* Set graphic bits: */
    398     if (comGuestType.GetRecommended2DVideoAcceleration())
    399         comGraphics.SetAccelerate2DVideoEnabled(comGuestType.GetRecommended2DVideoAcceleration());
    400 
    401     if (comGuestType.GetRecommended3DAcceleration())
    402         comGraphics.SetAccelerate3DEnabled(comGuestType.GetRecommended3DAcceleration());
     287    Q_UNUSED(strGuestTypeId);
     288    Q_UNUSED(comGuestType);
     289    // /* Get graphics adapter: */
     290    // CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter();
     291
     292    // /* RAM size: */
     293    // m_machine.SetMemorySize(field("baseMemory").toInt());
     294
     295    // /* VCPU count: */
     296    // int iVPUCount = qMax((unsigned)1, field("VCPUCount").toUInt());
     297    // m_machine.SetCPUCount(iVPUCount);
     298
     299    // /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */
     300    // if (iVPUCount > 1)
     301    //     m_machine.GetBIOSSettings().SetIOAPICEnabled(true);
     302
     303    // /* Graphics Controller type: */
     304    // comGraphics.SetGraphicsControllerType(comGuestType.GetRecommendedGraphicsController());
     305
     306    // /* VRAM size - select maximum between recommended and minimum for fullscreen: */
     307    // comGraphics.SetVRAMSize(qMax(comGuestType.GetRecommendedVRAM(), (ULONG)(UICommon::requiredVideoMemory(strGuestTypeId) / _1M)));
     308
     309    // /* Selecting recommended chipset type: */
     310    // m_machine.SetChipsetType(comGuestType.GetRecommendedChipset());
     311
     312    // /* Selecting recommended Audio Controller: */
     313    // m_machine.GetAudioAdapter().SetAudioController(comGuestType.GetRecommendedAudioController());
     314    // /* And the Audio Codec: */
     315    // m_machine.GetAudioAdapter().SetAudioCodec(comGuestType.GetRecommendedAudioCodec());
     316    // /* Enabling audio by default: */
     317    // m_machine.GetAudioAdapter().SetEnabled(true);
     318    // m_machine.GetAudioAdapter().SetEnabledOut(true);
     319
     320    // /* Enable the OHCI and EHCI controller by default for new VMs. (new in 2.2): */
     321    // CUSBDeviceFilters usbDeviceFilters = m_machine.GetUSBDeviceFilters();
     322    // bool fOhciEnabled = false;
     323    // if (!usbDeviceFilters.isNull() && comGuestType.GetRecommendedUSB3() && m_machine.GetUSBProxyAvailable())
     324    // {
     325    //     /* USB 3.0 is only available if the proper ExtPack is installed: */
     326    //     CExtPackManager extPackManager = uiCommon().virtualBox().GetExtensionPackManager();
     327    //     if (extPackManager.isNull() || extPackManager.IsExtPackUsable(GUI_ExtPackName))
     328    //     {
     329    //         m_machine.AddUSBController("XHCI", KUSBControllerType_XHCI);
     330    //         /* xHCI includes OHCI */
     331    //         fOhciEnabled = true;
     332    //     }
     333    // }
     334    // if (   !fOhciEnabled
     335    //     && !usbDeviceFilters.isNull() && comGuestType.GetRecommendedUSB() && m_machine.GetUSBProxyAvailable())
     336    // {
     337    //     m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);
     338    //     fOhciEnabled = true;
     339    //     /* USB 2.0 is only available if the proper ExtPack is installed.
     340    //      * Note. Configuring EHCI here and providing messages about
     341    //      * the missing extpack isn't exactly clean, but it is a
     342    //      * necessary evil to patch over legacy compatability issues
     343    //      * introduced by the new distribution model. */
     344    //     CExtPackManager extPackManager = uiCommon().virtualBox().GetExtensionPackManager();
     345    //     if (extPackManager.isNull() || extPackManager.IsExtPackUsable(GUI_ExtPackName))
     346    //         m_machine.AddUSBController("EHCI", KUSBControllerType_EHCI);
     347    // }
     348
     349    // /* Create a floppy controller if recommended: */
     350    // QString strFloppyName = getNextControllerName(KStorageBus_Floppy);
     351    // if (comGuestType.GetRecommendedFloppy())
     352    // {
     353    //     m_machine.AddStorageController(strFloppyName, KStorageBus_Floppy);
     354    //     CStorageController flpCtr = m_machine.GetStorageControllerByName(strFloppyName);
     355    //     flpCtr.SetControllerType(KStorageControllerType_I82078);
     356    // }
     357
     358    // /* Create recommended DVD storage controller: */
     359    // KStorageBus strDVDBus = comGuestType.GetRecommendedDVDStorageBus();
     360    // QString strDVDName = getNextControllerName(strDVDBus);
     361    // m_machine.AddStorageController(strDVDName, strDVDBus);
     362
     363    // /* Set recommended DVD storage controller type: */
     364    // CStorageController dvdCtr = m_machine.GetStorageControllerByName(strDVDName);
     365    // KStorageControllerType dvdStorageControllerType = comGuestType.GetRecommendedDVDStorageController();
     366    // dvdCtr.SetControllerType(dvdStorageControllerType);
     367
     368    // /* Create recommended HD storage controller if it's not the same as the DVD controller: */
     369    // KStorageBus ctrHDBus = comGuestType.GetRecommendedHDStorageBus();
     370    // KStorageControllerType hdStorageControllerType = comGuestType.GetRecommendedHDStorageController();
     371    // CStorageController hdCtr;
     372    // QString strHDName;
     373    // if (ctrHDBus != strDVDBus || hdStorageControllerType != dvdStorageControllerType)
     374    // {
     375    //     strHDName = getNextControllerName(ctrHDBus);
     376    //     m_machine.AddStorageController(strHDName, ctrHDBus);
     377    //     hdCtr = m_machine.GetStorageControllerByName(strHDName);
     378    //     hdCtr.SetControllerType(hdStorageControllerType);
     379    // }
     380    // else
     381    // {
     382    //     /* The HD controller is the same as DVD: */
     383    //     hdCtr = dvdCtr;
     384    //     strHDName = strDVDName;
     385    // }
     386
     387    // /* Limit the AHCI port count if it's used because windows has trouble with
     388    //    too many ports and other guest (OS X in particular) may take extra long
     389    //    to boot: */
     390    // if (hdStorageControllerType == KStorageControllerType_IntelAhci)
     391    //     hdCtr.SetPortCount(1 + (dvdStorageControllerType == KStorageControllerType_IntelAhci));
     392    // else if (dvdStorageControllerType == KStorageControllerType_IntelAhci)
     393    //     dvdCtr.SetPortCount(1);
     394
     395    // /* Turn on PAE, if recommended: */
     396    // m_machine.SetCPUProperty(KCPUPropertyType_PAE, comGuestType.GetRecommendedPAE());
     397
     398    // /* Set the recommended triple fault behavior: */
     399    // m_machine.SetCPUProperty(KCPUPropertyType_TripleFaultReset, comGuestType.GetRecommendedTFReset());
     400
     401    // /* Set recommended firmware type: */
     402    // m_machine.SetFirmwareType(getBoolFieldValue("EFIEnabled") ? KFirmwareType_EFI : KFirmwareType_BIOS);
     403
     404    // /* Set recommended human interface device types: */
     405    // if (comGuestType.GetRecommendedUSBHID())
     406    // {
     407    //     m_machine.SetKeyboardHIDType(KKeyboardHIDType_USBKeyboard);
     408    //     m_machine.SetPointingHIDType(KPointingHIDType_USBMouse);
     409    //     if (!fOhciEnabled && !usbDeviceFilters.isNull())
     410    //         m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);
     411    // }
     412
     413    // if (comGuestType.GetRecommendedUSBTablet())
     414    // {
     415    //     m_machine.SetPointingHIDType(KPointingHIDType_USBTablet);
     416    //     if (!fOhciEnabled && !usbDeviceFilters.isNull())
     417    //         m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI);
     418    // }
     419
     420    // /* Set HPET flag: */
     421    // m_machine.SetHPETEnabled(comGuestType.GetRecommendedHPET());
     422
     423    // /* Set UTC flags: */
     424    // m_machine.SetRTCUseUTC(comGuestType.GetRecommendedRTCUseUTC());
     425
     426    // /* Set graphic bits: */
     427    // if (comGuestType.GetRecommended2DVideoAcceleration())
     428    //     comGraphics.SetAccelerate2DVideoEnabled(comGuestType.GetRecommended2DVideoAcceleration());
     429
     430    // if (comGuestType.GetRecommended3DAcceleration())
     431    //     comGraphics.SetAccelerate3DEnabled(comGuestType.GetRecommended3DAcceleration());
    403432}
    404433
    405434bool UIWizardNewVM::attachDefaultDevices(const CGuestOSType &comGuestType)
    406435{
    407     bool success = false;
    408     QUuid uMachineId = m_machine.GetId();
    409     CSession session = uiCommon().openSession(uMachineId);
    410     if (!session.isNull())
    411     {
    412         CMachine machine = session.GetMachine();
    413         if (!m_virtualDisk.isNull())
    414         {
    415             KStorageBus enmHDDBus = comGuestType.GetRecommendedHDStorageBus();
    416             CStorageController comHDDController = m_machine.GetStorageControllerByInstance(enmHDDBus, 0);
    417             if (!comHDDController.isNull())
    418             {
    419                 machine.AttachDevice(comHDDController.GetName(), 0, 0, KDeviceType_HardDisk, m_virtualDisk);
    420                 if (!machine.isOk())
    421                     msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_HardDisk, field("mediumPath").toString(),
    422                                                    StorageSlot(enmHDDBus, 0, 0), this);
    423             }
    424         }
    425 
    426         /* Attach optical drive: */
    427         KStorageBus enmDVDBus = comGuestType.GetRecommendedDVDStorageBus();
    428         CStorageController comDVDController = m_machine.GetStorageControllerByInstance(enmDVDBus, 0);
    429         if (!comDVDController.isNull())
    430         {
    431             CMedium opticalDisk;
    432             QString strISOFilePath = ISOFilePath();
    433             if (!strISOFilePath.isEmpty() && !getBoolFieldValue("isUnattendedEnabled"))
    434             {
    435                 CVirtualBox vbox = uiCommon().virtualBox();
    436                 opticalDisk =
    437                     vbox.OpenMedium(strISOFilePath, KDeviceType_DVD,  KAccessMode_ReadWrite, false);
    438                 if (!vbox.isOk())
    439                     msgCenter().cannotOpenMedium(vbox, strISOFilePath, this);
    440             }
    441             machine.AttachDevice(comDVDController.GetName(), 1, 0, KDeviceType_DVD, opticalDisk);
    442             if (!machine.isOk())
    443                 msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_DVD, QString(),
    444                                                StorageSlot(enmDVDBus, 1, 0), this);
    445         }
    446 
    447         /* Attach an empty floppy drive if recommended */
    448         if (comGuestType.GetRecommendedFloppy()) {
    449             CStorageController comFloppyController = m_machine.GetStorageControllerByInstance(KStorageBus_Floppy, 0);
    450             if (!comFloppyController.isNull())
    451             {
    452                 machine.AttachDevice(comFloppyController.GetName(), 0, 0, KDeviceType_Floppy, CMedium());
    453                 if (!machine.isOk())
    454                     msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_Floppy, QString(),
    455                                                    StorageSlot(KStorageBus_Floppy, 0, 0), this);
    456             }
    457         }
    458 
    459         if (machine.isOk())
    460         {
    461             machine.SaveSettings();
    462             if (machine.isOk())
    463                 success = true;
    464             else
    465                 msgCenter().cannotSaveMachineSettings(machine, this);
    466         }
    467 
    468         session.UnlockMachine();
    469     }
    470     if (!success)
    471     {
    472         CVirtualBox vbox = uiCommon().virtualBox();
    473         /* Unregister on failure */
    474         QVector<CMedium> aMedia = m_machine.Unregister(KCleanupMode_UnregisterOnly);   /// @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below
    475         if (vbox.isOk())
    476         {
    477             CProgress progress = m_machine.DeleteConfig(aMedia);
    478             progress.WaitForCompletion(-1);         /// @todo do this nicely with a progress dialog, this can delete lots of files
    479         }
    480         return false;
    481     }
    482 
    483     /* Ensure we don't try to delete a newly created virtual hard drive on success: */
    484     if (!m_virtualDisk.isNull())
    485         m_virtualDisk.detach();
    486 
     436    Q_UNUSED(comGuestType);
    487437    return true;
     438    // bool success = false;
     439    // QUuid uMachineId = m_machine.GetId();
     440    // CSession session = uiCommon().openSession(uMachineId);
     441    // if (!session.isNull())
     442    // {
     443    //     CMachine machine = session.GetMachine();
     444    //     if (!m_virtualDisk.isNull())
     445    //     {
     446    //         KStorageBus enmHDDBus = comGuestType.GetRecommendedHDStorageBus();
     447    //         CStorageController comHDDController = m_machine.GetStorageControllerByInstance(enmHDDBus, 0);
     448    //         if (!comHDDController.isNull())
     449    //         {
     450    //             machine.AttachDevice(comHDDController.GetName(), 0, 0, KDeviceType_HardDisk, m_virtualDisk);
     451    //             if (!machine.isOk())
     452    //                 msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_HardDisk, field("mediumPath").toString(),
     453    //                                                StorageSlot(enmHDDBus, 0, 0), this);
     454    //         }
     455    //     }
     456
     457    //     /* Attach optical drive: */
     458    //     KStorageBus enmDVDBus = comGuestType.GetRecommendedDVDStorageBus();
     459    //     CStorageController comDVDController = m_machine.GetStorageControllerByInstance(enmDVDBus, 0);
     460    //     if (!comDVDController.isNull())
     461    //     {
     462    //         CMedium opticalDisk;
     463    //         QString strISOFilePath = ISOFilePath();
     464    //         if (!strISOFilePath.isEmpty() && !getBoolFieldValue("isUnattendedEnabled"))
     465    //         {
     466    //             CVirtualBox vbox = uiCommon().virtualBox();
     467    //             opticalDisk =
     468    //                 vbox.OpenMedium(strISOFilePath, KDeviceType_DVD,  KAccessMode_ReadWrite, false);
     469    //             if (!vbox.isOk())
     470    //                 msgCenter().cannotOpenMedium(vbox, strISOFilePath, this);
     471    //         }
     472    //         machine.AttachDevice(comDVDController.GetName(), 1, 0, KDeviceType_DVD, opticalDisk);
     473    //         if (!machine.isOk())
     474    //             msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_DVD, QString(),
     475    //                                            StorageSlot(enmDVDBus, 1, 0), this);
     476    //     }
     477
     478    //     /* Attach an empty floppy drive if recommended */
     479    //     if (comGuestType.GetRecommendedFloppy()) {
     480    //         CStorageController comFloppyController = m_machine.GetStorageControllerByInstance(KStorageBus_Floppy, 0);
     481    //         if (!comFloppyController.isNull())
     482    //         {
     483    //             machine.AttachDevice(comFloppyController.GetName(), 0, 0, KDeviceType_Floppy, CMedium());
     484    //             if (!machine.isOk())
     485    //                 msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_Floppy, QString(),
     486    //                                                StorageSlot(KStorageBus_Floppy, 0, 0), this);
     487    //         }
     488    //     }
     489
     490    //     if (machine.isOk())
     491    //     {
     492    //         machine.SaveSettings();
     493    //         if (machine.isOk())
     494    //             success = true;
     495    //         else
     496    //             msgCenter().cannotSaveMachineSettings(machine, this);
     497    //     }
     498
     499    //     session.UnlockMachine();
     500    // }
     501    // if (!success)
     502    // {
     503    //     CVirtualBox vbox = uiCommon().virtualBox();
     504    //     /* Unregister on failure */
     505    //     QVector<CMedium> aMedia = m_machine.Unregister(KCleanupMode_UnregisterOnly);   /// @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below
     506    //     if (vbox.isOk())
     507    //     {
     508    //         CProgress progress = m_machine.DeleteConfig(aMedia);
     509    //         progress.WaitForCompletion(-1);         /// @todo do this nicely with a progress dialog, this can delete lots of files
     510    //     }
     511    //     return false;
     512    // }
     513
     514    // /* Ensure we don't try to delete a newly created virtual hard drive on success: */
     515    // if (!m_virtualDisk.isNull())
     516    //     m_virtualDisk.detach();
     517
     518    // return true;
    488519}
    489520
    490521QString UIWizardNewVM::getStringFieldValue(const QString &strFieldName) const
    491522{
    492     QVariant fieldValue = field(strFieldName);
    493     if (!fieldValue.isNull() && fieldValue.isValid() && fieldValue.canConvert(QMetaType::QString))
    494         return fieldValue.toString();
     523    Q_UNUSED(strFieldName);
     524    // QVariant fieldValue = field(strFieldName);
     525    // if (!fieldValue.isNull() && fieldValue.isValid() && fieldValue.canConvert(QMetaType::QString))
     526    //     return fieldValue.toString();
    495527    return QString();
    496528}
     
    498530bool UIWizardNewVM::getBoolFieldValue(const QString &strFieldName) const
    499531{
    500     QVariant fieldValue = field(strFieldName);
    501     if (!fieldValue.isNull() && fieldValue.isValid() && fieldValue.canConvert(QMetaType::Bool))
    502         return fieldValue.toBool();
     532    Q_UNUSED(strFieldName);
     533    // QVariant fieldValue = field(strFieldName);
     534    // if (!fieldValue.isNull() && fieldValue.isValid() && fieldValue.canConvert(QMetaType::Bool))
     535    //     return fieldValue.toBool();
    503536    return false;
    504537}
     
    506539void UIWizardNewVM::sltHandleWizardCancel()
    507540{
    508     switch (mode())
    509     {
    510         case WizardMode_Basic:
    511         {
    512             UIWizardNewVMPageNameOSType *pPage = qobject_cast<UIWizardNewVMPageNameOSType*> (page(Page1));
    513             /* Make sure that we were able to find the page that created the folder. */
    514             Assert(pPage);
    515             if (pPage)
    516                 pPage->cleanupMachineFolder(true);
    517             break;
    518         }
    519         case WizardMode_Expert:
    520         {
    521             UIWizardNewVMPageExpert *pPage = qobject_cast<UIWizardNewVMPageExpert*> (page(PageExpert));
    522             if (pPage)
    523                 pPage->cleanupMachineFolder(true);
    524             break;
    525         }
    526         default:
    527             break;
    528     }
     541    // switch (mode())
     542    // {
     543    //     case WizardMode_Basic:
     544    //     {
     545    //         UIWizardNewVMPageNameOSType *pPage = qobject_cast<UIWizardNewVMPageNameOSType*> (page(Page1));
     546    //         /* Make sure that we were able to find the page that created the folder. */
     547    //         Assert(pPage);
     548    //         if (pPage)
     549    //             pPage->cleanupMachineFolder(true);
     550    //         break;
     551    //     }
     552    //     case WizardMode_Expert:
     553    //     {
     554    //         UIWizardNewVMPageExpert *pPage = qobject_cast<UIWizardNewVMPageExpert*> (page(PageExpert));
     555    //         if (pPage)
     556    //             pPage->cleanupMachineFolder(true);
     557    //         break;
     558    //     }
     559    //     default:
     560    //         break;
     561    // }
    529562}
    530563
    531564void UIWizardNewVM::sltHandleDetectedOSTypeChange()
    532565{
    533     UIWizardNewVMPageNameOSType *pPage = qobject_cast<UIWizardNewVMPageNameOSType*>(page(Page1));
    534     if (!pPage)
    535         return;
    536     pPage->setTypeByISODetectedOSType(getStringFieldValue("detectedOSTypeId"));
     566    // UIWizardNewVMPageNameOSType *pPage = qobject_cast<UIWizardNewVMPageNameOSType*>(page(Page1));
     567    // if (!pPage)
     568    //     return;
     569    // pPage->setTypeByISODetectedOSType(getStringFieldValue("detectedOSTypeId"));
    537570}
    538571
    539572void UIWizardNewVM::sltCustomButtonClicked(int iId)
    540573{
    541     UIWizard::sltCustomButtonClicked(iId);
    542     setFieldsFromDefaultUnttendedInstallData();
     574    Q_UNUSED(iId);
     575    // UIWizard::sltCustomButtonClicked(iId);
     576    // setFieldsFromDefaultUnttendedInstallData();
    543577}
    544578
     
    546580{
    547581    /* Call to base-class: */
    548     UIWizard::retranslateUi();
    549 
    550     /* Translate wizard: */
     582    UINativeWizard::retranslateUi();
     583
    551584    setWindowTitle(tr("Create Virtual Machine"));
    552     setButtonText(QWizard::FinishButton, tr("Create"));
     585    // setButtonText(QWizard::FinishButton, tr("Create"));
    553586}
    554587
     
    627660void UIWizardNewVM::setFieldsFromDefaultUnttendedInstallData()
    628661{
    629     setField("userName", m_unattendedInstallData.m_strUserName);
    630     setField("password", m_unattendedInstallData.m_strPassword);
    631     setField("hostname", m_unattendedInstallData.m_strHostname);
    632     setField("installGuestAdditions", m_unattendedInstallData.m_fInstallGuestAdditions);
    633     setField("guestAdditionsISOPath", m_unattendedInstallData.m_strGuestAdditionsISOPath);
     662    // setField("userName", m_unattendedInstallData.m_strUserName);
     663    // setField("password", m_unattendedInstallData.m_strPassword);
     664    // setField("hostname", m_unattendedInstallData.m_strHostname);
     665    // setField("installGuestAdditions", m_unattendedInstallData.m_fInstallGuestAdditions);
     666    // setField("guestAdditionsISOPath", m_unattendedInstallData.m_strGuestAdditionsISOPath);
    634667}
    635668
     
    689722bool UIWizardNewVM::isUnattendedEnabled() const
    690723{
    691     QVariant fieldValue = field("isUnattendedEnabled");
    692     if (fieldValue.isNull() || !fieldValue.isValid() || !fieldValue.canConvert(QMetaType::Bool))
    693         return false;
    694     return fieldValue.toBool();
     724    // QVariant fieldValue = field("isUnattendedEnabled");
     725    // if (fieldValue.isNull() || !fieldValue.isValid() || !fieldValue.canConvert(QMetaType::Bool))
     726    //     return false;
     727    // return fieldValue.toBool();
     728    return true;
    695729}
    696730
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h

    r88577 r90003  
    2323
    2424/* GUI includes: */
    25 #include "UIWizard.h"
     25#include "UINativeWizard.h"
    2626
    2727/* COM includes: */
     
    6262
    6363/** New Virtual Machine wizard: */
    64 class UIWizardNewVM : public UIWizard
     64class UIWizardNewVM : public UINativeWizard
    6565{
    6666    Q_OBJECT;
     
    8585
    8686    /** Constructor: */
    87     UIWizardNewVM(QWidget *pParent, const QString &strGroup = QString());
     87    UIWizardNewVM(QWidget *pParent, const QString &strGroup = QString(), WizardMode enmMode = WizardMode_Auto);
    8888
    8989    /** Prepare routine. */
     
    101101
    102102protected:
     103
     104    /** Populates pages. */
     105    virtual void populatePages() /* final */;
    103106
    104107    bool createVM();
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPageBasic.cpp

    r90002 r90003  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewVMPageDisk class implementation.
     3 * VBox Qt GUI - UIWizardNewVMDiskPageBasic class implementation.
    44 */
    55
     
    3636#include "UIMessageCenter.h"
    3737#include "UIWizardNewVD.h"
    38 #include "UIWizardNewVMPageDisk.h"
     38#include "UIWizardNewVMDiskPageBasic.h"
    3939
    4040/* COM includes: */
     
    4242#include "CSystemProperties.h"
    4343
    44 UIWizardNewVMPageDiskBase::UIWizardNewVMPageDiskBase()
    45     : m_fRecommendedNoDisk(false)
     44// UIWizardNewVMDiskPage::UIWizardNewVMDiskPage()
     45//     : m_fRecommendedNoDisk(false)
     46//     , m_enmSelectedDiskSource(SelectedDiskSource_New)
     47// {
     48// }
     49
     50// SelectedDiskSource UIWizardNewVMDiskPage::selectedDiskSource() const
     51// {
     52//     return m_enmSelectedDiskSource;
     53// }
     54
     55// void UIWizardNewVMDiskPage::setSelectedDiskSource(SelectedDiskSource enmSelectedDiskSource)
     56// {
     57//     m_enmSelectedDiskSource = enmSelectedDiskSource;
     58// }
     59
     60// void UIWizardNewVMDiskPage::getWithFileOpenDialog()
     61// {
     62//     QUuid uMediumId;
     63//     int returnCode = uiCommon().openMediumSelectorDialog(thisImp(), UIMediumDeviceType_HardDisk,
     64//                                                            uMediumId,
     65//                                                            fieldImp("machineFolder").toString(),
     66//                                                            fieldImp("machineBaseName").toString(),
     67//                                                            fieldImp("type").value<CGuestOSType>().GetId(),
     68//                                                            false /* don't show/enable the create action: */);
     69//     if (returnCode == static_cast<int>(UIMediumSelector::ReturnCode_Accepted) && !uMediumId.isNull())
     70//     {
     71//         m_pDiskSelector->setCurrentItem(uMediumId);
     72//         m_pDiskSelector->setFocus();
     73//     }
     74// }
     75
     76// void UIWizardNewVMDiskPage::setEnableDiskSelectionWidgets(bool fEnabled)
     77// {
     78//     if (!m_pDiskSelector || !m_pDiskSelectionButton)
     79//         return;
     80
     81//     m_pDiskSelector->setEnabled(fEnabled);
     82//     m_pDiskSelectionButton->setEnabled(fEnabled);
     83// }
     84
     85// QWidget *UIWizardNewVMDiskPage::createNewDiskWidgets()
     86// {
     87//     return new QWidget();
     88// }
     89
     90
     91UIWizardNewVMDiskPageBasic::UIWizardNewVMDiskPageBasic()
     92    : m_pDiskSourceButtonGroup(0)
    4693    , m_pDiskEmpty(0)
    4794    , m_pDiskNew(0)
     
    4996    , m_pDiskSelector(0)
    5097    , m_pDiskSelectionButton(0)
    51     , m_enmSelectedDiskSource(SelectedDiskSource_New)
    52 {
    53 }
    54 
    55 SelectedDiskSource UIWizardNewVMPageDiskBase::selectedDiskSource() const
    56 {
    57     return m_enmSelectedDiskSource;
    58 }
    59 
    60 void UIWizardNewVMPageDiskBase::setSelectedDiskSource(SelectedDiskSource enmSelectedDiskSource)
    61 {
    62     m_enmSelectedDiskSource = enmSelectedDiskSource;
    63 }
    64 
    65 void UIWizardNewVMPageDiskBase::getWithFileOpenDialog()
    66 {
    67     QUuid uMediumId;
    68     int returnCode = uiCommon().openMediumSelectorDialog(thisImp(), UIMediumDeviceType_HardDisk,
    69                                                            uMediumId,
    70                                                            fieldImp("machineFolder").toString(),
    71                                                            fieldImp("machineBaseName").toString(),
    72                                                            fieldImp("type").value<CGuestOSType>().GetId(),
    73                                                            false /* don't show/enable the create action: */);
    74     if (returnCode == static_cast<int>(UIMediumSelector::ReturnCode_Accepted) && !uMediumId.isNull())
     98    , m_pLabel(0)
     99    , m_pMediumSizeEditorLabel(0)
     100    , m_pMediumSizeEditor(0)
     101    , m_pDescriptionLabel(0)
     102    , m_pDynamicLabel(0)
     103    , m_pFixedLabel(0)
     104    , m_pSplitLabel(0)
     105    , m_pFixedCheckBox(0)
     106    , m_pSplitBox(0)
     107    , m_fUserSetSize(false)
     108{
     109    prepare();
     110    // qRegisterMetaType<CMedium>();
     111    // qRegisterMetaType<SelectedDiskSource>();
     112
     113    // /* We do not have any UI elements for HDD format selection since we default to VDI in case of guided wizard mode: */
     114    // bool fFoundVDI = false;
     115    // CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties();
     116    // const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
     117    // foreach (const CMediumFormat &format, formats)
     118    // {
     119    //     if (format.GetName() == "VDI")
     120    //     {
     121    //         m_mediumFormat = format;
     122    //         fFoundVDI = true;
     123    //     }
     124    // }
     125    // if (!fFoundVDI)
     126    //     AssertMsgFailed(("No medium format corresponding to VDI could be found!"));
     127
     128    // m_strDefaultExtension =  defaultExtension(m_mediumFormat);
     129
     130    // /* Since the medium format is static we can decide widget visibility here: */
     131    // setWidgetVisibility(m_mediumFormat);
     132}
     133
     134CMediumFormat UIWizardNewVMDiskPageBasic::mediumFormat() const
     135{
     136    return m_mediumFormat;
     137}
     138
     139QString UIWizardNewVMDiskPageBasic::mediumPath() const
     140{
     141    return QString();//absoluteFilePath(toFileName(m_strDefaultName, m_strDefaultExtension), m_strDefaultPath);
     142}
     143
     144void UIWizardNewVMDiskPageBasic::prepare()
     145{
     146    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     147
     148    m_pLabel = new QIRichTextLabel(this);
     149    pMainLayout->addWidget(m_pLabel);
     150    pMainLayout->addWidget(createDiskWidgets());
     151
     152    pMainLayout->addStretch();
     153    // setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing);
     154    // setEnableNewDiskWidgets(m_enmSelectedDiskSource == SelectedDiskSource_New);
     155
     156    createConnections();
     157}
     158
     159QWidget *UIWizardNewVMDiskPageBasic::createNewDiskWidgets()
     160{
     161    QWidget *pWidget = new QWidget;
     162    if (pWidget)
    75163    {
    76         m_pDiskSelector->setCurrentItem(uMediumId);
    77         m_pDiskSelector->setFocus();
     164        QVBoxLayout *pLayout = new QVBoxLayout(pWidget);
     165        if (pLayout)
     166        {
     167            pLayout->setContentsMargins(0, 0, 0, 0);
     168
     169            /* Prepare size layout: */
     170            QGridLayout *pSizeLayout = new QGridLayout;
     171            if (pSizeLayout)
     172            {
     173                pSizeLayout->setContentsMargins(0, 0, 0, 0);
     174
     175                /* Prepare Hard disk size label: */
     176                m_pMediumSizeEditorLabel = new QLabel(pWidget);
     177                if (m_pMediumSizeEditorLabel)
     178                {
     179                    m_pMediumSizeEditorLabel->setAlignment(Qt::AlignRight);
     180                    m_pMediumSizeEditorLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     181                    pSizeLayout->addWidget(m_pMediumSizeEditorLabel, 0, 0, Qt::AlignBottom);
     182                }
     183                /* Prepare Hard disk size editor: */
     184                m_pMediumSizeEditor = new UIMediumSizeEditor(pWidget);
     185                if (m_pMediumSizeEditor)
     186                {
     187                    m_pMediumSizeEditorLabel->setBuddy(m_pMediumSizeEditor);
     188                    pSizeLayout->addWidget(m_pMediumSizeEditor, 0, 1, 2, 1);
     189                }
     190
     191                pLayout->addLayout(pSizeLayout);
     192            }
     193
     194            /* Hard disk variant (dynamic vs. fixed) widgets: */
     195            pLayout->addWidget(createMediumVariantWidgets(false /* bool fWithLabels */));
     196        }
    78197    }
    79 }
    80 
    81 void UIWizardNewVMPageDiskBase::retranslateWidgets()
    82 {
     198
     199    return pWidget;
     200}
     201
     202void UIWizardNewVMDiskPageBasic::createConnections()
     203{
     204    // if (m_pDiskSourceButtonGroup)
     205    //     connect(m_pDiskSourceButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked),
     206    //             this, &UIWizardNewVMDiskPageBasic::sltSelectedDiskSourceChanged);
     207    // if (m_pDiskSelector)
     208    //     connect(m_pDiskSelector, static_cast<void(UIMediaComboBox::*)(int)>(&UIMediaComboBox::currentIndexChanged),
     209    //             this, &UIWizardNewVMDiskPageBasic::sltMediaComboBoxIndexChanged);
     210    // if (m_pDiskSelectionButton)
     211    //     connect(m_pDiskSelectionButton, &QIToolButton::clicked,
     212    //             this, &UIWizardNewVMDiskPageBasic::sltGetWithFileOpenDialog);
     213    // if (m_pMediumSizeEditor)
     214    // {
     215    //     connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
     216    //             this, &UIWizardNewVMDiskPageBasic::completeChanged);
     217    //     connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
     218    //             this, &UIWizardNewVMDiskPageBasic::sltHandleSizeEditorChange);
     219    // }
     220}
     221
     222void UIWizardNewVMDiskPageBasic::sltSelectedDiskSourceChanged()
     223{
     224    // if (!m_pDiskSourceButtonGroup)
     225    //     return;
     226
     227    // if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskEmpty)
     228    //     setSelectedDiskSource(SelectedDiskSource_Empty);
     229    // else if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskExisting)
     230    // {
     231    //     setSelectedDiskSource(SelectedDiskSource_Existing);
     232    //     setVirtualDiskFromDiskCombo();
     233    // }
     234    // else
     235    //     setSelectedDiskSource(SelectedDiskSource_New);
     236
     237    // setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing);
     238    // setEnableNewDiskWidgets(m_enmSelectedDiskSource == SelectedDiskSource_New);
     239
     240    // completeChanged();
     241}
     242
     243void UIWizardNewVMDiskPageBasic::sltMediaComboBoxIndexChanged()
     244{
     245    /* Make sure to set m_virtualDisk: */
     246    setVirtualDiskFromDiskCombo();
     247    emit completeChanged();
     248}
     249
     250void UIWizardNewVMDiskPageBasic::sltGetWithFileOpenDialog()
     251{
     252    //getWithFileOpenDialog();
     253}
     254
     255void UIWizardNewVMDiskPageBasic::retranslateUi()
     256{
     257    setTitle(UIWizardNewVM::tr("Virtual Hard disk"));
     258
     259    // QString strRecommendedHDD = field("type").value<CGuestOSType>().isNull() ? QString() :
     260    //                             UICommon::formatSize(field("type").value<CGuestOSType>().GetRecommendedHDD());
     261    if (m_pLabel)
     262        m_pLabel->setText(UIWizardNewVM::tr("<p>If you wish you can add a virtual hard disk to the new machine. "
     263                                            "You can either create a new hard disk file or select an existing one. "
     264                                            "Alternatively you can create a virtual machine without a virtual hard disk.</p>"));
     265
    83266    if (m_pDiskEmpty)
    84267        m_pDiskEmpty->setText(UIWizardNewVM::tr("&Do Not Add a Virtual Hard Disk"));
     
    89272    if (m_pDiskSelectionButton)
    90273        m_pDiskSelectionButton->setToolTip(UIWizardNewVM::tr("Choose a Virtual Hard Fisk File..."));
    91 }
    92 
    93 void UIWizardNewVMPageDiskBase::setEnableDiskSelectionWidgets(bool fEnabled)
    94 {
    95     if (!m_pDiskSelector || !m_pDiskSelectionButton)
    96         return;
    97 
    98     m_pDiskSelector->setEnabled(fEnabled);
    99     m_pDiskSelectionButton->setEnabled(fEnabled);
    100 }
    101 
    102 QWidget *UIWizardNewVMPageDiskBase::createNewDiskWidgets()
    103 {
    104     return new QWidget();
    105 }
    106 
    107 QWidget *UIWizardNewVMPageDiskBase::createDiskWidgets()
     274
     275    if (m_pMediumSizeEditorLabel)
     276        m_pMediumSizeEditorLabel->setText(UIWizardNewVD::tr("D&isk Size:"));
     277
     278    if (m_pFixedCheckBox)
     279    {
     280        m_pFixedCheckBox->setText(UIWizardNewVD::tr("Pre-allocate &Full Size"));
     281        m_pFixedCheckBox->setToolTip(UIWizardNewVD::tr("<p>When checked, the virtual disk image will be fully allocated at "
     282                                                       "VM creation time, rather than being allocated dynamically at VM run-time.</p>"));
     283    }
     284
     285    if (m_pSplitBox)
     286        m_pSplitBox->setText(UIWizardNewVD::tr("&Split Into Files of Less Than 2GB"));
     287
     288
     289    /* Translate rich text labels: */
     290    if (m_pDescriptionLabel)
     291        m_pDescriptionLabel->setText(UIWizardNewVD::tr("Please choose whether the new virtual hard disk file should grow as it is used "
     292                                                       "(dynamically allocated) or if it should be created at its maximum size (fixed size)."));
     293    if (m_pDynamicLabel)
     294        m_pDynamicLabel->setText(UIWizardNewVD::tr("<p>A <b>dynamically allocated</b> hard disk file will only use space "
     295                                                   "on your physical hard disk as it fills up (up to a maximum <b>fixed size</b>), "
     296                                                   "although it will not shrink again automatically when space on it is freed.</p>"));
     297    if (m_pFixedLabel)
     298        m_pFixedLabel->setText(UIWizardNewVD::tr("<p>A <b>fixed size</b> hard disk file may take longer to create on some "
     299                                                 "systems but is often faster to use.</p>"));
     300    if (m_pSplitLabel)
     301        m_pSplitLabel->setText(UIWizardNewVD::tr("<p>You can also choose to <b>split</b> the hard disk file into several files "
     302                                                 "of up to two gigabytes each. This is mainly useful if you wish to store the "
     303                                                 "virtual machine on removable USB devices or old systems, some of which cannot "
     304                                                 "handle very large files."));
     305
     306}
     307
     308void UIWizardNewVMDiskPageBasic::initializePage()
     309{
     310//     retranslateUi();
     311
     312//     if (!field("type").canConvert<CGuestOSType>())
     313//         return;
     314
     315//     CGuestOSType type = field("type").value<CGuestOSType>();
     316
     317//     if (type.GetRecommendedHDD() != 0)
     318//     {
     319//         if (m_pDiskNew)
     320//         {
     321//             m_pDiskNew->setFocus();
     322//             m_pDiskNew->setChecked(true);
     323//         }
     324//         setSelectedDiskSource(SelectedDiskSource_New);
     325//         m_fRecommendedNoDisk = false;
     326//     }
     327//     else
     328//     {
     329//         if (m_pDiskEmpty)
     330//         {
     331//             m_pDiskEmpty->setFocus();
     332//             m_pDiskEmpty->setChecked(true);
     333//         }
     334//         setSelectedDiskSource(SelectedDiskSource_Empty);
     335//         m_fRecommendedNoDisk = true;
     336//     }
     337//     if (m_pDiskSelector)
     338//         m_pDiskSelector->setCurrentIndex(0);
     339//     setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing);
     340//     setEnableNewDiskWidgets(m_enmSelectedDiskSource == SelectedDiskSource_New);
     341
     342//     /* We set the medium name and path according to machine name/path and do let user change these in the guided mode: */
     343//     QString strDefaultName = fieldImp("machineBaseName").toString();
     344//     m_strDefaultName = strDefaultName.isEmpty() ? QString("NewVirtualDisk1") : strDefaultName;
     345//     m_strDefaultPath = fieldImp("machineFolder").toString();
     346//     /* Set the recommended disk size if user has already not done so: */
     347//     if (m_pMediumSizeEditor && !m_fUserSetSize)
     348//     {
     349//         m_pMediumSizeEditor->blockSignals(true);
     350//         setMediumSize(fieldImp("type").value<CGuestOSType>().GetRecommendedHDD());
     351//         m_pMediumSizeEditor->blockSignals(false);
     352//     }
     353}
     354
     355void UIWizardNewVMDiskPageBasic::cleanupPage()
     356{
     357    //UIWizardPage::cleanupPage();
     358}
     359
     360bool UIWizardNewVMDiskPageBasic::isComplete() const
     361{
     362    // if (selectedDiskSource() == SelectedDiskSource_New)
     363    //     return mediumSize() >= m_uMediumSizeMin && mediumSize() <= m_uMediumSizeMax;
     364    // UIWizardNewVM *pWizard = wizardImp();
     365    // AssertReturn(pWizard, false);
     366    // if (selectedDiskSource() == SelectedDiskSource_Existing)
     367    //     return !pWizard->virtualDisk().isNull();
     368
     369    // if (m_pDiskNew && m_pDiskNew->isChecked())
     370    // {
     371    //     qulonglong uSize = field("mediumSize").toULongLong();
     372    //     if (uSize <= 0)
     373    //         return false;
     374    // }
     375
     376    return true;
     377}
     378
     379bool UIWizardNewVMDiskPageBasic::validatePage()
     380{
     381    bool fResult = true;
     382
     383    // /* Make sure user really intents to creae a vm with no hard drive: */
     384    // if (selectedDiskSource() == SelectedDiskSource_Empty)
     385    // {
     386    //     /* Ask user about disk-less machine unless that's the recommendation: */
     387    //     if (!m_fRecommendedNoDisk)
     388    //     {
     389    //         if (!msgCenter().confirmHardDisklessMachine(thisImp()))
     390    //             return false;
     391    //     }
     392    // }
     393    // else if (selectedDiskSource() == SelectedDiskSource_New)
     394    // {
     395    //     /* Check if the path we will be using for hard drive creation exists: */
     396    //     const QString strMediumPath(fieldImp("mediumPath").toString());
     397    //     fResult = !QFileInfo(strMediumPath).exists();
     398    //     if (!fResult)
     399    //     {
     400    //         msgCenter().cannotOverwriteHardDiskStorage(strMediumPath, this);
     401    //         return fResult;
     402    //     }
     403    //     /* Check FAT size limitation of the host hard drive: */
     404    //     fResult = UIWizardNewVDPageBaseSizeLocation::checkFATSizeLimitation(fieldImp("mediumVariant").toULongLong(),
     405    //                                                          fieldImp("mediumPath").toString(),
     406    //                                                          fieldImp("mediumSize").toULongLong());
     407    //     if (!fResult)
     408    //     {
     409    //         msgCenter().cannotCreateHardDiskStorageInFAT(strMediumPath, this);
     410    //         return fResult;
     411    //     }
     412    // }
     413
     414    // startProcessing();
     415    // UIWizardNewVM *pWizard = wizardImp();
     416    // if (pWizard)
     417    // {
     418    //     if (selectedDiskSource() == SelectedDiskSource_New)
     419    //     {
     420    //         /* Try to create the hard drive:*/
     421    //         fResult = pWizard->createVirtualDisk();
     422    //         /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */
     423    //         if (!fResult)
     424    //             return fResult;
     425    //     }
     426
     427    //     fResult = pWizard->createVM();
     428    //     /* Try to delete the hard disk: */
     429    //     if (!fResult)
     430    //         pWizard->deleteVirtualDisk();
     431    // }
     432    // endProcessing();
     433
     434    return fResult;
     435}
     436
     437void UIWizardNewVMDiskPageBasic::sltHandleSizeEditorChange()
     438{
     439    m_fUserSetSize = true;
     440}
     441
     442void UIWizardNewVMDiskPageBasic::setEnableNewDiskWidgets(bool fEnable)
     443{
     444    Q_UNUSED(fEnable);
     445    // if (m_pMediumSizeEditor)
     446    //     m_pMediumSizeEditor->setEnabled(fEnable);
     447    // if (m_pMediumSizeEditorLabel)
     448    //     m_pMediumSizeEditorLabel->setEnabled(fEnable);
     449    // if (m_pFixedCheckBox)
     450    //     m_pFixedCheckBox->setEnabled(fEnable);
     451}
     452
     453void UIWizardNewVMDiskPageBasic::setVirtualDiskFromDiskCombo()
     454{
     455    // AssertReturnVoid(m_pDiskSelector);
     456    // UIWizardNewVM *pWizard = wizardImp();
     457    // AssertReturnVoid(pWizard);
     458    // pWizard->setVirtualDisk(m_pDiskSelector->id());
     459}
     460
     461QWidget *UIWizardNewVMDiskPageBasic::createDiskWidgets()
    108462{
    109463    QWidget *pDiskContainer = new QWidget;
     
    140494}
    141495
    142 UIWizardNewVMPageDisk::UIWizardNewVMPageDisk()
    143     : m_pLabel(0)
    144     , m_fUserSetSize(false)
    145 
    146 {
    147     prepare();
    148     qRegisterMetaType<CMedium>();
    149     qRegisterMetaType<SelectedDiskSource>();
    150     registerField("selectedDiskSource", this, "selectedDiskSource");
    151 
    152     registerField("mediumFormat", this, "mediumFormat");
    153     registerField("mediumVariant" /* KMediumVariant */, this, "mediumVariant");
    154     registerField("mediumPath", this, "mediumPath");
    155     registerField("mediumSize", this, "mediumSize");
    156 
    157     /* We do not have any UI elements for HDD format selection since we default to VDI in case of guided wizard mode: */
    158     bool fFoundVDI = false;
    159     CSystemProperties properties = uiCommon().virtualBox().GetSystemProperties();
    160     const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
    161     foreach (const CMediumFormat &format, formats)
     496QWidget *UIWizardNewVMDiskPageBasic::createMediumVariantWidgets(bool fWithLabels)
     497{
     498    QWidget *pContainerWidget = new QWidget;
     499    QVBoxLayout *pMainLayout = new QVBoxLayout(pContainerWidget);
     500    if (pMainLayout)
    162501    {
    163         if (format.GetName() == "VDI")
     502        if (fWithLabels)
    164503        {
    165             m_mediumFormat = format;
    166             fFoundVDI = true;
     504            m_pDescriptionLabel = new QIRichTextLabel;
     505            m_pDynamicLabel = new QIRichTextLabel;
     506            m_pFixedLabel = new QIRichTextLabel;
     507            m_pSplitLabel = new QIRichTextLabel;
    167508        }
     509        QVBoxLayout *pVariantLayout = new QVBoxLayout;
     510        if (pVariantLayout)
     511        {
     512            m_pFixedCheckBox = new QCheckBox;
     513            m_pSplitBox = new QCheckBox;
     514            pVariantLayout->addWidget(m_pFixedCheckBox);
     515            pVariantLayout->addWidget(m_pSplitBox);
     516        }
     517        if (fWithLabels)
     518        {
     519            pMainLayout->addWidget(m_pDescriptionLabel);
     520            pMainLayout->addWidget(m_pDynamicLabel);
     521            pMainLayout->addWidget(m_pFixedLabel);
     522            pMainLayout->addWidget(m_pSplitLabel);
     523        }
     524        pMainLayout->addLayout(pVariantLayout);
     525        pMainLayout->addStretch();
     526        pMainLayout->setContentsMargins(0, 0, 0, 0);
    168527    }
    169     if (!fFoundVDI)
    170         AssertMsgFailed(("No medium format corresponding to VDI could be found!"));
    171 
    172     m_strDefaultExtension =  defaultExtension(m_mediumFormat);
    173 
    174     /* Since the medium format is static we can decide widget visibility here: */
    175     setWidgetVisibility(m_mediumFormat);
    176 }
    177 
    178 CMediumFormat UIWizardNewVMPageDisk::mediumFormat() const
    179 {
    180     return m_mediumFormat;
    181 }
    182 
    183 QString UIWizardNewVMPageDisk::mediumPath() const
    184 {
    185     return absoluteFilePath(toFileName(m_strDefaultName, m_strDefaultExtension), m_strDefaultPath);
    186 }
    187 
    188 void UIWizardNewVMPageDisk::prepare()
    189 {
    190     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    191 
    192     m_pLabel = new QIRichTextLabel(this);
    193     pMainLayout->addWidget(m_pLabel);
    194     pMainLayout->addWidget(createDiskWidgets());
    195 
    196     pMainLayout->addStretch();
    197     setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing);
    198     setEnableNewDiskWidgets(m_enmSelectedDiskSource == SelectedDiskSource_New);
    199 
    200     createConnections();
    201 }
    202 
    203 QWidget *UIWizardNewVMPageDisk::createNewDiskWidgets()
    204 {
    205     QWidget *pWidget = new QWidget;
    206     if (pWidget)
    207     {
    208         QVBoxLayout *pLayout = new QVBoxLayout(pWidget);
    209         if (pLayout)
    210         {
    211             pLayout->setContentsMargins(0, 0, 0, 0);
    212 
    213             /* Prepare size layout: */
    214             QGridLayout *pSizeLayout = new QGridLayout;
    215             if (pSizeLayout)
    216             {
    217                 pSizeLayout->setContentsMargins(0, 0, 0, 0);
    218 
    219                 /* Prepare Hard disk size label: */
    220                 m_pMediumSizeEditorLabel = new QLabel(pWidget);
    221                 if (m_pMediumSizeEditorLabel)
    222                 {
    223                     m_pMediumSizeEditorLabel->setAlignment(Qt::AlignRight);
    224                     m_pMediumSizeEditorLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    225                     pSizeLayout->addWidget(m_pMediumSizeEditorLabel, 0, 0, Qt::AlignBottom);
    226                 }
    227                 /* Prepare Hard disk size editor: */
    228                 m_pMediumSizeEditor = new UIMediumSizeEditor(pWidget);
    229                 if (m_pMediumSizeEditor)
    230                 {
    231                     m_pMediumSizeEditorLabel->setBuddy(m_pMediumSizeEditor);
    232                     pSizeLayout->addWidget(m_pMediumSizeEditor, 0, 1, 2, 1);
    233                 }
    234 
    235                 pLayout->addLayout(pSizeLayout);
    236             }
    237 
    238             /* Hard disk variant (dynamic vs. fixed) widgets: */
    239             pLayout->addWidget(createMediumVariantWidgets(false /* bool fWithLabels */));
    240         }
    241     }
    242 
    243     return pWidget;
    244 }
    245 
    246 void UIWizardNewVMPageDisk::createConnections()
    247 {
    248     if (m_pDiskSourceButtonGroup)
    249         connect(m_pDiskSourceButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked),
    250                 this, &UIWizardNewVMPageDisk::sltSelectedDiskSourceChanged);
    251     if (m_pDiskSelector)
    252         connect(m_pDiskSelector, static_cast<void(UIMediaComboBox::*)(int)>(&UIMediaComboBox::currentIndexChanged),
    253                 this, &UIWizardNewVMPageDisk::sltMediaComboBoxIndexChanged);
    254     if (m_pDiskSelectionButton)
    255         connect(m_pDiskSelectionButton, &QIToolButton::clicked,
    256                 this, &UIWizardNewVMPageDisk::sltGetWithFileOpenDialog);
    257     if (m_pMediumSizeEditor)
    258     {
    259         connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
    260                 this, &UIWizardNewVMPageDisk::completeChanged);
    261         connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
    262                 this, &UIWizardNewVMPageDisk::sltHandleSizeEditorChange);
    263     }
    264 }
    265 
    266 void UIWizardNewVMPageDisk::sltSelectedDiskSourceChanged()
    267 {
    268     if (!m_pDiskSourceButtonGroup)
    269         return;
    270 
    271     if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskEmpty)
    272         setSelectedDiskSource(SelectedDiskSource_Empty);
    273     else if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskExisting)
    274     {
    275         setSelectedDiskSource(SelectedDiskSource_Existing);
    276         setVirtualDiskFromDiskCombo();
    277     }
    278     else
    279         setSelectedDiskSource(SelectedDiskSource_New);
    280 
    281     setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing);
    282     setEnableNewDiskWidgets(m_enmSelectedDiskSource == SelectedDiskSource_New);
    283 
    284     completeChanged();
    285 }
    286 
    287 void UIWizardNewVMPageDisk::sltMediaComboBoxIndexChanged()
    288 {
    289     /* Make sure to set m_virtualDisk: */
    290     setVirtualDiskFromDiskCombo();
    291     emit completeChanged();
    292 }
    293 
    294 void UIWizardNewVMPageDisk::sltGetWithFileOpenDialog()
    295 {
    296     getWithFileOpenDialog();
    297 }
    298 
    299 void UIWizardNewVMPageDisk::retranslateUi()
    300 {
    301     setTitle(UIWizardNewVM::tr("Virtual Hard disk"));
    302 
    303     QString strRecommendedHDD = field("type").value<CGuestOSType>().isNull() ? QString() :
    304                                 UICommon::formatSize(field("type").value<CGuestOSType>().GetRecommendedHDD());
    305     if (m_pLabel)
    306         m_pLabel->setText(UIWizardNewVM::tr("<p>If you wish you can add a virtual hard disk to the new machine. "
    307                                             "You can either create a new hard disk file or select an existing one. "
    308                                             "Alternatively you can create a virtual machine without a virtual hard disk.</p>"));
    309 
    310     UIWizardNewVMPageDiskBase::retranslateWidgets();
    311     UIWizardNewVDPageBaseFileType::retranslateWidgets();
    312     UIWizardNewVDPageBaseVariant::retranslateWidgets();
    313     UIWizardNewVDPageBaseSizeLocation::retranslateWidgets();
    314 }
    315 
    316 void UIWizardNewVMPageDisk::initializePage()
    317 {
    318     retranslateUi();
    319 
    320     if (!field("type").canConvert<CGuestOSType>())
    321         return;
    322 
    323     CGuestOSType type = field("type").value<CGuestOSType>();
    324 
    325     if (type.GetRecommendedHDD() != 0)
    326     {
    327         if (m_pDiskNew)
    328         {
    329             m_pDiskNew->setFocus();
    330             m_pDiskNew->setChecked(true);
    331         }
    332         setSelectedDiskSource(SelectedDiskSource_New);
    333         m_fRecommendedNoDisk = false;
    334     }
    335     else
    336     {
    337         if (m_pDiskEmpty)
    338         {
    339             m_pDiskEmpty->setFocus();
    340             m_pDiskEmpty->setChecked(true);
    341         }
    342         setSelectedDiskSource(SelectedDiskSource_Empty);
    343         m_fRecommendedNoDisk = true;
    344     }
    345     if (m_pDiskSelector)
    346         m_pDiskSelector->setCurrentIndex(0);
    347     setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing);
    348     setEnableNewDiskWidgets(m_enmSelectedDiskSource == SelectedDiskSource_New);
    349 
    350     /* We set the medium name and path according to machine name/path and do let user change these in the guided mode: */
    351     QString strDefaultName = fieldImp("machineBaseName").toString();
    352     m_strDefaultName = strDefaultName.isEmpty() ? QString("NewVirtualDisk1") : strDefaultName;
    353     m_strDefaultPath = fieldImp("machineFolder").toString();
    354     /* Set the recommended disk size if user has already not done so: */
    355     if (m_pMediumSizeEditor && !m_fUserSetSize)
    356     {
    357         m_pMediumSizeEditor->blockSignals(true);
    358         setMediumSize(fieldImp("type").value<CGuestOSType>().GetRecommendedHDD());
    359         m_pMediumSizeEditor->blockSignals(false);
    360     }
    361 }
    362 
    363 void UIWizardNewVMPageDisk::cleanupPage()
    364 {
    365     UIWizardPage::cleanupPage();
    366 }
    367 
    368 bool UIWizardNewVMPageDisk::isComplete() const
    369 {
    370     if (selectedDiskSource() == SelectedDiskSource_New)
    371         return mediumSize() >= m_uMediumSizeMin && mediumSize() <= m_uMediumSizeMax;
    372     UIWizardNewVM *pWizard = wizardImp();
    373     AssertReturn(pWizard, false);
    374     if (selectedDiskSource() == SelectedDiskSource_Existing)
    375         return !pWizard->virtualDisk().isNull();
    376 
    377     if (m_pDiskNew && m_pDiskNew->isChecked())
    378     {
    379         qulonglong uSize = field("mediumSize").toULongLong();
    380         if (uSize <= 0)
    381             return false;
    382     }
    383 
    384     return true;
    385 }
    386 
    387 bool UIWizardNewVMPageDisk::validatePage()
    388 {
    389     bool fResult = true;
    390 
    391     /* Make sure user really intents to creae a vm with no hard drive: */
    392     if (selectedDiskSource() == SelectedDiskSource_Empty)
    393     {
    394         /* Ask user about disk-less machine unless that's the recommendation: */
    395         if (!m_fRecommendedNoDisk)
    396         {
    397             if (!msgCenter().confirmHardDisklessMachine(thisImp()))
    398                 return false;
    399         }
    400     }
    401     else if (selectedDiskSource() == SelectedDiskSource_New)
    402     {
    403         /* Check if the path we will be using for hard drive creation exists: */
    404         const QString strMediumPath(fieldImp("mediumPath").toString());
    405         fResult = !QFileInfo(strMediumPath).exists();
    406         if (!fResult)
    407         {
    408             msgCenter().cannotOverwriteHardDiskStorage(strMediumPath, this);
    409             return fResult;
    410         }
    411         /* Check FAT size limitation of the host hard drive: */
    412         fResult = UIWizardNewVDPageBaseSizeLocation::checkFATSizeLimitation(fieldImp("mediumVariant").toULongLong(),
    413                                                              fieldImp("mediumPath").toString(),
    414                                                              fieldImp("mediumSize").toULongLong());
    415         if (!fResult)
    416         {
    417             msgCenter().cannotCreateHardDiskStorageInFAT(strMediumPath, this);
    418             return fResult;
    419         }
    420     }
    421 
    422     startProcessing();
    423     UIWizardNewVM *pWizard = wizardImp();
    424     if (pWizard)
    425     {
    426         if (selectedDiskSource() == SelectedDiskSource_New)
    427         {
    428             /* Try to create the hard drive:*/
    429             fResult = pWizard->createVirtualDisk();
    430             /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */
    431             if (!fResult)
    432                 return fResult;
    433         }
    434 
    435         fResult = pWizard->createVM();
    436         /* Try to delete the hard disk: */
    437         if (!fResult)
    438             pWizard->deleteVirtualDisk();
    439     }
    440     endProcessing();
    441 
    442     return fResult;
    443 }
    444 
    445 void UIWizardNewVMPageDisk::sltHandleSizeEditorChange()
    446 {
    447     m_fUserSetSize = true;
    448 }
    449 
    450 void UIWizardNewVMPageDisk::setEnableNewDiskWidgets(bool fEnable)
    451 {
    452     if (m_pMediumSizeEditor)
    453         m_pMediumSizeEditor->setEnabled(fEnable);
    454     if (m_pMediumSizeEditorLabel)
    455         m_pMediumSizeEditorLabel->setEnabled(fEnable);
    456     if (m_pFixedCheckBox)
    457         m_pFixedCheckBox->setEnabled(fEnable);
    458 }
    459 
    460 void UIWizardNewVMPageDisk::setVirtualDiskFromDiskCombo()
    461 {
    462     AssertReturnVoid(m_pDiskSelector);
    463     UIWizardNewVM *pWizard = wizardImp();
    464     AssertReturnVoid(pWizard);
    465     pWizard->setVirtualDisk(m_pDiskSelector->id());
    466 }
     528    return pContainerWidget;
     529}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPageBasic.h

    r90002 r90003  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewVMPageDisk class declaration.
     3 * VBox Qt GUI - UIWizardNewVMDiskPageBasic class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageDisk_h
    19 #define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageDisk_h
     18#ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMDiskPageBasic_h
     19#define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMDiskPageBasic_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2626
    2727/* GUI includes: */
    28 #include "UIWizardPage.h"
     28#include "UINativeWizardPage.h"
    2929#include "UIWizardNewVDPageFileType.h"
    3030#include "UIWizardNewVDPageVariant.h"
     
    4444
    4545
    46 class UIWizardNewVMPageDiskBase : public UIWizardPageBase
     46// class UIWizardNewVMDiskPage : public UIWizardPageBase
     47// {
     48
     49// public:
     50
     51
     52// protected:
     53
     54//     UIWizardNewVMDiskPage();
     55
     56//     SelectedDiskSource selectedDiskSource() const;
     57//     void setSelectedDiskSource(SelectedDiskSource enmSelectedDiskSource);
     58//     bool getWithNewVirtualDiskWizard();
     59
     60//     virtual QWidget *createDiskWidgets();
     61//     virtual QWidget *createNewDiskWidgets();
     62//     void getWithFileOpenDialog();
     63//     void retranslateWidgets();
     64
     65//     void setEnableDiskSelectionWidgets(bool fEnable);
     66//     bool m_fRecommendedNoDisk;
     67
     68//     SelectedDiskSource m_enmSelectedDiskSource;
     69// };
     70
     71class UIWizardNewVMDiskPageBasic : public UINativeWizardPage
    4772{
     73    Q_OBJECT;
    4874
    4975public:
    5076
    51 
    52 protected:
    53 
    54     UIWizardNewVMPageDiskBase();
    55 
    56     SelectedDiskSource selectedDiskSource() const;
    57     void setSelectedDiskSource(SelectedDiskSource enmSelectedDiskSource);
    58     bool getWithNewVirtualDiskWizard();
    59 
    60     virtual QWidget *createDiskWidgets();
    61     virtual QWidget *createNewDiskWidgets();
    62     void getWithFileOpenDialog();
    63     void retranslateWidgets();
    64 
    65     void setEnableDiskSelectionWidgets(bool fEnable);
    66     bool m_fRecommendedNoDisk;
    67 
    68     /** @name Widgets
    69      * @{ */
    70        QButtonGroup *m_pDiskSourceButtonGroup;
    71        QRadioButton *m_pDiskEmpty;
    72        QRadioButton *m_pDiskNew;
    73        QRadioButton *m_pDiskExisting;
    74        UIMediaComboBox *m_pDiskSelector;
    75        QIToolButton *m_pDiskSelectionButton;
    76     /** @} */
    77     SelectedDiskSource m_enmSelectedDiskSource;
    78 };
    79 
    80 class UIWizardNewVMPageDisk : public UIWizardPage,
    81                                 public UIWizardNewVMPageDiskBase,
    82                                 public UIWizardNewVDPageBaseFileType,
    83                                 public UIWizardNewVDPageBaseVariant,
    84                                 public UIWizardNewVDPageBaseSizeLocation
    85 {
    86     Q_OBJECT;
    87     Q_PROPERTY(SelectedDiskSource selectedDiskSource READ selectedDiskSource WRITE setSelectedDiskSource);
    88     Q_PROPERTY(CMediumFormat mediumFormat READ mediumFormat);
    89     Q_PROPERTY(qulonglong mediumVariant READ mediumVariant WRITE setMediumVariant);
    90     Q_PROPERTY(QString mediumPath READ mediumPath);
    91     Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize);
    92 
    93 public:
    94 
    95     UIWizardNewVMPageDisk();
     77    UIWizardNewVMDiskPageBasic();
    9678    /** For the guide wizard mode medium path, name and extention is static and we have
    9779      * no UI element for this. thus override. */
     
    10183protected:
    10284
    103     /** Wrapper to access 'wizard' from base part. */
    104     UIWizardNewVM *wizardImp() const { return qobject_cast<UIWizardNewVM*>(wizard()); }
    105     /** Wrapper to access 'this' from base part. */
    106     UIWizardPage* thisImp() { return this; }
    107     /** Wrapper to access 'wizard-field' from base part. */
    108     QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
    10985
    11086private slots:
     
    125101    void setEnableNewDiskWidgets(bool fEnable);
    126102    void setVirtualDiskFromDiskCombo();
    127 
     103    QWidget *createDiskWidgets();
     104    QWidget *createMediumVariantWidgets(bool fWithLabels);
    128105    bool isComplete() const;
    129106    virtual bool validatePage() /* override */;
    130107
    131     QIRichTextLabel *m_pLabel;
     108    /** @name Widgets
     109     * @{ */
     110       QButtonGroup *m_pDiskSourceButtonGroup;
     111       QRadioButton *m_pDiskEmpty;
     112       QRadioButton *m_pDiskNew;
     113       QRadioButton *m_pDiskExisting;
     114       UIMediaComboBox *m_pDiskSelector;
     115       QIToolButton *m_pDiskSelectionButton;
     116       QIRichTextLabel *m_pLabel;
     117       QLabel          *m_pMediumSizeEditorLabel;
     118       UIMediumSizeEditor *m_pMediumSizeEditor;
     119       QIRichTextLabel *m_pDescriptionLabel;
     120       QIRichTextLabel *m_pDynamicLabel;
     121       QIRichTextLabel *m_pFixedLabel;
     122       QIRichTextLabel *m_pSplitLabel;
     123       QCheckBox *m_pFixedCheckBox;
     124       QCheckBox *m_pSplitBox;
     125    /** @} */
    132126
    133127    /** This is set to true when user manually set the size. */
     
    137131};
    138132
    139 #endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageDisk_h */
     133#endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMDiskPageBasic_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMHardwarePageBasic.cpp

    r90002 r90003  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewVMPageHardware class implementation.
     3 * VBox Qt GUI - UIWizardNewVMHardwarePageBasic class implementation.
    44 */
    55
     
    2828#include "UIVirtualCPUEditor.h"
    2929#include "UIWizardNewVM.h"
    30 #include "UIWizardNewVMPageHardware.h"
     30#include "UIWizardNewVMHardwarePageBasic.h"
    3131#include "UIWizardNewVDPageSizeLocation.h"
    3232
     
    3434#include "CGuestOSType.h"
    3535
    36 UIWizardNewVMPageHardwareBase::UIWizardNewVMPageHardwareBase()
     36// UIWizardNewVMHardwarePage::UIWizardNewVMHardwarePage()
     37// {
     38// }
     39
     40// int UIWizardNewVMHardwarePage::baseMemory() const
     41// {
     42//     if (!m_pBaseMemoryEditor)
     43//         return 0;
     44//     return m_pBaseMemoryEditor->value();
     45// }
     46
     47// int UIWizardNewVMHardwarePage::VCPUCount() const
     48// {
     49//     if (!m_pVirtualCPUEditor)
     50//         return 1;
     51//     return m_pVirtualCPUEditor->value();
     52// }
     53
     54// bool UIWizardNewVMHardwarePage::EFIEnabled() const
     55// {
     56//     if (!m_pEFICheckBox)
     57//         return false;
     58//     return m_pEFICheckBox->isChecked();
     59// }
     60
     61
     62UIWizardNewVMHardwarePageBasic::UIWizardNewVMHardwarePageBasic()
    3763    : m_pBaseMemoryEditor(0)
    3864    , m_pVirtualCPUEditor(0)
    3965    , m_pEFICheckBox(0)
     66    , m_pLabel(0)
     67{
     68    prepare();
     69    qRegisterMetaType<CMedium>();
     70}
     71
     72void UIWizardNewVMHardwarePageBasic::prepare()
     73{
     74    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
     75
     76    m_pLabel = new QIRichTextLabel(this);
     77    pMainLayout->addWidget(m_pLabel);
     78    pMainLayout->addWidget(createHardwareWidgets());
     79
     80    pMainLayout->addStretch();
     81    // createConnections();
     82}
     83
     84void UIWizardNewVMHardwarePageBasic::createConnections()
    4085{
    4186}
    4287
    43 int UIWizardNewVMPageHardwareBase::baseMemory() const
     88void UIWizardNewVMHardwarePageBasic::retranslateUi()
    4489{
    45     if (!m_pBaseMemoryEditor)
    46         return 0;
    47     return m_pBaseMemoryEditor->value();
    48 }
     90    setTitle(UIWizardNewVM::tr("Hardware"));
    4991
    50 int UIWizardNewVMPageHardwareBase::VCPUCount() const
    51 {
    52     if (!m_pVirtualCPUEditor)
    53         return 1;
    54     return m_pVirtualCPUEditor->value();
    55 }
     92    if (m_pLabel)
     93        m_pLabel->setText(UIWizardNewVM::tr("<p>You can modify virtual machine's hardware by changing amount of RAM and "
     94                                            "virtual CPU count. Enabling EFI is also possible.</p>"));
    5695
    57 bool UIWizardNewVMPageHardwareBase::EFIEnabled() const
    58 {
    59     if (!m_pEFICheckBox)
    60         return false;
    61     return m_pEFICheckBox->isChecked();
    62 }
    63 
    64 void UIWizardNewVMPageHardwareBase::retranslateWidgets()
    65 {
    6696    if (m_pEFICheckBox)
    6797    {
     
    73103}
    74104
    75 QWidget *UIWizardNewVMPageHardwareBase::createHardwareWidgets()
     105void UIWizardNewVMHardwarePageBasic::initializePage()
     106{
     107    retranslateUi();
     108
     109    // if (!field("type").canConvert<CGuestOSType>())
     110    //     return;
     111
     112    // CGuestOSType type = field("type").value<CGuestOSType>();
     113    // ULONG recommendedRam = type.GetRecommendedRAM();
     114    // if (m_pBaseMemoryEditor)
     115    //     m_pBaseMemoryEditor->setValue(recommendedRam);
     116
     117    // KFirmwareType fwType = type.GetRecommendedFirmware();
     118    // if (m_pEFICheckBox)
     119    //     m_pEFICheckBox->setChecked(fwType != KFirmwareType_BIOS);
     120}
     121
     122void UIWizardNewVMHardwarePageBasic::cleanupPage()
     123{
     124    //UIWizardPage::cleanupPage();
     125}
     126
     127bool UIWizardNewVMHardwarePageBasic::isComplete() const
     128{
     129    return true;
     130}
     131
     132QWidget *UIWizardNewVMHardwarePageBasic::createHardwareWidgets()
    76133{
    77134    QWidget *pHardwareContainer = new QWidget;
     
    88145    return pHardwareContainer;
    89146}
    90 
    91 UIWizardNewVMPageHardware::UIWizardNewVMPageHardware()
    92     : m_pLabel(0)
    93 {
    94     prepare();
    95     qRegisterMetaType<CMedium>();
    96     registerField("baseMemory", this, "baseMemory");
    97     registerField("VCPUCount", this, "VCPUCount");
    98     registerField("EFIEnabled", this, "EFIEnabled");
    99 }
    100 
    101 void UIWizardNewVMPageHardware::prepare()
    102 {
    103     QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    104 
    105     m_pLabel = new QIRichTextLabel(this);
    106     pMainLayout->addWidget(m_pLabel);
    107     pMainLayout->addWidget(createHardwareWidgets());
    108 
    109     pMainLayout->addStretch();
    110     createConnections();
    111 }
    112 
    113 void UIWizardNewVMPageHardware::createConnections()
    114 {
    115 }
    116 
    117 void UIWizardNewVMPageHardware::retranslateUi()
    118 {
    119     setTitle(UIWizardNewVM::tr("Hardware"));
    120 
    121     if (m_pLabel)
    122         m_pLabel->setText(UIWizardNewVM::tr("<p>You can modify virtual machine's hardware by changing amount of RAM and "
    123                                             "virtual CPU count. Enabling EFI is also possible.</p>"));
    124 
    125     retranslateWidgets();
    126 }
    127 
    128 void UIWizardNewVMPageHardware::initializePage()
    129 {
    130     retranslateUi();
    131 
    132     if (!field("type").canConvert<CGuestOSType>())
    133         return;
    134 
    135     CGuestOSType type = field("type").value<CGuestOSType>();
    136     ULONG recommendedRam = type.GetRecommendedRAM();
    137     if (m_pBaseMemoryEditor)
    138         m_pBaseMemoryEditor->setValue(recommendedRam);
    139 
    140     KFirmwareType fwType = type.GetRecommendedFirmware();
    141     if (m_pEFICheckBox)
    142         m_pEFICheckBox->setChecked(fwType != KFirmwareType_BIOS);
    143 }
    144 
    145 void UIWizardNewVMPageHardware::cleanupPage()
    146 {
    147     UIWizardPage::cleanupPage();
    148 }
    149 
    150 bool UIWizardNewVMPageHardware::isComplete() const
    151 {
    152     return true;
    153 }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMHardwarePageBasic.h

    r90002 r90003  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewVMPageHardware class declaration.
     3 * VBox Qt GUI - UIWizardNewVMHardwarePageBasic class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageHardware_h
    19 #define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageHardware_h
     18#ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMHardwarePageBasic_h
     19#define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMHardwarePageBasic_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2626
    2727/* GUI includes: */
    28 #include "UIWizardPage.h"
     28#include "UINativeWizardPage.h"
    2929
    3030/* COM includes: */
     
    4040
    4141/** 3rd page of the New Virtual Machine wizard (base part). */
    42 class UIWizardNewVMPageHardwareBase : public UIWizardPageBase
    43 {
     42// class UIWizardNewVMHardwarePage : public UIWizardPageBase
     43// {
    4444
    45 protected:
     45// protected:
    4646
    47     /** Constructor. */
    48     UIWizardNewVMPageHardwareBase();
     47//     /** Constructor. */
     48//     UIWizardNewVMHardwarePage();
    4949
    5050
    51     /** @name Property getters/setters
    52      * @{ */
    53        int baseMemory() const;
    54        int VCPUCount() const;
    55        bool EFIEnabled() const;
    56     /** @} */
     51//     /** @name Property getters/setters
     52//      * @{ */
     53//        int baseMemory() const;
     54//        int VCPUCount() const;
     55//        bool EFIEnabled() const;
     56//     /** @} */
    5757
    58     QWidget *createHardwareWidgets();
    59     void retranslateWidgets();
     58//     QWidget *createHardwareWidgets();
     59//     void retranslateWidgets();
    6060
    6161
    6262
    63     /** @name Widgets
    64      * @{ */
    65        UIBaseMemoryEditor *m_pBaseMemoryEditor;
    66        UIVirtualCPUEditor *m_pVirtualCPUEditor;
    67        QCheckBox          *m_pEFICheckBox;
    68     /** @} */
    6963
    70 };
     64// };
    7165
    7266/** 3rd page of the New Virtual Machine wizard (basic extension). */
    73 class UIWizardNewVMPageHardware : public UIWizardPage, public UIWizardNewVMPageHardwareBase
     67class UIWizardNewVMHardwarePageBasic : public UINativeWizardPage
    7468{
    7569    Q_OBJECT;
    76     Q_PROPERTY(int baseMemory READ baseMemory);
    77     Q_PROPERTY(int VCPUCount READ VCPUCount);
    78     Q_PROPERTY(bool EFIEnabled READ EFIEnabled);
    7970
    8071public:
    8172
    8273    /** Constructor. */
    83     UIWizardNewVMPageHardware();
     74    UIWizardNewVMHardwarePageBasic();
    8475
    8576protected:
    8677
    87     /** Wrapper to access 'wizard' from base part. */
    88     UIWizard *wizardImp() const { return wizard(); }
    89     /** Wrapper to access 'this' from base part. */
    90     UIWizardPage* thisImp() { return this; }
    91     /** Wrapper to access 'wizard-field' from base part. */
    92     QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
    9378
    9479private slots:
     
    10489    void initializePage();
    10590    void cleanupPage();
    106 
     91    QWidget *createHardwareWidgets();
    10792    bool isComplete() const;
    10893
    109     /** Widgets. */
    110     QIRichTextLabel *m_pLabel;
     94    /** @name Widgets
     95     * @{ */
     96       UIBaseMemoryEditor *m_pBaseMemoryEditor;
     97       UIVirtualCPUEditor *m_pVirtualCPUEditor;
     98       QCheckBox          *m_pEFICheckBox;
     99       QIRichTextLabel    *m_pLabel;
     100    /** @} */
    111101};
    112102
    113 #endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageHardware_h */
     103#endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMHardwarePageBasic_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.cpp

    r90002 r90003  
    3131#include "UIMessageCenter.h"
    3232#include "UINameAndSystemEditor.h"
    33 #include "UIWizardNewVMPageNameOSType.h"
     33#include "UIWizardNewVMNameOSTypePageBasic.h"
    3434#include "UIWizardNewVM.h"
    3535
     
    178178};
    179179
    180 UIWizardNewVMPageBaseNameOSType::UIWizardNewVMPageBaseNameOSType(const QString &strGroup)
    181     : m_pNameAndSystemEditor(0)
     180// UIWizardNewVMNameOSTypePage::UIWizardNewVMNameOSTypePage(const QString &strGroup)
     181//     : m_pNameAndSystemEditor(0)
     182//     , m_pSkipUnattendedCheckBox(0)
     183//     , m_strGroup(strGroup)
     184// {
     185//     CHost host = uiCommon().host();
     186//     m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
     187//     m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);
     188// }
     189
     190// void UIWizardNewVMNameOSTypePage::onNameChanged(QString strNewName)
     191// {
     192//     /* Do not forget about achitecture bits, if not yet specified: */
     193//     if (!strNewName.contains("32") && !strNewName.contains("64"))
     194//         strNewName += ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode ? "64" : "32";
     195
     196//     /* Search for a matching OS type based on the string the user typed already. */
     197//     for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)
     198//         if (strNewName.contains(gs_OSTypePattern[i].pattern))
     199//         {
     200//             if (m_pNameAndSystemEditor)
     201//                 m_pNameAndSystemEditor->setType(uiCommon().vmGuestOSType(gs_OSTypePattern[i].pcstId));
     202//             break;
     203//         }
     204// }
     205
     206// void UIWizardNewVMNameOSTypePage::onOsTypeChanged()
     207// {
     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 &)));
     212// }
     213
     214// void UIWizardNewVMNameOSTypePage::composeMachineFilePath()
     215// {
     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();
     232// }
     233
     234
     235// bool UIWizardNewVMNameOSTypePage::createMachineFolder()
     236// {
     237//     if (!m_pNameAndSystemEditor)
     238//         return false;
     239//     /* Cleanup previosly created folder if any: */
     240//     if (!cleanupMachineFolder())
     241//     {
     242//         msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp());
     243//         return false;
     244//     }
     245
     246//     composeMachineFilePath();
     247
     248//     /* Check if the folder already exists and check if it has been created by this wizard */
     249//     if (QDir(m_strMachineFolder).exists())
     250//     {
     251//         /* Looks like we have already created this folder for this run of the wizard. Just return */
     252//         if (m_strCreatedFolder == m_strMachineFolder)
     253//             return true;
     254//         /* The folder is there but not because of this wizard. Avoid overwriting a existing machine's folder */
     255//         else
     256//         {
     257//             msgCenter().cannotRewriteMachineFolder(m_strMachineFolder, thisImp());
     258//             return false;
     259//         }
     260//     }
     261
     262//     /* Try to create new folder (and it's predecessors): */
     263//     bool fMachineFolderCreated = QDir().mkpath(m_strMachineFolder);
     264//     if (!fMachineFolderCreated)
     265//     {
     266//         msgCenter().cannotCreateMachineFolder(m_strMachineFolder, thisImp());
     267//         return false;
     268//     }
     269//     m_strCreatedFolder = m_strMachineFolder;
     270//     return true;
     271// }
     272
     273// bool UIWizardNewVMNameOSTypePage::cleanupMachineFolder(bool fWizardCancel /* = false */)
     274// {
     275//     /* Make sure folder was previosly created: */
     276//     if (m_strCreatedFolder.isEmpty())
     277//         return true;
     278//     /* Clean this folder if the machine folder has been changed by the user or we are cancelling the wizard: */
     279//     if (m_strCreatedFolder != m_strMachineFolder || fWizardCancel)
     280//     {
     281//         /* Try to cleanup folder (and it's predecessors): */
     282//         bool fMachineFolderRemoved = QDir().rmpath(m_strCreatedFolder);
     283//         /* Reset machine folder value: */
     284//         if (fMachineFolderRemoved)
     285//             m_strCreatedFolder = QString();
     286//         /* Return cleanup result: */
     287//         return fMachineFolderRemoved;
     288//     }
     289//     return true;
     290// }
     291
     292// QString UIWizardNewVMNameOSTypePage::machineFilePath() const
     293// {
     294//     return m_strMachineFilePath;
     295// }
     296
     297// void UIWizardNewVMNameOSTypePage::setMachineFilePath(const QString &strMachineFilePath)
     298// {
     299//     m_strMachineFilePath = strMachineFilePath;
     300// }
     301
     302// QString UIWizardNewVMNameOSTypePage::machineFolder() const
     303// {
     304//     return m_strMachineFolder;
     305// }
     306
     307// void UIWizardNewVMNameOSTypePage::setMachineFolder(const QString &strMachineFolder)
     308// {
     309//     m_strMachineFolder = strMachineFolder;
     310// }
     311
     312// QString UIWizardNewVMNameOSTypePage::machineBaseName() const
     313// {
     314//     return m_strMachineBaseName;
     315// }
     316
     317// void UIWizardNewVMNameOSTypePage::setMachineBaseName(const QString &strMachineBaseName)
     318// {
     319//     m_strMachineBaseName = strMachineBaseName;
     320// }
     321
     322// QString UIWizardNewVMNameOSTypePage::guestOSFamiyId() const
     323// {
     324//     if (!m_pNameAndSystemEditor)
     325//         return QString();
     326//     return m_pNameAndSystemEditor->familyId();
     327// }
     328
     329// void UIWizardNewVMNameOSTypePage::markWidgets() const
     330// {
     331//     if (m_pNameAndSystemEditor)
     332//     {
     333//         m_pNameAndSystemEditor->markNameEditor(m_pNameAndSystemEditor->name().isEmpty());
     334//         m_pNameAndSystemEditor->markImageEditor(!checkISOFile(), UIWizardNewVM::tr("Invalid file path or unreadable file"));
     335//     }
     336// }
     337
     338
     339// QString UIWizardNewVMNameOSTypePage::ISOFilePath() const
     340// {
     341//     if (!m_pNameAndSystemEditor)
     342//         return QString();
     343//     return m_pNameAndSystemEditor->image();
     344// }
     345
     346// bool UIWizardNewVMNameOSTypePage::isUnattendedEnabled() const
     347// {
     348//     if (!m_pNameAndSystemEditor)
     349//         return false;
     350//     const QString &strPath = m_pNameAndSystemEditor->image();
     351//     if (strPath.isNull() || strPath.isEmpty())
     352//         return false;
     353//     if (m_pSkipUnattendedCheckBox && m_pSkipUnattendedCheckBox->isChecked())
     354//         return false;
     355//     return true;
     356// }
     357
     358// const QString &UIWizardNewVMNameOSTypePage::detectedOSTypeId() const
     359// {
     360//     return m_strDetectedOSTypeId;
     361// }
     362
     363// bool UIWizardNewVMNameOSTypePage::determineOSType(const QString &strISOPath)
     364// {
     365//     QFileInfo isoFileInfo(strISOPath);
     366//     if (!isoFileInfo.exists())
     367//     {
     368//         m_strDetectedOSTypeId.clear();
     369//         return false;
     370//     }
     371
     372//     CUnattended comUnatteded = uiCommon().virtualBox().CreateUnattendedInstaller();
     373//     comUnatteded.SetIsoPath(strISOPath);
     374//     comUnatteded.DetectIsoOS();
     375
     376//     m_strDetectedOSTypeId = comUnatteded.GetDetectedOSTypeId();
     377//     return true;
     378// }
     379
     380// bool UIWizardNewVMNameOSTypePage::skipUnattendedInstall() const
     381// {
     382//     return m_pSkipUnattendedCheckBox && m_pSkipUnattendedCheckBox->isChecked();
     383// }
     384
     385// bool UIWizardNewVMNameOSTypePage::checkISOFile() const
     386// {
     387//     if (!m_pNameAndSystemEditor)
     388//         return true;
     389//     const QString &strPath = m_pNameAndSystemEditor->image();
     390//     if (strPath.isNull() || strPath.isEmpty())
     391//         return true;
     392//     QFileInfo fileInfo(strPath);
     393//     if (!fileInfo.exists() || !fileInfo.isReadable())
     394//         return false;
     395//     return true;
     396// }
     397
     398// void UIWizardNewVMNameOSTypePage::setSkipCheckBoxEnable()
     399// {
     400//     if (!m_pSkipUnattendedCheckBox)
     401//         return;
     402//     if (m_pNameAndSystemEditor)
     403//     {
     404//         const QString &strPath = m_pNameAndSystemEditor->image();
     405//         m_pSkipUnattendedCheckBox->setEnabled(!strPath.isNull() && !strPath.isEmpty());
     406//     }
     407// }
     408
     409// void UIWizardNewVMNameOSTypePage::setTypeByISODetectedOSType(const QString &strDetectedOSType)
     410// {
     411//     Q_UNUSED(strDetectedOSType);
     412//     if (!strDetectedOSType.isEmpty())
     413//         onNameChanged(strDetectedOSType);
     414// }
     415
     416
     417UIWizardNewVMNameOSTypePageBasic::UIWizardNewVMNameOSTypePageBasic(const QString &strGroup)
     418    : m_pNameAndSystemLayout(0)
     419    , m_pNameAndSystemEditor(0)
    182420    , m_pSkipUnattendedCheckBox(0)
    183     , m_strGroup(strGroup)
    184 {
    185     CHost host = uiCommon().host();
    186     m_fSupportsHWVirtEx = host.GetProcessorFeature(KProcessorFeature_HWVirtEx);
    187     m_fSupportsLongMode = host.GetProcessorFeature(KProcessorFeature_LongMode);
    188 }
    189 
    190 void UIWizardNewVMPageBaseNameOSType::onNameChanged(QString strNewName)
    191 {
    192     /* Do not forget about achitecture bits, if not yet specified: */
    193     if (!strNewName.contains("32") && !strNewName.contains("64"))
    194         strNewName += ARCH_BITS == 64 && m_fSupportsHWVirtEx && m_fSupportsLongMode ? "64" : "32";
    195 
    196     /* Search for a matching OS type based on the string the user typed already. */
    197     for (size_t i = 0; i < RT_ELEMENTS(gs_OSTypePattern); ++i)
    198         if (strNewName.contains(gs_OSTypePattern[i].pattern))
    199         {
    200             if (m_pNameAndSystemEditor)
    201                 m_pNameAndSystemEditor->setType(uiCommon().vmGuestOSType(gs_OSTypePattern[i].pcstId));
    202             break;
    203         }
    204 }
    205 
    206 void UIWizardNewVMPageBaseNameOSType::onOsTypeChanged()
    207 {
    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 &)));
    212 }
    213 
    214 void UIWizardNewVMPageBaseNameOSType::composeMachineFilePath()
    215 {
    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();
    232 }
    233 
    234 QWidget *UIWizardNewVMPageBaseNameOSType::createNameOSTypeWidgets()
     421    , m_pNameOSTypeLabel(0)
     422{
     423    Q_UNUSED(strGroup);
     424    prepare();
     425}
     426
     427void UIWizardNewVMNameOSTypePageBasic::prepare()
     428{
     429    QVBoxLayout *pPageLayout = new QVBoxLayout(this);
     430    if (pPageLayout)
     431    {
     432        m_pNameOSTypeLabel = new QIRichTextLabel(this);
     433        if (m_pNameOSTypeLabel)
     434            pPageLayout->addWidget(m_pNameOSTypeLabel);
     435
     436        /* Prepare Name and OS Type editor: */
     437        pPageLayout->addWidget(createNameOSTypeWidgets());
     438
     439        pPageLayout->addStretch();
     440    }
     441
     442    // createConnections();
     443    // /* Register fields: */
     444    // registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
     445    // registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
     446    // registerField("machineFilePath", this, "machineFilePath");
     447    // registerField("machineFolder", this, "machineFolder");
     448    // registerField("machineBaseName", this, "machineBaseName");
     449    // registerField("guestOSFamiyId", this, "guestOSFamiyId");
     450    // registerField("startHeadless", this, "startHeadless");
     451    // registerField("ISOFilePath", this, "ISOFilePath");
     452    // registerField("isUnattendedEnabled", this, "isUnattendedEnabled");
     453    // registerField("detectedOSTypeId", this, "detectedOSTypeId");
     454}
     455
     456void UIWizardNewVMNameOSTypePageBasic::createConnections()
     457{
     458    // if (m_pNameAndSystemEditor)
     459    // {
     460    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged, this, &UIWizardNewVMNameOSTypePageBasic::sltNameChanged);
     461    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMNameOSTypePageBasic::sltPathChanged);
     462    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMNameOSTypePageBasic::sltOsTypeChanged);
     463    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigImageChanged, this, &UIWizardNewVMNameOSTypePageBasic::sltISOPathChanged);
     464    // }
     465}
     466
     467bool UIWizardNewVMNameOSTypePageBasic::isComplete() const
     468{
     469    // markWidgets();
     470    // if (m_pNameAndSystemEditor->name().isEmpty())
     471    //     return false;
     472    // return checkISOFile();
     473    return true;
     474}
     475
     476int UIWizardNewVMNameOSTypePageBasic::nextId() const
     477{
     478    // if (isUnattendedEnabled())
     479    //     return UIWizardNewVM::Page2;
     480    // return UIWizardNewVM::Page3;
     481    return 0;
     482}
     483
     484void UIWizardNewVMNameOSTypePageBasic::sltNameChanged(const QString &strNewName)
     485{
     486    Q_UNUSED(strNewName);
     487    // onNameChanged(strNewName);
     488    // composeMachineFilePath();
     489}
     490
     491void UIWizardNewVMNameOSTypePageBasic::sltPathChanged(const QString &strNewPath)
     492{
     493    Q_UNUSED(strNewPath);
     494    //composeMachineFilePath();
     495}
     496
     497void UIWizardNewVMNameOSTypePageBasic::sltOsTypeChanged()
     498{
     499    /* Call to base-class: */
     500    //onOsTypeChanged();
     501}
     502
     503void UIWizardNewVMNameOSTypePageBasic::retranslateUi()
     504{
     505    // retranslateWidgets();
     506    setTitle(UIWizardNewVM::tr("Virtual machine Name and Operating System"));
     507
     508    if (m_pNameOSTypeLabel)
     509        m_pNameOSTypeLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new "
     510                                                      "virtual machine. The name you choose will be used throughout VirtualBox "
     511                                                      "to identify this machine."));
     512
     513    if (m_pSkipUnattendedCheckBox)
     514    {
     515        m_pSkipUnattendedCheckBox->setText(UIWizardNewVM::tr("&Skip Unattended Installation"));
     516        m_pSkipUnattendedCheckBox->setToolTip(UIWizardNewVM::tr("<p>When checked selected ISO file will be mounted to the CD "
     517                                                                "drive of the virtual machine but the unattended installation "
     518                                                                "will not start.</p>"));
     519    }
     520
     521    if (m_pNameAndSystemLayout && m_pNameAndSystemEditor)
     522        m_pNameAndSystemLayout->setColumnMinimumWidth(0, m_pNameAndSystemEditor->firstColumnWidth());
     523}
     524
     525void UIWizardNewVMNameOSTypePageBasic::initializePage()
     526{
     527    /* Translate page: */
     528    // retranslateUi();
     529    // if (m_pNameAndSystemEditor)
     530    //     m_pNameAndSystemEditor->setFocus();
     531    // setSkipCheckBoxEnable();
     532}
     533
     534void UIWizardNewVMNameOSTypePageBasic::cleanupPage()
     535{
     536    /* Cleanup: */
     537    // cleanupMachineFolder();
     538    // /* Call to base-class: */
     539    // UIWizardPage::cleanupPage();
     540}
     541
     542bool UIWizardNewVMNameOSTypePageBasic::validatePage()
     543{
     544    /* Try to create machine folder: */
     545    //return createMachineFolder();
     546    return true;
     547}
     548
     549void UIWizardNewVMNameOSTypePageBasic::sltISOPathChanged(const QString &strPath)
     550{
     551    Q_UNUSED(strPath);
     552    // determineOSType(strPath);
     553    // setTypeByISODetectedOSType(m_strDetectedOSTypeId);
     554    // /* Update the global recent ISO path: */
     555    // QFileInfo fileInfo(strPath);
     556    // if (fileInfo.exists() && fileInfo.isReadable())
     557    //     uiCommon().updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType_DVD, strPath);
     558    // setSkipCheckBoxEnable();
     559    // emit completeChanged();
     560}
     561
     562QWidget *UIWizardNewVMNameOSTypePageBasic::createNameOSTypeWidgets()
    235563{
    236564    /* Prepare container widget: */
     
    263591    return pContainerWidget;
    264592}
    265 
    266 bool UIWizardNewVMPageBaseNameOSType::createMachineFolder()
    267 {
    268     if (!m_pNameAndSystemEditor)
    269         return false;
    270     /* Cleanup previosly created folder if any: */
    271     if (!cleanupMachineFolder())
    272     {
    273         msgCenter().cannotRemoveMachineFolder(m_strMachineFolder, thisImp());
    274         return false;
    275     }
    276 
    277     composeMachineFilePath();
    278 
    279     /* Check if the folder already exists and check if it has been created by this wizard */
    280     if (QDir(m_strMachineFolder).exists())
    281     {
    282         /* Looks like we have already created this folder for this run of the wizard. Just return */
    283         if (m_strCreatedFolder == m_strMachineFolder)
    284             return true;
    285         /* The folder is there but not because of this wizard. Avoid overwriting a existing machine's folder */
    286         else
    287         {
    288             msgCenter().cannotRewriteMachineFolder(m_strMachineFolder, thisImp());
    289             return false;
    290         }
    291     }
    292 
    293     /* Try to create new folder (and it's predecessors): */
    294     bool fMachineFolderCreated = QDir().mkpath(m_strMachineFolder);
    295     if (!fMachineFolderCreated)
    296     {
    297         msgCenter().cannotCreateMachineFolder(m_strMachineFolder, thisImp());
    298         return false;
    299     }
    300     m_strCreatedFolder = m_strMachineFolder;
    301     return true;
    302 }
    303 
    304 bool UIWizardNewVMPageBaseNameOSType::cleanupMachineFolder(bool fWizardCancel /* = false */)
    305 {
    306     /* Make sure folder was previosly created: */
    307     if (m_strCreatedFolder.isEmpty())
    308         return true;
    309     /* Clean this folder if the machine folder has been changed by the user or we are cancelling the wizard: */
    310     if (m_strCreatedFolder != m_strMachineFolder || fWizardCancel)
    311     {
    312         /* Try to cleanup folder (and it's predecessors): */
    313         bool fMachineFolderRemoved = QDir().rmpath(m_strCreatedFolder);
    314         /* Reset machine folder value: */
    315         if (fMachineFolderRemoved)
    316             m_strCreatedFolder = QString();
    317         /* Return cleanup result: */
    318         return fMachineFolderRemoved;
    319     }
    320     return true;
    321 }
    322 
    323 QString UIWizardNewVMPageBaseNameOSType::machineFilePath() const
    324 {
    325     return m_strMachineFilePath;
    326 }
    327 
    328 void UIWizardNewVMPageBaseNameOSType::setMachineFilePath(const QString &strMachineFilePath)
    329 {
    330     m_strMachineFilePath = strMachineFilePath;
    331 }
    332 
    333 QString UIWizardNewVMPageBaseNameOSType::machineFolder() const
    334 {
    335     return m_strMachineFolder;
    336 }
    337 
    338 void UIWizardNewVMPageBaseNameOSType::setMachineFolder(const QString &strMachineFolder)
    339 {
    340     m_strMachineFolder = strMachineFolder;
    341 }
    342 
    343 QString UIWizardNewVMPageBaseNameOSType::machineBaseName() const
    344 {
    345     return m_strMachineBaseName;
    346 }
    347 
    348 void UIWizardNewVMPageBaseNameOSType::setMachineBaseName(const QString &strMachineBaseName)
    349 {
    350     m_strMachineBaseName = strMachineBaseName;
    351 }
    352 
    353 QString UIWizardNewVMPageBaseNameOSType::guestOSFamiyId() const
    354 {
    355     if (!m_pNameAndSystemEditor)
    356         return QString();
    357     return m_pNameAndSystemEditor->familyId();
    358 }
    359 
    360 void UIWizardNewVMPageBaseNameOSType::markWidgets() const
    361 {
    362     if (m_pNameAndSystemEditor)
    363     {
    364         m_pNameAndSystemEditor->markNameEditor(m_pNameAndSystemEditor->name().isEmpty());
    365         m_pNameAndSystemEditor->markImageEditor(!checkISOFile(), UIWizardNewVM::tr("Invalid file path or unreadable file"));
    366     }
    367 }
    368 
    369 void UIWizardNewVMPageBaseNameOSType::retranslateWidgets()
    370 {
    371     if (m_pSkipUnattendedCheckBox)
    372     {
    373         m_pSkipUnattendedCheckBox->setText(UIWizardNewVM::tr("&Skip Unattended Installation"));
    374         m_pSkipUnattendedCheckBox->setToolTip(UIWizardNewVM::tr("<p>When checked selected ISO file will be mounted to the CD "
    375                                                                 "drive of the virtual machine but the unattended installation "
    376                                                                 "will not start.</p>"));
    377     }
    378 }
    379 
    380 QString UIWizardNewVMPageBaseNameOSType::ISOFilePath() const
    381 {
    382     if (!m_pNameAndSystemEditor)
    383         return QString();
    384     return m_pNameAndSystemEditor->image();
    385 }
    386 
    387 bool UIWizardNewVMPageBaseNameOSType::isUnattendedEnabled() const
    388 {
    389     if (!m_pNameAndSystemEditor)
    390         return false;
    391     const QString &strPath = m_pNameAndSystemEditor->image();
    392     if (strPath.isNull() || strPath.isEmpty())
    393         return false;
    394     if (m_pSkipUnattendedCheckBox && m_pSkipUnattendedCheckBox->isChecked())
    395         return false;
    396     return true;
    397 }
    398 
    399 const QString &UIWizardNewVMPageBaseNameOSType::detectedOSTypeId() const
    400 {
    401     return m_strDetectedOSTypeId;
    402 }
    403 
    404 bool UIWizardNewVMPageBaseNameOSType::determineOSType(const QString &strISOPath)
    405 {
    406     QFileInfo isoFileInfo(strISOPath);
    407     if (!isoFileInfo.exists())
    408     {
    409         m_strDetectedOSTypeId.clear();
    410         return false;
    411     }
    412 
    413     CUnattended comUnatteded = uiCommon().virtualBox().CreateUnattendedInstaller();
    414     comUnatteded.SetIsoPath(strISOPath);
    415     comUnatteded.DetectIsoOS();
    416 
    417     m_strDetectedOSTypeId = comUnatteded.GetDetectedOSTypeId();
    418     return true;
    419 }
    420 
    421 bool UIWizardNewVMPageBaseNameOSType::skipUnattendedInstall() const
    422 {
    423     return m_pSkipUnattendedCheckBox && m_pSkipUnattendedCheckBox->isChecked();
    424 }
    425 
    426 bool UIWizardNewVMPageBaseNameOSType::checkISOFile() const
    427 {
    428     if (!m_pNameAndSystemEditor)
    429         return true;
    430     const QString &strPath = m_pNameAndSystemEditor->image();
    431     if (strPath.isNull() || strPath.isEmpty())
    432         return true;
    433     QFileInfo fileInfo(strPath);
    434     if (!fileInfo.exists() || !fileInfo.isReadable())
    435         return false;
    436     return true;
    437 }
    438 
    439 void UIWizardNewVMPageBaseNameOSType::setSkipCheckBoxEnable()
    440 {
    441     if (!m_pSkipUnattendedCheckBox)
    442         return;
    443     if (m_pNameAndSystemEditor)
    444     {
    445         const QString &strPath = m_pNameAndSystemEditor->image();
    446         m_pSkipUnattendedCheckBox->setEnabled(!strPath.isNull() && !strPath.isEmpty());
    447     }
    448 }
    449 
    450 void UIWizardNewVMPageBaseNameOSType::setTypeByISODetectedOSType(const QString &strDetectedOSType)
    451 {
    452     Q_UNUSED(strDetectedOSType);
    453     if (!strDetectedOSType.isEmpty())
    454         onNameChanged(strDetectedOSType);
    455 }
    456 
    457 
    458 UIWizardNewVMPageNameOSType::UIWizardNewVMPageNameOSType(const QString &strGroup)
    459     : UIWizardNewVMPageBaseNameOSType(strGroup)
    460     , m_pNameOSTypeLabel(0)
    461 {
    462     prepare();
    463 }
    464 
    465 void UIWizardNewVMPageNameOSType::prepare()
    466 {
    467     /* Prepare page layout: */
    468     QVBoxLayout *pPageLayout = new QVBoxLayout(this);
    469     if (pPageLayout)
    470     {
    471         /* Prepare Name and OS Type label: */
    472         m_pNameOSTypeLabel = new QIRichTextLabel(this);
    473         if (m_pNameOSTypeLabel)
    474             pPageLayout->addWidget(m_pNameOSTypeLabel);
    475 
    476         /* Prepare Name and OS Type editor: */
    477         pPageLayout->addWidget(createNameOSTypeWidgets());
    478 
    479         pPageLayout->addStretch();
    480     }
    481 
    482     createConnections();
    483     /* Register fields: */
    484     registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
    485     registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
    486     registerField("machineFilePath", this, "machineFilePath");
    487     registerField("machineFolder", this, "machineFolder");
    488     registerField("machineBaseName", this, "machineBaseName");
    489     registerField("guestOSFamiyId", this, "guestOSFamiyId");
    490     registerField("startHeadless", this, "startHeadless");
    491     registerField("ISOFilePath", this, "ISOFilePath");
    492     registerField("isUnattendedEnabled", this, "isUnattendedEnabled");
    493     registerField("detectedOSTypeId", this, "detectedOSTypeId");
    494 }
    495 
    496 void UIWizardNewVMPageNameOSType::createConnections()
    497 {
    498     if (m_pNameAndSystemEditor)
    499     {
    500         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged, this, &UIWizardNewVMPageNameOSType::sltNameChanged);
    501         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged, this, &UIWizardNewVMPageNameOSType::sltPathChanged);
    502         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged, this, &UIWizardNewVMPageNameOSType::sltOsTypeChanged);
    503         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigImageChanged, this, &UIWizardNewVMPageNameOSType::sltISOPathChanged);
    504     }
    505 }
    506 
    507 bool UIWizardNewVMPageNameOSType::isComplete() const
    508 {
    509     markWidgets();
    510     if (m_pNameAndSystemEditor->name().isEmpty())
    511         return false;
    512     return checkISOFile();
    513 }
    514 
    515 int UIWizardNewVMPageNameOSType::nextId() const
    516 {
    517     if (isUnattendedEnabled())
    518         return UIWizardNewVM::Page2;
    519     return UIWizardNewVM::Page3;
    520 }
    521 
    522 void UIWizardNewVMPageNameOSType::sltNameChanged(const QString &strNewName)
    523 {
    524     onNameChanged(strNewName);
    525     composeMachineFilePath();
    526 }
    527 
    528 void UIWizardNewVMPageNameOSType::sltPathChanged(const QString &strNewPath)
    529 {
    530     Q_UNUSED(strNewPath);
    531     composeMachineFilePath();
    532 }
    533 
    534 void UIWizardNewVMPageNameOSType::sltOsTypeChanged()
    535 {
    536     /* Call to base-class: */
    537     onOsTypeChanged();
    538 }
    539 
    540 void UIWizardNewVMPageNameOSType::retranslateUi()
    541 {
    542     retranslateWidgets();
    543     /* Translate page: */
    544     setTitle(UIWizardNewVM::tr("Virtual machine Name and Operating System"));
    545 
    546     if (m_pNameOSTypeLabel)
    547         m_pNameOSTypeLabel->setText(UIWizardNewVM::tr("Please choose a descriptive name and destination folder for the new "
    548                                                       "virtual machine. The name you choose will be used throughout VirtualBox "
    549                                                       "to identify this machine."));
    550 
    551     if (m_pNameAndSystemLayout && m_pNameAndSystemEditor)
    552         m_pNameAndSystemLayout->setColumnMinimumWidth(0, m_pNameAndSystemEditor->firstColumnWidth());
    553 }
    554 
    555 void UIWizardNewVMPageNameOSType::initializePage()
    556 {
    557     /* Translate page: */
    558     retranslateUi();
    559     if (m_pNameAndSystemEditor)
    560         m_pNameAndSystemEditor->setFocus();
    561     setSkipCheckBoxEnable();
    562 }
    563 
    564 void UIWizardNewVMPageNameOSType::cleanupPage()
    565 {
    566     /* Cleanup: */
    567     cleanupMachineFolder();
    568     /* Call to base-class: */
    569     UIWizardPage::cleanupPage();
    570 }
    571 
    572 bool UIWizardNewVMPageNameOSType::validatePage()
    573 {
    574     /* Try to create machine folder: */
    575     return createMachineFolder();
    576 }
    577 
    578 void UIWizardNewVMPageNameOSType::sltISOPathChanged(const QString &strPath)
    579 {
    580     determineOSType(strPath);
    581     setTypeByISODetectedOSType(m_strDetectedOSTypeId);
    582     /* Update the global recent ISO path: */
    583     QFileInfo fileInfo(strPath);
    584     if (fileInfo.exists() && fileInfo.isReadable())
    585         uiCommon().updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType_DVD, strPath);
    586     setSkipCheckBoxEnable();
    587     emit completeChanged();
    588 }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMNameOSTypePageBasic.h

    r90002 r90003  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewVMPageNameOSType class declaration.
     3 * VBox Qt GUI - UIWizardNewVMNameOSTypePageBasic class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageNameOSType_h
    19 #define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageNameOSType_h
     18#ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMNameOSTypePageBasic_h
     19#define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMNameOSTypePageBasic_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2323
    2424/* Local includes: */
    25 #include "UIWizardPage.h"
     25#include "UINativeWizardPage.h"
    2626#include "UIExtraDataDefs.h"
    2727
     
    3737class UINameAndSystemEditor;
    3838
    39 /** 1st page of the New Virtual Machine wizard (base part): */
    40 class UIWizardNewVMPageBaseNameOSType : public UIWizardPageBase
    41 {
    42 protected:
     39// /** 1st page of the New Virtual Machine wizard (base part): */
     40// class UIWizardNewVMNameOSTypePage : public UIWizardPageBase
     41// {
     42// protected:
    4343
    44     /** Constructor. */
    45     UIWizardNewVMPageBaseNameOSType(const QString &strGroup);
     44//     /** Constructor. */
     45//     UIWizardNewVMNameOSTypePage(const QString &strGroup);
    4646
    47     /** Handlers. */
    48     void onNameChanged(QString strNewName);
    49     void onOsTypeChanged();
     47//     /** Handlers. */
     48//     void onNameChanged(QString strNewName);
     49//     void onOsTypeChanged();
    5050
    51     bool createMachineFolder();
    52     /** Removes a previously created folder (if exists) before creating a new one.
    53      *  used during page cleanup and new folder creation. Called upon page Next/Back and
    54      *  wizard cancel */
    55     bool cleanupMachineFolder(bool fWizardCancel = false);
     51//     bool createMachineFolder();
     52//     /** Removes a previously created folder (if exists) before creating a new one.
     53//      *  used during page cleanup and new folder creation. Called upon page Next/Back and
     54//      *  wizard cancel */
     55//     bool cleanupMachineFolder(bool fWizardCancel = false);
    5656
    57     /** @name Property getters/setters
    58       * @{ */
    59         QString machineFilePath() const;
    60         void setMachineFilePath(const QString &strMachineFilePath);
     57//     /** @name Property getters/setters
     58//       * @{ */
     59//         QString machineFilePath() const;
     60//         void setMachineFilePath(const QString &strMachineFilePath);
    6161
    62         QString machineFolder() const;
    63         void setMachineFolder(const QString &strMachineFolder);
     62//         QString machineFolder() const;
     63//         void setMachineFolder(const QString &strMachineFolder);
    6464
    65         QString machineBaseName() const;
    66         void setMachineBaseName(const QString &strMachineBaseName);
     65//         QString machineBaseName() const;
     66//         void setMachineBaseName(const QString &strMachineBaseName);
    6767
    68         QString guestOSFamiyId() const;
     68//         QString guestOSFamiyId() const;
    6969
    70         bool isUnattendedEnabled() const;
    71         const QString &detectedOSTypeId() const;
     70//         bool isUnattendedEnabled() const;
     71//         const QString &detectedOSTypeId() const;
    7272
    73         bool skipUnattendedInstall() const;
    74     /** @} */
     73//         bool skipUnattendedInstall() const;
     74//     /** @} */
    7575
    76     /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */
    77     void composeMachineFilePath();
     76//     /** calls CVirtualBox::ComposeMachineFilename(...) and sets related member variables */
     77//     void composeMachineFilePath();
    7878
    79     QWidget *createNameOSTypeWidgets();
    80     /** Colors the widgets red if they cause isComplete to fail. */
    81     void markWidgets() const;
    82     void retranslateWidgets();
    83     QString ISOFilePath() const;
    84     bool determineOSType(const QString &strISOPath);
    85     void setTypeByISODetectedOSType(const QString &strDetectedOSType);
    86     /** Return false if ISO path is not empty but points to an missing or unreadable file. */
    87     bool checkISOFile() const;
    88     void setSkipCheckBoxEnable();
    89     /** @name Widgets
    90      * @{ */
    91         QGridLayout           *m_pNameAndSystemLayout;
    92         UINameAndSystemEditor *m_pNameAndSystemEditor;
    93         QCheckBox             *m_pSkipUnattendedCheckBox;
    94     /** @} */
     79//     /** Colors the widgets red if they cause isComplete to fail. */
     80//     void markWidgets() const;
     81//     void retranslateWidgets();
     82//     QString ISOFilePath() const;
     83//     bool determineOSType(const QString &strISOPath);
     84//     void setTypeByISODetectedOSType(const QString &strDetectedOSType);
     85//     /** Return false if ISO path is not empty but points to an missing or unreadable file. */
     86//     bool checkISOFile() const;
     87//     void setSkipCheckBoxEnable();
    9588
    96     QString m_strDetectedOSTypeId;
     89//     QString m_strDetectedOSTypeId;
    9790
    98 private:
     91// private:
    9992
    100     /** Full path (including the file name) of the machine's configuration file. */
    101     QString m_strMachineFilePath;
    102     /** Path of the folder hosting the machine's configuration file. Generated from m_strMachineFilePath. */
    103     QString m_strMachineFolder;
    104     /** Path of the folder created by this wizard page. Used to remove previously created
    105      *  folder. see cleanupMachineFolder();*/
    106     QString m_strCreatedFolder;
    107     /** Base name of the machine is generated from the m_strMachineFilePath. */
    108     QString m_strMachineBaseName;
     93//     /** Full path (including the file name) of the machine's configuration file. */
     94//     QString m_strMachineFilePath;
     95//     /** Path of the folder hosting the machine's configuration file. Generated from m_strMachineFilePath. */
     96//     QString m_strMachineFolder;
     97//     /** Path of the folder created by this wizard page. Used to remove previously created
     98//      *  folder. see cleanupMachineFolder();*/
     99//     QString m_strCreatedFolder;
     100//     /** Base name of the machine is generated from the m_strMachineFilePath. */
     101//     QString m_strMachineBaseName;
    109102
    110     QString m_strGroup;
    111     bool m_fSupportsHWVirtEx;
    112     bool m_fSupportsLongMode;
     103//     QString m_strGroup;
     104//     bool m_fSupportsHWVirtEx;
     105//     bool m_fSupportsLongMode;
    113106
    114     friend class UIWizardNewVM;
    115 };
     107//     friend class UIWizardNewVM;
     108// };
    116109
    117110/** 1st page of the New Virtual Machine wizard (basic extension). */
    118 class UIWizardNewVMPageNameOSType : public UIWizardPage, public UIWizardNewVMPageBaseNameOSType
     111class UIWizardNewVMNameOSTypePageBasic : public UINativeWizardPage
    119112{
    120113
    121114    Q_OBJECT;
    122     Q_PROPERTY(QString machineFilePath READ machineFilePath WRITE setMachineFilePath);
    123     Q_PROPERTY(QString machineFolder READ machineFolder WRITE setMachineFolder);
    124     Q_PROPERTY(QString machineBaseName READ machineBaseName WRITE setMachineBaseName);
    125     Q_PROPERTY(QString guestOSFamiyId READ guestOSFamiyId);
    126     Q_PROPERTY(QString ISOFilePath READ ISOFilePath);
    127     Q_PROPERTY(bool isUnattendedEnabled READ isUnattendedEnabled);
    128     Q_PROPERTY(QString detectedOSTypeId READ detectedOSTypeId);
    129115
    130116public:
    131117
    132118    /** Constructor. */
    133     UIWizardNewVMPageNameOSType(const QString &strGroup);
     119    UIWizardNewVMNameOSTypePageBasic(const QString &strGroup);
    134120    virtual bool isComplete() const; /* override */
    135121    virtual int nextId() const /* override */;
    136122
    137123protected:
    138 
    139     /** Wrapper to access 'this' from base part. */
    140     UIWizardPage* thisImp() { return this; }
    141124
    142125private slots:
     
    159142    void cleanupPage();
    160143
     144    QWidget *createNameOSTypeWidgets();
     145
    161146    /** Validation stuff. */
    162147    virtual bool validatePage() /* override */;
     
    165150    /** @name Widgets
    166151     * @{ */
    167         QIRichTextLabel *m_pNameOSTypeLabel;
     152        QGridLayout           *m_pNameAndSystemLayout;
     153        UINameAndSystemEditor *m_pNameAndSystemEditor;
     154        QCheckBox             *m_pSkipUnattendedCheckBox;
     155        QIRichTextLabel       *m_pNameOSTypeLabel;
    168156    /** @} */
    169157};
    170158
    171 #endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageNameOSType_h */
     159#endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMNameOSTypePageBasic_h */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.cpp

    r89916 r90003  
    4848
    4949UIWizardNewVMPageExpert::UIWizardNewVMPageExpert(const QString &strGroup)
    50     : UIWizardNewVMPageBaseNameOSType(strGroup)
    51     , m_pToolBox(0)
     50    : //UIWizardNewVMPageBaseNameOSType(strGroup)
     51    m_pToolBox(0)
    5252    , m_pDiskFormatGroupBox(0)
    5353    , m_pDiskVariantGroupBox(0)
    5454    , m_pLocationLabel(0)
    5555{
     56    Q_UNUSED(strGroup);
    5657    /* Create widgets: */
    5758    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    5859    {
    5960        m_pToolBox = new UIToolBox;
    60         m_pToolBox->insertPage(ExpertToolboxItems_NameAndOSType, createNameOSTypeWidgets(), "");
    61         m_pToolBox->insertPage(ExpertToolboxItems_Unattended, createUnattendedWidgets(), "", false);
    62         m_pToolBox->insertPage(ExpertToolboxItems_Hardware, createHardwareWidgets(), "");
    63         m_pToolBox->insertPage(ExpertToolboxItems_Disk, createDiskWidgets(), "");
     61        // m_pToolBox->insertPage(ExpertToolboxItems_NameAndOSType, createNameOSTypeWidgets(), "");
     62        // m_pToolBox->insertPage(ExpertToolboxItems_Unattended, createUnattendedWidgets(), "", false);
     63        // m_pToolBox->insertPage(ExpertToolboxItems_Hardware, createHardwareWidgets(), "");
     64        // m_pToolBox->insertPage(ExpertToolboxItems_Disk, createDiskWidgets(), "");
    6465        m_pToolBox->setCurrentPage(ExpertToolboxItems_NameAndOSType);
    6566        pMainLayout->addWidget(m_pToolBox);
     
    7475
    7576    /* Register fields: */
    76     registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
    77     registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
    78     registerField("machineFilePath", this, "machineFilePath");
    79     registerField("machineFolder", this, "machineFolder");
    80     registerField("machineBaseName", this, "machineBaseName");
    81     registerField("baseMemory", this, "baseMemory");
    82     registerField("guestOSFamiyId", this, "guestOSFamiyId");
    83     registerField("ISOFilePath", this, "ISOFilePath");
    84     registerField("isUnattendedEnabled", this, "isUnattendedEnabled");
    85     registerField("startHeadless", this, "startHeadless");
    86     registerField("detectedOSTypeId", this, "detectedOSTypeId");
    87     registerField("userName", this, "userName");
    88     registerField("password", this, "password");
    89     registerField("hostname", this, "hostname");
    90     registerField("installGuestAdditions", this, "installGuestAdditions");
    91     registerField("guestAdditionsISOPath", this, "guestAdditionsISOPath");
    92     registerField("productKey", this, "productKey");
    93     registerField("VCPUCount", this, "VCPUCount");
    94     registerField("EFIEnabled", this, "EFIEnabled");
    95     registerField("mediumPath", this, "mediumPath");
    96     registerField("mediumFormat", this, "mediumFormat");
    97     registerField("mediumSize", this, "mediumSize");
    98     registerField("selectedDiskSource", this, "selectedDiskSource");
    99     registerField("mediumVariant", this, "mediumVariant");
     77//     registerField("name*", m_pNameAndSystemEditor, "name", SIGNAL(sigNameChanged(const QString &)));
     78//     registerField("type", m_pNameAndSystemEditor, "type", SIGNAL(sigOsTypeChanged()));
     79//     registerField("machineFilePath", this, "machineFilePath");
     80//     registerField("machineFolder", this, "machineFolder");
     81//     registerField("machineBaseName", this, "machineBaseName");
     82//     registerField("baseMemory", this, "baseMemory");
     83//     registerField("guestOSFamiyId", this, "guestOSFamiyId");
     84//     registerField("ISOFilePath", this, "ISOFilePath");
     85//     registerField("isUnattendedEnabled", this, "isUnattendedEnabled");
     86//     registerField("startHeadless", this, "startHeadless");
     87//     registerField("detectedOSTypeId", this, "detectedOSTypeId");
     88//     registerField("userName", this, "userName");
     89//     registerField("password", this, "password");
     90//     registerField("hostname", this, "hostname");
     91//     registerField("installGuestAdditions", this, "installGuestAdditions");
     92//     registerField("guestAdditionsISOPath", this, "guestAdditionsISOPath");
     93//     registerField("productKey", this, "productKey");
     94//     registerField("VCPUCount", this, "VCPUCount");
     95//     registerField("EFIEnabled", this, "EFIEnabled");
     96//     registerField("mediumPath", this, "mediumPath");
     97//     registerField("mediumFormat", this, "mediumFormat");
     98//     registerField("mediumSize", this, "mediumSize");
     99//     registerField("selectedDiskSource", this, "selectedDiskSource");
     100//     registerField("mediumVariant", this, "mediumVariant");
    100101}
    101102
    102103void UIWizardNewVMPageExpert::sltNameChanged(const QString &strNewText)
    103104{
    104     onNameChanged(strNewText);
    105     composeMachineFilePath();
    106     updateVirtualDiskPathFromMachinePathName();
    107     emit completeChanged();
     105    Q_UNUSED(strNewText);
     106    // onNameChanged(strNewText);
     107    // composeMachineFilePath();
     108    // updateVirtualDiskPathFromMachinePathName();
     109    // emit completeChanged();
    108110}
    109111
     
    111113{
    112114    Q_UNUSED(strNewPath);
    113     composeMachineFilePath();
    114     updateVirtualDiskPathFromMachinePathName();
     115    // composeMachineFilePath();
     116    // updateVirtualDiskPathFromMachinePathName();
    115117}
    116118
    117119void UIWizardNewVMPageExpert::sltOsTypeChanged()
    118120{
    119     onOsTypeChanged();
    120     setOSTypeDependedValues();
    121     emit completeChanged();
     121    // onOsTypeChanged();
     122    // setOSTypeDependedValues();
     123    // emit completeChanged();
    122124}
    123125
    124126void UIWizardNewVMPageExpert::sltGetWithFileOpenDialog()
    125127{
    126     getWithFileOpenDialog();
     128    //getWithFileOpenDialog();
    127129}
    128130
    129131void UIWizardNewVMPageExpert::sltISOPathChanged(const QString &strPath)
    130132{
    131     determineOSType(strPath);
    132     setTypeByISODetectedOSType(m_strDetectedOSTypeId);
    133     disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
    134 
    135     /* Update the global recent ISO path: */
    136     QFileInfo fileInfo(strPath);
    137     if (fileInfo.exists() && fileInfo.isReadable())
    138         uiCommon().updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType_DVD, strPath);
    139     setSkipCheckBoxEnable();
    140     emit completeChanged();
     133    Q_UNUSED(strPath);
     134    // determineOSType(strPath);
     135    // setTypeByISODetectedOSType(m_strDetectedOSTypeId);
     136    // disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
     137
     138    // /* Update the global recent ISO path: */
     139    // QFileInfo fileInfo(strPath);
     140    // if (fileInfo.exists() && fileInfo.isReadable())
     141    //     uiCommon().updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType_DVD, strPath);
     142    // setSkipCheckBoxEnable();
     143    // emit completeChanged();
    141144}
    142145
     
    144147{
    145148    Q_UNUSED(strPath);
    146     emit completeChanged();
     149    //emit completeChanged();
    147150}
    148151
    149152void UIWizardNewVMPageExpert::sltOSFamilyTypeChanged()
    150153{
    151     disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
     154    //disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
    152155}
    153156
    154157void UIWizardNewVMPageExpert::retranslateUi()
    155158{
    156     UIWizardNewVMPageBaseNameOSType::retranslateWidgets();
    157     UIWizardNewVMPageBaseUnattended::retranslateWidgets();
    158     UIWizardNewVMPageHardwareBase::retranslateWidgets();
    159     UIWizardNewVMPageDiskBase::retranslateWidgets();
    160     UIWizardNewVDPageBaseFileType::retranslateWidgets();
    161     UIWizardNewVDPageBaseVariant::retranslateWidgets();
    162     UIWizardNewVDPageBaseSizeLocation::retranslateWidgets();
    163 
    164     if (m_pToolBox)
    165     {
    166         m_pToolBox->setPageTitle(ExpertToolboxItems_NameAndOSType, QString(UIWizardNewVM::tr("Name and &Operating System")));
    167         m_pToolBox->setPageTitle(ExpertToolboxItems_Unattended, UIWizardNewVM::tr("&Unattended Install"));
    168         m_pToolBox->setPageTitle(ExpertToolboxItems_Disk, UIWizardNewVM::tr("Hard Dis&k"));
    169         m_pToolBox->setPageTitle(ExpertToolboxItems_Hardware, UIWizardNewVM::tr("H&ardware"));
    170     }
    171 
    172     if (m_pDiskFormatGroupBox)
    173         m_pDiskFormatGroupBox->setTitle(UIWizardNewVM::tr("Hard Disk File &Type"));
    174     if (m_pFormatButtonGroup)
    175     {
    176         QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons();
    177         for (int i = 0; i < buttons.size(); ++i)
    178         {
    179             QAbstractButton *pButton = buttons[i];
    180             UIMediumFormat enmFormat = gpConverter->fromInternalString<UIMediumFormat>(m_formatNames[m_pFormatButtonGroup->id(pButton)]);
    181             pButton->setText(gpConverter->toString(enmFormat));
    182         }
    183     }
    184     if (m_pDiskVariantGroupBox)
    185         m_pDiskVariantGroupBox->setTitle(UIWizardNewVM::tr("Storage on Physical Hard Disk"));
    186     if (m_pLocationLabel)
    187         m_pLocationLabel->setText(UIWizardNewVM::tr("Disk &Location:"));
    188 
    189     if (m_pNameAndSystemLayout && m_pNameAndSystemEditor)
    190         m_pNameAndSystemLayout->setColumnMinimumWidth(0, m_pNameAndSystemEditor->firstColumnWidth());
     159    // UIWizardNewVMPageBaseNameOSType::retranslateWidgets();
     160    // UIWizardNewVMPageBaseUnattended::retranslateWidgets();
     161    // UIWizardNewVMPageHardwareBase::retranslateWidgets();
     162    // UIWizardNewVMPageDiskBase::retranslateWidgets();
     163    // UIWizardNewVDPageBaseFileType::retranslateWidgets();
     164    // UIWizardNewVDPageBaseVariant::retranslateWidgets();
     165    // UIWizardNewVDPageBaseSizeLocation::retranslateWidgets();
     166
     167    // if (m_pToolBox)
     168    // {
     169    //     m_pToolBox->setPageTitle(ExpertToolboxItems_NameAndOSType, QString(UIWizardNewVM::tr("Name and &Operating System")));
     170    //     m_pToolBox->setPageTitle(ExpertToolboxItems_Unattended, UIWizardNewVM::tr("&Unattended Install"));
     171    //     m_pToolBox->setPageTitle(ExpertToolboxItems_Disk, UIWizardNewVM::tr("Hard Dis&k"));
     172    //     m_pToolBox->setPageTitle(ExpertToolboxItems_Hardware, UIWizardNewVM::tr("H&ardware"));
     173    // }
     174
     175    // if (m_pDiskFormatGroupBox)
     176    //     m_pDiskFormatGroupBox->setTitle(UIWizardNewVM::tr("Hard Disk File &Type"));
     177    // if (m_pFormatButtonGroup)
     178    // {
     179    //     QList<QAbstractButton*> buttons = m_pFormatButtonGroup->buttons();
     180    //     for (int i = 0; i < buttons.size(); ++i)
     181    //     {
     182    //         QAbstractButton *pButton = buttons[i];
     183    //         UIMediumFormat enmFormat = gpConverter->fromInternalString<UIMediumFormat>(m_formatNames[m_pFormatButtonGroup->id(pButton)]);
     184    //         pButton->setText(gpConverter->toString(enmFormat));
     185    //     }
     186    // }
     187    // if (m_pDiskVariantGroupBox)
     188    //     m_pDiskVariantGroupBox->setTitle(UIWizardNewVM::tr("Storage on Physical Hard Disk"));
     189    // if (m_pLocationLabel)
     190    //     m_pLocationLabel->setText(UIWizardNewVM::tr("Disk &Location:"));
     191
     192    // if (m_pNameAndSystemLayout && m_pNameAndSystemEditor)
     193    //     m_pNameAndSystemLayout->setColumnMinimumWidth(0, m_pNameAndSystemEditor->firstColumnWidth());
    191194}
    192195
    193196void UIWizardNewVMPageExpert::sltInstallGACheckBoxToggle(bool fEnabled)
    194197{
    195     disableEnableGAWidgets(fEnabled);
    196     emit completeChanged();
     198    Q_UNUSED(fEnabled);
     199    // disableEnableGAWidgets(fEnabled);
     200    // emit completeChanged();
    197201}
    198202
     
    200204{
    201205    /* Connections for Name, OS Type, and unattended install stuff: */
    202     if (m_pNameAndSystemEditor)
    203     {
    204         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged,
    205                 this, &UIWizardNewVMPageExpert::sltNameChanged);
    206         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged,
    207                 this, &UIWizardNewVMPageExpert::sltPathChanged);
    208         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged,
    209                 this, &UIWizardNewVMPageExpert::sltOsTypeChanged);
    210         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOSFamilyChanged,
    211                 this, &UIWizardNewVMPageExpert::sltOSFamilyTypeChanged);
    212         connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigImageChanged,
    213                 this, &UIWizardNewVMPageExpert::sltISOPathChanged);
    214     }
    215 
    216     /* Connections for username, password, and hostname: */
    217     if (m_pUserNamePasswordEditor)
    218         connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigSomeTextChanged,
    219                 this, &UIWizardNewVMPageExpert::completeChanged);
    220     if (m_pGAISOFilePathSelector)
    221         connect(m_pGAISOFilePathSelector, &UIFilePathSelector::pathChanged,
    222                 this, &UIWizardNewVMPageExpert::sltGAISOPathChanged);
    223 
    224     if (m_pGAInstallationISOContainer)
    225         connect(m_pGAInstallationISOContainer, &QGroupBox::toggled,
    226                 this, &UIWizardNewVMPageExpert::sltInstallGACheckBoxToggle);
    227 
    228     if (m_pBaseMemoryEditor)
    229         connect(m_pBaseMemoryEditor, &UIBaseMemoryEditor::sigValueChanged,
    230                 this, &UIWizardNewVMPageExpert::sltValueModified);
    231     if (m_pEFICheckBox)
    232         connect(m_pEFICheckBox, &QCheckBox::toggled,
    233                 this, &UIWizardNewVMPageExpert::sltValueModified);
    234 
    235     if (m_pFormatButtonGroup)
    236         connect(m_pFormatButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
    237                 this, &UIWizardNewVMPageExpert::sltMediumFormatChanged);
    238 
    239     /* Virtual disk related connections: */
    240     if (m_pMediumSizeEditor)
    241         connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
    242                 this, &UIWizardNewVMPageExpert::sltMediumSizeChanged);
    243 
    244     if (m_pDiskSelectionButton)
    245         connect(m_pDiskSelectionButton, &QIToolButton::clicked,
    246                 this, &UIWizardNewVMPageExpert::sltGetWithFileOpenDialog);
    247 
    248     if (m_pDiskSelector)
    249         connect(m_pDiskSelector, static_cast<void(UIMediaComboBox::*)(int)>(&UIMediaComboBox::currentIndexChanged),
    250                 this, &UIWizardNewVMPageExpert::sltMediaComboBoxIndexChanged);
    251 
    252     if (m_pDiskSourceButtonGroup)
    253     {
    254         connect(m_pDiskSourceButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked),
    255                 this, &UIWizardNewVMPageExpert::sltSelectedDiskSourceChanged);
    256         connect(m_pDiskSourceButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked),
    257                 this, &UIWizardNewVMPageExpert::sltValueModified);
    258     }
    259     connect(m_pSkipUnattendedCheckBox, &QCheckBox::toggled, this, &UIWizardNewVMPageExpert::sltSkipUnattendedCheckBoxChecked);
    260 
    261     if (m_pLocationOpenButton)
    262         connect(m_pLocationOpenButton, &QIToolButton::clicked, this, &UIWizardNewVMPageExpert::sltSelectLocationButtonClicked);
     206    // if (m_pNameAndSystemEditor)
     207    // {
     208    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigNameChanged,
     209    //             this, &UIWizardNewVMPageExpert::sltNameChanged);
     210    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigPathChanged,
     211    //             this, &UIWizardNewVMPageExpert::sltPathChanged);
     212    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOsTypeChanged,
     213    //             this, &UIWizardNewVMPageExpert::sltOsTypeChanged);
     214    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigOSFamilyChanged,
     215    //             this, &UIWizardNewVMPageExpert::sltOSFamilyTypeChanged);
     216    //     connect(m_pNameAndSystemEditor, &UINameAndSystemEditor::sigImageChanged,
     217    //             this, &UIWizardNewVMPageExpert::sltISOPathChanged);
     218    // }
     219
     220    // /* Connections for username, password, and hostname: */
     221    // if (m_pUserNamePasswordEditor)
     222    //     connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigSomeTextChanged,
     223    //             this, &UIWizardNewVMPageExpert::completeChanged);
     224    // if (m_pGAISOFilePathSelector)
     225    //     connect(m_pGAISOFilePathSelector, &UIFilePathSelector::pathChanged,
     226    //             this, &UIWizardNewVMPageExpert::sltGAISOPathChanged);
     227
     228    // if (m_pGAInstallationISOContainer)
     229    //     connect(m_pGAInstallationISOContainer, &QGroupBox::toggled,
     230    //             this, &UIWizardNewVMPageExpert::sltInstallGACheckBoxToggle);
     231
     232    // if (m_pBaseMemoryEditor)
     233    //     connect(m_pBaseMemoryEditor, &UIBaseMemoryEditor::sigValueChanged,
     234    //             this, &UIWizardNewVMPageExpert::sltValueModified);
     235    // if (m_pEFICheckBox)
     236    //     connect(m_pEFICheckBox, &QCheckBox::toggled,
     237    //             this, &UIWizardNewVMPageExpert::sltValueModified);
     238
     239    // if (m_pFormatButtonGroup)
     240    //     connect(m_pFormatButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
     241    //             this, &UIWizardNewVMPageExpert::sltMediumFormatChanged);
     242
     243    // /* Virtual disk related connections: */
     244    // if (m_pMediumSizeEditor)
     245    //     connect(m_pMediumSizeEditor, &UIMediumSizeEditor::sigSizeChanged,
     246    //             this, &UIWizardNewVMPageExpert::sltMediumSizeChanged);
     247
     248    // if (m_pDiskSelectionButton)
     249    //     connect(m_pDiskSelectionButton, &QIToolButton::clicked,
     250    //             this, &UIWizardNewVMPageExpert::sltGetWithFileOpenDialog);
     251
     252    // if (m_pDiskSelector)
     253    //     connect(m_pDiskSelector, static_cast<void(UIMediaComboBox::*)(int)>(&UIMediaComboBox::currentIndexChanged),
     254    //             this, &UIWizardNewVMPageExpert::sltMediaComboBoxIndexChanged);
     255
     256    // if (m_pDiskSourceButtonGroup)
     257    // {
     258    //     connect(m_pDiskSourceButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked),
     259    //             this, &UIWizardNewVMPageExpert::sltSelectedDiskSourceChanged);
     260    //     connect(m_pDiskSourceButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked),
     261    //             this, &UIWizardNewVMPageExpert::sltValueModified);
     262    // }
     263    // connect(m_pSkipUnattendedCheckBox, &QCheckBox::toggled, this, &UIWizardNewVMPageExpert::sltSkipUnattendedCheckBoxChecked);
     264
     265    // if (m_pLocationOpenButton)
     266    //     connect(m_pLocationOpenButton, &QIToolButton::clicked, this, &UIWizardNewVMPageExpert::sltSelectLocationButtonClicked);
    263267}
    264268
    265269void UIWizardNewVMPageExpert::setOSTypeDependedValues()
    266270{
    267     if (!field("type").canConvert<CGuestOSType>())
    268         return;
    269 
    270     /* Get recommended 'ram' field value: */
    271     CGuestOSType type = field("type").value<CGuestOSType>();
    272     ULONG recommendedRam = type.GetRecommendedRAM();
    273 
    274     if (m_pBaseMemoryEditor && !m_userSetWidgets.contains(m_pBaseMemoryEditor))
    275     {
    276         m_pBaseMemoryEditor->blockSignals(true);
    277         m_pBaseMemoryEditor->setValue(recommendedRam);
    278         m_pBaseMemoryEditor->blockSignals(false);
    279     }
    280 
    281     KFirmwareType fwType = type.GetRecommendedFirmware();
    282     if (m_pEFICheckBox && !m_userSetWidgets.contains(m_pEFICheckBox))
    283     {
    284         m_pEFICheckBox->blockSignals(true);
    285         m_pEFICheckBox->setChecked(fwType != KFirmwareType_BIOS);
    286         m_pEFICheckBox->blockSignals(false);
    287     }
    288     LONG64 recommendedDiskSize = type.GetRecommendedHDD();
    289     /* Prepare initial disk choice: */
    290     if (!m_userSetWidgets.contains(m_pDiskSourceButtonGroup))
    291     {
    292         if (recommendedDiskSize != 0)
    293         {
    294             if (m_pDiskNew)
    295                 m_pDiskNew->setChecked(true);
    296             setSelectedDiskSource(SelectedDiskSource_New);
    297             setEnableDiskSelectionWidgets(false);
    298             setEnableNewDiskWidgets(true);
    299             m_fRecommendedNoDisk = false;
    300         }
    301         else
    302         {
    303             if (m_pDiskEmpty)
    304                 m_pDiskEmpty->setChecked(true);
    305             setSelectedDiskSource(SelectedDiskSource_Empty);
    306             setEnableDiskSelectionWidgets(false);
    307             setEnableNewDiskWidgets(false);
    308             m_fRecommendedNoDisk = true;
    309         }
    310         if (m_pDiskSelector)
    311             m_pDiskSelector->setCurrentIndex(0);
    312     }
    313 
    314     if (m_pMediumSizeEditor  && !m_userSetWidgets.contains(m_pMediumSizeEditor))
    315     {
    316         m_pMediumSizeEditor->blockSignals(true);
    317         setMediumSize(recommendedDiskSize);
    318         m_pMediumSizeEditor->blockSignals(false);
    319     }
    320 
    321     if (m_pProductKeyLabel)
    322         m_pProductKeyLabel->setEnabled(isProductKeyWidgetEnabled());
    323     if (m_pProductKeyLineEdit)
    324         m_pProductKeyLineEdit->setEnabled(isProductKeyWidgetEnabled());
     271    // if (!field("type").canConvert<CGuestOSType>())
     272    //     return;
     273
     274    // /* Get recommended 'ram' field value: */
     275    // CGuestOSType type = field("type").value<CGuestOSType>();
     276    // ULONG recommendedRam = type.GetRecommendedRAM();
     277
     278    // if (m_pBaseMemoryEditor && !m_userSetWidgets.contains(m_pBaseMemoryEditor))
     279    // {
     280    //     m_pBaseMemoryEditor->blockSignals(true);
     281    //     m_pBaseMemoryEditor->setValue(recommendedRam);
     282    //     m_pBaseMemoryEditor->blockSignals(false);
     283    // }
     284
     285    // KFirmwareType fwType = type.GetRecommendedFirmware();
     286    // if (m_pEFICheckBox && !m_userSetWidgets.contains(m_pEFICheckBox))
     287    // {
     288    //     m_pEFICheckBox->blockSignals(true);
     289    //     m_pEFICheckBox->setChecked(fwType != KFirmwareType_BIOS);
     290    //     m_pEFICheckBox->blockSignals(false);
     291    // }
     292    // LONG64 recommendedDiskSize = type.GetRecommendedHDD();
     293    // /* Prepare initial disk choice: */
     294    // if (!m_userSetWidgets.contains(m_pDiskSourceButtonGroup))
     295    // {
     296    //     if (recommendedDiskSize != 0)
     297    //     {
     298    //         if (m_pDiskNew)
     299    //             m_pDiskNew->setChecked(true);
     300    //         setSelectedDiskSource(SelectedDiskSource_New);
     301    //         setEnableDiskSelectionWidgets(false);
     302    //         setEnableNewDiskWidgets(true);
     303    //         m_fRecommendedNoDisk = false;
     304    //     }
     305    //     else
     306    //     {
     307    //         if (m_pDiskEmpty)
     308    //             m_pDiskEmpty->setChecked(true);
     309    //         setSelectedDiskSource(SelectedDiskSource_Empty);
     310    //         setEnableDiskSelectionWidgets(false);
     311    //         setEnableNewDiskWidgets(false);
     312    //         m_fRecommendedNoDisk = true;
     313    //     }
     314    //     if (m_pDiskSelector)
     315    //         m_pDiskSelector->setCurrentIndex(0);
     316    // }
     317
     318    // if (m_pMediumSizeEditor  && !m_userSetWidgets.contains(m_pMediumSizeEditor))
     319    // {
     320    //     m_pMediumSizeEditor->blockSignals(true);
     321    //     setMediumSize(recommendedDiskSize);
     322    //     m_pMediumSizeEditor->blockSignals(false);
     323    // }
     324
     325    // if (m_pProductKeyLabel)
     326    //     m_pProductKeyLabel->setEnabled(isProductKeyWidgetEnabled());
     327    // if (m_pProductKeyLineEdit)
     328    //     m_pProductKeyLineEdit->setEnabled(isProductKeyWidgetEnabled());
    325329}
    326330
    327331void UIWizardNewVMPageExpert::initializePage()
    328332{
    329     disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
    330     setOSTypeDependedValues();
    331     disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
    332     updateVirtualDiskPathFromMachinePathName();
    333     updateWidgetAterMediumFormatChange();
    334     setSkipCheckBoxEnable();
    335     retranslateUi();
     333    // disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
     334    // setOSTypeDependedValues();
     335    // disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
     336    // updateVirtualDiskPathFromMachinePathName();
     337    // updateWidgetAterMediumFormatChange();
     338    // setSkipCheckBoxEnable();
     339    // retranslateUi();
    336340}
    337341
    338342void UIWizardNewVMPageExpert::cleanupPage()
    339343{
    340     cleanupMachineFolder();
     344    //cleanupMachineFolder();
    341345}
    342346
    343347void UIWizardNewVMPageExpert::markWidgets() const
    344348{
    345     UIWizardNewVMPageBaseNameOSType::markWidgets();
    346     UIWizardNewVMPageBaseUnattended::markWidgets();
     349    // UIWizardNewVMPageBaseNameOSType::markWidgets();
     350    // UIWizardNewVMPageBaseUnattended::markWidgets();
    347351}
    348352
     
    350354{
    351355    QWidget *pContainerWidget = new QWidget;
    352     QGridLayout *pLayout = new QGridLayout(pContainerWidget);
    353     pLayout->setContentsMargins(0, 0, 0, 0);
    354     int iRow = 0;
    355 
    356     /* Username selector: */
    357     pLayout->addWidget(createUserNameWidgets(), iRow, 0, 1, 2);
    358 
    359     /* Additional options: */
    360     pLayout->addWidget(createAdditionalOptionsWidgets(), iRow, 2, 1, 2);
    361 
    362     ++iRow;
    363     /* Guest additions installation: */
    364     pLayout->addWidget(createGAInstallWidgets(), iRow, 0, 1, 4);
     356    // QGridLayout *pLayout = new QGridLayout(pContainerWidget);
     357    // pLayout->setContentsMargins(0, 0, 0, 0);
     358    // int iRow = 0;
     359
     360    // /* Username selector: */
     361    // pLayout->addWidget(createUserNameWidgets(), iRow, 0, 1, 2);
     362
     363    // /* Additional options: */
     364    // pLayout->addWidget(createAdditionalOptionsWidgets(), iRow, 2, 1, 2);
     365
     366    // ++iRow;
     367    // /* Guest additions installation: */
     368    // pLayout->addWidget(createGAInstallWidgets(), iRow, 0, 1, 4);
    365369
    366370    return pContainerWidget;
     
    418422bool UIWizardNewVMPageExpert::isComplete() const
    419423{
    420     markWidgets();
     424    //markWidgets();
    421425    bool fIsComplete = true;
    422     m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType, QIcon());
    423     m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Unattended, QIcon());
    424     m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Disk, QIcon());
    425     m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Hardware, QIcon());
    426 
    427     if (!UIWizardPage::isComplete())
    428     {
    429         m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType,
    430                                      UIIconPool::iconSet(":/status_error_16px.png"),
    431                                      UIWizardNewVM::tr("A valid VM name is required"));
    432         fIsComplete = false;
    433     }
    434 
    435     if (m_pDiskExisting && m_pDiskExisting->isChecked() && uiCommon().medium(m_pDiskSelector->id()).isNull())
    436     {
    437         m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Disk,
    438                                      UIIconPool::iconSet(":/status_error_16px.png"), UIWizardNewVM::tr("No valid disk is selected"));
    439         fIsComplete = false;
    440     }
    441 
    442     if (m_pDiskNew && m_pDiskNew->isChecked())
    443     {
    444         qulonglong uSize = field("mediumSize").toULongLong();
    445         if (uSize <= 0)
    446         {
    447             m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Disk,
    448                                          UIIconPool::iconSet(":/status_error_16px.png"), UIWizardNewVM::tr("Invalid disk size"));
    449             fIsComplete = false;
    450         }
    451     }
    452 
    453     /* Check unattended install related stuff: */
    454     if (isUnattendedEnabled())
    455     {
    456         /* Check the installation medium: */
    457         if (!checkISOFile())
    458         {
    459             m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType,
    460                                          UIIconPool::iconSet(":/status_error_16px.png"),
    461                                          UIWizardNewVM::tr("Invalid path or unreadable ISO file"));
    462             fIsComplete = false;
    463         }
    464         /* Check the GA installation medium: */
    465         if (m_pGAInstallationISOContainer && m_pGAInstallationISOContainer->isChecked() && !checkGAISOFile())
    466         {
    467             m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Unattended,
    468                                          UIIconPool::iconSet(":/status_error_16px.png"),
    469                                          UIWizardNewVM::tr("Invalid path or unreadable ISO file"));
    470 
    471             fIsComplete = false;
    472         }
    473         if (m_pUserNamePasswordEditor)
    474         {
    475             if (!m_pUserNamePasswordEditor->isComplete())
    476             {
    477                 m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Unattended,
    478                                              UIIconPool::iconSet(":/status_error_16px.png"),
    479                                              UIWizardNewVM::tr("Invalid username and/or password"));
    480                 fIsComplete = false;
    481             }
    482         }
    483     }
     426    // m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType, QIcon());
     427    // m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Unattended, QIcon());
     428    // m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Disk, QIcon());
     429    // m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Hardware, QIcon());
     430
     431    // if (!UIWizardPage::isComplete())
     432    // {
     433    //     m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType,
     434    //                                  UIIconPool::iconSet(":/status_error_16px.png"),
     435    //                                  UIWizardNewVM::tr("A valid VM name is required"));
     436    //     fIsComplete = false;
     437    // }
     438
     439    // if (m_pDiskExisting && m_pDiskExisting->isChecked() && uiCommon().medium(m_pDiskSelector->id()).isNull())
     440    // {
     441    //     m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Disk,
     442    //                                  UIIconPool::iconSet(":/status_error_16px.png"), UIWizardNewVM::tr("No valid disk is selected"));
     443    //     fIsComplete = false;
     444    // }
     445
     446    // if (m_pDiskNew && m_pDiskNew->isChecked())
     447    // {
     448    //     qulonglong uSize = field("mediumSize").toULongLong();
     449    //     if (uSize <= 0)
     450    //     {
     451    //         m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Disk,
     452    //                                      UIIconPool::iconSet(":/status_error_16px.png"), UIWizardNewVM::tr("Invalid disk size"));
     453    //         fIsComplete = false;
     454    //     }
     455    // }
     456
     457    // /* Check unattended install related stuff: */
     458    // if (isUnattendedEnabled())
     459    // {
     460    //     /* Check the installation medium: */
     461    //     if (!checkISOFile())
     462    //     {
     463    //         m_pToolBox->setPageTitleIcon(ExpertToolboxItems_NameAndOSType,
     464    //                                      UIIconPool::iconSet(":/status_error_16px.png"),
     465    //                                      UIWizardNewVM::tr("Invalid path or unreadable ISO file"));
     466    //         fIsComplete = false;
     467    //     }
     468    //     /* Check the GA installation medium: */
     469    //     if (m_pGAInstallationISOContainer && m_pGAInstallationISOContainer->isChecked() && !checkGAISOFile())
     470    //     {
     471    //         m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Unattended,
     472    //                                      UIIconPool::iconSet(":/status_error_16px.png"),
     473    //                                      UIWizardNewVM::tr("Invalid path or unreadable ISO file"));
     474
     475    //         fIsComplete = false;
     476    //     }
     477    //     if (m_pUserNamePasswordEditor)
     478    //     {
     479    //         if (!m_pUserNamePasswordEditor->isComplete())
     480    //         {
     481    //             m_pToolBox->setPageTitleIcon(ExpertToolboxItems_Unattended,
     482    //                                          UIIconPool::iconSet(":/status_error_16px.png"),
     483    //                                          UIWizardNewVM::tr("Invalid username and/or password"));
     484    //             fIsComplete = false;
     485    //         }
     486    //     }
     487    // }
    484488
    485489     // return !mediumFormat().isNull() &&
     
    495499    bool fResult = true;
    496500
    497     if (selectedDiskSource() == SelectedDiskSource_New)
    498     {
    499         /* Check if the path we will be using for hard drive creation exists: */
    500         const QString strMediumPath(fieldImp("mediumPath").toString());
    501         fResult = !QFileInfo(strMediumPath).exists();
    502         if (!fResult)
    503         {
    504             msgCenter().cannotOverwriteHardDiskStorage(strMediumPath, this);
    505             return fResult;
    506         }
    507         /* Check FAT size limitation of the host hard drive: */
    508         fResult = UIWizardNewVDPageBaseSizeLocation::checkFATSizeLimitation(fieldImp("mediumVariant").toULongLong(),
    509                                                              fieldImp("mediumPath").toString(),
    510                                                              fieldImp("mediumSize").toULongLong());
    511         if (!fResult)
    512         {
    513             msgCenter().cannotCreateHardDiskStorageInFAT(strMediumPath, this);
    514             return fResult;
    515         }
    516     }
    517 
    518     startProcessing();
    519     UIWizardNewVM *pWizard = wizardImp();
    520     AssertReturn(pWizard, false);
    521     if (selectedDiskSource() == SelectedDiskSource_New)
    522     {
    523         /* Try to create the hard drive:*/
    524         fResult = pWizard->createVirtualDisk();
    525         /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */
    526         if (!fResult)
    527             return fResult;
    528     }
    529 
    530     fResult = pWizard->createVM();
    531     /* Try to delete the hard disk: */
    532     if (!fResult)
    533         pWizard->deleteVirtualDisk();
    534 
    535     endProcessing();
     501    // if (selectedDiskSource() == SelectedDiskSource_New)
     502    // {
     503    //     /* Check if the path we will be using for hard drive creation exists: */
     504    //     const QString strMediumPath(fieldImp("mediumPath").toString());
     505    //     fResult = !QFileInfo(strMediumPath).exists();
     506    //     if (!fResult)
     507    //     {
     508    //         msgCenter().cannotOverwriteHardDiskStorage(strMediumPath, this);
     509    //         return fResult;
     510    //     }
     511    //     /* Check FAT size limitation of the host hard drive: */
     512    //     fResult = UIWizardNewVDPageBaseSizeLocation::checkFATSizeLimitation(fieldImp("mediumVariant").toULongLong(),
     513    //                                                          fieldImp("mediumPath").toString(),
     514    //                                                          fieldImp("mediumSize").toULongLong());
     515    //     if (!fResult)
     516    //     {
     517    //         msgCenter().cannotCreateHardDiskStorageInFAT(strMediumPath, this);
     518    //         return fResult;
     519    //     }
     520    // }
     521
     522    // startProcessing();
     523    // UIWizardNewVM *pWizard = wizardImp();
     524    // AssertReturn(pWizard, false);
     525    // if (selectedDiskSource() == SelectedDiskSource_New)
     526    // {
     527    //     /* Try to create the hard drive:*/
     528    //     fResult = pWizard->createVirtualDisk();
     529    //     /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */
     530    //     if (!fResult)
     531    //         return fResult;
     532    // }
     533
     534    // fResult = pWizard->createVM();
     535    // /* Try to delete the hard disk: */
     536    // if (!fResult)
     537    //     pWizard->deleteVirtualDisk();
     538
     539    // endProcessing();
    536540
    537541    return fResult;
     
    540544bool UIWizardNewVMPageExpert::isProductKeyWidgetEnabled() const
    541545{
    542     UIWizardNewVM *pWizard = wizardImp();
    543     AssertReturn(pWizard, false);
    544     if (!pWizard->isUnattendedEnabled() || !pWizard->isGuestOSTypeWindows())
    545         return false;
     546    // UIWizardNewVM *pWizard = wizardImp();
     547    // AssertReturn(pWizard, false);
     548    // if (!pWizard->isUnattendedEnabled() || !pWizard->isGuestOSTypeWindows())
     549    //     return false;
    546550    return true;
    547551}
     
    549553void UIWizardNewVMPageExpert::disableEnableUnattendedRelatedWidgets(bool fEnabled)
    550554{
    551     if (m_pUserNameContainer)
    552         m_pUserNameContainer->setEnabled(fEnabled);
    553     if (m_pAdditionalOptionsContainer)
    554         m_pAdditionalOptionsContainer->setEnabled(fEnabled);
    555     if (m_pGAInstallationISOContainer)
    556         m_pGAInstallationISOContainer->setEnabled(fEnabled);
    557     disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
    558     disableEnableGAWidgets(isGAInstallEnabled());
     555    Q_UNUSED(fEnabled);
     556
     557    // if (m_pUserNameContainer)
     558    //     m_pUserNameContainer->setEnabled(fEnabled);
     559    // if (m_pAdditionalOptionsContainer)
     560    //     m_pAdditionalOptionsContainer->setEnabled(fEnabled);
     561    // if (m_pGAInstallationISOContainer)
     562    //     m_pGAInstallationISOContainer->setEnabled(fEnabled);
     563    // disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
     564    // disableEnableGAWidgets(isGAInstallEnabled());
    559565}
    560566
     
    569575void UIWizardNewVMPageExpert::sltSkipUnattendedCheckBoxChecked()
    570576{
    571     disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
     577    //disableEnableUnattendedRelatedWidgets(isUnattendedEnabled());
    572578}
    573579
     
    595601void UIWizardNewVMPageExpert::sltSelectedDiskSourceChanged()
    596602{
    597     if (!m_pDiskSourceButtonGroup)
    598         return;
    599     m_userSetWidgets << m_pDiskSourceButtonGroup;
    600     if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskEmpty)
    601         setSelectedDiskSource(SelectedDiskSource_Empty);
    602     else if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskExisting)
    603     {
    604         setSelectedDiskSource(SelectedDiskSource_Existing);
    605         setVirtualDiskFromDiskCombo();
    606     }
    607     else
    608         setSelectedDiskSource(SelectedDiskSource_New);
    609 
    610     setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing);
    611     setEnableNewDiskWidgets(m_enmSelectedDiskSource == SelectedDiskSource_New);
    612 
    613     completeChanged();
     603    // if (!m_pDiskSourceButtonGroup)
     604    //     return;
     605    // m_userSetWidgets << m_pDiskSourceButtonGroup;
     606    // if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskEmpty)
     607    //     setSelectedDiskSource(SelectedDiskSource_Empty);
     608    // else if (m_pDiskSourceButtonGroup->checkedButton() == m_pDiskExisting)
     609    // {
     610    //     setSelectedDiskSource(SelectedDiskSource_Existing);
     611    //     setVirtualDiskFromDiskCombo();
     612    // }
     613    // else
     614    //     setSelectedDiskSource(SelectedDiskSource_New);
     615
     616    // setEnableDiskSelectionWidgets(m_enmSelectedDiskSource == SelectedDiskSource_Existing);
     617    // setEnableNewDiskWidgets(m_enmSelectedDiskSource == SelectedDiskSource_New);
     618
     619    // completeChanged();
    614620}
    615621
     
    621627void UIWizardNewVMPageExpert::updateVirtualDiskPathFromMachinePathName()
    622628{
    623     QString strDiskFileName = machineBaseName().isEmpty() ? QString("NewVirtualDisk1") : machineBaseName();
    624     QString strDiskPath = machineFolder();
    625     if (strDiskPath.isEmpty())
    626     {
    627         if (m_pNameAndSystemEditor)
    628             strDiskPath = m_pNameAndSystemEditor->path();
    629         else
    630             strDiskPath = uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
    631     }
    632     QString strExtension = defaultExtension(mediumFormat());
    633     if (m_pLocationEditor)
    634         m_pLocationEditor->setText(absoluteFilePath(strDiskFileName, strDiskPath, strExtension));
     629    // QString strDiskFileName = machineBaseName().isEmpty() ? QString("NewVirtualDisk1") : machineBaseName();
     630    // QString strDiskPath = machineFolder();
     631    // if (strDiskPath.isEmpty())
     632    // {
     633    //     if (m_pNameAndSystemEditor)
     634    //         strDiskPath = m_pNameAndSystemEditor->path();
     635    //     else
     636    //         strDiskPath = uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
     637    // }
     638    // QString strExtension = defaultExtension(mediumFormat());
     639    // if (m_pLocationEditor)
     640    //     m_pLocationEditor->setText(absoluteFilePath(strDiskFileName, strDiskPath, strExtension));
    635641}
    636642
     
    667673void UIWizardNewVMPageExpert::setVirtualDiskFromDiskCombo()
    668674{
    669     AssertReturnVoid(m_pDiskSelector);
    670     UIWizardNewVM *pWizard = wizardImp();
    671     AssertReturnVoid(pWizard);
    672     pWizard->setVirtualDisk(m_pDiskSelector->id());
    673 }
     675    // AssertReturnVoid(m_pDiskSelector);
     676    // UIWizardNewVM *pWizard = wizardImp();
     677    // AssertReturnVoid(pWizard);
     678    // pWizard->setVirtualDisk(m_pDiskSelector->id());
     679}
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageExpert.h

    r89916 r90003  
    2626
    2727/* Local includes: */
    28 #include "UIWizardNewVMPageNameOSType.h"
    29 #include "UIWizardNewVMPageUnattended.h"
    30 #include "UIWizardNewVMPageHardware.h"
    31 #include "UIWizardNewVMPageDisk.h"
     28#include "UIWizardNewVMNameOSTypePageBasic.h"
     29#include "UIWizardNewVMUnattendedPageBasic.h"
     30#include "UIWizardNewVMHardwarePageBasic.h"
     31#include "UIWizardNewVMDiskPageBasic.h"
    3232#include "UIWizardNewVDPageSizeLocation.h"
    3333
     
    3838/** Expert page of the New Virtual Machine wizard. */
    3939class UIWizardNewVMPageExpert : public UIWizardPage,
    40                                 public UIWizardNewVMPageBaseNameOSType,
    41                                 public UIWizardNewVMPageBaseUnattended,
    42                                 public UIWizardNewVMPageHardwareBase,
    43                                 public UIWizardNewVMPageDiskBase,
    4440                                public UIWizardNewVDPageBaseFileType,
    4541                                public UIWizardNewVDPageBaseVariant,
     
    4844
    4945    Q_OBJECT;
    50     Q_PROPERTY(QString machineFolder READ machineFolder WRITE setMachineFolder);
    51     Q_PROPERTY(QString machineBaseName READ machineBaseName WRITE setMachineBaseName);
    52     Q_PROPERTY(QString machineFilePath READ machineFilePath WRITE setMachineFilePath);
    53     Q_PROPERTY(int baseMemory READ baseMemory);
    54     Q_PROPERTY(QString guestOSFamiyId READ guestOSFamiyId);
    55     Q_PROPERTY(QString ISOFilePath READ ISOFilePath);
    56     Q_PROPERTY(bool isUnattendedEnabled READ isUnattendedEnabled);
    57     Q_PROPERTY(bool startHeadless READ startHeadless);
    58     Q_PROPERTY(QString detectedOSTypeId READ detectedOSTypeId);
    59     Q_PROPERTY(QString userName READ userName WRITE setUserName);
    60     Q_PROPERTY(QString password READ password WRITE setPassword);
    61     Q_PROPERTY(QString hostname READ hostname WRITE setHostname);
    62     Q_PROPERTY(bool installGuestAdditions READ installGuestAdditions WRITE setInstallGuestAdditions);
    63     Q_PROPERTY(QString guestAdditionsISOPath READ guestAdditionsISOPath WRITE setGuestAdditionsISOPath);
    64     Q_PROPERTY(QString productKey READ productKey);
    65     Q_PROPERTY(int VCPUCount READ VCPUCount);
    66     Q_PROPERTY(bool EFIEnabled READ EFIEnabled);
    67 
    68     Q_PROPERTY(SelectedDiskSource selectedDiskSource READ selectedDiskSource WRITE setSelectedDiskSource);
    69     Q_PROPERTY(CMediumFormat mediumFormat READ mediumFormat);
    70     Q_PROPERTY(qulonglong mediumVariant READ mediumVariant WRITE setMediumVariant);
    71     Q_PROPERTY(QString mediumPath READ mediumPath);
    72     Q_PROPERTY(qulonglong mediumSize READ mediumSize WRITE setMediumSize);
    7346
    7447public:
     
    7952protected:
    8053
    81     /** Wrapper to access 'wizard' from base part. */
    82     UIWizardNewVM *wizardImp() const { return qobject_cast<UIWizardNewVM*>(wizard()); }
    83     /** Wrapper to access 'this' from base part. */
    84     UIWizardPage* thisImp() { return this; }
    85     /** Wrapper to access 'wizard-field' from base part. */
    86     QVariant fieldImp(const QString &strFieldName) const { return UIWizardPage::field(strFieldName); }
    8754
    8855private slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMUnattendedPageBasic.cpp

    r90002 r90003  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewVMPageUnattended class implementation.
     3 * VBox Qt GUI - UIWizardNewVMUnattendedPageBasic class implementation.
    44 */
    55
     
    3232#include "UIIconPool.h"
    3333#include "UIUserNamePasswordEditor.h"
    34 #include "UIWizardNewVMPageUnattended.h"
     34#include "UIWizardNewVMUnattendedPageBasic.h"
    3535#include "UIWizardNewVM.h"
    3636
     
    4040#include "CUnattended.h"
    4141
    42 UIWizardNewVMPageBaseUnattended::UIWizardNewVMPageBaseUnattended()
    43     : m_pUserNameContainer(0)
     42// UIWizardNewVMUnattendedPage::UIWizardNewVMUnattendedPage()
     43
     44// {
     45// }
     46
     47// QString UIWizardNewVMUnattendedPage::userName() const
     48// {
     49//     if (m_pUserNamePasswordEditor)
     50//         return m_pUserNamePasswordEditor->userName();
     51//     return QString();
     52// }
     53
     54// void UIWizardNewVMUnattendedPage::setUserName(const QString &strName)
     55// {
     56//     if (m_pUserNamePasswordEditor)
     57//         m_pUserNamePasswordEditor->setUserName(strName);
     58// }
     59
     60// QString UIWizardNewVMUnattendedPage::password() const
     61// {
     62//     if (m_pUserNamePasswordEditor)
     63//         return m_pUserNamePasswordEditor->password();
     64//     return QString();
     65// }
     66
     67// void UIWizardNewVMUnattendedPage::setPassword(const QString &strPassword)
     68// {
     69//     if (m_pUserNamePasswordEditor)
     70//         return m_pUserNamePasswordEditor->setPassword(strPassword);
     71// }
     72
     73// QString UIWizardNewVMUnattendedPage::hostname() const
     74// {
     75//     if (m_pHostnameLineEdit)
     76//         return m_pHostnameLineEdit->text();
     77//     return QString();
     78// }
     79
     80// void UIWizardNewVMUnattendedPage::setHostname(const QString &strHostName)
     81// {
     82//     if (m_pHostnameLineEdit)
     83//         return m_pHostnameLineEdit->setText(strHostName);
     84// }
     85
     86// bool UIWizardNewVMUnattendedPage::installGuestAdditions() const
     87// {
     88//     if (!m_pGAInstallationISOContainer)
     89//         return false;
     90//     return m_pGAInstallationISOContainer->isChecked();
     91// }
     92
     93// void UIWizardNewVMUnattendedPage::setInstallGuestAdditions(bool fInstallGA)
     94// {
     95//     if (m_pGAInstallationISOContainer)
     96//         m_pGAInstallationISOContainer->setChecked(fInstallGA);
     97// }
     98
     99// QString UIWizardNewVMUnattendedPage::guestAdditionsISOPath() const
     100// {
     101//     if (!m_pGAISOFilePathSelector)
     102//         return QString();
     103//     return m_pGAISOFilePathSelector->path();
     104// }
     105
     106// void UIWizardNewVMUnattendedPage::setGuestAdditionsISOPath(const QString &strISOPath)
     107// {
     108//     if (m_pGAISOFilePathSelector)
     109//         m_pGAISOFilePathSelector->setPath(strISOPath);
     110// }
     111
     112// QString UIWizardNewVMUnattendedPage::productKey() const
     113// {
     114//     if (!m_pProductKeyLineEdit || !m_pProductKeyLineEdit->hasAcceptableInput())
     115//         return QString();
     116//     return m_pProductKeyLineEdit->text();
     117// }
     118
     119
     120// bool UIWizardNewVMUnattendedPage::checkGAISOFile() const
     121// {
     122//     if (!m_pGAISOFilePathSelector)
     123//         return false;
     124//     /* GA ISO selector should not be empty since GA install check box is checked at this point: */
     125//     const QString &strPath = m_pGAISOFilePathSelector->path();
     126//     if (strPath.isNull() || strPath.isEmpty())
     127//         return false;
     128//     QFileInfo fileInfo(strPath);
     129//     if (!fileInfo.exists() || !fileInfo.isReadable())
     130//         return false;
     131//     return true;
     132// }
     133
     134// void UIWizardNewVMUnattendedPage::markWidgets() const
     135// {
     136//     if (installGuestAdditions())
     137//         m_pGAISOFilePathSelector->mark(!checkGAISOFile());
     138// }
     139
     140
     141// void UIWizardNewVMUnattendedPage::disableEnableGAWidgets(bool fEnabled)
     142// {
     143//     if (m_pGAISOPathLabel)
     144//         m_pGAISOPathLabel->setEnabled(fEnabled);
     145//     if (m_pGAISOFilePathSelector)
     146//         m_pGAISOFilePathSelector->setEnabled(fEnabled);
     147// }
     148
     149// void UIWizardNewVMUnattendedPage::disableEnableProductKeyWidgets(bool fEnabled)
     150// {
     151//     if (m_pProductKeyLabel)
     152//         m_pProductKeyLabel->setEnabled(fEnabled);
     153//     if (m_pProductKeyLineEdit)
     154//         m_pProductKeyLineEdit->setEnabled(fEnabled);
     155// }
     156
     157// bool UIWizardNewVMUnattendedPage::startHeadless() const
     158// {
     159//     if (!m_pStartHeadlessCheckBox)
     160//         return false;
     161//     return m_pStartHeadlessCheckBox->isChecked();
     162// }
     163
     164
     165// bool UIWizardNewVMUnattendedPage::isGAInstallEnabled() const
     166// {
     167//     if (m_pGAInstallationISOContainer && m_pGAInstallationISOContainer->isChecked())
     168//         return true;
     169//     return false;
     170// }
     171
     172UIWizardNewVMUnattendedPageBasic::UIWizardNewVMUnattendedPageBasic()
     173    : m_pLabel(0)
     174    , m_pUserNameContainer(0)
    44175    , m_pAdditionalOptionsContainer(0)
    45176    , m_pGAInstallationISOContainer(0)
     
    52183    , m_pProductKeyLineEdit(0)
    53184    , m_pProductKeyLabel(0)
    54 
    55 {
    56 }
    57 
    58 QString UIWizardNewVMPageBaseUnattended::userName() const
    59 {
     185{
     186    prepare();
     187}
     188
     189void UIWizardNewVMUnattendedPageBasic::prepare()
     190{
     191    QGridLayout *pMainLayout = new QGridLayout(this);
     192
     193    m_pLabel = new QIRichTextLabel(this);
     194    if (m_pLabel)
     195        pMainLayout->addWidget(m_pLabel, 0, 0, 1, 2);
     196    pMainLayout->addWidget(createUserNameWidgets(), 1, 0, 1, 1);
     197    pMainLayout->addWidget(createAdditionalOptionsWidgets(), 1, 1, 1, 1);
     198    pMainLayout->addWidget(createGAInstallWidgets(), 2, 0, 1, 2);
     199    pMainLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding), 3, 0, 1, 2);
     200
     201
     202    // createConnections();
     203}
     204
     205void UIWizardNewVMUnattendedPageBasic::createConnections()
     206{
     207    // if (m_pUserNamePasswordEditor)
     208    //     connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigSomeTextChanged,
     209    //             this, &UIWizardNewVMUnattendedPageBasic::completeChanged);
     210    // if (m_pGAISOFilePathSelector)
     211    //     connect(m_pGAISOFilePathSelector, &UIFilePathSelector::pathChanged,
     212    //             this, &UIWizardNewVMUnattendedPageBasic::sltGAISOPathChanged);
     213    // if (m_pGAISOFilePathSelector)
     214    //     connect(m_pGAInstallationISOContainer, &QGroupBox::toggled,
     215    //             this, &UIWizardNewVMUnattendedPageBasic::sltInstallGACheckBoxToggle);
     216}
     217
     218
     219void UIWizardNewVMUnattendedPageBasic::retranslateUi()
     220{
     221    setTitle(UIWizardNewVM::tr("Unattended Guest OS Install Setup"));
     222    if (m_pLabel)
     223        m_pLabel->setText(UIWizardNewVM::tr("<p>You can configure the unattended guest OS install by modifying username, password, and "
     224                                            "hostname. Additionally you can enable guest additions install. "
     225                                            "For Microsoft Windows guests it is possible to provide a product key.</p>"));
     226    if (m_pHostnameLabel)
     227        m_pHostnameLabel->setText(UIWizardNewVM::tr("Hostna&me:"));
     228
     229    if (m_pGAISOPathLabel)
     230        m_pGAISOPathLabel->setText(UIWizardNewVM::tr("GA I&nstallation ISO:"));
     231    if (m_pGAISOFilePathSelector)
     232        m_pGAISOFilePathSelector->setToolTip(UIWizardNewVM::tr("Please select an installation medium (ISO file)"));
     233    if (m_pGAInstallationISOContainer)
     234    {
     235        m_pGAInstallationISOContainer->setTitle(UIWizardNewVM::tr("Gu&est Additions"));
     236        m_pGAInstallationISOContainer->setToolTip(UIWizardNewVM::tr("<p>When checked the guest additions will be installed "
     237                                                           "after the OS install.</p>"));
     238    }
     239    if (m_pProductKeyLabel)
     240        m_pProductKeyLabel->setText(UIWizardNewVM::tr("&Product Key:"));
     241    if (m_pUserNameContainer)
     242        m_pUserNameContainer->setTitle(UIWizardNewVM::tr("Username and Password"));
     243    if (m_pAdditionalOptionsContainer)
     244        m_pAdditionalOptionsContainer->setTitle(UIWizardNewVM::tr("Additional Options"));
     245    if (m_pStartHeadlessCheckBox)
     246    {
     247        m_pStartHeadlessCheckBox->setText(UIWizardNewVM::tr("&Install in Background"));
     248        m_pStartHeadlessCheckBox->setToolTip(UIWizardNewVM::tr("<p>When checked, the newly created virtual machine will be started "
     249                                                               "in headless mode (without a GUI) for the unattended guest OS install.</p>"));
     250    }
     251}
     252
     253
     254void UIWizardNewVMUnattendedPageBasic::initializePage()
     255{
     256    // disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
     257    // disableEnableGAWidgets(m_pGAInstallationISOContainer ? m_pGAInstallationISOContainer->isChecked() : false);
     258    // retranslateUi();
     259}
     260
     261bool UIWizardNewVMUnattendedPageBasic::isComplete() const
     262{
     263//     markWidgets();
     264//     if (isGAInstallEnabled() && !checkGAISOFile())
     265//         return false;
     266// //     bool fIsComplete = true;
     267// //     if (!checkGAISOFile())
     268// //     {
     269// //         m_pToolBox->setItemIcon(ToolBoxItems_GAInstall, UIIconPool::iconSet(":/status_error_16px.png"));
     270// //         fIsComplete = false;
     271// //     }
     272//     if (m_pUserNamePasswordEditor && !m_pUserNamePasswordEditor->isComplete())
     273//         return false;
     274// //     {
     275// //         m_pToolBox->setItemIcon(ToolBoxItems_UserNameHostname, UIIconPool::iconSet(":/status_error_16px.png"));
     276// //         fIsComplete = false;
     277// //     }
     278// //     return fIsComplete;
     279    return true;
     280}
     281
     282void UIWizardNewVMUnattendedPageBasic::cleanupPage()
     283{
     284}
     285
     286void UIWizardNewVMUnattendedPageBasic::showEvent(QShowEvent *pEvent)
     287{
     288    Q_UNUSED(pEvent);
     289    // if (m_pToolBox)
     290    //     m_pToolBox->setItemEnabled(ToolBoxItems_ProductKey, isProductKeyWidgetEnabled());
     291    //UIWizardPage::showEvent(pEvent);
     292}
     293
     294void UIWizardNewVMUnattendedPageBasic::sltInstallGACheckBoxToggle(bool fEnabled)
     295{
     296    Q_UNUSED(fEnabled);
     297    // disableEnableGAWidgets(fEnabled);
     298    // emit completeChanged();
     299}
     300
     301void UIWizardNewVMUnattendedPageBasic::sltGAISOPathChanged(const QString &strPath)
     302{
     303    Q_UNUSED(strPath);
     304    // emit completeChanged();
     305}
     306
     307bool UIWizardNewVMUnattendedPageBasic::isProductKeyWidgetEnabled() const
     308{
     309    // UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
     310    // if (!pWizard || !pWizard->isUnattendedEnabled() || !pWizard->isGuestOSTypeWindows())
     311    //     return false;
     312    return true;
     313}
     314
     315QWidget *UIWizardNewVMUnattendedPageBasic::createUserNameWidgets()
     316{
     317    if (m_pUserNameContainer)
     318        return m_pUserNameContainer;
     319
     320    m_pUserNameContainer = new QGroupBox;
     321    QVBoxLayout *pUserNameContainerLayout = new QVBoxLayout(m_pUserNameContainer);
     322    m_pUserNamePasswordEditor = new UIUserNamePasswordEditor;
    60323    if (m_pUserNamePasswordEditor)
    61         return m_pUserNamePasswordEditor->userName();
    62     return QString();
    63 }
    64 
    65 void UIWizardNewVMPageBaseUnattended::setUserName(const QString &strName)
    66 {
    67     if (m_pUserNamePasswordEditor)
    68         m_pUserNamePasswordEditor->setUserName(strName);
    69 }
    70 
    71 QString UIWizardNewVMPageBaseUnattended::password() const
    72 {
    73     if (m_pUserNamePasswordEditor)
    74         return m_pUserNamePasswordEditor->password();
    75     return QString();
    76 }
    77 
    78 void UIWizardNewVMPageBaseUnattended::setPassword(const QString &strPassword)
    79 {
    80     if (m_pUserNamePasswordEditor)
    81         return m_pUserNamePasswordEditor->setPassword(strPassword);
    82 }
    83 
    84 QString UIWizardNewVMPageBaseUnattended::hostname() const
    85 {
     324    {
     325        m_pUserNamePasswordEditor->setLabelsVisible(true);
     326        pUserNameContainerLayout->addWidget(m_pUserNamePasswordEditor);
     327    }
     328    return m_pUserNameContainer;
     329}
     330
     331QWidget *UIWizardNewVMUnattendedPageBasic::createAdditionalOptionsWidgets()
     332{
     333    if (m_pAdditionalOptionsContainer)
     334        return m_pAdditionalOptionsContainer;
     335
     336    m_pAdditionalOptionsContainer = new QGroupBox;
     337    QGridLayout *pAdditionalOptionsContainerLayout = new QGridLayout(m_pAdditionalOptionsContainer);
     338    pAdditionalOptionsContainerLayout->setColumnStretch(0, 0);
     339    pAdditionalOptionsContainerLayout->setColumnStretch(1, 1);
     340
     341    m_pProductKeyLabel = new QLabel;
     342    if (m_pProductKeyLabel)
     343    {
     344        m_pProductKeyLabel->setAlignment(Qt::AlignRight);
     345        m_pProductKeyLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     346        pAdditionalOptionsContainerLayout->addWidget(m_pProductKeyLabel, 0, 0);
     347    }
     348    m_pProductKeyLineEdit = new QLineEdit;
     349    if (m_pProductKeyLineEdit)
     350    {
     351        m_pProductKeyLineEdit->setInputMask(">NNNNN-NNNNN-NNNNN-NNNNN-NNNNN;#");
     352        if (m_pProductKeyLabel)
     353            m_pProductKeyLabel->setBuddy(m_pProductKeyLineEdit);
     354        pAdditionalOptionsContainerLayout->addWidget(m_pProductKeyLineEdit, 0, 1, 1, 2);
     355    }
     356
     357    m_pHostnameLabel = new QLabel;
     358    if (m_pHostnameLabel)
     359    {
     360        m_pHostnameLabel->setAlignment(Qt::AlignRight);
     361        m_pHostnameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     362        pAdditionalOptionsContainerLayout->addWidget(m_pHostnameLabel, 1, 0);
     363    }
     364    m_pHostnameLineEdit = new QLineEdit;
    86365    if (m_pHostnameLineEdit)
    87         return m_pHostnameLineEdit->text();
    88     return QString();
    89 }
    90 
    91 void UIWizardNewVMPageBaseUnattended::setHostname(const QString &strHostName)
    92 {
    93     if (m_pHostnameLineEdit)
    94         return m_pHostnameLineEdit->setText(strHostName);
    95 }
    96 
    97 bool UIWizardNewVMPageBaseUnattended::installGuestAdditions() const
    98 {
    99     if (!m_pGAInstallationISOContainer)
    100         return false;
    101     return m_pGAInstallationISOContainer->isChecked();
    102 }
    103 
    104 void UIWizardNewVMPageBaseUnattended::setInstallGuestAdditions(bool fInstallGA)
    105 {
    106     if (m_pGAInstallationISOContainer)
    107         m_pGAInstallationISOContainer->setChecked(fInstallGA);
    108 }
    109 
    110 QString UIWizardNewVMPageBaseUnattended::guestAdditionsISOPath() const
    111 {
    112     if (!m_pGAISOFilePathSelector)
    113         return QString();
    114     return m_pGAISOFilePathSelector->path();
    115 }
    116 
    117 void UIWizardNewVMPageBaseUnattended::setGuestAdditionsISOPath(const QString &strISOPath)
    118 {
    119     if (m_pGAISOFilePathSelector)
    120         m_pGAISOFilePathSelector->setPath(strISOPath);
    121 }
    122 
    123 QString UIWizardNewVMPageBaseUnattended::productKey() const
    124 {
    125     if (!m_pProductKeyLineEdit || !m_pProductKeyLineEdit->hasAcceptableInput())
    126         return QString();
    127     return m_pProductKeyLineEdit->text();
    128 }
    129 
    130 QWidget *UIWizardNewVMPageBaseUnattended::createGAInstallWidgets()
     366    {
     367        if (m_pHostnameLabel)
     368            m_pHostnameLabel->setBuddy(m_pHostnameLineEdit);
     369        pAdditionalOptionsContainerLayout->addWidget(m_pHostnameLineEdit, 1, 1, 1, 2);
     370    }
     371
     372    m_pStartHeadlessCheckBox = new QCheckBox;
     373    if (m_pStartHeadlessCheckBox)
     374        pAdditionalOptionsContainerLayout->addWidget(m_pStartHeadlessCheckBox, 2, 1);
     375
     376    return m_pAdditionalOptionsContainer;
     377}
     378
     379QWidget *UIWizardNewVMUnattendedPageBasic::createGAInstallWidgets()
    131380{
    132381    if (m_pGAInstallationISOContainer)
     
    170419    return m_pGAInstallationISOContainer;
    171420}
    172 
    173 bool UIWizardNewVMPageBaseUnattended::checkGAISOFile() const
    174 {
    175     if (!m_pGAISOFilePathSelector)
    176         return false;
    177     /* GA ISO selector should not be empty since GA install check box is checked at this point: */
    178     const QString &strPath = m_pGAISOFilePathSelector->path();
    179     if (strPath.isNull() || strPath.isEmpty())
    180         return false;
    181     QFileInfo fileInfo(strPath);
    182     if (!fileInfo.exists() || !fileInfo.isReadable())
    183         return false;
    184     return true;
    185 }
    186 
    187 void UIWizardNewVMPageBaseUnattended::markWidgets() const
    188 {
    189     if (installGuestAdditions())
    190         m_pGAISOFilePathSelector->mark(!checkGAISOFile());
    191 }
    192 
    193 void UIWizardNewVMPageBaseUnattended::retranslateWidgets()
    194 {
    195     if (m_pHostnameLabel)
    196         m_pHostnameLabel->setText(UIWizardNewVM::tr("Hostna&me:"));
    197 
    198     if (m_pGAISOPathLabel)
    199         m_pGAISOPathLabel->setText(UIWizardNewVM::tr("GA I&nstallation ISO:"));
    200     if (m_pGAISOFilePathSelector)
    201         m_pGAISOFilePathSelector->setToolTip(UIWizardNewVM::tr("Please select an installation medium (ISO file)"));
    202     if (m_pGAInstallationISOContainer)
    203     {
    204         m_pGAInstallationISOContainer->setTitle(UIWizardNewVM::tr("Gu&est Additions"));
    205         m_pGAInstallationISOContainer->setToolTip(UIWizardNewVM::tr("<p>When checked the guest additions will be installed "
    206                                                            "after the OS install.</p>"));
    207     }
    208     if (m_pProductKeyLabel)
    209         m_pProductKeyLabel->setText(UIWizardNewVM::tr("&Product Key:"));
    210     if (m_pUserNameContainer)
    211         m_pUserNameContainer->setTitle(UIWizardNewVM::tr("Username and Password"));
    212     if (m_pAdditionalOptionsContainer)
    213         m_pAdditionalOptionsContainer->setTitle(UIWizardNewVM::tr("Additional Options"));
    214     if (m_pStartHeadlessCheckBox)
    215     {
    216         m_pStartHeadlessCheckBox->setText(UIWizardNewVM::tr("&Install in Background"));
    217         m_pStartHeadlessCheckBox->setToolTip(UIWizardNewVM::tr("<p>When checked, the newly created virtual machine will be started "
    218                                                                "in headless mode (without a GUI) for the unattended guest OS install.</p>"));
    219     }
    220 }
    221 
    222 void UIWizardNewVMPageBaseUnattended::disableEnableGAWidgets(bool fEnabled)
    223 {
    224     if (m_pGAISOPathLabel)
    225         m_pGAISOPathLabel->setEnabled(fEnabled);
    226     if (m_pGAISOFilePathSelector)
    227         m_pGAISOFilePathSelector->setEnabled(fEnabled);
    228 }
    229 
    230 void UIWizardNewVMPageBaseUnattended::disableEnableProductKeyWidgets(bool fEnabled)
    231 {
    232     if (m_pProductKeyLabel)
    233         m_pProductKeyLabel->setEnabled(fEnabled);
    234     if (m_pProductKeyLineEdit)
    235         m_pProductKeyLineEdit->setEnabled(fEnabled);
    236 }
    237 
    238 bool UIWizardNewVMPageBaseUnattended::startHeadless() const
    239 {
    240     if (!m_pStartHeadlessCheckBox)
    241         return false;
    242     return m_pStartHeadlessCheckBox->isChecked();
    243 }
    244 
    245 QWidget *UIWizardNewVMPageBaseUnattended::createUserNameWidgets()
    246 {
    247     if (m_pUserNameContainer)
    248         return m_pUserNameContainer;
    249 
    250     m_pUserNameContainer = new QGroupBox;
    251     QVBoxLayout *pUserNameContainerLayout = new QVBoxLayout(m_pUserNameContainer);
    252     m_pUserNamePasswordEditor = new UIUserNamePasswordEditor;
    253     if (m_pUserNamePasswordEditor)
    254     {
    255         m_pUserNamePasswordEditor->setLabelsVisible(true);
    256         pUserNameContainerLayout->addWidget(m_pUserNamePasswordEditor);
    257     }
    258     return m_pUserNameContainer;
    259 }
    260 
    261 QWidget *UIWizardNewVMPageBaseUnattended::createAdditionalOptionsWidgets()
    262 {
    263     if (m_pAdditionalOptionsContainer)
    264         return m_pAdditionalOptionsContainer;
    265 
    266     m_pAdditionalOptionsContainer = new QGroupBox;
    267     QGridLayout *pAdditionalOptionsContainerLayout = new QGridLayout(m_pAdditionalOptionsContainer);
    268     pAdditionalOptionsContainerLayout->setColumnStretch(0, 0);
    269     pAdditionalOptionsContainerLayout->setColumnStretch(1, 1);
    270 
    271     m_pProductKeyLabel = new QLabel;
    272     if (m_pProductKeyLabel)
    273     {
    274         m_pProductKeyLabel->setAlignment(Qt::AlignRight);
    275         m_pProductKeyLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    276         pAdditionalOptionsContainerLayout->addWidget(m_pProductKeyLabel, 0, 0);
    277     }
    278     m_pProductKeyLineEdit = new QLineEdit;
    279     if (m_pProductKeyLineEdit)
    280     {
    281         m_pProductKeyLineEdit->setInputMask(">NNNNN-NNNNN-NNNNN-NNNNN-NNNNN;#");
    282         if (m_pProductKeyLabel)
    283             m_pProductKeyLabel->setBuddy(m_pProductKeyLineEdit);
    284         pAdditionalOptionsContainerLayout->addWidget(m_pProductKeyLineEdit, 0, 1, 1, 2);
    285     }
    286 
    287     m_pHostnameLabel = new QLabel;
    288     if (m_pHostnameLabel)
    289     {
    290         m_pHostnameLabel->setAlignment(Qt::AlignRight);
    291         m_pHostnameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
    292         pAdditionalOptionsContainerLayout->addWidget(m_pHostnameLabel, 1, 0);
    293     }
    294     m_pHostnameLineEdit = new QLineEdit;
    295     if (m_pHostnameLineEdit)
    296     {
    297         if (m_pHostnameLabel)
    298             m_pHostnameLabel->setBuddy(m_pHostnameLineEdit);
    299         pAdditionalOptionsContainerLayout->addWidget(m_pHostnameLineEdit, 1, 1, 1, 2);
    300     }
    301 
    302     m_pStartHeadlessCheckBox = new QCheckBox;
    303     if (m_pStartHeadlessCheckBox)
    304         pAdditionalOptionsContainerLayout->addWidget(m_pStartHeadlessCheckBox, 2, 1);
    305 
    306     return m_pAdditionalOptionsContainer;
    307 }
    308 
    309 bool UIWizardNewVMPageBaseUnattended::isGAInstallEnabled() const
    310 {
    311     if (m_pGAInstallationISOContainer && m_pGAInstallationISOContainer->isChecked())
    312         return true;
    313     return false;
    314 }
    315 
    316 UIWizardNewVMPageUnattended::UIWizardNewVMPageUnattended()
    317     : m_pLabel(0)
    318 {
    319     prepare();
    320 }
    321 
    322 void UIWizardNewVMPageUnattended::prepare()
    323 {
    324     QGridLayout *pMainLayout = new QGridLayout(this);
    325 
    326     m_pLabel = new QIRichTextLabel(this);
    327     if (m_pLabel)
    328         pMainLayout->addWidget(m_pLabel, 0, 0, 1, 2);
    329     pMainLayout->addWidget(createUserNameWidgets(), 1, 0, 1, 1);
    330     pMainLayout->addWidget(createAdditionalOptionsWidgets(), 1, 1, 1, 1);
    331     pMainLayout->addWidget(createGAInstallWidgets(), 2, 0, 1, 2);
    332     pMainLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding), 3, 0, 1, 2);
    333 
    334     registerField("userName", this, "userName");
    335     registerField("password", this, "password");
    336     registerField("hostname", this, "hostname");
    337     registerField("installGuestAdditions", this, "installGuestAdditions");
    338     registerField("guestAdditionsISOPath", this, "guestAdditionsISOPath");
    339     registerField("productKey", this, "productKey");
    340 
    341     createConnections();
    342 }
    343 
    344 void UIWizardNewVMPageUnattended::createConnections()
    345 {
    346     if (m_pUserNamePasswordEditor)
    347         connect(m_pUserNamePasswordEditor, &UIUserNamePasswordEditor::sigSomeTextChanged,
    348                 this, &UIWizardNewVMPageUnattended::completeChanged);
    349     if (m_pGAISOFilePathSelector)
    350         connect(m_pGAISOFilePathSelector, &UIFilePathSelector::pathChanged,
    351                 this, &UIWizardNewVMPageUnattended::sltGAISOPathChanged);
    352     if (m_pGAISOFilePathSelector)
    353         connect(m_pGAInstallationISOContainer, &QGroupBox::toggled,
    354                 this, &UIWizardNewVMPageUnattended::sltInstallGACheckBoxToggle);
    355 }
    356 
    357 
    358 void UIWizardNewVMPageUnattended::retranslateUi()
    359 {
    360     setTitle(UIWizardNewVM::tr("Unattended Guest OS Install Setup"));
    361     if (m_pLabel)
    362         m_pLabel->setText(UIWizardNewVM::tr("<p>You can configure the unattended guest OS install by modifying username, password, and "
    363                                             "hostname. Additionally you can enable guest additions install. "
    364                                             "For Microsoft Windows guests it is possible to provide a product key.</p>"));
    365     retranslateWidgets();
    366 }
    367 
    368 void UIWizardNewVMPageUnattended::initializePage()
    369 {
    370     disableEnableProductKeyWidgets(isProductKeyWidgetEnabled());
    371     disableEnableGAWidgets(m_pGAInstallationISOContainer ? m_pGAInstallationISOContainer->isChecked() : false);
    372     retranslateUi();
    373 }
    374 
    375 bool UIWizardNewVMPageUnattended::isComplete() const
    376 {
    377     markWidgets();
    378     if (isGAInstallEnabled() && !checkGAISOFile())
    379         return false;
    380 //     bool fIsComplete = true;
    381 //     if (!checkGAISOFile())
    382 //     {
    383 //         m_pToolBox->setItemIcon(ToolBoxItems_GAInstall, UIIconPool::iconSet(":/status_error_16px.png"));
    384 //         fIsComplete = false;
    385 //     }
    386     if (m_pUserNamePasswordEditor && !m_pUserNamePasswordEditor->isComplete())
    387         return false;
    388 //     {
    389 //         m_pToolBox->setItemIcon(ToolBoxItems_UserNameHostname, UIIconPool::iconSet(":/status_error_16px.png"));
    390 //         fIsComplete = false;
    391 //     }
    392 //     return fIsComplete;
    393     return true;
    394 }
    395 
    396 void UIWizardNewVMPageUnattended::cleanupPage()
    397 {
    398 }
    399 
    400 void UIWizardNewVMPageUnattended::showEvent(QShowEvent *pEvent)
    401 {
    402     // if (m_pToolBox)
    403     //     m_pToolBox->setItemEnabled(ToolBoxItems_ProductKey, isProductKeyWidgetEnabled());
    404     UIWizardPage::showEvent(pEvent);
    405 }
    406 
    407 void UIWizardNewVMPageUnattended::sltInstallGACheckBoxToggle(bool fEnabled)
    408 {
    409     disableEnableGAWidgets(fEnabled);
    410     emit completeChanged();
    411 }
    412 
    413 void UIWizardNewVMPageUnattended::sltGAISOPathChanged(const QString &strPath)
    414 {
    415     Q_UNUSED(strPath);
    416     emit completeChanged();
    417 }
    418 
    419 bool UIWizardNewVMPageUnattended::isProductKeyWidgetEnabled() const
    420 {
    421     UIWizardNewVM *pWizard = qobject_cast<UIWizardNewVM*>(wizard());
    422     if (!pWizard || !pWizard->isUnattendedEnabled() || !pWizard->isGuestOSTypeWindows())
    423         return false;
    424     return true;
    425 }
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMUnattendedPageBasic.h

    r90002 r90003  
    11/* $Id$ */
    22/** @file
    3  * VBox Qt GUI - UIWizardNewVMPageUnattended class declaration.
     3 * VBox Qt GUI - UIWizardNewVMUnattendedPageBasic class declaration.
    44 */
    55
     
    1616 */
    1717
    18 #ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageUnattended_h
    19 #define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageUnattended_h
     18#ifndef FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMUnattendedPageBasic_h
     19#define FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMUnattendedPageBasic_h
    2020#ifndef RT_WITHOUT_PRAGMA_ONCE
    2121# pragma once
     
    2424/* Local includes: */
    2525#include "QIWithRetranslateUI.h"
    26 #include "UIWizardPage.h"
     26#include "UINativeWizardPage.h"
    2727
    2828/* Forward declarations: */
     
    3939
    4040
    41 class UIWizardNewVMPageBaseUnattended : public UIWizardPageBase
     41// class UIWizardNewVMUnattendedPage : public UIWizardPageBase
     42// {
     43// public:
     44
     45//     UIWizardNewVMUnattendedPage();
     46
     47//     /** @name Property getters/setters
     48//       * @{ */
     49//         QString userName() const;
     50//         void setUserName(const QString &strName);
     51//         QString password() const;
     52//         void setPassword(const QString &strPassword);
     53//         QString hostname() const;
     54//         void setHostname(const QString &strHostName);
     55//         bool installGuestAdditions() const;
     56//         void setInstallGuestAdditions(bool fInstallGA);
     57//         QString guestAdditionsISOPath() const;
     58//         void setGuestAdditionsISOPath(const QString &strISOPath);
     59//         QString productKey() const;
     60//     /** @} */
     61
     62// protected:
     63//     enum
     64//     {
     65//         ToolBoxItems_UserNameHostname,
     66//         ToolBoxItems_GAInstall,
     67//         ToolBoxItems_ProductKey
     68//     };
     69
     70
     71//     /** Returns false if ISO path selector is non empty but has invalid file path. */
     72//     bool checkGAISOFile() const;
     73//     void markWidgets() const;
     74//     void retranslateWidgets();
     75//     void disableEnableGAWidgets(bool fEnabled);
     76//     void disableEnableProductKeyWidgets(bool fEnabled);
     77
     78//     bool startHeadless() const;
     79
     80//     bool isGAInstallEnabled() const;
     81
     82
     83// private:
     84
     85//     friend class UIWizardNewVM;
     86// };
     87
     88class UIWizardNewVMUnattendedPageBasic : public UINativeWizardPage
    4289{
     90    Q_OBJECT;
     91
    4392public:
    4493
    45     UIWizardNewVMPageBaseUnattended();
    46 
    47     /** @name Property getters/setters
    48       * @{ */
    49         QString userName() const;
    50         void setUserName(const QString &strName);
    51         QString password() const;
    52         void setPassword(const QString &strPassword);
    53         QString hostname() const;
    54         void setHostname(const QString &strHostName);
    55         bool installGuestAdditions() const;
    56         void setInstallGuestAdditions(bool fInstallGA);
    57         QString guestAdditionsISOPath() const;
    58         void setGuestAdditionsISOPath(const QString &strISOPath);
    59         QString productKey() const;
    60     /** @} */
     94    UIWizardNewVMUnattendedPageBasic();
    6195
    6296protected:
    63     enum
    64     {
    65         ToolBoxItems_UserNameHostname,
    66         ToolBoxItems_GAInstall,
    67         ToolBoxItems_ProductKey
    68     };
    6997
     98    virtual void showEvent(QShowEvent *pEvent) /* override */;
     99    /** Don't reset the user entered values in case of "back" button press. */
     100    virtual void cleanupPage() /* override */;
     101
     102private slots:
     103
     104    void sltInstallGACheckBoxToggle(bool fChecked);
     105    void sltGAISOPathChanged(const QString &strPath);
     106
     107private:
     108
     109    void prepare();
     110    void createConnections();
     111    QWidget *createUserNameWidgets();
     112    QWidget *createAdditionalOptionsWidgets();
    70113    QWidget *createGAInstallWidgets();
    71114
    72     /** Returns false if ISO path selector is non empty but has invalid file path. */
    73     bool checkGAISOFile() const;
    74     void markWidgets() const;
    75     void retranslateWidgets();
    76     void disableEnableGAWidgets(bool fEnabled);
    77     void disableEnableProductKeyWidgets(bool fEnabled);
     115    void retranslateUi();
     116    void initializePage();
     117    bool isComplete() const;
     118    /** Returns true if we show the widgets for guest os product key. */
     119    bool isProductKeyWidgetEnabled() const;
    78120
    79     bool startHeadless() const;
    80 
    81     QWidget *createUserNameWidgets();
    82     QWidget *createAdditionalOptionsWidgets();
    83     bool isGAInstallEnabled() const;
     121    QIRichTextLabel *m_pLabel;
    84122
    85123    /** @name Widgets
     
    99137    /** @} */
    100138
    101 private:
    102 
    103     friend class UIWizardNewVM;
    104139};
    105140
    106 class UIWizardNewVMPageUnattended : public UIWizardPage, public UIWizardNewVMPageBaseUnattended
    107 {
    108     Q_OBJECT;
    109     Q_PROPERTY(QString userName READ userName WRITE setUserName);
    110     Q_PROPERTY(QString password READ password WRITE setPassword);
    111     Q_PROPERTY(QString hostname READ hostname WRITE setHostname);
    112     Q_PROPERTY(bool installGuestAdditions READ installGuestAdditions WRITE setInstallGuestAdditions);
    113     Q_PROPERTY(QString guestAdditionsISOPath READ guestAdditionsISOPath WRITE setGuestAdditionsISOPath);
    114     Q_PROPERTY(QString productKey READ productKey);
    115     Q_PROPERTY(bool startHeadless READ startHeadless);
    116 
    117 public:
    118 
    119     UIWizardNewVMPageUnattended();
    120 
    121 protected:
    122 
    123     virtual void showEvent(QShowEvent *pEvent) /* override */;
    124     /** Don't reset the user entered values in case of "back" button press. */
    125     virtual void cleanupPage() /* override */;
    126 
    127 private slots:
    128 
    129     void sltInstallGACheckBoxToggle(bool fChecked);
    130     void sltGAISOPathChanged(const QString &strPath);
    131 
    132 private:
    133 
    134     void prepare();
    135     void createConnections();
    136     void retranslateUi();
    137     void initializePage();
    138     bool isComplete() const;
    139     /** Returns true if we show the widgets for guest os product key. */
    140     bool isProductKeyWidgetEnabled() const;
    141 
    142     QIRichTextLabel *m_pLabel;
    143 };
    144 
    145 #endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMPageUnattended_h */
     141#endif /* !FEQT_INCLUDED_SRC_wizards_newvm_UIWizardNewVMUnattendedPageBasic_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