Add "Refresh" action to hover actions for podcasts.

Issue #1753
This commit is contained in:
Craig Drummond
2021-11-12 21:34:52 +00:00
parent 630d3c5c6e
commit cb8cbb6002
5 changed files with 30 additions and 0 deletions

View File

@@ -34,6 +34,7 @@
Sequeira.
25. When searching for lyrics, if fail and artist starts with "The " then try
again without "The "
26. Add "Refresh" action to hover actions for podcasts.
2.4.2
-----

View File

@@ -28,6 +28,7 @@
#include "support/utils.h"
#include "support/monoicon.h"
#include "gui/settings.h"
#include "gui/stdactions.h"
#include "widgets/icons.h"
#include "mpd-interface/mpdconnection.h"
#include "config.h"
@@ -427,6 +428,7 @@ PodcastService::PodcastService()
useCovers(name(), true);
clearPartialDownloads();
connect(MPDConnection::self(), SIGNAL(currentSongUpdated(const Song &)), this, SLOT(currentMpdSong(const Song &)));
refreshAction = new Action(Icons::self()->reloadIcon, tr("Refresh"), this);
}
QString PodcastService::name() const
@@ -577,6 +579,11 @@ QVariant PodcastService::data(const QModelIndex &index, int role) const
Podcast *podcast=static_cast<Podcast *>(item);
switch(role) {
case Cantata::Role_Actions: {
QVariant v;
v.setValue<QList<Action *> >(QList<Action *>() << StdActions::self()->replacePlayQueueAction << StdActions::self()->appendToPlayQueueAction << refreshAction);
return v;
}
case Cantata::Role_ListImage:
return true;
case Cantata::Role_CoverSong: {

View File

@@ -162,6 +162,7 @@ public:
void startRssUpdateTimer();
void stopRssUpdateTimer();
bool exportSubscriptions(const QString &name);
Action * refreshAct() { return refreshAction; }
Q_SIGNALS:
void error(const QString &msg);
@@ -206,6 +207,7 @@ private:
QTimer *deleteTimer;
QDateTime lastDelete;
QSet<QUrl> updateUrls;
Action *refreshAction;
static QString iconFile;
};

View File

@@ -68,6 +68,7 @@ PodcastWidget::PodcastWidget(PodcastService *s, QWidget *p)
connect(markAsListenedAction, SIGNAL(triggered()), this, SLOT(markAsListened()));
//connect(unplayedOnlyAction, SIGNAL(toggled(bool)), this, SLOT(showUnplayedOnly(bool)));
connect(exportAction, SIGNAL(triggered()), SLOT(exportSubscriptions()));
connect(srv->refreshAct(), SIGNAL(triggered()), this, SLOT(refreshPodcast()));
view->setMode(ItemView::Mode_DetailedTree);
Configuration config(metaObject()->className());
@@ -271,7 +272,17 @@ void PodcastWidget::doSearch()
}
}
void PodcastWidget::refreshPodcast()
{
doRefresh(true);
}
void PodcastWidget::refresh()
{
doRefresh(false);
}
void PodcastWidget::doRefresh(bool singleOnly)
{
QModelIndexList sel=view->selectedIndexes(false);
QModelIndexList selected;
@@ -281,6 +292,13 @@ void PodcastWidget::refresh()
}
}
if (singleOnly) {
if (1==selected.count()) {
srv->refresh(selected);
}
return;
}
if (selected.isEmpty() || selected.count()==srv->podcastCount()) {
srv->refreshAll();
return;

View File

@@ -52,10 +52,12 @@ private Q_SLOTS:
//void showUnplayedOnly(bool on);
void configure();
void exportSubscriptions();
void refreshPodcast();
private:
void doSearch() override;
void refresh() override;
void doRefresh(bool singleOnly);
void controlActions() override;
private: