VirtualBox

Ignore:
Timestamp:
Mar 25, 2014 5:29:10 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Selector UI: Details pane: Allow to remount DVD/floppy mediums through the anchor links (initial commit).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp

    r50845 r50871  
    3434#include "UIIconPool.h"
    3535#include "UIConverter.h"
     36#include "VBoxGlobal.h"
    3637
    3738UIGDetailsElement::UIGDetailsElement(UIGDetailsSet *pParent, DetailsElementType type, bool fOpened)
     
    133134}
    134135
     136void UIGDetailsElement::sltHandleAnchorClicked(const QString &strAnchor)
     137{
     138    /* Current anchor role: */
     139    QString strRole = strAnchor.section(',', 0, 0);
     140
     141    /* Handle known roles: */
     142    if (strRole == "#choose")
     143        handleAnchorClickedRoleChoose(strAnchor.section(',', 1));
     144}
     145
     146void UIGDetailsElement::sltMountStorageMedium()
     147{
     148    /* Sender action: */
     149    QAction *pAction = qobject_cast<QAction*>(sender());
     150    AssertMsgReturnVoid(pAction, ("This slot should only be called by menu action!\n"));
     151
     152    /* Current mount-target: */
     153    const UIMediumTarget target = pAction->data().value<UIMediumTarget>();
     154
     155    /* Update current machine mount-target: */
     156    vboxGlobal().updateMachineStorage(machine(), target);
     157}
     158
    135159void UIGDetailsElement::resizeEvent(QGraphicsSceneResizeEvent*)
    136160{
     
    392416    m_pTextPane = new UIGraphicsTextPane(this, model()->paintDevice());
    393417    connect(m_pTextPane, SIGNAL(sigGeometryChanged()), this, SLOT(sltUpdateGeometry()));
     418    connect(m_pTextPane, SIGNAL(sigAnchorClicked(const QString&)), this, SLOT(sltHandleAnchorClicked(const QString&)));
    394419}
    395420
     
    625650}
    626651
     652void UIGDetailsElement::handleAnchorClickedRoleChoose(const QString &strData)
     653{
     654    /* Prepare storage-menu: */
     655    QMenu menu;
     656
     657    /* Storage-controller name: */
     658    QString strControllerName = strData.section(',', 0, 0);
     659    /* Storage-slot: */
     660    StorageSlot storageSlot = gpConverter->fromString<StorageSlot>(strData.section(',', 1));
     661
     662    /* Fill storage-menu: */
     663    vboxGlobal().prepareStorageMenu(menu, this, SLOT(sltMountStorageMedium()),
     664                                    machine(), strControllerName, storageSlot);
     665
     666    /* Exec menu: */
     667    menu.exec(QCursor::pos());
     668}
     669
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h

    r50845 r50871  
    9696    void sltUpdateGeometry() { updateGeometry(); }
    9797
     98    /** Handles children anchor clicks. */
     99    void sltHandleAnchorClicked(const QString &strAnchor);
     100
     101    /** Handles mount storage medium requests. */
     102    void sltMountStorageMedium();
     103
    98104protected:
    99105
     
    181187    /* Helper: Animation stuff: */
    182188    void updateAnimationParameters();
     189
     190    /** Handle clicked anchor with role '#choose'. */
     191    void handleAnchorClickedRoleChoose(const QString &strData);
    183192
    184193    /* Variables: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp

    r50843 r50871  
    507507                    } // hack
    508508                    /* Append 'device slot name' with 'device type name' for CD/DVD devices only: */
    509                     QString strDeviceType = attachment.GetType() == KDeviceType_DVD ?
     509                    KDeviceType deviceType = attachment.GetType();
     510                    QString strDeviceType = deviceType == KDeviceType_DVD ?
    510511                                QApplication::translate("UIGDetails", "[CD/DVD]", "details (storage)") : QString();
    511512                    if (!strDeviceType.isNull())
     
    513514                    /* Insert that attachment information into the map: */
    514515                    if (!strAttachmentInfo.isNull())
    515                         attachmentsMap.insert(attachmentSlot, strDeviceType + strAttachmentInfo);
     516                    {
     517                        /* Hovering anchors for dvd/floppy stuff: */
     518                        if (deviceType == KDeviceType_DVD || deviceType == KDeviceType_Floppy)
     519                            attachmentsMap.insert(attachmentSlot,
     520                                                  QString("<a href=#choose,%1,%2>%3</a>")
     521                                                          .arg(controller.GetName(),
     522                                                               gpConverter->toString(attachmentSlot),
     523                                                               strDeviceType + strAttachmentInfo));
     524                        /* Usual stuff for hard-drives: */
     525                        else
     526                            attachmentsMap.insert(attachmentSlot, strDeviceType + strAttachmentInfo);
     527                    }
    516528                }
    517529                /* Iterate over the sorted map: */
Note: See TracChangeset for help on using the changeset viewer.

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