Пример #1
0
 void CSimulator::InitMedia(TConfigurationNode& t_tree) {
    try {
       /* Cycle through the media */
       TConfigurationNodeIterator itMedia;
       for(itMedia = itMedia.begin(&t_tree);
           itMedia != itMedia.end();
           ++itMedia) {
          /* Create the  medium */
          CMedium* pcMedium = CFactory<CMedium>::New(itMedia->Value());
          try {
             /* Initialize the medium */
             pcMedium->Init(*itMedia);
             /* Check that an medium with that ID does not exist yet */
             if(m_mapMedia.find(pcMedium->GetId()) == m_mapMedia.end()) {
                /* Add it to the lists */
                m_mapMedia[pcMedium->GetId()] = pcMedium;
                m_vecMedia.push_back(pcMedium);
             }
             else {
                /* Duplicate id -> error */
                THROW_ARGOSEXCEPTION("A medium with id \"" << pcMedium->GetId() << "\" exists already. The ids must be unique!");
             }
          }
          catch(CARGoSException& ex) {
             /* Error while executing medium init, destroy what done to prevent memory leaks */
             pcMedium->Destroy();
             delete pcMedium;
             THROW_ARGOSEXCEPTION_NESTED("Error initializing medium type \"" << itMedia->Value() << "\"", ex);
          }
       }
    }
    catch(CARGoSException& ex) {
       THROW_ARGOSEXCEPTION_NESTED("Failed to initialize the media. Parse error in the <media> subtree.", ex);
    }
 }
Пример #2
0
    /* Insert hard-disks to the passed uimedium map.
     * Get existing one from the previous map if any. */
    foreach (CMedium medium, inputMediums)
    {
        /* If VBoxGlobal is cleaning up, abort immediately: */
        if (vboxGlobal().isCleaningUp())
            break;

        /* Prepare uimedium on the basis of current medium: */
        QString strMediumID = medium.GetId();
        UIMedium uimedium = m_mediums.contains(strMediumID) ? m_mediums[strMediumID] :
                                                              UIMedium(medium, mediumType);

        /* Insert uimedium into map: */
        outputMediums.insert(uimedium.id(), uimedium);
    }
Пример #3
0
UIWizardCloneVDPageBasic1::UIWizardCloneVDPageBasic1(const CMedium &sourceVirtualDisk)
{
    /* Create widgets: */
    QVBoxLayout *pMainLayout = new QVBoxLayout(this);
    {
        m_pLabel = new QIRichTextLabel(this);
        QHBoxLayout *pSourceDiskLayout = new QHBoxLayout;
        {
            m_pSourceDiskSelector = new VBoxMediaComboBox(this);
            {
                m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
                m_pSourceDiskSelector->setType(UIMediumType_HardDisk);
                m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());
                m_pSourceDiskSelector->repopulate();
            }
            m_pSourceDiskOpenButton = new QIToolButton(this);
            {
                m_pSourceDiskOpenButton->setAutoRaise(true);
                m_pSourceDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_disabled_16px.png"));
            }
            pSourceDiskLayout->addWidget(m_pSourceDiskSelector);
            pSourceDiskLayout->addWidget(m_pSourceDiskOpenButton);
        }
        pMainLayout->addWidget(m_pLabel);
        pMainLayout->addLayout(pSourceDiskLayout);
        pMainLayout->addStretch();
    }

    /* Setup connections: */
    connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SIGNAL(completeChanged()));
    connect(m_pSourceDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick()));

    /* Register classes: */
    qRegisterMetaType<CMedium>();
    /* Register fields: */
    registerField("sourceVirtualDisk", this, "sourceVirtualDisk");
}
Пример #4
0
void UIWizardCloneVDPage1::setSourceVirtualDisk(const CMedium &sourceVirtualDisk)
{
    m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());
}
UIWizardCloneVDPageExpert::UIWizardCloneVDPageExpert(const CMedium &sourceVirtualDisk)
{
    /* Create widgets: */
    QGridLayout *pMainLayout = new QGridLayout(this);
    {
        pMainLayout->setContentsMargins(8, 6, 8, 6);
        pMainLayout->setSpacing(10);
        m_pSourceDiskCnt = new QGroupBox(this);
        {
            m_pSourceDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
            QHBoxLayout *pSourceDiskCntLayout = new QHBoxLayout(m_pSourceDiskCnt);
            {
                m_pSourceDiskSelector = new VBoxMediaComboBox(m_pSourceDiskCnt);
                {
                    m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
                    m_pSourceDiskSelector->setType(UIMediumType_HardDisk);
                    m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());
                    m_pSourceDiskSelector->repopulate();
                }
                m_pSourceDiskOpenButton = new QIToolButton(m_pSourceDiskCnt);
                {
                    m_pSourceDiskOpenButton->setAutoRaise(true);
                    m_pSourceDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_disabled_16px.png"));
                }
                pSourceDiskCntLayout->addWidget(m_pSourceDiskSelector);
                pSourceDiskCntLayout->addWidget(m_pSourceDiskOpenButton);
            }
        }
        m_pDestinationCnt = new QGroupBox(this);
        {
            m_pDestinationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
            QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pDestinationCnt);
            {
                m_pDestinationDiskEditor = new QLineEdit(m_pDestinationCnt);
                m_pDestinationDiskOpenButton = new QIToolButton(m_pDestinationCnt);
                {
                    m_pDestinationDiskOpenButton->setAutoRaise(true);
                    m_pDestinationDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_disabled_16px.png"));
                }
            }
            pLocationCntLayout->addWidget(m_pDestinationDiskEditor);
            pLocationCntLayout->addWidget(m_pDestinationDiskOpenButton);
        }
        m_pFormatCnt = new QGroupBox(this);
        {
            m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
            QVBoxLayout *pFormatCntLayout = new QVBoxLayout(m_pFormatCnt);
            {
                m_pFormatButtonGroup = new QButtonGroup(m_pFormatCnt);
                {
                    /* Enumerate medium formats in special order: */
                    CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties();
                    const QVector<CMediumFormat> &formats = properties.GetMediumFormats();
                    QMap<QString, CMediumFormat> vdi, preferred, others;
                    foreach (const CMediumFormat &format, formats)
                    {
                        /* VDI goes first: */
                        if (format.GetName() == "VDI")
                            vdi[format.GetId()] = format;
                        else
                        {
                            const QVector<KMediumFormatCapabilities> &capabilities = format.GetCapabilities();
                            /* Then goes preferred: */
                            if (capabilities.contains(KMediumFormatCapabilities_Preferred))
                                preferred[format.GetId()] = format;
                            /* Then others: */
                            else
                                others[format.GetId()] = format;
                        }
                    }

                    /* Create buttons for VDI, preferred and others: */
                    foreach (const QString &strId, vdi.keys())
                        addFormatButton(this, pFormatCntLayout, vdi.value(strId), true);
                    foreach (const QString &strId, preferred.keys())
                        addFormatButton(this, pFormatCntLayout, preferred.value(strId), true);
                    foreach (const QString &strId, others.keys())
                        addFormatButton(this, pFormatCntLayout, others.value(strId));

                    if (!m_pFormatButtonGroup->buttons().isEmpty())
                    {
                        m_pFormatButtonGroup->button(0)->click();
                        m_pFormatButtonGroup->button(0)->setFocus();
                    }
                }
            }
        }
        m_pVariantCnt = new QGroupBox(this);
        {
            m_pVariantCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
            QVBoxLayout *pVariantCntLayout = new QVBoxLayout(m_pVariantCnt);
            {
                m_pVariantButtonGroup = new QButtonGroup(m_pVariantCnt);
                {
                    m_pDynamicalButton = new QRadioButton(m_pVariantCnt);
                    {
                        m_pDynamicalButton->click();
                        m_pDynamicalButton->setFocus();
                    }
                    m_pFixedButton = new QRadioButton(m_pVariantCnt);
                    m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
                    m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
                }
                m_pSplitBox = new QCheckBox(m_pVariantCnt);
                pVariantCntLayout->addWidget(m_pDynamicalButton);
                pVariantCntLayout->addWidget(m_pFixedButton);
                pVariantCntLayout->addWidget(m_pSplitBox);
            }
        }
        pMainLayout->addWidget(m_pSourceDiskCnt, 0, 0, 1, 2);
        pMainLayout->addWidget(m_pDestinationCnt, 1, 0, 1, 2);
        pMainLayout->addWidget(m_pFormatCnt, 2, 0, Qt::AlignTop);
        pMainLayout->addWidget(m_pVariantCnt, 2, 1, Qt::AlignTop);
        sltHandleSourceDiskChange();
        sltMediumFormatChanged();
    }

    /* Setup connections: */
    connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(sltHandleSourceDiskChange()));
    connect(m_pSourceDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick()));
    connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(sltMediumFormatChanged()));
    connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged()));
    connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged()));
    connect(m_pDestinationDiskEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
    connect(m_pDestinationDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked()));

    /* Register classes: */
    qRegisterMetaType<CMedium>();
    qRegisterMetaType<CMediumFormat>();
    /* Register fields: */
    registerField("sourceVirtualDisk", this, "sourceVirtualDisk");
    registerField("mediumFormat", this, "mediumFormat");
    registerField("mediumVariant", this, "mediumVariant");
    registerField("mediumPath", this, "mediumPath");
    registerField("mediumSize", this, "mediumSize");
}
Пример #6
0
void UIMedium::refresh()
{
    /* Reset ID parameters: */
    m_strId = nullID();
    m_strRootId = nullID();
    m_strParentId = nullID();

    /* Reset cache parameters: */
    //m_strKey = nullID();

    /* Reset name/location/size parameters: */
    m_strName = VBoxGlobal::tr("Empty", "medium");
    m_strLocation = m_strSize = m_strLogicalSize = QString("--");

    /* Reset hard drive related parameters: */
    m_strHardDiskType = QString();
    m_strHardDiskFormat = QString();
    m_strStorageDetails = QString();
    m_strEncryptionPasswordID = QString();

    /* Reset data parameters: */
    m_strUsage = QString();
    m_strToolTip = QString();
    m_machineIds.clear();
    m_curStateMachineIds.clear();

    /* Reset m_noDiffs: */
    m_noDiffs.isSet = false;

    /* Reset flags: */
    m_fHidden = false;
    m_fUsedByHiddenMachinesOnly = false;
    m_fReadOnly = false;
    m_fUsedInSnapshots = false;
    m_fHostDrive = false;
    m_fEncrypted = false;

    /* For non NULL medium: */
    if (!m_medium.isNull())
    {
        /* Refresh medium ID: */
        m_strId = normalizedID(m_medium.GetId());
        /* Refresh root medium ID: */
        m_strRootId = m_strId;

        /* Init medium key if necessary: */
        if (m_strKey.isNull())
            m_strKey = m_strId;

        /* Check whether this is host-drive medium: */
        m_fHostDrive = m_medium.GetHostDrive();

        /* Refresh medium name: */
        if (!m_fHostDrive)
            m_strName = m_medium.GetName();
        else if (m_medium.GetDescription().isEmpty())
            m_strName = VBoxGlobal::tr("Host Drive '%1'", "medium").arg(QDir::toNativeSeparators(m_medium.GetLocation()));
        else
            m_strName = VBoxGlobal::tr("Host Drive %1 (%2)", "medium").arg(m_medium.GetDescription(), m_medium.GetName());
        /* Refresh medium location: */
        if (!m_fHostDrive)
            m_strLocation = QDir::toNativeSeparators(m_medium.GetLocation());

        /* Refresh medium size and logical size: */
        if (!m_fHostDrive)
        {
            /* Only for created and accessible mediums: */
            if (m_state != KMediumState_Inaccessible && m_state != KMediumState_NotCreated)
            {
                m_strSize = vboxGlobal().formatSize(m_medium.GetSize());
                if (m_type == UIMediumType_HardDisk)
                    m_strLogicalSize = vboxGlobal().formatSize(m_medium.GetLogicalSize());
                else
                    m_strLogicalSize = m_strSize;
            }
        }

        /* For hard drive medium: */
        if (m_type == UIMediumType_HardDisk)
        {
            /* Refresh hard drive disk type: */
            m_strHardDiskType = vboxGlobal().mediumTypeString(m_medium);
            /* Refresh hard drive format: */
            m_strHardDiskFormat = m_medium.GetFormat();

            /* Refresh hard drive storage details: */
            qlonglong iMediumVariant = 0;
            foreach (const KMediumVariant &enmVariant, m_medium.GetVariant())
                iMediumVariant |= enmVariant;
            m_strStorageDetails = gpConverter->toString((KMediumVariant)iMediumVariant);

            /* Check whether this is read-only hard drive: */
            m_fReadOnly = m_medium.GetReadOnly();

            /* Refresh parent hard drive ID: */
            CMedium parentMedium = m_medium.GetParent();
            if (!parentMedium.isNull())
                m_strParentId = normalizedID(parentMedium.GetId());

            /* Only for created and accessible mediums: */
            if (m_state != KMediumState_Inaccessible && m_state != KMediumState_NotCreated)
            {
                /* Refresh root hard drive ID: */
                while (!parentMedium.isNull())
                {
                    m_strRootId = normalizedID(parentMedium.GetId());
                    parentMedium = parentMedium.GetParent();
                }

                /* Refresh encryption attributes: */
                if (m_strRootId != m_strId)
                {
                    m_strEncryptionPasswordID = root().encryptionPasswordID();
                    m_fEncrypted = root().isEncrypted();
                }
                else
                {
                    QString strCipher;
                    CMedium medium(m_medium);
                    const QString strEncryptionPasswordID = medium.GetEncryptionSettings(strCipher);
                    if (medium.isOk())
                    {
                        m_strEncryptionPasswordID = strEncryptionPasswordID;
                        m_fEncrypted = true;
                    }
                }
            }
        }
void UIMachineSettingsGeneral::loadToCacheFrom(QVariant &data)
{
    /* Fetch data to machine: */
    UISettingsPageMachine::fetchData(data);

    /* Clear cache initially: */
    m_cache.clear();

    /* Prepare general data: */
    UIDataSettingsMachineGeneral generalData;

    /* 'Basic' tab data: */
    generalData.m_strName = m_machine.GetName();
    generalData.m_strGuestOsTypeId = m_machine.GetOSTypeId();

    /* 'Advanced' tab data: */
    generalData.m_strSnapshotsFolder = m_machine.GetSnapshotFolder();
    generalData.m_strSnapshotsHomeDir = QFileInfo(m_machine.GetSettingsFilePath()).absolutePath();
    generalData.m_clipboardMode = m_machine.GetClipboardMode();
    generalData.m_dndMode = m_machine.GetDnDMode();

    /* 'Description' tab data: */
    generalData.m_strDescription = m_machine.GetDescription();

    /* 'Encryption' tab data: */
    QString strCipher;
    bool fEncryptionCipherCommon = true;
    /* Prepare the map of the encrypted mediums: */
    EncryptedMediumMap encryptedMediums;
    foreach (const CMediumAttachment &attachment, m_machine.GetMediumAttachments())
    {
        /* Acquire hard-drive attachments only: */
        if (attachment.GetType() == KDeviceType_HardDisk)
        {
            /* Get the attachment medium base: */
            const CMedium medium = attachment.GetMedium();
            /* Check medium encryption attributes: */
            QString strCurrentCipher;
            const QString strCurrentPasswordId = medium.GetEncryptionSettings(strCurrentCipher);
            if (medium.isOk())
            {
                encryptedMediums.insert(strCurrentPasswordId, medium.GetId());
                if (strCurrentCipher != strCipher)
                {
                    if (strCipher.isNull())
                        strCipher = strCurrentCipher;
                    else
                        fEncryptionCipherCommon = false;
                }
            }
        }
    }
    generalData.m_fEncryptionEnabled = !encryptedMediums.isEmpty();
    generalData.m_fEncryptionCipherChanged = false;
    generalData.m_fEncryptionPasswordChanged = false;
    if (fEncryptionCipherCommon)
        generalData.m_iEncryptionCipherIndex = m_encryptionCiphers.indexOf(strCipher);
    if (generalData.m_iEncryptionCipherIndex == -1)
        generalData.m_iEncryptionCipherIndex = 0;
    generalData.m_encryptedMediums = encryptedMediums;

    /* Cache general data: */
    m_cache.cacheInitialData(generalData);

    /* Upload machine to data: */
    UISettingsPageMachine::uploadData(data);
}
void UIMachineSettingsGeneral::saveFromCacheTo(QVariant &data)
{
    /* Fetch data to machine: */
    UISettingsPageMachine::fetchData(data);

    /* Check if general data was changed: */
    if (m_cache.wasChanged())
    {
        /* Get general data from cache: */
        const UIDataSettingsMachineGeneral &generalData = m_cache.data();

        if (isMachineInValidMode())
        {
            /* 'Advanced' tab data: */
            if (generalData.m_clipboardMode != m_cache.base().m_clipboardMode)
                m_machine.SetClipboardMode(generalData.m_clipboardMode);
            if (generalData.m_dndMode != m_cache.base().m_dndMode)
                m_machine.SetDnDMode(generalData.m_dndMode);

            /* 'Description' tab: */
            if (generalData.m_strDescription != m_cache.base().m_strDescription)
                m_machine.SetDescription(generalData.m_strDescription);
        }

        if (isMachineOffline())
        {
            /* 'Basic' tab data: Must update long mode CPU feature bit when os type changes. */
            if (generalData.m_strGuestOsTypeId != m_cache.base().m_strGuestOsTypeId)
            {
                m_machine.SetOSTypeId(generalData.m_strGuestOsTypeId);
                CVirtualBox vbox = vboxGlobal().virtualBox();
                CGuestOSType newType = vbox.GetGuestOSType(generalData.m_strGuestOsTypeId);
                m_machine.SetCPUProperty(KCPUPropertyType_LongMode, newType.GetIs64Bit());
            }

            /* 'Advanced' tab data: */
            if (generalData.m_strSnapshotsFolder != m_cache.base().m_strSnapshotsFolder)
                m_machine.SetSnapshotFolder(generalData.m_strSnapshotsFolder);

            /* 'Basic' (again) tab data: */
            /* VM name must be last as otherwise its VM rename magic
             * can collide with other settings in the config,
             * especially with the snapshot folder: */
            if (generalData.m_strName != m_cache.base().m_strName)
                m_machine.SetName(generalData.m_strName);

            /* Encryption tab data: */
            if (generalData.m_fEncryptionEnabled != m_cache.base().m_fEncryptionEnabled ||
                generalData.m_fEncryptionCipherChanged != m_cache.base().m_fEncryptionCipherChanged ||
                generalData.m_fEncryptionPasswordChanged != m_cache.base().m_fEncryptionPasswordChanged)
            {
                /* Cipher attribute changed? */
                QString strNewCipher;
                if (generalData.m_fEncryptionCipherChanged)
                {
                    strNewCipher = generalData.m_fEncryptionEnabled ?
                                   m_encryptionCiphers.at(generalData.m_iEncryptionCipherIndex) : QString();
                }
                /* Password attribute changed? */
                QString strNewPassword;
                QString strNewPasswordId;
                if (generalData.m_fEncryptionPasswordChanged)
                {
                    strNewPassword = generalData.m_fEncryptionEnabled ?
                                     generalData.m_strEncryptionPassword : QString();
                    strNewPasswordId = generalData.m_fEncryptionEnabled ?
                                       m_machine.GetName() : QString();
                }

                /* Get the maps of encrypted mediums and their passwords: */
                const EncryptedMediumMap &encryptedMedium = generalData.m_encryptedMediums;
                const EncryptionPasswordMap &encryptionPasswords = generalData.m_encryptionPasswords;
                /* Enumerate attachments: */
                foreach (const CMediumAttachment &attachment, m_machine.GetMediumAttachments())
                {
                    /* Enumerate hard-drives only: */
                    if (attachment.GetType() == KDeviceType_HardDisk)
                    {
                        /* Get corresponding medium: */
                        CMedium medium = attachment.GetMedium();

                        /* Check if old password exists/provided: */
                        QString strOldPasswordId = encryptedMedium.key(medium.GetId());
                        QString strOldPassword = encryptionPasswords.value(strOldPasswordId);

                        /* Update encryption: */
                        CProgress cprogress = medium.ChangeEncryption(strOldPassword,
                                                                      strNewCipher,
                                                                      strNewPassword,
                                                                      strNewPasswordId);
                        if (!medium.isOk())
                        {
                            QMetaObject::invokeMethod(this, "sigOperationProgressError", Qt::BlockingQueuedConnection,
                                                      Q_ARG(QString, UIMessageCenter::formatErrorInfo(medium)));
                            continue;
                        }
                        UIProgress uiprogress(cprogress);
                        connect(&uiprogress, SIGNAL(sigProgressChange(ulong, QString, ulong, ulong)),
                                this, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)),
                                Qt::QueuedConnection);
                        connect(&uiprogress, SIGNAL(sigProgressError(QString)),
                                this, SIGNAL(sigOperationProgressError(QString)),
                                Qt::BlockingQueuedConnection);
                        uiprogress.run(350);
                    }
                }
            }
        }
    }
UIWizardCloneVDPageExpert::UIWizardCloneVDPageExpert(const CMedium &sourceVirtualDisk)
{
    /* Create widgets: */
    QGridLayout *pMainLayout = new QGridLayout(this);
    {
        pMainLayout->setContentsMargins(8, 6, 8, 6);
        pMainLayout->setSpacing(10);
        m_pSourceDiskCnt = new QGroupBox(this);
        {
            m_pSourceDiskCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
            QHBoxLayout *pSourceDiskCntLayout = new QHBoxLayout(m_pSourceDiskCnt);
            {
                m_pSourceDiskSelector = new VBoxMediaComboBox(m_pSourceDiskCnt);
                {
                    m_pSourceDiskSelector->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
                    m_pSourceDiskSelector->setType(UIMediumType_HardDisk);
                    m_pSourceDiskSelector->setCurrentItem(sourceVirtualDisk.GetId());
                    m_pSourceDiskSelector->repopulate();
                }
                m_pSourceDiskOpenButton = new QIToolButton(m_pSourceDiskCnt);
                {
                    m_pSourceDiskOpenButton->setAutoRaise(true);
                    m_pSourceDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", ":/select_file_disabled_16px.png"));
                }
                pSourceDiskCntLayout->addWidget(m_pSourceDiskSelector);
                pSourceDiskCntLayout->addWidget(m_pSourceDiskOpenButton);
            }
        }
        m_pDestinationCnt = new QGroupBox(this);
        {
            m_pDestinationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
            QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pDestinationCnt);
            {
                m_pDestinationDiskEditor = new QLineEdit(m_pDestinationCnt);
                m_pDestinationDiskOpenButton = new QIToolButton(m_pDestinationCnt);
                {
                    m_pDestinationDiskOpenButton->setAutoRaise(true);
                    m_pDestinationDiskOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_disabled_16px.png"));
                }
            }
            pLocationCntLayout->addWidget(m_pDestinationDiskEditor);
            pLocationCntLayout->addWidget(m_pDestinationDiskOpenButton);
        }
        m_pFormatCnt = new QGroupBox(this);
        {
            m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
            QVBoxLayout *pFormatCntLayout = new QVBoxLayout(m_pFormatCnt);
            {
                m_pFormatButtonGroup = new QButtonGroup(this);
                {
                    CSystemProperties systemProperties = vboxGlobal().virtualBox().GetSystemProperties();
                    const QVector<CMediumFormat> &medFormats = systemProperties.GetMediumFormats();
                    for (int i = 0; i < medFormats.size(); ++i)
                    {
                        const CMediumFormat &medFormat = medFormats[i];
                        if (medFormat.GetName() == "VDI")
                            addFormatButton(m_pFormatCnt, pFormatCntLayout, medFormat);
                    }
                    for (int i = 0; i < medFormats.size(); ++i)
                    {
                        const CMediumFormat &medFormat = medFormats[i];
                        if (medFormat.GetName() != "VDI")
                            addFormatButton(m_pFormatCnt, pFormatCntLayout, medFormat);
                    }
                    if (!m_pFormatButtonGroup->buttons().isEmpty())
                    {
                        m_pFormatButtonGroup->button(0)->click();
                        m_pFormatButtonGroup->button(0)->setFocus();
                    }
                }
            }
        }
        m_pVariantCnt = new QGroupBox(this);
        {
            m_pVariantCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
            QVBoxLayout *pVariantCntLayout = new QVBoxLayout(m_pVariantCnt);
            {
                m_pVariantButtonGroup = new QButtonGroup(m_pVariantCnt);
                {
                    m_pDynamicalButton = new QRadioButton(m_pVariantCnt);
                    {
                        m_pDynamicalButton->click();
                        m_pDynamicalButton->setFocus();
                    }
                    m_pFixedButton = new QRadioButton(m_pVariantCnt);
                    m_pVariantButtonGroup->addButton(m_pDynamicalButton, 0);
                    m_pVariantButtonGroup->addButton(m_pFixedButton, 1);
                }
                m_pSplitBox = new QCheckBox(m_pVariantCnt);
                pVariantCntLayout->addWidget(m_pDynamicalButton);
                pVariantCntLayout->addWidget(m_pFixedButton);
                pVariantCntLayout->addWidget(m_pSplitBox);
            }
        }
        pMainLayout->addWidget(m_pSourceDiskCnt, 0, 0, 1, 2);
        pMainLayout->addWidget(m_pDestinationCnt, 1, 0, 1, 2);
        pMainLayout->addWidget(m_pFormatCnt, 2, 0, Qt::AlignTop);
        pMainLayout->addWidget(m_pVariantCnt, 2, 1, Qt::AlignTop);
        sltHandleSourceDiskChange();
        sltMediumFormatChanged();
    }

    /* Setup connections: */
    connect(m_pSourceDiskSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(sltHandleSourceDiskChange()));
    connect(m_pSourceDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltHandleOpenSourceDiskClick()));
    connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(sltMediumFormatChanged()));
    connect(m_pVariantButtonGroup, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(completeChanged()));
    connect(m_pSplitBox, SIGNAL(stateChanged(int)), this, SIGNAL(completeChanged()));
    connect(m_pDestinationDiskEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged()));
    connect(m_pDestinationDiskOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked()));

    /* Register classes: */
    qRegisterMetaType<CMedium>();
    qRegisterMetaType<CMediumFormat>();
    /* Register fields: */
    registerField("sourceVirtualDisk", this, "sourceVirtualDisk");
    registerField("mediumFormat", this, "mediumFormat");
    registerField("mediumVariant", this, "mediumVariant");
    registerField("mediumPath", this, "mediumPath");
    registerField("mediumSize", this, "mediumSize");
}