VirtualBox

Changeset 74483 in vbox for trunk/src


Ignore:
Timestamp:
Sep 26, 2018 4:27:10 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager: Chooser and Tools panes: Handle tools button click for machine/global items; rework Tools pane to be popup widget.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.cpp

    r74464 r74483  
    308308    /* Then handle current item change (again!): */
    309309    sltHandleChooserPaneIndexChangeDefault();
     310}
     311
     312void UIVirtualBoxManagerWidget::sltHandleToolMenuRequested(UIToolsClass enmClass, const QPoint &position)
     313{
     314    m_pPaneTools->setToolsClass(enmClass);
     315    if (m_pPaneTools->minimumSize().isValid())
     316        m_pPaneTools->resize(m_pPaneTools->minimumSize());
     317    m_pPaneTools->move(m_pPaneChooser->mapToGlobal(position));
     318    m_pPaneTools->show();
    310319}
    311320
     
    507516            else
    508517                m_pPaneTools->setToolsClass(UIToolsClass_Machine);
    509 
    510             /* Add into layout: */
    511             pLayoutMain->addWidget(m_pPaneTools);
    512518        }
    513519    }
     
    536542    connect(m_pPaneChooser, &UIChooser::sigGroupSavingStateChanged,
    537543            this, &UIVirtualBoxManagerWidget::sigGroupSavingStateChanged);
     544    connect(m_pPaneChooser, &UIChooser::sigToolMenuRequested,
     545            this, &UIVirtualBoxManagerWidget::sltHandleToolMenuRequested);
    538546
    539547    /* Details-pane connections: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManagerWidget.h

    r74260 r74483  
    138138    /** @name Tools stuff.
    139139      * @{ */
     140        /** Handles tool menu request. */
     141        void sltHandleToolMenuRequested(UIToolsClass enmClass, const QPoint &position);
     142
    140143        /** Handles signal abour Tools-pane index change. */
    141144        void sltHandleToolsPaneIndexChange();
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.cpp

    r74246 r74483  
    171171    connect(m_pChooserModel, &UIChooserModel::sigFocusChanged,
    172172            m_pChooserView, &UIChooserView::sltFocusChanged);
     173    connect(m_pChooserModel, &UIChooserModel::sigToolMenuRequested,
     174            this, &UIChooser::sigToolMenuRequested);
    173175
    174176    /* Setup chooser-view connections: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooser.h

    r74246 r74483  
    2121/* Qt includes: */
    2222#include <QWidget>
     23
     24/* GUI includes: */
     25#include "UIExtraDataDefs.h"
    2326
    2427/* Forward declarations: */
     
    4952        /** Notifies listeners about toggling finished. */
    5053        void sigToggleFinished();
     54
     55        /** Notifies listeners about tool popup-menu request for certain tool @a enmClass and in specified @a position. */
     56        void sigToolMenuRequested(UIToolsClass enmClass, const QPoint &position);
    5157    /** @} */
    5258
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserHandlerMouse.cpp

    r73600 r74483  
    7676                /* Or a global one? */
    7777                else if (UIChooserItemGlobal *pGlobalItem = qgraphicsitem_cast<UIChooserItemGlobal*>(pItemUnderMouse))
    78                     pClickedItem = pGlobalItem;
     78                {
     79                    const QPoint itemCursorPos = pGlobalItem->mapFromScene(scenePos).toPoint();
     80                    if (model()->currentItem() == pGlobalItem && pGlobalItem->isToolsButtonArea(itemCursorPos))
     81                        model()->handleToolButtonClick(pGlobalItem);
     82                    else
     83                        pClickedItem = pGlobalItem;
     84                }
    7985                /* Or a machine one? */
    8086                else if (UIChooserItemMachine *pMachineItem = qgraphicsitem_cast<UIChooserItemMachine*>(pItemUnderMouse))
    81                     pClickedItem = pMachineItem;
     87                {
     88                    const QPoint itemCursorPos = pMachineItem->mapFromScene(scenePos).toPoint();
     89                    if (model()->currentItem() == pMachineItem && pMachineItem->isToolsButtonArea(itemCursorPos))
     90                        model()->handleToolButtonClick(pMachineItem);
     91                    else
     92                        pClickedItem = pMachineItem;
     93                }
    8294                /* If we had clicked one of required item types: */
    8395                if (pClickedItem && !pClickedItem->isRoot())
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r74272 r74483  
    150150{
    151151    return scene()->itemAt(position, deviceTransform);
     152}
     153
     154void UIChooserModel::handleToolButtonClick(UIChooserItem *pItem)
     155{
     156    switch (pItem->type())
     157    {
     158        case UIChooserItemType_Global:
     159            emit sigToolMenuRequested(UIToolsClass_Global, pItem->geometry().topRight().toPoint());
     160            break;
     161        case UIChooserItemType_Group:
     162        case UIChooserItemType_Machine:
     163            emit sigToolMenuRequested(UIToolsClass_Machine, pItem->geometry().topRight().toPoint());
     164            break;
     165        default:
     166            break;
     167    }
    152168}
    153169
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r74246 r74483  
    2828/* GUI includes: */
    2929#include "UIChooserItem.h"
     30#include "UIExtraDataDefs.h"
    3031
    3132/* COM includes: */
     
    6364signals:
    6465
     66    /** @name General stuff.
     67      * @{ */
     68        /** Notify listeners about tool menu popup request for certain @a enmClass and @a position. */
     69        void sigToolMenuRequested(UIToolsClass enmClass, const QPoint &position);
     70    /** @} */
     71
    6572    /** @name Selection stuff.
    6673      * @{ */
     
    120127        /** Returns item at @a position, taking into account possible @a deviceTransform. */
    121128        QGraphicsItem *itemAt(const QPointF &position, const QTransform &deviceTransform = QTransform()) const;
     129
     130        /** Handles tool button click for certain @a pItem. */
     131        void handleToolButtonClick(UIChooserItem *pItem);
    122132    /** @} */
    123133
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UITools.cpp

    r74319 r74483  
    3434
    3535UITools::UITools(UIVirtualBoxManagerWidget *pParent)
    36     : QWidget(pParent)
     36    : QWidget(pParent, Qt::Popup)
    3737    , m_pManagerWidget(pParent)
    3838    , m_pMainLayout(0)
     
    122122    {
    123123        /* Configure main-layout: */
    124         m_pMainLayout->setContentsMargins(1, 0, 0, 0);
     124        m_pMainLayout->setContentsMargins(1, 1, 1, 1);
    125125        m_pMainLayout->setSpacing(0);
    126126    }
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsItem.cpp

    r74467 r74483  
    764764
    765765    /* Draw frame: */
    766     pPainter->drawLine(rectangle.topLeft(), rectangle.topRight() + QPoint(1, 0));
    767     pPainter->drawLine(rectangle.bottomLeft() + QPoint(0, 1), rectangle.bottomRight() + QPoint(1, 1));
     766    pPainter->drawRect(rectangle);
    768767
    769768    /* Restore painter: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/tools/UIToolsView.cpp

    r74369 r74483  
    147147    m_iMinimumHeightHint = iHint;
    148148
     149    /* Set minimum view height according passed height-hint: */
     150    setMinimumHeight(2 * frameWidth() + m_iMinimumHeightHint);
     151
    149152    /* Update scene-rect: */
    150153    updateSceneRect();
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