Refactoring
This commit is contained in:
@@ -36,13 +36,14 @@
|
||||
#include <QTextBrowser>
|
||||
|
||||
#include "console.h"
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/application.h"
|
||||
#include "core/database.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
Console::Console(Application *app, QWidget *parent) : QDialog(parent), ui_{}, app_(app) {
|
||||
Console::Console(const SharedPtr<Database> database, QWidget *parent) : QDialog(parent), ui_{}, database_(database) {
|
||||
|
||||
ui_.setupUi(this);
|
||||
|
||||
@@ -60,14 +61,16 @@ Console::Console(Application *app, QWidget *parent) : QDialog(parent), ui_{}, ap
|
||||
|
||||
void Console::RunQuery() {
|
||||
|
||||
QSqlDatabase db = app_->database()->Connect();
|
||||
QSqlDatabase db = database_->Connect();
|
||||
QSqlQuery query(db);
|
||||
if (!query.prepare(ui_.query->text())) {
|
||||
qLog(Error) << query.lastError();
|
||||
Q_EMIT Error(query.lastError().text());
|
||||
return;
|
||||
}
|
||||
if (!query.exec()) {
|
||||
qLog(Error) << query.lastError();
|
||||
Q_EMIT Error(query.lastError().text());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,20 +31,25 @@
|
||||
|
||||
#include "ui_console.h"
|
||||
|
||||
class Application;
|
||||
#include "includes/shared_ptr.h"
|
||||
|
||||
class Database;
|
||||
|
||||
class Console : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Console(Application *app, QWidget *parent = nullptr);
|
||||
explicit Console(const SharedPtr<Database> database, QWidget *parent = nullptr);
|
||||
|
||||
private Q_SLOTS:
|
||||
void RunQuery();
|
||||
|
||||
Q_SIGNALS:
|
||||
void Error(const QString &error);
|
||||
|
||||
private:
|
||||
Ui::Console ui_;
|
||||
Application *app_;
|
||||
const SharedPtr<Database> database_;
|
||||
};
|
||||
|
||||
#endif // CONSOLE_H
|
||||
|
||||
@@ -70,7 +70,6 @@
|
||||
#include <QSettings>
|
||||
#include <QMimeData>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/settings.h"
|
||||
@@ -110,16 +109,28 @@ constexpr int kSmallImageSize = 128;
|
||||
const char EditTagDialog::kTagsDifferentHintText[] = QT_TR_NOOP("(different across multiple songs)");
|
||||
const char EditTagDialog::kArtDifferentHintText[] = QT_TR_NOOP("Different art across multiple songs.");
|
||||
|
||||
EditTagDialog::EditTagDialog(Application *app, QWidget *parent)
|
||||
EditTagDialog::EditTagDialog(const SharedPtr<NetworkAccessManager> network,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<CollectionBackend> collection_backend,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const SharedPtr<CurrentAlbumCoverLoader> current_albumcover_loader,
|
||||
const SharedPtr<CoverProviders> cover_providers,
|
||||
const SharedPtr<LyricsProviders> lyrics_providers,
|
||||
const SharedPtr<StreamingServices> streaming_services,
|
||||
QWidget *parent)
|
||||
: QDialog(parent),
|
||||
ui_(new Ui_EditTagDialog),
|
||||
app_(app),
|
||||
tagreader_client_(tagreader_client),
|
||||
collection_backend_(collection_backend),
|
||||
albumcover_loader_(albumcover_loader),
|
||||
current_albumcover_loader_(current_albumcover_loader),
|
||||
cover_providers_(cover_providers),
|
||||
album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
|
||||
#ifdef HAVE_MUSICBRAINZ
|
||||
tag_fetcher_(new TagFetcher(app->network(), this)),
|
||||
results_dialog_(new TrackSelectionDialog(this)),
|
||||
tag_fetcher_(new TagFetcher(network, this)),
|
||||
results_dialog_(new TrackSelectionDialog(tagreader_client, this)),
|
||||
#endif
|
||||
lyrics_fetcher_(new LyricsFetcher(app->lyrics_providers(), this)),
|
||||
lyrics_fetcher_(new LyricsFetcher(lyrics_providers, this)),
|
||||
cover_menu_(new QMenu(this)),
|
||||
image_no_cover_thumbnail_(ImageUtils::GenerateNoCoverImage(QSize(128, 128), devicePixelRatioF())),
|
||||
loading_(false),
|
||||
@@ -130,7 +141,7 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent)
|
||||
save_tag_pending_(0),
|
||||
lyrics_id_(-1) {
|
||||
|
||||
QObject::connect(&*app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &EditTagDialog::AlbumCoverLoaded);
|
||||
QObject::connect(&*albumcover_loader_, &AlbumCoverLoader::AlbumCoverLoaded, this, &EditTagDialog::AlbumCoverLoaded);
|
||||
|
||||
#ifdef HAVE_MUSICBRAINZ
|
||||
QObject::connect(tag_fetcher_, &TagFetcher::ResultAvailable, results_dialog_, &TrackSelectionDialog::FetchTagFinished, Qt::QueuedConnection);
|
||||
@@ -140,7 +151,7 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent)
|
||||
#endif
|
||||
QObject::connect(lyrics_fetcher_, &LyricsFetcher::LyricsFetched, this, &EditTagDialog::UpdateLyrics);
|
||||
|
||||
album_cover_choice_controller_->Init(app_);
|
||||
album_cover_choice_controller_->Init(network, tagreader_client, collection_backend, albumcover_loader, current_albumcover_loader, cover_providers, streaming_services);
|
||||
|
||||
ui_->setupUi(this);
|
||||
ui_->splitter->setSizes(QList<int>() << 200 << width() - 200);
|
||||
@@ -259,13 +270,13 @@ EditTagDialog::EditTagDialog(Application *app, QWidget *parent)
|
||||
QKeySequence(QKeySequence::Forward).toString(QKeySequence::NativeText),
|
||||
QKeySequence(QKeySequence::MoveToNextPage).toString(QKeySequence::NativeText)));
|
||||
|
||||
new TagCompleter(app_->collection_backend(), Playlist::Column::Artist, ui_->artist);
|
||||
new TagCompleter(app_->collection_backend(), Playlist::Column::Album, ui_->album);
|
||||
new TagCompleter(app_->collection_backend(), Playlist::Column::AlbumArtist, ui_->albumartist);
|
||||
new TagCompleter(app_->collection_backend(), Playlist::Column::Genre, ui_->genre);
|
||||
new TagCompleter(app_->collection_backend(), Playlist::Column::Composer, ui_->composer);
|
||||
new TagCompleter(app_->collection_backend(), Playlist::Column::Performer, ui_->performer);
|
||||
new TagCompleter(app_->collection_backend(), Playlist::Column::Grouping, ui_->grouping);
|
||||
new TagCompleter(collection_backend, Playlist::Column::Artist, ui_->artist);
|
||||
new TagCompleter(collection_backend, Playlist::Column::Album, ui_->album);
|
||||
new TagCompleter(collection_backend, Playlist::Column::AlbumArtist, ui_->albumartist);
|
||||
new TagCompleter(collection_backend, Playlist::Column::Genre, ui_->genre);
|
||||
new TagCompleter(collection_backend, Playlist::Column::Composer, ui_->composer);
|
||||
new TagCompleter(collection_backend, Playlist::Column::Performer, ui_->performer);
|
||||
new TagCompleter(collection_backend, Playlist::Column::Grouping, ui_->grouping);
|
||||
|
||||
}
|
||||
|
||||
@@ -393,7 +404,7 @@ bool EditTagDialog::SetLoading(const QString &message) {
|
||||
|
||||
}
|
||||
|
||||
QList<EditTagDialog::Data> EditTagDialog::LoadData(const SongList &songs) {
|
||||
QList<EditTagDialog::Data> EditTagDialog::LoadData(const SongList &songs) const {
|
||||
|
||||
QList<Data> ret;
|
||||
|
||||
@@ -401,7 +412,7 @@ QList<EditTagDialog::Data> EditTagDialog::LoadData(const SongList &songs) {
|
||||
if (song.IsEditable()) {
|
||||
// Try reloading the tags from file
|
||||
Song copy(song);
|
||||
const TagReaderResult result = TagReaderClient::Instance()->ReadFileBlocking(copy.url().toLocalFile(), ©);
|
||||
const TagReaderResult result = tagreader_client_->ReadFileBlocking(copy.url().toLocalFile(), ©);
|
||||
if (result.success() && copy.is_valid()) {
|
||||
copy.MergeUserSetData(song, false, false);
|
||||
ret << Data(copy);
|
||||
@@ -424,7 +435,7 @@ void EditTagDialog::SetSongs(const SongList &s, const PlaylistItemPtrList &items
|
||||
collection_songs_.clear();
|
||||
|
||||
// Reload tags in the background
|
||||
QFuture<QList<Data>> future = QtConcurrent::run(&EditTagDialog::LoadData, s);
|
||||
QFuture<QList<Data>> future = QtConcurrent::run(&EditTagDialog::LoadData, this, s);
|
||||
QFutureWatcher<QList<Data>> *watcher = new QFutureWatcher<QList<Data>>();
|
||||
QObject::connect(watcher, &QFutureWatcher<QList<Data>>::finished, this, &EditTagDialog::SetSongsFinished);
|
||||
watcher->setFuture(future);
|
||||
@@ -725,7 +736,7 @@ void EditTagDialog::SelectionChanged() {
|
||||
album_cover_choice_controller_->cover_to_file_action()->setEnabled(first_song.has_valid_art() && !first_song.art_unset());
|
||||
album_cover_choice_controller_->cover_from_file_action()->setEnabled(enable_change_art);
|
||||
album_cover_choice_controller_->cover_from_url_action()->setEnabled(enable_change_art);
|
||||
album_cover_choice_controller_->search_for_cover_action()->setEnabled(app_->cover_providers()->HasAnyProviders() && enable_change_art);
|
||||
album_cover_choice_controller_->search_for_cover_action()->setEnabled(cover_providers_->HasAnyProviders() && enable_change_art);
|
||||
album_cover_choice_controller_->unset_cover_action()->setEnabled(enable_change_art && !first_song.art_unset());
|
||||
album_cover_choice_controller_->clear_cover_action()->setEnabled(enable_change_art && (!first_song.art_manual().isEmpty() || first_song.art_unset()));
|
||||
album_cover_choice_controller_->delete_cover_action()->setEnabled(enable_change_art && (first_song.art_embedded() || !first_song.art_automatic().isEmpty() || !first_song.art_manual().isEmpty()));
|
||||
@@ -734,10 +745,10 @@ void EditTagDialog::SelectionChanged() {
|
||||
cover_options.desired_scaled_size = QSize(kSmallImageSize, kSmallImageSize);
|
||||
cover_options.device_pixel_ratio = devicePixelRatioF();
|
||||
if (data_.value(indexes.first().row()).cover_action_ == UpdateCoverAction::None) {
|
||||
tags_cover_art_id_ = app_->album_cover_loader()->LoadImageAsync(cover_options, first_song);
|
||||
tags_cover_art_id_ = albumcover_loader_->LoadImageAsync(cover_options, first_song);
|
||||
}
|
||||
else {
|
||||
tags_cover_art_id_ = app_->album_cover_loader()->LoadImageAsync(cover_options, data_[indexes.first().row()].cover_result_);
|
||||
tags_cover_art_id_ = albumcover_loader_->LoadImageAsync(cover_options, data_[indexes.first().row()].cover_result_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -788,7 +799,7 @@ void EditTagDialog::UpdateSummaryTab(const Song &song) {
|
||||
cover_options.types = cover_types_;
|
||||
cover_options.desired_scaled_size = QSize(kSmallImageSize, kSmallImageSize);
|
||||
cover_options.device_pixel_ratio = devicePixelRatioF();
|
||||
summary_cover_art_id_ = app_->album_cover_loader()->LoadImageAsync(cover_options, song);
|
||||
summary_cover_art_id_ = albumcover_loader_->LoadImageAsync(cover_options, song);
|
||||
|
||||
ui_->summary->setText(u"<p><b>"_s + song.PrettyTitleWithArtist().toHtmlEscaped() + u"</b></p>"_s);
|
||||
|
||||
@@ -1299,7 +1310,7 @@ void EditTagDialog::SaveData() {
|
||||
if (save_embedded_cover) {
|
||||
save_tags_options |= TagReaderClient::SaveOption::Cover;
|
||||
}
|
||||
TagReaderReplyPtr reply = TagReaderClient::Instance()->WriteFileAsync(ref.current_.url().toLocalFile(), ref.current_, save_tags_options, save_tag_cover_data);
|
||||
TagReaderReplyPtr reply = tagreader_client_->WriteFileAsync(ref.current_.url().toLocalFile(), ref.current_, save_tags_options, save_tag_cover_data);
|
||||
QObject::connect(&*reply, &TagReaderReply::Finished, this, [this, reply, ref]() { SongSaveTagsComplete(reply, ref.current_.url().toLocalFile(), ref.current_, ref.cover_action_); }, Qt::QueuedConnection);
|
||||
}
|
||||
// If the cover was changed, but no tags written, make sure to update the collection.
|
||||
@@ -1307,8 +1318,8 @@ void EditTagDialog::SaveData() {
|
||||
if (ref.current_.is_collection_song()) {
|
||||
collection_songs_.insert(ref.current_.id(), ref.current_);
|
||||
}
|
||||
if (ref.current_ == app_->current_albumcover_loader()->last_song()) {
|
||||
app_->current_albumcover_loader()->LoadAlbumCover(ref.current_);
|
||||
if (ref.current_ == current_albumcover_loader_->last_song()) {
|
||||
current_albumcover_loader_->LoadAlbumCover(ref.current_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1321,7 +1332,7 @@ void EditTagDialog::SaveData() {
|
||||
void EditTagDialog::SaveDataFinished() {
|
||||
|
||||
if (!collection_songs_.isEmpty()) {
|
||||
app_->collection_backend()->AddOrUpdateSongsAsync(collection_songs_.values());
|
||||
collection_backend_->AddOrUpdateSongsAsync(collection_songs_.values());
|
||||
collection_songs_.clear();
|
||||
}
|
||||
|
||||
@@ -1483,8 +1494,8 @@ void EditTagDialog::SongSaveTagsComplete(TagReaderReplyPtr reply, const QString
|
||||
}
|
||||
collection_songs_.insert(song.id(), song);
|
||||
}
|
||||
if (cover_action != UpdateCoverAction::None && song == app_->current_albumcover_loader()->last_song()) {
|
||||
app_->current_albumcover_loader()->LoadAlbumCover(song);
|
||||
if (cover_action != UpdateCoverAction::None && song == current_albumcover_loader_->last_song()) {
|
||||
current_albumcover_loader_->LoadAlbumCover(song);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -51,7 +51,13 @@ class QEvent;
|
||||
class QShowEvent;
|
||||
class QHideEvent;
|
||||
|
||||
class Application;
|
||||
class NetworkAccessManager;
|
||||
class CollectionBackend;
|
||||
class AlbumCoverLoader;
|
||||
class CurrentAlbumCoverLoader;
|
||||
class CoverProviders;
|
||||
class LyricsProviders;
|
||||
class StreamingServices;
|
||||
class AlbumCoverChoiceController;
|
||||
class Ui_EditTagDialog;
|
||||
#ifdef HAVE_MUSICBRAINZ
|
||||
@@ -64,7 +70,16 @@ class EditTagDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditTagDialog(Application *app, QWidget *parent = nullptr);
|
||||
explicit EditTagDialog(const SharedPtr<NetworkAccessManager> network,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<CollectionBackend> collection_backend,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const SharedPtr<CurrentAlbumCoverLoader> current_albumcover_loader,
|
||||
const SharedPtr<CoverProviders> cover_providers,
|
||||
const SharedPtr<LyricsProviders> lyrics_providers,
|
||||
const SharedPtr<StreamingServices> streaming_services,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
~EditTagDialog() override;
|
||||
|
||||
void SetSongs(const SongList &songs, const PlaylistItemPtrList &items = PlaylistItemPtrList());
|
||||
@@ -168,7 +183,7 @@ class EditTagDialog : public QDialog {
|
||||
void SetSongListVisibility(bool visible);
|
||||
|
||||
// Called by QtConcurrentRun
|
||||
static QList<Data> LoadData(const SongList &songs);
|
||||
QList<Data> LoadData(const SongList &songs) const;
|
||||
void SaveData();
|
||||
|
||||
static void SetText(QLabel *label, const int value, const QString &suffix, const QString &def = QString());
|
||||
@@ -180,7 +195,12 @@ class EditTagDialog : public QDialog {
|
||||
|
||||
Ui_EditTagDialog *ui_;
|
||||
|
||||
Application *app_;
|
||||
const SharedPtr<TagReaderClient> tagreader_client_;
|
||||
const SharedPtr<CollectionBackend> collection_backend_;
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader_;
|
||||
const SharedPtr<CurrentAlbumCoverLoader> current_albumcover_loader_;
|
||||
const SharedPtr<CoverProviders> cover_providers_;
|
||||
|
||||
AlbumCoverChoiceController *album_cover_choice_controller_;
|
||||
#ifdef HAVE_MUSICBRAINZ
|
||||
TagFetcher *tag_fetcher_;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "lastfmimportdialog.h"
|
||||
#include "ui_lastfmimportdialog.h"
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "scrobbler/lastfmimport.h"
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
|
||||
#include "ui_lastfmimportdialog.h"
|
||||
|
||||
|
||||
@@ -30,16 +30,16 @@
|
||||
#include "ui_saveplaylistsdialog.h"
|
||||
|
||||
#include "core/settings.h"
|
||||
#include "playlist/playlist.h"
|
||||
#include "constants/playlistsettings.h"
|
||||
|
||||
SavePlaylistsDialog::SavePlaylistsDialog(const QStringList &types, const QString &default_extension, QWidget *parent) : QDialog(parent), ui_(new Ui_SavePlaylistsDialog) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(Playlist::kSettingsGroup);
|
||||
QString last_save_path = s.value("last_save_all_path", QDir::homePath()).toString();
|
||||
QString last_save_extension = s.value("last_save_all_extension", default_extension).toString();
|
||||
s.beginGroup(PlaylistSettings::kSettingsGroup);
|
||||
QString last_save_path = s.value(PlaylistSettings::kLastSaveAllPath, QDir::homePath()).toString();
|
||||
QString last_save_extension = s.value(PlaylistSettings::kLastSaveAllExtension, default_extension).toString();
|
||||
s.endGroup();
|
||||
|
||||
ui_->lineedit_path->setText(last_save_path);
|
||||
@@ -81,9 +81,9 @@ void SavePlaylistsDialog::accept() {
|
||||
}
|
||||
|
||||
Settings s;
|
||||
s.beginGroup(Playlist::kSettingsGroup);
|
||||
s.setValue("last_save_all_path", path);
|
||||
s.setValue("last_save_all_extension", ui_->combobox_type->currentText());
|
||||
s.beginGroup(PlaylistSettings::kSettingsGroup);
|
||||
s.setValue(PlaylistSettings::kLastSaveAllPath, path);
|
||||
s.setValue(PlaylistSettings::kLastSaveAllExtension, ui_->combobox_type->currentText());
|
||||
s.endGroup();
|
||||
|
||||
QDialog::accept();
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "constants/mainwindowsettings.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/mainwindow.h"
|
||||
#include "utilities/screenutils.h"
|
||||
|
||||
#include "snapdialog.h"
|
||||
@@ -84,7 +84,7 @@ SnapDialog::SnapDialog(QWidget *parent) : MessageDialog(parent) {
|
||||
ui_->label_text->adjustSize();
|
||||
adjustSize();
|
||||
|
||||
settings_group_ = QLatin1String(MainWindow::kSettingsGroup);
|
||||
settings_group_ = QLatin1String(MainWindowSettings::kSettingsGroup);
|
||||
do_not_show_message_again_ = "ignore_snap"_L1;
|
||||
|
||||
if (parent) {
|
||||
|
||||
@@ -53,9 +53,10 @@
|
||||
#include "trackselectiondialog.h"
|
||||
#include "ui_trackselectiondialog.h"
|
||||
|
||||
TrackSelectionDialog::TrackSelectionDialog(QWidget *parent)
|
||||
TrackSelectionDialog::TrackSelectionDialog(const SharedPtr<TagReaderClient> tagreader_client, QWidget *parent)
|
||||
: QDialog(parent),
|
||||
ui_(new Ui_TrackSelectionDialog),
|
||||
tagreader_client_(tagreader_client),
|
||||
save_on_close_(false) {
|
||||
|
||||
// Setup dialog window
|
||||
@@ -261,10 +262,10 @@ void TrackSelectionDialog::SetLoading(const QString &message) {
|
||||
|
||||
}
|
||||
|
||||
void TrackSelectionDialog::SaveData(const QList<Data> &data) {
|
||||
void TrackSelectionDialog::SaveData(const QList<Data> &_data) const {
|
||||
|
||||
for (int i = 0; i < data.count(); ++i) {
|
||||
const Data &ref = data[i];
|
||||
for (int i = 0; i < _data.count(); ++i) {
|
||||
const Data &ref = _data[i];
|
||||
if (ref.pending_ || ref.results_.isEmpty() || ref.selected_result_ == -1) {
|
||||
continue;
|
||||
}
|
||||
@@ -278,7 +279,7 @@ void TrackSelectionDialog::SaveData(const QList<Data> &data) {
|
||||
copy.set_track(new_metadata.track());
|
||||
copy.set_year(new_metadata.year());
|
||||
|
||||
const TagReaderResult result = TagReaderClient::Instance()->WriteFileBlocking(copy.url().toLocalFile(), copy, TagReaderClient::SaveOption::Tags, SaveTagCoverData());
|
||||
const TagReaderResult result = tagreader_client_->WriteFileBlocking(copy.url().toLocalFile(), copy, TagReaderClient::SaveOption::Tags, SaveTagCoverData());
|
||||
if (!result.success()) {
|
||||
qLog(Error) << "Failed to write new auto-tags to" << copy.url().toLocalFile() << result.error_string();
|
||||
}
|
||||
@@ -292,7 +293,7 @@ void TrackSelectionDialog::accept() {
|
||||
SetLoading(tr("Saving tracks") + QStringLiteral("..."));
|
||||
|
||||
// Save tags in the background
|
||||
QFuture<void> future = QtConcurrent::run(&TrackSelectionDialog::SaveData, data_);
|
||||
QFuture<void> future = QtConcurrent::run(&TrackSelectionDialog::SaveData, this, data_);
|
||||
QFutureWatcher<void> *watcher = new QFutureWatcher<void>(this);
|
||||
QObject::connect(watcher, &QFutureWatcher<void>::finished, this, &TrackSelectionDialog::AcceptFinished);
|
||||
watcher->setFuture(future);
|
||||
|
||||
@@ -22,24 +22,27 @@
|
||||
#ifndef TRACKSELECTIONDIALOG_H
|
||||
#define TRACKSELECTIONDIALOG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "config.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class QWidget;
|
||||
class QTreeWidget;
|
||||
class QPushButton;
|
||||
class Ui_TrackSelectionDialog;
|
||||
class TagReaderClient;
|
||||
|
||||
class TrackSelectionDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TrackSelectionDialog(QWidget *parent = nullptr);
|
||||
explicit TrackSelectionDialog(const SharedPtr<TagReaderClient> tagreader_client, QWidget *parent = nullptr);
|
||||
~TrackSelectionDialog() override;
|
||||
|
||||
void set_save_on_close(bool save_on_close) { save_on_close_ = save_on_close; }
|
||||
@@ -83,9 +86,11 @@ class TrackSelectionDialog : public QDialog {
|
||||
static void AddSong(const Song &song, int result_index, QTreeWidget *parent);
|
||||
|
||||
void SetLoading(const QString &message);
|
||||
static void SaveData(const QList<Data> &data);
|
||||
void SaveData(const QList<Data> &data) const;
|
||||
|
||||
private:
|
||||
const SharedPtr<TagReaderClient> tagreader_client_;
|
||||
|
||||
QList<Data> data_;
|
||||
|
||||
QPushButton *previous_button_;
|
||||
|
||||
Reference in New Issue
Block a user