Changeset 77238 in vbox
- Timestamp:
- Feb 10, 2019 1:48:07 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 128745
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r77217 r77238 431 431 QSettings settings(m_strBrandingConfigFilePath, QSettings::IniFormat); 432 432 return settings.value(QString("%1").arg(strKey)).toString(); 433 } 434 435 /*static */ 436 QString VBoxGlobal::findUniqueFileName(const QString &strFullFolderPath, const QString &strBaseFileName) 437 { 438 QDir folder(strFullFolderPath); 439 if (!folder.exists()) 440 return strBaseFileName; 441 QFileInfoList folderContent = folder.entryInfoList(); 442 QSet<QString> fileNameSet; 443 foreach (const QFileInfo &fileInfo, folderContent) 444 { 445 /* Remove the extension : */ 446 fileNameSet.insert(fileInfo.baseName()); 447 } 448 int iSuffix = 0; 449 QString strNewName(strBaseFileName); 450 while (fileNameSet.contains(strNewName)) 451 { 452 strNewName = strBaseFileName + QString("_") + QString::number(++iSuffix); 453 } 454 return strNewName; 433 455 } 434 456 … … 2793 2815 2794 2816 QUuid VBoxGlobal::createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineGuestOSTypeId, 2817 const QString &strMachineName, 2795 2818 const QString &strMachineFolder) 2796 2819 { 2797 2820 /* Initialize variables: */ 2798 2821 const CGuestOSType comGuestOSType = virtualBox().GetGuestOSType(strMachineGuestOSTypeId); 2799 const QFileInfo fileInfo(strMachineFolder);2822 QString strDiskName = findUniqueFileName(strMachineFolder, strMachineName); 2800 2823 /* Show New VD wizard: */ 2801 UISafePointerWizardNewVD pWizard = new UIWizardNewVD(pParent, QString(), fileInfo.absolutePath(), comGuestOSType.GetRecommendedHDD());2824 UISafePointerWizardNewVD pWizard = new UIWizardNewVD(pParent, strDiskName, strMachineFolder, comGuestOSType.GetRecommendedHDD()); 2802 2825 2803 2826 if (!pWizard) -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r77217 r77238 185 185 /** Returns value for certain branding @a strKey from custom.ini file. */ 186 186 QString brandingGetKey(QString strKey); 187 /** Returns a file name (unique up to extension) wrt. @a strFullFolderPath folder content. Starts 188 * searching strBaseFileName and adds suffixes until a unique file name is found. */ 189 static QString findUniqueFileName(const QString &strFullFolderPath, const QString &strBaseFileName); 187 190 /** @} */ 188 191 … … 528 531 * @param parent Passes the parent of the wizard, 529 532 * @param strMachineGuestOSTypeId Passes the string of machine's guest OS type ID, 533 * @param strMachineName Passes the name of the machine, 530 534 * @param strMachineFolder Passes the machine folder, 531 535 * returns the ID of the created hard disk if successful, a null QUuid otherwise.*/ 532 QUuid createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineGuestOSTypeId, const QString &strMachineFolder); 536 QUuid createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineGuestOSTypeId, 537 const QString &strMachineName, const QString &strMachineFolder); 533 538 534 539 /** Prepares storage menu according passed parameters. -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.cpp
r77216 r77238 163 163 return strInitialPath; 164 164 165 strInitialPath = QDir(strInitialPath).absoluteFilePath(m_strMachineName + "." + strPreferredExtension); 165 QString strDiskname = VBoxGlobal::findUniqueFileName(m_strMachineFolder, m_strMachineName); 166 167 strInitialPath = QDir(strInitialPath).absoluteFilePath(strDiskname + "." + strPreferredExtension); 166 168 return strInitialPath; 167 169 } -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp
r77217 r77238 449 449 uMediumId = vboxGlobal().showCreateFloppyDiskDialog(this, m_strMachineName, m_strMachineFolder); 450 450 else if (m_enmMediumType == UIMediumDeviceType_HardDisk) 451 uMediumId = vboxGlobal().createHDWithNewHDWizard(this, m_strMachineGuestOSTypeId, m_strMachine Folder);451 uMediumId = vboxGlobal().createHDWithNewHDWizard(this, m_strMachineGuestOSTypeId, m_strMachineName, m_strMachineFolder); 452 452 else if (m_enmMediumType == UIMediumDeviceType_DVD) 453 453 uMediumId = vboxGlobal().createVisoMediumWithVisoCreator(this, m_strMachineName, m_strMachineFolder); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r77217 r77238 3082 3082 void UIMachineSettingsStorage::sltCreateNewHardDisk() 3083 3083 { 3084 const QUuid uMediumId = vboxGlobal().createHDWithNewHDWizard(this, m_strMachineGuestOSTypeId, m_strMachineSettingsFilePath); 3084 const QUuid uMediumId = vboxGlobal().createHDWithNewHDWizard(this, m_strMachineGuestOSTypeId, 3085 m_strMachineName, m_strMachineSettingsFilePath); 3085 3086 3086 3087 if (!uMediumId.isNull())
Note:
See TracChangeset
for help on using the changeset viewer.