mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02:00
improved support for thumbnail buttons
This commit is contained in:
@@ -73,7 +73,6 @@
|
|||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <qtsparkle/Updater>
|
#include <qtsparkle/Updater>
|
||||||
#include <shobjidl.h>
|
|
||||||
#ifndef THBN_CLICKED
|
#ifndef THBN_CLICKED
|
||||||
#define THBN_CLICKED 0x1800
|
#define THBN_CLICKED 0x1800
|
||||||
#endif
|
#endif
|
||||||
@@ -89,6 +88,7 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
|||||||
: QMainWindow( parent )
|
: QMainWindow( parent )
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
, m_buttonCreatedID( RegisterWindowMessage( L"TaskbarButtonCreated" ) )
|
, m_buttonCreatedID( RegisterWindowMessage( L"TaskbarButtonCreated" ) )
|
||||||
|
, m_taskbarList(0)
|
||||||
#endif
|
#endif
|
||||||
, ui( new Ui::TomahawkWindow )
|
, ui( new Ui::TomahawkWindow )
|
||||||
, m_searchWidget( 0 )
|
, m_searchWidget( 0 )
|
||||||
@@ -103,6 +103,9 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
|||||||
connect( vm, SIGNAL( hideQueueRequested() ), SLOT( hideQueue() ) );
|
connect( vm, SIGNAL( hideQueueRequested() ), SLOT( hideQueue() ) );
|
||||||
connect( APP, SIGNAL( tomahawkLoaded() ), vm, SLOT( setTomahawkLoaded() ) ); // Pass loaded signal into libtomahawk so components in there can connect to ViewManager
|
connect( APP, SIGNAL( tomahawkLoaded() ), vm, SLOT( setTomahawkLoaded() ) ); // Pass loaded signal into libtomahawk so components in there can connect to ViewManager
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
connect(AudioEngine::instance(),SIGNAL(stateChanged(AudioState,AudioState)),this,SLOT(audioStateChanged(AudioState,AudioState)));
|
||||||
|
#endif
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
|
|
||||||
ui->menuApp->insertAction( ui->actionCreatePlaylist, ActionCollection::instance()->getAction( "togglePrivacy" ) );
|
ui->menuApp->insertAction( ui->actionCreatePlaylist, ActionCollection::instance()->getAction( "togglePrivacy" ) );
|
||||||
@@ -337,7 +340,6 @@ TomahawkWindow::setupWindowsButtons()
|
|||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
QPixmap play( RESPATH "images/play-rest.png" );
|
QPixmap play( RESPATH "images/play-rest.png" );
|
||||||
QPixmap pause( RESPATH "images/pause-rest.png" );
|
|
||||||
QPixmap back( RESPATH "images/back-rest.png" );
|
QPixmap back( RESPATH "images/back-rest.png" );
|
||||||
QPixmap love( RESPATH "images/not-loved.png" );
|
QPixmap love( RESPATH "images/not-loved.png" );
|
||||||
|
|
||||||
@@ -345,43 +347,50 @@ TomahawkWindow::setupWindowsButtons()
|
|||||||
transform.rotate( 180 );
|
transform.rotate( 180 );
|
||||||
QPixmap next( back.transformed( transform ) );
|
QPixmap next( back.transformed( transform ) );
|
||||||
|
|
||||||
THUMBBUTTON thumbButtons[5];
|
THUMBBUTTONMASK dwMask = THUMBBUTTONMASK( THB_ICON | THB_TOOLTIP | THB_FLAGS );
|
||||||
|
m_thumbButtons[0].dwMask = dwMask;
|
||||||
|
m_thumbButtons[0].iId = PREVIOUS;
|
||||||
|
m_thumbButtons[0].hIcon = back.toWinHICON();
|
||||||
|
m_thumbButtons[0].dwFlags = THBF_ENABLED;
|
||||||
|
m_thumbButtons[0].szTip[ tr( "Back" ).toWCharArray( m_thumbButtons[0].szTip ) ] = 0;
|
||||||
|
|
||||||
THUMBBUTTONMASK dwMask = THUMBBUTTONMASK( THB_ICON | THB_TOOLTIP );
|
m_thumbButtons[1].dwMask = dwMask;
|
||||||
thumbButtons[0].dwMask = dwMask;
|
m_thumbButtons[1].iId = PLAY_PAUSE;
|
||||||
thumbButtons[0].iId = 1;
|
m_thumbButtons[1].hIcon = play.toWinHICON();
|
||||||
thumbButtons[0].hIcon = back.toWinHICON();
|
m_thumbButtons[1].dwFlags = THBF_ENABLED;
|
||||||
thumbButtons[0].szTip[ tr( "Back" ).toWCharArray( thumbButtons[0].szTip ) ] = 0;
|
m_thumbButtons[1].szTip[ tr( "Play" ).toWCharArray( m_thumbButtons[1].szTip ) ] = 0;
|
||||||
|
|
||||||
thumbButtons[1].dwMask = dwMask;
|
|
||||||
thumbButtons[1].iId = 2;
|
|
||||||
thumbButtons[1].hIcon = pause.toWinHICON();
|
|
||||||
thumbButtons[1].szTip[ tr( "Pause" ).toWCharArray( thumbButtons[1].szTip ) ] = 0;
|
|
||||||
|
|
||||||
thumbButtons[2].dwMask = dwMask;
|
m_thumbButtons[2].dwMask = dwMask;
|
||||||
thumbButtons[2].iId = 3;
|
m_thumbButtons[2].iId = NEXT;
|
||||||
thumbButtons[2].hIcon = play.toWinHICON();
|
m_thumbButtons[2].hIcon = next.toWinHICON();
|
||||||
thumbButtons[2].szTip[ tr( "Play" ).toWCharArray( thumbButtons[2].szTip ) ] = 0;
|
m_thumbButtons[2].dwFlags = THBF_ENABLED;
|
||||||
|
m_thumbButtons[2].szTip[ tr( "Next" ).toWCharArray( m_thumbButtons[2].szTip ) ] = 0;
|
||||||
|
|
||||||
thumbButtons[3].dwMask = dwMask;
|
m_thumbButtons[3].dwMask = dwMask;
|
||||||
thumbButtons[3].iId = 4;
|
m_thumbButtons[3].iId = -1;
|
||||||
thumbButtons[3].hIcon = next.toWinHICON();
|
m_thumbButtons[3].hIcon = 0;
|
||||||
thumbButtons[3].szTip[ tr( "Next" ).toWCharArray( thumbButtons[3].szTip ) ] = 0;
|
m_thumbButtons[3].dwFlags = THBF_NOBACKGROUND | THBF_DISABLED;
|
||||||
|
m_thumbButtons[3].szTip[0] = 0;
|
||||||
|
|
||||||
thumbButtons[4].dwMask = dwMask;
|
m_thumbButtons[4].dwMask = dwMask;
|
||||||
thumbButtons[4].iId = 5;
|
m_thumbButtons[4].iId = LOVE;
|
||||||
thumbButtons[4].hIcon = love.toWinHICON();
|
m_thumbButtons[4].hIcon = love.toWinHICON();
|
||||||
thumbButtons[4].szTip[ tr( "Love" ).toWCharArray( thumbButtons[4].szTip ) ] = 0;
|
m_thumbButtons[4].dwFlags = THBF_DISABLED;
|
||||||
|
m_thumbButtons[4].szTip[ tr( "Love" ).toWCharArray( m_thumbButtons[4].szTip ) ] = 0;
|
||||||
|
|
||||||
ITaskbarList3 *taskbarList;
|
if ( S_OK == CoCreateInstance( CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void **)&m_taskbarList ) )
|
||||||
if ( S_OK == CoCreateInstance( CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void **)&taskbarList ) )
|
|
||||||
{
|
{
|
||||||
taskbarList->HrInit();
|
hr = m_taskbarList->HrInit();
|
||||||
if ( SUCCEEDED( hr ) )
|
if ( SUCCEEDED( hr ) )
|
||||||
{
|
{
|
||||||
hr = taskbarList->ThumbBarAddButtons( winId(), ARRAYSIZE( thumbButtons ), thumbButtons );
|
hr = m_taskbarList->ThumbBarAddButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_taskbarList->Release();
|
||||||
|
m_taskbarList = 0;
|
||||||
}
|
}
|
||||||
taskbarList->Release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCEEDED( hr );
|
return SUCCEEDED( hr );
|
||||||
@@ -571,29 +580,39 @@ TomahawkWindow::winEvent( MSG* msg, long* result )
|
|||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
if ( HIWORD( msg->wParam ) == THBN_CLICKED )
|
if ( HIWORD( msg->wParam ) == THBN_CLICKED )
|
||||||
{
|
{
|
||||||
switch( LOWORD( msg->wParam ) )
|
switch( TB_STATES(LOWORD( msg->wParam )) )
|
||||||
{
|
{
|
||||||
case 1:
|
case PREVIOUS:
|
||||||
tLog() << TB_PRESSED << "Previous";
|
tLog() << TB_PRESSED << "Previous";
|
||||||
AudioEngine::instance()->previous();
|
AudioEngine::instance()->previous();
|
||||||
break;
|
break;
|
||||||
case 2:
|
case PLAY_PAUSE:
|
||||||
tLog() << TB_PRESSED << "Pause";
|
tLog() << TB_PRESSED << "Play/Pause";
|
||||||
AudioEngine::instance()->pause();
|
AudioEngine::instance()->playPause();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case NEXT:
|
||||||
tLog() << TB_PRESSED << "Play";
|
|
||||||
AudioEngine::instance()->play();
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
tLog() << TB_PRESSED << "Next";
|
tLog() << TB_PRESSED << "Next";
|
||||||
AudioEngine::instance()->next();
|
AudioEngine::instance()->next();
|
||||||
break;
|
break;
|
||||||
case 5:
|
case LOVE:
|
||||||
tLog() << TB_PRESSED << "Love";
|
tLog() << TB_PRESSED << "Love";
|
||||||
if ( !AudioEngine::instance()->currentTrack().isNull() )
|
if ( !AudioEngine::instance()->currentTrack().isNull() )
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->currentTrack()->toQuery()->setLoved( true );
|
AudioEngine::instance()->currentTrack()->toQuery()->setLoved( !AudioEngine::instance()->currentTrack()->toQuery()->loved() );
|
||||||
|
if ( AudioEngine::instance()->currentTrack()->toQuery()->loved())
|
||||||
|
{
|
||||||
|
QPixmap loved( RESPATH "images/loved.png" );
|
||||||
|
m_thumbButtons[4].hIcon = loved.toWinHICON();
|
||||||
|
m_thumbButtons[4].szTip[ tr( "Unlove" ).toWCharArray( m_thumbButtons[4].szTip ) ] = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QPixmap not_loved( RESPATH "images/not-loved.png" );
|
||||||
|
m_thumbButtons[4].hIcon = not_loved.toWinHICON();
|
||||||
|
m_thumbButtons[4].szTip[ tr( "Love" ).toWCharArray( m_thumbButtons[4].szTip ) ] = 0;
|
||||||
|
}
|
||||||
|
m_taskbarList->ThumbBarUpdateButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -607,9 +626,62 @@ TomahawkWindow::winEvent( MSG* msg, long* result )
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
|
||||||
|
{
|
||||||
|
if(m_taskbarList == 0)
|
||||||
|
return;
|
||||||
|
switch(newState){
|
||||||
|
case AudioEngine::Playing:
|
||||||
|
{
|
||||||
|
QPixmap pause( RESPATH "images/pause-rest.png" );
|
||||||
|
m_thumbButtons[1].hIcon = pause.toWinHICON();
|
||||||
|
m_thumbButtons[1].szTip[ tr( "Pause" ).toWCharArray( m_thumbButtons[1].szTip ) ] = 0;
|
||||||
|
|
||||||
|
if ( !AudioEngine::instance()->currentTrack().isNull() && AudioEngine::instance()->currentTrack()->toQuery()->loved())
|
||||||
|
{
|
||||||
|
QPixmap loved( RESPATH "images/loved.png" );
|
||||||
|
m_thumbButtons[4].hIcon = loved.toWinHICON();
|
||||||
|
m_thumbButtons[4].szTip[ tr( "Unlove" ).toWCharArray( m_thumbButtons[4].szTip ) ] = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QPixmap not_loved( RESPATH "images/not-loved.png" );
|
||||||
|
m_thumbButtons[4].hIcon = not_loved.toWinHICON();
|
||||||
|
m_thumbButtons[4].szTip[ tr( "Love" ).toWCharArray( m_thumbButtons[4].szTip ) ] = 0;
|
||||||
|
}
|
||||||
|
m_thumbButtons[4].dwFlags = THBF_ENABLED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AudioEngine::Paused:
|
||||||
|
{
|
||||||
|
QPixmap play( RESPATH "images/play-rest.png" );
|
||||||
|
m_thumbButtons[1].hIcon = play.toWinHICON();
|
||||||
|
m_thumbButtons[1].szTip[ tr( "Play" ).toWCharArray( m_thumbButtons[1].szTip ) ] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AudioEngine::Stopped:
|
||||||
|
{
|
||||||
|
QPixmap play( RESPATH "images/play-rest.png" );
|
||||||
|
m_thumbButtons[1].hIcon = play.toWinHICON();
|
||||||
|
m_thumbButtons[1].szTip[ tr( "Play" ).toWCharArray( m_thumbButtons[1].szTip ) ] = 0;
|
||||||
|
|
||||||
|
QPixmap not_loved( RESPATH "images/not-loved.png" );
|
||||||
|
m_thumbButtons[4].hIcon = not_loved.toWinHICON();
|
||||||
|
m_thumbButtons[4].dwFlags = THBF_DISABLED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_taskbarList->ThumbBarUpdateButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons );
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkWindow::onHistoryBackAvailable( bool avail )
|
TomahawkWindow::onHistoryBackAvailable( bool avail )
|
||||||
{
|
{
|
||||||
|
@@ -31,6 +31,10 @@
|
|||||||
#include "audio/AudioEngine.h"
|
#include "audio/AudioEngine.h"
|
||||||
#include "utils/XspfLoader.h"
|
#include "utils/XspfLoader.h"
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <shobjidl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
namespace Accounts
|
namespace Accounts
|
||||||
@@ -138,6 +142,10 @@ private slots:
|
|||||||
|
|
||||||
void crashNow();
|
void crashNow();
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
void audioStateChanged( AudioState newState, AudioState oldState );
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
@@ -151,6 +159,15 @@ private:
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool setupWindowsButtons();
|
bool setupWindowsButtons();
|
||||||
const unsigned int m_buttonCreatedID;
|
const unsigned int m_buttonCreatedID;
|
||||||
|
ITaskbarList3 *m_taskbarList;
|
||||||
|
THUMBBUTTON m_thumbButtons[5];
|
||||||
|
enum TB_STATES{
|
||||||
|
PREVIOUS,
|
||||||
|
PLAY_PAUSE,
|
||||||
|
NEXT,
|
||||||
|
LOVE
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ui::TomahawkWindow* ui;
|
Ui::TomahawkWindow* ui;
|
||||||
|
Reference in New Issue
Block a user