Changeset 77277 in vbox
- Timestamp:
- Feb 12, 2019 2:45:05 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 128792
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp
r77264 r77277 91 91 92 92 /* COM includes: */ 93 #include "CAudioAdapter.h" 94 #include "CBIOSSettings.h" 95 #include "CConsole.h" 93 96 #include "CExtPack.h" 94 97 #include "CExtPackFile.h" 95 98 #include "CExtPackManager.h" 99 #include "CHostUSBDevice.h" 100 #include "CHostVideoInputDevice.h" 96 101 #include "CMachine.h" 97 #include "CUSBDevice.h"98 #include "CUSBDeviceFilters.h"99 #include "CUSBDeviceFilter.h"100 #include "CBIOSSettings.h"101 #include "CVRDEServer.h"102 #include "CStorageController.h"103 102 #include "CMediumAttachment.h" 104 #include "CAudioAdapter.h"105 103 #include "CNetworkAdapter.h" 106 104 #include "CSerialPort.h" 105 #include "CSharedFolder.h" 106 #include "CSnapshot.h" 107 #include "CStorageController.h" 108 #include "CSystemProperties.h" 107 109 #include "CUSBController.h" 108 #include "CHostUSBDevice.h" 109 #include "CHostVideoInputDevice.h" 110 #include "CSharedFolder.h" 111 #include "CConsole.h" 112 #include "CSnapshot.h" 110 #include "CUSBDevice.h" 111 #include "CUSBDeviceFilter.h" 112 #include "CUSBDeviceFilters.h" 113 #include "CVRDEServer.h" 113 114 114 115 /* Other VBox includes: */ … … 2576 2577 2577 2578 QUuid VBoxGlobal::openMediumWithFileOpenDialog(UIMediumDeviceType enmMediumType, QWidget *pParent, 2578 2579 2579 const QString &strDefaultFolder /* = QString() */, 2580 bool fUseLastFolder /* = false */) 2580 2581 { 2581 2582 /* Initialize variables: */ … … 2586 2587 QString strTitle; 2587 2588 QString allType; 2588 QString strLastFolder ;2589 QString strLastFolder = defaultFolderPathForType(enmMediumType); 2589 2590 switch (enmMediumType) 2590 2591 { … … 2594 2595 strTitle = tr("Please choose a virtual hard disk file"); 2595 2596 allType = tr("All virtual hard disk files (%1)"); 2596 strLastFolder = gEDataManager->recentFolderForHardDrives();2597 if (strLastFolder.isEmpty())2598 strLastFolder = gEDataManager->recentFolderForOpticalDisks();2599 if (strLastFolder.isEmpty())2600 strLastFolder = gEDataManager->recentFolderForFloppyDisks();2601 2597 break; 2602 2598 } … … 2606 2602 strTitle = tr("Please choose a virtual optical disk file"); 2607 2603 allType = tr("All virtual optical disk files (%1)"); 2608 strLastFolder = gEDataManager->recentFolderForOpticalDisks();2609 if (strLastFolder.isEmpty())2610 strLastFolder = gEDataManager->recentFolderForFloppyDisks();2611 if (strLastFolder.isEmpty())2612 strLastFolder = gEDataManager->recentFolderForHardDrives();2613 2604 break; 2614 2605 } … … 2618 2609 strTitle = tr("Please choose a virtual floppy disk file"); 2619 2610 allType = tr("All virtual floppy disk files (%1)"); 2620 strLastFolder = gEDataManager->recentFolderForFloppyDisks();2621 if (strLastFolder.isEmpty())2622 strLastFolder = gEDataManager->recentFolderForOpticalDisks();2623 if (strLastFolder.isEmpty())2624 strLastFolder = gEDataManager->recentFolderForHardDrives();2625 2611 break; 2626 2612 } … … 2688 2674 2689 2675 2690 QUuid VBoxGlobal::createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strFolder, const QString &strMachineName /* = QString */) 2691 { 2676 QUuid VBoxGlobal::createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strDefaultFolder /* = QString */, 2677 const QString &strMachineName /* = QString */) 2678 { 2679 QString strVisoSaveFolder(strDefaultFolder); 2680 if (strVisoSaveFolder.isEmpty()) 2681 strVisoSaveFolder = defaultFolderPathForType(UIMediumDeviceType_DVD); 2682 2692 2683 QWidget *pDialogParent = windowManager().realParentWindow(pParent); 2693 2684 QPointer<UIVisoCreator> pVisoCreator = new UIVisoCreator(pDialogParent, strMachineName); … … 2713 2704 char szVisoPath[RTPATH_MAX]; 2714 2705 QString strFileName = QString("%1%2").arg(strVisoName).arg(".viso"); 2715 int vrc = RTPathJoin(szVisoPath, sizeof(szVisoPath), str Folder.toUtf8().constData(), strFileName.toUtf8().constData());2706 int vrc = RTPathJoin(szVisoPath, sizeof(szVisoPath), strDefaultFolder.toUtf8().constData(), strFileName.toUtf8().constData()); 2716 2707 if (RT_SUCCESS(vrc)) 2717 2708 { … … 2761 2752 } 2762 2753 2763 QUuid VBoxGlobal::showCreateFloppyDiskDialog(QWidget *pParent, const QString &strMachineName, const QString &strMachineFolder) 2764 { 2754 QUuid VBoxGlobal::showCreateFloppyDiskDialog(QWidget *pParent, const QString &strDefaultFolder /* QString() */, 2755 const QString &strMachineName /* = QString() */ ) 2756 { 2757 QString strStartPath(strDefaultFolder); 2758 2759 if (strStartPath.isEmpty()) 2760 strStartPath = defaultFolderPathForType(UIMediumDeviceType_Floppy); 2761 2765 2762 QWidget *pDialogParent = windowManager().realParentWindow(pParent); 2766 2763 2767 UIFDCreationDialog *pDialog = new UIFDCreationDialog(pParent, str MachineFolder, strMachineName);2764 UIFDCreationDialog *pDialog = new UIFDCreationDialog(pParent, strStartPath, strMachineName); 2768 2765 if (!pDialog) 2769 2766 return QUuid(); … … 2814 2811 } 2815 2812 2813 QUuid VBoxGlobal::openMediumCreatorDialog(QWidget *pParent, UIMediumDeviceType enmMediumType, 2814 const QString &strDefaultFolder /* = QString() */, const QString &strMachineName /* = QString() */, 2815 const QString &strMachineGuestOSTypeId /*= QString() */) 2816 { 2817 QUuid uMediumId; 2818 2819 switch (enmMediumType) 2820 { 2821 case UIMediumDeviceType_Floppy: 2822 uMediumId = showCreateFloppyDiskDialog(pParent, strDefaultFolder, strMachineName); 2823 break; 2824 case UIMediumDeviceType_HardDisk: 2825 uMediumId = createHDWithNewHDWizard(pParent, strMachineGuestOSTypeId, strDefaultFolder, strMachineName); 2826 2827 break; 2828 case UIMediumDeviceType_DVD: 2829 uMediumId = createVisoMediumWithVisoCreator(pParent, strDefaultFolder, strMachineName); 2830 break; 2831 default: 2832 break; 2833 } 2834 2835 return uMediumId; 2836 } 2837 2816 2838 QUuid VBoxGlobal::createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineGuestOSTypeId, 2817 const QString &strMachine Name,2818 const QString &strMachine Folder)2839 const QString &strMachineFolder /* = QString() */, 2840 const QString &strMachineName /* = QString() */) 2819 2841 { 2820 2842 /* Initialize variables: */ 2821 const CGuestOSType comGuestOSType = virtualBox().GetGuestOSType(strMachineGuestOSTypeId); 2822 QString strDiskName = findUniqueFileName(strMachineFolder, strMachineName); 2843 QString strDefaultFolder(strMachineFolder); 2844 if (strDefaultFolder.isEmpty()) 2845 strDefaultFolder = defaultFolderPathForType(UIMediumDeviceType_HardDisk); 2846 2847 const CGuestOSType comGuestOSType = virtualBox().GetGuestOSType(!strMachineGuestOSTypeId.isEmpty() ? strMachineGuestOSTypeId : "Other"); 2848 QString strDiskName = findUniqueFileName(strDefaultFolder, 2849 !strMachineName.isEmpty() ? strMachineName : "NewVirtualDisk"); 2823 2850 /* Show New VD wizard: */ 2824 UISafePointerWizardNewVD pWizard = new UIWizardNewVD(pParent, strDiskName, str MachineFolder, comGuestOSType.GetRecommendedHDD());2851 UISafePointerWizardNewVD pWizard = new UIWizardNewVD(pParent, strDiskName, strDefaultFolder, comGuestOSType.GetRecommendedHDD()); 2825 2852 2826 2853 if (!pWizard) … … 3052 3079 3053 3080 else if(target.type == UIMediumTarget::UIMediumTargetType_CreateFloppyDisk) 3054 uMediumID = showCreateFloppyDiskDialog(windowManager().mainWindowShown(), comConstMachine.GetName(), strMachineFolder);3081 uMediumID = showCreateFloppyDiskDialog(windowManager().mainWindowShown(), strMachineFolder, comConstMachine.GetName()); 3055 3082 3056 3083 /* Return focus back: */ … … 3249 3276 default: break; 3250 3277 } 3278 } 3279 3280 QString VBoxGlobal::defaultFolderPathForType(UIMediumDeviceType enmMediumType) 3281 { 3282 QString strLastFolder; 3283 switch (enmMediumType) 3284 { 3285 case UIMediumDeviceType_HardDisk: 3286 strLastFolder = gEDataManager->recentFolderForHardDrives(); 3287 if (strLastFolder.isEmpty()) 3288 strLastFolder = gEDataManager->recentFolderForOpticalDisks(); 3289 if (strLastFolder.isEmpty()) 3290 strLastFolder = gEDataManager->recentFolderForFloppyDisks(); 3291 break; 3292 case UIMediumDeviceType_DVD: 3293 strLastFolder = gEDataManager->recentFolderForOpticalDisks(); 3294 if (strLastFolder.isEmpty()) 3295 strLastFolder = gEDataManager->recentFolderForFloppyDisks(); 3296 if (strLastFolder.isEmpty()) 3297 strLastFolder = gEDataManager->recentFolderForHardDrives(); 3298 break; 3299 case UIMediumDeviceType_Floppy: 3300 strLastFolder = gEDataManager->recentFolderForFloppyDisks(); 3301 if (strLastFolder.isEmpty()) 3302 strLastFolder = gEDataManager->recentFolderForOpticalDisks(); 3303 if (strLastFolder.isEmpty()) 3304 strLastFolder = gEDataManager->recentFolderForHardDrives(); 3305 break; 3306 default: 3307 break; 3308 } 3309 3310 if (strLastFolder.isEmpty()) 3311 return virtualBox().GetSystemProperties().GetDefaultMachineFolder(); 3312 3313 return strLastFolder; 3251 3314 } 3252 3315 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h
r77264 r77277 500 500 * @param fUseLastFolder Brings whether we should propose to use last used folder. */ 501 501 QUuid openMediumWithFileOpenDialog(UIMediumDeviceType enmMediumType, QWidget *pParent = 0, 502 const QString &strDefaultFolder = QString(), bool fUseLastFolder = true);502 const QString &strDefaultFolder = QString(), bool fUseLastFolder = false); 503 503 504 504 /** Creates a VISO by using the VISO creator dialog. 505 * @param pParent Brings the dialog parent.506 * @param str Folder Brings the folder to save the VISO file.505 * @param pParent Passes the dialog parent. 506 * @param strDefaultFolder Passes the folder to save the VISO file. 507 507 * @param strMachineName Passes the name of the machine, */ 508 QUuid createVisoMediumWithVisoCreator(QWidget *pParent, const QString &str Folder, const QString &strMachineName = QString());508 QUuid createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strDefaultFolder = QString(), const QString &strMachineName = QString()); 509 509 510 510 /** Creates and shows a dialog thru which user can create a new floppy disk a VISO using the file-open dialog. 511 511 * @param parent Passes the parent of the dialog, 512 * @param strDefaultFolder Passes the default folder, 512 513 * @param strMachineName Passes the name of the machine, 513 * @param strMachineFolder Passes the machine folder,514 514 * returns the ID of the newly created medium if successful, a null QUuid otherwise.*/ 515 QUuid showCreateFloppyDiskDialog(QWidget *pParent, const QString &strMachineName, const QString &strMachineFolder); 515 QUuid showCreateFloppyDiskDialog(QWidget *pParent, const QString &strDefaultFolder = QString(), 516 const QString &strMachineName = QString()); 516 517 517 518 /** Creates and shows a UIMediumSelector dialog. … … 528 529 const QString &strMachineGuestOSTypeId, bool fEnableCreate); 529 530 531 /** Creates and shows a dialog (wizard) to create a medium of type @a enmMediumType. 532 * @param parent Passes the parent of the dialog, 533 * @param enmMediumType Passes the medium type. 534 * @param strMachineName Passes the name of the machine, 535 * @param strMachineFolder Passes the machine folder, 536 * @param strMachineGuestOSTypeId Passes the type ID of machine's guest os, 537 * @param fEnableCreate Passes whether to show/enable create action in the medium selector dialog, 538 * returns the return code of the UIMediumSelector::ReturnCode as int. In case of a medium selection 539 * UUID of the selected medium is stored in @param outUuid.*/ 540 QUuid openMediumCreatorDialog(QWidget *pParent, UIMediumDeviceType enmMediumType, 541 const QString &strMachineFolder = QString(), const QString &strMachineName = QString(), 542 const QString &strMachineGuestOSTypeId = QString()); 543 544 530 545 /** Creates and shows a UIWizardNewVD wizard. 531 546 * @param parent Passes the parent of the wizard, 532 547 * @param strMachineGuestOSTypeId Passes the string of machine's guest OS type ID, 548 * @param strMachineFolder Passes the machine folder, 533 549 * @param strMachineName Passes the name of the machine, 534 * @param strMachineFolder Passes the machine folder,535 550 * returns the ID of the created hard disk if successful, a null QUuid otherwise.*/ 536 551 QUuid createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineGuestOSTypeId, 537 const QString &strMachine Name, const QString &strMachineFolder);552 const QString &strMachineFolder = QString(), const QString &strMachineName = QString()); 538 553 539 554 /** Prepares storage menu according passed parameters. … … 559 574 * @param strMediumLocation Passes the medium location. */ 560 575 void updateRecentlyUsedMediumListAndFolder(UIMediumDeviceType enmMediumType, QString strMediumLocation); 576 577 /** Searches extra data for the recently used folder path which corresponds to @a enmMediumType. When that search fails 578 it looks for recent folder extra data for other medium types. As the last resort returns default vm folder path. 579 * @param enmMediumType Passes the medium type. */ 580 QString defaultFolderPathForType(UIMediumDeviceType enmMediumType); 561 581 /** @} */ 562 582 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r77255 r77277 494 494 void UIMediumManagerWidget::sltCreateMedium() 495 495 { 496 vboxGlobal().openMediumCreatorDialog(this, currentMediumType()); 496 497 } 497 498 -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp
r77264 r77277 433 433 void UIMediumSelector::sltAddMedium() 434 434 { 435 QString strDefaultMachineFolder = vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder(); 436 QUuid uMediumID = vboxGlobal().openMediumWithFileOpenDialog(m_enmMediumType, this, strDefaultMachineFolder); 435 QUuid uMediumID = vboxGlobal().openMediumWithFileOpenDialog(m_enmMediumType, this, m_strMachineFolder); 437 436 if (uMediumID.isNull()) 438 437 return; … … 444 443 void UIMediumSelector::sltCreateMedium() 445 444 { 446 QUuid uMediumId; 447 448 switch (m_enmMediumType) 449 { 450 case UIMediumDeviceType_Floppy: 451 uMediumId = vboxGlobal().showCreateFloppyDiskDialog(this, m_strMachineName, m_strMachineFolder); 452 break; 453 case UIMediumDeviceType_HardDisk: 454 uMediumId = vboxGlobal().createHDWithNewHDWizard(this, m_strMachineGuestOSTypeId, m_strMachineName, m_strMachineFolder); 455 break; 456 case UIMediumDeviceType_DVD: 457 uMediumId = vboxGlobal().createVisoMediumWithVisoCreator(this, m_strMachineFolder, m_strMachineName); 458 break; 459 default: 460 break; 461 } 445 QUuid uMediumId = vboxGlobal().openMediumCreatorDialog(this, m_enmMediumType, m_strMachineFolder, 446 m_strMachineName, m_strMachineGuestOSTypeId); 462 447 if (!uMediumId.isNull()) 463 448 { -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r77238 r77277 3083 3083 { 3084 3084 const QUuid uMediumId = vboxGlobal().createHDWithNewHDWizard(this, m_strMachineGuestOSTypeId, 3085 m_strMachineName, m_strMachineSettingsFilePath); 3086 3085 m_strMachineSettingsFilePath, m_strMachineName); 3087 3086 if (!uMediumId.isNull()) 3088 3087 m_pMediumIdHolder->setId(uMediumId);
Note:
See TracChangeset
for help on using the changeset viewer.