VirtualBox

Changeset 102262 in vbox for trunk


Ignore:
Timestamp:
Nov 22, 2023 3:19:20 PM (15 months ago)
Author:
vboxsync
Message:

FE/Qt: bugref:10513: Make sure selector of UIAdvancedSettingsDialog is properly synchronized with actual scroll-area position.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.cpp

    r102260 r102262  
    210210    Q_PROPERTY(int verticalScrollBarPosition READ verticalScrollBarPosition WRITE setVerticalScrollBarPosition);
    211211
     212signals:
     213
     214    /** Notifies listeners about wheel-event. */
     215    void sigWheelEvent();
     216
    212217public:
    213218
     
    227232    /** Returns the minimum widget size. */
    228233    virtual QSize minimumSizeHint() const RT_OVERRIDE;
     234
     235    /** Handles wheel @a pEvent. */
     236    virtual void wheelEvent(QWheelEvent *pEvent) RT_OVERRIDE;
    229237
    230238private:
     
    568576                                (int)(iMinWidth / 1.6));
    569577    return QSize(iMinWidth, iMinHeight);
     578}
     579
     580void UIVerticalScrollArea::wheelEvent(QWheelEvent *pEvent)
     581{
     582    /* Call to base-class: */
     583    QScrollArea::wheelEvent(pEvent);
     584
     585    /* Notify listeners: */
     586    emit sigWheelEvent();
    570587}
    571588
     
    11361153}
    11371154
     1155void UIAdvancedSettingsDialog::sltHandleVerticalScrollAreaWheelEvent()
     1156{
     1157    /* Acquire layout info: */
     1158    int iL = 0, iT = 0, iR = 0, iB = 0;
     1159    if (   m_pScrollViewport
     1160        && m_pScrollViewport->layout())
     1161        m_pScrollViewport->layout()->getContentsMargins(&iL, &iT, &iR, &iB);
     1162
     1163    /* Search through all the frame keys we have: */
     1164    int iActualKey = -1;
     1165    foreach (int iKey, m_frames.keys())
     1166    {
     1167        /* Let's calculate scroll-bar position for enumerated frame: */
     1168        int iPosition = 0;
     1169        /* We'll have to take upper content's margin into account: */
     1170        iPosition -= iT;
     1171        /* And actual page position according to parent: */
     1172        const QPoint pnt = m_frames.value(iKey)->pos();
     1173        iPosition += pnt.y();
     1174
     1175        /* Check if scroll-bar haven't passed this position yet: */
     1176        if (m_pScrollArea->verticalScrollBarPosition() < iPosition)
     1177            break;
     1178
     1179        /* Remember last suitable frame key: */
     1180        iActualKey = iKey;
     1181    }
     1182
     1183    /* Silently update the selector with frame number we found: */
     1184    if (iActualKey != -1)
     1185        m_pSelector->selectById(iActualKey, true /* silently */);
     1186}
     1187
    11381188void UIAdvancedSettingsDialog::prepare()
    11391189{
     
    12331283        m_pScrollArea->setWidgetResizable(true);
    12341284        m_pScrollArea->setFrameShape(QFrame::NoFrame);
     1285        connect(m_pScrollArea, &UIVerticalScrollArea::sigWheelEvent,
     1286                this, &UIAdvancedSettingsDialog::sltHandleVerticalScrollAreaWheelEvent);
    12351287
    12361288        /* Prepare scroll-viewport: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.h

    r102140 r102262  
    211211    void sltHandleFrameVisibilityChange(bool fVisible);
    212212
     213    /** Handles signal about vertical scroll-area wheel-event. */
     214    void sltHandleVerticalScrollAreaWheelEvent();
     215
    213216private:
    214217
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