void VBoxGuestRAMSlider::init() { ulong fullSize = vboxGlobal().virtualBox().GetHost().GetMemorySize(); CSystemProperties sys = vboxGlobal().virtualBox().GetSystemProperties(); mMinRAM = sys.GetMinGuestRAM(); mMaxRAM = RT_MIN (RT_ALIGN (fullSize, _1G / _1M), sys.GetMaxGuestRAM()); /* Come up with some nice round percent boundaries relative to * the system memory. A max of 75% on a 256GB config is ridiculous, * even on an 8GB rig reserving 2GB for the OS is way to conservative. * The max numbers can be estimated using the following program: * * double calcMaxPct(uint64_t cbRam) * { * double cbRamOverhead = cbRam * 0.0390625; // 160 bytes per page. * double cbRamForTheOS = RT_MAX(RT_MIN(_512M, cbRam * 0.25), _64M); * double OSPct = (cbRamOverhead + cbRamForTheOS) * 100.0 / cbRam; * double MaxPct = 100 - OSPct; * return MaxPct; * } * * int main() * { * uint64_t cbRam = _1G; * for (; !(cbRam >> 33); cbRam += _1G) * printf("%8lluGB %.1f%% %8lluKB\n", cbRam >> 30, calcMaxPct(cbRam), * (uint64_t)(cbRam * calcMaxPct(cbRam) / 100.0) >> 20); * for (; !(cbRam >> 51); cbRam <<= 1) * printf("%8lluGB %.1f%% %8lluKB\n", cbRam >> 30, calcMaxPct(cbRam), * (uint64_t)(cbRam * calcMaxPct(cbRam) / 100.0) >> 20); * return 0; * } * * Note. We might wanna put these calculations somewhere global later. */ /* System RAM amount test */ mMaxRAMAlw = (uint)(0.75 * fullSize); mMaxRAMOpt = (uint)(0.50 * fullSize); if (fullSize < 3072) /* done */; else if (fullSize < 4096) /* 3GB */ mMaxRAMAlw = (uint)(0.80 * fullSize); else if (fullSize < 6144) /* 4-5GB */ { mMaxRAMAlw = (uint)(0.84 * fullSize); mMaxRAMOpt = (uint)(0.60 * fullSize); } else if (fullSize < 8192) /* 6-7GB */ { mMaxRAMAlw = (uint)(0.88 * fullSize); mMaxRAMOpt = (uint)(0.65 * fullSize); } else if (fullSize < 16384) /* 8-15GB */ { mMaxRAMAlw = (uint)(0.90 * fullSize); mMaxRAMOpt = (uint)(0.70 * fullSize); } else if (fullSize < 32768) /* 16-31GB */ { mMaxRAMAlw = (uint)(0.93 * fullSize); mMaxRAMOpt = (uint)(0.75 * fullSize); } else if (fullSize < 65536) /* 32-63GB */ { mMaxRAMAlw = (uint)(0.94 * fullSize); mMaxRAMOpt = (uint)(0.80 * fullSize); } else if (fullSize < 131072) /* 64-127GB */ { mMaxRAMAlw = (uint)(0.95 * fullSize); mMaxRAMOpt = (uint)(0.85 * fullSize); } else /* 128GB- */ { mMaxRAMAlw = (uint)(0.96 * fullSize); mMaxRAMOpt = (uint)(0.90 * fullSize); } /* Now check the calculated maximums are out of the range for the guest * RAM. If so change it accordingly. */ mMaxRAMAlw = RT_MIN (mMaxRAMAlw, mMaxRAM); mMaxRAMOpt = RT_MIN (mMaxRAMOpt, mMaxRAM); setPageStep (calcPageStep (mMaxRAM)); setSingleStep (pageStep() / 4); setTickInterval (pageStep()); /* Setup the scale so that ticks are at page step boundaries */ setMinimum ((mMinRAM / pageStep()) * pageStep()); setMaximum (mMaxRAM); setSnappingEnabled (true); setOptimalHint (mMinRAM, mMaxRAMOpt); setWarningHint (mMaxRAMOpt, mMaxRAMAlw); setErrorHint (mMaxRAMAlw, mMaxRAM); }
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"); }
void UIVMInformationDialog::retranslateUi() { sltUpdateDetails(); AssertReturnVoid(!m_session.isNull()); CMachine machine = m_session.GetMachine(); AssertReturnVoid(!machine.isNull()); /* Setup dialog title: */ setWindowTitle(tr("%1 - Session Information").arg(machine.GetName())); /* Translate tabs: */ m_pTabWidget->setTabText(0, tr("Configuration &Details")); m_pTabWidget->setTabText(1, tr("&Runtime Information")); /* Clear counter names initially: */ m_names.clear(); m_units.clear(); m_links.clear(); /* Storage statistics: */ CSystemProperties sp = vboxGlobal().virtualBox().GetSystemProperties(); CStorageControllerVector controllers = m_session.GetMachine().GetStorageControllers(); int iIDECount = 0, iSATACount = 0, iSCSICount = 0; foreach (const CStorageController &controller, controllers) { switch (controller.GetBus()) { case KStorageBus_IDE: { for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus(KStorageBus_IDE); ++i) { for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus(KStorageBus_IDE); ++j) { /* Names: */ m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA") .arg(iIDECount).arg(i).arg(j)] = tr("DMA Transfers"); m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO") .arg(iIDECount).arg(i).arg(j)] = tr("PIO Transfers"); m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes") .arg(iIDECount).arg(i).arg(j)] = tr("Data Read"); m_names[QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes") .arg(iIDECount).arg(i).arg(j)] = tr("Data Written"); /* Units: */ m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA") .arg(iIDECount).arg(i).arg(j)] = "[B]"; m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO") .arg(iIDECount).arg(i).arg(j)] = "[B]"; m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes") .arg(iIDECount).arg(i).arg(j)] = "B"; m_units[QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes") .arg(iIDECount).arg(i).arg(j)] = "B"; /* Belongs to */ m_links[QString("/Devices/IDE%1/ATA%2/Unit%3").arg(iIDECount).arg(i).arg(j)] = QStringList() << QString("/Devices/IDE%1/ATA%2/Unit%3/*DMA").arg(iIDECount).arg(i).arg(j) << QString("/Devices/IDE%1/ATA%2/Unit%3/*PIO").arg(iIDECount).arg(i).arg(j) << QString("/Devices/IDE%1/ATA%2/Unit%3/ReadBytes").arg(iIDECount).arg(i).arg(j) << QString("/Devices/IDE%1/ATA%2/Unit%3/WrittenBytes").arg(iIDECount).arg(i).arg(j); } } ++iIDECount; break; } case KStorageBus_SATA: { for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus(KStorageBus_SATA); ++i) { for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus(KStorageBus_SATA); ++j) { /* Names: */ m_names[QString("/Devices/SATA%1/Port%2/DMA").arg(iSATACount).arg(i)] = tr("DMA Transfers"); m_names[QString("/Devices/SATA%1/Port%2/ReadBytes").arg(iSATACount).arg(i)] = tr("Data Read"); m_names[QString("/Devices/SATA%1/Port%2/WrittenBytes").arg(iSATACount).arg(i)] = tr("Data Written"); /* Units: */ m_units[QString("/Devices/SATA%1/Port%2/DMA").arg(iSATACount).arg(i)] = "[B]"; m_units[QString("/Devices/SATA%1/Port%2/ReadBytes").arg(iSATACount).arg(i)] = "B"; m_units[QString("/Devices/SATA%1/Port%2/WrittenBytes").arg(iSATACount).arg(i)] = "B"; /* Belongs to: */ m_links[QString("/Devices/SATA%1/Port%2").arg(iSATACount).arg(i)] = QStringList() << QString("/Devices/SATA%1/Port%2/DMA").arg(iSATACount).arg(i) << QString("/Devices/SATA%1/Port%2/ReadBytes").arg(iSATACount).arg(i) << QString("/Devices/SATA%1/Port%2/WrittenBytes").arg(iSATACount).arg(i); } } ++iSATACount; break; } case KStorageBus_SCSI: { for (ULONG i = 0; i < sp.GetMaxPortCountForStorageBus(KStorageBus_SCSI); ++i) { for (ULONG j = 0; j < sp.GetMaxDevicesPerPortForStorageBus(KStorageBus_SCSI); ++j) { /* Names: */ m_names[QString("/Devices/SCSI%1/%2/ReadBytes").arg(iSCSICount).arg(i)] = tr("Data Read"); m_names[QString("/Devices/SCSI%1/%2/WrittenBytes").arg(iSCSICount).arg(i)] = tr("Data Written"); /* Units: */ m_units[QString("/Devices/SCSI%1/%2/ReadBytes").arg(iSCSICount).arg(i)] = "B"; m_units[QString("/Devices/SCSI%1/%2/WrittenBytes").arg(iSCSICount).arg(i)] = "B"; /* Belongs to: */ m_links[QString("/Devices/SCSI%1/%2").arg(iSCSICount).arg(i)] = QStringList() << QString("/Devices/SCSI%1/%2/ReadBytes").arg(iSCSICount).arg(i) << QString("/Devices/SCSI%1/%2/WrittenBytes").arg(iSCSICount).arg(i); } } ++iSCSICount; break; } default: break; } } /* Network statistics: */ ulong count = vboxGlobal().virtualBox().GetSystemProperties().GetMaxNetworkAdapters(KChipsetType_PIIX3); for (ulong i = 0; i < count; ++i) { CNetworkAdapter na = machine.GetNetworkAdapter(i); KNetworkAdapterType ty = na.GetAdapterType(); const char *name; switch (ty) { case KNetworkAdapterType_I82540EM: case KNetworkAdapterType_I82543GC: case KNetworkAdapterType_I82545EM: name = "E1k"; break; case KNetworkAdapterType_Virtio: name = "VNet"; break; default: name = "PCNet"; break; } /* Names: */ m_names[QString("/Devices/%1%2/TransmitBytes").arg(name).arg(i)] = tr("Data Transmitted"); m_names[QString("/Devices/%1%2/ReceiveBytes").arg(name).arg(i)] = tr("Data Received"); /* Units: */ m_units[QString("/Devices/%1%2/TransmitBytes").arg(name).arg(i)] = "B"; m_units[QString("/Devices/%1%2/ReceiveBytes").arg(name).arg(i)] = "B"; /* Belongs to: */ m_links[QString("NA%1").arg(i)] = QStringList() << QString("/Devices/%1%2/TransmitBytes").arg(name).arg(i) << QString("/Devices/%1%2/ReceiveBytes").arg(name).arg(i); } /* Statistics page update: */ refreshStatistics(); }
void UIMachineSettingsSystem::prepareTabMotherboard() { /* Load configuration: */ CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties(); /* Preconfigure memory-size editor: */ m_pEditorMemorySize->setMinimum(m_pSliderMemorySize->minRAM()); m_pEditorMemorySize->setMaximum(m_pSliderMemorySize->maxRAM()); vboxGlobal().setMinimumWidthAccordingSymbolCount(m_pEditorMemorySize, 5); /* Preconfigure boot-table widgets: */ mTbBootItemUp->setIcon(UIIconPool::iconSet(":/list_moveup_16px.png", ":/list_moveup_disabled_16px.png")); mTbBootItemDown->setIcon(UIIconPool::iconSet(":/list_movedown_16px.png", ":/list_movedown_disabled_16px.png")); #ifdef Q_WS_MAC /* We need a little space for the focus rect: */ m_pLayoutBootOrder->setContentsMargins(3, 3, 3, 3); m_pLayoutBootOrder->setSpacing(3); #endif /* Q_WS_MAC */ /* Install global event filter * to handle boot-table focus in/out events: */ // TODO: Get rid of that *crap*! qApp->installEventFilter(this); /* Populate possible boot items list. * Currently, it seems, we are supporting only 4 possible boot device types: * 1. Floppy, 2. DVD-ROM, 3. Hard Disk, 4. Network. * But maximum boot devices count supported by machine * should be retrieved through the ISystemProperties getter. * Moreover, possible boot device types are not listed in some separate Main vector, * so we should get them (randomely?) from the list of all device types. * Until there will be separate Main getter for list of supported boot device types, * this list will be hard-coded here... */ int iPossibleBootListSize = qMin((ULONG)4, properties.GetMaxBootPosition()); for (int iBootPosition = 1; iBootPosition <= iPossibleBootListSize; ++iBootPosition) { switch (iBootPosition) { case 1: m_possibleBootItems << KDeviceType_Floppy; break; case 2: m_possibleBootItems << KDeviceType_DVD; break; case 3: m_possibleBootItems << KDeviceType_HardDisk; break; case 4: m_possibleBootItems << KDeviceType_Network; break; default: break; } } /* Add all available devices types, so we could initially calculate the right size: */ for (int i = 0; i < m_possibleBootItems.size(); ++i) { QListWidgetItem *pItem = new UIBootTableItem(m_possibleBootItems[i]); mTwBootOrder->addItem(pItem); } /* Populate 'chipset type' combo: */ m_pComboChipsetType->addItem(gpConverter->toString(KChipsetType_PIIX3), QVariant(KChipsetType_PIIX3)); m_pComboChipsetType->addItem(gpConverter->toString(KChipsetType_ICH9), QVariant(KChipsetType_ICH9)); /* Preconfigure 'pointing HID type' combo: */ m_pComboPointingHIDType->setSizeAdjustPolicy(QComboBox::AdjustToContents); /* Install memory-size widget connections: */ connect(m_pSliderMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleMemorySizeSliderChange())); connect(m_pEditorMemorySize, SIGNAL(valueChanged(int)), this, SLOT(sltHandleMemorySizeEditorChange())); /* Install boot-table connections: */ connect(mTbBootItemUp, SIGNAL(clicked()), mTwBootOrder, SLOT(sltMoveItemUp())); connect(mTbBootItemDown, SIGNAL(clicked()), mTwBootOrder, SLOT(sltMoveItemDown())); connect(mTwBootOrder, SIGNAL(sigRowChanged(int)), this, SLOT(sltCurrentBootItemChanged(int))); }
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"); }
UIMachineSettingsSystem::UIMachineSettingsSystem() : mValidator(0) , mMinGuestCPU(0), mMaxGuestCPU(0) , mMinGuestCPUExecCap(0), mMedGuestCPUExecCap(0), mMaxGuestCPUExecCap(0) , m_fOHCIEnabled(false) { /* Apply UI decorations */ Ui::UIMachineSettingsSystem::setupUi (this); /* Setup constants */ CSystemProperties properties = vboxGlobal().virtualBox().GetSystemProperties(); uint hostCPUs = vboxGlobal().host().GetProcessorCount(); mMinGuestCPU = properties.GetMinGuestCPUCount(); mMaxGuestCPU = RT_MIN (2 * hostCPUs, properties.GetMaxGuestCPUCount()); mMinGuestCPUExecCap = 1; mMedGuestCPUExecCap = 40; mMaxGuestCPUExecCap = 100; /* Populate possible boot items list. * Currently, it seems, we are supporting only 4 possible boot device types: * 1. Floppy, 2. DVD-ROM, 3. Hard Disk, 4. Network. * But maximum boot devices count supported by machine * should be retrieved through the ISystemProperties getter. * Moreover, possible boot device types are not listed in some separate Main vector, * so we should get them (randomely?) from the list of all device types. * Until there will be separate Main getter for list of supported boot device types, * this list will be hard-coded here... */ int iPossibleBootListSize = qMin((ULONG)4, properties.GetMaxBootPosition()); for (int iBootPosition = 1; iBootPosition <= iPossibleBootListSize; ++iBootPosition) { switch (iBootPosition) { case 1: m_possibleBootItems << KDeviceType_Floppy; break; case 2: m_possibleBootItems << KDeviceType_DVD; break; case 3: m_possibleBootItems << KDeviceType_HardDisk; break; case 4: m_possibleBootItems << KDeviceType_Network; break; default: break; } } /* Add all available devices types, so we could initially calculate the * right size. */ for (int i = 0; i < m_possibleBootItems.size(); ++i) { QListWidgetItem *pItem = new UIBootTableItem(m_possibleBootItems[i]); mTwBootOrder->addItem(pItem); } /* Setup validators */ mLeMemory->setValidator (new QIntValidator (mSlMemory->minRAM(), mSlMemory->maxRAM(), this)); mLeCPU->setValidator (new QIntValidator (mMinGuestCPU, mMaxGuestCPU, this)); mLeCPUExecCap->setValidator(new QIntValidator(mMinGuestCPUExecCap, mMaxGuestCPUExecCap, this)); /* Setup connections */ connect (mSlMemory, SIGNAL (valueChanged (int)), this, SLOT (valueChangedRAM (int))); connect (mLeMemory, SIGNAL (textChanged (const QString&)), this, SLOT (textChangedRAM (const QString&))); connect (mTbBootItemUp, SIGNAL (clicked()), mTwBootOrder, SLOT(sltMoveItemUp())); connect (mTbBootItemDown, SIGNAL (clicked()), mTwBootOrder, SLOT(sltMoveItemDown())); connect (mTwBootOrder, SIGNAL (sigRowChanged(int)), this, SLOT (onCurrentBootItemChanged (int))); connect (mSlCPU, SIGNAL (valueChanged (int)), this, SLOT (valueChangedCPU (int))); connect (mLeCPU, SIGNAL (textChanged (const QString&)), this, SLOT (textChangedCPU (const QString&))); connect(mSlCPUExecCap, SIGNAL(valueChanged(int)), this, SLOT(sltValueChangedCPUExecCap(int))); connect(mLeCPUExecCap, SIGNAL(textChanged(const QString&)), this, SLOT(sltTextChangedCPUExecCap(const QString&))); /* Setup iconsets */ mTbBootItemUp->setIcon(UIIconPool::iconSet(":/list_moveup_16px.png", ":/list_moveup_disabled_16px.png")); mTbBootItemDown->setIcon(UIIconPool::iconSet(":/list_movedown_16px.png", ":/list_movedown_disabled_16px.png")); #ifdef Q_WS_MAC /* We need a little space for the focus rect. */ mLtBootOrder->setContentsMargins (3, 3, 3, 3); mLtBootOrder->setSpacing (3); #endif /* Q_WS_MAC */ /* Limit min/max. size of QLineEdit */ mLeMemory->setFixedWidthByText (QString().fill ('8', 5)); /* Ensure mLeMemory value and validation is updated */ valueChangedRAM (mSlMemory->value()); /* Setup cpu slider */ mSlCPU->setPageStep (1); mSlCPU->setSingleStep (1); mSlCPU->setTickInterval (1); /* Setup the scale so that ticks are at page step boundaries */ mSlCPU->setMinimum (mMinGuestCPU); mSlCPU->setMaximum (mMaxGuestCPU); mSlCPU->setOptimalHint (1, hostCPUs); mSlCPU->setWarningHint (hostCPUs, mMaxGuestCPU); /* Limit min/max. size of QLineEdit */ mLeCPU->setFixedWidthByText(QString().fill('8', 4)); /* Ensure mLeMemory value and validation is updated */ valueChangedCPU (mSlCPU->value()); /* Setup cpu cap slider: */ mSlCPUExecCap->setPageStep(10); mSlCPUExecCap->setSingleStep(1); mSlCPUExecCap->setTickInterval(10); /* Setup the scale so that ticks are at page step boundaries: */ mSlCPUExecCap->setMinimum(mMinGuestCPUExecCap); mSlCPUExecCap->setMaximum(mMaxGuestCPUExecCap); mSlCPUExecCap->setWarningHint(mMinGuestCPUExecCap, mMedGuestCPUExecCap); mSlCPUExecCap->setOptimalHint(mMedGuestCPUExecCap, mMaxGuestCPUExecCap); /* Limit min/max. size of QLineEdit: */ mLeCPUExecCap->setFixedWidthByText(QString().fill('8', 4)); /* Ensure mLeMemory value and validation is updated: */ sltValueChangedCPUExecCap(mSlCPUExecCap->value()); /* Populate chipset combo: */ mCbChipset->insertItem(0, vboxGlobal().toString(KChipsetType_PIIX3), QVariant(KChipsetType_PIIX3)); mCbChipset->insertItem(1, vboxGlobal().toString(KChipsetType_ICH9), QVariant(KChipsetType_ICH9)); /* Install global event filter */ qApp->installEventFilter (this); /* Applying language settings */ retranslateUi(); }