diff --git a/CMakeLists.txt b/CMakeLists.txt index f7208c190..bd40eebce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,7 @@ SET( CANTATA_SRCS gui/preferencesdialog.cpp gui/settings.cpp gui/covers.cpp + gui/filesettings.cpp gui/interfacesettings.cpp gui/playbacksettings.cpp gui/serverplaybacksettings.cpp @@ -165,6 +166,7 @@ SET( CANTATA_MOC_HDRS gui/serverplaybacksettings.h gui/serversettings.h gui/preferencesdialog.h + gui/filesettings.h gui/interfacesettings.h gui/cachesettings.h gui/trayitem.h @@ -224,6 +226,7 @@ SET( CANTATA_UIS gui/librarypage.ui gui/albumspage.ui gui/playlistspage.ui + gui/filesettings.ui gui/interfacesettings.ui gui/playbacksettings.ui gui/serverplaybacksettings.ui diff --git a/ChangeLog b/ChangeLog index 01d96e216..b2a2d6d51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -64,6 +64,7 @@ 37. Scale image in lyrics view if it is less than 300x300px 38. Allow to move streams to different categories via drag-n-drop. 39. Read/write device cache files in non-gui thread. +40. Add option to save streams in mpd folder. 0.9.2 ----- diff --git a/gui/filesettings.cpp b/gui/filesettings.cpp new file mode 100644 index 000000000..d750cf8ac --- /dev/null +++ b/gui/filesettings.cpp @@ -0,0 +1,53 @@ +/* + * Cantata + * + * Copyright (c) 2011-2013 Craig Drummond + * + * ---- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "filesettings.h" +#include "settings.h" +#include "onoffbutton.h" + +FileSettings::FileSettings(QWidget *p) + : QWidget(p) +{ + setupUi(this); +} + +void FileSettings::load() +{ + storeCoversInMpdDir->setChecked(Settings::self()->storeCoversInMpdDir()); + storeLyricsInMpdDir->setChecked(Settings::self()->storeLyricsInMpdDir()); + storeStreamsInMpdDir->setChecked(Settings::self()->storeStreamsInMpdDir()); +} + +void FileSettings::save() +{ + // TODO: Move streams? + bool streamsWereInMpd=Settings::self()->storeStreamsInMpdDir(); + bool streamsChaged=streamsWereInMpd!=storeStreamsInMpdDir->isChecked(); + Settings::self()->saveStoreCoversInMpdDir(storeCoversInMpdDir->isChecked()); + Settings::self()->saveStoreLyricsInMpdDir(storeLyricsInMpdDir->isChecked()); + Settings::self()->saveStoreStreamsInMpdDir(storeStreamsInMpdDir->isChecked()); + + if (streamsChaged) { + emit reloadStreams(); + } +} diff --git a/gui/filesettings.h b/gui/filesettings.h new file mode 100644 index 000000000..bee09173b --- /dev/null +++ b/gui/filesettings.h @@ -0,0 +1,44 @@ +/* + * Cantata + * + * Copyright (c) 2011-2013 Craig Drummond + * + * ---- + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef FILESETTINGS_H +#define FILESETTINGS_H + +#include "ui_filesettings.h" + +class FileSettings : public QWidget, private Ui::FileSettings +{ + Q_OBJECT + +public: + FileSettings(QWidget *p); + virtual ~FileSettings() { } + + void load(); + void save(); + +Q_SIGNALS: + void reloadStreams(); +}; + +#endif diff --git a/gui/filesettings.ui b/gui/filesettings.ui new file mode 100644 index 000000000..557d3a959 --- /dev/null +++ b/gui/filesettings.ui @@ -0,0 +1,122 @@ + + + FileSettings + + + + 0 + 0 + 400 + 300 + + + + Form + + + + 0 + + + + + + + Save downloaded covers in music folder: + + + storeCoversInMpdDir + + + + + + + + + + Save downloaded lyrics in music folder: + + + storeLyricsInMpdDir + + + + + + + + + + + + + + Save list of streams in music folder: + + + storeStreamsInMpdDir + + + + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + + + + + + 0 + 0 + + + + <i><b>NOTE:</b> If you enable one of the above options, amd Cantata cannot access the music folder, then the files will be written as if the option was disabled. i.e. covers and lyrics will be stored in your cache folder, and streams will be saved in your config folder.</i> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + BuddyLabel + QLabel +
buddylabel.h
+
+ + OnOffButton + QCheckBox +
onoffbutton.h
+
+
+ + +
diff --git a/gui/httpserversettings.cpp b/gui/httpserversettings.cpp index 9cff260ff..dc387b02d 100644 --- a/gui/httpserversettings.cpp +++ b/gui/httpserversettings.cpp @@ -28,7 +28,7 @@ HttpServerSettings::HttpServerSettings(QWidget *p) : QWidget(p) { setupUi(this); -}; +} void HttpServerSettings::load() { diff --git a/gui/interfacesettings.cpp b/gui/interfacesettings.cpp index 99abc6f71..30fd0d12a 100644 --- a/gui/interfacesettings.cpp +++ b/gui/interfacesettings.cpp @@ -103,7 +103,7 @@ InterfaceSettings::InterfaceSettings(QWidget *p) #endif connect(systemTrayCheckBox, SIGNAL(toggled(bool)), minimiseOnClose, SLOT(setEnabled(bool))); connect(systemTrayCheckBox, SIGNAL(toggled(bool)), minimiseOnCloseLabel, SLOT(setEnabled(bool))); -}; +} void InterfaceSettings::load() { @@ -129,8 +129,6 @@ void InterfaceSettings::load() playQueueAutoExpand->setChecked(Settings::self()->playQueueAutoExpand()); playQueueStartClosed->setChecked(Settings::self()->playQueueStartClosed()); playQueueScroll->setChecked(Settings::self()->playQueueScroll()); - storeCoversInMpdDir->setChecked(Settings::self()->storeCoversInMpdDir()); - storeLyricsInMpdDir->setChecked(Settings::self()->storeLyricsInMpdDir()); albumsViewChanged(); albumsCoverSizeChanged(); playListsStyleChanged(); @@ -171,8 +169,6 @@ void InterfaceSettings::save() Settings::self()->savePlayQueueAutoExpand(playQueueAutoExpand->isChecked()); Settings::self()->savePlayQueueStartClosed(playQueueStartClosed->isChecked()); Settings::self()->savePlayQueueScroll(playQueueScroll->isChecked()); - Settings::self()->saveStoreCoversInMpdDir(storeCoversInMpdDir->isChecked()); - Settings::self()->saveStoreLyricsInMpdDir(storeLyricsInMpdDir->isChecked()); Settings::self()->saveLyricsBgnd(lyricsBgnd->isChecked()); Settings::self()->saveForceSingleClick(forceSingleClick->isChecked()); Settings::self()->saveUseSystemTray(systemTrayCheckBox->isChecked()); diff --git a/gui/interfacesettings.ui b/gui/interfacesettings.ui index 91a9d7cc1..4f5503e12 100644 --- a/gui/interfacesettings.ui +++ b/gui/interfacesettings.ui @@ -6,7 +6,7 @@ 0 0 - 495 + 482 341 @@ -535,36 +535,6 @@ within the folder of the current track, or within its parent folder. If no image - - - Save downloaded covers in music folder: - - - storeCoversInMpdDir - - - - - - - - - - Save downloaded lyrics in music folder: - - - storeLyricsInMpdDir - - - - - - - - - - - Enforce single-click activation of items: @@ -574,7 +544,7 @@ within the folder of the current track, or within its parent folder. If no image - + @@ -662,8 +632,6 @@ within the folder of the current track, or within its parent folder. If no image groupSingle groupMultiple showDeleteAction - storeCoversInMpdDir - storeLyricsInMpdDir forceSingleClick diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 0d8bfbe61..2915f099b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1200,6 +1200,7 @@ void MainWindow::showPreferencesDialog() PreferencesDialog pref(this, lyricsPage); connect(&pref, SIGNAL(settingsSaved()), this, SLOT(updateSettings())); connect(&pref, SIGNAL(connectTo(const MPDConnectionDetails &)), this, SLOT(connectToMpd(const MPDConnectionDetails &))); + connect(&pref, SIGNAL(reloadStreams()), streamsPage, SLOT(refresh())); pref.exec(); updateConnectionsMenu(); diff --git a/gui/playbacksettings.cpp b/gui/playbacksettings.cpp index b5375f568..df290966c 100644 --- a/gui/playbacksettings.cpp +++ b/gui/playbacksettings.cpp @@ -33,7 +33,7 @@ PlaybackSettings::PlaybackSettings(QWidget *p) stopFadeDuration->setSuffix(i18n(" ms")); stopFadeDuration->setRange(Settings::MinFade, Settings::MaxFade); stopFadeDuration->setSingleStep(100); -}; +} void PlaybackSettings::load() { diff --git a/gui/preferencesdialog.cpp b/gui/preferencesdialog.cpp index 14eb5451b..b510220b6 100644 --- a/gui/preferencesdialog.cpp +++ b/gui/preferencesdialog.cpp @@ -29,6 +29,7 @@ #include "serversettings.h" #include "serverplaybacksettings.h" #include "playbacksettings.h" +#include "filesettings.h" #ifdef TAGLIB_FOUND #include "httpserversettings.h" #endif @@ -53,6 +54,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, LyricsPage *lp) server = new ServerSettings(widget); serverplayback = new ServerPlaybackSettings(widget); playback = new PlaybackSettings(widget); + files = new FileSettings(widget); interface = new InterfaceSettings(widget); #ifdef TAGLIB_FOUND http = new HttpServerSettings(widget); @@ -62,6 +64,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, LyricsPage *lp) server->load(); serverplayback->load(); playback->load(); + files->load(); interface->load(); #ifdef TAGLIB_FOUND http->load(); @@ -71,6 +74,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, LyricsPage *lp) widget->addPage(server, i18n("Connection"), Icons::libraryIcon, i18n("Connection Settings")); widget->addPage(serverplayback, i18n("Output"), Icons::speakerIcon, i18n("Output Settings")); widget->addPage(playback, i18n("Playback"), Icon("media-playback-start"), i18n("Playback Settings")); + widget->addPage(files, i18n("Files"), Icon("audio-x-generic"), i18n("File Settings")); widget->addPage(interface, i18n("Interface"), Icon("preferences-other"), i18n("Interface Settings")); #ifdef TAGLIB_FOUND widget->addPage(http, i18n("HTTP Server"), Icon("network-server"), i18n("HTTP Server Settings")); @@ -92,6 +96,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, LyricsPage *lp) setMainWidget(widget); connect(server, SIGNAL(connectTo(const MPDConnectionDetails &)), SIGNAL(connectTo(const MPDConnectionDetails &))); connect(server, SIGNAL(disconnectFromMpd()), MPDConnection::self(), SLOT(disconnectMpd())); + connect(files, SIGNAL(reloadStreams()), SIGNAL(reloadStreams())); } void PreferencesDialog::writeSettings() @@ -100,6 +105,7 @@ void PreferencesDialog::writeSettings() server->save(); serverplayback->save(); playback->save(); + files->save(); interface->save(); #ifdef TAGLIB_FOUND http->save(); diff --git a/gui/preferencesdialog.h b/gui/preferencesdialog.h index 2036c3c1b..a7115b671 100644 --- a/gui/preferencesdialog.h +++ b/gui/preferencesdialog.h @@ -34,6 +34,7 @@ class ShortcutsSettingsPage; class ServerSettings; class ServerPlaybackSettings; class PlaybackSettings; +class FileSettings; class InterfaceSettings; class LyricSettings; class LyricsPage; @@ -59,11 +60,13 @@ private Q_SLOTS: Q_SIGNALS: void settingsSaved(); void connectTo(const MPDConnectionDetails &details); + void reloadStreams(); private: ServerSettings *server; ServerPlaybackSettings *serverplayback; PlaybackSettings *playback; + FileSettings *files; InterfaceSettings *interface; LyricSettings *lyrics; #ifdef TAGLIB_FOUND diff --git a/gui/settings.cpp b/gui/settings.cpp index fb3fd82dc..91cb8710f 100644 --- a/gui/settings.cpp +++ b/gui/settings.cpp @@ -327,6 +327,11 @@ bool Settings::storeLyricsInMpdDir() return GET_BOOL("storeLyricsInMpdDir", true); } +bool Settings::storeStreamsInMpdDir() +{ + return GET_BOOL("storeStreamsInMpdDir", false); +} + int Settings::libraryView() { int v=version(); @@ -714,6 +719,11 @@ void Settings::saveStoreLyricsInMpdDir(bool v) SET_VALUE_MOD(storeLyricsInMpdDir) } +void Settings::saveStoreStreamsInMpdDir(bool v) +{ + SET_VALUE_MOD(storeStreamsInMpdDir) +} + void Settings::saveLibraryView(int v) { SET_ITEMVIEW_MODE_VALUE_MOD(libraryView) diff --git a/gui/settings.h b/gui/settings.h index 5148938ab..61f068c2c 100644 --- a/gui/settings.h +++ b/gui/settings.h @@ -108,6 +108,7 @@ public: bool smallPlaybackButtons(); bool storeCoversInMpdDir(); bool storeLyricsInMpdDir(); + bool storeStreamsInMpdDir(); int libraryView(); int albumsView(); int folderView(); @@ -171,6 +172,7 @@ public: void saveShowPopups(bool v); void saveStoreCoversInMpdDir(bool v); void saveStoreLyricsInMpdDir(bool v); + void saveStoreStreamsInMpdDir(bool v); void saveLibraryView(int v); void saveAlbumsView(int v); void saveFolderView(int v); diff --git a/models/streamsmodel.cpp b/models/streamsmodel.cpp index bccc2cb85..8d05bae92 100644 --- a/models/streamsmodel.cpp +++ b/models/streamsmodel.cpp @@ -88,9 +88,14 @@ static bool iconIsValid(const QString &icon) return icon.startsWith('/') ? QFile::exists(icon) : QIcon::hasThemeIcon(icon); } +static const QLatin1String constStreamsFileName("streams.xml"); + static QString getInternalFile(bool createDir=false) { - return Utils::configDir(QString(), createDir)+"streams.xml"; + if (Settings::self()->storeStreamsInMpdDir() && MPDConnection::self()->getDetails().dirReadable) { + return MPDConnection::self()->getDetails().dir+constStreamsFileName; + } + return Utils::configDir(QString(), createDir)+constStreamsFileName; } StreamsModel::StreamsModel() diff --git a/streams/streamspage.h b/streams/streamspage.h index 2a49287c9..1e32c7e3e 100644 --- a/streams/streamspage.h +++ b/streams/streamspage.h @@ -51,7 +51,6 @@ public: void setEnabled(bool e); bool isEnabled() const { return enabled; } - void refresh(); void save(); void addSelectionToPlaylist(bool replace, quint8 priorty=0); void setView(int v) { view->setMode((ItemView::Mode)v); } @@ -65,6 +64,7 @@ Q_SIGNALS: void add(const QStringList &streams, bool replace, quint8 priorty); public Q_SLOTS: + void refresh(); void removeItems(); void controlActions();