diff --git a/src/tomahawk/TomahawkWindow.cpp b/src/tomahawk/TomahawkWindow.cpp index 99c86439a..75a41860f 100644 --- a/src/tomahawk/TomahawkWindow.cpp +++ b/src/tomahawk/TomahawkWindow.cpp @@ -96,12 +96,6 @@ #endif #endif #include - #if QT_VERSION < QT_VERSION_CHECK(5,2,0) - #include - #ifndef THBN_CLICKED - #define THBN_CLICKED 0x1800 - #endif - #endif #endif using namespace Tomahawk; @@ -536,6 +530,9 @@ TomahawkWindow::setupWindowsButtons() { m_taskbarList = new QWinThumbnailToolBar( this ); m_taskbarList->setWindow( this->windowHandle() ); + m_taskbarList->setIconicPixmapNotificationsEnabled( true ); + connect( m_taskbarList , &QWinThumbnailToolBar::iconicThumbnailPixmapRequested , this , &TomahawkWindow::updatePreview); + connect( m_taskbarList , &QWinThumbnailToolBar::iconicLivePreviewPixmapRequested , this , &TomahawkWindow::updatePreview); QWinThumbnailToolButton *back = new QWinThumbnailToolButton( m_taskbarList ); back->setToolTip( tr( "Back" ) ); @@ -571,6 +568,64 @@ TomahawkWindow::setupWindowsButtons() m_taskbarList->addButton(love); } +void +TomahawkWindow::updatePreview() +{ + qDebug() << "Update cover"; + const QSize coverSize( 500 , 500 ); + const QSize size(900,600); + QPixmap cover; + + if ( !AudioEngine::instance()->currentTrack().isNull() ) { + cover = AudioEngine::instance()->currentTrack()->track()->albumPtr()->cover( coverSize , false ); + } + if ( cover.isNull() ) { + cover = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultAlbumCover , TomahawkUtils::Original, coverSize ); + } + + QPixmap thumb(size); + thumb.fill(Qt::white); + + QPainter paint(&thumb); + paint.drawPixmap((size.width() - coverSize.width())/2 ,0, coverSize.width(), coverSize.height(), cover); + + QFont font = paint.font(); + font.setPointSize(40); + paint.setFont(font); + paint.setPen(Qt::black); + paint.drawText(QRect(0,coverSize.height(),size.width(),size.height() - coverSize.height()),windowTitle()); + + m_taskbarList->setIconicThumbnailPixmap( thumb ); + m_taskbarList->setIconicLivePreviewPixmap( thumb ); +} + +void +TomahawkWindow::updateWindowsLoveButton() +{ + QWinThumbnailToolButton *love = m_taskbarList->buttons()[ TP_LOVE ]; + + if ( !AudioEngine::instance()->currentTrack().isNull() ) + { + love->setInteractive(true); + if ( AudioEngine::instance()->currentTrack()->track()->loved() ) + { + love->setIcon(thumbIcon(TomahawkUtils::Loved)); + love->setToolTip( tr( "Unlove" ) ); + } + else + { + love->setIcon( thumbIcon(TomahawkUtils::NotLoved) ); + love->setToolTip( tr( "Love" ) ); + } + } + else + { + love->setInteractive(false); + love->setIcon( thumbIcon(TomahawkUtils::NotLoved) ); + love->setToolTip( tr( "Love" ) ); + } +} + QIcon TomahawkWindow::thumbIcon(TomahawkUtils::ImageType type) { @@ -774,6 +829,8 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState ) #ifndef Q_OS_WIN Q_UNUSED(newState); #else + updatePreview(); + QWinThumbnailToolButton *play = m_taskbarList->buttons()[ TP_PLAY_PAUSE ]; switch ( newState ) { @@ -782,7 +839,6 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState ) play->setIcon( thumbIcon(TomahawkUtils::PauseButton) ); play->setToolTip( tr( "Pause" ) ); updateWindowsLoveButton(); - } break; @@ -815,37 +871,6 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState ) #endif//Q_OS_WIN } - -void -TomahawkWindow::updateWindowsLoveButton() -{ -#if defined(Q_OS_WIN) - QWinThumbnailToolButton *love = m_taskbarList->buttons()[ TP_LOVE ]; - - if ( !AudioEngine::instance()->currentTrack().isNull() ) - { - love->setInteractive(true); - if ( AudioEngine::instance()->currentTrack()->track()->loved() ) - { - love->setIcon(thumbIcon(TomahawkUtils::Loved)); - love->setToolTip( tr( "Unlove" ) ); - } - else - { - love->setIcon( thumbIcon(TomahawkUtils::NotLoved) ); - love->setToolTip( tr( "Love" ) ); - } - } - else - { - love->setInteractive(false); - love->setIcon( thumbIcon(TomahawkUtils::NotLoved) ); - love->setToolTip( tr( "Love" ) ); - } -#endif//defined(Q_OS_WIN) -} - - void TomahawkWindow::onHistoryBackAvailable( bool avail ) { diff --git a/src/tomahawk/TomahawkWindow.h b/src/tomahawk/TomahawkWindow.h index 0b2fe4076..a21053928 100644 --- a/src/tomahawk/TomahawkWindow.h +++ b/src/tomahawk/TomahawkWindow.h @@ -149,7 +149,11 @@ private slots: void toggleLoved(); void audioStateChanged( AudioState newState, AudioState oldState ); + +#ifdef Q_OS_WIN void updateWindowsLoveButton(); + void updatePreview(); +#endif private: void loadSettings();