VirtualBox

Ignore:
Timestamp:
Feb 13, 2019 9:13:50 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128808
Message:

FE/Qt: bugref:9340. Make all medium creation functions in VBoxGlobal private to have a single interface for medium creation.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r77278 r77291  
    26742674
    26752675
     2676QUuid VBoxGlobal::openMediumCreatorDialog(QWidget *pParent, UIMediumDeviceType  enmMediumType,
     2677                                          const QString &strDefaultFolder /* = QString() */, const QString &strMachineName /* = QString() */,
     2678                                          const QString &strMachineGuestOSTypeId /*= QString() */)
     2679{
     2680    QUuid uMediumId;
     2681
     2682    switch (enmMediumType)
     2683    {
     2684        case UIMediumDeviceType_Floppy:
     2685            uMediumId = showCreateFloppyDiskDialog(pParent, strDefaultFolder, strMachineName);
     2686            break;
     2687        case UIMediumDeviceType_HardDisk:
     2688            uMediumId = createHDWithNewHDWizard(pParent, strDefaultFolder, strMachineName, strMachineGuestOSTypeId);
     2689            break;
     2690        case UIMediumDeviceType_DVD:
     2691            uMediumId = createVisoMediumWithVisoCreator(pParent, strDefaultFolder, strMachineName);
     2692            break;
     2693        default:
     2694            break;
     2695    }
     2696
     2697    return uMediumId;
     2698}
     2699
    26762700QUuid VBoxGlobal::createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strDefaultFolder /* = QString */,
    26772701                                                  const QString &strMachineName /* = QString */)
     
    27772801
    27782802int VBoxGlobal::openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType  enmMediumType, QUuid &outUuid,
    2779                                          const QString &strMachineName, const QString &strMachineFolder,
     2803                                         const QString &strMachineFolder, const QString &strMachineName,
    27802804                                         const QString &strMachineGuestOSTypeId, bool fEnableCreate)
    27812805{
     
    28112835}
    28122836
    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 
    2838 QUuid VBoxGlobal::createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineGuestOSTypeId,
     2837QUuid VBoxGlobal::createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineGuestOSTypeId  /* = QString() */,
    28392838                                          const QString &strMachineFolder /* = QString() */,
    28402839                                          const QString &strMachineName /* = QString() */)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r77277 r77291  
    502502                                             const QString &strDefaultFolder = QString(), bool fUseLastFolder = false);
    503503
    504         /** Creates a VISO by using the VISO creator dialog.
    505           * @param  pParent           Passes the dialog parent.
    506           * @param  strDefaultFolder  Passes the folder to save the VISO file.
    507           * @param  strMachineName    Passes the name of the machine, */
    508         QUuid createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strDefaultFolder = QString(), const QString &strMachineName = QString());
    509 
    510         /** Creates and shows a dialog thru which user can create a new floppy disk a VISO using the file-open dialog.
    511           * @param  parent            Passes the parent of the dialog,
    512           * @param  strDefaultFolder  Passes the default folder,
    513           * @param  strMachineName    Passes the name of the machine,
    514           * returns the ID of the newly created medium if successful, a null QUuid otherwise.*/
    515         QUuid showCreateFloppyDiskDialog(QWidget *pParent, const QString &strDefaultFolder = QString(),
    516                                          const QString &strMachineName = QString());
    517504
    518505        /** Creates and shows a UIMediumSelector dialog.
     
    526513          *         UUID of the selected medium is stored in @param outUuid.*/
    527514        int openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType  enmMediumType, QUuid &outUuid,
    528                                      const QString &strMachineName, const QString &strMachineFolder,
     515                                     const QString &strMachineFolder, const QString &strMachineName,
    529516                                     const QString &strMachineGuestOSTypeId, bool fEnableCreate);
    530517
     
    543530
    544531
    545         /** Creates and shows a UIWizardNewVD wizard.
    546           * @param  parent                    Passes the parent of the wizard,
    547           * @param  strMachineGuestOSTypeId   Passes the string of machine's guest OS type ID,
    548           * @param  strMachineFolder          Passes the machine folder,
    549           * @param  strMachineName            Passes the name of the machine,
    550           * returns the ID of the  created hard disk if successful, a null QUuid otherwise.*/
    551         QUuid createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineGuestOSTypeId,
    552                                       const QString &strMachineFolder = QString(), const QString &strMachineName = QString());
    553 
    554532        /** Prepares storage menu according passed parameters.
    555533          * @param  menu               Brings the #QMenu to be prepared.
     
    713691    /** Destrucs global VirtualBox object. */
    714692    virtual ~VBoxGlobal() /* override */;
     693
     694
     695    /** @name COM: Virtual Media create functions.
     696     * @{ */
     697
     698        /** Creates a VISO by using the VISO creator dialog.
     699          * @param  pParent           Passes the dialog parent.
     700          * @param  strDefaultFolder  Passes the folder to save the VISO file.
     701          * @param  strMachineName    Passes the name of the machine, */
     702        QUuid createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strDefaultFolder = QString(), const QString &strMachineName = QString());
     703
     704        /** Creates and shows a dialog thru which user can create a new floppy disk a VISO using the file-open dialog.
     705          * @param  parent            Passes the parent of the dialog,
     706          * @param  strDefaultFolder  Passes the default folder,
     707          * @param  strMachineName    Passes the name of the machine,
     708          * returns the ID of the newly created medium if successful, a null QUuid otherwise.*/
     709        QUuid showCreateFloppyDiskDialog(QWidget *pParent, const QString &strDefaultFolder = QString(),
     710                                         const QString &strMachineName = QString());
     711
     712        /** Creates and shows a UIWizardNewVD wizard.
     713          * @param  parent                    Passes the parent of the wizard,
     714          * @param  strMachineFolder          Passes the machine folder,
     715          * @param  strMachineName            Passes the name of the machine,
     716          * @param  strMachineGuestOSTypeId   Passes the string of machine's guest OS type ID,
     717          * returns the ID of the  created hard disk if successful, a null QUuid otherwise.*/
     718        QUuid createHDWithNewHDWizard(QWidget *pParent, const QString &strMachineFolder = QString(),
     719                                      const QString &strMachineName = QString(), const QString &strMachineGuestOSTypeId = QString());
     720    /** @} */
    715721
    716722    /** @name Common stuff.
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp

    r77277 r77291  
    156156    prepareWidgets();
    157157    prepareActions();
     158    prepareMenuAndToolBar();
    158159    prepareConnections();
    159160}
     
    182183    {
    183184        /* Configure add-action: */
    184         m_pActionAdd->setShortcut(QKeySequence("Ctrl+A"));
     185        m_pActionAdd->setShortcut(QKeySequence(""));
    185186
    186187        m_pActionAdd->setIcon(UIIconPool::iconSetFull(QString(":/%1_add_32px.png").arg(strPrefix),
     
    188189                                                      QString(":/%1_add_disabled_32px.png").arg(strPrefix),
    189190                                                      QString(":/%1_add_disabled_16px.png").arg(strPrefix)));
    190         if (m_pMainMenu)
    191             m_pMainMenu->addAction(m_pActionAdd);
    192         if (m_pToolBar)
    193             m_pToolBar->addAction(m_pActionAdd);
     191
    194192    }
    195193
     
    197195    if (m_pActionCreate)
    198196    {
    199 
    200         m_pActionCreate->setShortcut(QKeySequence("Ctrl+C"));
     197        m_pActionCreate->setShortcut(QKeySequence(""));
    201198        m_pActionCreate->setIcon(UIIconPool::iconSetFull(QString(":/%1_create_32px.png").arg(strPrefix),
    202199                                                         QString(":/%1_create_16px.png").arg(strPrefix),
    203200                                                         QString(":/%1_create_disabled_32px.png").arg(strPrefix),
    204201                                                         QString(":/%1_create_disabled_16px.png").arg(strPrefix)));
    205         if (m_pMainMenu)
    206             m_pMainMenu->addAction(m_pActionCreate);
    207         if (m_pToolBar)
    208             m_pToolBar->addAction(m_pActionCreate);
    209202    }
    210203
     
    213206    if (m_pActionRefresh)
    214207    {
    215         m_pActionRefresh->setShortcut(QKeySequence(QKeySequence::Refresh));
     208        m_pActionRefresh->setShortcut(QKeySequence());
    216209        if (m_pActionRefresh && m_pActionRefresh->icon().isNull())
    217210            m_pActionRefresh->setIcon(UIIconPool::iconSetFull(":/refresh_32px.png", ":/refresh_16px.png",
    218211                                                              ":/refresh_disabled_32px.png", ":/refresh_disabled_16px.png"));
    219         if (m_pMainMenu)
    220             m_pMainMenu->addAction(m_pActionRefresh);
    221         if (m_pToolBar)
    222             m_pToolBar->addAction(m_pActionRefresh);
    223     }
     212    }
     213}
     214
     215void UIMediumSelector::prepareMenuAndToolBar()
     216{
     217    if (!m_pMainMenu || !m_pToolBar)
     218        return;
     219
     220    m_pMainMenu->addAction(m_pActionAdd);
     221    m_pMainMenu->addAction(m_pActionCreate);
     222    m_pMainMenu->addSeparator();
     223    m_pMainMenu->addAction(m_pActionRefresh);
     224
     225    m_pToolBar->addAction(m_pActionAdd);
     226    m_pToolBar->addAction(m_pActionCreate);
     227    m_pToolBar->addSeparator();
     228    m_pToolBar->addAction(m_pActionRefresh);
    224229}
    225230
     
    748753    {
    749754        case UIMediumDeviceType_DVD:
    750             setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Optical Disk Selector")));
     755            if (!m_strMachineName.isEmpty())
     756                setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Optical Disk Selector")));
     757            else
     758                setWindowTitle(QString("%1").arg(tr("Optical Disk Selector")));
    751759            break;
    752760        case UIMediumDeviceType_Floppy:
    753             setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Floppy Disk Selector")));
     761            if (!m_strMachineName.isEmpty())
     762                setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Floppy Disk Selector")));
     763            else
     764                setWindowTitle(QString("%1").arg(tr("Floppy Disk Selector")));
    754765            break;
    755766        case UIMediumDeviceType_HardDisk:
    756             setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Hard Disk Selector")));
     767            if (!m_strMachineName.isEmpty())
     768                setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Hard Disk Selector")));
     769            else
     770                setWindowTitle(QString("%1").arg(tr("Hard Disk Selector")));
    757771            break;
    758772        case UIMediumDeviceType_All:
    759773        case UIMediumDeviceType_Invalid:
    760774        default:
    761             setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Virtual Medium Selector")));
    762             break;
    763     }
    764 }
     775            if (!m_strMachineName.isEmpty())
     776                setWindowTitle(QString("%1 - %2").arg(m_strMachineName).arg(tr("Virtual Medium Selector")));
     777            else
     778                setWindowTitle(QString("%1").arg(tr("Virtual Medium Selector")));
     779            break;
     780    }
     781}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h

    r77217 r77291  
    104104            void prepareWidgets();
    105105            void prepareActions();
     106            void prepareMenuAndToolBar();
    106107            void prepareConnections();
    107108        /** Perform final preparations. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r77277 r77291  
    30823082void UIMachineSettingsStorage::sltCreateNewHardDisk()
    30833083{
    3084     const QUuid uMediumId = vboxGlobal().createHDWithNewHDWizard(this, m_strMachineGuestOSTypeId,
    3085                                                                  m_strMachineSettingsFilePath, m_strMachineName);
     3084    const QUuid uMediumId = vboxGlobal().openMediumCreatorDialog(this, UIMediumDeviceType_HardDisk, m_strMachineSettingsFilePath,
     3085                                                                 m_strMachineName, m_strMachineGuestOSTypeId);
     3086
    30863087    if (!uMediumId.isNull())
    30873088        m_pMediumIdHolder->setId(uMediumId);
     
    30993100    QUuid uMediumId;
    31003101    int iResult = vboxGlobal().openMediumSelectorDialog(this, m_pMediumIdHolder->type(), uMediumId,
    3101                                                         m_strMachineName, strMachineFolder,
     3102                                                        strMachineFolder, m_strMachineName,
    31023103                                                        m_strMachineGuestOSTypeId, true /* enable create action: */);
    31033104
     
    38113812    QUuid uMediumId;
    38123813    int iResult = vboxGlobal().openMediumSelectorDialog(this, UIMediumDefs::mediumTypeToLocal(enmDevice), uMediumId,
    3813                                                         m_strMachineName, strMachineFolder,
     3814                                                        strMachineFolder, m_strMachineName,
    38143815                                                        m_strMachineGuestOSTypeId, true /* enable cr1eate action: */);
    38153816
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMPageBasic3.cpp

    r77217 r77291  
    6767    int returnCode = vboxGlobal().openMediumSelectorDialog(thisImp(), UIMediumDeviceType_HardDisk,
    6868                                                           uMediumId,
     69                                                           fieldImp("machineFolder").toString(),
    6970                                                           fieldImp("machineBaseName").toString(),
    70                                                            fieldImp("machineFolder").toString(),
    7171                                                           fieldImp("type").value<CGuestOSType>().GetId(),
    7272                                                           false /* don't show/enable the create action: */);
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