Add buttons and menu items to open the Podcast settings page. Also route these requests through Application rather than InternetModel

This commit is contained in:
David Sansome 2012-03-10 22:39:24 +00:00
parent d004875b0f
commit d538b71809
15 changed files with 50 additions and 24 deletions

View File

@ -140,3 +140,7 @@ LibraryModel* Application::library_model() const {
void Application::ReloadSettings() {
emit SettingsChanged();
}
void Application::OpenSettingsDialogAtPage(SettingsDialog::Page page) {
emit SettingsDialogRequested(page);
}

View File

@ -18,6 +18,8 @@
#ifndef APPLICATION_H
#define APPLICATION_H
#include "ui/settingsdialog.h"
#include <QObject>
class AlbumCoverLoader;
@ -77,10 +79,12 @@ public:
public slots:
void AddError(const QString& message);
void ReloadSettings();
void OpenSettingsDialogAtPage(SettingsDialog::Page page);
signals:
void ErrorAdded(const QString& message);
void SettingsChanged();
void SettingsDialogRequested(SettingsDialog::Page page);
private:
TagReaderClient* tag_reader_client_;

View File

@ -213,7 +213,7 @@ void DigitallyImportedServiceBase::LoadPlaylistFinished() {
}
void DigitallyImportedServiceBase::ShowSettingsDialog() {
emit OpenSettingsAtPage(SettingsDialog::Page_DigitallyImported);
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_DigitallyImported);
}
DigitallyImportedClient::ChannelList DigitallyImportedServiceBase::Channels() {

View File

@ -156,7 +156,7 @@ void GroovesharkService::LazyPopulate(QStandardItem* item) {
}
void GroovesharkService::ShowConfig() {
emit OpenSettingsAtPage(SettingsDialog::Page_Grooveshark);
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Grooveshark);
}
void GroovesharkService::Search(const QString& text, Playlist* playlist, bool now) {

View File

@ -91,7 +91,6 @@ void InternetModel::AddService(InternetService *service) {
connect(service, SIGNAL(StreamError(QString)), SIGNAL(StreamError(QString)));
connect(service, SIGNAL(StreamMetadataFound(QUrl,Song)), SIGNAL(StreamMetadataFound(QUrl,Song)));
connect(service, SIGNAL(OpenSettingsAtPage(SettingsDialog::Page)), SIGNAL(OpenSettingsAtPage(SettingsDialog::Page)));
connect(service, SIGNAL(AddToPlaylistSignal(QMimeData*)), SIGNAL(AddToPlaylist(QMimeData*)));
connect(service, SIGNAL(destroyed()), SLOT(ServiceDeleted()));

View File

@ -151,7 +151,6 @@ public:
signals:
void StreamError(const QString& message);
void StreamMetadataFound(const QUrl& original_url, const Song& song);
void OpenSettingsAtPage(SettingsDialog::Page);
void AddToPlaylist(QMimeData* data);

View File

@ -68,7 +68,6 @@ public:
signals:
void StreamError(const QString& message);
void StreamMetadataFound(const QUrl& original_url, const Song& song);
void OpenSettingsAtPage(SettingsDialog::Page page);
void AddToPlaylistSignal(QMimeData* data);

View File

@ -159,7 +159,7 @@ void LastFMService::ReloadSettings() {
}
void LastFMService::ShowConfig() {
emit OpenSettingsAtPage(SettingsDialog::Page_Lastfm);
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Lastfm);
}
bool LastFMService::IsAuthenticated() const {

View File

@ -341,7 +341,7 @@ QUrl MagnatuneService::ModifyUrl(const QUrl& url) const {
}
void MagnatuneService::ShowConfig() {
emit OpenSettingsAtPage(SettingsDialog::Page_Magnatune);
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Magnatune);
}
void MagnatuneService::Download() {

View File

@ -657,7 +657,7 @@ void SpotifyService::SyncPlaylistProgress(
}
void SpotifyService::ShowConfig() {
emit OpenSettingsAtPage(SettingsDialog::Page_Spotify);
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Spotify);
}
void SpotifyService::Logout() {

View File

@ -59,6 +59,11 @@ AddPodcastDialog::AddPodcastDialog(Application* app, QWidget* parent)
connect(remove_button_, SIGNAL(clicked()), SLOT(RemovePodcast()));
ui_->button_box->addButton(remove_button_, QDialogButtonBox::ActionRole);
QPushButton* settings_button = new QPushButton(
IconLoader::Load("configure"), tr("Configure podcasts..."), this);
connect(settings_button, SIGNAL(clicked()), SLOT(OpenSettingsPage()));
ui_->button_box->addButton(settings_button, QDialogButtonBox::ResetRole);
// Add providers
AddPage(new AddPodcastByUrl(app, this));
AddPage(new FixedOpmlPage(QUrl(kBbcOpmlUrl), tr("BBC Podcasts"),
@ -179,3 +184,7 @@ void AddPodcastDialog::RemovePodcast() {
add_button_->setEnabled(true);
remove_button_->setEnabled(false);
}
void AddPodcastDialog::OpenSettingsPage() {
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Podcasts);
}

View File

@ -39,6 +39,7 @@ public:
static const char* kBbcOpmlUrl;
private slots:
void OpenSettingsPage();
void AddPodcast();
void RemovePodcast();
void ChangePage(int index);

View File

@ -244,21 +244,28 @@ void PodcastService::ShowContextMenu(const QModelIndex& index,
const QPoint& global_pos) {
if (!context_menu_) {
context_menu_ = new QMenu;
context_menu_->addAction(IconLoader::Load("list-add"), tr("Add podcast..."),
this, SLOT(AddPodcast()));
context_menu_->addAction(IconLoader::Load("view-refresh"), tr("Update all podcasts"),
app_->podcast_updater(), SLOT(UpdateAllPodcastsNow()));
context_menu_->addAction(
IconLoader::Load("list-add"), tr("Add podcast..."),
this, SLOT(AddPodcast()));
context_menu_->addAction(
IconLoader::Load("view-refresh"), tr("Update all podcasts"),
app_->podcast_updater(), SLOT(UpdateAllPodcastsNow()));
context_menu_->addSeparator();
update_selected_action_ = context_menu_->addAction(IconLoader::Load("view-refresh"),
tr("Update this podcast"),
this, SLOT(UpdateSelectedPodcast()));
remove_selected_action_ = context_menu_->addAction(IconLoader::Load("list-remove"),
tr("Unsubscribe"),
this, SLOT(RemoveSelectedPodcast()));
download_selected_action_ = context_menu_->addAction(IconLoader::Load("download"),
tr("Download this episode"),
this, SLOT(DownloadSelectedEpisode()));
update_selected_action_ = context_menu_->addAction(
IconLoader::Load("view-refresh"), tr("Update this podcast"),
this, SLOT(UpdateSelectedPodcast()));
remove_selected_action_ = context_menu_->addAction(
IconLoader::Load("list-remove"), tr("Unsubscribe"),
this, SLOT(RemoveSelectedPodcast()));
download_selected_action_ = context_menu_->addAction(
IconLoader::Load("download"), tr("Download this episode"),
this, SLOT(DownloadSelectedEpisode()));
context_menu_->addSeparator();
context_menu_->addAction(
IconLoader::Load("configure"), tr("Configure podcasts..."),
this, SLOT(ShowConfig()));
}
current_index_ = index;
@ -416,3 +423,7 @@ void PodcastService::DownloadProgressChanged(const PodcastEpisode& episode,
UpdateEpisodeText(item, state, percent);
}
void PodcastService::ShowConfig() {
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Podcasts);
}

View File

@ -66,8 +66,8 @@ private slots:
void AddPodcast();
void UpdateSelectedPodcast();
void RemoveSelectedPodcast();
void DownloadSelectedEpisode();
void ShowConfig();
void SubscriptionAdded(const Podcast& podcast);
void SubscriptionRemoved(const Podcast& podcast);

View File

@ -189,8 +189,9 @@ MainWindow::MainWindow(Application* app,
{
qLog(Debug) << "Starting";
// Database connections
connect(app, SIGNAL(ErrorAdded(QString)), SLOT(ShowErrorDialog(QString)));
connect(app, SIGNAL(SettingsDialogRequested(SettingsDialog::Page)),
SLOT(OpenSettingsDialogAtPage(SettingsDialog::Page)));
// Initialise the UI
ui_->setupUi(this);
@ -509,7 +510,6 @@ MainWindow::MainWindow(Application* app,
// Internet connections
connect(app_->internet_model(), SIGNAL(StreamError(QString)), SLOT(ShowErrorDialog(QString)));
connect(app_->internet_model(), SIGNAL(StreamMetadataFound(QUrl,Song)), app_->playlist_manager(), SLOT(SetActiveStreamMetadata(QUrl,Song)));
connect(app_->internet_model(), SIGNAL(OpenSettingsAtPage(SettingsDialog::Page)), SLOT(OpenSettingsDialogAtPage(SettingsDialog::Page)));
connect(app_->internet_model(), SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*)));
#ifdef HAVE_LIBLASTFM
LastFMService* lastfm_service = InternetModel::Service<LastFMService>();