Subsonic: Add button to delete songs

Fixes #883
This commit is contained in:
Jonas Kvinge 2022-01-28 21:25:44 +01:00
parent 81e6b55c39
commit 7a61e740e8
6 changed files with 53 additions and 10 deletions

View File

@ -1801,6 +1801,12 @@ void CollectionBackend::ResetStatistics(const int id) {
}
void CollectionBackend::DeleteAllAsync() {
QMetaObject::invokeMethod(this, "DeleteAll", Qt::QueuedConnection);
}
void CollectionBackend::DeleteAll() {
{

View File

@ -197,7 +197,7 @@ class CollectionBackend : public CollectionBackendInterface {
void IncrementSkipCountAsync(const int id, const float progress);
void ResetStatisticsAsync(const int id);
void DeleteAll();
void DeleteAllAsync();
Song GetSongBySongId(const QString &song_id);
SongList GetSongsBySongId(const QStringList &song_ids);
@ -234,6 +234,7 @@ class CollectionBackend : public CollectionBackendInterface {
void IncrementPlayCount(const int id);
void IncrementSkipCount(const int id, const float progress);
void ResetStatistics(const int id);
void DeleteAll();
void SongPathChanged(const Song &song, const QFileInfo &new_file, const std::optional<int> new_collection_directory_id);
SongList GetSongsBy(const QString &artist, const QString &album, const QString &title);

View File

@ -50,6 +50,7 @@ SubsonicSettingsPage::SubsonicSettingsPage(SettingsDialog *dialog, QWidget *pare
setWindowIcon(IconLoader::Load("subsonic"));
QObject::connect(ui_->button_test, &QPushButton::clicked, this, &SubsonicSettingsPage::TestClicked);
QObject::connect(ui_->button_deletesongs, &QPushButton::clicked, service_, &SubsonicService::DeleteSongs);
QObject::connect(this, &SubsonicSettingsPage::Test, service_, &SubsonicService::SendPingWithCredentials);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>460</width>
<height>644</height>
<height>749</height>
</rect>
</property>
<property name="windowTitle">
@ -144,13 +144,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_test">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_preferences">
<property name="title">
@ -188,6 +181,42 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupbox_tools">
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="button_test">
<property name="text">
<string>Test</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="button_deletesongs">
<property name="text">
<string>Delete songs</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="spacer_middle">
<property name="orientation">
@ -244,7 +273,6 @@
<tabstop>server_url</tabstop>
<tabstop>username</tabstop>
<tabstop>password</tabstop>
<tabstop>button_test</tabstop>
<tabstop>checkbox_verify_certificate</tabstop>
<tabstop>checkbox_download_album_covers</tabstop>
</tabstops>

View File

@ -446,6 +446,12 @@ void SubsonicService::GetSongs() {
}
void SubsonicService::DeleteSongs() {
collection_backend_->DeleteAllAsync();
}
void SubsonicService::SongsResultsReceived(const SongMap &songs, const QString &error) {
emit SongsResults(songs, error);

View File

@ -92,6 +92,7 @@ class SubsonicService : public InternetService {
void SendPing();
void SendPingWithCredentials(QUrl url, const QString &username, const QString &password, const SubsonicSettingsPage::AuthMethod auth_method, const bool redirect = false);
void GetSongs() override;
void DeleteSongs();
void ResetSongsRequest() override;
private slots: