Create a PodcastInfoDialog that utilizes the existing PodcastInfoWidget. Add a Podcast Information menu item that is enabled when exactly one podcast is represented by the highlighted items. (#6190)

This commit is contained in:
Jim Broadus 2018-11-11 12:53:06 -08:00 committed by John Maguire
parent 0104763009
commit 2e4814eb36
6 changed files with 216 additions and 0 deletions

View File

@ -275,6 +275,7 @@ set(SOURCES
internet/podcasts/podcastdeleter.cpp
internet/podcasts/podcastdownloader.cpp
internet/podcasts/podcastepisode.cpp
internet/podcasts/podcastinfodialog.cpp
internet/podcasts/podcastinfowidget.cpp
internet/podcasts/podcastservice.cpp
internet/podcasts/podcastservicemodel.cpp
@ -569,6 +570,7 @@ set(HEADERS
internet/podcasts/podcastdiscoverymodel.h
internet/podcasts/podcastdeleter.h
internet/podcasts/podcastdownloader.h
internet/podcasts/podcastinfodialog.h
internet/podcasts/podcastinfowidget.h
internet/podcasts/podcastservice.h
internet/podcasts/podcastservicemodel.h
@ -715,6 +717,7 @@ set(UI
internet/podcasts/addpodcastdialog.ui
internet/podcasts/gpoddersearchpage.ui
internet/podcasts/itunessearchpage.ui
internet/podcasts/podcastinfodialog.ui
internet/podcasts/podcastinfowidget.ui
internet/podcasts/podcastsettingspage.ui

View File

@ -0,0 +1,39 @@
/* This file is part of Clementine.
Copyright 2018, Jim Broadus <jbroadus@gmail.com>
Clementine 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 3 of the License, or
(at your option) any later version.
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "podcastinfodialog.h"
#include "ui_podcastinfodialog.h"
PodcastInfoDialog::PodcastInfoDialog(Application* app, QWidget* parent)
: QDialog(parent),
app_(app),
ui_(new Ui_PodcastInfoDialog) {
ui_->setupUi(this);
ui_->details->SetApplication(app);
}
PodcastInfoDialog::~PodcastInfoDialog() {
delete ui_;
}
void PodcastInfoDialog::ShowPodcast(const Podcast& podcast) {
show();
ui_->podcast_url->setText(podcast.url().toString());
ui_->podcast_url->setReadOnly(true);
ui_->details->SetPodcast(podcast);
}

View File

@ -0,0 +1,42 @@
/* This file is part of Clementine.
Copyright 2018, Jim Broadus <jbroadus@gmail.com>
Clementine 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 3 of the License, or
(at your option) any later version.
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INTERNET_PODCASTS_PODCASTINFODIALOG_H_
#define INTERNET_PODCASTS_PODCASTINFODIALOG_H_
#include <QDialog>
class Application;
class Podcast;
class Ui_PodcastInfoDialog;
class PodcastInfoDialog : public QDialog {
Q_OBJECT
public:
explicit PodcastInfoDialog(Application* app, QWidget* parent = nullptr);
~PodcastInfoDialog();
void ShowPodcast(const Podcast& podcast);
private:
Application* app_;
Ui_PodcastInfoDialog* ui_;
};
#endif // INTERNET_PODCASTS_PODCASTINFODIALOG_H_

View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PodcastInfoDialog</class>
<widget class="QDialog" name="PodcastInfoDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>493</width>
<height>395</height>
</rect>
</property>
<property name="windowTitle">
<string>Podcast Information</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLineEdit" name="podcast_url"/>
</item>
<item>
<widget class="QScrollArea" name="details_scroll_area">
<property name="minimumSize">
<size>
<width>250</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="PodcastInfoWidget" name="details">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>473</width>
<height>313</height>
</rect>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>PodcastInfoWidget</class>
<extends>QWidget</extends>
<header>internet/podcasts/podcastinfowidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>PodcastInfoDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>PodcastInfoDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -26,6 +26,7 @@
#include <QtConcurrentRun>
#include "addpodcastdialog.h"
#include "podcastinfodialog.h"
#include "core/application.h"
#include "core/logging.h"
#include "core/mergedproxymodel.h"
@ -430,6 +431,11 @@ void PodcastService::ShowContextMenu(const QPoint& global_pos) {
download_selected_action_ =
context_menu_->addAction(IconLoader::Load("download", IconLoader::Base),
"", this, SLOT(DownloadSelectedEpisode()));
info_selected_action_ =
context_menu_->addAction(IconLoader::Load("about-info",
IconLoader::Base),
tr("Podcast information"), this,
SLOT(PodcastInfo()));
delete_downloaded_action_ = context_menu_->addAction(
IconLoader::Load("edit-delete", IconLoader::Base),
tr("Delete downloaded data"), this, SLOT(DeleteDownloadedData()));
@ -521,6 +527,12 @@ void PodcastService::ShowContextMenu(const QPoint& global_pos) {
delete_downloaded_action_->setEnabled(episodes);
}
if (selected_podcasts_.count() == 1) {
info_selected_action_->setEnabled(true);
} else {
info_selected_action_->setEnabled(false);
}
if (explicitly_selected_podcasts_.isEmpty() && selected_episodes_.isEmpty()) {
PodcastEpisodeList epis = backend_->GetNewDownloadedEpisodes();
set_listened_action_->setEnabled(!epis.isEmpty());
@ -686,6 +698,15 @@ void PodcastService::DownloadSelectedEpisode() {
}
}
void PodcastService::PodcastInfo() {
if (selected_podcasts_.count() > 0) {
const Podcast podcast =
selected_podcasts_[0].data(Role_Podcast).value<Podcast>();
podcast_info_dialog_.reset(new PodcastInfoDialog(app_));
podcast_info_dialog_->ShowPodcast(podcast);
}
}
void PodcastService::DeleteDownloadedData() {
for (const QModelIndex& index : selected_episodes_) {
app_->podcast_deleter()->DeleteEpisode(

View File

@ -30,6 +30,7 @@
#include <QScopedPointer>
class AddPodcastDialog;
class PodcastInfoDialog;
class OrganiseDialog;
class Podcast;
class PodcastBackend;
@ -76,6 +77,7 @@ class PodcastService : public InternetService {
void ReloadPodcast(const Podcast& podcast);
void RemoveSelectedPodcast();
void DownloadSelectedEpisode();
void PodcastInfo();
void DeleteDownloadedData();
void SetNew();
void SetListened();
@ -148,6 +150,7 @@ class PodcastService : public InternetService {
QAction* update_selected_action_;
QAction* remove_selected_action_;
QAction* download_selected_action_;
QAction* info_selected_action_;
QAction* delete_downloaded_action_;
QAction* set_new_action_;
QAction* set_listened_action_;
@ -164,6 +167,7 @@ class PodcastService : public InternetService {
QMap<int, QStandardItem*> episodes_by_database_id_;
std::unique_ptr<AddPodcastDialog> add_podcast_dialog_;
std::unique_ptr<PodcastInfoDialog> podcast_info_dialog_;
};
#endif // INTERNET_PODCASTS_PODCASTSERVICE_H_