1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 17:29:42 +01:00

fixed invalid icons for windows thumbbottons crashing explorer.exe

This commit is contained in:
Patrick von Reth 2012-12-12 12:10:32 +01:00
parent a40b386cd7
commit ddafbdafee
2 changed files with 43 additions and 45 deletions

View File

@ -116,6 +116,18 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
connect( APP, SIGNAL( tomahawkLoaded() ), vm, SLOT( setTomahawkLoaded() ) ); // Pass loaded signal into libtomahawk so components in there can connect to ViewManager
#ifdef Q_OS_WIN
QList<TomahawkUtils::ImageType> list;
list<<TomahawkUtils::PauseButton<<TomahawkUtils::PlayButton<<TomahawkUtils::PrevButton<<TomahawkUtils::NextButton<<TomahawkUtils::NotLoved<<TomahawkUtils::Loved;
foreach(TomahawkUtils::ImageType type,list)
{
QPixmap pix ( TomahawkUtils::defaultPixmap(type , TomahawkUtils::Original, QSize( 20, 20 ) ) );
if( pix.isNull() )
{
qFatal("One of thumbbar icons is null, this would lead to explorer.exe crashes, aborting tomahawk");
}
m_thumbIcons[type] = pix.toWinHICON();
}
connect( AudioEngine::instance(), SIGNAL( stateChanged( AudioState, AudioState) ), SLOT( audioStateChanged( AudioState, AudioState) ) );
#endif
ui->setupUi( this );
@ -446,30 +458,22 @@ TomahawkWindow::setupWindowsButtons()
const GUID IID_ITaskbarList3 = { 0xea1afb91,0x9e28,0x4b86, { 0x90,0xe9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf } };
HRESULT hr = S_OK;
QPixmap play( RESPATH "images/play-rest.png" );
QPixmap back( RESPATH "images/back-rest.png" );
QPixmap love( RESPATH "images/not-loved.png" );
QTransform transform;
transform.rotate( 180 );
QPixmap next( back.transformed( transform ) );
THUMBBUTTONMASK dwMask = THUMBBUTTONMASK( THB_ICON | THB_TOOLTIP | THB_FLAGS );
m_thumbButtons[TP_PREVIOUS].dwMask = dwMask;
m_thumbButtons[TP_PREVIOUS].iId = TP_PREVIOUS;
m_thumbButtons[TP_PREVIOUS].hIcon = back.toWinHICON();
m_thumbButtons[TP_PREVIOUS].hIcon = m_thumbIcons[TomahawkUtils::PrevButton];
m_thumbButtons[TP_PREVIOUS].dwFlags = THBF_ENABLED;
m_thumbButtons[TP_PREVIOUS].szTip[ tr( "Back" ).toWCharArray( m_thumbButtons[TP_PREVIOUS].szTip ) ] = 0;
m_thumbButtons[TP_PLAY_PAUSE].dwMask = dwMask;
m_thumbButtons[TP_PLAY_PAUSE].iId = TP_PLAY_PAUSE;
m_thumbButtons[TP_PLAY_PAUSE].hIcon = play.toWinHICON();
m_thumbButtons[TP_PLAY_PAUSE].hIcon = m_thumbIcons[TomahawkUtils::PlayButton];
m_thumbButtons[TP_PLAY_PAUSE].dwFlags = THBF_ENABLED;
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Play" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
m_thumbButtons[TP_NEXT].dwMask = dwMask;
m_thumbButtons[TP_NEXT].iId = TP_NEXT;
m_thumbButtons[TP_NEXT].hIcon = next.toWinHICON();
m_thumbButtons[TP_NEXT].hIcon = m_thumbIcons[TomahawkUtils::NextButton];
m_thumbButtons[TP_NEXT].dwFlags = THBF_ENABLED;
m_thumbButtons[TP_NEXT].szTip[ tr( "Next" ).toWCharArray( m_thumbButtons[TP_NEXT].szTip ) ] = 0;
@ -481,7 +485,7 @@ TomahawkWindow::setupWindowsButtons()
m_thumbButtons[TP_LOVE].dwMask = dwMask;
m_thumbButtons[TP_LOVE].iId = TP_LOVE;
m_thumbButtons[TP_LOVE].hIcon = love.toWinHICON();
m_thumbButtons[TP_LOVE].hIcon = m_thumbIcons[TomahawkUtils::NotLoved];
m_thumbButtons[TP_LOVE].dwFlags = THBF_DISABLED;
m_thumbButtons[TP_LOVE].szTip[ tr( "Love" ).toWCharArray( m_thumbButtons[TP_LOVE].szTip ) ] = 0;
@ -723,46 +727,41 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
#ifdef HAVE_THUMBBUTTON
if ( m_taskbarList == 0 )
return;
switch ( newState )
{
case AudioEngine::Playing:
{
QPixmap pause( RESPATH "images/pause-rest.png" );
m_thumbButtons[TP_PLAY_PAUSE].hIcon = pause.toWinHICON();
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Pause" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
updateWindowsLoveButton();
case AudioEngine::Playing:
{
m_thumbButtons[TP_PLAY_PAUSE].hIcon = m_thumbIcons[TomahawkUtils::PauseButton];
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Pause" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
updateWindowsLoveButton();
}
}
break;
case AudioEngine::Paused:
{
QPixmap play( RESPATH "images/play-rest.png" );
m_thumbButtons[TP_PLAY_PAUSE].hIcon = play.toWinHICON();
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Play" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
}
case AudioEngine::Paused:
{
m_thumbButtons[TP_PLAY_PAUSE].hIcon = m_thumbIcons[TomahawkUtils::PlayButton];
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Play" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
}
break;
case AudioEngine::Stopped:
case AudioEngine::Stopped:
{
if ( !AudioEngine::instance()->currentTrack().isNull() )
{
if ( !AudioEngine::instance()->currentTrack().isNull() )
{
disconnect( AudioEngine::instance()->currentTrack()->toQuery().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( updateWindowsLoveButton() ) );
}
QPixmap play( RESPATH "images/play-rest.png" );
m_thumbButtons[TP_PLAY_PAUSE].hIcon = play.toWinHICON();
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Play" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
QPixmap not_loved( RESPATH "images/not-loved.png" );
m_thumbButtons[TP_LOVE].hIcon = not_loved.toWinHICON();
m_thumbButtons[TP_LOVE].dwFlags = THBF_DISABLED;
disconnect( AudioEngine::instance()->currentTrack()->toQuery().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( updateWindowsLoveButton() ) );
}
m_thumbButtons[TP_PLAY_PAUSE].hIcon = m_thumbIcons[TomahawkUtils::PlayButton];
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Play" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
m_thumbButtons[TP_LOVE].hIcon = m_thumbIcons[TomahawkUtils::NotLoved];
m_thumbButtons[TP_LOVE].dwFlags = THBF_DISABLED;
}
break;
default:
return;
default:
return;
}
m_taskbarList->ThumbBarUpdateButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons );
@ -776,14 +775,12 @@ TomahawkWindow::updateWindowsLoveButton()
#ifdef HAVE_THUMBBUTTON
if ( !AudioEngine::instance()->currentTrack().isNull() && AudioEngine::instance()->currentTrack()->toQuery()->loved() )
{
QPixmap loved( RESPATH "images/loved.png" );
m_thumbButtons[TP_LOVE].hIcon = loved.toWinHICON();
m_thumbButtons[TP_LOVE].hIcon = m_thumbIcons[TomahawkUtils::Loved];
m_thumbButtons[TP_LOVE].szTip[ tr( "Unlove" ).toWCharArray( m_thumbButtons[TP_LOVE].szTip ) ] = 0;
}
else
{
QPixmap not_loved( RESPATH "images/not-loved.png" );
m_thumbButtons[TP_LOVE].hIcon = not_loved.toWinHICON();
m_thumbButtons[TP_LOVE].hIcon = m_thumbIcons[TomahawkUtils::NotLoved];
m_thumbButtons[TP_LOVE].szTip[ tr( "Love" ).toWCharArray( m_thumbButtons[TP_LOVE].szTip ) ] = 0;
}

View File

@ -167,6 +167,7 @@ private:
#ifdef Q_OS_WIN
bool setupWindowsButtons();
const unsigned int m_buttonCreatedID;
QMap<TomahawkUtils::ImageType,HICON> m_thumbIcons;
#ifdef HAVE_THUMBBUTTON
ITaskbarList3* m_taskbarList;
THUMBBUTTON m_thumbButtons[5];