1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 14:28:24 +01:00

Correctly paint hover state in DropDownButton

This commit is contained in:
Dominik Schmidt 2016-01-17 05:17:15 +01:00
parent 996d112ebb
commit f95bd4aab8
2 changed files with 23 additions and 1 deletions

View File

@ -32,7 +32,9 @@ using namespace Tomahawk;
DropDownButton::DropDownButton( QWidget* parent )
: QComboBox( parent )
, m_hovering( false )
{
setAttribute( Qt::WA_Hover, true );
}
@ -49,7 +51,7 @@ DropDownButton::paintEvent( QPaintEvent* event )
setupPainter( &p );
drawPrimitive( &p, contentsRect(), currentText(), true, true );
drawPrimitive( &p, contentsRect(), currentText(), m_hovering, true );
}
@ -118,6 +120,22 @@ DropDownButton::mousePressEvent( QMouseEvent* event )
}
void
DropDownButton::enterEvent( QEvent * event )
{
m_hovering = true;
QWidget::enterEvent(event);
}
void
DropDownButton::leaveEvent( QEvent* event )
{
m_hovering = false;
QWidget::leaveEvent(event);
}
void
DropDownButton::setupPainter( QPainter* p )
{

View File

@ -42,11 +42,15 @@ signals:
protected:
void paintEvent( QPaintEvent* event );
void mousePressEvent( QMouseEvent* event );
void enterEvent( QEvent* event );
void leaveEvent( QEvent* event );
private slots:
private:
static void setupPainter( QPainter* p );
bool m_hovering;
};
#endif // DROPDOWNBUTTON_H