VirtualBox

Changeset 77923 in vbox for trunk/src


Ignore:
Timestamp:
Mar 27, 2019 2:43:18 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: VirtualBox Manager: Chooser pane: Restore lost drag scrolling functionality.

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

Legend:

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

    r77922 r77923  
    140140}
    141141
     142void UIChooserItemGroup::scrollBy(int iDelta)
     143{
     144    m_pScrollArea->scrollBy(iDelta);
     145}
     146
    142147void UIChooserItemGroup::makeSureItemIsVisible(UIChooserItem *pItem)
    143148{
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.h

    r77922 r77923  
    9090    /** @name Navigation stuff.
    9191      * @{ */
     92        /** Performs scrolling by @a iDelta pixels. */
     93        void scrollBy(int iDelta);
     94
    9295        /** Makes sure passed @a pItem is visible within the current root item.
    9396          * @note Please keep in mind that any group item can be a root, but there
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserModel.cpp

    r77922 r77923  
    10871087void UIChooserModel::sltStartScrolling()
    10881088{
     1089    /* Make sure view exists: */
     1090    AssertPtrReturnVoid(view());
     1091
    10891092    /* Should we scroll? */
    10901093    if (!m_fIsScrollingInProgress)
     
    10941097    m_fIsScrollingInProgress = false;
    10951098
    1096     /* Get view/scrollbar: */
    1097     QGraphicsView *pView = view();
    1098     QScrollBar *pVerticalScrollBar = pView->verticalScrollBar();
    1099 
    11001099    /* Convert mouse position to view co-ordinates: */
    1101     const QPoint mousePos = pView->mapFromGlobal(QCursor::pos());
     1100    const QPoint mousePos = view()->mapFromGlobal(QCursor::pos());
    11021101    /* Mouse position is at the top of view? */
    11031102    if (mousePos.y() < m_iScrollingTokenSize && mousePos.y() > 0)
    11041103    {
    11051104        int iValue = mousePos.y();
    1106         if (!iValue) iValue = 1;
    1107         int iDelta = m_iScrollingTokenSize / iValue;
    1108         if (pVerticalScrollBar->value() > pVerticalScrollBar->minimum())
    1109         {
    1110             /* Backward scrolling: */
    1111             pVerticalScrollBar->setValue(pVerticalScrollBar->value() - 2 * iDelta);
    1112             m_fIsScrollingInProgress = true;
    1113             QTimer::singleShot(10, this, SLOT(sltStartScrolling()));
    1114         }
     1105        if (!iValue)
     1106            iValue = 1;
     1107        const int iDelta = m_iScrollingTokenSize / iValue;
     1108        /* Backward scrolling: */
     1109        root()->toGroupItem()->scrollBy(- 2 * iDelta);
     1110        m_fIsScrollingInProgress = true;
     1111        QTimer::singleShot(10, this, SLOT(sltStartScrolling()));
    11151112    }
    11161113    /* Mouse position is at the bottom of view? */
    1117     else if (mousePos.y() > pView->height() - m_iScrollingTokenSize && mousePos.y() < pView->height())
    1118     {
    1119         int iValue = pView->height() - mousePos.y();
    1120         if (!iValue) iValue = 1;
    1121         int iDelta = m_iScrollingTokenSize / iValue;
    1122         if (pVerticalScrollBar->value() < pVerticalScrollBar->maximum())
    1123         {
    1124             /* Forward scrolling: */
    1125             pVerticalScrollBar->setValue(pVerticalScrollBar->value() + 2 * iDelta);
    1126             m_fIsScrollingInProgress = true;
    1127             QTimer::singleShot(10, this, SLOT(sltStartScrolling()));
    1128         }
     1114    else if (mousePos.y() > view()->height() - m_iScrollingTokenSize && mousePos.y() < view()->height())
     1115    {
     1116        int iValue = view()->height() - mousePos.y();
     1117        if (!iValue)
     1118            iValue = 1;
     1119        const int iDelta = m_iScrollingTokenSize / iValue;
     1120        /* Forward scrolling: */
     1121        root()->toGroupItem()->scrollBy(2 * iDelta);
     1122        m_fIsScrollingInProgress = true;
     1123        QTimer::singleShot(10, this, SLOT(sltStartScrolling()));
    11291124    }
    11301125}
     
    16001595bool UIChooserModel::processDragMoveEvent(QGraphicsSceneDragDropEvent *pEvent)
    16011596{
     1597    /* Make sure view exists: */
     1598    AssertPtrReturn(view(), false);
     1599
    16021600    /* Do we scrolling already? */
    16031601    if (m_fIsScrollingInProgress)
    16041602        return false;
    16051603
    1606     /* Get view: */
    1607     QGraphicsView *pView = view();
    1608 
    16091604    /* Check scroll-area: */
    1610     const QPoint eventPoint = pView->mapFromGlobal(pEvent->screenPos());
    1611     if ((eventPoint.y() < m_iScrollingTokenSize) ||
    1612         (eventPoint.y() > pView->height() - m_iScrollingTokenSize))
     1605    const QPoint eventPoint = view()->mapFromGlobal(pEvent->screenPos());
     1606    if (   (eventPoint.y() < m_iScrollingTokenSize)
     1607        || (eventPoint.y() > view()->height() - m_iScrollingTokenSize))
    16131608    {
    16141609        /* Set scrolling in progress: */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollArea.cpp

    r77310 r77923  
    9696{
    9797    return m_pViewport;
     98}
     99
     100void UIGraphicsScrollArea::scrollBy(int iDelta)
     101{
     102    m_pScrollBar->setValue(m_pScrollBar->value() + iDelta);
    98103}
    99104
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollArea.h

    r77228 r77923  
    5050    QIGraphicsWidget *viewport() const;
    5151
     52    /** Performs scrolling by @a iDelta pixels. */
     53    void scrollBy(int iDelta);
     54
    5255    /** Makes sure passed @a rect is visible. */
    5356    void makeSureRectIsVisible(const QRectF &rect);
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