From f216a0fe82227ab74c45bb3eecabd21c0b471011 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt <dev@dominik-schmidt.de> Date: Fri, 11 Nov 2011 03:43:42 +0100 Subject: [PATCH] Do some work towards tomahawk headless --- src/libtomahawk/CMakeLists.txt | 54 ++++++++++++-------- src/libtomahawk/globalactionmanager.cpp | 19 ++++--- src/libtomahawk/playlistinterface.h | 1 - src/libtomahawk/resolver.cpp | 13 +++-- src/libtomahawk/resolvers/qtscriptresolver.h | 1 - src/libtomahawk/sip/SipHandler.h | 6 ++- src/libtomahawk/sip/SipPlugin.h | 14 ++++- src/libtomahawk/tomahawksettings.cpp | 12 +++-- src/libtomahawk/tomahawksettings.h | 15 ++++-- src/libtomahawk/utils/tomahawkutils.h | 5 +- 10 files changed, 94 insertions(+), 46 deletions(-) diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index d1dc0661a..2bde15e72 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -12,6 +12,29 @@ add_definitions( ${QT_DEFINITIONS} ) add_definitions( -DQT_SHARED ) add_definitions( -DDLLEXPORT_PRO ) +set( libGuiHeaders + viewpage.h + viewmanager.h + + playlist/topbar/topbar.h + playlist/topbar/clearbutton.h + playlist/topbar/searchlineedit.h + playlist/topbar/lineedit.h + playlist/topbar/lineedit_p.h + playlist/topbar/searchbutton.h +) + +set( libGuiSources + viewpage.cpp + viewmanager.cpp + + playlist/topbar/topbar.cpp + playlist/topbar/clearbutton.cpp + playlist/topbar/searchlineedit.cpp + playlist/topbar/lineedit.cpp + playlist/topbar/searchbutton.cpp +) + set( libSources tomahawksettings.cpp sourcelist.cpp @@ -28,8 +51,6 @@ set( libSources result.cpp source.cpp sourceplaylistinterface.cpp - viewpage.cpp - viewmanager.cpp globalactionmanager.cpp contextmenu.cpp dropjob.cpp @@ -148,11 +169,6 @@ set( libSources playlist/PlaylistUpdaterInterface.cpp playlist/XspfUpdater.cpp - playlist/topbar/topbar.cpp - playlist/topbar/clearbutton.cpp - playlist/topbar/searchlineedit.cpp - playlist/topbar/lineedit.cpp - playlist/topbar/searchbutton.cpp playlist/dynamic/DynamicPlaylist.cpp playlist/dynamic/DynamicControl.cpp @@ -256,11 +272,9 @@ set( libHeaders result.h source.h sourceplaylistinterface.h - viewmanager.h globalactionmanager.h contextmenu.h dropjob.h - AtticaManager.h LatchManager.h artist.h @@ -388,13 +402,6 @@ set( libHeaders playlist/PlaylistUpdaterInterface.h playlist/XspfUpdater.h - playlist/topbar/topbar.h - playlist/topbar/clearbutton.h - playlist/topbar/searchlineedit.h - playlist/topbar/lineedit.h - playlist/topbar/lineedit_p.h - playlist/topbar/searchbutton.h - playlist/dynamic/DynamicPlaylist.h playlist/dynamic/DynamicControl.h playlist/dynamic/GeneratorInterface.h @@ -469,8 +476,6 @@ set( libHeaders ) set( libHeaders_NoMOC - viewpage.h - infosystem/infoplugins/unix/imageconverter.h playlist/dynamic/GeneratorInterface.h @@ -517,8 +522,8 @@ IF(QCA2_FOUND) ENDIF(QCA2_FOUND) IF(LIBATTICA_FOUND) - SET( libSources ${libSources} AtticaManager.cpp ) - SET( libHeaders ${libHeaders} AtticaManager.h ) + SET( libGuiSources ${libGuiSources} AtticaManager.cpp ) + SET( libGuiHeaders ${libGuiHeaders} AtticaManager.h ) INCLUDE_DIRECTORIES( ${LIBATTICA_INCLUDE_DIR} ) ENDIF(LIBATTICA_FOUND) @@ -591,12 +596,17 @@ IF(LIBLASTFM_FOUND) SET(LINK_LIBRARIES ${LINK_LIBRARIES} tomahawk_lastfm2 ) ENDIF(LIBLASTFM_FOUND) +IF(BUILD_GUI) + LIST(APPEND libSources ${libGuiSources} ) + LIST(APPEND libHeaders ${libGuiHeaders} ) +ENDIF() + qt4_wrap_ui( libUI_H ${libUI} ) -qt4_wrap_cpp( libMoc ${libHeaders} ) +qt4_wrap_cpp( libMoc ${libHeaders} ${libGuiHeaders} ) SET( libSources ${libSources} ${libUI_H} ${libHeaders_NoMOC} ) -ADD_LIBRARY( tomahawklib SHARED ${libSources} ${libMoc} ) +ADD_LIBRARY( tomahawklib SHARED ${libGuiSources} ${libSources} ${libMoc} ) IF(QCA2_FOUND) SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${QCA2_LIBRARIES} ) diff --git a/src/libtomahawk/globalactionmanager.cpp b/src/libtomahawk/globalactionmanager.cpp index b0bbe57fd..33723a0dd 100644 --- a/src/libtomahawk/globalactionmanager.cpp +++ b/src/libtomahawk/globalactionmanager.cpp @@ -18,8 +18,10 @@ #include "globalactionmanager.h" -#include <QApplication> -#include <QClipboard> +#ifndef ENABLE_HEADLESS + #include <QClipboard> +#endif + #include <QMimeData> #include <QUrl> #include <QtNetwork/QNetworkAccessManager> @@ -31,13 +33,10 @@ #include "album.h" #include "sourcelist.h" #include "pipeline.h" -#include "viewmanager.h" #include "tomahawksettings.h" #include "audio/audioengine.h" #include "database/localcollection.h" #include "playlist/dynamic/GeneratorInterface.h" -#include "playlist/topbar/topbar.h" -#include "playlist/playlistview.h" #include "echonest/Playlist.h" @@ -50,7 +49,15 @@ #include "utils/spotifyparser.h" #include "utils/shortenedlinkparser.h" #include "utils/rdioparser.h" -#include "widgets/searchwidget.h" + +#ifndef ENABLE_HEADLESS + #include <QApplication> + #include "widgets/searchwidget.h" + #include "viewmanager.h" + #include "playlist/topbar/topbar.h" + #include "playlist/playlistview.h" + +#endif GlobalActionManager* GlobalActionManager::s_instance = 0; diff --git a/src/libtomahawk/playlistinterface.h b/src/libtomahawk/playlistinterface.h index 71d034caf..266e10e7e 100644 --- a/src/libtomahawk/playlistinterface.h +++ b/src/libtomahawk/playlistinterface.h @@ -20,7 +20,6 @@ #define PLAYLISTINTERFACE_H #include <QModelIndex> -#include <QWidget> #include "typedefs.h" #include "dllmacro.h" diff --git a/src/libtomahawk/resolver.cpp b/src/libtomahawk/resolver.cpp index 2a21ad755..55eb02a76 100644 --- a/src/libtomahawk/resolver.cpp +++ b/src/libtomahawk/resolver.cpp @@ -18,21 +18,26 @@ #include "resolver.h" -#include <QWidget> -#include <QtUiTools/QUiLoader> + #include <QMetaProperty> #include <QBuffer> #include <QDir> -#include <QIcon> #include "utils/logger.h" +#ifndef ENABLE_HEADLESS + #include <QIcon> + #include <QWidget> +#endif +#include <QUiLoader> + Tomahawk::ExternalResolver::ErrorState Tomahawk::ExternalResolver::error() const { return NoError; } +#ifndef ENABLE_HEADLESS QVariant Tomahawk::ExternalResolver::configMsgFromWidget( QWidget* w ) { @@ -45,7 +50,7 @@ Tomahawk::ExternalResolver::configMsgFromWidget( QWidget* w ) // qDebug() << "Generated widget variant:" << widgetMap; return widgetMap; } - +#endif void Tomahawk::ExternalResolver::addChildProperties( QObject* widget, QVariantMap& m ) diff --git a/src/libtomahawk/resolvers/qtscriptresolver.h b/src/libtomahawk/resolvers/qtscriptresolver.h index 673b648ee..889bef3c1 100644 --- a/src/libtomahawk/resolvers/qtscriptresolver.h +++ b/src/libtomahawk/resolvers/qtscriptresolver.h @@ -24,7 +24,6 @@ #include "utils/tomahawkutils.h" #include "config.h" -#include <QApplication> #include <QDir> #include <QFile> #include <QThread> diff --git a/src/libtomahawk/sip/SipHandler.h b/src/libtomahawk/sip/SipHandler.h index 8eed7f3a2..f22d5784a 100644 --- a/src/libtomahawk/sip/SipHandler.h +++ b/src/libtomahawk/sip/SipHandler.h @@ -24,9 +24,13 @@ #include <QObject> #include <QHash> -#include <QPixmap> #include <QString> +#ifndef ENABLE_HEADLESS + #include <QPixmap> +#endif + + class DLLEXPORT SipHandler : public QObject { Q_OBJECT diff --git a/src/libtomahawk/sip/SipPlugin.h b/src/libtomahawk/sip/SipPlugin.h index 1830a9ea5..1ac38edc3 100644 --- a/src/libtomahawk/sip/SipPlugin.h +++ b/src/libtomahawk/sip/SipPlugin.h @@ -24,9 +24,12 @@ #include <QObject> #include <QString> -#include <QMenu> #include <QNetworkProxy> +#ifndef ENABLE_HEADLESS + #include <QMenu> +#endif + #include "dllmacro.h" class SipPlugin; @@ -42,8 +45,12 @@ public: virtual QString prettyName() const = 0; // internal name virtual QString factoryId() const = 0; + +#ifndef ENABLE_HEADLESS // if the user can create multiple virtual QIcon icon() const { return QIcon(); } +#endif + virtual bool isUnique() const { return false; } virtual SipPlugin* createPlugin( const QString& pluginId = QString() ) = 0; @@ -73,8 +80,10 @@ public: virtual const QString accountName() const = 0; virtual ConnectionState connectionState() const = 0; virtual QString errorMessage() const; +#ifndef ENABLE_HEADLESS virtual QMenu* menu(); virtual QWidget* configWidget(); +#endif virtual void saveConfig() {} // called when the widget has been edited virtual QIcon icon() const; @@ -110,9 +119,10 @@ signals: // new data for other sources; void avatarReceived ( const QString& from, const QPixmap& avatar); - +#ifndef ENABLE_HEADLESS void addMenu( QMenu* menu ); void removeMenu( QMenu* menu ); +#endif void dataError( bool ); diff --git a/src/libtomahawk/tomahawksettings.cpp b/src/libtomahawk/tomahawksettings.cpp index 4590d6d2b..d80ea268e 100644 --- a/src/libtomahawk/tomahawksettings.cpp +++ b/src/libtomahawk/tomahawksettings.cpp @@ -18,7 +18,7 @@ #include "tomahawksettings.h" -#ifndef TOMAHAWK_HEADLESS +#ifndef ENABLE_HEADLESS #include <QDesktopServices> #include "settingsdialog.h" #endif @@ -37,7 +37,7 @@ using namespace Tomahawk; TomahawkSettings* TomahawkSettings::s_instance = 0; - +#ifndef ENABLE_HEADLESS inline QDataStream& operator<<(QDataStream& out, const AtticaManager::StateHash& states) { out << VERSION; @@ -69,6 +69,7 @@ inline QDataStream& operator>>(QDataStream& in, AtticaManager::StateHash& states } return in; } +#endif TomahawkSettings* TomahawkSettings::instance() @@ -104,8 +105,11 @@ TomahawkSettings::TomahawkSettings( QObject* parent ) setValue( "configversion", VERSION ); } +#ifndef ENABLE_HEADLESS qRegisterMetaType< AtticaManager::StateHash >( "AtticaManager::StateHash" ); qRegisterMetaTypeStreamOperators<AtticaManager::StateHash>("AtticaManager::StateHash"); +#endif + } @@ -257,7 +261,7 @@ TomahawkSettings::scannerPaths() { QString musicLocation; -#ifndef TOMAHAWK_HEADLESS +#ifndef ENABLE_HEADLESS musicLocation = QDesktopServices::storageLocation( QDesktopServices::MusicLocation ); #endif @@ -905,6 +909,7 @@ TomahawkSettings::setEnabledScriptResolvers( const QStringList& resolvers ) setValue( "script/loadedresolvers", resolvers ); } +#ifndef ENABLE_HEADLESS void TomahawkSettings::setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state ) { @@ -937,6 +942,7 @@ TomahawkSettings::removeAtticaResolverState ( const QString& resolver ) resolvers.remove( resolver ); setValue( "script/atticaresolverstates", QVariant::fromValue< AtticaManager::StateHash >( resolvers ) ); } +#endif QString TomahawkSettings::scriptDefaultPath() const diff --git a/src/libtomahawk/tomahawksettings.h b/src/libtomahawk/tomahawksettings.h index 5b83a7f9a..9ce0b2a5a 100644 --- a/src/libtomahawk/tomahawksettings.h +++ b/src/libtomahawk/tomahawksettings.h @@ -19,15 +19,16 @@ #ifndef TOMAHAWK_SETTINGS_H #define TOMAHAWK_SETTINGS_H -#include <QSettings> +#ifndef ENABLE_HEADLESS + #include "AtticaManager.h" +#endif -#include "dllmacro.h" - -#include "AtticaManager.h" #include "playlist.h" +#include <QSettings> #include <QtNetwork/QNetworkProxy> +#include "dllmacro.h" /** * Convenience wrapper around QSettings for tomahawk-specific config */ @@ -187,11 +188,13 @@ public: QStringList enabledScriptResolvers() const; void setEnabledScriptResolvers( const QStringList& resolvers ); +#ifndef ENABLE_HEADLESS AtticaManager::StateHash atticaResolverStates() const; void setAtticaResolverStates( const AtticaManager::StateHash states ); void setAtticaResolverState( const QString& resolver, AtticaManager::ResolverState state ); void removeAtticaResolverState( const QString& resolver ); +#endif QString scriptDefaultPath() const; void setScriptDefaultPath( const QString& path ); @@ -211,7 +214,7 @@ public: }; PrivateListeningMode privateListeningMode() const; void setPrivateListeningMode( PrivateListeningMode mode ); - + signals: void changed(); void recentlyPlayedPlaylistAdded( const Tomahawk::playlist_ptr& playlist ); @@ -223,6 +226,8 @@ private: static TomahawkSettings* s_instance; }; +#ifndef ENABLE_HEADLESS Q_DECLARE_METATYPE(AtticaManager::StateHash); +#endif #endif diff --git a/src/libtomahawk/utils/tomahawkutils.h b/src/libtomahawk/utils/tomahawkutils.h index b45dcb56e..2f25aad34 100644 --- a/src/libtomahawk/utils/tomahawkutils.h +++ b/src/libtomahawk/utils/tomahawkutils.h @@ -26,7 +26,10 @@ #include <QtNetwork/QNetworkProxy> #include <QtCore/QStringList> #include <QtCore/QRect> -#include <QPalette> + +#ifndef ENABLE_HEADLESS + #include <QPalette> +#endif #define RESPATH ":/data/"