bool UIWizardNewVDPageBasic3::validatePage() { /* Initial result: */ bool fResult = true; /* Make sure such file doesn't exists already: */ QString strMediumPath(mediumPath()); fResult = !QFileInfo(strMediumPath).exists(); if (!fResult) msgCenter().cannotOverwriteHardDiskStorage(strMediumPath, this); if (fResult) { /* Lock finish button: */ startProcessing(); /* Try to create virtual hard drive file: */ fResult = qobject_cast<UIWizardNewVD*>(wizard())->createVirtualDisk(); /* Unlock finish button: */ endProcessing(); } /* Return result: */ return fResult; }
void UIWizardNewVDPage3::onSelectLocationButtonClicked() { /* Get current folder and filename: */ QFileInfo fullFilePath(mediumPath()); QDir folder = fullFilePath.path(); QString strFileName = fullFilePath.fileName(); /* Set the first parent folder that exists as the current: */ while (!folder.exists() && !folder.isRoot()) { QFileInfo folderInfo(folder.absolutePath()); if (folder == QDir(folderInfo.absolutePath())) break; folder = folderInfo.absolutePath(); } /* But if it doesn't exists at all: */ if (!folder.exists() || folder.isRoot()) { /* Use recommended one folder: */ QFileInfo defaultFilePath(absoluteFilePath(strFileName, m_strDefaultPath)); folder = defaultFilePath.path(); } /* Prepare backends list: */ QVector<QString> fileExtensions; QVector<KDeviceType> deviceTypes; CMediumFormat mediumFormat = fieldImp("mediumFormat").value<CMediumFormat>(); mediumFormat.DescribeFileExtensions(fileExtensions, deviceTypes); QStringList validExtensionList; for (int i = 0; i < fileExtensions.size(); ++i) if (deviceTypes[i] == KDeviceType_HardDisk) validExtensionList << QString("*.%1").arg(fileExtensions[i]); /* Compose full filter list: */ QString strBackendsList = QString("%1 (%2)").arg(mediumFormat.GetName()).arg(validExtensionList.join(" ")); /* Open corresponding file-dialog: */ QString strChosenFilePath = QIFileDialog::getSaveFileName(folder.absoluteFilePath(strFileName), strBackendsList, thisImp(), VBoxGlobal::tr("Please choose a location for new virtual hard drive file")); /* If there was something really chosen: */ if (!strChosenFilePath.isEmpty()) { /* If valid file extension is missed, append it: */ if (QFileInfo(strChosenFilePath).suffix().isEmpty()) strChosenFilePath += QString(".%1").arg(m_strDefaultExtension); m_pLocationEditor->setText(QDir::toNativeSeparators(strChosenFilePath)); m_pLocationEditor->selectAll(); m_pLocationEditor->setFocus(); } }
int UIWizardCloneVDPageExpert::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = UIWizardPage::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 4) qt_static_metacall(this, _c, _id, _a); _id -= 4; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< CMedium*>(_v) = sourceVirtualDisk(); break; case 1: *reinterpret_cast< CMediumFormat*>(_v) = mediumFormat(); break; case 2: *reinterpret_cast< qulonglong*>(_v) = mediumVariant(); break; case 3: *reinterpret_cast< QString*>(_v) = mediumPath(); break; case 4: *reinterpret_cast< qulonglong*>(_v) = mediumSize(); break; } _id -= 5; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setSourceVirtualDisk(*reinterpret_cast< CMedium*>(_v)); break; case 1: setMediumFormat(*reinterpret_cast< CMediumFormat*>(_v)); break; case 2: setMediumVariant(*reinterpret_cast< qulonglong*>(_v)); break; } _id -= 5; } else if (_c == QMetaObject::ResetProperty) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 5; } #endif // QT_NO_PROPERTIES return _id; }
bool UIWizardCloneVDPageExpert::validatePage() { /* Initial result: */ bool fResult = true; /* Lock finish button: */ startProcessing(); /* Make sure such virtual-disk doesn't exists: */ QString strMediumPath(mediumPath()); fResult = !QFileInfo(strMediumPath).exists(); if (!fResult) msgCenter().cannotOverwriteHardDiskStorage(strMediumPath, this); /* Try to copy virtual-disk: */ if (fResult) fResult = qobject_cast<UIWizardCloneVD*>(wizard())->copyVirtualDisk(); /* Unlock finish button: */ endProcessing(); /* Return result: */ return fResult; }