VirtualBox

Changeset 77277 in vbox


Ignore:
Timestamp:
Feb 12, 2019 2:45:05 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128792
Message:

FE/Qt: bugref:9340. Adding a medium create action to virtualmedium manager. incomplete!

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  
    9191
    9292/* COM includes: */
     93#include "CAudioAdapter.h"
     94#include "CBIOSSettings.h"
     95#include "CConsole.h"
    9396#include "CExtPack.h"
    9497#include "CExtPackFile.h"
    9598#include "CExtPackManager.h"
     99#include "CHostUSBDevice.h"
     100#include "CHostVideoInputDevice.h"
    96101#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"
    103102#include "CMediumAttachment.h"
    104 #include "CAudioAdapter.h"
    105103#include "CNetworkAdapter.h"
    106104#include "CSerialPort.h"
     105#include "CSharedFolder.h"
     106#include "CSnapshot.h"
     107#include "CStorageController.h"
     108#include "CSystemProperties.h"
    107109#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"
    113114
    114115/* Other VBox includes: */
     
    25762577
    25772578QUuid VBoxGlobal::openMediumWithFileOpenDialog(UIMediumDeviceType enmMediumType, QWidget *pParent,
    2578                                                  const QString &strDefaultFolder /* = QString() */,
    2579                                                  bool fUseLastFolder /* = false */)
     2579                                               const QString &strDefaultFolder /* = QString() */,
     2580                                               bool fUseLastFolder /* = false */)
    25802581{
    25812582    /* Initialize variables: */
     
    25862587    QString strTitle;
    25872588    QString allType;
    2588     QString strLastFolder;
     2589    QString strLastFolder = defaultFolderPathForType(enmMediumType);
    25892590    switch (enmMediumType)
    25902591    {
     
    25942595            strTitle = tr("Please choose a virtual hard disk file");
    25952596            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();
    26012597            break;
    26022598        }
     
    26062602            strTitle = tr("Please choose a virtual optical disk file");
    26072603            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();
    26132604            break;
    26142605        }
     
    26182609            strTitle = tr("Please choose a virtual floppy disk file");
    26192610            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();
    26252611            break;
    26262612        }
     
    26882674
    26892675
    2690 QUuid VBoxGlobal::createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strFolder, const QString &strMachineName /* = QString */)
    2691 {
     2676QUuid 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
    26922683    QWidget *pDialogParent = windowManager().realParentWindow(pParent);
    26932684    QPointer<UIVisoCreator> pVisoCreator = new UIVisoCreator(pDialogParent, strMachineName);
     
    27132704        char szVisoPath[RTPATH_MAX];
    27142705        QString strFileName = QString("%1%2").arg(strVisoName).arg(".viso");
    2715         int vrc = RTPathJoin(szVisoPath, sizeof(szVisoPath), strFolder.toUtf8().constData(), strFileName.toUtf8().constData());
     2706        int vrc = RTPathJoin(szVisoPath, sizeof(szVisoPath), strDefaultFolder.toUtf8().constData(), strFileName.toUtf8().constData());
    27162707        if (RT_SUCCESS(vrc))
    27172708        {
     
    27612752}
    27622753
    2763 QUuid VBoxGlobal::showCreateFloppyDiskDialog(QWidget *pParent, const QString &strMachineName, const QString &strMachineFolder)
    2764 {
     2754QUuid 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
    27652762    QWidget *pDialogParent = windowManager().realParentWindow(pParent);
    27662763
    2767     UIFDCreationDialog *pDialog = new UIFDCreationDialog(pParent, strMachineFolder, strMachineName);
     2764    UIFDCreationDialog *pDialog = new UIFDCreationDialog(pParent, strStartPath, strMachineName);
    27682765    if (!pDialog)
    27692766        return QUuid();
     
    28142811}
    28152812
     2813QUuid 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
    28162838QUuid VBoxGlobal::createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineGuestOSTypeId,
    2817                                           const QString &strMachineName,
    2818                                           const QString &strMachineFolder)
     2839                                          const QString &strMachineFolder /* = QString() */,
     2840                                          const QString &strMachineName /* = QString() */)
    28192841{
    28202842    /* 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");
    28232850    /* Show New VD wizard: */
    2824     UISafePointerWizardNewVD pWizard = new UIWizardNewVD(pParent, strDiskName, strMachineFolder, comGuestOSType.GetRecommendedHDD());
     2851    UISafePointerWizardNewVD pWizard = new UIWizardNewVD(pParent, strDiskName, strDefaultFolder, comGuestOSType.GetRecommendedHDD());
    28252852
    28262853    if (!pWizard)
     
    30523079
    30533080                else if(target.type == UIMediumTarget::UIMediumTargetType_CreateFloppyDisk)
    3054                     uMediumID = showCreateFloppyDiskDialog(windowManager().mainWindowShown(), comConstMachine.GetName(), strMachineFolder);
     3081                    uMediumID = showCreateFloppyDiskDialog(windowManager().mainWindowShown(), strMachineFolder, comConstMachine.GetName());
    30553082
    30563083                /* Return focus back: */
     
    32493276        default: break;
    32503277    }
     3278}
     3279
     3280QString 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;
    32513314}
    32523315
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r77264 r77277  
    500500          * @param  fUseLastFolder    Brings whether we should propose to use last used folder. */
    501501        QUuid openMediumWithFileOpenDialog(UIMediumDeviceType enmMediumType, QWidget *pParent = 0,
    502                                              const QString &strDefaultFolder = QString(), bool fUseLastFolder = true);
     502                                             const QString &strDefaultFolder = QString(), bool fUseLastFolder = false);
    503503
    504504        /** Creates a VISO by using the VISO creator dialog.
    505           * @param  pParent    Brings the dialog parent.
    506           * @param  strFolder  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.
    507507          * @param  strMachineName    Passes the name of the machine, */
    508         QUuid createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strFolder, const QString &strMachineName = QString());
     508        QUuid createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strDefaultFolder = QString(), const QString &strMachineName = QString());
    509509
    510510        /** Creates and shows a dialog thru which user can create a new floppy disk a VISO using the file-open dialog.
    511511          * @param  parent            Passes the parent of the dialog,
     512          * @param  strDefaultFolder  Passes the default folder,
    512513          * @param  strMachineName    Passes the name of the machine,
    513           * @param  strMachineFolder  Passes the machine folder,
    514514          * 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());
    516517
    517518        /** Creates and shows a UIMediumSelector dialog.
     
    528529                                     const QString &strMachineGuestOSTypeId, bool fEnableCreate);
    529530
     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
    530545        /** Creates and shows a UIWizardNewVD wizard.
    531546          * @param  parent                    Passes the parent of the wizard,
    532547          * @param  strMachineGuestOSTypeId   Passes the string of machine's guest OS type ID,
     548          * @param  strMachineFolder          Passes the machine folder,
    533549          * @param  strMachineName            Passes the name of the machine,
    534           * @param  strMachineFolder          Passes the machine folder,
    535550          * returns the ID of the  created hard disk if successful, a null QUuid otherwise.*/
    536551        QUuid createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineGuestOSTypeId,
    537                                       const QString &strMachineName, const QString &strMachineFolder);
     552                                      const QString &strMachineFolder = QString(), const QString &strMachineName = QString());
    538553
    539554        /** Prepares storage menu according passed parameters.
     
    559574          * @param  strMediumLocation   Passes the medium location. */
    560575        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);
    561581    /** @} */
    562582
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp

    r77255 r77277  
    494494void UIMediumManagerWidget::sltCreateMedium()
    495495{
     496    vboxGlobal().openMediumCreatorDialog(this, currentMediumType());
    496497}
    497498
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp

    r77264 r77277  
    433433void UIMediumSelector::sltAddMedium()
    434434{
    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);
    437436    if (uMediumID.isNull())
    438437        return;
     
    444443void UIMediumSelector::sltCreateMedium()
    445444{
    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);
    462447    if (!uMediumId.isNull())
    463448    {
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r77238 r77277  
    30833083{
    30843084    const QUuid uMediumId = vboxGlobal().createHDWithNewHDWizard(this, m_strMachineGuestOSTypeId,
    3085                                                                  m_strMachineName, m_strMachineSettingsFilePath);
    3086 
     3085                                                                 m_strMachineSettingsFilePath, m_strMachineName);
    30873086    if (!uMediumId.isNull())
    30883087        m_pMediumIdHolder->setId(uMediumId);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette