VirtualBox

Changeset 77224 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 8, 2019 3:38:03 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: VirtualBox Manager UI: Now, that one is heavy: Moving Chooser-pane scrolling logic from QGraphicsView to own UIGraphicsScrollArea making it potentially possible to scroll any group we have separately.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
Files:
9 edited

Legend:

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

    r76606 r77224  
    167167    connect(m_pChooserModel, &UIChooserModel::sigRootItemMinimumWidthHintChanged,
    168168            m_pChooserView, &UIChooserView::sltMinimumWidthHintChanged);
    169     connect(m_pChooserModel, &UIChooserModel::sigRootItemMinimumHeightHintChanged,
    170             m_pChooserView, &UIChooserView::sltMinimumHeightHintChanged);
    171169    connect(m_pChooserModel, &UIChooserModel::sigFocusChanged,
    172170            m_pChooserView, &UIChooserView::sltFocusChanged);
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp

    r77061 r77224  
    209209    , m_iAnimatedValue(m_iDefaultValue)
    210210    , m_iPreviousMinimumWidthHint(0)
    211     , m_iPreviousMinimumHeightHint(0)
    212211    , m_enmDragTokenPlace(DragToken_Off)
    213212    , m_iDragTokenDarkness(110)
     
    391390            emit sigMinimumWidthHintChanged(m_iPreviousMinimumWidthHint);
    392391        }
    393         /* Root-item should notify chooser-view if minimum-height-hint was changed: */
    394         const int iMinimumHeightHint = minimumHeightHint();
    395         if (m_iPreviousMinimumHeightHint != iMinimumHeightHint)
    396         {
    397             /* Save new minimum-height-hint, notify listener: */
    398             m_iPreviousMinimumHeightHint = iMinimumHeightHint;
    399             emit sigMinimumHeightHintChanged(m_iPreviousMinimumHeightHint);
    400         }
    401392    }
    402393}
     
    538529    /* Reset minimum size hints for non-root items: */
    539530    if (!isRoot())
    540     {
    541531        m_iPreviousMinimumWidthHint = 0;
    542         m_iPreviousMinimumHeightHint = 0;
    543     }
    544532}
    545533
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h

    r77199 r77224  
    9898        /** Notifies listeners about @a iMinimumWidthHint change. */
    9999        void sigMinimumWidthHintChanged(int iMinimumWidthHint);
    100         /** Notifies listeners about @a iMinimumHeightHint change. */
    101         void sigMinimumHeightHintChanged(int iMinimumHeightHint);
    102100    /** @} */
    103101
     
    159157        /** Returns whether item is hovered. */
    160158        bool isHovered() const;
     159
     160        /** Installs event-filter for @a pSource object.
     161          * @note  Base-class implementation does nothing. */
     162        virtual void installEventFilterHelper(QObject *pSource) { Q_UNUSED(pSource); }
    161163    /** @} */
    162164
     
    358360        /** Holds previous minimum width hint. */
    359361        int  m_iPreviousMinimumWidthHint;
    360         /** Holds previous minimum height hint. */
    361         int  m_iPreviousMinimumHeightHint;
    362362    /** @} */
    363363
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp

    r77199 r77224  
    3535#include "UIChooserView.h"
    3636#include "UIGraphicsRotatorButton.h"
     37#include "UIGraphicsScrollArea.h"
    3738#include "UIIconPool.h"
    3839#include "UIVirtualBoxManager.h"
     
    5354    , m_pExitButton(0)
    5455    , m_pNameEditorWidget(0)
     56    , m_pScrollArea(0)
    5557    , m_pContainer(0)
    5658    , m_pLayout(0)
     
    7274    connect(this, &UIChooserItemGroup::sigMinimumWidthHintChanged,
    7375            model(), &UIChooserModel::sigRootItemMinimumWidthHintChanged);
    74     connect(this, &UIChooserItemGroup::sigMinimumHeightHintChanged,
    75             model(), &UIChooserModel::sigRootItemMinimumHeightHintChanged);
    7676}
    7777
     
    8989    , m_pExitButton(0)
    9090    , m_pNameEditorWidget(0)
     91    , m_pScrollArea(0)
    9192    , m_pContainer(0)
    9293    , m_pLayout(0)
     
    128129    , m_pExitButton(0)
    129130    , m_pNameEditorWidget(0)
     131    , m_pScrollArea(0)
    130132    , m_pContainer(0)
    131133    , m_pLayout(0)
     
    160162    connect(this, &UIChooserItemGroup::sigMinimumWidthHintChanged,
    161163            model(), &UIChooserModel::sigRootItemMinimumWidthHintChanged);
    162     connect(this, &UIChooserItemGroup::sigMinimumHeightHintChanged,
    163             model(), &UIChooserModel::sigRootItemMinimumHeightHintChanged);
    164164}
    165165
     
    177177    , m_pExitButton(0)
    178178    , m_pNameEditorWidget(0)
     179    , m_pScrollArea(0)
    179180    , m_pContainer(0)
    180181    , m_pLayout(0)
     
    276277{
    277278    return !m_fClosed || isRoot();
     279}
     280
     281void UIChooserItemGroup::installEventFilterHelper(QObject *pSource)
     282{
     283    /* The only object which need's that filter for now is scroll-area: */
     284    pSource->installEventFilter(m_pScrollArea);
    278285}
    279286
     
    792799    if (isRoot())
    793800    {
     801        /* Acquire view: */
     802        const QGraphicsView *pView = model()->scene()->views().first();
     803
    794804        /* Header (non-main root-item): */
    795805        if (!isMainRoot())
     
    818828            iPreviousVerticalIndent = iVerticalMargin + iFullHeaderHeight + iVerticalMargin;
    819829        }
     830
     831        /* Adjust scroll-view geometry: */
     832        QSize viewSize = pView->size();
     833        viewSize.setHeight(viewSize.height() - iPreviousVerticalIndent);
     834        m_pScrollArea->resize(viewSize);
     835        m_pScrollArea->setPos(0, iPreviousVerticalIndent);
    820836    }
    821837    /* Header (non-root-item): */
     
    856872        /* Prepare body indent: */
    857873        iPreviousVerticalIndent = 2 * iVerticalMargin + iFullHeaderHeight;
    858     }
    859 
    860     /* Adjust container geometry: */
    861     QSize itemSize = size().toSize();
    862     itemSize.setHeight(minimumHeightHint() - iPreviousVerticalIndent);
    863     m_pContainer->resize(itemSize);
    864     m_pContainer->setPos(0, iPreviousVerticalIndent);
     874
     875        /* Adjust scroll-view geometry: */
     876        QSize itemSize = size().toSize();
     877        itemSize.setHeight(itemSize.height() - iPreviousVerticalIndent);
     878        m_pScrollArea->resize(itemSize);
     879        m_pScrollArea->setPos(0, iPreviousVerticalIndent);
     880    }
    865881
    866882    /* No body for closed group: */
    867883    if (isClosed())
    868         m_pContainer->hide();
     884        m_pScrollArea->hide();
    869885    /* Body for opened group: */
    870886    else
    871887    {
    872         m_pContainer->show();
     888        m_pScrollArea->show();
    873889        foreach (UIChooserItem *pItem, items())
    874890            pItem->updateLayout();
     
    12571273    m_exitButtonSize = m_pExitButton ? m_pExitButton->minimumSizeHint().toSize() : QSize(0, 0);
    12581274
    1259     /* Prepare container: */
    1260     m_pContainer = new QIGraphicsWidget(this);
    1261     if (m_pContainer)
    1262     {
    1263         /* Prepare layout: */
    1264         m_pLayout = new QGraphicsLinearLayout(Qt::Vertical, m_pContainer);
    1265         if (m_pLayout)
    1266         {
    1267             m_pLayout->setContentsMargins(0, 0, 0, 0);
    1268             m_pLayout->setSpacing(0);
    1269 
    1270             /* Prepare global layout: */
    1271             m_pLayoutGlobal = new QGraphicsLinearLayout(Qt::Vertical);
    1272             if (m_pLayoutGlobal)
     1275    /* Prepare scroll-area: */
     1276    m_pScrollArea = new UIGraphicsScrollArea(Qt::Vertical, this);
     1277    if (m_pScrollArea)
     1278    {
     1279        /* Prepare container: */
     1280        m_pContainer = new QIGraphicsWidget;
     1281        if (m_pContainer)
     1282        {
     1283            /* Prepare layout: */
     1284            m_pLayout = new QGraphicsLinearLayout(Qt::Vertical, m_pContainer);
     1285            if (m_pLayout)
    12731286            {
    1274                 m_pLayoutGlobal->setContentsMargins(0, 0, 0, 0);
    1275                 m_pLayoutGlobal->setSpacing(1);
    1276                 m_pLayout->addItem(m_pLayoutGlobal);
     1287                m_pLayout->setContentsMargins(0, 0, 0, 0);
     1288                m_pLayout->setSpacing(0);
     1289
     1290                /* Prepare global layout: */
     1291                m_pLayoutGlobal = new QGraphicsLinearLayout(Qt::Vertical);
     1292                if (m_pLayoutGlobal)
     1293                {
     1294                    m_pLayoutGlobal->setContentsMargins(0, 0, 0, 0);
     1295                    m_pLayoutGlobal->setSpacing(1);
     1296                    m_pLayout->addItem(m_pLayoutGlobal);
     1297                }
     1298
     1299                /* Prepare group layout: */
     1300                m_pLayoutGroup = new QGraphicsLinearLayout(Qt::Vertical);
     1301                if (m_pLayoutGroup)
     1302                {
     1303                    m_pLayoutGroup->setContentsMargins(0, 0, 0, 0);
     1304                    m_pLayoutGroup->setSpacing(1);
     1305                    m_pLayout->addItem(m_pLayoutGroup);
     1306                }
     1307
     1308                /* Prepare machine layout: */
     1309                m_pLayoutMachine = new QGraphicsLinearLayout(Qt::Vertical);
     1310                if (m_pLayoutMachine)
     1311                {
     1312                    m_pLayoutMachine->setContentsMargins(0, 0, 0, 0);
     1313                    m_pLayoutMachine->setSpacing(1);
     1314                    m_pLayout->addItem(m_pLayoutMachine);
     1315                }
    12771316            }
    12781317
    1279             /* Prepare group layout: */
    1280             m_pLayoutGroup = new QGraphicsLinearLayout(Qt::Vertical);
    1281             if (m_pLayoutGroup)
    1282             {
    1283                 m_pLayoutGroup->setContentsMargins(0, 0, 0, 0);
    1284                 m_pLayoutGroup->setSpacing(1);
    1285                 m_pLayout->addItem(m_pLayoutGroup);
    1286             }
    1287 
    1288             /* Prepare machine layout: */
    1289             m_pLayoutMachine = new QGraphicsLinearLayout(Qt::Vertical);
    1290             if (m_pLayoutMachine)
    1291             {
    1292                 m_pLayoutMachine->setContentsMargins(0, 0, 0, 0);
    1293                 m_pLayoutMachine->setSpacing(1);
    1294                 m_pLayout->addItem(m_pLayoutMachine);
    1295             }
     1318            /* Assign to scroll-area: */
     1319            m_pScrollArea->setViewport(m_pContainer);
    12961320        }
    12971321    }
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h

    r77199 r77224  
    4141class UIGraphicsButton;
    4242class UIGraphicsRotatorButton;
     43class UIGraphicsScrollArea;
    4344
    4445
     
    8990        /** Returns whether group is opened. */
    9091        bool isOpened() const;
     92
     93        /** Installs event-filter for @a pSource object. */
     94        virtual void installEventFilterHelper(QObject *pSource) /* override */;
    9195    /** @} */
    9296
     
    355359    /** @name Children stuff.
    356360      * @{ */
     361        /** Holds the children scroll-area instance. */
     362        UIGraphicsScrollArea  *m_pScrollArea;
    357363        /** Holds the children container instance. */
    358         QIGraphicsWidget *m_pContainer;
     364        QIGraphicsWidget      *m_pContainer;
    359365
    360366        /** Holds the main layout instance. */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r77061 r77224  
    9292void UIChooserModel::init()
    9393{
     94    /* Install root as event-filter for scene view,
     95     * we need QEvent::Scroll events from it: */
     96    root()->installEventFilterHelper(scene()->views()[0]);
     97
    9498    /* Load group tree: */
    9599    loadGroupTree();
     
    668672    /* Initialize variables: */
    669673    const int iSceneMargin = data(ChooserModelData_Margin).toInt();
    670     const QSize viewportSize = scene()->views()[0]->viewport()->size();
     674    const QSize viewportSize = scene()->views()[0]->size();
    671675    const int iViewportWidth = viewportSize.width() - 2 * iSceneMargin;
    672676    const int iViewportHeight = viewportSize.height() - 2 * iSceneMargin;
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.h

    r77026 r77224  
    9595        /** Notifies about root item minimum width @a iHint changed. */
    9696        void sigRootItemMinimumWidthHintChanged(int iHint);
    97         /** Notifies about root item minimum height @a iHint changed. */
    98         void sigRootItemMinimumHeightHintChanged(int iHint);
    9997    /** @} */
    10098
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.cpp

    r76606 r77224  
    9595    , m_pChooser(pParent)
    9696    , m_iMinimumWidthHint(0)
    97     , m_iMinimumHeightHint(0)
    9897{
    9998    /* Prepare: */
     
    132131}
    133132
    134 void UIChooserView::sltMinimumHeightHintChanged(int iHint)
    135 {
    136     /* Is there something changed? */
    137     if (m_iMinimumHeightHint == iHint)
    138         return;
    139 
    140     /* Remember new value: */
    141     m_iMinimumHeightHint = iHint;
    142 
    143     /* Update scene-rect: */
    144     updateSceneRect();
    145 }
    146 
    147133void UIChooserView::retranslateUi()
    148134{
     
    168154    /* Setup scroll-bars policy: */
    169155    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     156    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    170157
    171158    /* Update scene-rect: */
     
    191178    /* Notify listeners: */
    192179    emit sigResized();
     180
     181    /* Update scene-rect: */
     182    updateSceneRect();
    193183}
    194184
    195185void UIChooserView::updateSceneRect()
    196186{
    197     setSceneRect(0, 0, m_iMinimumWidthHint, m_iMinimumHeightHint);
     187    setSceneRect(0, 0, m_iMinimumWidthHint, height());
    198188}
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserView.h

    r76581 r77224  
    6363        /** Handles minimum width @a iHint change. */
    6464        void sltMinimumWidthHintChanged(int iHint);
    65         /** Handles minimum height @a iHint change. */
    66         void sltMinimumHeightHintChanged(int iHint);
    6765    /** @} */
    6866
     
    104102        /** Holds the minimum width hint. */
    105103        int m_iMinimumWidthHint;
    106         /** Holds the minimum height hint. */
    107         int m_iMinimumHeightHint;
    108104    /** @} */
    109105};
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