From b03563f3178059844a982c7dd908c6b099339f53 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sun, 27 May 2012 21:15:58 +0100 Subject: [PATCH] Make it possible to compile out moodbar support --- src/CMakeLists.txt | 30 +++++++++++++++++------------- src/core/application.cpp | 11 +++++++++-- src/playlist/playlistheader.cpp | 6 ++++++ src/playlist/playlistview.cpp | 16 ++++++++++++++-- src/ui/mainwindow.cpp | 9 +++++++-- src/widgets/trackslider.cpp | 9 ++++++++- 6 files changed, 61 insertions(+), 20 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0aebe4aa5..6eac41b84 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -198,13 +198,6 @@ set(SOURCES library/librarywatcher.cpp library/sqlrow.cpp - moodbar/moodbarcontroller.cpp - moodbar/moodbaritemdelegate.cpp - moodbar/moodbarloader.cpp - moodbar/moodbarpipeline.cpp - moodbar/moodbarproxystyle.cpp - moodbar/moodbarrenderer.cpp - musicbrainz/acoustidclient.cpp musicbrainz/chromaprinter.cpp musicbrainz/musicbrainzclient.cpp @@ -466,12 +459,6 @@ set(HEADERS library/libraryviewcontainer.h library/librarywatcher.h - moodbar/moodbarcontroller.h - moodbar/moodbaritemdelegate.h - moodbar/moodbarloader.h - moodbar/moodbarpipeline.h - moodbar/moodbarproxystyle.h - musicbrainz/acoustidclient.h musicbrainz/musicbrainzclient.h musicbrainz/tagfetcher.h @@ -991,6 +978,23 @@ optional_source(HAVE_SAC devices/wmdmloader.h ) +# Moodbar support +optional_source(HAVE_MOODBAR + SOURCES + moodbar/moodbarcontroller.cpp + moodbar/moodbaritemdelegate.cpp + moodbar/moodbarloader.cpp + moodbar/moodbarpipeline.cpp + moodbar/moodbarproxystyle.cpp + moodbar/moodbarrenderer.cpp + HEADERS + moodbar/moodbarcontroller.h + moodbar/moodbaritemdelegate.h + moodbar/moodbarloader.h + moodbar/moodbarpipeline.h + moodbar/moodbarproxystyle.h +) + # Hack to add Clementine to the Unity system tray whitelist optional_source(LINUX SOURCES core/ubuntuunityhack.cpp diff --git a/src/core/application.cpp b/src/core/application.cpp index d0987a3ad..92ef2d36b 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -17,6 +17,7 @@ #include "application.h" #include "appearance.h" +#include "config.h" #include "database.h" #include "player.h" #include "tagreaderclient.h" @@ -29,8 +30,6 @@ #include "globalsearch/globalsearch.h" #include "library/library.h" #include "library/librarybackend.h" -#include "moodbar/moodbarcontroller.h" -#include "moodbar/moodbarloader.h" #include "playlist/playlistbackend.h" #include "playlist/playlistmanager.h" #include "podcasts/gpoddersync.h" @@ -38,6 +37,11 @@ #include "podcasts/podcastdownloader.h" #include "podcasts/podcastupdater.h" +#ifdef HAVE_MOODBAR +# include "moodbar/moodbarcontroller.h" +# include "moodbar/moodbarloader.h" +#endif + Application::Application(QObject* parent) : QObject(parent), tag_reader_client_(NULL), @@ -90,8 +94,11 @@ Application::Application(QObject* parent) podcast_updater_ = new PodcastUpdater(this, this); podcast_downloader_ = new PodcastDownloader(this, this); gpodder_sync_ = new GPodderSync(this, this); + +#ifdef HAVE_MOODBAR moodbar_loader_ = new MoodbarLoader(this); moodbar_controller_ = new MoodbarController(this, this); +#endif library_->Init(); library_->StartThreads(); diff --git a/src/playlist/playlistheader.cpp b/src/playlist/playlistheader.cpp index b25aa542c..49d24c244 100644 --- a/src/playlist/playlistheader.cpp +++ b/src/playlist/playlistheader.cpp @@ -85,6 +85,12 @@ void PlaylistHeader::contextMenuEvent(QContextMenuEvent* e) { } void PlaylistHeader::AddColumnAction(int index) { +#ifndef HAVE_MOODBAR + if (index == Playlist::Column_Mood) { + return; + } +#endif + QString title(model()->headerData(index, Qt::Horizontal).toString()); QAction* action = menu_->addAction(title, show_mapper_, SLOT(map())); diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index ff9ddce16..db3b320a1 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -15,6 +15,7 @@ along with Clementine. If not, see . */ +#include "config.h" #include "dynamicplaylistcontrols.h" #include "playlist.h" #include "playlistdelegates.h" @@ -24,7 +25,6 @@ #include "core/logging.h" #include "core/player.h" #include "covers/currentartloader.h" -#include "moodbar/moodbaritemdelegate.h" #include #include @@ -41,7 +41,11 @@ #include -const int PlaylistView::kStateVersion = 4; +#ifdef HAVE_MOODBAR +# include "moodbar/moodbaritemdelegate.h" +#endif + +const int PlaylistView::kStateVersion = 5; const int PlaylistView::kGlowIntensitySteps = 24; const int PlaylistView::kAutoscrollGraceTimeout = 60; // seconds const int PlaylistView::kDropIndicatorWidth = 2; @@ -199,7 +203,10 @@ void PlaylistView::SetItemDelegates(LibraryBackend* backend) { setItemDelegateForColumn(Playlist::Column_Filename, new NativeSeparatorsDelegate(this)); setItemDelegateForColumn(Playlist::Column_Rating, rating_delegate_); setItemDelegateForColumn(Playlist::Column_LastPlayed, new LastPlayedItemDelegate(this)); + +#ifdef HAVE_MOODBAR setItemDelegateForColumn(Playlist::Column_Mood, new MoodbarItemDelegate(app_, this)); +#endif if (app_ && app_->player()) { setItemDelegateForColumn(Playlist::Column_Source, new SongSourceDelegate(this, app_->player())); @@ -308,6 +315,11 @@ void PlaylistView::LoadGeometry() { if (state_version < 3) { header_->HideSection(Playlist::Column_Comment); } + if (state_version < 5) { +#ifndef HAVE_MOODBAR + header_->HideSection(Playlist::Column_Mood); +#endif + } // Make sure at least one column is visible bool all_hidden = true; diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index e2d3909fa..d59638dbc 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -55,8 +55,6 @@ #include "library/librarydirectorymodel.h" #include "library/libraryfilterwidget.h" #include "library/libraryviewcontainer.h" -#include "moodbar/moodbarcontroller.h" -#include "moodbar/moodbarproxystyle.h" #include "musicbrainz/tagfetcher.h" #include "playlist/playlistbackend.h" #include "playlist/playlist.h" @@ -110,6 +108,11 @@ # include "visualisations/visualisationcontainer.h" #endif +#ifdef HAVE_MOODBAR +# include "moodbar/moodbarcontroller.h" +# include "moodbar/moodbarproxystyle.h" +#endif + #include #include #include @@ -618,9 +621,11 @@ MainWindow::MainWindow(Application* app, ui_->status_bar_stack->setCurrentWidget(ui_->playlist_summary_page); connect(ui_->multi_loading_indicator, SIGNAL(TaskCountChange(int)), SLOT(TaskCountChanged(int))); +#ifdef HAVE_MOODBAR // Moodbar connections connect(app_->moodbar_controller(), SIGNAL(CurrentMoodbarDataChanged(QByteArray)), ui_->track_slider->moodbar_style(), SLOT(SetMoodbarData(QByteArray))); +#endif // Now playing widget qLog(Debug) << "Creating now playing widget"; diff --git a/src/widgets/trackslider.cpp b/src/widgets/trackslider.cpp index 318fd2415..2c3bc0e20 100644 --- a/src/widgets/trackslider.cpp +++ b/src/widgets/trackslider.cpp @@ -15,13 +15,17 @@ along with Clementine. If not, see . */ +#include "config.h" #include "trackslider.h" #include "ui_trackslider.h" #include "core/utilities.h" -#include "moodbar/moodbarproxystyle.h" #include +#ifdef HAVE_MOODBAR +# include "moodbar/moodbarproxystyle.h" +#endif + const char* TrackSlider::kSettingsGroup = "MainWindow"; TrackSlider::TrackSlider(QWidget* parent) @@ -33,7 +37,10 @@ TrackSlider::TrackSlider(QWidget* parent) slider_maximum_value_(0) { ui_->setupUi(this); + +#ifdef HAVE_MOODBAR moodbar_style_ = new MoodbarProxyStyle(ui_->slider); +#endif QFont font("Courier"); ui_->elapsed->setFont(font);