1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 21:57:41 +02:00

Make thumbbuttons optional

Thumbbuttons are a feature that is not
    supported by older MINGW libraries.
    So check if the feature is available before
    using it.
This commit is contained in:
Andre Heinecke
2012-08-06 18:55:01 +02:00
committed by Dominik Schmidt
parent d89ebffc05
commit 42b1f8f6ee
4 changed files with 23 additions and 0 deletions

View File

@@ -7,6 +7,16 @@ ADD_DEFINITIONS( -DUNICODE )
SET( QXTWEB_LIBRARIES qxtweb-standalone ) SET( QXTWEB_LIBRARIES qxtweb-standalone )
# Check for the availability of the Thumbbutton
check_cxx_source_compiles( "
#include <shobjidl.h>
int main() {
THUMBBUTTON foo;
return 0;
}
"
HAVE_THUMBBUTTON )
SET( OS_SPECIFIC_LINK_LIBRARIES SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES} ${OS_SPECIFIC_LINK_LIBRARIES}

View File

@@ -16,6 +16,7 @@
#cmakedefine SNOW_LEOPARD #cmakedefine SNOW_LEOPARD
#cmakedefine LEOPARD #cmakedefine LEOPARD
#cmakedefine HAVE_SPARKLE #cmakedefine HAVE_SPARKLE
#cmakedefine HAVE_THUMBBUTTON
#cmakedefine WITH_BREAKPAD #cmakedefine WITH_BREAKPAD
#cmakedefine WITH_CRASHREPORTER #cmakedefine WITH_CRASHREPORTER

View File

@@ -92,7 +92,9 @@ 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" ) )
# ifdef HAVE_THUMBBUTTON
, m_taskbarList(0) , m_taskbarList(0)
# endif
#endif #endif
, ui( new Ui::TomahawkWindow ) , ui( new Ui::TomahawkWindow )
, m_searchWidget( 0 ) , m_searchWidget( 0 )
@@ -426,6 +428,7 @@ TomahawkWindow::setupUpdateCheck()
bool bool
TomahawkWindow::setupWindowsButtons() TomahawkWindow::setupWindowsButtons()
{ {
#ifdef HAVE_THUMBBUTTON
const GUID IID_ITaskbarList3 = { 0xea1afb91,0x9e28,0x4b86, { 0x90,0xe9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf } }; const GUID IID_ITaskbarList3 = { 0xea1afb91,0x9e28,0x4b86, { 0x90,0xe9,0x9e,0x9f,0x8a,0x5e,0xef,0xaf } };
HRESULT hr = S_OK; HRESULT hr = S_OK;
@@ -483,6 +486,9 @@ TomahawkWindow::setupWindowsButtons()
} }
return SUCCEEDED( hr ); return SUCCEEDED( hr );
#else // HAVE_THUMBBUTTON
return false;
#endif
} }
#endif #endif
@@ -714,6 +720,7 @@ TomahawkWindow::winEvent( MSG* msg, long* result )
void void
TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState ) TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
{ {
#ifdef HAVE_THUMBBUTTON
if ( m_taskbarList == 0 ) if ( m_taskbarList == 0 )
return; return;
@@ -758,11 +765,13 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
} }
m_taskbarList->ThumbBarUpdateButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons ); m_taskbarList->ThumbBarUpdateButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons );
#endif // HAVE_THUMBBUTTON
} }
void void
TomahawkWindow::updateWindowsLoveButton() TomahawkWindow::updateWindowsLoveButton()
{ {
#ifdef HAVE_THUMBBUTTON
if ( !AudioEngine::instance()->currentTrack().isNull() && AudioEngine::instance()->currentTrack()->toQuery()->loved() ) if ( !AudioEngine::instance()->currentTrack().isNull() && AudioEngine::instance()->currentTrack()->toQuery()->loved() )
{ {
QPixmap loved( RESPATH "images/loved.png" ); QPixmap loved( RESPATH "images/loved.png" );
@@ -777,6 +786,7 @@ TomahawkWindow::updateWindowsLoveButton()
} }
m_thumbButtons[TP_LOVE].dwFlags = THBF_ENABLED; m_thumbButtons[TP_LOVE].dwFlags = THBF_ENABLED;
m_taskbarList->ThumbBarUpdateButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons ); m_taskbarList->ThumbBarUpdateButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons );
#endif // HAVE_THUMBBUTTON
} }
#endif #endif

View File

@@ -167,8 +167,10 @@ private:
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
bool setupWindowsButtons(); bool setupWindowsButtons();
const unsigned int m_buttonCreatedID; const unsigned int m_buttonCreatedID;
# ifdef HAVE_THUMBBUTTON
ITaskbarList3 *m_taskbarList; ITaskbarList3 *m_taskbarList;
THUMBBUTTON m_thumbButtons[5]; THUMBBUTTON m_thumbButtons[5];
# endif
enum TB_STATES{ TP_PREVIOUS = 0,TP_PLAY_PAUSE = 1,TP_NEXT = 2,TP_LOVE = 4 }; enum TB_STATES{ TP_PREVIOUS = 0,TP_PLAY_PAUSE = 1,TP_NEXT = 2,TP_LOVE = 4 };
#endif #endif