Replace NewClosure with lamdas

This commit is contained in:
Jonas Kvinge
2021-01-29 18:47:50 +01:00
parent fd9c6d460a
commit cb5a7f8c9d
6 changed files with 10 additions and 9 deletions

View File

@@ -2064,7 +2064,8 @@ void MainWindow::RenumberTracks() {
if (song.IsEditable()) { if (song.IsEditable()) {
song.set_track(track); song.set_track(track);
TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); 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; ++track;
} }
@@ -2094,7 +2095,8 @@ void MainWindow::SelectionSetValue() {
if (!song.is_valid() || !song.url().isLocalFile()) continue; if (!song.is_valid() || !song.url().isLocalFile()) continue;
if (Playlist::set_column_value(song, column, column_value)) { if (Playlist::set_column_value(song, column, column_value)) {
TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); 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); });
} }
} }

View File

@@ -776,7 +776,7 @@ void EditTagDialog::SaveData(const QList<Data> &tag_data) {
++pending_; ++pending_;
TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(ref.current_.url().toLocalFile(), ref.current_); 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_); });
} }

View File

@@ -24,7 +24,6 @@
#include "core/application.h" #include "core/application.h"
#include "core/player.h" #include "core/player.h"
#include "core/song.h" #include "core/song.h"
#include "core/closure.h"
#include "engine/engine_fwd.h" #include "engine/engine_fwd.h"
#include "settings/moodbarsettingspage.h" #include "settings/moodbarsettingspage.h"
#include "playlist/playlistmanager.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. // bar. Our slot will be called when the data is actually loaded.
emit CurrentMoodbarDataChanged(QByteArray()); 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; break;
} }

View File

@@ -155,7 +155,7 @@ void MoodbarItemDelegate::StartLoadingData(const QUrl &url, Data *data) {
case MoodbarLoader::WillLoadAsync: case MoodbarLoader::WillLoadAsync:
// Maybe in a little while. // 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; break;
} }

View File

@@ -39,7 +39,6 @@
#include <QtDebug> #include <QtDebug>
#include "core/application.h" #include "core/application.h"
#include "core/closure.h"
#include "core/logging.h" #include "core/logging.h"
#include "moodbarpipeline.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. // There was no existing file, analyze the audio file and create one.
MoodbarPipeline *pipeline = new MoodbarPipeline(url); MoodbarPipeline *pipeline = new MoodbarPipeline(url);
pipeline->moveToThread(thread_); 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; requests_[url] = pipeline;
queued_requests_ << url; queued_requests_ << url;

View File

@@ -392,7 +392,8 @@ bool Playlist::setData(const QModelIndex &idx, const QVariant &value, int role)
if (!set_column_value(song, static_cast<Column>(idx.column()), value)) return false; if (!set_column_value(song, static_cast<Column>(idx.column()), value)) return false;
TagReaderReply *reply = TagReaderClient::Instance()->SaveFile(song.url().toLocalFile(), song); 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; return true;