QVector<CMediumFormat> UIMediumDefs::getFormatsForDeviceType(KDeviceType enmDeviceType) { CSystemProperties comSystemProperties = vboxGlobal().virtualBox().GetSystemProperties(); QVector<CMediumFormat> mediumFormats = comSystemProperties.GetMediumFormats(); QVector<CMediumFormat> formatList; for (int i = 0; i < mediumFormats.size(); ++i) { /* File extensions */ QVector <QString> fileExtensions; QVector <KDeviceType> deviceTypes; mediumFormats[i].DescribeFileExtensions(fileExtensions, deviceTypes); if (deviceTypes.contains(enmDeviceType)) formatList.push_back(mediumFormats[i]); } return formatList; }
UIWizardNewVDPageBasic1::UIWizardNewVDPageBasic1() { /* Create widgets: */ QVBoxLayout *pMainLayout = new QVBoxLayout(this); { m_pLabel = new QIRichTextLabel(this); QVBoxLayout *pFormatLayout = new QVBoxLayout; { 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(this, pFormatLayout, medFormat); } for (int i = 0; i < medFormats.size(); ++i) { const CMediumFormat &medFormat = medFormats[i]; if (medFormat.GetName() != "VDI") addFormatButton(this, pFormatLayout, medFormat); } } if (!m_pFormatButtonGroup->buttons().isEmpty()) { m_pFormatButtonGroup->button(0)->click(); m_pFormatButtonGroup->button(0)->setFocus(); } } pMainLayout->addWidget(m_pLabel); pMainLayout->addLayout(pFormatLayout); pMainLayout->addStretch(); } /* Setup connections: */ connect(m_pFormatButtonGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SIGNAL(completeChanged())); /* Register classes: */ qRegisterMetaType<CMediumFormat>(); /* Register fields: */ registerField("mediumFormat", this, "mediumFormat"); }
QString UIMediumDefs::getPreferredExtensionForMedium(KDeviceType enmDeviceType) { CSystemProperties comSystemProperties = vboxGlobal().virtualBox().GetSystemProperties(); QVector<CMediumFormat> mediumFormats = comSystemProperties.GetMediumFormats(); for (int i = 0; i < mediumFormats.size(); ++i) { /* File extensions */ QVector <QString> fileExtensions; QVector <KDeviceType> deviceTypes; mediumFormats[i].DescribeFileExtensions(fileExtensions, deviceTypes); if (fileExtensions.size() != deviceTypes.size()) continue; for (int a = 0; a < fileExtensions.size(); ++a) { if (deviceTypes[a] == enmDeviceType) return fileExtensions[a]; } } return QString(); }
QList<QPair<QString, QString> > UIMediumDefs::MediumBackends(const CVirtualBox &comVBox, KDeviceType enmType) { /* Prepare a list of pairs with the form <tt>{"Backend Name", "*.suffix1 .suffix2 ..."}</tt>. */ const CSystemProperties comSystemProperties = comVBox.GetSystemProperties(); QVector<CMediumFormat> mediumFormats = comSystemProperties.GetMediumFormats(); QList<QPair<QString, QString> > backendPropList; for (int i = 0; i < mediumFormats.size(); ++i) { /* Acquire file extensions & device types: */ QVector<QString> fileExtensions; QVector<KDeviceType> deviceTypes; mediumFormats[i].DescribeFileExtensions(fileExtensions, deviceTypes); /* Compose filters list: */ QStringList filters; for (int iExtensionIndex = 0; iExtensionIndex < fileExtensions.size(); ++iExtensionIndex) if (deviceTypes[iExtensionIndex] == enmType) filters << QString("*.%1").arg(fileExtensions[iExtensionIndex]); /* Create a pair out of the backend description and all suffix's. */ if (!filters.isEmpty()) backendPropList << QPair<QString, QString>(mediumFormats[i].GetName(), filters.join(" ")); } return backendPropList; }
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"); }
UIWizardNewVDPageExpert::UIWizardNewVDPageExpert(const QString &strDefaultName, const QString &strDefaultPath, qulonglong uDefaultSize) : UIWizardNewVDPage3(strDefaultName, strDefaultPath) { /* Create widgets: */ QGridLayout *pMainLayout = new QGridLayout(this); { pMainLayout->setContentsMargins(8, 6, 8, 6); pMainLayout->setSpacing(10); m_pLocationCnt = new QGroupBox(this); { m_pLocationCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); QHBoxLayout *pLocationCntLayout = new QHBoxLayout(m_pLocationCnt); { m_pLocationEditor = new QLineEdit(m_pLocationCnt); { m_pLocationEditor->setText(m_strDefaultName); } m_pLocationOpenButton = new QIToolButton(m_pLocationCnt); { m_pLocationOpenButton->setAutoRaise(true); m_pLocationOpenButton->setIcon(UIIconPool::iconSet(":/select_file_16px.png", "select_file_disabled_16px.png")); } pLocationCntLayout->addWidget(m_pLocationEditor); pLocationCntLayout->addWidget(m_pLocationOpenButton); } } m_pSizeCnt = new QGroupBox(this); { m_pSizeCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); QGridLayout *pSizeCntLayout = new QGridLayout(m_pSizeCnt); { m_pSizeSlider = new QSlider(m_pSizeCnt); { m_pSizeSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); m_pSizeSlider->setOrientation(Qt::Horizontal); m_pSizeSlider->setTickPosition(QSlider::TicksBelow); m_pSizeSlider->setFocusPolicy(Qt::StrongFocus); m_pSizeSlider->setPageStep(m_iSliderScale); m_pSizeSlider->setSingleStep(m_iSliderScale / 8); m_pSizeSlider->setTickInterval(0); m_pSizeSlider->setMinimum(sizeMBToSlider(m_uMediumSizeMin, m_iSliderScale)); m_pSizeSlider->setMaximum(sizeMBToSlider(m_uMediumSizeMax, m_iSliderScale)); } m_pSizeEditor = new QILineEdit(m_pSizeCnt); { m_pSizeEditor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); m_pSizeEditor->setFixedWidthByText("88888.88 MB"); m_pSizeEditor->setAlignment(Qt::AlignRight); m_pSizeEditor->setValidator(new QRegExpValidator(QRegExp(vboxGlobal().sizeRegexp()), this)); } QLabel *m_pSizeMin = new QLabel(m_pSizeCnt); { m_pSizeMin->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); m_pSizeMin->setText(vboxGlobal().formatSize(m_uMediumSizeMin)); } QLabel *m_pSizeMax = new QLabel(m_pSizeCnt); { m_pSizeMax->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); m_pSizeMax->setText(vboxGlobal().formatSize(m_uMediumSizeMax)); } pSizeCntLayout->addWidget(m_pSizeSlider, 0, 0, 1, 3); pSizeCntLayout->addWidget(m_pSizeEditor, 0, 3); pSizeCntLayout->addWidget(m_pSizeMin, 1, 0); pSizeCntLayout->setColumnStretch(1, 1); pSizeCntLayout->addWidget(m_pSizeMax, 1, 2); } } m_pFormatCnt = new QGroupBox(this); { m_pFormatCnt->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); QVBoxLayout *pFormatCntLayout = new QVBoxLayout(m_pFormatCnt); { m_pFormatButtonGroup = new QButtonGroup(m_pFormatCnt); { 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_pLocationCnt, 0, 0, 1, 2); pMainLayout->addWidget(m_pSizeCnt, 1, 0, 1, 2); pMainLayout->addWidget(m_pFormatCnt, 2, 0, Qt::AlignTop); pMainLayout->addWidget(m_pVariantCnt, 2, 1, Qt::AlignTop); setMediumSize(uDefaultSize); sltMediumFormatChanged(); } /* Setup connections: */ 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_pLocationEditor, SIGNAL(textChanged(const QString &)), this, SIGNAL(completeChanged())); connect(m_pLocationOpenButton, SIGNAL(clicked()), this, SLOT(sltSelectLocationButtonClicked())); connect(m_pSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(sltSizeSliderValueChanged(int))); connect(m_pSizeEditor, SIGNAL(textChanged(const QString &)), this, SLOT(sltSizeEditorTextChanged(const QString &))); /* Register classes: */ qRegisterMetaType<CMediumFormat>(); /* Register fields: */ registerField("mediumFormat", this, "mediumFormat"); registerField("mediumVariant", this, "mediumVariant"); registerField("mediumPath", this, "mediumPath"); registerField("mediumSize", this, "mediumSize"); }
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"); }
UIWizardCloneVDPageExpert::UIWizardCloneVDPageExpert(KDeviceType enmDeviceType) { /* Create widgets: */ QGridLayout *pMainLayout = new QGridLayout(this); { 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, enmDeviceType, vdi.value(strId), true); foreach (const QString &strId, preferred.keys()) addFormatButton(this, pFormatCntLayout, enmDeviceType, preferred.value(strId), true); foreach (const QString &strId, others.keys()) addFormatButton(this, pFormatCntLayout, enmDeviceType, 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); if (enmDeviceType == KDeviceType_HardDisk) { m_pDynamicalButton->click(); m_pDynamicalButton->setFocus(); } m_pFixedButton = new QRadioButton(m_pVariantCnt); if ( enmDeviceType == KDeviceType_DVD || enmDeviceType == KDeviceType_Floppy) { m_pFixedButton->click(); m_pFixedButton->setFocus(); } 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_pDestinationCnt, 1, 0, 1, 2); pMainLayout->addWidget(m_pFormatCnt, 2, 0, Qt::AlignTop); pMainLayout->addWidget(m_pVariantCnt, 2, 1, Qt::AlignTop); } /* Setup connections: */ connect(m_pFormatButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked), this, &UIWizardCloneVDPageExpert::sltMediumFormatChanged); connect(m_pVariantButtonGroup, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked), this, &UIWizardCloneVDPageExpert::completeChanged); connect(m_pSplitBox, &QCheckBox::stateChanged, this, &UIWizardCloneVDPageExpert::completeChanged); connect(m_pDestinationDiskEditor, &QLineEdit::textChanged, this, &UIWizardCloneVDPageExpert::completeChanged); connect(m_pDestinationDiskOpenButton, &QIToolButton::clicked, this, &UIWizardCloneVDPageExpert::sltSelectLocationButtonClicked); /* Register classes: */ qRegisterMetaType<CMedium>(); qRegisterMetaType<CMediumFormat>(); /* Register fields: */ registerField("mediumFormat", this, "mediumFormat"); registerField("mediumVariant", this, "mediumVariant"); registerField("mediumPath", this, "mediumPath"); registerField("mediumSize", this, "mediumSize"); }