VirtualBox

Changeset 92588 in vbox


Ignore:
Timestamp:
Nov 24, 2021 7:48:54 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148472
Message:

FE/Qt: Moving several virtual media related dialog initilization from UICommon to respective class.

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

Legend:

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

    r92414 r92588  
    16901690    {
    16911691        case UIMediumDeviceType_HardDisk:
    1692             uMediumId = createVDWithWizard(pParent, strDefaultFolder, strMachineName, strMachineGuestOSTypeId);
     1692            uMediumId = UIWizardNewVD::createVDWithWizard(pParent, strDefaultFolder, strMachineName, strMachineGuestOSTypeId);
    16931693            break;
    16941694        case UIMediumDeviceType_DVD:
    1695             uMediumId = createVisoMediumWithVisoCreator(pActionPool, pParent, strDefaultFolder, strMachineName);
     1695            uMediumId = UIVisoCreatorWidget::createViso(pActionPool, pParent, strDefaultFolder, strMachineName);
    16961696            break;
    16971697        case UIMediumDeviceType_Floppy:
    1698             uMediumId = showCreateFloppyDiskDialog(pParent, strDefaultFolder, strMachineName);
     1698            uMediumId = UIFDCreationDialog::createFloppyDisk(pParent, strDefaultFolder, strMachineName);
    16991699            break;
    17001700        default:
     
    17081708        updateRecentlyUsedMediumListAndFolder(enmMediumType, medium(uMediumId).location());
    17091709    return uMediumId;
    1710 }
    1711 
    1712 QUuid UICommon::createVisoMediumWithVisoCreator(UIActionPool *pActionPool, QWidget *pParent, const QString &strDefaultFolder /* = QString */,
    1713                                                 const QString &strMachineName /* = QString */)
    1714 {
    1715     QWidget *pDialogParent = windowManager().realParentWindow(pParent);
    1716     UIVisoCreatorDialog *pVisoCreator = new UIVisoCreatorDialog(pActionPool, pDialogParent, strMachineName);
    1717 
    1718     if (!pVisoCreator)
    1719         return QString();
    1720     windowManager().registerNewParent(pVisoCreator, pDialogParent);
    1721     pVisoCreator->setCurrentPath(gEDataManager->visoCreatorRecentFolder());
    1722 
    1723     if (pVisoCreator->exec(false /* not application modal */))
    1724     {
    1725         QStringList files = pVisoCreator->entryList();
    1726         QString strVisoName = pVisoCreator->visoName();
    1727         if (strVisoName.isEmpty())
    1728             strVisoName = strMachineName;
    1729 
    1730         if (files.empty() || files[0].isEmpty())
    1731         {
    1732             delete pVisoCreator;
    1733             return QUuid();
    1734         }
    1735 
    1736         gEDataManager->setVISOCreatorRecentFolder(pVisoCreator->currentPath());
    1737 
    1738         /* Produce the VISO. */
    1739         char szVisoPath[RTPATH_MAX];
    1740         QString strFileName = QString("%1%2").arg(strVisoName).arg(".viso");
    1741 
    1742         QString strVisoSaveFolder(strDefaultFolder);
    1743         if (strVisoSaveFolder.isEmpty())
    1744             strVisoSaveFolder = defaultFolderPathForType(UIMediumDeviceType_DVD);
    1745 
    1746         int vrc = RTPathJoin(szVisoPath, sizeof(szVisoPath), strVisoSaveFolder.toUtf8().constData(), strFileName.toUtf8().constData());
    1747         if (RT_SUCCESS(vrc))
    1748         {
    1749             PRTSTREAM pStrmViso;
    1750             vrc = RTStrmOpen(szVisoPath, "w", &pStrmViso);
    1751             if (RT_SUCCESS(vrc))
    1752             {
    1753                 RTUUID Uuid;
    1754                 vrc = RTUuidCreate(&Uuid);
    1755                 if (RT_SUCCESS(vrc))
    1756                 {
    1757                     RTStrmPrintf(pStrmViso, "--iprt-iso-maker-file-marker-bourne-sh %RTuuid\n", &Uuid);
    1758                     vrc = UIVisoCreatorWidget::visoWriteQuotedString(pStrmViso, "--volume-id=", strVisoName, "\n");
    1759 
    1760                     for (int iFile = 0; iFile < files.size() && RT_SUCCESS(vrc); iFile++)
    1761                         vrc = UIVisoCreatorWidget::visoWriteQuotedString(pStrmViso, NULL, files[iFile], "\n");
    1762 
    1763                     /* Append custom options if any to the file: */
    1764                     const QStringList &customOptions = pVisoCreator->customOptions();
    1765                     foreach (QString strLine, customOptions)
    1766                         RTStrmPrintf(pStrmViso, "%s\n", strLine.toUtf8().constData());
    1767 
    1768                     RTStrmFlush(pStrmViso);
    1769                     if (RT_SUCCESS(vrc))
    1770                         vrc = RTStrmError(pStrmViso);
    1771                 }
    1772 
    1773                 RTStrmClose(pStrmViso);
    1774             }
    1775         }
    1776 
    1777         /* Done. */
    1778         if (RT_SUCCESS(vrc))
    1779         {
    1780             delete pVisoCreator;
    1781             return openMedium(UIMediumDeviceType_DVD, QString(szVisoPath), pParent);
    1782         }
    1783         /** @todo error message. */
    1784         else
    1785         {
    1786             delete pVisoCreator;
    1787             return QUuid();
    1788         }
    1789     }
    1790     delete pVisoCreator;
    1791     return QUuid();
    1792 }
    1793 
    1794 QUuid UICommon::showCreateFloppyDiskDialog(QWidget *pParent, const QString &strDefaultFolder /* QString() */,
    1795                                              const QString &strMachineName /* = QString() */ )
    1796 {
    1797     QString strStartPath(strDefaultFolder);
    1798 
    1799     if (strStartPath.isEmpty())
    1800         strStartPath = defaultFolderPathForType(UIMediumDeviceType_Floppy);
    1801 
    1802     QWidget *pDialogParent = windowManager().realParentWindow(pParent);
    1803 
    1804     UIFDCreationDialog *pDialog = new UIFDCreationDialog(pParent, strStartPath, strMachineName);
    1805     if (!pDialog)
    1806         return QUuid();
    1807     windowManager().registerNewParent(pDialog, pDialogParent);
    1808 
    1809     if (pDialog->exec())
    1810     {
    1811         QUuid uMediumID = pDialog->mediumID();
    1812         delete pDialog;
    1813         return uMediumID;
    1814     }
    1815     delete pDialog;
    1816     return QUuid();
    1817 }
    1818 
    1819 int UICommon::openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType  enmMediumType, const QUuid &uCurrentMediumId,
    1820                                        QUuid &uSelectedMediumUuid, const QString &strMachineFolder, const QString &strMachineName,
    1821                                        const QString &strMachineGuestOSTypeId, bool fEnableCreate, const QUuid &uMachineID,
    1822                                        UIActionPool *pActionPool)
    1823 {
    1824     QUuid uMachineOrGlobalId = uMachineID == QUuid() ? gEDataManager->GlobalID : uMachineID;
    1825 
    1826     QWidget *pDialogParent = windowManager().realParentWindow(pParent);
    1827     QPointer<UIMediumSelector> pSelector = new UIMediumSelector(uCurrentMediumId, enmMediumType, strMachineName,
    1828                                                                 strMachineFolder, strMachineGuestOSTypeId,
    1829                                                                 uMachineOrGlobalId, pDialogParent, pActionPool);
    1830 
    1831     if (!pSelector)
    1832         return static_cast<int>(UIMediumSelector::ReturnCode_Rejected);
    1833     pSelector->setEnableCreateAction(fEnableCreate);
    1834     windowManager().registerNewParent(pSelector, pDialogParent);
    1835 
    1836     int iResult = pSelector->exec(false);
    1837     UIMediumSelector::ReturnCode returnCode;
    1838 
    1839     if (iResult >= static_cast<int>(UIMediumSelector::ReturnCode_Max) || iResult < 0)
    1840         returnCode = UIMediumSelector::ReturnCode_Rejected;
    1841     else
    1842         returnCode = static_cast<UIMediumSelector::ReturnCode>(iResult);
    1843 
    1844     if (returnCode == UIMediumSelector::ReturnCode_Accepted)
    1845     {
    1846         QList<QUuid> selectedMediumIds = pSelector->selectedMediumIds();
    1847 
    1848         /* Currently we only care about the 0th since we support single selection by intention: */
    1849         if (selectedMediumIds.isEmpty())
    1850             returnCode = UIMediumSelector::ReturnCode_Rejected;
    1851         else
    1852         {
    1853             uSelectedMediumUuid = selectedMediumIds[0];
    1854             updateRecentlyUsedMediumListAndFolder(enmMediumType, medium(uSelectedMediumUuid).location());
    1855         }
    1856     }
    1857     delete pSelector;
    1858     return static_cast<int>(returnCode);
    1859 }
    1860 
    1861 QUuid UICommon::createVDWithWizard(QWidget *pParent,
    1862                                    const QString &strMachineFolder /* = QString() */,
    1863                                    const QString &strMachineName /* = QString() */,
    1864                                    const QString &strMachineGuestOSTypeId  /* = QString() */)
    1865 {
    1866     /* Initialize variables: */
    1867     QString strDefaultFolder = strMachineFolder;
    1868     if (strDefaultFolder.isEmpty())
    1869         strDefaultFolder = defaultFolderPathForType(UIMediumDeviceType_HardDisk);
    1870 
    1871     /* In case we dont have a 'guest os type id' default back to 'Other': */
    1872     const CGuestOSType comGuestOSType = virtualBox().GetGuestOSType(  !strMachineGuestOSTypeId.isEmpty()
    1873                                                                     ? strMachineGuestOSTypeId
    1874                                                                     : "Other");
    1875     const QString strDiskName = findUniqueFileName(strDefaultFolder,   !strMachineName.isEmpty()
    1876                                                                      ? strMachineName
    1877                                                                      : "NewVirtualDisk");
    1878 
    1879     /* Show New VD wizard: */
    1880     UISafePointerWizardNewVD pWizard = new UIWizardNewVD(pParent,
    1881                                                          strDiskName,
    1882                                                          strDefaultFolder,
    1883                                                          comGuestOSType.GetRecommendedHDD());
    1884     if (!pWizard)
    1885         return QUuid();
    1886     QWidget *pDialogParent = windowManager().realParentWindow(pParent);
    1887     windowManager().registerNewParent(pWizard, pDialogParent);
    1888     QUuid mediumId = pWizard->mediumId();
    1889     pWizard->exec();
    1890     delete pWizard;
    1891     return mediumId;
    18921710}
    18931711
     
    20911909                if (target.type == UIMediumTarget::UIMediumTargetType_WithID)
    20921910                {
    2093                     int iDialogReturn = openMediumSelectorDialog(windowManager().mainWindowShown(), target.mediumType,
    2094                                                                  uCurrentID, uMediumID,
    2095                                                                  strMachineFolder, comConstMachine.GetName(),
    2096                                                                  comConstMachine.GetOSTypeId(), true /*fEnableCreate */,
    2097                                                                  comConstMachine.GetId(), pActionPool);
     1911                    int iDialogReturn = UIMediumSelector::openMediumSelectorDialog(windowManager().mainWindowShown(), target.mediumType,
     1912                                                                                   uCurrentID, uMediumID,
     1913                                                                                   strMachineFolder, comConstMachine.GetName(),
     1914                                                                                   comConstMachine.GetOSTypeId(), true /*fEnableCreate */,
     1915                                                                                   comConstMachine.GetId(), pActionPool);
    20981916                    if (iDialogReturn == UIMediumSelector::ReturnCode_LeftEmpty &&
    20991917                        (target.mediumType == UIMediumDeviceType_DVD || target.mediumType == UIMediumDeviceType_Floppy))
     
    21061924                }
    21071925                else if(target.type == UIMediumTarget::UIMediumTargetType_CreateAdHocVISO)
    2108                     uMediumID = createVisoMediumWithVisoCreator(pActionPool, windowManager().mainWindowShown(), strMachineFolder,
    2109                                                                 comConstMachine.GetName());
     1926                    uMediumID = UIVisoCreatorWidget::createViso(pActionPool, windowManager().mainWindowShown(),
     1927                                                                strMachineFolder, comConstMachine.GetName());
    21101928
    21111929                else if(target.type == UIMediumTarget::UIMediumTargetType_CreateFloppyDisk)
    2112                     uMediumID = showCreateFloppyDiskDialog(windowManager().mainWindowShown(), strMachineFolder, comConstMachine.GetName());
     1930                    uMediumID = UIFDCreationDialog::createFloppyDisk(windowManager().mainWindowShown(), strMachineFolder, comConstMachine.GetName());
    21131931
    21141932                /* Return focus back: */
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UICommon.h

    r92413 r92588  
    407407                                           const QString &strDefaultFolder = QString(), bool fUseLastFolder = false);
    408408
    409         /** Creates and shows a UIMediumSelector dialog.
    410           * @param  parent                   Passes the parent of the dialog,
    411           * @param  enmMediumType            Passes the medium type,
    412           * @param  uCurrentMediumId         Passes  the id of the currently selected medium,
    413           * @param  uSelectedMediumUuid      Gets  the selected medium id from selection dialog,
    414           * @param  strMachineFolder         Passes the machine folder,
    415           * @param  strMachineName           Passes the name of the machine,
    416           * @param  strMachineGuestOSTypeId  Passes the type ID of machine's guest os,
    417           * @param  fEnableCreate            Passes whether to show/enable create action in the medium selector dialog,
    418           * @param  uMachineID               Passes the machine UUID,
    419           * @param  pActionPool              Passes the action pool instance pointer,
    420           * returns the return code of the UIMediumSelector::ReturnCode as int. In case of a medium selection
    421           *         UUID of the selected medium is stored in @param inOutUuid.*/
    422         int openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType  enmMediumType, const QUuid &uCurrentMediumId,
    423                                      QUuid &uSelectedMediumUuid, const QString &strMachineFolder, const QString &strMachineName,
    424                                      const QString &strMachineGuestOSTypeId, bool fEnableCreate, const QUuid &uMachineID,
    425                                      UIActionPool *pActionPool);
    426 
    427409        /** Creates and shows a dialog (wizard) to create a medium of type @a enmMediumType.
    428410          * @param  pParent                  Passes the parent of the dialog,
     
    607589    /** Cleanups all. */
    608590    void cleanup();
    609 
    610     /** @name COM: Virtual Media create functions.
    611      * @{ */
    612 
    613         /** Creates a VISO by using the VISO creator dialog.
    614           * @param  pParent           Passes the dialog parent.
    615           * @param  strDefaultFolder  Passes the folder to save the VISO file.
    616           * @param  strMachineName    Passes the name of the machine, */
    617         QUuid createVisoMediumWithVisoCreator(UIActionPool *pActionPool, QWidget *pParent,
    618                                               const QString &strDefaultFolder = QString(), const QString &strMachineName = QString());
    619 
    620         /** Creates and shows a dialog thru which user can create a new floppy disk a VISO using the file-open dialog.
    621           * @param  parent            Passes the parent of the dialog,
    622           * @param  strDefaultFolder  Passes the default folder,
    623           * @param  strMachineName    Passes the name of the machine,
    624           * returns the ID of the newly created medium if successful, a null QUuid otherwise.*/
    625         QUuid showCreateFloppyDiskDialog(QWidget *pParent, const QString &strDefaultFolder = QString(),
    626                                          const QString &strMachineName = QString());
    627 
    628         /** Creates and shows a UIWizardNewVD wizard.
    629           * @param  pParent                   Passes the parent of the wizard,
    630           * @param  strMachineFolder          Passes the machine folder,
    631           * @param  strMachineName            Passes the name of the machine,
    632           * @param  strMachineGuestOSTypeId   Passes the string of machine's guest OS type ID,
    633           * returns QUuid of the created medium. */
    634         QUuid createVDWithWizard(QWidget *pParent,
    635                                  const QString &strMachineFolder = QString(),
    636                                  const QString &strMachineName = QString(),
    637                                  const QString &strMachineGuestOSTypeId = QString());
    638     /** @} */
    639591
    640592    /** @name Process arguments stuff.
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.cpp

    r91350 r92588  
    3131#include "UIMessageCenter.h"
    3232#include "UINotificationCenter.h"
     33#include "UIModalWindowManager.h"
    3334
    3435/* COM includes: */
     
    5960}
    6061
     62/* static */
     63QUuid UIFDCreationDialog::createFloppyDisk(QWidget *pParent, const QString &strDefaultFolder /* QString() */,
     64                                           const QString &strMachineName /* = QString() */ )
     65{
     66    QString strStartPath(strDefaultFolder);
     67
     68    if (strStartPath.isEmpty())
     69        strStartPath = uiCommon().defaultFolderPathForType(UIMediumDeviceType_Floppy);
     70
     71    QWidget *pDialogParent = windowManager().realParentWindow(pParent);
     72
     73    UIFDCreationDialog *pDialog = new UIFDCreationDialog(pParent, strStartPath, strMachineName);
     74    if (!pDialog)
     75        return QUuid();
     76    windowManager().registerNewParent(pDialog, pDialogParent);
     77
     78    if (pDialog->exec())
     79    {
     80        QUuid uMediumID = pDialog->mediumID();
     81        delete pDialog;
     82        return uMediumID;
     83    }
     84    delete pDialog;
     85    return QUuid();
     86}
     87
    6188void UIFDCreationDialog::accept()
    6289{
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.h

    r91350 r92588  
    5353    /** Return the medium ID. */
    5454    QUuid mediumID() const;
     55
     56    /** Creates and shows a dialog thru which user can create a new floppy disk a VISO using the file-open dialog.
     57      * @param  parent            Passes the parent of the dialog,
     58      * @param  strDefaultFolder  Passes the default folder,
     59      * @param  strMachineName    Passes the name of the machine,
     60      * returns the UUID of the newly created medium if successful, a null QUuid otherwise.*/
     61    static QUuid createFloppyDisk(QWidget *pParent, const QString &strDefaultFolder = QString(),
     62                           const QString &strMachineName = QString());
     63
    5564
    5665public slots:
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp

    r92440 r92588  
    116116}
    117117
     118/* static */
     119int UIMediumSelector::openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType  enmMediumType, const QUuid &uCurrentMediumId,
     120                                               QUuid &uSelectedMediumUuid, const QString &strMachineFolder, const QString &strMachineName,
     121                                               const QString &strMachineGuestOSTypeId, bool fEnableCreate, const QUuid &uMachineID,
     122                                               UIActionPool *pActionPool)
     123{
     124    QUuid uMachineOrGlobalId = uMachineID == QUuid() ? gEDataManager->GlobalID : uMachineID;
     125
     126    QWidget *pDialogParent = windowManager().realParentWindow(pParent);
     127    QPointer<UIMediumSelector> pSelector = new UIMediumSelector(uCurrentMediumId, enmMediumType, strMachineName,
     128                                                                strMachineFolder, strMachineGuestOSTypeId,
     129                                                                uMachineOrGlobalId, pDialogParent, pActionPool);
     130
     131    if (!pSelector)
     132        return static_cast<int>(UIMediumSelector::ReturnCode_Rejected);
     133    pSelector->setEnableCreateAction(fEnableCreate);
     134    windowManager().registerNewParent(pSelector, pDialogParent);
     135
     136    int iResult = pSelector->exec(false);
     137    UIMediumSelector::ReturnCode returnCode;
     138
     139    if (iResult >= static_cast<int>(UIMediumSelector::ReturnCode_Max) || iResult < 0)
     140        returnCode = UIMediumSelector::ReturnCode_Rejected;
     141    else
     142        returnCode = static_cast<UIMediumSelector::ReturnCode>(iResult);
     143
     144    if (returnCode == UIMediumSelector::ReturnCode_Accepted)
     145    {
     146        QList<QUuid> selectedMediumIds = pSelector->selectedMediumIds();
     147
     148        /* Currently we only care about the 0th since we support single selection by intention: */
     149        if (selectedMediumIds.isEmpty())
     150            returnCode = UIMediumSelector::ReturnCode_Rejected;
     151        else
     152        {
     153            uSelectedMediumUuid = selectedMediumIds[0];
     154            uiCommon().updateRecentlyUsedMediumListAndFolder(enmMediumType, uiCommon().medium(uSelectedMediumUuid).location());
     155        }
     156    }
     157    delete pSelector;
     158    return static_cast<int>(returnCode);
     159}
     160
    118161void UIMediumSelector::retranslateUi()
    119162{
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.h

    r92440 r92588  
    6666        ReturnCode_Max
    6767    };
     68
     69    /** Creates and shows a UIMediumSelector dialog.
     70      * @param  parent                   Passes the parent of the dialog,
     71      * @param  enmMediumType            Passes the medium type,
     72      * @param  uCurrentMediumId         Passes  the id of the currently selected medium,
     73      * @param  uSelectedMediumUuid      Gets  the selected medium id from selection dialog,
     74      * @param  strMachineFolder         Passes the machine folder,
     75      * @param  strMachineName           Passes the name of the machine,
     76      * @param  strMachineGuestOSTypeId  Passes the type ID of machine's guest os,
     77      * @param  fEnableCreate            Passes whether to show/enable create action in the medium selector dialog,
     78      * @param  uMachineID               Passes the machine UUID,
     79      * @param  pActionPool              Passes the action pool instance pointer,
     80      * returns the return code of the UIMediumSelector::ReturnCode as int. In case of a medium selection
     81      *         UUID of the selected medium is returned in @param uSelectedMediumUuid.*/
     82    static int openMediumSelectorDialog(QWidget *pParent, UIMediumDeviceType  enmMediumType, const QUuid &uCurrentMediumId,
     83                                        QUuid &uSelectedMediumUuid, const QString &strMachineFolder, const QString &strMachineName,
     84                                        const QString &strMachineGuestOSTypeId, bool fEnableCreate, const QUuid &uMachineID,
     85                                        UIActionPool *pActionPool);
    6886
    6987protected:
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.cpp

    r92504 r92588  
    4141#endif
    4242
     43/* Other VBox includes: */
    4344#include <iprt/getopt.h>
     45#include <iprt/path.h>
    4446
    4547
     
    510512}
    511513
     514/* static */
     515QUuid UIVisoCreatorWidget::createViso(UIActionPool *pActionPool, QWidget *pParent,
     516                                      const QString &strDefaultFolder /* = QString() */,
     517                                      const QString &strMachineName /* = QString() */)
     518{
     519    QWidget *pDialogParent = windowManager().realParentWindow(pParent);
     520    UIVisoCreatorDialog *pVisoCreator = new UIVisoCreatorDialog(pActionPool, pDialogParent, strMachineName);
     521
     522    if (!pVisoCreator)
     523        return QString();
     524    windowManager().registerNewParent(pVisoCreator, pDialogParent);
     525    pVisoCreator->setCurrentPath(gEDataManager->visoCreatorRecentFolder());
     526
     527    if (pVisoCreator->exec(false /* not application modal */))
     528    {
     529        QStringList files = pVisoCreator->entryList();
     530        QString strVisoName = pVisoCreator->visoName();
     531        if (strVisoName.isEmpty())
     532            strVisoName = strMachineName;
     533
     534        if (files.empty() || files[0].isEmpty())
     535        {
     536            delete pVisoCreator;
     537            return QUuid();
     538        }
     539
     540        gEDataManager->setVISOCreatorRecentFolder(pVisoCreator->currentPath());
     541
     542        /* Produce the VISO. */
     543        char szVisoPath[RTPATH_MAX];
     544        QString strFileName = QString("%1%2").arg(strVisoName).arg(".viso");
     545
     546        QString strVisoSaveFolder(strDefaultFolder);
     547        if (strVisoSaveFolder.isEmpty())
     548            strVisoSaveFolder = uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD);
     549
     550        int vrc = RTPathJoin(szVisoPath, sizeof(szVisoPath), strVisoSaveFolder.toUtf8().constData(), strFileName.toUtf8().constData());
     551        if (RT_SUCCESS(vrc))
     552        {
     553            PRTSTREAM pStrmViso;
     554            vrc = RTStrmOpen(szVisoPath, "w", &pStrmViso);
     555            if (RT_SUCCESS(vrc))
     556            {
     557                RTUUID Uuid;
     558                vrc = RTUuidCreate(&Uuid);
     559                if (RT_SUCCESS(vrc))
     560                {
     561                    RTStrmPrintf(pStrmViso, "--iprt-iso-maker-file-marker-bourne-sh %RTuuid\n", &Uuid);
     562                    vrc = UIVisoCreatorWidget::visoWriteQuotedString(pStrmViso, "--volume-id=", strVisoName, "\n");
     563
     564                    for (int iFile = 0; iFile < files.size() && RT_SUCCESS(vrc); iFile++)
     565                        vrc = UIVisoCreatorWidget::visoWriteQuotedString(pStrmViso, NULL, files[iFile], "\n");
     566
     567                    /* Append custom options if any to the file: */
     568                    const QStringList &customOptions = pVisoCreator->customOptions();
     569                    foreach (QString strLine, customOptions)
     570                        RTStrmPrintf(pStrmViso, "%s\n", strLine.toUtf8().constData());
     571
     572                    RTStrmFlush(pStrmViso);
     573                    if (RT_SUCCESS(vrc))
     574                        vrc = RTStrmError(pStrmViso);
     575                }
     576
     577                RTStrmClose(pStrmViso);
     578            }
     579        }
     580
     581        /* Done. */
     582        if (RT_SUCCESS(vrc))
     583        {
     584            delete pVisoCreator;
     585            return uiCommon().openMedium(UIMediumDeviceType_DVD, QString(szVisoPath), pParent);
     586        }
     587        /** @todo error message. */
     588        else
     589        {
     590            delete pVisoCreator;
     591            return QUuid();
     592        }
     593    }
     594    delete pVisoCreator;
     595    return QUuid();
     596}
    512597
    513598/*********************************************************************************************************************************
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/viso/UIVisoCreator.h

    r92504 r92588  
    6969    void    setCurrentPath(const QString &strPath);
    7070    QMenu *menu() const;
     71
     72    /** Creates a VISO by using the VISO creator dialog.
     73      * @param  pParent           Passes the dialog parent.
     74      * @param  strDefaultFolder  Passes the folder to save the VISO file.
     75      * @param  strMachineName    Passes the name of the machine,
     76      * returns the UUID of the created medium or a null QUuid. */
     77    static QUuid createViso(UIActionPool *pActionPool, QWidget *pParent,
     78                            const QString &strDefaultFolder = QString(),
     79                            const QString &strMachineName  = QString());
    7180
    7281#ifdef VBOX_WS_MAC
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp

    r92455 r92588  
    40084008        uCurrentMediumId = m_pMediumIdHolder->id();
    40094009    QUuid uSelectedMediumId;
    4010     int iResult = uiCommon().openMediumSelectorDialog(this, m_pMediumIdHolder->type(), uCurrentMediumId, uSelectedMediumId,
    4011                                                       strMachineFolder, m_strMachineName,
    4012                                                       m_strMachineGuestOSTypeId,
    4013                                                       true /* enable create action: */, m_uMachineId, m_pActionPool);
     4010    int iResult = UIMediumSelector::openMediumSelectorDialog(this, m_pMediumIdHolder->type(), uCurrentMediumId, uSelectedMediumId,
     4011                                                             strMachineFolder, m_strMachineName,
     4012                                                             m_strMachineGuestOSTypeId,
     4013                                                             true /* enable create action: */, m_uMachineId, m_pActionPool);
    40144014
    40154015    if (iResult == UIMediumSelector::ReturnCode_Rejected ||
     
    52285228    Assert(m_pModelStorage->data(index, StorageModel::R_IsController).toBool());
    52295229    Assert(m_pModelStorage->data(index, StorageModel::R_IsMoreAttachmentsPossible).toBool());
    5230     // const QString strControllerName(m_pModelStorage->data(index, StorageModel::R_CtrName).toString());
    52315230    const QString strMachineFolder(QFileInfo(m_strMachineSettingsFilePath).absolutePath());
    52325231
    52335232    QUuid uMediumId;
    5234     int iResult = uiCommon().openMediumSelectorDialog(this, UIMediumDefs::mediumTypeToLocal(enmDeviceType),
    5235                                                       QUuid() /* current medium Id */, uMediumId,
    5236                                                       strMachineFolder, m_strMachineName,
    5237                                                       m_strMachineGuestOSTypeId,
    5238                                                       true /* enable cr1eate action: */, m_uMachineId, m_pActionPool);
     5233    int iResult = UIMediumSelector::openMediumSelectorDialog(this, UIMediumDefs::mediumTypeToLocal(enmDeviceType),
     5234                                                             QUuid() /* current medium Id */, uMediumId,
     5235                                                             strMachineFolder, m_strMachineName,
     5236                                                             m_strMachineGuestOSTypeId,
     5237                                                             true /* enable cr1eate action: */, m_uMachineId, m_pActionPool);
    52395238
    52405239    /* Continue only if iResult is either UIMediumSelector::ReturnCode_Accepted or UIMediumSelector::ReturnCode_LeftEmpty: */
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVD.cpp

    r92103 r92588  
    1818/* GUI includes: */
    1919#include "UICommon.h"
     20#include "UIModalWindowManager.h"
    2021#include "UINotificationCenter.h"
    2122#include "UIWizardNewVD.h"
     
    156157}
    157158
     159/* static */
     160QUuid UIWizardNewVD::createVDWithWizard(QWidget *pParent,
     161                                        const QString &strMachineFolder /* = QString() */,
     162                                        const QString &strMachineName /* = QString() */,
     163                                        const QString &strMachineGuestOSTypeId  /* = QString() */)
     164{
     165    /* Initialize variables: */
     166    QString strDefaultFolder = strMachineFolder;
     167    if (strDefaultFolder.isEmpty())
     168        strDefaultFolder = uiCommon().defaultFolderPathForType(UIMediumDeviceType_HardDisk);
     169
     170    /* In case we dont have a 'guest os type id' default back to 'Other': */
     171    const CGuestOSType comGuestOSType = uiCommon().virtualBox().GetGuestOSType(  !strMachineGuestOSTypeId.isEmpty()
     172                                                                                 ? strMachineGuestOSTypeId
     173                                                                                 : "Other");
     174    const QString strDiskName = uiCommon().findUniqueFileName(strDefaultFolder,   !strMachineName.isEmpty()
     175                                                                     ? strMachineName
     176                                                                     : "NewVirtualDisk");
     177
     178    /* Show New VD wizard: */
     179    UISafePointerWizardNewVD pWizard = new UIWizardNewVD(pParent,
     180                                                         strDiskName,
     181                                                         strDefaultFolder,
     182                                                         comGuestOSType.GetRecommendedHDD());
     183    if (!pWizard)
     184        return QUuid();
     185    QWidget *pDialogParent = windowManager().realParentWindow(pParent);
     186    windowManager().registerNewParent(pWizard, pDialogParent);
     187    QUuid mediumId = pWizard->mediumId();
     188    pWizard->exec();
     189    delete pWizard;
     190    return mediumId;
     191}
     192
    158193void UIWizardNewVD::retranslateUi()
    159194{
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvd/UIWizardNewVD.h

    r91714 r92588  
    4343    bool createVirtualDisk();
    4444
    45     /** @name Setter/getters for vm parameters
     45    /** Creates and shows a UIWizardNewVD wizard.
     46      * @param  pParent                   Passes the parent of the wizard,
     47      * @param  strMachineFolder          Passes the machine folder,
     48      * @param  strMachineName            Passes the name of the machine,
     49      * @param  strMachineGuestOSTypeId   Passes the string of machine's guest OS type ID,
     50      * returns QUuid of the created medium. */
     51    static QUuid createVDWithWizard(QWidget *pParent,
     52                                    const QString &strMachineFolder = QString(),
     53                                    const QString &strMachineName = QString(),
     54                                    const QString &strMachineGuestOSTypeId = QString());
     55
     56    /** @name Setter/getters for virtual disk parameters
    4657     * @{ */
    4758       qulonglong mediumVariant() const;
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPage.cpp

    r92413 r92588  
    4545{
    4646    QUuid uMediumId;
    47     int returnCode = uiCommon().openMediumSelectorDialog(pCaller, UIMediumDeviceType_HardDisk,
     47    int returnCode = UIMediumSelector::openMediumSelectorDialog(pCaller, UIMediumDeviceType_HardDisk,
    4848                                                         QUuid() /* current medium id */,
    4949                                                         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