VirtualBox

Changeset 47951 in vbox


Ignore:
Timestamp:
Aug 21, 2013 8:38:18 AM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Settings Dialog: Warning-pane: Hover-stuff timer preventing mouse-over flicker.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIWarningPane.cpp

    r47945 r47951  
    2222#include <QLabel>
    2323#include <QEvent>
     24#include <QTimer>
    2425
    2526/* GUI includes: */
     
    3435    , m_pIconLayout(0)
    3536    , m_pTextLabel(0)
     37    , m_pHoverTimer(0)
     38    , m_iHoveredIconLabelPosition(-1)
    3639{
    3740    /* Prepare: */
     
    7982}
    8083
     84void UIWarningPane::sltHandleHoverTimer()
     85{
     86    /* Notify listeners about hovering: */
     87    if (m_iHoveredIconLabelPosition >= 0 && m_iHoveredIconLabelPosition < m_validators.size())
     88        emit sigHoverEnter(m_validators[m_iHoveredIconLabelPosition]);
     89}
     90
    8191void UIWarningPane::prepare()
    8292{
     
    110120            pMainLayout->addLayout(m_pIconLayout);
    111121        }
     122        /* Create hover-timer: */
     123        m_pHoverTimer = new QTimer(this);
     124        {
     125            /* Configure timer: */
     126            m_pHoverTimer->setInterval(200);
     127            m_pHoverTimer->setSingleShot(true);
     128            connect(m_pHoverTimer, SIGNAL(timeout()), this, SLOT(sltHandleHoverTimer()));
     129        }
    112130        /* Add right stretch: */
    113131        pMainLayout->addStretch();
     
    134152                    {
    135153                        m_hovered[iIconLabelPosition] = true;
    136                         emit sigHoverEnter(m_validators[iIconLabelPosition]);
     154                        m_iHoveredIconLabelPosition = iIconLabelPosition;
     155                        m_pHoverTimer->start();
    137156                    }
    138157                }
     
    154173                    {
    155174                        m_hovered[iIconLabelPosition] = false;
    156                         emit sigHoverLeave(m_validators[iIconLabelPosition]);
     175                        if (m_pHoverTimer->isActive())
     176                        {
     177                            m_pHoverTimer->stop();
     178                            m_iHoveredIconLabelPosition = -1;
     179                        }
     180                        else
     181                            emit sigHoverLeave(m_validators[iIconLabelPosition]);
    157182                    }
    158183                }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIWarningPane.h

    r47847 r47951  
    2727class QHBoxLayout;
    2828class QLabel;
     29class QTimer;
    2930
    3031/* Warning-pane prototype: */
     
    5051    void registerValidator(UIPageValidator *pValidator);
    5152
     53private slots:
     54
     55    /* Handler: Hover stuff: */
     56    void sltHandleHoverTimer();
     57
    5258private:
    5359
     
    6571    QList<QLabel*> m_icons;
    6672    QList<bool> m_hovered;
     73    QTimer *m_pHoverTimer;
     74    int m_iHoveredIconLabelPosition;
    6775};
    6876
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