VirtualBox

Changeset 47761 in vbox


Ignore:
Timestamp:
Aug 15, 2013 1:02:43 PM (11 years ago)
Author:
vboxsync
Message:

FE/Qt: Settings Dialog: Warning-pane: Mouse hovering stuff.

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

Legend:

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

    r47616 r47761  
    2121#include <QHBoxLayout>
    2222#include <QLabel>
     23#include <QEvent>
    2324
    2425/* GUI includes: */
     
    2930    , m_pLabelIcon(0)
    3031    , m_pLabelText(0)
     32    , m_fHovered(false)
    3133{
    3234    /* Prepare: */
     
    5254void UIWarningPane::prepareContent()
    5355{
     56    /* Configure self: */
     57    setMouseTracking(true);
     58    installEventFilter(this);
    5459    /* Create layout: */
    5560    QHBoxLayout *pLayout = new QHBoxLayout(this);
     
    5964        /* Create icon label: */
    6065        m_pLabelIcon = new QLabel;
     66        {
     67            /* Configure icon label: */
     68            m_pLabelIcon->setMouseTracking(true);
     69            m_pLabelIcon->installEventFilter(this);
     70        }
    6171        /* Create text label: */
    6272        m_pLabelText = new QLabel;
     73        {
     74            /* Configure text label: */
     75            m_pLabelText->setMouseTracking(true);
     76            m_pLabelText->installEventFilter(this);
     77        }
    6378        /* Add widgets into layout: */
    6479        pLayout->addWidget(m_pLabelIcon);
     
    6782}
    6883
     84bool UIWarningPane::eventFilter(QObject *pWatched, QEvent *pEvent)
     85{
     86    /* Depending on event-type: */
     87    switch (pEvent->type())
     88    {
     89        /* Anything is hovered: */
     90        case QEvent::MouseMove:
     91        {
     92            /* Hover warning-pane if not yet hovered: */
     93            if (!m_fHovered)
     94            {
     95                m_fHovered = true;
     96                emit sigHoverEnter();
     97            }
     98            break;
     99        }
     100        /* Warning-pane is unhovered: */
     101        case QEvent::Leave:
     102        {
     103            /* Unhover warning-pane if hovered: */
     104            if (pWatched == this && m_fHovered)
     105            {
     106                m_fHovered = false;
     107                emit sigHoverLeave();
     108            }
     109            break;
     110        }
     111        /* Default case: */
     112        default: break;
     113    }
     114    /* Call to base-class: */
     115    return QWidget::eventFilter(pWatched, pEvent);
     116}
     117
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIWarningPane.h

    r47616 r47761  
    3131    Q_OBJECT;
    3232
     33signals:
     34
     35    /* Notifiers: Hover stuff: */
     36    void sigHoverEnter();
     37    void sigHoverLeave();
     38
    3339public:
    3440
     
    4652    void prepareContent();
    4753
     54    /* Handler: Event processing stuff: */
     55    bool eventFilter(QObject *pWatched, QEvent *pEvent);
     56
    4857    /* Variables: Widgets: */
    4958    QLabel *m_pLabelIcon;
    5059    QLabel *m_pLabelText;
     60
     61    /* Variable: Hover stuff: */
     62    bool m_fHovered;
    5163};
    5264
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