VirtualBox

Changeset 72903 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jul 4, 2018 7:59:39 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123450
Message:

FE/Qt: bugref:9083 Adding an action to machine ui status bar menu for 'create new floppy disk'

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

Legend:

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

    r72822 r72903  
    5959# include "QIMessageBox.h"
    6060# include "QIDialogButtonBox.h"
     61# include "UIFDCreationDialog.h"
    6162# include "UIIconPool.h"
    6263# include "UIThreadPool.h"
     
    27192720}
    27202721
     2722QString VBoxGlobal::showCreateFloppyDiskDialog(QWidget *pParent, const QString &strMachineName, const QString &strMachineFolder)
     2723{
     2724    QString strMediumID;
     2725    UIFDCreationDialog *pDialog = new UIFDCreationDialog(pParent, strMachineName, strMachineFolder);
     2726    if (pDialog->exec())
     2727    {
     2728        strMediumID = pDialog->mediumID();
     2729    }
     2730    delete pDialog;
     2731    return strMediumID;
     2732}
     2733
    27212734void VBoxGlobal::prepareStorageMenu(QMenu &menu,
    27222735                                    QObject *pListener, const char *pszSlotName,
     
    27462759                                                               "This is used for hard disks, optical media and floppies"));
    27472760
     2761    /* Prepare create floppy disk action: */
     2762    if (enmMediumType == UIMediumType_Floppy)
     2763    {
     2764        QAction *pActionCreateFloppy = menu.addAction(UIIconPool::iconSet(":/fd_add_16px.png"),
     2765                                                      QString(), pListener, pszSlotName);
     2766        pActionCreateFloppy->setData(QVariant::fromValue(UIMediumTarget(strControllerName, comCurrentAttachment.GetPort(),
     2767                                                                        comCurrentAttachment.GetDevice(), enmMediumType,
     2768                                                                        UIMediumTarget::UIMediumTargetType_CreateFloppyDisk)));
     2769        pActionCreateFloppy->setText(QApplication::translate("UIMachineSettingsStorage", "Create a new floppy disk...",
     2770                                                             "This is used to create a new floppy disk"));
     2771    }
    27482772    /* Prepare ad-hoc-viso action for DVD-ROMs: */
    27492773    if (enmMediumType == UIMediumType_DVD)
     
    28972921        case UIMediumTarget::UIMediumTargetType_WithID:
    28982922        case UIMediumTarget::UIMediumTargetType_CreateAdHocVISO:
     2923        case UIMediumTarget::UIMediumTargetType_CreateFloppyDisk:
    28992924        {
    29002925            /* New mount-target attributes: */
     
    29152940                /* Call for file-open dialog: */
    29162941                const QString strMachineFolder(QFileInfo(comConstMachine.GetSettingsFilePath()).absolutePath());
    2917                 const QString strMediumID = target.type != UIMediumTarget::UIMediumTargetType_CreateAdHocVISO
    2918                                           ? openMediumWithFileOpenDialog(target.mediumType,
    2919                                                                          windowManager().mainWindowShown(),
    2920                                                                          strMachineFolder)
    2921                                           : createVisoMediumWithFileOpenDialog(windowManager().mainWindowShown(),
    2922                                                                                strMachineFolder);
     2942                QString strMediumID;
     2943                if (target.type == UIMediumTarget::UIMediumTargetType_WithID)
     2944                    strMediumID = openMediumWithFileOpenDialog(target.mediumType, windowManager().mainWindowShown(), strMachineFolder);
     2945                else if(target.type == UIMediumTarget::UIMediumTargetType_CreateAdHocVISO)
     2946                    strMediumID = createVisoMediumWithFileOpenDialog(windowManager().mainWindowShown(), strMachineFolder);
     2947                else if(target.type == UIMediumTarget::UIMediumTargetType_CreateFloppyDisk)
     2948                    strMediumID = showCreateFloppyDiskDialog(windowManager().mainWindowShown(), comConstMachine.GetName(), strMachineFolder);
     2949
    29232950                /* Return focus back: */
    29242951                if (pLastFocusedWidget)
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r72822 r72903  
    508508        QString createVisoMediumWithFileOpenDialog(QWidget *pParent, const QString &strFolder);
    509509
     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  strMachineName    Passes the name of the machine,
     513          * @param  strMachineFolder  Passes the machine folder,
     514          * returns the ID of the newly created medium if successful, an empty string otherwise.*/
     515        QString showCreateFloppyDiskDialog(QWidget *pParent, const QString &strMachineName, const QString &strMachineFolder);
     516
    510517        /** Prepares storage menu according passed parameters.
    511518          * @param  menu               Brings the #QMenu to be prepared.
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.cpp

    r72873 r72903  
    4343UIFDCreationDialog::UIFDCreationDialog(QWidget *pParent /* = 0 */,
    4444                                       const QString &strMachineName /* = QString() */,
    45                                        const QString &strMachineSettingsFilePath /* = QString() */)
     45                                       const QString &strMachineFolder /* = QString() */)
    4646   : QIWithRetranslateUI<QDialog>(pParent)
    4747    , m_pFilePathselector(0)
    4848    , m_strMachineName(strMachineName)
    49     , m_strMachineSettingsFilePath(strMachineSettingsFilePath)
     49    , m_strMachineFolder(strMachineFolder)
    5050    , m_pPathLabel(0)
    5151    , m_pSizeLabel(0)
     
    150150    QString strPreferredExtension = UIMediumDefs::getPreferredExtensionForMedium(KDeviceType_Floppy);
    151151
    152     QString strInitialPath = QFileInfo(m_strMachineSettingsFilePath).absolutePath();
     152    QString strInitialPath = m_strMachineFolder;
    153153    if (strInitialPath.isEmpty())
    154154        strInitialPath = vboxGlobal().virtualBox().GetSystemProperties().GetDefaultMachineFolder();
     
    195195        return;
    196196    }
     197    /* Store the id of the newly create medium: */
     198    m_strMediumID = newMedium.GetId();
    197199
    198200    /* After a successful creation and initilization of the floppy disk we call base class accept
     
    200202    QDialog::accept();
    201203}
     204
     205QString UIFDCreationDialog::mediumID() const
     206{
     207    return m_strMediumID;
     208}
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIFDCreationDialog.h

    r72869 r72903  
    4343    UIFDCreationDialog(QWidget *pParent = 0,
    4444                       const QString &strMachineName = QString(),
    45                        const QString &strMachineSettingsFilePath = QString());
     45                       const QString &strMachineFolder = QString());
    4646
    4747    virtual void accept() /* override */;
     48    /* Return the mediumID */
     49    QString mediumID() const;
    4850
    4951protected:
     
    6769    UIFilePathSelector *m_pFilePathselector;
    6870    QString             m_strMachineName;
    69     QString             m_strMachineSettingsFilePath;
     71    QString             m_strMachineFolder;
    7072    QLabel             *m_pPathLabel;
    7173    QLabel             *m_pSizeLabel;
    7274    QComboBox          *m_pSizeCombo;
    7375    QDialogButtonBox   *m_pButtonBox;
     76    QString             m_strMediumID;
    7477};
    7578
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumDefs.h

    r72869 r72903  
    8585{
    8686    /** Medium-target types. */
    87     enum UIMediumTargetType { UIMediumTargetType_WithID, UIMediumTargetType_WithLocation, UIMediumTargetType_CreateAdHocVISO };
     87    enum UIMediumTargetType
     88    {
     89        UIMediumTargetType_WithID,
     90        UIMediumTargetType_WithLocation,
     91        UIMediumTargetType_CreateAdHocVISO,
     92        UIMediumTargetType_CreateFloppyDisk
     93    };
    8894
    8995    /** Medium-target constructor. */
  • trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumSelector.cpp

    r72869 r72903  
    480480void UIMediumSelector::sltCreateMedium()
    481481{
    482 
    483     UIFDCreationDialog *pDialog = new UIFDCreationDialog(this, m_strMachineName, m_strMachineSettingsFilePath);
     482    QString strMachineFolder = QFileInfo(m_strMachineSettingsFilePath).absolutePath();
     483    UIFDCreationDialog *pDialog = new UIFDCreationDialog(this, m_strMachineName, strMachineFolder);
    484484    if (pDialog->exec())
    485485    {
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