1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-13 20:39:57 +01:00

* Style fixes.

This commit is contained in:
Christian Muehlhaeuser 2012-07-07 02:17:00 +02:00
parent 7e6931f25a
commit 18329b122d
2 changed files with 66 additions and 58 deletions

View File

@ -72,11 +72,11 @@
#include "LoadXSPFDialog.h"
#ifdef Q_OS_WIN
#include <qtsparkle/Updater>
#include <shobjidl.h>
#ifndef THBN_CLICKED
# define THBN_CLICKED 0x1800
#endif
#include <qtsparkle/Updater>
#include <shobjidl.h>
#ifndef THBN_CLICKED
#define THBN_CLICKED 0x1800
#endif
#endif
#include "utils/Logger.h"
@ -84,16 +84,17 @@
using namespace Tomahawk;
using namespace Accounts;
TomahawkWindow::TomahawkWindow( QWidget* parent )
: QMainWindow( parent )
#ifdef Q_OS_WIN
, m_buttonCreatedID( RegisterWindowMessage( L"TaskbarButtonCreated" ) )
#endif
, ui( new Ui::TomahawkWindow )
, m_searchWidget( 0 )
, m_audioControls( new AudioControls( this ) )
, m_trayIcon( new TomahawkTrayIcon( this ) )
, m_audioRetryCounter( 0 )
#ifdef Q_OS_WIN
, m_buttonCreatedID(RegisterWindowMessage(L"TaskbarButtonCreated"))
#endif
{
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
@ -244,7 +245,7 @@ TomahawkWindow::setupToolBar()
m_searchWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
m_searchWidget->setMaximumWidth( 340 );
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
toolbar->addWidget( m_searchWidget );
}
@ -327,68 +328,67 @@ TomahawkWindow::setupUpdateCheck()
#endif
}
#ifdef Q_OS_WIN
bool
TomahawkWindow::setupButtons()
TomahawkWindow::setupWindowsButtons()
{
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;
QPixmap play( RESPATH "images/play-rest.png");
QPixmap pause( RESPATH "images/pause-rest.png");
QPixmap back( RESPATH "images/back-rest.png");
QPixmap love( RESPATH "images/not-loved.png");
QPixmap play( RESPATH "images/play-rest.png" );
QPixmap pause( RESPATH "images/pause-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));
transform.rotate( 180 );
QPixmap next( back.transformed( transform ) );
THUMBBUTTON thumbButtons[5];
THUMBBUTTONMASK dwMask = THUMBBUTTONMASK(THB_ICON| THB_TOOLTIP);
THUMBBUTTONMASK dwMask = THUMBBUTTONMASK( THB_ICON | THB_TOOLTIP );
thumbButtons[0].dwMask = dwMask;
thumbButtons[0].iId = 1;
thumbButtons[0].hIcon = back.toWinHICON();
thumbButtons[0].szTip[tr("Back").toWCharArray(thumbButtons[0].szTip)] = 0;
thumbButtons[0].szTip[ tr( "Back" ).toWCharArray( thumbButtons[0].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[1].szTip[ tr( "Pause" ).toWCharArray( thumbButtons[1].szTip ) ] = 0;
thumbButtons[2].dwMask = dwMask;
thumbButtons[2].iId = 3;
thumbButtons[2].hIcon = play.toWinHICON();
thumbButtons[2].szTip[tr("Play").toWCharArray(thumbButtons[2].szTip)] = 0;
thumbButtons[2].szTip[ tr( "Play" ).toWCharArray( thumbButtons[2].szTip ) ] = 0;
thumbButtons[3].dwMask = dwMask;
thumbButtons[3].iId = 4;
thumbButtons[3].hIcon = next.toWinHICON();
thumbButtons[3].szTip[tr("Next").toWCharArray(thumbButtons[3].szTip)] = 0;
thumbButtons[3].szTip[ tr( "Next" ).toWCharArray( thumbButtons[3].szTip ) ] = 0;
thumbButtons[4].dwMask = dwMask;
thumbButtons[4].iId = 5;
thumbButtons[4].hIcon = love.toWinHICON();
thumbButtons[4].szTip[tr("Love").toWCharArray(thumbButtons[4].szTip)] = 0;
thumbButtons[4].szTip[ tr( "Love" ).toWCharArray( thumbButtons[4].szTip ) ] = 0;
ITaskbarList3 *taskbarList;
if( S_OK == CoCreateInstance( CLSID_TaskbarList,NULL, CLSCTX_INPROC_SERVER,IID_ITaskbarList3,(void **)&taskbarList) )
if ( S_OK == CoCreateInstance( CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void **)&taskbarList ) )
{
taskbarList->HrInit();
if (SUCCEEDED(hr))
if ( SUCCEEDED( hr ) )
{
hr = taskbarList->ThumbBarAddButtons(winId(), ARRAYSIZE(thumbButtons), thumbButtons);
hr = taskbarList->ThumbBarAddButtons( winId(), ARRAYSIZE( thumbButtons ), thumbButtons );
}
taskbarList->Release();
}
return SUCCEEDED(hr);
return SUCCEEDED( hr );
}
#endif
void
TomahawkWindow::setupSignals()
{
@ -448,7 +448,7 @@ TomahawkWindow::setupSignals()
connect( account->sipPlugin(), SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
connect( account->sipPlugin(), SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
}
connect( ViewManager::instance(), SIGNAL( historyBackAvailable( bool ) ), SLOT( onHistoryBackAvailable( bool ) ) );
connect( ViewManager::instance(), SIGNAL( historyForwardAvailable( bool ) ), SLOT( onHistoryForwardAvailable( bool ) ) );
}
@ -559,46 +559,52 @@ TomahawkWindow::keyPressEvent( QKeyEvent* e )
QMainWindow::keyPressEvent( e );
}
#ifdef Q_OS_WIN
bool
TomahawkWindow::winEvent ( MSG * msg, long * result )
TomahawkWindow::winEvent( MSG* msg, long* result )
{
#define TB_PRESSED Q_FUNC_INFO << "Taskbar Button Pressed:"
switch(msg->message)
#define TB_PRESSED Q_FUNC_INFO << "Taskbar Button Pressed:"
switch( msg->message )
{
case WM_COMMAND:
if (HIWORD(msg->wParam) == THBN_CLICKED)
if ( HIWORD( msg->wParam ) == THBN_CLICKED )
{
switch(LOWORD(msg->wParam))
switch( LOWORD( msg->wParam ) )
{
case 1:
tLog()<<TB_PRESSED<<"Previous";
tLog() << TB_PRESSED << "Previous";
AudioEngine::instance()->previous();
break;
case 2:
tLog()<<TB_PRESSED<<"Pause";
tLog() << TB_PRESSED << "Pause";
AudioEngine::instance()->pause();
break;
case 3:
tLog()<<TB_PRESSED<<"Play";
tLog() << TB_PRESSED << "Play";
AudioEngine::instance()->play();
break;
case 4:
tLog()<<TB_PRESSED<<"Next";
tLog() << TB_PRESSED << "Next";
AudioEngine::instance()->next();
break;
case 5:
tLog()<<TB_PRESSED<<"Love";
if(!AudioEngine::instance()->currentTrack().isNull())
tLog() << TB_PRESSED << "Love";
if ( !AudioEngine::instance()->currentTrack().isNull() )
{
AudioEngine::instance()->currentTrack()->toQuery()->setLoved( true );
}
break;
}
return true;
}
break;
}
if ( msg->message == m_buttonCreatedID)
return setupButtons();
if ( msg->message == m_buttonCreatedID )
return setupWindowsButtons();
return false;
}
#endif
@ -626,7 +632,7 @@ TomahawkWindow::showSettingsDialog()
}
void
void
TomahawkWindow::showDiagnosticsDialog()
{
DiagnosticsDialog win;
@ -965,7 +971,7 @@ TomahawkWindow::audioStopped()
{
audioPaused();
ActionCollection::instance()->getAction( "stop" )->setEnabled( false );
m_currentTrack = result_ptr();
setWindowTitle( m_windowTitle );
}

View File

@ -31,10 +31,12 @@
#include "audio/AudioEngine.h"
#include "utils/XspfLoader.h"
namespace Tomahawk {
namespace Accounts {
class Account;
}
namespace Tomahawk
{
namespace Accounts
{
class Account;
}
}
class JobStatusModel;
@ -74,8 +76,9 @@ protected:
void showEvent( QShowEvent* e );
void hideEvent( QHideEvent* e );
void keyPressEvent( QKeyEvent* e );
#ifdef Q_OS_WIN
bool winEvent ( MSG * message, long * result );
bool winEvent( MSG* message, long* result );
#endif
public slots:
@ -88,8 +91,8 @@ public slots:
void legalInfo();
void updateCollectionManually();
void rescanCollectionManually();
void pluginMenuAdded(QMenu*);
void pluginMenuRemoved(QMenu*);
void pluginMenuAdded( QMenu* );
void pluginMenuRemoved( QMenu* );
void showOfflineSources();
void fullScreenEntered();
@ -144,8 +147,10 @@ private:
void setupToolBar();
void setupSideBar();
void setupUpdateCheck();
#ifdef Q_OS_WIN
bool setupButtons();
bool setupWindowsButtons();
const unsigned int m_buttonCreatedID;
#endif
Ui::TomahawkWindow* ui;
@ -165,9 +170,6 @@ private:
Tomahawk::result_ptr m_currentTrack;
QString m_windowTitle;
int m_audioRetryCounter;
#ifdef Q_OS_WIN
const uint m_buttonCreatedID;
#endif
};
#endif // TOMAHAWKWINDOW_H