diff --git a/alsa-playback/CMakeLists.txt b/alsa-playback/CMakeLists.txt index d080ebaa6..676ed83e1 100644 --- a/alsa-playback/CMakeLists.txt +++ b/alsa-playback/CMakeLists.txt @@ -13,7 +13,7 @@ SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") #ADD_DEFINITIONS(-Wall -O2 -DNDEBUG) -#ADD_DEFINITIONS(-fPIC) +ADD_DEFINITIONS(-fPIC) SET(AUDIO_LIBS "") diff --git a/include/tomahawk/tomahawkapp.h b/include/tomahawk/tomahawkapp.h index e048778dc..c7733120f 100644 --- a/include/tomahawk/tomahawkapp.h +++ b/include/tomahawk/tomahawkapp.h @@ -3,14 +3,11 @@ #define APP TomahawkApp::instance() -#define RESPATH ":/data/" - #include "headlesscheck.h" #include #include #include -#include #include #include "QxtHttpServerConnector" @@ -61,16 +58,12 @@ public: static TomahawkApp* instance(); - AudioEngine* audioEngine() { return m_audioEngine; } SipHandler* sipHandler() { return m_sipHandler; } - QNetworkAccessManager* nam() { return m_nam; } - QNetworkProxy* proxy() { return m_proxy; } Tomahawk::InfoSystem::InfoSystem* infoSystem() { return m_infoSystem; } XMPPBot* xmppBot() { return m_xmppBot; } #ifndef TOMAHAWK_HEADLESS AudioControls* audioControls(); - PlaylistManager* playlistManager(); TomahawkWindow* mainWindow() const { return m_mainwindow; } #endif @@ -107,9 +100,6 @@ private: bool m_headless; - QNetworkAccessManager* m_nam; - QNetworkProxy* m_proxy; - Tomahawk::InfoSystem::InfoSystem* m_infoSystem; QxtHttpServerConnector m_connector; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0a5c7e248..0359f30e3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,13 +27,6 @@ SET( TOMAHAWK_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../include/" ) #ENDFOREACH( moddir ) SET( tomahawkSources ${tomahawkSources} - audio/madtranscode.cpp - audio/vorbistranscode.cpp - audio/flactranscode.cpp - audio/audioengine.cpp - - utils/tomahawkutils.cpp - sip/SipHandler.cpp infosystem/infosystem.cpp @@ -52,36 +45,6 @@ SET( tomahawkSources ${tomahawkSources} ) SET( tomahawkSourcesGui ${tomahawkSourcesGui} - utils/querylabel.cpp - utils/elidedlabel.cpp - utils/imagebutton.cpp - utils/progresstreeview.cpp - utils/proxystyle.cpp - utils/widgetdragfilter.cpp - utils/animatedsplitter.cpp - - playlist/collectionmodel.cpp - playlist/collectionproxymodel.cpp - playlist/collectionflatmodel.cpp - playlist/collectionview.cpp - playlist/playlistmanager.cpp - playlist/plitem.cpp - playlist/playlistmodel.cpp - playlist/playlistproxymodel.cpp - playlist/playlistview.cpp - playlist/playlistitemdelegate.cpp - playlist/queueproxymodel.cpp - playlist/queueview.cpp - playlist/trackmodel.cpp - playlist/trackproxymodel.cpp - playlist/trackview.cpp - playlist/trackheader.cpp - playlist/albumitem.cpp - playlist/albummodel.cpp - playlist/albumproxymodel.cpp - playlist/albumitemdelegate.cpp - playlist/albumview.cpp - sourcetree/sourcesmodel.cpp sourcetree/sourcetreeitem.cpp sourcetree/sourcetreeitemwidget.cpp @@ -93,11 +56,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui} topbar/lineedit.cpp topbar/searchbutton.cpp - infowidgets/sourceinfowidget.cpp - - widgets/newplaylistwidget.cpp - widgets/welcomewidget.cpp - xspfloader.cpp transferview.cpp tomahawktrayicon.cpp @@ -110,12 +68,6 @@ SET( tomahawkHeaders ${tomahawkHeaders} "${TOMAHAWK_INC_DIR}/tomahawk/tomahawkapp.h" "${TOMAHAWK_INC_DIR}/tomahawk/infosystem.h" - audio/transcodeinterface.h - audio/madtranscode.h - audio/vorbistranscode.h - audio/flactranscode.h - audio/audioengine.h - sip/SipHandler.h infosystem/infoplugins/echonestplugin.h @@ -130,36 +82,6 @@ SET( tomahawkHeaders ${tomahawkHeaders} ) SET( tomahawkHeadersGui ${tomahawkHeadersGui} - utils/querylabel.h - utils/elidedlabel.h - utils/animatedcounterlabel.h - utils/imagebutton.h - utils/progresstreeview.h - utils/widgetdragfilter.h - utils/animatedsplitter.h - - playlist/collectionmodel.h - playlist/collectionproxymodel.h - playlist/collectionflatmodel.h - playlist/collectionview.h - playlist/playlistmanager.h - playlist/plitem.h - playlist/playlistmodel.h - playlist/playlistproxymodel.h - playlist/playlistview.h - playlist/playlistitemdelegate.h - playlist/queueproxymodel.h - playlist/queueview.h - playlist/trackmodel.h - playlist/trackproxymodel.h - playlist/trackview.h - playlist/trackheader.h - playlist/albumitem.h - playlist/albummodel.h - playlist/albumproxymodel.h - playlist/albumitemdelegate.h - playlist/albumview.h - sourcetree/sourcesmodel.h sourcetree/sourcetreeitem.h sourcetree/sourcetreeitemwidget.h @@ -172,11 +94,6 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui} topbar/lineedit_p.h topbar/searchbutton.h - infowidgets/sourceinfowidget.h - - widgets/newplaylistwidget.h - widgets/welcomewidget.h - xspfloader.h transferview.h tomahawktrayicon.h @@ -193,10 +110,6 @@ SET( tomahawkUI ${tomahawkUI} audiocontrols.ui sourcetree/sourcetreeitemwidget.ui topbar/topbar.ui - - infowidgets/sourceinfowidget.ui - widgets/newplaylistwidget.ui - widgets/welcomewidget.ui ) INCLUDE_DIRECTORIES( @@ -213,8 +126,8 @@ INCLUDE_DIRECTORIES( utils libtomahawk - ../rtaudio ../alsa-playback + ../rtaudio ../qxt/qxtweb-standalone/qxtweb /usr/include/taglib diff --git a/src/audiocontrols.cpp b/src/audiocontrols.cpp index deb883d09..bc255af3b 100644 --- a/src/audiocontrols.cpp +++ b/src/audiocontrols.cpp @@ -4,12 +4,12 @@ #include #include "tomahawk/tomahawkapp.h" -#include "album.h" +#include "audio/audioengine.h" +#include "playlist/playlistmanager.h" +#include "utils/imagebutton.h" #include "utils/tomahawkutils.h" -#include "audioengine.h" -#include "imagebutton.h" -#include "playlist/playlistmanager.h" +#include "album.h" #define LASTFM_DEFAULT_COVER "http://cdn.last.fm/flatness/catalogue/noimage" @@ -83,7 +83,7 @@ AudioControls::AudioControls( QWidget* parent ) ui->volumeSlider->setFixedHeight( 20 ); ui->volumeSlider->setRange( 0, 100 ); - ui->volumeSlider->setValue( APP->audioEngine()->volume() ); + ui->volumeSlider->setValue( AudioEngine::instance()->volume() ); ui->volumeSlider->setStyleSheet( "QSlider::groove::horizontal {" "margin: 5px; border-width: 3px;" "border-image: url(" RESPATH "images/volume-slider-bkg.png) 3 3 3 3 stretch stretch;" @@ -113,13 +113,13 @@ AudioControls::AudioControls( QWidget* parent ) connect( m_prevAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( previous() ) ); connect( m_nextAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( next() ) ); */ - connect( ui->volumeSlider, SIGNAL( valueChanged( int ) ), (QObject*)APP->audioEngine(), SLOT( setVolume( int ) ) ); - connect( ui->prevButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( previous() ) ); - connect( ui->playPauseButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( play() ) ); - connect( ui->pauseButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( pause() ) ); - connect( ui->nextButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( next() ) ); - connect( ui->volumeLowButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( lowerVolume() ) ); - connect( ui->volumeHighButton, SIGNAL( clicked() ), (QObject*)APP->audioEngine(), SLOT( raiseVolume() ) ); + connect( ui->volumeSlider, SIGNAL( valueChanged( int ) ), AudioEngine::instance(), SLOT( setVolume( int ) ) ); + connect( ui->prevButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( previous() ) ); + connect( ui->playPauseButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( play() ) ); + connect( ui->pauseButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( pause() ) ); + connect( ui->nextButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( next() ) ); + connect( ui->volumeLowButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( lowerVolume() ) ); + connect( ui->volumeHighButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( raiseVolume() ) ); connect( ui->repeatButton, SIGNAL( clicked() ), SLOT( onRepeatClicked() ) ); connect( ui->shuffleButton, SIGNAL( clicked() ), SLOT( onShuffleClicked() ) ); @@ -128,13 +128,13 @@ AudioControls::AudioControls( QWidget* parent ) connect( ui->albumLabel, SIGNAL( clicked() ), SLOT( onAlbumClicked() ) ); // - connect( (QObject*)APP->audioEngine(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) ); - connect( (QObject*)APP->audioEngine(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ) ); - connect( (QObject*)APP->audioEngine(), SIGNAL( paused() ), SLOT( onPlaybackPaused() ) ); - connect( (QObject*)APP->audioEngine(), SIGNAL( resumed() ), SLOT( onPlaybackResumed() ) ); - connect( (QObject*)APP->audioEngine(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ) ); - connect( (QObject*)APP->audioEngine(), SIGNAL( timerSeconds( unsigned int ) ), SLOT( onPlaybackTimer( unsigned int ) ) ); - connect( (QObject*)APP->audioEngine(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) ); + connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackLoading( Tomahawk::result_ptr ) ) ); + connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ) ); + connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( onPlaybackPaused() ) ); + connect( AudioEngine::instance(), SIGNAL( resumed() ), SLOT( onPlaybackResumed() ) ); + connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ) ); + connect( AudioEngine::instance(), SIGNAL( timerSeconds( unsigned int ) ), SLOT( onPlaybackTimer( unsigned int ) ) ); + connect( AudioEngine::instance(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) ); m_defaultCover = QPixmap( RESPATH "images/no-album-art-placeholder.png" ) .scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); @@ -200,7 +200,7 @@ AudioControls::onCoverArtDownloaded() { // Follow HTTP redirect QNetworkRequest req( redir ); - QNetworkReply* reply = APP->nam()->get( req ); + QNetworkReply* reply = TomahawkUtils::nam()->get( req ); connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) ); } @@ -217,7 +217,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result ) QString imgurl = "http://ws.audioscrobbler.com/2.0/?method=album.imageredirect&artist=%1&album=%2&size=medium&api_key=7a90f6672a04b809ee309af169f34b8b"; QNetworkRequest req( imgurl.arg( result->artist()->name() ).arg( result->album()->name() ) ); - QNetworkReply* reply = APP->nam()->get( req ); + QNetworkReply* reply = TomahawkUtils::nam()->get( req ); connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) ); } @@ -359,21 +359,21 @@ AudioControls::onRepeatClicked() case PlaylistInterface::NoRepeat: { // switch to RepeatOne - APP->playlistManager()->setRepeatMode( PlaylistInterface::RepeatOne ); + PlaylistManager::instance()->setRepeatMode( PlaylistInterface::RepeatOne ); } break; case PlaylistInterface::RepeatOne: { // switch to RepeatAll - APP->playlistManager()->setRepeatMode( PlaylistInterface::RepeatAll ); + PlaylistManager::instance()->setRepeatMode( PlaylistInterface::RepeatAll ); } break; case PlaylistInterface::RepeatAll: { // switch to NoRepeat - APP->playlistManager()->setRepeatMode( PlaylistInterface::NoRepeat ); + PlaylistManager::instance()->setRepeatMode( PlaylistInterface::NoRepeat ); } break; @@ -408,19 +408,19 @@ AudioControls::onShuffleModeChanged( bool enabled ) void AudioControls::onShuffleClicked() { - APP->playlistManager()->setShuffled( m_shuffled ^ true ); + PlaylistManager::instance()->setShuffled( m_shuffled ^ true ); } void AudioControls::onTrackClicked() { - APP->playlistManager()->showCurrentTrack(); + PlaylistManager::instance()->showCurrentTrack(); } void AudioControls::onAlbumClicked() { - APP->playlistManager()->show( m_currentTrack->album() ); + PlaylistManager::instance()->show( m_currentTrack->album() ); } diff --git a/src/audiocontrols.ui b/src/audiocontrols.ui index 033f51bef..31ac8f656 100644 --- a/src/audiocontrols.ui +++ b/src/audiocontrols.ui @@ -492,12 +492,12 @@ ImageButton QPushButton -
imagebutton.h
+
utils/imagebutton.h
QueryLabel QLabel -
querylabel.h
+
utils/querylabel.h
diff --git a/src/infosystem/infoplugins/musixmatchplugin.cpp b/src/infosystem/infoplugins/musixmatchplugin.cpp index 4e9429e27..8cae2c6fe 100644 --- a/src/infosystem/infoplugins/musixmatchplugin.cpp +++ b/src/infosystem/infoplugins/musixmatchplugin.cpp @@ -44,7 +44,7 @@ void MusixMatchPlugin::getInfo(const QString &caller, const InfoType type, const url.addQueryItem("apikey", m_apiKey); url.addQueryItem("q_artist", artist); url.addQueryItem("q_track", track); - QNetworkReply* reply = TomahawkApp::instance()->nam()->get(QNetworkRequest(url)); + QNetworkReply* reply = TomahawkUtils::nam()->get(QNetworkRequest(url)); reply->setProperty("customData", QVariant::fromValue(customData)); reply->setProperty("origData", data); reply->setProperty("caller", caller); @@ -104,7 +104,7 @@ void MusixMatchPlugin::trackSearchSlot() QUrl url(requestString); url.addQueryItem("apikey", m_apiKey); url.addQueryItem("track_id", track_id); - QNetworkReply* newReply = TomahawkApp::instance()->nam()->get(QNetworkRequest(url)); + QNetworkReply* newReply = TomahawkUtils::nam()->get(QNetworkRequest(url)); newReply->setProperty("origData", oldReply->property("origData")); newReply->setProperty("customData", oldReply->property("customData")); newReply->setProperty("caller", oldReply->property("caller")); @@ -133,4 +133,4 @@ void MusixMatchPlugin::trackLyricsSlot() qDebug() << "Emitting lyrics: " << lyrics; emit info(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics, reply->property("origData"), QVariant(lyrics), reply->property("customData").value()); emit finished(reply->property("caller").toString(), Tomahawk::InfoSystem::InfoTrackLyrics); -} \ No newline at end of file +} diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index f5dae399a..866e54e5a 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -1,5 +1,6 @@ project( tomahawklib ) +SET( QT_USE_QTGUI TRUE ) SET( QT_USE_QTSQL TRUE ) SET( QT_USE_QTNETWORK TRUE ) SET( QT_USE_QTXML TRUE ) @@ -25,6 +26,11 @@ set( libSources sip/SipPlugin.cpp + audio/madtranscode.cpp + audio/vorbistranscode.cpp + audio/flactranscode.cpp + audio/audioengine.cpp + database/database.cpp database/databasecollection.cpp database/databaseworker.cpp @@ -54,6 +60,28 @@ set( libSources database/databasecommand_updatesearchindex.cpp database/fuzzyindex.cpp + playlist/collectionmodel.cpp + playlist/collectionproxymodel.cpp + playlist/collectionflatmodel.cpp + playlist/collectionview.cpp + playlist/playlistmanager.cpp + playlist/plitem.cpp + playlist/playlistmodel.cpp + playlist/playlistproxymodel.cpp + playlist/playlistview.cpp + playlist/playlistitemdelegate.cpp + playlist/queueproxymodel.cpp + playlist/queueview.cpp + playlist/trackmodel.cpp + playlist/trackproxymodel.cpp + playlist/trackview.cpp + playlist/trackheader.cpp + playlist/albumitem.cpp + playlist/albummodel.cpp + playlist/albumproxymodel.cpp + playlist/albumitemdelegate.cpp + playlist/albumview.cpp + network/bufferiodevice.cpp network/msgprocessor.cpp network/filetransferconnection.cpp @@ -63,6 +91,19 @@ set( libSources network/servent.cpp network/connection.cpp network/controlconnection.cpp + + utils/tomahawkutils.cpp + utils/querylabel.cpp + utils/elidedlabel.cpp + utils/imagebutton.cpp + utils/progresstreeview.cpp + utils/proxystyle.cpp + utils/widgetdragfilter.cpp + utils/animatedsplitter.cpp + + widgets/newplaylistwidget.cpp + widgets/welcomewidget.cpp + widgets/infowidgets/sourceinfowidget.cpp ) set( libHeaders @@ -83,6 +124,12 @@ set( libHeaders sip/SipPlugin.h + audio/transcodeinterface.h + audio/madtranscode.h + audio/vorbistranscode.h + audio/flactranscode.h + audio/audioengine.h + database/database.h database/databasecollection.h database/databaseworker.h @@ -121,6 +168,46 @@ set( libHeaders network/connection.h network/controlconnection.h network/portfwdthread.h + + playlist/collectionmodel.h + playlist/collectionproxymodel.h + playlist/collectionflatmodel.h + playlist/collectionview.h + playlist/playlistmanager.h + playlist/plitem.h + playlist/playlistmodel.h + playlist/playlistproxymodel.h + playlist/playlistview.h + playlist/playlistitemdelegate.h + playlist/queueproxymodel.h + playlist/queueview.h + playlist/trackmodel.h + playlist/trackproxymodel.h + playlist/trackview.h + playlist/trackheader.h + playlist/albumitem.h + playlist/albummodel.h + playlist/albumproxymodel.h + playlist/albumitemdelegate.h + playlist/albumview.h + + utils/querylabel.h + utils/elidedlabel.h + utils/animatedcounterlabel.h + utils/imagebutton.h + utils/progresstreeview.h + utils/widgetdragfilter.h + utils/animatedsplitter.h + + widgets/newplaylistwidget.h + widgets/welcomewidget.h + widgets/infowidgets/sourceinfowidget.h +) + +set( libUI ${libUI} + widgets/newplaylistwidget.ui + widgets/welcomewidget.ui + widgets/infowidgets/sourceinfowidget.ui ) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. @@ -129,9 +216,15 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} .. ../../include ../network ../../qxt/qxtweb-standalone/qxtweb + ../../rtaudio + ../../alsa-playback ) +qt4_wrap_ui( libUI_H ${libUI} ) qt4_wrap_cpp( libMoc ${libHeaders} ) + +SET( libSources ${libSources} ${libUI_H} ) + add_library( tomahawklib SHARED ${libSources} ${libMoc} ) IF( WIN32 ) @@ -143,6 +236,24 @@ SET( OS_SPECIFIC_LINK_LIBRARIES ) ENDIF( WIN32 ) +IF( APPLE ) +SET( OS_SPECIFIC_LINK_LIBRARIES + ${OS_SPECIFIC_LINK_LIBRARIES} + ${COREAUDIO_LIBRARY} + ${COREFOUNDATION_LIBRARY} + rtaudio +) + +ENDIF( APPLE ) + +IF( UNIX AND NOT APPLE ) +SET( OS_SPECIFIC_LINK_LIBRARIES + ${OS_SPECIFIC_LINK_LIBRARIES} + alsaplayback +) +ENDIF( UNIX AND NOT APPLE ) + + target_link_libraries( tomahawklib ${QT_LIBRARIES} ${OS_SPECIFIC_LINK_LIBRARIES} diff --git a/src/audio/audioengine.cpp b/src/libtomahawk/audio/audioengine.cpp similarity index 98% rename from src/audio/audioengine.cpp rename to src/libtomahawk/audio/audioengine.cpp index 970bdb4de..7ebbf9197 100644 --- a/src/audio/audioengine.cpp +++ b/src/libtomahawk/audio/audioengine.cpp @@ -17,6 +17,15 @@ #include "flactranscode.h" #endif +AudioEngine* AudioEngine::s_instance = 0; + + +AudioEngine* +AudioEngine::instance() +{ + return s_instance; +} + AudioEngine::AudioEngine() : QThread() @@ -26,6 +35,7 @@ AudioEngine::AudioEngine() , m_timeElapsed( 0 ) , m_i( 0 ) { + s_instance = this; qDebug() << "Init AudioEngine"; moveToThread( this ); diff --git a/src/audio/audioengine.h b/src/libtomahawk/audio/audioengine.h similarity index 95% rename from src/audio/audioengine.h rename to src/libtomahawk/audio/audioengine.h index 0c78f0afe..e763c9235 100644 --- a/src/audio/audioengine.h +++ b/src/libtomahawk/audio/audioengine.h @@ -12,17 +12,21 @@ #include "alsaplayback.h" #include "transcodeinterface.h" +#include "dllmacro.h" + #define AUDIO_VOLUME_STEP 5 class PlaylistInterface; -class AudioEngine : public QThread +class DLLEXPORT AudioEngine : public QThread { Q_OBJECT public: enum AudioErrorCode { StreamReadError, AudioDeviceError, DecodeError }; + static AudioEngine* instance(); + explicit AudioEngine(); ~AudioEngine(); @@ -104,6 +108,8 @@ private: unsigned int m_timeElapsed; int m_i; + + static AudioEngine* s_instance; }; #endif // AUDIOENGINE_H diff --git a/src/audio/flactranscode.cpp b/src/libtomahawk/audio/flactranscode.cpp similarity index 100% rename from src/audio/flactranscode.cpp rename to src/libtomahawk/audio/flactranscode.cpp diff --git a/src/audio/flactranscode.h b/src/libtomahawk/audio/flactranscode.h similarity index 94% rename from src/audio/flactranscode.h rename to src/libtomahawk/audio/flactranscode.h index ba65a0185..38711e07a 100644 --- a/src/audio/flactranscode.h +++ b/src/libtomahawk/audio/flactranscode.h @@ -15,10 +15,12 @@ #include #include +#include "dllmacro.h" + #define FLAC_BUFFER 32768 * 36 #define FLAC_BUFFER_PREFERRED 32768 -class FLACTranscode : public TranscodeInterface , protected FLAC::Decoder::Stream +class DLLEXPORT FLACTranscode : public TranscodeInterface , protected FLAC::Decoder::Stream { Q_OBJECT diff --git a/src/audio/madtranscode.cpp b/src/libtomahawk/audio/madtranscode.cpp similarity index 100% rename from src/audio/madtranscode.cpp rename to src/libtomahawk/audio/madtranscode.cpp diff --git a/src/audio/madtranscode.h b/src/libtomahawk/audio/madtranscode.h similarity index 95% rename from src/audio/madtranscode.h rename to src/libtomahawk/audio/madtranscode.h index 6b5ea5433..cef9aeb71 100644 --- a/src/audio/madtranscode.h +++ b/src/libtomahawk/audio/madtranscode.h @@ -14,10 +14,12 @@ #include #include +#include "dllmacro.h" + #define MP3_BUFFER 32768 #define MP3_BUFFER_PREFERRED 32768 -class MADTranscode : public TranscodeInterface +class DLLEXPORT MADTranscode : public TranscodeInterface { Q_OBJECT diff --git a/src/audio/rtaudiooutput.cpp b/src/libtomahawk/audio/rtaudiooutput.cpp similarity index 100% rename from src/audio/rtaudiooutput.cpp rename to src/libtomahawk/audio/rtaudiooutput.cpp diff --git a/src/audio/rtaudiooutput.h b/src/libtomahawk/audio/rtaudiooutput.h similarity index 100% rename from src/audio/rtaudiooutput.h rename to src/libtomahawk/audio/rtaudiooutput.h diff --git a/src/audio/transcodeinterface.h b/src/libtomahawk/audio/transcodeinterface.h similarity index 90% rename from src/audio/transcodeinterface.h rename to src/libtomahawk/audio/transcodeinterface.h index 1209cbfe6..3ff4dffd1 100644 --- a/src/audio/transcodeinterface.h +++ b/src/libtomahawk/audio/transcodeinterface.h @@ -6,7 +6,9 @@ #include #include -class TranscodeInterface : public QObject +#include "dllmacro.h" + +class DLLEXPORT TranscodeInterface : public QObject { Q_OBJECT diff --git a/src/audio/vorbistranscode.cpp b/src/libtomahawk/audio/vorbistranscode.cpp similarity index 100% rename from src/audio/vorbistranscode.cpp rename to src/libtomahawk/audio/vorbistranscode.cpp diff --git a/src/audio/vorbistranscode.h b/src/libtomahawk/audio/vorbistranscode.h similarity index 94% rename from src/audio/vorbistranscode.h rename to src/libtomahawk/audio/vorbistranscode.h index a9ed09e29..c7a1dd024 100644 --- a/src/audio/vorbistranscode.h +++ b/src/libtomahawk/audio/vorbistranscode.h @@ -15,11 +15,13 @@ #include #include +#include "dllmacro.h" + // Must not be smaller than 8500 bytes! #define OGG_BUFFER 8500 #define OGG_BUFFER_PREFERRED 32768 -class VorbisTranscode : public TranscodeInterface +class DLLEXPORT VorbisTranscode : public TranscodeInterface { Q_OBJECT diff --git a/src/playlist/albumitem.cpp b/src/libtomahawk/playlist/albumitem.cpp similarity index 100% rename from src/playlist/albumitem.cpp rename to src/libtomahawk/playlist/albumitem.cpp diff --git a/src/playlist/albumitem.h b/src/libtomahawk/playlist/albumitem.h similarity index 92% rename from src/playlist/albumitem.h rename to src/libtomahawk/playlist/albumitem.h index 028f018a1..16dc81b70 100644 --- a/src/playlist/albumitem.h +++ b/src/libtomahawk/playlist/albumitem.h @@ -8,7 +8,9 @@ #include "album.h" -class AlbumItem : public QObject +#include "dllmacro.h" + +class DLLEXPORT AlbumItem : public QObject { Q_OBJECT diff --git a/src/playlist/albumitemdelegate.cpp b/src/libtomahawk/playlist/albumitemdelegate.cpp similarity index 93% rename from src/playlist/albumitemdelegate.cpp rename to src/libtomahawk/playlist/albumitemdelegate.cpp index 508a4256f..631ac6bf1 100644 --- a/src/playlist/albumitemdelegate.cpp +++ b/src/libtomahawk/playlist/albumitemdelegate.cpp @@ -1,12 +1,14 @@ #include "albumitemdelegate.h" +#include #include #include #include #include "query.h" #include "result.h" -#include "tomahawk/tomahawkapp.h" + +#include "utils/tomahawkutils.h" #include "playlist/albumitem.h" #include "playlist/albumproxymodel.h" @@ -37,7 +39,7 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, QStyleOptionViewItemV4 opt = option; initStyleOption( &opt, QModelIndex() ); - APP->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); + qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); if ( option.state & QStyle::State_Selected ) { diff --git a/src/playlist/albumitemdelegate.h b/src/libtomahawk/playlist/albumitemdelegate.h similarity index 88% rename from src/playlist/albumitemdelegate.h rename to src/libtomahawk/playlist/albumitemdelegate.h index 9798a9b28..708eec70d 100644 --- a/src/playlist/albumitemdelegate.h +++ b/src/libtomahawk/playlist/albumitemdelegate.h @@ -3,9 +3,11 @@ #include +#include "dllmacro.h" + class AlbumProxyModel; -class AlbumItemDelegate : public QStyledItemDelegate +class DLLEXPORT AlbumItemDelegate : public QStyledItemDelegate { Q_OBJECT diff --git a/src/playlist/albummodel.cpp b/src/libtomahawk/playlist/albummodel.cpp similarity index 98% rename from src/playlist/albummodel.cpp rename to src/libtomahawk/playlist/albummodel.cpp index b791c79c9..09487b670 100644 --- a/src/playlist/albummodel.cpp +++ b/src/libtomahawk/playlist/albummodel.cpp @@ -5,9 +5,10 @@ #include #include -#include "tomahawk/tomahawkapp.h" #include "database/database.h" +#include "utils/tomahawkutils.h" + #define LASTFM_DEFAULT_COVER "http://cdn.last.fm/flatness/catalogue/noimage" using namespace Tomahawk; @@ -270,7 +271,7 @@ AlbumModel::onAlbumsAdded( const QList& albums, const Tomah QString imgurl = "http://ws.audioscrobbler.com/2.0/?method=album.imageredirect&artist=%1&album=%2&size=large&api_key=7a90f6672a04b809ee309af169f34b8b"; QNetworkRequest req( imgurl.arg( album->artist()->name() ).arg( album->name() ) ); req.setAttribute( QNetworkRequest::User, (qlonglong)albumitem ); - QNetworkReply* reply = APP->nam()->get( req ); + QNetworkReply* reply = TomahawkUtils::nam()->get( req ); connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) ); connect( albumitem, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) ); @@ -313,7 +314,7 @@ AlbumModel::onCoverArtDownloaded() // Follow HTTP redirect QNetworkRequest req( redir ); req.setAttribute( QNetworkRequest::User, reply->request().attribute( QNetworkRequest::User ) ); - QNetworkReply* reply = APP->nam()->get( req ); + QNetworkReply* reply = TomahawkUtils::nam()->get( req ); connect( reply, SIGNAL( finished() ), SLOT( onCoverArtDownloaded() ) ); } diff --git a/src/playlist/albummodel.h b/src/libtomahawk/playlist/albummodel.h similarity index 97% rename from src/playlist/albummodel.h rename to src/libtomahawk/playlist/albummodel.h index 46f8ce29f..445538b86 100644 --- a/src/playlist/albummodel.h +++ b/src/libtomahawk/playlist/albummodel.h @@ -11,9 +11,11 @@ #include "albumitem.h" +#include "dllmacro.h" + class QMetaData; -class AlbumModel : public QAbstractItemModel +class DLLEXPORT AlbumModel : public QAbstractItemModel { Q_OBJECT diff --git a/src/playlist/albumproxymodel.cpp b/src/libtomahawk/playlist/albumproxymodel.cpp similarity index 100% rename from src/playlist/albumproxymodel.cpp rename to src/libtomahawk/playlist/albumproxymodel.cpp diff --git a/src/playlist/albumproxymodel.h b/src/libtomahawk/playlist/albumproxymodel.h similarity index 94% rename from src/playlist/albumproxymodel.h rename to src/libtomahawk/playlist/albumproxymodel.h index f259f79f2..0abd4e1a7 100644 --- a/src/playlist/albumproxymodel.h +++ b/src/libtomahawk/playlist/albumproxymodel.h @@ -6,7 +6,9 @@ #include "playlistinterface.h" #include "playlist/albummodel.h" -class AlbumProxyModel : public QSortFilterProxyModel, public PlaylistInterface +#include "dllmacro.h" + +class DLLEXPORT AlbumProxyModel : public QSortFilterProxyModel, public PlaylistInterface { Q_OBJECT diff --git a/src/playlist/albumview.cpp b/src/libtomahawk/playlist/albumview.cpp similarity index 95% rename from src/playlist/albumview.cpp rename to src/libtomahawk/playlist/albumview.cpp index a10a86b5a..9e954cc7f 100644 --- a/src/playlist/albumview.cpp +++ b/src/libtomahawk/playlist/albumview.cpp @@ -6,10 +6,9 @@ #include #include -#include "tomahawk/tomahawkapp.h" -#include "audioengine.h" -#include "tomahawksettings.h" +#include "audio/audioengine.h" +#include "tomahawksettings.h" #include "albumitemdelegate.h" #include "albummodel.h" #include "albumproxymodel.h" @@ -82,7 +81,7 @@ AlbumView::onItemActivated( const QModelIndex& index ) // qDebug() << "Result activated:" << item->album()->tracks().first()->toString() << item->album()->tracks().first()->results().first()->url(); // APP->audioEngine()->playItem( item->album().data(), item->album()->tracks().first()->results().first() ); - APP->playlistManager()->show( item->album() ); + PlaylistManager::instance()->show( item->album() ); } } diff --git a/src/playlist/albumview.h b/src/libtomahawk/playlist/albumview.h similarity index 94% rename from src/playlist/albumview.h rename to src/libtomahawk/playlist/albumview.h index b9772723c..a2445971f 100644 --- a/src/playlist/albumview.h +++ b/src/libtomahawk/playlist/albumview.h @@ -4,10 +4,12 @@ #include #include +#include "dllmacro.h" + class AlbumModel; class AlbumProxyModel; -class AlbumView : public QListView +class DLLEXPORT AlbumView : public QListView { Q_OBJECT diff --git a/src/playlist/collectionflatmodel.cpp b/src/libtomahawk/playlist/collectionflatmodel.cpp similarity index 100% rename from src/playlist/collectionflatmodel.cpp rename to src/libtomahawk/playlist/collectionflatmodel.cpp diff --git a/src/playlist/collectionflatmodel.h b/src/libtomahawk/playlist/collectionflatmodel.h similarity index 95% rename from src/playlist/collectionflatmodel.h rename to src/libtomahawk/playlist/collectionflatmodel.h index 529631e4f..a87e6a32d 100644 --- a/src/playlist/collectionflatmodel.h +++ b/src/libtomahawk/playlist/collectionflatmodel.h @@ -15,9 +15,11 @@ #include "database/databasecommand_alltracks.h" +#include "dllmacro.h" + class QMetaData; -class CollectionFlatModel : public TrackModel +class DLLEXPORT CollectionFlatModel : public TrackModel { Q_OBJECT diff --git a/src/playlist/collectionmodel.cpp b/src/libtomahawk/playlist/collectionmodel.cpp similarity index 100% rename from src/playlist/collectionmodel.cpp rename to src/libtomahawk/playlist/collectionmodel.cpp diff --git a/src/playlist/collectionmodel.h b/src/libtomahawk/playlist/collectionmodel.h similarity index 95% rename from src/playlist/collectionmodel.h rename to src/libtomahawk/playlist/collectionmodel.h index 4eb918d3a..3fdcad115 100644 --- a/src/playlist/collectionmodel.h +++ b/src/libtomahawk/playlist/collectionmodel.h @@ -12,9 +12,11 @@ #include "playlist.h" #include "playlistinterface.h" +#include "dllmacro.h" + class QMetaData; -class CollectionModel : public QAbstractItemModel +class DLLEXPORT CollectionModel : public QAbstractItemModel { Q_OBJECT diff --git a/src/playlist/collectionproxymodel.cpp b/src/libtomahawk/playlist/collectionproxymodel.cpp similarity index 100% rename from src/playlist/collectionproxymodel.cpp rename to src/libtomahawk/playlist/collectionproxymodel.cpp diff --git a/src/playlist/collectionproxymodel.h b/src/libtomahawk/playlist/collectionproxymodel.h similarity index 77% rename from src/playlist/collectionproxymodel.h rename to src/libtomahawk/playlist/collectionproxymodel.h index 0a08aeb41..e6ea9311d 100644 --- a/src/playlist/collectionproxymodel.h +++ b/src/libtomahawk/playlist/collectionproxymodel.h @@ -3,7 +3,9 @@ #include "trackproxymodel.h" -class CollectionProxyModel : public TrackProxyModel +#include "dllmacro.h" + +class DLLEXPORT CollectionProxyModel : public TrackProxyModel { Q_OBJECT diff --git a/src/playlist/collectionview.cpp b/src/libtomahawk/playlist/collectionview.cpp similarity index 100% rename from src/playlist/collectionview.cpp rename to src/libtomahawk/playlist/collectionview.cpp diff --git a/src/playlist/collectionview.h b/src/libtomahawk/playlist/collectionview.h similarity index 87% rename from src/playlist/collectionview.h rename to src/libtomahawk/playlist/collectionview.h index 9559fc2ed..940f0d4a9 100644 --- a/src/playlist/collectionview.h +++ b/src/libtomahawk/playlist/collectionview.h @@ -3,10 +3,11 @@ #include -#include "tomahawk/tomahawkapp.h" #include "trackview.h" -class CollectionView : public TrackView +#include "dllmacro.h" + +class DLLEXPORT CollectionView : public TrackView { Q_OBJECT diff --git a/src/playlist/playlistitemdelegate.cpp b/src/libtomahawk/playlist/playlistitemdelegate.cpp similarity index 98% rename from src/playlist/playlistitemdelegate.cpp rename to src/libtomahawk/playlist/playlistitemdelegate.cpp index bb7583168..4b7cf133f 100644 --- a/src/playlist/playlistitemdelegate.cpp +++ b/src/libtomahawk/playlist/playlistitemdelegate.cpp @@ -6,7 +6,6 @@ #include "query.h" #include "result.h" -#include "tomahawk/tomahawkapp.h" #include "playlist/plitem.h" #include "playlist/trackproxymodel.h" diff --git a/src/playlist/playlistitemdelegate.h b/src/libtomahawk/playlist/playlistitemdelegate.h similarity index 90% rename from src/playlist/playlistitemdelegate.h rename to src/libtomahawk/playlist/playlistitemdelegate.h index f47826f63..8001a48b7 100644 --- a/src/playlist/playlistitemdelegate.h +++ b/src/libtomahawk/playlist/playlistitemdelegate.h @@ -3,9 +3,11 @@ #include +#include "dllmacro.h" + class TrackProxyModel; -class PlaylistItemDelegate : public QStyledItemDelegate +class DLLEXPORT PlaylistItemDelegate : public QStyledItemDelegate { Q_OBJECT diff --git a/src/playlist/playlistmanager.cpp b/src/libtomahawk/playlist/playlistmanager.cpp similarity index 97% rename from src/playlist/playlistmanager.cpp rename to src/libtomahawk/playlist/playlistmanager.cpp index 257410a8d..53b166754 100644 --- a/src/playlist/playlistmanager.cpp +++ b/src/libtomahawk/playlist/playlistmanager.cpp @@ -19,10 +19,19 @@ #include "sourcelist.h" #include "tomahawksettings.h" -#include "infowidgets/sourceinfowidget.h" +#include "widgets/infowidgets/sourceinfowidget.h" #define FILTER_TIMEOUT 280 +PlaylistManager* PlaylistManager::s_instance = 0; + + +PlaylistManager* +PlaylistManager::instance() +{ + return s_instance; +} + PlaylistManager::PlaylistManager( QObject* parent ) : QObject( parent ) @@ -33,6 +42,7 @@ PlaylistManager::PlaylistManager( QObject* parent ) , m_statsAvailable( false ) , m_modesAvailable( false ) { + s_instance = this; m_stack = new QStackedWidget(); m_widget->setLayout( new QVBoxLayout() ); @@ -46,7 +56,7 @@ PlaylistManager::PlaylistManager( QObject* parent ) m_queueView = new QueueView( m_splitter ); m_queueModel = new PlaylistModel( m_queueView ); m_queueView->queue()->setModel( m_queueModel ); - APP->audioEngine()->setQueue( m_queueView->queue()->proxyModel() ); + AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() ); m_splitter->addWidget( m_queueView ); m_splitter->hide( 1, false ); @@ -484,7 +494,7 @@ PlaylistManager::linkPlaylist() } applyFilter(); - APP->audioEngine()->setPlaylist( m_currentInterface ); + AudioEngine::instance()->setPlaylist( m_currentInterface ); if ( m_currentInterface && m_statsAvailable ) { @@ -544,7 +554,7 @@ PlaylistManager::showCurrentTrack() { unlinkPlaylist(); - m_currentInterface = APP->audioEngine()->currentTrackPlaylist(); + m_currentInterface = AudioEngine::instance()->currentTrackPlaylist(); if ( m_currentInterface->widget() ) m_stack->setCurrentWidget( m_currentInterface->widget() ); diff --git a/src/playlist/playlistmanager.h b/src/libtomahawk/playlist/playlistmanager.h similarity index 95% rename from src/playlist/playlistmanager.h rename to src/libtomahawk/playlist/playlistmanager.h index 729472bbc..40ff02e08 100644 --- a/src/playlist/playlistmanager.h +++ b/src/libtomahawk/playlist/playlistmanager.h @@ -8,6 +8,8 @@ #include "collection.h" #include "playlistinterface.h" +#include "dllmacro.h" + class AnimatedSplitter; class AlbumModel; class AlbumView; @@ -22,11 +24,13 @@ class TrackModel; class TrackView; class SourceInfoWidget; -class PlaylistManager : public QObject +class DLLEXPORT PlaylistManager : public QObject { Q_OBJECT public: + static PlaylistManager* instance(); + explicit PlaylistManager( QObject* parent = 0 ); ~PlaylistManager(); @@ -116,6 +120,8 @@ private: QTimer m_filterTimer; QString m_filter; + + static PlaylistManager* s_instance; }; #endif // PLAYLISTMANAGER_H diff --git a/src/playlist/playlistmodel.cpp b/src/libtomahawk/playlist/playlistmodel.cpp similarity index 100% rename from src/playlist/playlistmodel.cpp rename to src/libtomahawk/playlist/playlistmodel.cpp diff --git a/src/playlist/playlistmodel.h b/src/libtomahawk/playlist/playlistmodel.h similarity index 96% rename from src/playlist/playlistmodel.h rename to src/libtomahawk/playlist/playlistmodel.h index 3f68ef30b..b07be5bb0 100644 --- a/src/playlist/playlistmodel.h +++ b/src/libtomahawk/playlist/playlistmodel.h @@ -6,16 +6,17 @@ #include "plitem.h" #include "trackmodel.h" -#include "tomahawk/tomahawkapp.h" #include "collection.h" #include "query.h" #include "typedefs.h" #include "playlist.h" #include "playlistinterface.h" +#include "dllmacro.h" + class QMetaData; -class PlaylistModel : public TrackModel +class DLLEXPORT PlaylistModel : public TrackModel { Q_OBJECT diff --git a/src/playlist/playlistproxymodel.cpp b/src/libtomahawk/playlist/playlistproxymodel.cpp similarity index 100% rename from src/playlist/playlistproxymodel.cpp rename to src/libtomahawk/playlist/playlistproxymodel.cpp diff --git a/src/playlist/playlistproxymodel.h b/src/libtomahawk/playlist/playlistproxymodel.h similarity index 70% rename from src/playlist/playlistproxymodel.h rename to src/libtomahawk/playlist/playlistproxymodel.h index ad3dc6ecd..9149c74b8 100644 --- a/src/playlist/playlistproxymodel.h +++ b/src/libtomahawk/playlist/playlistproxymodel.h @@ -3,7 +3,9 @@ #include "trackproxymodel.h" -class PlaylistProxyModel : public TrackProxyModel +#include "dllmacro.h" + +class DLLEXPORT PlaylistProxyModel : public TrackProxyModel { Q_OBJECT diff --git a/src/playlist/playlistview.cpp b/src/libtomahawk/playlist/playlistview.cpp similarity index 100% rename from src/playlist/playlistview.cpp rename to src/libtomahawk/playlist/playlistview.cpp diff --git a/src/playlist/playlistview.h b/src/libtomahawk/playlist/playlistview.h similarity index 89% rename from src/playlist/playlistview.h rename to src/libtomahawk/playlist/playlistview.h index e9887fe0e..8c864be99 100644 --- a/src/playlist/playlistview.h +++ b/src/libtomahawk/playlist/playlistview.h @@ -3,10 +3,11 @@ #include -#include "tomahawk/tomahawkapp.h" #include "trackview.h" -class PlaylistView : public TrackView +#include "dllmacro.h" + +class DLLEXPORT PlaylistView : public TrackView { Q_OBJECT diff --git a/src/playlist/plitem.cpp b/src/libtomahawk/playlist/plitem.cpp similarity index 100% rename from src/playlist/plitem.cpp rename to src/libtomahawk/playlist/plitem.cpp diff --git a/src/playlist/plitem.h b/src/libtomahawk/playlist/plitem.h similarity index 95% rename from src/playlist/plitem.h rename to src/libtomahawk/playlist/plitem.h index 4ffcd6076..06e0e640f 100644 --- a/src/playlist/plitem.h +++ b/src/libtomahawk/playlist/plitem.h @@ -8,7 +8,9 @@ #include "query.h" #include "typedefs.h" -class PlItem : public QObject +#include "dllmacro.h" + +class DLLEXPORT PlItem : public QObject { Q_OBJECT diff --git a/src/playlist/queueproxymodel.cpp b/src/libtomahawk/playlist/queueproxymodel.cpp similarity index 89% rename from src/playlist/queueproxymodel.cpp rename to src/libtomahawk/playlist/queueproxymodel.cpp index e55da1bbb..730cf80c8 100644 --- a/src/playlist/queueproxymodel.cpp +++ b/src/libtomahawk/playlist/queueproxymodel.cpp @@ -2,7 +2,6 @@ #include -#include "tomahawk/tomahawkapp.h" #include "playlist/playlistmanager.h" using namespace Tomahawk; @@ -30,7 +29,7 @@ QueueProxyModel::siblingItem( int itemsAway ) qDebug() << "new rowcount:" << rowCount( QModelIndex() ); if ( rowCount( QModelIndex() ) == 1 ) - APP->playlistManager()->hideQueue(); + PlaylistManager::instance()->hideQueue(); removeIndex( currentItem() ); diff --git a/src/playlist/queueproxymodel.h b/src/libtomahawk/playlist/queueproxymodel.h similarity index 78% rename from src/playlist/queueproxymodel.h rename to src/libtomahawk/playlist/queueproxymodel.h index 6cf280694..d74229e75 100644 --- a/src/playlist/queueproxymodel.h +++ b/src/libtomahawk/playlist/queueproxymodel.h @@ -3,9 +3,11 @@ #include "playlistproxymodel.h" +#include "dllmacro.h" + class QMetaData; -class QueueProxyModel : public PlaylistProxyModel +class DLLEXPORT QueueProxyModel : public PlaylistProxyModel { Q_OBJECT diff --git a/src/playlist/queueview.cpp b/src/libtomahawk/playlist/queueview.cpp similarity index 100% rename from src/playlist/queueview.cpp rename to src/libtomahawk/playlist/queueview.cpp diff --git a/src/playlist/queueview.h b/src/libtomahawk/playlist/queueview.h similarity index 87% rename from src/playlist/queueview.h rename to src/libtomahawk/playlist/queueview.h index 204e63ad3..f43b717fc 100644 --- a/src/playlist/queueview.h +++ b/src/libtomahawk/playlist/queueview.h @@ -6,7 +6,9 @@ #include "utils/animatedsplitter.h" #include "playlistview.h" -class QueueView : public AnimatedWidget +#include "dllmacro.h" + +class DLLEXPORT QueueView : public AnimatedWidget { Q_OBJECT diff --git a/src/playlist/trackheader.cpp b/src/libtomahawk/playlist/trackheader.cpp similarity index 99% rename from src/playlist/trackheader.cpp rename to src/libtomahawk/playlist/trackheader.cpp index 60cbb6d4e..6472b24bb 100644 --- a/src/playlist/trackheader.cpp +++ b/src/libtomahawk/playlist/trackheader.cpp @@ -4,7 +4,6 @@ #include #include -#include "tomahawk/tomahawkapp.h" #include "tomahawksettings.h" #include "playlist/trackmodel.h" #include "playlist/trackview.h" diff --git a/src/playlist/trackheader.h b/src/libtomahawk/playlist/trackheader.h similarity index 91% rename from src/playlist/trackheader.h rename to src/libtomahawk/playlist/trackheader.h index a8f757a01..5f36cdba8 100644 --- a/src/playlist/trackheader.h +++ b/src/libtomahawk/playlist/trackheader.h @@ -4,9 +4,11 @@ #include #include +#include "dllmacro.h" + class TrackView; -class TrackHeader : public QHeaderView +class DLLEXPORT TrackHeader : public QHeaderView { Q_OBJECT diff --git a/src/playlist/trackmodel.cpp b/src/libtomahawk/playlist/trackmodel.cpp similarity index 95% rename from src/playlist/trackmodel.cpp rename to src/libtomahawk/playlist/trackmodel.cpp index d4e348d9f..0a78a446e 100644 --- a/src/playlist/trackmodel.cpp +++ b/src/libtomahawk/playlist/trackmodel.cpp @@ -4,7 +4,9 @@ #include #include -#include "tomahawk/tomahawkapp.h" +#include "audio/audioengine.h" +#include "utils/tomahawkutils.h" + #include "album.h" using namespace Tomahawk; @@ -17,8 +19,8 @@ TrackModel::TrackModel( QObject* parent ) { qDebug() << Q_FUNC_INFO; - connect( (QObject*)APP->audioEngine(), SIGNAL( finished( Tomahawk::result_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::result_ptr ) ), Qt::DirectConnection ); - connect( (QObject*)APP->audioEngine(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ), Qt::DirectConnection ); + connect( AudioEngine::instance(), SIGNAL( finished( Tomahawk::result_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::result_ptr ) ), Qt::DirectConnection ); + connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ), Qt::DirectConnection ); } diff --git a/src/playlist/trackmodel.h b/src/libtomahawk/playlist/trackmodel.h similarity index 96% rename from src/playlist/trackmodel.h rename to src/libtomahawk/playlist/trackmodel.h index 8c5094de2..ad43006be 100644 --- a/src/playlist/trackmodel.h +++ b/src/libtomahawk/playlist/trackmodel.h @@ -6,9 +6,11 @@ #include "playlistinterface.h" #include "playlist/plitem.h" +#include "dllmacro.h" + class QMetaData; -class TrackModel : public QAbstractItemModel +class DLLEXPORT TrackModel : public QAbstractItemModel { Q_OBJECT diff --git a/src/playlist/trackproxymodel.cpp b/src/libtomahawk/playlist/trackproxymodel.cpp similarity index 100% rename from src/playlist/trackproxymodel.cpp rename to src/libtomahawk/playlist/trackproxymodel.cpp diff --git a/src/playlist/trackproxymodel.h b/src/libtomahawk/playlist/trackproxymodel.h similarity index 94% rename from src/playlist/trackproxymodel.h rename to src/libtomahawk/playlist/trackproxymodel.h index 88552dd27..45d0020b3 100644 --- a/src/playlist/trackproxymodel.h +++ b/src/libtomahawk/playlist/trackproxymodel.h @@ -6,7 +6,9 @@ #include "playlistinterface.h" #include "playlist/trackmodel.h" -class TrackProxyModel : public QSortFilterProxyModel, public PlaylistInterface +#include "dllmacro.h" + +class DLLEXPORT TrackProxyModel : public QSortFilterProxyModel, public PlaylistInterface { Q_OBJECT diff --git a/src/playlist/trackview.cpp b/src/libtomahawk/playlist/trackview.cpp similarity index 95% rename from src/playlist/trackview.cpp rename to src/libtomahawk/playlist/trackview.cpp index 0bc0ab27d..b6d1576e1 100644 --- a/src/playlist/trackview.cpp +++ b/src/libtomahawk/playlist/trackview.cpp @@ -5,11 +5,12 @@ #include #include -#include "tomahawk/tomahawkapp.h" -#include "playlist/trackheader.h" -#include "playlist/playlistmanager.h" -#include "playlist/queueview.h" -#include "audioengine.h" +#include "audio/audioengine.h" +#include "utils/tomahawkutils.h" + +#include "trackheader.h" +#include "playlistmanager.h" +#include "queueview.h" #include "trackmodel.h" #include "trackproxymodel.h" @@ -94,7 +95,7 @@ TrackView::onItemActivated( const QModelIndex& index ) { qDebug() << "Result activated:" << item->query()->toString() << item->query()->results().first()->url(); m_proxyModel->setCurrentItem( index ); - APP->audioEngine()->playItem( m_proxyModel, item->query()->results().first() ); + AudioEngine::instance()->playItem( m_proxyModel, item->query()->results().first() ); } } @@ -141,8 +142,8 @@ TrackView::addItemsToQueue() PlItem* item = model()->itemFromIndex( proxyModel()->mapToSource( idx ) ); if ( item && item->query()->numResults() ) { - APP->playlistManager()->queue()->model()->append( item->query() ); - APP->playlistManager()->showQueue(); + PlaylistManager::instance()->queue()->model()->append( item->query() ); + PlaylistManager::instance()->showQueue(); } } } diff --git a/src/playlist/trackview.h b/src/libtomahawk/playlist/trackview.h similarity index 96% rename from src/playlist/trackview.h rename to src/libtomahawk/playlist/trackview.h index 018a97c2c..92601ed7c 100644 --- a/src/playlist/trackview.h +++ b/src/libtomahawk/playlist/trackview.h @@ -6,12 +6,14 @@ #include "playlistitemdelegate.h" +#include "dllmacro.h" + class PlaylistInterface; class TrackHeader; class TrackModel; class TrackProxyModel; -class TrackView : public QTreeView +class DLLEXPORT TrackView : public QTreeView { Q_OBJECT diff --git a/src/utils/animatedcounterlabel.h b/src/libtomahawk/utils/animatedcounterlabel.h similarity index 100% rename from src/utils/animatedcounterlabel.h rename to src/libtomahawk/utils/animatedcounterlabel.h diff --git a/src/utils/animatedsplitter.cpp b/src/libtomahawk/utils/animatedsplitter.cpp similarity index 100% rename from src/utils/animatedsplitter.cpp rename to src/libtomahawk/utils/animatedsplitter.cpp diff --git a/src/utils/animatedsplitter.h b/src/libtomahawk/utils/animatedsplitter.h similarity index 92% rename from src/utils/animatedsplitter.h rename to src/libtomahawk/utils/animatedsplitter.h index 678c63a5c..6072dcdb9 100644 --- a/src/utils/animatedsplitter.h +++ b/src/libtomahawk/utils/animatedsplitter.h @@ -5,9 +5,11 @@ #include #include +#include "dllmacro.h" + class AnimatedWidget; -class AnimatedSplitter : public QSplitter +class DLLEXPORT AnimatedSplitter : public QSplitter { Q_OBJECT @@ -44,7 +46,7 @@ private: QTimeLine* m_timeLine; }; -class AnimatedWidget : public QWidget +class DLLEXPORT AnimatedWidget : public QWidget { Q_OBJECT public: diff --git a/src/utils/elidedlabel.cpp b/src/libtomahawk/utils/elidedlabel.cpp similarity index 100% rename from src/utils/elidedlabel.cpp rename to src/libtomahawk/utils/elidedlabel.cpp diff --git a/src/utils/elidedlabel.h b/src/libtomahawk/utils/elidedlabel.h similarity index 95% rename from src/utils/elidedlabel.h rename to src/libtomahawk/utils/elidedlabel.h index f05b766c5..2756ac73e 100644 --- a/src/utils/elidedlabel.h +++ b/src/libtomahawk/utils/elidedlabel.h @@ -4,7 +4,9 @@ #include #include -class ElidedLabel : public QFrame +#include "dllmacro.h" + +class DLLEXPORT ElidedLabel : public QFrame { Q_OBJECT Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged ) diff --git a/src/utils/imagebutton.cpp b/src/libtomahawk/utils/imagebutton.cpp similarity index 100% rename from src/utils/imagebutton.cpp rename to src/libtomahawk/utils/imagebutton.cpp diff --git a/src/utils/imagebutton.h b/src/libtomahawk/utils/imagebutton.h similarity index 92% rename from src/utils/imagebutton.h rename to src/libtomahawk/utils/imagebutton.h index 66e9082d6..822d77cb3 100644 --- a/src/utils/imagebutton.h +++ b/src/libtomahawk/utils/imagebutton.h @@ -5,8 +5,9 @@ #include #include +#include "dllmacro.h" -class ImageButton : public QAbstractButton +class DLLEXPORT ImageButton : public QAbstractButton { Q_OBJECT diff --git a/src/utils/modeltest.cpp b/src/libtomahawk/utils/modeltest.cpp similarity index 100% rename from src/utils/modeltest.cpp rename to src/libtomahawk/utils/modeltest.cpp diff --git a/src/utils/modeltest.h b/src/libtomahawk/utils/modeltest.h similarity index 100% rename from src/utils/modeltest.h rename to src/libtomahawk/utils/modeltest.h diff --git a/src/utils/progresstreeview.cpp b/src/libtomahawk/utils/progresstreeview.cpp similarity index 100% rename from src/utils/progresstreeview.cpp rename to src/libtomahawk/utils/progresstreeview.cpp diff --git a/src/utils/progresstreeview.h b/src/libtomahawk/utils/progresstreeview.h similarity index 90% rename from src/utils/progresstreeview.h rename to src/libtomahawk/utils/progresstreeview.h index 89caba11e..154e1e7d0 100644 --- a/src/utils/progresstreeview.h +++ b/src/libtomahawk/utils/progresstreeview.h @@ -4,7 +4,9 @@ #include #include -class ProgressTreeView : public QTreeView +#include "dllmacro.h" + +class DLLEXPORT ProgressTreeView : public QTreeView { Q_OBJECT diff --git a/src/utils/proxystyle.cpp b/src/libtomahawk/utils/proxystyle.cpp similarity index 100% rename from src/utils/proxystyle.cpp rename to src/libtomahawk/utils/proxystyle.cpp diff --git a/src/utils/proxystyle.h b/src/libtomahawk/utils/proxystyle.h similarity index 75% rename from src/utils/proxystyle.h rename to src/libtomahawk/utils/proxystyle.h index 356175f8b..fcf105e12 100644 --- a/src/utils/proxystyle.h +++ b/src/libtomahawk/utils/proxystyle.h @@ -4,7 +4,9 @@ #include #include -class ProxyStyle : public QProxyStyle +#include "dllmacro.h" + +class DLLEXPORT ProxyStyle : public QProxyStyle { public: ProxyStyle() {} diff --git a/src/utils/querylabel.cpp b/src/libtomahawk/utils/querylabel.cpp similarity index 100% rename from src/utils/querylabel.cpp rename to src/libtomahawk/utils/querylabel.cpp diff --git a/src/utils/querylabel.h b/src/libtomahawk/utils/querylabel.h similarity index 97% rename from src/utils/querylabel.h rename to src/libtomahawk/utils/querylabel.h index a9974966c..25ebefce8 100644 --- a/src/utils/querylabel.h +++ b/src/libtomahawk/utils/querylabel.h @@ -6,7 +6,9 @@ #include "result.h" -class QueryLabel : public QFrame +#include "dllmacro.h" + +class DLLEXPORT QueryLabel : public QFrame { Q_OBJECT diff --git a/src/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp similarity index 94% rename from src/utils/tomahawkutils.cpp rename to src/libtomahawk/utils/tomahawkutils.cpp index d9a5e6c50..312459328 100644 --- a/src/utils/tomahawkutils.cpp +++ b/src/libtomahawk/utils/tomahawkutils.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #ifdef WIN32 #include @@ -273,4 +274,35 @@ createDragPixmap( int itemCount ) return dragPixmap; } + +QNetworkAccessManager* s_nam = 0; +QNetworkProxy* s_proxy = 0; + +QNetworkAccessManager* +nam() +{ + return s_nam; +} + + +QNetworkProxy* +proxy() +{ + return s_proxy; +} + + +void +setNam( QNetworkAccessManager* nam ) +{ + s_nam = nam; +} + + +void +setProxy( QNetworkProxy* proxy ) +{ + s_proxy = proxy; +} + } // ns diff --git a/src/libtomahawk/utils/tomahawkutils.h b/src/libtomahawk/utils/tomahawkutils.h new file mode 100644 index 000000000..6fdd14bc7 --- /dev/null +++ b/src/libtomahawk/utils/tomahawkutils.h @@ -0,0 +1,33 @@ +#ifndef TOMAHAWKUTILS_H +#define TOMAHAWKUTILS_H + +#include "dllmacro.h" + +#define RESPATH ":/data/" + +class QDir; +class QDateTime; +class QString; +class QPixmap; +class QNetworkAccessManager; +class QNetworkProxy; + +namespace TomahawkUtils +{ + DLLEXPORT QDir appConfigDir(); + DLLEXPORT QDir appDataDir(); + + DLLEXPORT QString timeToString( int seconds ); + DLLEXPORT QString ageToString( const QDateTime& time ); + DLLEXPORT QString filesizeToString( unsigned int size ); + + DLLEXPORT QPixmap createDragPixmap( int itemCount = 1 ); + + DLLEXPORT QNetworkAccessManager* nam(); + DLLEXPORT QNetworkProxy* proxy(); + + DLLEXPORT void setNam( QNetworkAccessManager* nam ); + DLLEXPORT void setProxy( QNetworkProxy* proxy ); +} + +#endif // TOMAHAWKUTILS_H diff --git a/src/utils/widgetdragfilter.cpp b/src/libtomahawk/utils/widgetdragfilter.cpp similarity index 100% rename from src/utils/widgetdragfilter.cpp rename to src/libtomahawk/utils/widgetdragfilter.cpp diff --git a/src/utils/widgetdragfilter.h b/src/libtomahawk/utils/widgetdragfilter.h similarity index 89% rename from src/utils/widgetdragfilter.h rename to src/libtomahawk/utils/widgetdragfilter.h index 2c4235a1a..18bfc36dd 100644 --- a/src/utils/widgetdragfilter.h +++ b/src/libtomahawk/utils/widgetdragfilter.h @@ -5,6 +5,8 @@ #include #include +#include "dllmacro.h" + class QMouseEvent; class QEvent; @@ -12,7 +14,7 @@ class QEvent; * This class encapsulates an event filter on a widget that lets any drag events over the widget * translate into move events for the whole application. */ -class WidgetDragFilter : public QObject +class DLLEXPORT WidgetDragFilter : public QObject { Q_OBJECT public: diff --git a/src/infowidgets/sourceinfowidget.cpp b/src/libtomahawk/widgets/infowidgets/sourceinfowidget.cpp similarity index 98% rename from src/infowidgets/sourceinfowidget.cpp rename to src/libtomahawk/widgets/infowidgets/sourceinfowidget.cpp index f2845b697..b04ccae35 100644 --- a/src/infowidgets/sourceinfowidget.cpp +++ b/src/libtomahawk/widgets/infowidgets/sourceinfowidget.cpp @@ -1,7 +1,6 @@ #include "sourceinfowidget.h" #include "ui_sourceinfowidget.h" -#include "tomahawk/tomahawkapp.h" #include "utils/tomahawkutils.h" #include "playlist/playlistmanager.h" diff --git a/src/infowidgets/sourceinfowidget.h b/src/libtomahawk/widgets/infowidgets/sourceinfowidget.h similarity index 90% rename from src/infowidgets/sourceinfowidget.h rename to src/libtomahawk/widgets/infowidgets/sourceinfowidget.h index 1fe064980..8d369a97e 100644 --- a/src/infowidgets/sourceinfowidget.h +++ b/src/libtomahawk/widgets/infowidgets/sourceinfowidget.h @@ -7,6 +7,8 @@ #include "result.h" #include "playlistinterface.h" +#include "dllmacro.h" + class AlbumModel; class CollectionFlatModel; class PlaylistModel; @@ -16,7 +18,7 @@ namespace Ui class SourceInfoWidget; } -class SourceInfoWidget : public QWidget +class DLLEXPORT SourceInfoWidget : public QWidget { Q_OBJECT diff --git a/src/infowidgets/sourceinfowidget.ui b/src/libtomahawk/widgets/infowidgets/sourceinfowidget.ui similarity index 96% rename from src/infowidgets/sourceinfowidget.ui rename to src/libtomahawk/widgets/infowidgets/sourceinfowidget.ui index 1146b9fd9..871331a85 100644 --- a/src/infowidgets/sourceinfowidget.ui +++ b/src/libtomahawk/widgets/infowidgets/sourceinfowidget.ui @@ -120,17 +120,17 @@ PlaylistView QTreeView -
playlistview.h
+
playlist/playlistview.h
CollectionView QTreeView -
collectionview.h
+
playlist/collectionview.h
AlbumView QListView -
albumview.h
+
playlist/albumview.h
diff --git a/src/widgets/newplaylistwidget.cpp b/src/libtomahawk/widgets/newplaylistwidget.cpp similarity index 97% rename from src/widgets/newplaylistwidget.cpp rename to src/libtomahawk/widgets/newplaylistwidget.cpp index 94bcd7ac9..1d867b84a 100644 --- a/src/widgets/newplaylistwidget.cpp +++ b/src/libtomahawk/widgets/newplaylistwidget.cpp @@ -4,7 +4,6 @@ #include #include -#include "tomahawk/tomahawkapp.h" #include "utils/tomahawkutils.h" #include "playlist/playlistmanager.h" @@ -118,7 +117,7 @@ NewPlaylistWidget::savePlaylist() playlist = Tomahawk::Playlist::create( SourceList::instance()->getLocal(), uuid(), ui->titleEdit->text(), "", "", false ); playlist->createNewRevision( uuid(), playlist->currentrevision(), m_entries ); - APP->playlistManager()->show( playlist ); + PlaylistManager::instance()->show( playlist ); cancel(); } diff --git a/src/widgets/newplaylistwidget.h b/src/libtomahawk/widgets/newplaylistwidget.h similarity index 91% rename from src/widgets/newplaylistwidget.h rename to src/libtomahawk/widgets/newplaylistwidget.h index c20ef73f4..36a6c9e67 100644 --- a/src/widgets/newplaylistwidget.h +++ b/src/libtomahawk/widgets/newplaylistwidget.h @@ -8,6 +8,8 @@ #include "result.h" #include "playlistinterface.h" +#include "dllmacro.h" + class PlaylistModel; namespace Ui @@ -15,7 +17,7 @@ namespace Ui class NewPlaylistWidget; } -class NewPlaylistWidget : public QWidget +class DLLEXPORT NewPlaylistWidget : public QWidget { Q_OBJECT diff --git a/src/widgets/newplaylistwidget.ui b/src/libtomahawk/widgets/newplaylistwidget.ui similarity index 98% rename from src/widgets/newplaylistwidget.ui rename to src/libtomahawk/widgets/newplaylistwidget.ui index f6095dd78..8b30f4780 100644 --- a/src/widgets/newplaylistwidget.ui +++ b/src/libtomahawk/widgets/newplaylistwidget.ui @@ -103,7 +103,7 @@ PlaylistView QTreeView -
playlistview.h
+
playlist/playlistview.h
diff --git a/src/widgets/welcomewidget.cpp b/src/libtomahawk/widgets/welcomewidget.cpp similarity index 96% rename from src/widgets/welcomewidget.cpp rename to src/libtomahawk/widgets/welcomewidget.cpp index 7e0b12de3..6e5c2b749 100644 --- a/src/widgets/welcomewidget.cpp +++ b/src/libtomahawk/widgets/welcomewidget.cpp @@ -1,7 +1,6 @@ #include "welcomewidget.h" #include "ui_welcomewidget.h" -#include "tomahawk/tomahawkapp.h" #include "utils/tomahawkutils.h" #include "playlist/playlistmanager.h" @@ -79,7 +78,7 @@ WelcomeWidget::onPlaylistActivated( QListWidgetItem* item ) qDebug() << Q_FUNC_INFO; PlaylistWidgetItem* pwi = dynamic_cast(item); - APP->playlistManager()->show( pwi->playlist() ); + PlaylistManager::instance()->show( pwi->playlist() ); } @@ -146,7 +145,7 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, { QStyleOptionViewItemV4 opt = option; initStyleOption( &opt, QModelIndex() ); - APP->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); + qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); if ( option.state & QStyle::State_Selected ) { diff --git a/src/widgets/welcomewidget.h b/src/libtomahawk/widgets/welcomewidget.h similarity index 87% rename from src/widgets/welcomewidget.h rename to src/libtomahawk/widgets/welcomewidget.h index 707c5945e..c98e8a148 100644 --- a/src/widgets/welcomewidget.h +++ b/src/libtomahawk/widgets/welcomewidget.h @@ -5,12 +5,15 @@ #include #include -#include "tomahawk/tomahawkapp.h" #include "playlistinterface.h" #include "playlist.h" #include "result.h" +#include "utils/tomahawkutils.h" + +#include "dllmacro.h" + class PlaylistModel; namespace Ui @@ -18,7 +21,7 @@ namespace Ui class WelcomeWidget; } -class PlaylistDelegate : public QStyledItemDelegate +class DLLEXPORT PlaylistDelegate : public QStyledItemDelegate { Q_OBJECT @@ -37,7 +40,7 @@ private: }; -class PlaylistWidgetItem : public QListWidgetItem +class DLLEXPORT PlaylistWidgetItem : public QListWidgetItem { public: enum ItemRoles @@ -57,7 +60,7 @@ private: }; -class WelcomeWidget : public QWidget +class DLLEXPORT WelcomeWidget : public QWidget { Q_OBJECT diff --git a/src/widgets/welcomewidget.ui b/src/libtomahawk/widgets/welcomewidget.ui similarity index 97% rename from src/widgets/welcomewidget.ui rename to src/libtomahawk/widgets/welcomewidget.ui index 789b748d3..bbd6b2846 100644 --- a/src/widgets/welcomewidget.ui +++ b/src/libtomahawk/widgets/welcomewidget.ui @@ -64,7 +64,7 @@ PlaylistView QTreeView -
playlistview.h
+
playlist/playlistview.h
diff --git a/src/scrobbler.cpp b/src/scrobbler.cpp index 0cfb0bf3f..0e5bb1661 100644 --- a/src/scrobbler.cpp +++ b/src/scrobbler.cpp @@ -52,8 +52,8 @@ Scrobbler::Scrobbler( QObject* parent ) connect( TomahawkApp::instance(), SIGNAL( settingsChanged() ), SLOT( settingsChanged() ), Qt::QueuedConnection ); - connect( TomahawkApp::instance()->audioEngine(), SIGNAL( timerSeconds( unsigned int ) ), - SLOT( engineTick( unsigned int ) ), Qt::QueuedConnection ); + connect( AudioEngine::instance(), SIGNAL( timerSeconds( unsigned int ) ), + SLOT( engineTick( unsigned int ) ), Qt::QueuedConnection ); } diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index e8f6e4c5c..16304914f 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -303,9 +303,9 @@ ProxyDialog::saveSettings() return; QNetworkProxy proxy( static_cast(s->proxyType()), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ); - QNetworkAccessManager* nam = TomahawkApp::instance()->nam(); + QNetworkAccessManager* nam = TomahawkUtils::nam(); nam->setProxy( proxy ); - QNetworkProxy* globalProxy = TomahawkApp::instance()->proxy(); + QNetworkProxy* globalProxy = TomahawkUtils::proxy(); QNetworkProxy* oldProxy = globalProxy; globalProxy = new QNetworkProxy( proxy ); if( oldProxy ) diff --git a/src/sourcetree/sourcesmodel.cpp b/src/sourcetree/sourcesmodel.cpp index ed58b5009..15143ec87 100644 --- a/src/sourcetree/sourcesmodel.cpp +++ b/src/sourcetree/sourcesmodel.cpp @@ -9,7 +9,7 @@ #include "query.h" #include "sourcelist.h" #include "sourcetreeitem.h" -#include "imagebutton.h" +#include "utils/imagebutton.h" using namespace Tomahawk; diff --git a/src/sourcetree/sourcetreeitemwidget.cpp b/src/sourcetree/sourcetreeitemwidget.cpp index d175d6766..a93c59d29 100644 --- a/src/sourcetree/sourcetreeitemwidget.cpp +++ b/src/sourcetree/sourcetreeitemwidget.cpp @@ -7,7 +7,7 @@ #include "database/database.h" #include "database/databasecommand_collectionstats.h" #include "network/dbsyncconnection.h" -#include "playlistmanager.h" +#include "playlist/playlistmanager.h" using namespace Tomahawk; @@ -173,5 +173,5 @@ SourceTreeItemWidget::onOffline() void SourceTreeItemWidget::onInfoButtonClicked() { - APP->playlistManager()->show( m_source ); + PlaylistManager::instance()->show( m_source ); } diff --git a/src/sourcetree/sourcetreeitemwidget.ui b/src/sourcetree/sourcetreeitemwidget.ui index 17457afa9..e87cc409c 100644 --- a/src/sourcetree/sourcetreeitemwidget.ui +++ b/src/sourcetree/sourcetreeitemwidget.ui @@ -182,17 +182,17 @@ ImageButton QPushButton -
imagebutton.h
+
utils/imagebutton.h
QueryLabel QLabel -
querylabel.h
+
utils/querylabel.h
ElidedLabel QLabel -
elidedlabel.h
+
utils/elidedlabel.h
diff --git a/src/sourcetree/sourcetreeview.cpp b/src/sourcetree/sourcetreeview.cpp index 6017709a0..d63f47e4c 100644 --- a/src/sourcetree/sourcetreeview.cpp +++ b/src/sourcetree/sourcetreeview.cpp @@ -1,8 +1,8 @@ #include "sourcetreeview.h" #include "playlist.h" -#include "collectionmodel.h" -#include "playlistmanager.h" +#include "playlist/collectionmodel.h" +#include "playlist/playlistmanager.h" #include "sourcetreeitem.h" #include "sourcesmodel.h" #include "sourcelist.h" @@ -129,13 +129,13 @@ SourceTreeView::onItemActivated( const QModelIndex& index ) { if ( item->source().isNull() ) { - APP->playlistManager()->showSuperCollection(); + PlaylistManager::instance()->showSuperCollection(); } else { qDebug() << "SourceTreeItem toggled:" << item->source()->userName(); - APP->playlistManager()->show( item->source()->collection() ); + PlaylistManager::instance()->show( item->source()->collection() ); // APP->playlistManager()->show( item->source() ); } } @@ -147,7 +147,7 @@ SourceTreeView::onItemActivated( const QModelIndex& index ) { qDebug() << "Playlist activated:" << playlist->title(); - APP->playlistManager()->show( playlist ); + PlaylistManager::instance()->show( playlist ); } } } diff --git a/src/tomahawkapp.cpp b/src/tomahawkapp.cpp index 349f90821..ee9dcabd9 100644 --- a/src/tomahawkapp.cpp +++ b/src/tomahawkapp.cpp @@ -21,7 +21,7 @@ #include "scriptresolver.h" #include "sourcelist.h" -#include "audioengine.h" +#include "audio/audioengine.h" #ifndef TOMAHAWK_HEADLESS #include "tomahawkwindow.h" @@ -102,8 +102,6 @@ using namespace Tomahawk; TomahawkApp::TomahawkApp( int& argc, char *argv[] ) : TOMAHAWK_APPLICATION( argc, argv ) , m_audioEngine( 0 ) - , m_nam( 0 ) - , m_proxy( 0 ) , m_infoSystem( 0 ) { qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) ); @@ -141,7 +139,7 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] ) #ifndef NO_LIBLASTFM m_scrobbler = new Scrobbler( this ); - m_nam = new lastfm::NetworkAccessManager( this ); + TomahawkUtils::setNam( new lastfm::NetworkAccessManager( this ) ); connect( m_audioEngine, SIGNAL( started( const Tomahawk::result_ptr& ) ), m_scrobbler, SLOT( trackStarted( const Tomahawk::result_ptr& ) ), Qt::QueuedConnection ); @@ -155,23 +153,22 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] ) connect( m_audioEngine, SIGNAL( stopped() ), m_scrobbler, SLOT( trackStopped() ), Qt::QueuedConnection ); #else - m_nam = new QNetworkAccessManager; + TomahawkUtils::setNam( new QNetworkAccessManager ); #endif // Set up proxy if( TomahawkSettings::instance()->proxyType() != QNetworkProxy::NoProxy && !TomahawkSettings::instance()->proxyHost().isEmpty() ) { qDebug() << "Setting proxy to saved values"; - m_proxy = new QNetworkProxy( static_cast(TomahawkSettings::instance()->proxyType()), TomahawkSettings::instance()->proxyHost(), TomahawkSettings::instance()->proxyPort(), TomahawkSettings::instance()->proxyUsername(), TomahawkSettings::instance()->proxyPassword() ); - qDebug() << "Proxy type =" << QString::number( static_cast(m_proxy->type()) ); - qDebug() << "Proxy host =" << m_proxy->hostName(); - QNetworkAccessManager* nam = TomahawkApp::instance()->nam(); - nam->setProxy( *m_proxy ); + TomahawkUtils::setProxy( new QNetworkProxy( static_cast(TomahawkSettings::instance()->proxyType()), TomahawkSettings::instance()->proxyHost(), TomahawkSettings::instance()->proxyPort(), TomahawkSettings::instance()->proxyUsername(), TomahawkSettings::instance()->proxyPassword() ) ); + qDebug() << "Proxy type =" << QString::number( static_cast(TomahawkUtils::proxy()->type()) ); + qDebug() << "Proxy host =" << TomahawkUtils::proxy()->hostName(); + TomahawkUtils::nam()->setProxy( *TomahawkUtils::proxy() ); } else - m_proxy = new QNetworkProxy( QNetworkProxy::NoProxy ); + TomahawkUtils::setProxy( new QNetworkProxy( QNetworkProxy::NoProxy ) ); - QNetworkProxy::setApplicationProxy( *m_proxy ); + QNetworkProxy::setApplicationProxy( *TomahawkUtils::proxy() ); m_sipHandler = new SipHandler( this ); m_infoSystem = new Tomahawk::InfoSystem::InfoSystem( this ); @@ -230,13 +227,6 @@ TomahawkApp::audioControls() { return m_mainwindow->audioControls(); } - - -PlaylistManager* -TomahawkApp::playlistManager() -{ - return m_mainwindow->playlistManager(); -} #endif diff --git a/src/tomahawktrayicon.cpp b/src/tomahawktrayicon.cpp index 7dfeec69d..f2f92233c 100644 --- a/src/tomahawktrayicon.cpp +++ b/src/tomahawktrayicon.cpp @@ -28,14 +28,14 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent ) m_contextMenu->addSeparator(); m_quitAction = m_contextMenu->addAction( tr( "Quit" ) ); - connect( (QObject*)APP->audioEngine(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( setResult( Tomahawk::result_ptr ) ) ); + connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( setResult( Tomahawk::result_ptr ) ) ); - connect( m_playAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( play() ) ); - connect( m_pauseAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( pause() ) ); - connect( m_stopAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( stop() ) ); - connect( m_prevAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( previous() ) ); - connect( m_nextAction, SIGNAL( triggered() ), (QObject*)APP->audioEngine(), SLOT( next() ) ); - connect( m_quitAction, SIGNAL( triggered() ), (QObject*)APP, SLOT( quit() ) ); + connect( m_playAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( play() ) ); + connect( m_pauseAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( pause() ) ); + connect( m_stopAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( stop() ) ); + connect( m_prevAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) ); + connect( m_nextAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( next() ) ); + connect( m_quitAction, SIGNAL( triggered() ), (QObject*)APP, SLOT( quit() ) ); connect( &m_animationTimer, SIGNAL( timeout() ), SLOT( onAnimationTimer() ) ); connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), SLOT( onActivated( QSystemTrayIcon::ActivationReason ) ) ); @@ -142,11 +142,11 @@ TomahawkTrayIcon::event( QEvent* e ) { if ( ((QWheelEvent*)e)->delta() > 0 ) { - APP->audioEngine()->raiseVolume(); + AudioEngine::instance()->raiseVolume(); } else { - APP->audioEngine()->lowerVolume(); + AudioEngine::instance()->lowerVolume(); } return true; diff --git a/src/tomahawkwindow.cpp b/src/tomahawkwindow.cpp index 2ad525efd..295eeb29b 100644 --- a/src/tomahawkwindow.cpp +++ b/src/tomahawkwindow.cpp @@ -16,26 +16,24 @@ #include "playlist.h" #include "query.h" +#include "audio/audioengine.h" +#include "database/database.h" #include "database/databasecommand_collectionstats.h" -#include "topbar/topbar.h" - +#include "network/controlconnection.h" +#include "playlist/playlistmanager.h" #include "sip/SipHandler.h" - +#include "topbar/topbar.h" +#include "utils/proxystyle.h" +#include "utils/widgetdragfilter.h" #include "widgets/newplaylistwidget.h" #include "widgets/welcomewidget.h" #include "audiocontrols.h" -#include "network/controlconnection.h" -#include "database/database.h" #include "musicscanner.h" -#include "playlistmanager.h" -#include "proxystyle.h" #include "settingsdialog.h" #include "xspfloader.h" -#include "proxystyle.h" #include "tomahawksettings.h" #include "tomahawktrayicon.h" -#include "widgetdragfilter.h" using namespace Tomahawk; @@ -45,7 +43,6 @@ TomahawkWindow::TomahawkWindow( QWidget* parent ) , ui( new Ui::TomahawkWindow ) , m_topbar( new TopBar( this ) ) , m_audioControls( new AudioControls( this ) ) - , m_playlistManager( new PlaylistManager( this ) ) , m_trayIcon( new TomahawkTrayIcon( this ) ) { qApp->setStyle( new ProxyStyle() ); @@ -55,10 +52,12 @@ TomahawkWindow::TomahawkWindow( QWidget* parent ) setUnifiedTitleAndToolBarOnMac( true ); #endif + new PlaylistManager( this ); + ui->setupUi( this ); delete ui->playlistWidget; - ui->splitter->addWidget( m_playlistManager->widget() ); + ui->splitter->addWidget( PlaylistManager::instance()->widget() ); ui->splitter->setStretchFactor( 0, 1 ); ui->splitter->setStretchFactor( 1, 3 ); ui->splitter->setCollapsible( 1, false ); @@ -81,7 +80,7 @@ TomahawkWindow::TomahawkWindow( QWidget* parent ) loadSettings(); setupSignals(); - m_playlistManager->show( new WelcomeWidget() ); + PlaylistManager::instance()->show( new WelcomeWidget() ); } @@ -118,45 +117,45 @@ TomahawkWindow::setupSignals() { // connect( m_topbar, SIGNAL( filterTextChanged( const QString& ) ), - playlistManager(), SLOT( setFilter( const QString& ) ) ); + PlaylistManager::instance(), SLOT( setFilter( const QString& ) ) ); - connect( playlistManager(), SIGNAL( numSourcesChanged( unsigned int ) ), + connect( PlaylistManager::instance(), SIGNAL( numSourcesChanged( unsigned int ) ), m_topbar, SLOT( setNumSources( unsigned int ) ) ); - connect( playlistManager(), SIGNAL( numTracksChanged( unsigned int ) ), + connect( PlaylistManager::instance(), SIGNAL( numTracksChanged( unsigned int ) ), m_topbar, SLOT( setNumTracks( unsigned int ) ) ); - connect( playlistManager(), SIGNAL( numArtistsChanged( unsigned int ) ), + connect( PlaylistManager::instance(), SIGNAL( numArtistsChanged( unsigned int ) ), m_topbar, SLOT( setNumArtists( unsigned int ) ) ); - connect( playlistManager(), SIGNAL( numShownChanged( unsigned int ) ), + connect( PlaylistManager::instance(), SIGNAL( numShownChanged( unsigned int ) ), m_topbar, SLOT( setNumShown( unsigned int ) ) ); connect( m_topbar, SIGNAL( flatMode() ), - playlistManager(), SLOT( setTableMode() ) ); + PlaylistManager::instance(), SLOT( setTableMode() ) ); connect( m_topbar, SIGNAL( artistMode() ), - playlistManager(), SLOT( setTreeMode() ) ); + PlaylistManager::instance(), SLOT( setTreeMode() ) ); connect( m_topbar, SIGNAL( albumMode() ), - playlistManager(), SLOT( setAlbumMode() ) ); + PlaylistManager::instance(), SLOT( setAlbumMode() ) ); - connect( playlistManager(), SIGNAL( statsAvailable( bool ) ), + connect( PlaylistManager::instance(), SIGNAL( statsAvailable( bool ) ), m_topbar, SLOT( setStatsVisible( bool ) ) ); - connect( playlistManager(), SIGNAL( modesAvailable( bool ) ), + connect( PlaylistManager::instance(), SIGNAL( modesAvailable( bool ) ), m_topbar, SLOT( setModesVisible( bool ) ) ); // - connect( playlistManager(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ), + connect( PlaylistManager::instance(), SIGNAL( repeatModeChanged( PlaylistInterface::RepeatMode ) ), m_audioControls, SLOT( onRepeatModeChanged( PlaylistInterface::RepeatMode ) ) ); - connect( playlistManager(), SIGNAL( shuffleModeChanged( bool ) ), + connect( PlaylistManager::instance(), SIGNAL( shuffleModeChanged( bool ) ), m_audioControls, SLOT( onShuffleModeChanged( bool ) ) ); // - connect( (QObject*)APP->audioEngine(), SIGNAL( loading( const Tomahawk::result_ptr& ) ), - SLOT( onPlaybackLoading( const Tomahawk::result_ptr& ) ) ); + connect( AudioEngine::instance(), SIGNAL( loading( const Tomahawk::result_ptr& ) ), + SLOT( onPlaybackLoading( const Tomahawk::result_ptr& ) ) ); // connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) ); @@ -212,13 +211,6 @@ TomahawkWindow::closeEvent( QCloseEvent* e ) } -PlaylistManager* -TomahawkWindow::playlistManager() -{ - return m_playlistManager; -} - - void TomahawkWindow::showSettingsDialog() { @@ -325,7 +317,7 @@ TomahawkWindow::createPlaylist() { qDebug() << Q_FUNC_INFO; - playlistManager()->show( new NewPlaylistWidget() ); + PlaylistManager::instance()->show( new NewPlaylistWidget() ); /* bool ok; QString name = QInputDialog::getText( this, "Create New Playlist", "Name:", QLineEdit::Normal, "New Playlist", &ok ); diff --git a/src/tomahawkwindow.h b/src/tomahawkwindow.h index a7291addb..95ea53302 100644 --- a/src/tomahawkwindow.h +++ b/src/tomahawkwindow.h @@ -12,7 +12,6 @@ class QAction; class AudioControls; -class PlaylistManager; class TopBar; class TomahawkTrayIcon; @@ -29,7 +28,6 @@ public: TomahawkWindow( QWidget* parent = 0 ); ~TomahawkWindow(); - PlaylistManager* playlistManager(); AudioControls* audioControls() { return m_audioControls; } QStackedWidget* playlistStack(); @@ -70,7 +68,6 @@ private: Ui::TomahawkWindow* ui; TopBar* m_topbar; AudioControls* m_audioControls; - PlaylistManager* m_playlistManager; TomahawkTrayIcon* m_trayIcon; QNetworkAccessManager m_nam; diff --git a/src/tomahawkwindow.ui b/src/tomahawkwindow.ui index d2b1bbad0..85dbeffbc 100644 --- a/src/tomahawkwindow.ui +++ b/src/tomahawkwindow.ui @@ -170,7 +170,7 @@ AnimatedSplitter QSplitter -
animatedsplitter.h
+
utils/animatedsplitter.h
1
diff --git a/src/topbar/topbar.ui b/src/topbar/topbar.ui index 4a2c6d41c..6d5ee8c7f 100644 --- a/src/topbar/topbar.ui +++ b/src/topbar/topbar.ui @@ -311,7 +311,7 @@ AnimatedCounterLabel QLabel -
animatedcounterlabel.h
+
utils/animatedcounterlabel.h
SearchLineEdit diff --git a/src/utils/tomahawkutils.h b/src/utils/tomahawkutils.h deleted file mode 100644 index 737f56612..000000000 --- a/src/utils/tomahawkutils.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef TOMAHAWKUTILS_H -#define TOMAHAWKUTILS_H - -class QDir; -class QDateTime; -class QString; -class QPixmap; - -namespace TomahawkUtils -{ - QDir appConfigDir(); - QDir appDataDir(); - - QString timeToString( int seconds ); - QString ageToString( const QDateTime& time ); - QString filesizeToString( unsigned int size ); - - QPixmap createDragPixmap( int itemCount = 1 ); -} - -#endif // TOMAHAWKUTILS_H diff --git a/src/xmppbot/xmppbot.cpp b/src/xmppbot/xmppbot.cpp index ca5f8a83c..0745a07e8 100644 --- a/src/xmppbot/xmppbot.cpp +++ b/src/xmppbot/xmppbot.cpp @@ -6,6 +6,7 @@ #include "typedefs.h" #include "tomahawksettings.h" #include "pipeline.h" + #include "audio/audioengine.h" #include @@ -45,7 +46,7 @@ XMPPBot::XMPPBot(QObject *parent) m_client.data()->registerMessageHandler(this); m_client.data()->setPresence(Presence::Available, 1, "Tomahawkbot available"); - connect(TomahawkApp::instance()->audioEngine(), SIGNAL(started(const Tomahawk::result_ptr &)), + connect(AudioEngine::instance(), SIGNAL(started(const Tomahawk::result_ptr &)), SLOT(newTrackSlot(const Tomahawk::result_ptr &))); connect(TomahawkApp::instance()->infoSystem(), @@ -139,7 +140,7 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session) { QStringList tokens = body.right( body.length() - 5 ).split( QString( "-" ), QString::SkipEmptyParts ); if ( tokens.count() < 2 ) - APP->audioEngine()->play(); + AudioEngine::instance()->play(); QVariantMap qv; qv["artist"] = tokens.first().trimmed(); @@ -153,22 +154,22 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session) } else if ( body.startsWith( "stop" ) ) { - APP->audioEngine()->stop(); + AudioEngine::instance()->stop(); return; } else if ( body.startsWith( "prev" ) ) { - APP->audioEngine()->previous(); + AudioEngine::instance()->previous(); return; } else if ( body.startsWith( "next" ) ) { - APP->audioEngine()->next(); + AudioEngine::instance()->next(); return; } else if ( body.startsWith( "pause" ) ) { - APP->audioEngine()->pause(); + AudioEngine::instance()->pause(); return; } @@ -398,7 +399,7 @@ void XMPPBot::infoFinishedSlot(QString caller) void XMPPBot::onResultsAdded( const QList& result ) { - APP->audioEngine()->playItem( 0, result.first() ); + AudioEngine::instance()->playItem( 0, result.first() ); } /////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/xspfloader.cpp b/src/xspfloader.cpp index 3ae71a03e..04194a636 100644 --- a/src/xspfloader.cpp +++ b/src/xspfloader.cpp @@ -14,7 +14,7 @@ void XSPFLoader::load( const QUrl& url ) { QNetworkRequest request( url ); - QNetworkReply* reply = APP->nam()->get( request ); + QNetworkReply* reply = TomahawkUtils::nam()->get( request ); // isn't there a race condition here? something could happen before we connect() connect( reply, SIGNAL( finished() ),