From cb5a7f8c9d663768821d516e6d6d5af421c0fd41 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Fri, 29 Jan 2021 18:47:50 +0100 Subject: [PATCH] Replace NewClosure with lamdas --- src/core/mainwindow.cpp | 6 ++++-- src/dialogs/edittagdialog.cpp | 2 +- src/moodbar/moodbarcontroller.cpp | 3 +-- src/moodbar/moodbaritemdelegate.cpp | 2 +- src/moodbar/moodbarloader.cpp | 3 +-- src/playlist/playlist.cpp | 3 ++- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/core/mainwindow.cpp b/src/core/mainwindow.cpp index 925063c74..ea44f08da 100644 --- a/src/core/mainwindow.cpp +++ b/src/core/mainwindow.cpp @@ -2064,7 +2064,8 @@ void MainWindow::RenumberTracks() { if (song.IsEditable()) { song.set_track(track); TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); - NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)), reply, QPersistentModelIndex(source_index)); + QPersistentModelIndex persistent_index = QPersistentModelIndex(source_index); + connect(reply, &TagReaderReply::Finished, this, [this, reply, persistent_index]() { SongSaveComplete(reply, persistent_index); }); } ++track; } @@ -2094,7 +2095,8 @@ void MainWindow::SelectionSetValue() { if (!song.is_valid() || !song.url().isLocalFile()) continue; if (Playlist::set_column_value(song, column, column_value)) { TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); - NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)), reply, QPersistentModelIndex(source_index)); + QPersistentModelIndex persistent_index = QPersistentModelIndex(source_index); + connect(reply, &TagReaderReply::Finished, this, [this, reply, persistent_index]() { SongSaveComplete(reply, persistent_index); }); } } diff --git a/src/dialogs/edittagdialog.cpp b/src/dialogs/edittagdialog.cpp index 758967139..316dd47bb 100644 --- a/src/dialogs/edittagdialog.cpp +++ b/src/dialogs/edittagdialog.cpp @@ -776,7 +776,7 @@ void EditTagDialog::SaveData(const QList &tag_data) { ++pending_; TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(ref.current_.url().toLocalFile(), ref.current_); - NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QString, Song)), reply, ref.current_.url().toLocalFile(), ref.current_); + connect(reply, &TagReaderReply::Finished, this, [this, reply, ref]() { SongSaveComplete(reply, ref.current_.url().toLocalFile(), ref.current_); }); } diff --git a/src/moodbar/moodbarcontroller.cpp b/src/moodbar/moodbarcontroller.cpp index 67f146995..4c8ee3a90 100644 --- a/src/moodbar/moodbarcontroller.cpp +++ b/src/moodbar/moodbarcontroller.cpp @@ -24,7 +24,6 @@ #include "core/application.h" #include "core/player.h" #include "core/song.h" -#include "core/closure.h" #include "engine/engine_fwd.h" #include "settings/moodbarsettingspage.h" #include "playlist/playlistmanager.h" @@ -76,7 +75,7 @@ void MoodbarController::CurrentSongChanged(const Song &song) { // bar. Our slot will be called when the data is actually loaded. emit CurrentMoodbarDataChanged(QByteArray()); - NewClosure(pipeline, SIGNAL(Finished(bool)), this, SLOT(AsyncLoadComplete(MoodbarPipeline*, QUrl)), pipeline, song.url()); + QObject::connect(pipeline, &MoodbarPipeline::Finished, this, [this, pipeline, song]() { AsyncLoadComplete(pipeline, song.url()); }); break; } diff --git a/src/moodbar/moodbaritemdelegate.cpp b/src/moodbar/moodbaritemdelegate.cpp index 1a67a46bc..f2db69c56 100644 --- a/src/moodbar/moodbaritemdelegate.cpp +++ b/src/moodbar/moodbaritemdelegate.cpp @@ -155,7 +155,7 @@ void MoodbarItemDelegate::StartLoadingData(const QUrl &url, Data *data) { case MoodbarLoader::WillLoadAsync: // Maybe in a little while. - NewClosure(pipeline, SIGNAL(Finished(bool)), this, SLOT(DataLoaded(QUrl, MoodbarPipeline*)), url, pipeline); + QObject::connect(pipeline, &MoodbarPipeline::Finished, this, [this, url, pipeline]() { DataLoaded(url, pipeline); }); break; } diff --git a/src/moodbar/moodbarloader.cpp b/src/moodbar/moodbarloader.cpp index 470e4b953..e09ad7d9f 100644 --- a/src/moodbar/moodbarloader.cpp +++ b/src/moodbar/moodbarloader.cpp @@ -39,7 +39,6 @@ #include #include "core/application.h" -#include "core/closure.h" #include "core/logging.h" #include "moodbarpipeline.h" @@ -130,7 +129,7 @@ MoodbarLoader::Result MoodbarLoader::Load(const QUrl &url, QByteArray *data, Moo // There was no existing file, analyze the audio file and create one. MoodbarPipeline *pipeline = new MoodbarPipeline(url); pipeline->moveToThread(thread_); - NewClosure(pipeline, SIGNAL(Finished(bool)), this, SLOT(RequestFinished(MoodbarPipeline*, QUrl)), pipeline, url); + QObject::connect(pipeline, &MoodbarPipeline::Finished, this, [this, pipeline, url]() { RequestFinished(pipeline, url); }); requests_[url] = pipeline; queued_requests_ << url; diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index b5b11762e..6d4d96b44 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -392,7 +392,8 @@ bool Playlist::setData(const QModelIndex &idx, const QVariant &value, int role) if (!set_column_value(song, static_cast(idx.column()), value)) return false; TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); - NewClosure(reply, SIGNAL(Finished(bool)), this, SLOT(SongSaveComplete(TagReaderReply*, QPersistentModelIndex)), reply, QPersistentModelIndex(idx)); + QPersistentModelIndex persistent_index = QPersistentModelIndex(idx); + connect(reply, &TagReaderReply::Finished, this, [this, reply, persistent_index]() { SongSaveComplete(reply, persistent_index); }); return true;