mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 00:09:47 +01:00
* OverlayWidget now expects a QAbstractItemView which it automatically connects all signals to.
This commit is contained in:
parent
7a8818ae94
commit
7bdc5ea4f2
@ -30,7 +30,7 @@
|
||||
#define OPACITY 0.70
|
||||
|
||||
|
||||
OverlayWidget::OverlayWidget( QWidget* parent )
|
||||
OverlayWidget::OverlayWidget( QAbstractItemView* parent )
|
||||
: QWidget( parent ) // this is on purpose!
|
||||
, m_opacity( 0.00 )
|
||||
, m_parent( parent )
|
||||
@ -42,6 +42,12 @@ OverlayWidget::OverlayWidget( QWidget* parent )
|
||||
|
||||
m_timer.setSingleShot( true );
|
||||
connect( &m_timer, SIGNAL( timeout() ), this, SLOT( hide() ) );
|
||||
|
||||
if ( m_parent->model() )
|
||||
{
|
||||
connect( m_parent->model(), SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ), Qt::UniqueConnection );
|
||||
}
|
||||
connect( m_parent, SIGNAL( modelChanged() ), SLOT( onViewModelChanged() ) );
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
QFont f( font() );
|
||||
@ -120,6 +126,31 @@ OverlayWidget::shown() const
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OverlayWidget::onViewChanged()
|
||||
{
|
||||
if ( m_parent->model()->rowCount() )
|
||||
{
|
||||
hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OverlayWidget::onViewModelChanged()
|
||||
{
|
||||
if ( m_parent->model() )
|
||||
{
|
||||
connect( m_parent->model(), SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ), Qt::UniqueConnection );
|
||||
onViewChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OverlayWidget::paintEvent( QPaintEvent* event )
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ Q_OBJECT
|
||||
Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity )
|
||||
|
||||
public:
|
||||
OverlayWidget( QWidget* parent );
|
||||
OverlayWidget( QAbstractItemView* parent );
|
||||
~OverlayWidget();
|
||||
|
||||
qreal opacity() const { return m_opacity; }
|
||||
@ -49,12 +49,16 @@ public slots:
|
||||
protected:
|
||||
// void changeEvent( QEvent* e );
|
||||
void paintEvent( QPaintEvent* event );
|
||||
|
||||
private slots:
|
||||
void onViewChanged();
|
||||
void onViewModelChanged();
|
||||
|
||||
private:
|
||||
QString m_text;
|
||||
qreal m_opacity;
|
||||
|
||||
QWidget* m_parent;
|
||||
QAbstractItemView* m_parent;
|
||||
QTimer m_timer;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user