mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 07:07:05 +02:00
Merge remote branch 'origin/master' into dynamic
Conflicts: src/libtomahawk/widgets/overlaywidget.cpp
This commit is contained in:
@@ -110,7 +110,6 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << ql.length();
|
qDebug() << Q_FUNC_INFO << ql.length();
|
||||||
|
|
||||||
if ( ql.count() )
|
emit tracks( ql, m_collection );
|
||||||
emit tracks( ql, m_collection );
|
|
||||||
emit done( m_collection );
|
emit done( m_collection );
|
||||||
}
|
}
|
||||||
|
@@ -159,7 +159,10 @@ void
|
|||||||
CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
CollectionFlatModel::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
||||||
{
|
{
|
||||||
if ( !tracks.count() )
|
if ( !tracks.count() )
|
||||||
|
{
|
||||||
|
emit trackCountChanged( rowCount( QModelIndex() ) );
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int c = rowCount( QModelIndex() );
|
int c = rowCount( QModelIndex() );
|
||||||
QPair< int, int > crows;
|
QPair< int, int > crows;
|
||||||
|
@@ -32,6 +32,15 @@ CollectionView::~CollectionView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CollectionView::setModel( TrackModel* model )
|
||||||
|
{
|
||||||
|
TrackView::setModel( model );
|
||||||
|
|
||||||
|
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CollectionView::dragEnterEvent( QDragEnterEvent* event )
|
CollectionView::dragEnterEvent( QDragEnterEvent* event )
|
||||||
{
|
{
|
||||||
@@ -74,14 +83,13 @@ CollectionView::onCustomContextMenu( const QPoint& pos )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CollectionView::paintEvent( QPaintEvent* event )
|
CollectionView::onTrackCountChanged( unsigned int tracks )
|
||||||
{
|
{
|
||||||
TrackView::paintEvent( event );
|
if ( tracks == 0 )
|
||||||
QPainter painter( viewport() );
|
|
||||||
|
|
||||||
if ( !model()->trackCount() )
|
|
||||||
{
|
{
|
||||||
overlay()->setText( tr( "This collection is empty." ) );
|
overlay()->setText( tr( "This collection is empty." ) );
|
||||||
overlay()->paint( &painter );
|
overlay()->show();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
overlay()->hide();
|
||||||
}
|
}
|
||||||
|
@@ -15,12 +15,14 @@ public:
|
|||||||
explicit CollectionView( QWidget* parent = 0 );
|
explicit CollectionView( QWidget* parent = 0 );
|
||||||
~CollectionView();
|
~CollectionView();
|
||||||
|
|
||||||
|
virtual void setModel( TrackModel* model );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCustomContextMenu( const QPoint& pos );
|
void onCustomContextMenu( const QPoint& pos );
|
||||||
|
void onTrackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void dragEnterEvent( QDragEnterEvent* event );
|
virtual void dragEnterEvent( QDragEnterEvent* event );
|
||||||
void paintEvent( QPaintEvent* event );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupMenus();
|
void setupMenus();
|
||||||
|
@@ -20,22 +20,12 @@
|
|||||||
#include "trackmodel.h"
|
#include "trackmodel.h"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
DynamicView::DynamicView( QWidget* parent )
|
DynamicView::DynamicView( QWidget* parent )
|
||||||
: PlaylistView( parent )
|
: PlaylistView( parent )
|
||||||
{
|
{
|
||||||
m_showTimer.setInterval( 5000 );
|
|
||||||
m_showTimer.setSingleShot( true );
|
|
||||||
|
|
||||||
m_fadeOut = new QPropertyAnimation( overlay(), "opacity" );
|
|
||||||
m_fadeOut->setDuration( 500 );
|
|
||||||
m_fadeOut->setEndValue( 0 );
|
|
||||||
m_fadeOut->setEasingCurve( QEasingCurve::InOutQuad );
|
|
||||||
|
|
||||||
connect( &m_showTimer, SIGNAL( timeout() ), m_fadeOut, SLOT( start() ) );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,27 +34,33 @@ DynamicView::~DynamicView()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DynamicView::setModel( TrackModel* model)
|
||||||
|
{
|
||||||
|
PlaylistView::setModel( model );
|
||||||
|
|
||||||
|
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::showMessageTimeout( const QString& title, const QString& body )
|
DynamicView::showMessageTimeout( const QString& title, const QString& body )
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
m_body = body;
|
m_body = body;
|
||||||
m_showTimer.start();
|
|
||||||
viewport()->update();
|
overlay()->setText( QString( "%1:\n\n%2" ).arg( m_title, m_body ) );
|
||||||
|
overlay()->show( 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::paintEvent( QPaintEvent* event )
|
DynamicView::onTrackCountChanged( unsigned int tracks )
|
||||||
{
|
{
|
||||||
QPainter painter( viewport() );
|
if ( tracks == 0 )
|
||||||
if ( m_showTimer.isActive() || m_fadeOut->state() == QPropertyAnimation::Running )
|
|
||||||
{
|
{
|
||||||
overlay()->setText( QString( "%1:\n\n%2" ).arg( m_title, m_body ) );
|
|
||||||
overlay()->paint( &painter );
|
|
||||||
} else if( !model()->trackCount() ) {
|
|
||||||
overlay()->setText( tr( "Add some filters above, and press Generate to get started!" ) );
|
overlay()->setText( tr( "Add some filters above, and press Generate to get started!" ) );
|
||||||
overlay()->paint( &painter );
|
overlay()->show();
|
||||||
} else {
|
|
||||||
PlaylistView::paintEvent( event );
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
overlay()->hide();
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
|
class TrackModel;
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -31,11 +32,13 @@ public:
|
|||||||
explicit DynamicView( QWidget* parent = 0 );
|
explicit DynamicView( QWidget* parent = 0 );
|
||||||
virtual ~DynamicView();
|
virtual ~DynamicView();
|
||||||
|
|
||||||
|
virtual void setModel( TrackModel* model );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showMessageTimeout( const QString& title, const QString& body );
|
void showMessageTimeout( const QString& title, const QString& body );
|
||||||
|
|
||||||
protected:
|
private slots:
|
||||||
virtual void paintEvent( QPaintEvent* event );
|
void onTrackCountChanged( unsigned int );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer m_showTimer;
|
QTimer m_showTimer;
|
||||||
|
@@ -90,8 +90,8 @@ PlaylistModel::loadPlaylist( const Tomahawk::playlist_ptr& playlist )
|
|||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << rowCount( QModelIndex() );
|
|
||||||
emit loadingFinished();
|
emit loadingFinished();
|
||||||
|
emit trackCountChanged( rowCount( QModelIndex() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -194,7 +194,10 @@ void
|
|||||||
PlaylistModel::onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
PlaylistModel::onTracksInserted( unsigned int row, const QList<Tomahawk::query_ptr>& tracks, const Tomahawk::collection_ptr& collection )
|
||||||
{
|
{
|
||||||
if ( !tracks.count() )
|
if ( !tracks.count() )
|
||||||
|
{
|
||||||
|
emit trackCountChanged( rowCount( QModelIndex() ) );
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int c = row;
|
int c = row;
|
||||||
QPair< int, int > crows;
|
QPair< int, int > crows;
|
||||||
@@ -220,7 +223,6 @@ PlaylistModel::onTracksInserted( unsigned int row, const QList<Tomahawk::query_p
|
|||||||
|
|
||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
emit trackCountChanged( rowCount( QModelIndex() ) );
|
emit trackCountChanged( rowCount( QModelIndex() ) );
|
||||||
qDebug() << rowCount( QModelIndex() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -30,8 +30,9 @@ void
|
|||||||
PlaylistView::setModel( TrackModel* model )
|
PlaylistView::setModel( TrackModel* model )
|
||||||
{
|
{
|
||||||
TrackView::setModel( model );
|
TrackView::setModel( model );
|
||||||
|
|
||||||
setColumnHidden( 5, true ); // Hide age column per default
|
setColumnHidden( 5, true ); // Hide age column per default
|
||||||
|
|
||||||
|
connect( model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -110,14 +111,13 @@ PlaylistView::deleteItems()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlaylistView::paintEvent( QPaintEvent* event )
|
PlaylistView::onTrackCountChanged( unsigned int tracks )
|
||||||
{
|
{
|
||||||
TrackView::paintEvent( event );
|
if ( tracks == 0 )
|
||||||
QPainter painter( viewport() );
|
|
||||||
|
|
||||||
if ( !model()->trackCount() )
|
|
||||||
{
|
{
|
||||||
overlay()->setText( tr( "This playlist is currently empty. Add some tracks to it and enjoy the music!" ) );
|
overlay()->setText( tr( "This playlist is currently empty. Add some tracks to it and enjoy the music!" ) );
|
||||||
overlay()->paint( &painter );
|
overlay()->show();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
overlay()->hide();
|
||||||
}
|
}
|
||||||
|
@@ -15,14 +15,14 @@ public:
|
|||||||
explicit PlaylistView( QWidget* parent = 0 );
|
explicit PlaylistView( QWidget* parent = 0 );
|
||||||
~PlaylistView();
|
~PlaylistView();
|
||||||
|
|
||||||
void setModel( TrackModel* model );
|
virtual void setModel( TrackModel* model );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent( QKeyEvent* event );
|
void keyPressEvent( QKeyEvent* event );
|
||||||
void paintEvent( QPaintEvent* event );
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCustomContextMenu( const QPoint& pos );
|
void onCustomContextMenu( const QPoint& pos );
|
||||||
|
void onTrackCountChanged( unsigned int tracks );
|
||||||
|
|
||||||
void addItemsToPlaylist();
|
void addItemsToPlaylist();
|
||||||
void deleteItems();
|
void deleteItems();
|
||||||
|
@@ -251,13 +251,6 @@ TrackView::paintEvent( QPaintEvent* event )
|
|||||||
QTreeView::paintEvent( event );
|
QTreeView::paintEvent( event );
|
||||||
QPainter painter( viewport() );
|
QPainter painter( viewport() );
|
||||||
|
|
||||||
if ( !proxyModel()->filter().isEmpty() && !proxyModel()->trackCount() &&
|
|
||||||
model()->trackCount() )
|
|
||||||
{
|
|
||||||
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->filter() ) );
|
|
||||||
m_overlay->paint( &painter );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_dragging )
|
if ( m_dragging )
|
||||||
{
|
{
|
||||||
// draw drop indicator
|
// draw drop indicator
|
||||||
@@ -289,6 +282,16 @@ TrackView::onFilterChanged( const QString& )
|
|||||||
{
|
{
|
||||||
if ( selectedIndexes().count() )
|
if ( selectedIndexes().count() )
|
||||||
scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter );
|
scrollTo( selectedIndexes().at( 0 ), QAbstractItemView::PositionAtCenter );
|
||||||
|
|
||||||
|
if ( !proxyModel()->filter().isEmpty() && !proxyModel()->trackCount() &&
|
||||||
|
model()->trackCount() )
|
||||||
|
{
|
||||||
|
m_overlay->setText( tr( "Sorry, your filter '%1' did not match any results." ).arg( proxyModel()->filter() ) );
|
||||||
|
m_overlay->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if ( model()->trackCount() )
|
||||||
|
m_overlay->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ public:
|
|||||||
TrackHeader* header() const { return m_header; }
|
TrackHeader* header() const { return m_header; }
|
||||||
OverlayWidget* overlay() const { return m_overlay; }
|
OverlayWidget* overlay() const { return m_overlay; }
|
||||||
|
|
||||||
void setModel( TrackModel* model );
|
virtual void setModel( TrackModel* model );
|
||||||
|
|
||||||
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
|
QModelIndex contextMenuIndex() const { return m_contextMenuIndex; }
|
||||||
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
|
void setContextMenuIndex( const QModelIndex& idx ) { m_contextMenuIndex = idx; }
|
||||||
|
@@ -4,18 +4,24 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
#define CORNER_ROUNDNESS 32.0
|
#define CORNER_ROUNDNESS 16.0
|
||||||
#define FADEIN_DURATION 500
|
#define FADING_DURATION 500
|
||||||
#define FONT_SIZE 18
|
#define FONT_SIZE 18
|
||||||
#define OPACITY 0.80
|
#define OPACITY 0.86
|
||||||
|
|
||||||
|
|
||||||
OverlayWidget::OverlayWidget( QAbstractItemView* parent )
|
OverlayWidget::OverlayWidget( QWidget* parent )
|
||||||
: QWidget() // this is on purpose!
|
: QWidget( parent ) // this is on purpose!
|
||||||
|
, m_opacity( 0.00 )
|
||||||
, m_parent( parent )
|
, m_parent( parent )
|
||||||
{
|
{
|
||||||
resize( 380, 220 );
|
resize( 380, 220 );
|
||||||
setAttribute( Qt::WA_TranslucentBackground, true );
|
setAttribute( Qt::WA_TranslucentBackground, true );
|
||||||
|
|
||||||
|
setOpacity( m_opacity );
|
||||||
|
|
||||||
|
m_timer.setSingleShot( true );
|
||||||
|
connect( &m_timer, SIGNAL( timeout() ), this, SLOT( hide() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -28,77 +34,67 @@ void
|
|||||||
OverlayWidget::setOpacity( qreal opacity )
|
OverlayWidget::setOpacity( qreal opacity )
|
||||||
{
|
{
|
||||||
m_opacity = opacity;
|
m_opacity = opacity;
|
||||||
m_parent->viewport()->update();
|
|
||||||
|
if ( m_opacity == 0.00 && !isHidden() )
|
||||||
|
{
|
||||||
|
QWidget::hide();
|
||||||
|
}
|
||||||
|
else if ( m_opacity > 0.00 && isHidden() )
|
||||||
|
{
|
||||||
|
QWidget::show();
|
||||||
|
}
|
||||||
|
|
||||||
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
OverlayWidget::setText( const QString& text )
|
OverlayWidget::setText( const QString& text )
|
||||||
{
|
{
|
||||||
if ( text == m_text )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ( isEnabled() )
|
|
||||||
{
|
|
||||||
QPropertyAnimation* animation = new QPropertyAnimation( this, "opacity" );
|
|
||||||
animation->setDuration( FADEIN_DURATION );
|
|
||||||
animation->setStartValue( 0.00 );
|
|
||||||
animation->setEndValue( OPACITY );
|
|
||||||
animation->start();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
m_opacity = OPACITY;
|
|
||||||
|
|
||||||
m_text = text;
|
m_text = text;
|
||||||
m_pixmap = QPixmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QPixmap
|
|
||||||
OverlayWidget::pixmap()
|
|
||||||
{
|
|
||||||
if ( m_pixmap.isNull() )
|
|
||||||
{
|
|
||||||
QPixmap p( contentsRect().size() );
|
|
||||||
p.fill( Qt::transparent );
|
|
||||||
render( &p );
|
|
||||||
|
|
||||||
m_pixmap = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_pixmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
OverlayWidget::paint( QPainter* painter )
|
OverlayWidget::show( int timeoutSecs )
|
||||||
{
|
{
|
||||||
if ( !isEnabled() )
|
QPropertyAnimation* animation = new QPropertyAnimation( this, "opacity" );
|
||||||
return;
|
animation->setDuration( FADING_DURATION );
|
||||||
|
animation->setStartValue( 0.00 );
|
||||||
|
animation->setEndValue( OPACITY );
|
||||||
|
animation->start();
|
||||||
|
|
||||||
|
if( timeoutSecs > 0 )
|
||||||
|
m_timer.start( timeoutSecs * 1000 );
|
||||||
|
}
|
||||||
|
|
||||||
pixmap(); // cache the image
|
|
||||||
|
|
||||||
QRect center( QPoint( ( painter->viewport().width() - m_pixmap.width() ) / 2,
|
void
|
||||||
( painter->viewport().height() - m_pixmap.height() ) / 2 ), m_pixmap.size() );
|
OverlayWidget::hide()
|
||||||
|
{
|
||||||
painter->save();
|
QPropertyAnimation* animation = new QPropertyAnimation( this, "opacity" );
|
||||||
painter->setOpacity( m_opacity );
|
animation->setDuration( FADING_DURATION );
|
||||||
painter->drawPixmap( center, m_pixmap );
|
animation->setEndValue( 0.00 );
|
||||||
painter->restore();
|
animation->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
OverlayWidget::paintEvent( QPaintEvent* event )
|
OverlayWidget::paintEvent( QPaintEvent* event )
|
||||||
{
|
{
|
||||||
|
QPoint center( ( m_parent->width() - width() ) / 2, ( m_parent->height() - height() ) / 2 );
|
||||||
|
move( center );
|
||||||
|
|
||||||
QPainter p( this );
|
QPainter p( this );
|
||||||
QRect r = contentsRect();
|
QRect r = contentsRect();
|
||||||
|
|
||||||
p.setBackgroundMode( Qt::TransparentMode );
|
p.setBackgroundMode( Qt::TransparentMode );
|
||||||
p.setRenderHint( QPainter::Antialiasing );
|
p.setRenderHint( QPainter::Antialiasing );
|
||||||
|
p.setOpacity( m_opacity );
|
||||||
|
|
||||||
p.setPen( palette().shadow().color() );
|
QPen pen( palette().dark().color(), .5 );
|
||||||
p.setBrush( palette().shadow() );
|
p.setPen( pen );
|
||||||
|
p.setBrush( palette().highlight() );
|
||||||
|
|
||||||
p.drawRoundedRect( r, CORNER_ROUNDNESS, CORNER_ROUNDNESS );
|
p.drawRoundedRect( r, CORNER_ROUNDNESS, CORNER_ROUNDNESS );
|
||||||
|
|
||||||
@@ -110,6 +106,6 @@ OverlayWidget::paintEvent( QPaintEvent* event )
|
|||||||
f.setBold( true );
|
f.setBold( true );
|
||||||
|
|
||||||
p.setFont( f );
|
p.setFont( f );
|
||||||
p.setPen( palette().light().color() );
|
p.setPen( palette().highlightedText().color() );
|
||||||
p.drawText( r.adjusted( 16, 16, -16, -16 ), text(), to );
|
p.drawText( r.adjusted( 16, 16, -16, -16 ), text(), to );
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include <QAbstractItemView>
|
#include <QAbstractItemView>
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
class DLLEXPORT OverlayWidget : public QWidget
|
class DLLEXPORT OverlayWidget : public QWidget
|
||||||
{
|
{
|
||||||
@@ -12,18 +13,18 @@ Q_OBJECT
|
|||||||
Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity )
|
Q_PROPERTY( qreal opacity READ opacity WRITE setOpacity )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OverlayWidget( QAbstractItemView* parent );
|
OverlayWidget( QWidget* parent );
|
||||||
~OverlayWidget();
|
~OverlayWidget();
|
||||||
|
|
||||||
QPixmap pixmap();
|
|
||||||
|
|
||||||
qreal opacity() const { return m_opacity; }
|
qreal opacity() const { return m_opacity; }
|
||||||
void setOpacity( qreal opacity );
|
void setOpacity( qreal opacity );
|
||||||
|
|
||||||
QString text() const { return m_text; }
|
QString text() const { return m_text; }
|
||||||
void setText( const QString& text );
|
void setText( const QString& text );
|
||||||
|
|
||||||
void paint( QPainter* painter );
|
public slots:
|
||||||
|
void show( int timeoutSecs = 0 );
|
||||||
|
void hide();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// void changeEvent( QEvent* e );
|
// void changeEvent( QEvent* e );
|
||||||
@@ -31,10 +32,10 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_text;
|
QString m_text;
|
||||||
QPixmap m_pixmap;
|
|
||||||
qreal m_opacity;
|
qreal m_opacity;
|
||||||
|
|
||||||
QAbstractItemView* m_parent;
|
QWidget* m_parent;
|
||||||
|
QTimer m_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WELCOMEWIDGET_H
|
#endif // OVERLAYWIDGET_H
|
||||||
|
@@ -56,6 +56,14 @@ WelcomeWidget::updatePlaylists()
|
|||||||
ui->playlistWidget->addItem( item );
|
ui->playlistWidget->addItem( item );
|
||||||
item->setData( Qt::DisplayRole, playlist->title() );
|
item->setData( Qt::DisplayRole, playlist->title() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !playlists.count() )
|
||||||
|
{
|
||||||
|
ui->playlistWidget->overlay()->setText( tr( "You have not played any playlists yet." ) );
|
||||||
|
ui->playlistWidget->overlay()->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ui->playlistWidget->overlay()->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -178,3 +186,10 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PlaylistWidget::PlaylistWidget( QWidget* parent )
|
||||||
|
: QListWidget( parent )
|
||||||
|
{
|
||||||
|
m_overlay = new OverlayWidget( this );
|
||||||
|
}
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
class PlaylistModel;
|
class PlaylistModel;
|
||||||
|
class OverlayWidget;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@@ -60,6 +61,18 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class DLLEXPORT PlaylistWidget : public QListWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlaylistWidget( QWidget* parent = 0 );
|
||||||
|
|
||||||
|
OverlayWidget* overlay() const { return m_overlay; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
OverlayWidget* m_overlay;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT WelcomeWidget : public QWidget
|
class DLLEXPORT WelcomeWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="playlistWidget"/>
|
<widget class="PlaylistWidget" name="playlistWidget"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
@@ -66,6 +66,11 @@
|
|||||||
<extends>QTreeView</extends>
|
<extends>QTreeView</extends>
|
||||||
<header>playlist/playlistview.h</header>
|
<header>playlist/playlistview.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>PlaylistWidget</class>
|
||||||
|
<extends>QListWidget</extends>
|
||||||
|
<header>widgets/welcomewidget.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@@ -140,6 +140,9 @@ Scrobbler::scrobble()
|
|||||||
{
|
{
|
||||||
Q_ASSERT( QThread::currentThread() == thread() );
|
Q_ASSERT( QThread::currentThread() == thread() );
|
||||||
|
|
||||||
|
if ( !m_scrobbler || m_track.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << m_track.toString();
|
qDebug() << Q_FUNC_INFO << m_track.toString();
|
||||||
m_scrobbler->cache( m_track );
|
m_scrobbler->cache( m_track );
|
||||||
m_scrobbler->submit();
|
m_scrobbler->submit();
|
||||||
|
Reference in New Issue
Block a user