VirtualBox

Changeset 79842 in vbox


Ignore:
Timestamp:
Jul 17, 2019 4:51:51 PM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: VirtualBox Manager: Details pane: Rework Details group to use own UIGraphicsScrollArea instead of common scrolling facility of UIDetailsView.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/details
Files:
8 edited

Legend:

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

    r79461 r79842  
    6565                pMainLayout->addWidget(m_pDetailsView);
    6666            }
     67
     68            /* Init model: */
     69            m_pDetailsModel->init();
    6770        }
    6871    }
     
    7780    connect(m_pDetailsModel, &UIDetailsModel::sigRootItemMinimumWidthHintChanged,
    7881            m_pDetailsView, &UIDetailsView::sltMinimumWidthHintChanged);
    79     connect(m_pDetailsModel, &UIDetailsModel::sigRootItemMinimumHeightHintChanged,
    80             m_pDetailsView, &UIDetailsView::sltMinimumHeightHintChanged);
    8182    connect(m_pDetailsModel, &UIDetailsModel::sigLinkClicked,
    8283            this, &UIDetails::sigLinkClicked);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsGroup.cpp

    r79841 r79842  
    2424
    2525/* GUI includes: */
     26#include "UIGraphicsScrollArea.h"
    2627#include "UIDetailsGroup.h"
    2728#include "UIDetailsModel.h"
     
    3637    : UIDetailsItem(0)
    3738    , m_pBuildStep(0)
     39    , m_pScrollArea(0)
    3840    , m_pContainer(0)
    3941    , m_pLayout(0)
    4042    , m_iPreviousMinimumWidthHint(0)
    41     , m_iPreviousMinimumHeightHint(0)
    42 {
    43     /* Prepare container: */
    44     m_pContainer = new QIGraphicsWidget(this);
    45     if (m_pContainer)
    46     {
    47         /* Prepare layout: */
    48         m_pLayout = new QGraphicsLinearLayout(Qt::Vertical, m_pContainer);
    49         if (m_pLayout)
     43{
     44    /* Prepare scroll-area: */
     45    m_pScrollArea = new UIGraphicsScrollArea(Qt::Vertical, this);
     46    if (m_pScrollArea)
     47    {
     48        /* Prepare container: */
     49        m_pContainer = new QIGraphicsWidget;
     50        if (m_pContainer)
    5051        {
    51             m_pLayout->setContentsMargins(0, 0, 0, 0);
    52             m_pLayout->setSpacing(0);
     52            /* Prepare layout: */
     53            m_pLayout = new QGraphicsLinearLayout(Qt::Vertical, m_pContainer);
     54            if (m_pLayout)
     55            {
     56                m_pLayout->setContentsMargins(0, 0, 0, 0);
     57                m_pLayout->setSpacing(0);
     58            }
     59
     60            /* Assign to scroll-area: */
     61            m_pScrollArea->setViewport(m_pContainer);
    5362        }
    5463    }
     
    102111}
    103112
     113void UIDetailsGroup::installEventFilterHelper(QObject *pSource)
     114{
     115    /* The only object which need's that filter for now is scroll-area: */
     116    pSource->installEventFilter(m_pScrollArea);
     117}
     118
    104119QList<UIDetailsItem*> UIDetailsGroup::items(UIDetailsItemType enmType /* = UIDetailsItemType_Set */) const
    105120{
     
    118133    UIDetailsView *pView = model()->view();
    119134
    120     /* Adjust children container geometry: */
    121     m_pContainer->resize(pView->viewport()->size());
    122     m_pContainer->setPos(0, 0);
     135    /* Adjust children scroll-area: */
     136    m_pScrollArea->resize(pView->size());
     137    m_pScrollArea->setPos(0, 0);
    123138
    124139    /* Layout all the sets: */
     
    242257        emit sigMinimumWidthHintChanged(m_iPreviousMinimumWidthHint);
    243258    }
    244     /* Group-item should notify details-view if minimum-height-hint was changed: */
    245     int iMinimumHeightHint = minimumHeightHint();
    246     if (m_iPreviousMinimumHeightHint != iMinimumHeightHint)
    247     {
    248         /* Save new minimum-height-hint, notify listener: */
    249         m_iPreviousMinimumHeightHint = iMinimumHeightHint;
    250         emit sigMinimumHeightHintChanged(m_iPreviousMinimumHeightHint);
    251     }
    252259}
    253260
     
    257264    connect(this, SIGNAL(sigMinimumWidthHintChanged(int)),
    258265            model(), SIGNAL(sigRootItemMinimumWidthHintChanged(int)));
    259     connect(this, SIGNAL(sigMinimumHeightHintChanged(int)),
    260             model(), SIGNAL(sigRootItemMinimumHeightHintChanged(int)));
    261266}
    262267
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsGroup.h

    r79841 r79842  
    2828class QGraphicsLinearLayout;
    2929class QGraphicsScene;
     30class UIGraphicsScrollArea;
    3031class UIVirtualMachineItem;
    3132
     
    4142        /** Notifies listeners about @a iMinimumWidthHint changed. */
    4243        void sigMinimumWidthHintChanged(int iMinimumWidthHint);
    43         /** Notifies listeners about @a iMinimumHeightHint changed. */
    44         void sigMinimumHeightHintChanged(int iMinimumHeightHint);
    4544    /** @} */
    4645
     
    6362        /** Stops currently building group. */
    6463        void stopBuildingGroup();
     64
     65        /** Installs event-filter for @a pSource object. */
     66        virtual void installEventFilterHelper(QObject *pSource) /* override */;
    6567    /** @} */
    6668
     
    152154    /** @name Children stuff.
    153155      * @{ */
     156        /** Holds the children scroll-area instance. */
     157        UIGraphicsScrollArea  *m_pScrollArea;
    154158        /** Holds the children container instance. */
    155159        QIGraphicsWidget      *m_pContainer;
     
    166170    /** @name Layout stuff.
    167171      * @{ */
     172        /** Holds previous minimum width hint. */
    168173        int m_iPreviousMinimumWidthHint;
    169         int m_iPreviousMinimumHeightHint;
    170174    /** @} */
    171175};
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsItem.h

    r76581 r79842  
    8989        /** Returns the description of the item. */
    9090        virtual QString description() const = 0;
     91
     92        /** Installs event-filter for @a pSource object.
     93          * @note  Base-class implementation does nothing. */
     94        virtual void installEventFilterHelper(QObject *pSource) { Q_UNUSED(pSource); }
    9195    /** @} */
    9296
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsModel.cpp

    r79839 r79842  
    5656}
    5757
     58void UIDetailsModel::init()
     59{
     60    /* Install root as event-filter for scene view,
     61     * we need QEvent::Scroll events from it: */
     62    root()->installEventFilterHelper(view());
     63}
     64
    5865QGraphicsScene *UIDetailsModel::scene() const
    5966{
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsModel.h

    r79839 r79842  
    5858    /** Notifies listeners about model root item @a iMinimumWidthHint changed. */
    5959    void sigRootItemMinimumWidthHintChanged(int iMinimumWidthHint);
    60     /** Notifies listeners about model root item @a iMinimumHeightHint changed. */
    61     void sigRootItemMinimumHeightHintChanged(int iMinimumHeightHint);
    6260
    6361    /** Notifies listeners about element link clicked.
     
    7472    /** Destructs a details model. */
    7573    virtual ~UIDetailsModel() /* override */;
     74
     75    /** Inits model. */
     76    void init();
    7677
    7778    /** Returns graphics scene this model belongs to. */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsView.cpp

    r76606 r79842  
    110110    , m_pDetails(pParent)
    111111    , m_iMinimumWidthHint(0)
    112     , m_iMinimumHeightHint(0)
    113112{
    114113    /* Install Details-view accessibility interface factory: */
     
    122121    /* Setup scroll-bars policy: */
    123122    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     123    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    124124
    125125    /* Update scene-rect: */
     
    148148}
    149149
    150 void UIDetailsView::sltMinimumHeightHintChanged(int iMinimumHeightHint)
    151 {
    152     /* Is there something changed? */
    153     if (m_iMinimumHeightHint == iMinimumHeightHint)
    154         return;
    155 
    156     /* Remember new value: */
    157     m_iMinimumHeightHint = iMinimumHeightHint;
    158     if (m_iMinimumHeightHint <= 0)
    159         m_iMinimumHeightHint = 1;
    160 
    161     /* Update scene-rect: */
    162     updateSceneRect();
    163 }
    164 
    165150void UIDetailsView::retranslateUi()
    166151{
     
    177162    /* Notify listeners: */
    178163    emit sigResized();
     164
     165    /* Update scene-rect: */
     166    updateSceneRect();
    179167}
    180168
    181169void UIDetailsView::updateSceneRect()
    182170{
    183     setSceneRect(0, 0, m_iMinimumWidthHint, m_iMinimumHeightHint);
     171    setSceneRect(0, 0, m_iMinimumWidthHint, height());
    184172}
    185173
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsView.h

    r76581 r79842  
    5252    /* Handlers: Size-hint stuff: */
    5353    void sltMinimumWidthHintChanged(int iMinimumWidthHint);
    54     void sltMinimumHeightHintChanged(int iMinimumHeightHint);
    5554
    5655private:
     
    7069    /* Variables: */
    7170    int m_iMinimumWidthHint;
    72     int m_iMinimumHeightHint;
    7371};
    7472
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