parent
d6b53f78ab
commit
2e61235403
@ -269,6 +269,7 @@ set(SOURCES
|
||||
radios/radioparadiseservice.cpp
|
||||
|
||||
scrobbler/audioscrobbler.cpp
|
||||
scrobbler/scrobblersettings.cpp
|
||||
scrobbler/scrobblerservice.cpp
|
||||
scrobbler/scrobblercache.cpp
|
||||
scrobbler/scrobblercacheitem.cpp
|
||||
@ -502,6 +503,7 @@ set(HEADERS
|
||||
radios/radioparadiseservice.h
|
||||
|
||||
scrobbler/audioscrobbler.h
|
||||
scrobbler/scrobblersettings.h
|
||||
scrobbler/scrobblerservice.h
|
||||
scrobbler/scrobblercache.h
|
||||
scrobbler/scrobblingapi20.h
|
||||
|
@ -24,9 +24,9 @@
|
||||
|
||||
#include "analyzerbase.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QVector>
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <QString>
|
||||
#include <QPainter>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "analyzer/fht.h"
|
||||
#include "engine/enginebase.h"
|
||||
|
||||
@ -54,7 +55,7 @@ class AnalyzerBase : public QWidget {
|
||||
|
||||
int timeout() const { return timeout_; }
|
||||
|
||||
void set_engine(EngineBase *engine) { engine_ = engine; }
|
||||
void set_engine(SharedPtr<EngineBase> engine) { engine_ = engine; }
|
||||
|
||||
void ChangeTimeout(const int timeout);
|
||||
|
||||
@ -82,7 +83,7 @@ class AnalyzerBase : public QWidget {
|
||||
protected:
|
||||
QBasicTimer timer_;
|
||||
FHT *fht_;
|
||||
EngineBase *engine_;
|
||||
SharedPtr<EngineBase> engine_;
|
||||
Scope lastscope_;
|
||||
|
||||
bool new_frame_;
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "sonogram.h"
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "engine/enginebase.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
@ -125,7 +126,7 @@ void AnalyzerContainer::wheelEvent(QWheelEvent *e) {
|
||||
emit WheelEvent(e->angleDelta().y());
|
||||
}
|
||||
|
||||
void AnalyzerContainer::SetEngine(EngineBase *engine) {
|
||||
void AnalyzerContainer::SetEngine(SharedPtr<EngineBase> engine) {
|
||||
|
||||
if (current_analyzer_) current_analyzer_->set_engine(engine);
|
||||
engine_ = engine;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "engine/enginebase.h"
|
||||
|
||||
class QTimer;
|
||||
@ -44,7 +45,7 @@ class AnalyzerContainer : public QWidget {
|
||||
public:
|
||||
explicit AnalyzerContainer(QWidget *parent);
|
||||
|
||||
void SetEngine(EngineBase *engine);
|
||||
void SetEngine(SharedPtr<EngineBase> engine);
|
||||
void SetActions(QAction *visualisation);
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
@ -93,7 +94,7 @@ class AnalyzerContainer : public QWidget {
|
||||
bool ignore_next_click_;
|
||||
|
||||
AnalyzerBase *current_analyzer_;
|
||||
EngineBase *engine_;
|
||||
SharedPtr<EngineBase> engine_;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
@ -43,6 +45,9 @@
|
||||
#include "scrobbler/lastfmimport.h"
|
||||
#include "settings/collectionsettingspage.h"
|
||||
|
||||
using std::make_unique;
|
||||
using std::make_shared;
|
||||
|
||||
const char *SCollection::kSongsTable = "songs";
|
||||
const char *SCollection::kFtsTable = "songs_fts";
|
||||
const char *SCollection::kDirsTable = "directories";
|
||||
@ -61,9 +66,9 @@ SCollection::SCollection(Application *app, QObject *parent)
|
||||
|
||||
original_thread_ = thread();
|
||||
|
||||
backend_ = new CollectionBackend();
|
||||
backend_ = make_shared<CollectionBackend>();
|
||||
backend()->moveToThread(app->database()->thread());
|
||||
qLog(Debug) << backend_ << "moved to thread" << app->database()->thread();
|
||||
qLog(Debug) << &*backend_ << "moved to thread" << app->database()->thread();
|
||||
|
||||
backend_->Init(app->database(), app->task_manager(), Song::Source::Collection, kSongsTable, kFtsTable, kDirsTable, kSubdirsTable);
|
||||
|
||||
@ -83,44 +88,43 @@ SCollection::~SCollection() {
|
||||
watcher_thread_->exit();
|
||||
watcher_thread_->wait(5000);
|
||||
}
|
||||
backend_->deleteLater();
|
||||
|
||||
}
|
||||
|
||||
void SCollection::Init() {
|
||||
|
||||
watcher_ = new CollectionWatcher(Song::Source::Collection);
|
||||
watcher_ = make_unique<CollectionWatcher>(Song::Source::Collection);
|
||||
watcher_thread_ = new Thread(this);
|
||||
|
||||
watcher_thread_->SetIoPriority(Utilities::IoPriority::IOPRIO_CLASS_IDLE);
|
||||
|
||||
watcher_->moveToThread(watcher_thread_);
|
||||
|
||||
qLog(Debug) << watcher_ << "moved to thread" << watcher_thread_;
|
||||
qLog(Debug) << &*watcher_ << "moved to thread" << watcher_thread_;
|
||||
|
||||
watcher_thread_->start(QThread::IdlePriority);
|
||||
|
||||
watcher_->set_backend(backend_);
|
||||
watcher_->set_task_manager(app_->task_manager());
|
||||
|
||||
QObject::connect(backend_, &CollectionBackend::Error, this, &SCollection::Error);
|
||||
QObject::connect(backend_, &CollectionBackend::DirectoryDiscovered, watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(backend_, &CollectionBackend::DirectoryDeleted, watcher_, &CollectionWatcher::RemoveDirectory);
|
||||
QObject::connect(backend_, &CollectionBackend::SongsRatingChanged, this, &SCollection::SongsRatingChanged);
|
||||
QObject::connect(backend_, &CollectionBackend::SongsStatisticsChanged, this, &SCollection::SongsPlaycountChanged);
|
||||
QObject::connect(&*backend_, &CollectionBackend::Error, this, &SCollection::Error);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDiscovered, &*watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDeleted, &*watcher_, &CollectionWatcher::RemoveDirectory);
|
||||
QObject::connect(&*backend_, &CollectionBackend::SongsRatingChanged, this, &SCollection::SongsRatingChanged);
|
||||
QObject::connect(&*backend_, &CollectionBackend::SongsStatisticsChanged, this, &SCollection::SongsPlaycountChanged);
|
||||
|
||||
QObject::connect(watcher_, &CollectionWatcher::NewOrUpdatedSongs, backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsMTimeUpdated, backend_, &CollectionBackend::UpdateMTimesOnly);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsDeleted, backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsUnavailable, backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsReadded, backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SubdirsDiscovered, backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SubdirsMTimeUpdated, backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::CompilationsNeedUpdating, backend_, &CollectionBackend::CompilationsNeedUpdating);
|
||||
QObject::connect(watcher_, &CollectionWatcher::UpdateLastSeen, backend_, &CollectionBackend::UpdateLastSeen);
|
||||
QObject::connect(&*watcher_, &CollectionWatcher::NewOrUpdatedSongs, &*backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(&*watcher_, &CollectionWatcher::SongsMTimeUpdated, &*backend_, &CollectionBackend::UpdateMTimesOnly);
|
||||
QObject::connect(&*watcher_, &CollectionWatcher::SongsDeleted, &*backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(&*watcher_, &CollectionWatcher::SongsUnavailable, &*backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(&*watcher_, &CollectionWatcher::SongsReadded, &*backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(&*watcher_, &CollectionWatcher::SubdirsDiscovered, &*backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(&*watcher_, &CollectionWatcher::SubdirsMTimeUpdated, &*backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(&*watcher_, &CollectionWatcher::CompilationsNeedUpdating, &*backend_, &CollectionBackend::CompilationsNeedUpdating);
|
||||
QObject::connect(&*watcher_, &CollectionWatcher::UpdateLastSeen, &*backend_, &CollectionBackend::UpdateLastSeen);
|
||||
|
||||
QObject::connect(app_->lastfm_import(), &LastFMImport::UpdateLastPlayed, backend_, &CollectionBackend::UpdateLastPlayed);
|
||||
QObject::connect(app_->lastfm_import(), &LastFMImport::UpdatePlayCount, backend_, &CollectionBackend::UpdatePlayCount);
|
||||
QObject::connect(&*app_->lastfm_import(), &LastFMImport::UpdateLastPlayed, &*backend_, &CollectionBackend::UpdateLastPlayed);
|
||||
QObject::connect(&*app_->lastfm_import(), &LastFMImport::UpdatePlayCount, &*backend_, &CollectionBackend::UpdatePlayCount);
|
||||
|
||||
// This will start the watcher checking for updates
|
||||
backend_->LoadDirectoriesAsync();
|
||||
@ -129,13 +133,13 @@ void SCollection::Init() {
|
||||
|
||||
void SCollection::Exit() {
|
||||
|
||||
wait_for_exit_ << backend_ << watcher_;
|
||||
wait_for_exit_ << &*backend_ << &*watcher_;
|
||||
|
||||
QObject::disconnect(backend_, nullptr, watcher_, nullptr);
|
||||
QObject::disconnect(watcher_, nullptr, backend_, nullptr);
|
||||
QObject::disconnect(&*backend_, nullptr, &*watcher_, nullptr);
|
||||
QObject::disconnect(&*watcher_, nullptr, &*backend_, nullptr);
|
||||
|
||||
QObject::connect(backend_, &CollectionBackend::ExitFinished, this, &SCollection::ExitReceived);
|
||||
QObject::connect(watcher_, &CollectionWatcher::ExitFinished, this, &SCollection::ExitReceived);
|
||||
QObject::connect(&*backend_, &CollectionBackend::ExitFinished, this, &SCollection::ExitReceived);
|
||||
QObject::connect(&*watcher_, &CollectionWatcher::ExitFinished, this, &SCollection::ExitReceived);
|
||||
backend_->ExitAsync();
|
||||
watcher_->Abort();
|
||||
watcher_->ExitAsync();
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class QThread;
|
||||
@ -42,7 +44,7 @@ class SCollection : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SCollection(Application *app, QObject *parent);
|
||||
explicit SCollection(Application *app, QObject *parent = nullptr);
|
||||
~SCollection() override;
|
||||
|
||||
static const char *kSongsTable;
|
||||
@ -53,7 +55,7 @@ class SCollection : public QObject {
|
||||
void Init();
|
||||
void Exit();
|
||||
|
||||
CollectionBackend *backend() const { return backend_; }
|
||||
SharedPtr<CollectionBackend> backend() const { return backend_; }
|
||||
CollectionModel *model() const { return model_; }
|
||||
|
||||
QString full_rescan_reason(int schema_version) const { return full_rescan_revisions_.value(schema_version, QString()); }
|
||||
@ -86,10 +88,10 @@ class SCollection : public QObject {
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
CollectionBackend *backend_;
|
||||
SharedPtr<CollectionBackend> backend_;
|
||||
CollectionModel *model_;
|
||||
|
||||
CollectionWatcher *watcher_;
|
||||
ScopedPtr<CollectionWatcher> watcher_;
|
||||
Thread *watcher_thread_;
|
||||
QThread *original_thread_;
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/database.h"
|
||||
#include "core/scopedtransaction.h"
|
||||
@ -67,7 +68,13 @@ CollectionBackend::CollectionBackend(QObject *parent)
|
||||
|
||||
}
|
||||
|
||||
void CollectionBackend::Init(Database *db, TaskManager *task_manager, const Song::Source source, const QString &songs_table, const QString &fts_table, const QString &dirs_table, const QString &subdirs_table) {
|
||||
CollectionBackend::~CollectionBackend() {
|
||||
|
||||
qLog(Debug) << "Collection backend" << this << "for" << Song::TextForSource(source_) << "deleted";
|
||||
|
||||
}
|
||||
|
||||
void CollectionBackend::Init(SharedPtr<Database> db, SharedPtr<TaskManager> task_manager, const Song::Source source, const QString &songs_table, const QString &fts_table, const QString &dirs_table, const QString &subdirs_table) {
|
||||
|
||||
db_ = db;
|
||||
task_manager_ = task_manager;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <optional>
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
@ -35,6 +36,7 @@
|
||||
#include <QUrl>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "collectionfilteroptions.h"
|
||||
#include "collectionquery.h"
|
||||
@ -82,7 +84,7 @@ class CollectionBackendInterface : public QObject {
|
||||
|
||||
virtual Song::Source source() const = 0;
|
||||
|
||||
virtual Database *db() const = 0;
|
||||
virtual SharedPtr<Database> db() const = 0;
|
||||
|
||||
// Get a list of directories in the collection. Emits DirectoriesDiscovered.
|
||||
virtual void LoadDirectoriesAsync() = 0;
|
||||
@ -140,7 +142,9 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
|
||||
Q_INVOKABLE explicit CollectionBackend(QObject *parent = nullptr);
|
||||
|
||||
void Init(Database *db, TaskManager *task_manager, const Song::Source source, const QString &songs_table, const QString &fts_table, const QString &dirs_table = QString(), const QString &subdirs_table = QString());
|
||||
~CollectionBackend();
|
||||
|
||||
void Init(SharedPtr<Database> db, SharedPtr<TaskManager> task_manager, const Song::Source source, const QString &songs_table, const QString &fts_table, const QString &dirs_table = QString(), const QString &subdirs_table = QString());
|
||||
void Close();
|
||||
|
||||
void ExitAsync();
|
||||
@ -149,7 +153,7 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
|
||||
Song::Source source() const override { return source_; }
|
||||
|
||||
Database *db() const override { return db_; }
|
||||
SharedPtr<Database> db() const override { return db_; }
|
||||
|
||||
QString songs_table() const override { return songs_table_; }
|
||||
QString fts_table() const override { return fts_table_; }
|
||||
@ -305,8 +309,8 @@ class CollectionBackend : public CollectionBackendInterface {
|
||||
SongList GetSongsBySongId(const QStringList &song_ids, QSqlDatabase &db);
|
||||
|
||||
private:
|
||||
Database *db_;
|
||||
TaskManager *task_manager_;
|
||||
SharedPtr<Database> db_;
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
Song::Source source_;
|
||||
QString songs_table_;
|
||||
QString dirs_table_;
|
||||
|
@ -20,12 +20,15 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QStandardItemModel>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/filesystemmusicstorage.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/musicstorage.h"
|
||||
@ -34,24 +37,24 @@
|
||||
#include "collectionbackend.h"
|
||||
#include "collectiondirectorymodel.h"
|
||||
|
||||
CollectionDirectoryModel::CollectionDirectoryModel(CollectionBackend *backend, QObject *parent)
|
||||
using std::make_shared;
|
||||
|
||||
CollectionDirectoryModel::CollectionDirectoryModel(SharedPtr<CollectionBackend> backend, QObject *parent)
|
||||
: QStandardItemModel(parent),
|
||||
dir_icon_(IconLoader::Load("document-open-folder")),
|
||||
backend_(backend) {
|
||||
|
||||
QObject::connect(backend_, &CollectionBackend::DirectoryDiscovered, this, &CollectionDirectoryModel::DirectoryDiscovered);
|
||||
QObject::connect(backend_, &CollectionBackend::DirectoryDeleted, this, &CollectionDirectoryModel::DirectoryDeleted);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDiscovered, this, &CollectionDirectoryModel::DirectoryDiscovered);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDeleted, this, &CollectionDirectoryModel::DirectoryDeleted);
|
||||
|
||||
}
|
||||
|
||||
CollectionDirectoryModel::~CollectionDirectoryModel() = default;
|
||||
|
||||
void CollectionDirectoryModel::DirectoryDiscovered(const CollectionDirectory &dir) {
|
||||
|
||||
QStandardItem *item = new QStandardItem(dir.path);
|
||||
item->setData(dir.id, kIdRole);
|
||||
item->setIcon(dir_icon_);
|
||||
storage_ << std::make_shared<FilesystemMusicStorage>(backend_->source(), dir.path, dir.id);
|
||||
storage_ << make_shared<FilesystemMusicStorage>(backend_->source(), dir.path, dir.id);
|
||||
appendRow(item);
|
||||
|
||||
}
|
||||
|
@ -23,8 +23,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QStandardItemModel>
|
||||
#include <QList>
|
||||
@ -32,6 +30,8 @@
|
||||
#include <QString>
|
||||
#include <QIcon>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
class QModelIndex;
|
||||
|
||||
struct CollectionDirectory;
|
||||
@ -42,8 +42,7 @@ class CollectionDirectoryModel : public QStandardItemModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CollectionDirectoryModel(CollectionBackend *backend, QObject *parent = nullptr);
|
||||
~CollectionDirectoryModel() override;
|
||||
explicit CollectionDirectoryModel(SharedPtr<CollectionBackend> collection_backend, QObject *parent = nullptr);
|
||||
|
||||
// To be called by GUIs
|
||||
void AddDirectory(const QString &path);
|
||||
@ -60,8 +59,8 @@ class CollectionDirectoryModel : public QStandardItemModel {
|
||||
static const int kIdRole = Qt::UserRole + 1;
|
||||
|
||||
QIcon dir_icon_;
|
||||
CollectionBackend *backend_;
|
||||
QList<std::shared_ptr<MusicStorage>> storage_;
|
||||
SharedPtr<CollectionBackend> backend_;
|
||||
QList<SharedPtr<MusicStorage>> storage_;
|
||||
};
|
||||
|
||||
#endif // COLLECTIONDIRECTORYMODEL_H
|
||||
|
@ -53,6 +53,8 @@
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/database.h"
|
||||
#include "core/iconloader.h"
|
||||
@ -78,7 +80,7 @@ const char *CollectionModel::kPixmapDiskCacheDir = "pixmapcache";
|
||||
|
||||
QNetworkDiskCache *CollectionModel::sIconCache = nullptr;
|
||||
|
||||
CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, QObject *parent)
|
||||
CollectionModel::CollectionModel(SharedPtr<CollectionBackend> backend, Application *app, QObject *parent)
|
||||
: SimpleTreeModel<CollectionItem>(new CollectionItem(this), parent),
|
||||
backend_(backend),
|
||||
app_(app),
|
||||
@ -103,7 +105,7 @@ CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, Q
|
||||
group_by_[2] = GroupBy::None;
|
||||
|
||||
if (app_) {
|
||||
QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &CollectionModel::AlbumCoverLoaded);
|
||||
QObject::connect(&*app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &CollectionModel::AlbumCoverLoaded);
|
||||
}
|
||||
|
||||
QIcon nocover = IconLoader::Load("cdcase");
|
||||
@ -118,14 +120,14 @@ CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, Q
|
||||
QObject::connect(app_, &Application::ClearPixmapDiskCache, this, &CollectionModel::ClearDiskCache);
|
||||
}
|
||||
|
||||
QObject::connect(backend_, &CollectionBackend::SongsDiscovered, this, &CollectionModel::SongsDiscovered);
|
||||
QObject::connect(backend_, &CollectionBackend::SongsDeleted, this, &CollectionModel::SongsDeleted);
|
||||
QObject::connect(backend_, &CollectionBackend::DatabaseReset, this, &CollectionModel::Reset);
|
||||
QObject::connect(backend_, &CollectionBackend::TotalSongCountUpdated, this, &CollectionModel::TotalSongCountUpdatedSlot);
|
||||
QObject::connect(backend_, &CollectionBackend::TotalArtistCountUpdated, this, &CollectionModel::TotalArtistCountUpdatedSlot);
|
||||
QObject::connect(backend_, &CollectionBackend::TotalAlbumCountUpdated, this, &CollectionModel::TotalAlbumCountUpdatedSlot);
|
||||
QObject::connect(backend_, &CollectionBackend::SongsStatisticsChanged, this, &CollectionModel::SongsSlightlyChanged);
|
||||
QObject::connect(backend_, &CollectionBackend::SongsRatingChanged, this, &CollectionModel::SongsSlightlyChanged);
|
||||
QObject::connect(&*backend_, &CollectionBackend::SongsDiscovered, this, &CollectionModel::SongsDiscovered);
|
||||
QObject::connect(&*backend_, &CollectionBackend::SongsDeleted, this, &CollectionModel::SongsDeleted);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DatabaseReset, this, &CollectionModel::Reset);
|
||||
QObject::connect(&*backend_, &CollectionBackend::TotalSongCountUpdated, this, &CollectionModel::TotalSongCountUpdatedSlot);
|
||||
QObject::connect(&*backend_, &CollectionBackend::TotalArtistCountUpdated, this, &CollectionModel::TotalArtistCountUpdatedSlot);
|
||||
QObject::connect(&*backend_, &CollectionBackend::TotalAlbumCountUpdated, this, &CollectionModel::TotalAlbumCountUpdatedSlot);
|
||||
QObject::connect(&*backend_, &CollectionBackend::SongsStatisticsChanged, this, &CollectionModel::SongsSlightlyChanged);
|
||||
QObject::connect(&*backend_, &CollectionBackend::SongsRatingChanged, this, &CollectionModel::SongsSlightlyChanged);
|
||||
|
||||
backend_->UpdateTotalSongCountAsync();
|
||||
backend_->UpdateTotalArtistCountAsync();
|
||||
@ -136,7 +138,11 @@ CollectionModel::CollectionModel(CollectionBackend *backend, Application *app, Q
|
||||
}
|
||||
|
||||
CollectionModel::~CollectionModel() {
|
||||
|
||||
qLog(Debug) << "Collection model" << this << "for" << Song::TextForSource(backend_->source()) << "deleted";
|
||||
|
||||
delete root_;
|
||||
|
||||
}
|
||||
|
||||
void CollectionModel::set_pretty_covers(const bool use_pretty_covers) {
|
||||
@ -632,10 +638,10 @@ QVariant CollectionModel::AlbumIcon(const QModelIndex &idx) {
|
||||
|
||||
// Try to load it from the disk cache
|
||||
if (use_disk_cache_ && sIconCache) {
|
||||
std::unique_ptr<QIODevice> disk_cache_img(sIconCache->data(AlbumIconPixmapDiskCacheKey(cache_key)));
|
||||
ScopedPtr<QIODevice> disk_cache_img(sIconCache->data(AlbumIconPixmapDiskCacheKey(cache_key)));
|
||||
if (disk_cache_img) {
|
||||
QImage cached_image;
|
||||
if (cached_image.load(disk_cache_img.get(), "XPM")) {
|
||||
if (cached_image.load(&*disk_cache_img, "XPM")) {
|
||||
QPixmapCache::insert(cache_key, QPixmap::fromImage(cached_image));
|
||||
return QPixmap::fromImage(cached_image);
|
||||
}
|
||||
@ -688,7 +694,7 @@ void CollectionModel::AlbumCoverLoaded(const quint64 id, const AlbumCoverLoaderR
|
||||
// If we have a valid cover not already in the disk cache
|
||||
if (use_disk_cache_ && sIconCache && result.success && !result.image_scaled.isNull()) {
|
||||
const QUrl disk_cache_key = AlbumIconPixmapDiskCacheKey(cache_key);
|
||||
std::unique_ptr<QIODevice> disk_cache_img(sIconCache->data(disk_cache_key));
|
||||
ScopedPtr<QIODevice> disk_cache_img(sIconCache->data(disk_cache_key));
|
||||
if (!disk_cache_img) {
|
||||
QNetworkCacheMetaData disk_cache_metadata;
|
||||
disk_cache_metadata.setSaveToDisk(true);
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <QPixmap>
|
||||
#include <QNetworkDiskCache>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/simpletreemodel.h"
|
||||
#include "core/song.h"
|
||||
#include "core/sqlrow.h"
|
||||
@ -64,7 +65,7 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CollectionModel(CollectionBackend *backend, Application *app, QObject *parent = nullptr);
|
||||
explicit CollectionModel(SharedPtr<CollectionBackend> backend, Application *app, QObject *parent = nullptr);
|
||||
~CollectionModel() override;
|
||||
|
||||
static const int kPrettyCoverSize;
|
||||
@ -131,7 +132,7 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
bool create_va;
|
||||
};
|
||||
|
||||
CollectionBackend *backend() const { return backend_; }
|
||||
SharedPtr<CollectionBackend> backend() const { return backend_; }
|
||||
CollectionDirectoryModel *directory_model() const { return dir_model_; }
|
||||
|
||||
// Call before Init()
|
||||
@ -273,7 +274,7 @@ class CollectionModel : public SimpleTreeModel<CollectionItem> {
|
||||
static qint64 MaximumCacheSize(QSettings *s, const char *size_id, const char *size_unit_id, const qint64 cache_size_default);
|
||||
|
||||
private:
|
||||
CollectionBackend *backend_;
|
||||
SharedPtr<CollectionBackend> backend_;
|
||||
Application *app_;
|
||||
CollectionDirectoryModel *dir_model_;
|
||||
bool show_various_artists_;
|
||||
|
@ -19,10 +19,11 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "collectiontask.h"
|
||||
|
||||
CollectionTask::CollectionTask(TaskManager *task_manager, const QString &message) : task_manager_(task_manager), task_id_(-1) {
|
||||
CollectionTask::CollectionTask(SharedPtr<TaskManager> task_manager, const QString &message) : task_manager_(task_manager), task_id_(-1) {
|
||||
|
||||
if (task_manager_) task_id_ = task_manager_->StartTask(message);
|
||||
|
||||
|
@ -23,15 +23,17 @@
|
||||
#include <QtGlobal>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
class TaskManager;
|
||||
|
||||
class CollectionTask {
|
||||
public:
|
||||
explicit CollectionTask(TaskManager *task_manager, const QString &message);
|
||||
explicit CollectionTask(SharedPtr<TaskManager> task_manager, const QString &message);
|
||||
~CollectionTask();
|
||||
|
||||
private:
|
||||
TaskManager *task_manager_;
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
int task_id_;
|
||||
|
||||
Q_DISABLE_COPY(CollectionTask)
|
||||
|
@ -71,6 +71,8 @@
|
||||
#include "organize/organizeerrordialog.h"
|
||||
#include "settings/collectionsettingspage.h"
|
||||
|
||||
using std::make_unique;
|
||||
|
||||
CollectionView::CollectionView(QWidget *parent)
|
||||
: AutoExpandingTreeView(parent),
|
||||
app_(nullptr),
|
||||
@ -573,7 +575,7 @@ SongList CollectionView::GetSelectedSongs() const {
|
||||
void CollectionView::Organize() {
|
||||
|
||||
if (!organize_dialog_) {
|
||||
organize_dialog_ = std::make_unique<OrganizeDialog>(app_->task_manager(), app_->collection_backend(), this);
|
||||
organize_dialog_ = make_unique<OrganizeDialog>(app_->task_manager(), app_->collection_backend(), this);
|
||||
}
|
||||
|
||||
organize_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||
@ -591,8 +593,8 @@ void CollectionView::Organize() {
|
||||
void CollectionView::EditTracks() {
|
||||
|
||||
if (!edit_tag_dialog_) {
|
||||
edit_tag_dialog_ = std::make_unique<EditTagDialog>(app_, this);
|
||||
QObject::connect(edit_tag_dialog_.get(), &EditTagDialog::Error, this, &CollectionView::EditTagError);
|
||||
edit_tag_dialog_ = make_unique<EditTagDialog>(app_, this);
|
||||
QObject::connect(&*edit_tag_dialog_, &EditTagDialog::Error, this, &CollectionView::EditTagError);
|
||||
}
|
||||
const SongList songs = GetSelectedSongs();
|
||||
edit_tag_dialog_->SetSongs(songs);
|
||||
@ -614,7 +616,7 @@ void CollectionView::CopyToDevice() {
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
if (!organize_dialog_) {
|
||||
organize_dialog_ = std::make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
organize_dialog_ = make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
}
|
||||
|
||||
organize_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
||||
@ -686,7 +688,7 @@ void CollectionView::Delete() {
|
||||
if (DeleteConfirmationDialog::warning(files) != QDialogButtonBox::Yes) return;
|
||||
|
||||
// We can cheat and always take the storage of the first directory, since they'll all be FilesystemMusicStorage in a collection and deleting doesn't check the actual directory.
|
||||
std::shared_ptr<MusicStorage> storage = app_->collection_model()->directory_model()->index(0, 0).data(MusicStorage::Role_Storage).value<std::shared_ptr<MusicStorage>>();
|
||||
SharedPtr<MusicStorage> storage = app_->collection_model()->directory_model()->index(0, 0).data(MusicStorage::Role_Storage).value<SharedPtr<MusicStorage>>();
|
||||
|
||||
DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true);
|
||||
QObject::connect(delete_files, &DeleteFiles::Finished, this, &CollectionView::DeleteFilesFinished);
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAbstractItemView>
|
||||
@ -33,6 +31,7 @@
|
||||
#include <QPixmap>
|
||||
#include <QSet>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "widgets/autoexpandingtreeview.h"
|
||||
|
||||
@ -148,8 +147,8 @@ class CollectionView : public AutoExpandingTreeView {
|
||||
QAction *action_no_show_in_various_;
|
||||
QAction *action_delete_files_;
|
||||
|
||||
std::unique_ptr<OrganizeDialog> organize_dialog_;
|
||||
std::unique_ptr<EditTagDialog> edit_tag_dialog_;
|
||||
ScopedPtr<OrganizeDialog> organize_dialog_;
|
||||
ScopedPtr<EditTagDialog> edit_tag_dialog_;
|
||||
|
||||
bool is_in_keyboard_search_;
|
||||
bool delete_files_;
|
||||
|
@ -119,6 +119,12 @@ CollectionWatcher::CollectionWatcher(Song::Source source, QObject *parent)
|
||||
|
||||
}
|
||||
|
||||
CollectionWatcher::~CollectionWatcher() {
|
||||
|
||||
qLog(Debug) << "Collection watcher" << this << "for" << Song::TextForSource(source_) << "deleted.";
|
||||
|
||||
}
|
||||
|
||||
void CollectionWatcher::ExitAsync() {
|
||||
QMetaObject::invokeMethod(this, &CollectionWatcher::Exit, Qt::QueuedConnection);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <QUrl>
|
||||
|
||||
#include "collectiondirectory.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class QThread;
|
||||
@ -50,11 +51,12 @@ class CollectionWatcher : public QObject {
|
||||
|
||||
public:
|
||||
explicit CollectionWatcher(Song::Source source, QObject *parent = nullptr);
|
||||
~CollectionWatcher();
|
||||
|
||||
Song::Source source() { return source_; }
|
||||
|
||||
void set_backend(CollectionBackend *backend) { backend_ = backend; }
|
||||
void set_task_manager(TaskManager *task_manager) { task_manager_ = task_manager; }
|
||||
void set_backend(SharedPtr<CollectionBackend> backend) { backend_ = backend; }
|
||||
void set_task_manager(SharedPtr<TaskManager> task_manager) { task_manager_ = task_manager; }
|
||||
void set_device_name(const QString &device_name) { device_name_ = device_name; }
|
||||
|
||||
void IncrementalScanAsync();
|
||||
@ -208,8 +210,8 @@ class CollectionWatcher : public QObject {
|
||||
|
||||
private:
|
||||
Song::Source source_;
|
||||
CollectionBackend *backend_;
|
||||
TaskManager *task_manager_;
|
||||
SharedPtr<CollectionBackend> backend_;
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
QString device_name_;
|
||||
|
||||
FileSystemWatcherInterface *fs_watcher_;
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
@ -41,6 +41,8 @@
|
||||
#include <boost/multi_index_container_fwd.hpp>
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
using std::make_unique;
|
||||
|
||||
using boost::multi_index_container;
|
||||
using boost::multi_index::indexed_by;
|
||||
using boost::multi_index::ordered_unique;
|
||||
@ -69,7 +71,7 @@ class GroupByDialogPrivate {
|
||||
MappingContainer mapping_;
|
||||
};
|
||||
|
||||
GroupByDialog::GroupByDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_GroupByDialog), p_(new GroupByDialogPrivate) {
|
||||
GroupByDialog::GroupByDialog(QWidget *parent) : QDialog(parent), ui_(make_unique<Ui_GroupByDialog>()), p_(make_unique<GroupByDialogPrivate>()) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
Reset();
|
||||
|
@ -24,12 +24,11 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "collectionmodel.h"
|
||||
#include "ui_groupbydialog.h"
|
||||
|
||||
@ -55,8 +54,8 @@ class GroupByDialog : public QDialog {
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_GroupByDialog> ui_;
|
||||
std::unique_ptr<GroupByDialogPrivate> p_;
|
||||
ScopedPtr<Ui_GroupByDialog> ui_;
|
||||
ScopedPtr<GroupByDialogPrivate> p_;
|
||||
};
|
||||
|
||||
#endif // GROUPBYDIALOG_H
|
||||
|
@ -37,12 +37,16 @@
|
||||
#include <QContextMenuEvent>
|
||||
#include <QPaintEvent>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "utilities/imageutils.h"
|
||||
#include "covermanager/albumcoverchoicecontroller.h"
|
||||
|
||||
#include "contextview.h"
|
||||
#include "contextalbum.h"
|
||||
|
||||
using std::make_unique;
|
||||
using std::make_shared;
|
||||
|
||||
const int ContextAlbum::kFadeTimeLineMs = 1000;
|
||||
|
||||
ContextAlbum::ContextAlbum(QWidget *parent)
|
||||
@ -155,15 +159,15 @@ void ContextAlbum::SetImage(QImage image) {
|
||||
ScaleCover();
|
||||
|
||||
if (!pixmap_previous.isNull()) {
|
||||
std::shared_ptr<PreviousCover> previous_cover = std::make_shared<PreviousCover>();
|
||||
SharedPtr<PreviousCover> previous_cover = make_shared<PreviousCover>();
|
||||
previous_cover->image = image_previous;
|
||||
previous_cover->pixmap = pixmap_previous;
|
||||
previous_cover->opacity = opacity_previous;
|
||||
previous_cover->timeline.reset(new QTimeLine(kFadeTimeLineMs), [](QTimeLine *timeline) { timeline->deleteLater(); });
|
||||
previous_cover->timeline->setDirection(QTimeLine::Backward);
|
||||
previous_cover->timeline->setCurrentTime(timeline_fade_->state() == QTimeLine::Running ? timeline_fade_->currentTime() : kFadeTimeLineMs);
|
||||
QObject::connect(previous_cover->timeline.get(), &QTimeLine::valueChanged, this, [this, previous_cover]() { FadePreviousCover(previous_cover); });
|
||||
QObject::connect(previous_cover->timeline.get(), &QTimeLine::finished, this, [this, previous_cover]() { FadePreviousCoverFinished(previous_cover); });
|
||||
QObject::connect(&*previous_cover->timeline, &QTimeLine::valueChanged, this, [this, previous_cover]() { FadePreviousCover(previous_cover); });
|
||||
QObject::connect(&*previous_cover->timeline, &QTimeLine::finished, this, [this, previous_cover]() { FadePreviousCoverFinished(previous_cover); });
|
||||
previous_covers_ << previous_cover;
|
||||
previous_cover->timeline->start();
|
||||
}
|
||||
@ -194,7 +198,7 @@ void ContextAlbum::DrawSpinner(QPainter *p) {
|
||||
|
||||
void ContextAlbum::DrawPreviousCovers(QPainter *p) {
|
||||
|
||||
for (std::shared_ptr<PreviousCover> previous_cover : previous_covers_) {
|
||||
for (SharedPtr<PreviousCover> previous_cover : previous_covers_) {
|
||||
DrawImage(p, previous_cover->pixmap, previous_cover->opacity);
|
||||
}
|
||||
|
||||
@ -217,7 +221,7 @@ void ContextAlbum::FadeCurrentCoverFinished() {
|
||||
|
||||
}
|
||||
|
||||
void ContextAlbum::FadePreviousCover(std::shared_ptr<PreviousCover> previous_cover) {
|
||||
void ContextAlbum::FadePreviousCover(SharedPtr<PreviousCover> previous_cover) {
|
||||
|
||||
if (previous_cover->timeline->currentValue() >= previous_cover->opacity) return;
|
||||
|
||||
@ -225,7 +229,7 @@ void ContextAlbum::FadePreviousCover(std::shared_ptr<PreviousCover> previous_cov
|
||||
|
||||
}
|
||||
|
||||
void ContextAlbum::FadePreviousCoverFinished(std::shared_ptr<PreviousCover> previous_cover) {
|
||||
void ContextAlbum::FadePreviousCoverFinished(SharedPtr<PreviousCover> previous_cover) {
|
||||
|
||||
previous_covers_.removeAll(previous_cover);
|
||||
|
||||
@ -245,7 +249,7 @@ void ContextAlbum::ScaleCover() {
|
||||
|
||||
void ContextAlbum::ScalePreviousCovers() {
|
||||
|
||||
for (std::shared_ptr<PreviousCover> previous_cover : previous_covers_) {
|
||||
for (SharedPtr<PreviousCover> previous_cover : previous_covers_) {
|
||||
QImage image = ImageUtils::ScaleImage(previous_cover->image, QSize(desired_height_, desired_height_), devicePixelRatioF(), true);
|
||||
if (image.isNull()) {
|
||||
previous_cover->pixmap = QPixmap();
|
||||
@ -262,8 +266,8 @@ void ContextAlbum::SearchCoverInProgress() {
|
||||
downloading_covers_ = true;
|
||||
|
||||
// Show a spinner animation
|
||||
spinner_animation_ = std::make_unique<QMovie>(":/pictures/spinner.gif", QByteArray(), this);
|
||||
QObject::connect(spinner_animation_.get(), &QMovie::updated, this, &ContextAlbum::Update);
|
||||
spinner_animation_ = make_unique<QMovie>(":/pictures/spinner.gif", QByteArray(), this);
|
||||
QObject::connect(&*spinner_animation_, &QMovie::updated, this, &ContextAlbum::Update);
|
||||
spinner_animation_->start();
|
||||
update();
|
||||
|
||||
|
@ -33,6 +33,9 @@
|
||||
#include <QPixmap>
|
||||
#include <QMovie>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
class QMenu;
|
||||
class QTimeLine;
|
||||
class QPainter;
|
||||
@ -64,10 +67,10 @@ class ContextAlbum : public QWidget {
|
||||
QImage image;
|
||||
QPixmap pixmap;
|
||||
qreal opacity;
|
||||
std::shared_ptr<QTimeLine> timeline;
|
||||
SharedPtr<QTimeLine> timeline;
|
||||
};
|
||||
|
||||
QList<std::shared_ptr<PreviousCover>> previous_covers_;
|
||||
QList<SharedPtr<PreviousCover>> previous_covers_;
|
||||
|
||||
void DrawImage(QPainter *p, const QPixmap &pixmap, const qreal opacity);
|
||||
void DrawSpinner(QPainter *p);
|
||||
@ -84,8 +87,8 @@ class ContextAlbum : public QWidget {
|
||||
void AutomaticCoverSearchDone();
|
||||
void FadeCurrentCover(const qreal value);
|
||||
void FadeCurrentCoverFinished();
|
||||
void FadePreviousCover(std::shared_ptr<PreviousCover> previouscover);
|
||||
void FadePreviousCoverFinished(std::shared_ptr<PreviousCover> previouscover);
|
||||
void FadePreviousCover(SharedPtr<PreviousCover> previouscover);
|
||||
void FadePreviousCoverFinished(SharedPtr<PreviousCover> previouscover);
|
||||
|
||||
public slots:
|
||||
void SearchCoverInProgress();
|
||||
@ -103,7 +106,7 @@ class ContextAlbum : public QWidget {
|
||||
QImage image_original_;
|
||||
QPixmap pixmap_current_;
|
||||
qreal pixmap_current_opacity_;
|
||||
std::unique_ptr<QMovie> spinner_animation_;
|
||||
ScopedPtr<QMovie> spinner_animation_;
|
||||
int desired_height_;
|
||||
};
|
||||
|
||||
|
@ -31,10 +31,11 @@
|
||||
#include <QThread>
|
||||
#include <QString>
|
||||
|
||||
#include "core/lazy.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "core/logging.h"
|
||||
|
||||
#include "shared_ptr.h"
|
||||
#include "lazy.h"
|
||||
#include "tagreaderclient.h"
|
||||
#include "database.h"
|
||||
#include "taskmanager.h"
|
||||
#include "player.h"
|
||||
@ -98,99 +99,103 @@
|
||||
#include "radios/radioservices.h"
|
||||
#include "radios/radiobackend.h"
|
||||
|
||||
using std::make_shared;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
class ApplicationImpl {
|
||||
public:
|
||||
explicit ApplicationImpl(Application *app) :
|
||||
tag_reader_client_([app]() {
|
||||
TagReaderClient *client = new TagReaderClient(app);
|
||||
tag_reader_client_([app](){
|
||||
TagReaderClient *client = new TagReaderClient();
|
||||
app->MoveToNewThread(client);
|
||||
client->Start();
|
||||
return client;
|
||||
}),
|
||||
database_([app]() {
|
||||
Database *db = new Database(app, app);
|
||||
Database *db = new Database(app);
|
||||
app->MoveToNewThread(db);
|
||||
QTimer::singleShot(30s, db, &Database::DoBackup);
|
||||
return db;
|
||||
}),
|
||||
task_manager_([app]() { return new TaskManager(app); }),
|
||||
player_([app]() { return new Player(app, app); }),
|
||||
network_([app]() { return new NetworkAccessManager(app); }),
|
||||
device_finders_([app]() { return new DeviceFinders(app); }),
|
||||
task_manager_([]() { return new TaskManager(); }),
|
||||
player_([app]() { return new Player(app); }),
|
||||
network_([]() { return new NetworkAccessManager(); }),
|
||||
device_finders_([]() { return new DeviceFinders(); }),
|
||||
#ifndef Q_OS_WIN
|
||||
device_manager_([app]() { return new DeviceManager(app, app); }),
|
||||
device_manager_([app]() { return new DeviceManager(app); }),
|
||||
#endif
|
||||
collection_([app]() { return new SCollection(app, app); }),
|
||||
collection_([app]() { return new SCollection(app); }),
|
||||
playlist_backend_([this, app]() {
|
||||
PlaylistBackend *backend = new PlaylistBackend(app, app);
|
||||
PlaylistBackend *backend = new PlaylistBackend(app);
|
||||
app->MoveToThread(backend, database_->thread());
|
||||
return backend;
|
||||
}),
|
||||
playlist_manager_([app]() { return new PlaylistManager(app); }),
|
||||
cover_providers_([app]() {
|
||||
CoverProviders *cover_providers = new CoverProviders(app);
|
||||
CoverProviders *cover_providers = new CoverProviders();
|
||||
// Initialize the repository of cover providers.
|
||||
cover_providers->AddProvider(new LastFmCoverProvider(app, app->network(), app));
|
||||
cover_providers->AddProvider(new MusicbrainzCoverProvider(app, app->network(), app));
|
||||
cover_providers->AddProvider(new DiscogsCoverProvider(app, app->network(), app));
|
||||
cover_providers->AddProvider(new DeezerCoverProvider(app, app->network(), app));
|
||||
cover_providers->AddProvider(new MusixmatchCoverProvider(app, app->network(), app));
|
||||
cover_providers->AddProvider(new SpotifyCoverProvider(app, app->network(), app));
|
||||
cover_providers->AddProvider(new LastFmCoverProvider(app, app->network()));
|
||||
cover_providers->AddProvider(new MusicbrainzCoverProvider(app, app->network()));
|
||||
cover_providers->AddProvider(new DiscogsCoverProvider(app, app->network()));
|
||||
cover_providers->AddProvider(new DeezerCoverProvider(app, app->network()));
|
||||
cover_providers->AddProvider(new MusixmatchCoverProvider(app, app->network()));
|
||||
cover_providers->AddProvider(new SpotifyCoverProvider(app, app->network()));
|
||||
#ifdef HAVE_TIDAL
|
||||
cover_providers->AddProvider(new TidalCoverProvider(app, app->network(), app));
|
||||
cover_providers->AddProvider(new TidalCoverProvider(app, app->network()));
|
||||
#endif
|
||||
#ifdef HAVE_QOBUZ
|
||||
cover_providers->AddProvider(new QobuzCoverProvider(app, app->network(), app));
|
||||
cover_providers->AddProvider(new QobuzCoverProvider(app, app->network()));
|
||||
#endif
|
||||
cover_providers->ReloadSettings();
|
||||
return cover_providers;
|
||||
}),
|
||||
album_cover_loader_([app]() {
|
||||
AlbumCoverLoader *loader = new AlbumCoverLoader(app);
|
||||
AlbumCoverLoader *loader = new AlbumCoverLoader();
|
||||
app->MoveToNewThread(loader);
|
||||
return loader;
|
||||
}),
|
||||
current_albumcover_loader_([app]() { return new CurrentAlbumCoverLoader(app, app); }),
|
||||
current_albumcover_loader_([app]() { return new CurrentAlbumCoverLoader(app); }),
|
||||
lyrics_providers_([app]() {
|
||||
LyricsProviders *lyrics_providers = new LyricsProviders(app);
|
||||
// Initialize the repository of lyrics providers.
|
||||
lyrics_providers->AddProvider(new GeniusLyricsProvider(app->network(), app));
|
||||
lyrics_providers->AddProvider(new OVHLyricsProvider(app->network(), app));
|
||||
lyrics_providers->AddProvider(new LoloLyricsProvider(app->network(), app));
|
||||
lyrics_providers->AddProvider(new MusixmatchLyricsProvider(app->network(), app));
|
||||
lyrics_providers->AddProvider(new ChartLyricsProvider(app->network(), app));
|
||||
lyrics_providers->AddProvider(new LyricsComLyricsProvider(app->network(), app));
|
||||
lyrics_providers->AddProvider(new GeniusLyricsProvider(app->network()));
|
||||
lyrics_providers->AddProvider(new OVHLyricsProvider(app->network()));
|
||||
lyrics_providers->AddProvider(new LoloLyricsProvider(app->network()));
|
||||
lyrics_providers->AddProvider(new MusixmatchLyricsProvider(app->network()));
|
||||
lyrics_providers->AddProvider(new ChartLyricsProvider(app->network()));
|
||||
lyrics_providers->AddProvider(new LyricsComLyricsProvider(app->network()));
|
||||
lyrics_providers->ReloadSettings();
|
||||
return lyrics_providers;
|
||||
}),
|
||||
internet_services_([app]() {
|
||||
InternetServices *internet_services = new InternetServices(app);
|
||||
InternetServices *internet_services = new InternetServices();
|
||||
#ifdef HAVE_SUBSONIC
|
||||
internet_services->AddService(new SubsonicService(app, internet_services));
|
||||
internet_services->AddService(make_shared<SubsonicService>(app));
|
||||
#endif
|
||||
#ifdef HAVE_TIDAL
|
||||
internet_services->AddService(new TidalService(app, internet_services));
|
||||
internet_services->AddService(make_shared<TidalService>(app));
|
||||
#endif
|
||||
#ifdef HAVE_QOBUZ
|
||||
internet_services->AddService(new QobuzService(app, internet_services));
|
||||
internet_services->AddService(make_shared<QobuzService>(app));
|
||||
#endif
|
||||
return internet_services;
|
||||
}),
|
||||
radio_services_([app]() { return new RadioServices(app, app); }),
|
||||
radio_services_([app]() { return new RadioServices(app); }),
|
||||
scrobbler_([app]() {
|
||||
AudioScrobbler *scrobbler = new AudioScrobbler(app);
|
||||
scrobbler->AddService(new LastFMScrobbler(scrobbler, app->network(), app));
|
||||
scrobbler->AddService(new LibreFMScrobbler(scrobbler, app->network(), app));
|
||||
scrobbler->AddService(new ListenBrainzScrobbler(scrobbler, app->network(), app));
|
||||
scrobbler->AddService(make_shared<LastFMScrobbler>(scrobbler->settings(), app->network()));
|
||||
scrobbler->AddService(make_shared<LibreFMScrobbler>(scrobbler->settings(), app->network()));
|
||||
scrobbler->AddService(make_shared<ListenBrainzScrobbler>(scrobbler->settings(), app->network()));
|
||||
#ifdef HAVE_SUBSONIC
|
||||
scrobbler->AddService(make_shared<SubsonicScrobbler>(scrobbler->settings(), app));
|
||||
#endif
|
||||
return scrobbler;
|
||||
}),
|
||||
#ifdef HAVE_MOODBAR
|
||||
moodbar_loader_([app]() { return new MoodbarLoader(app, app); }),
|
||||
moodbar_controller_([app]() { return new MoodbarController(app, app); }),
|
||||
moodbar_loader_([app]() { return new MoodbarLoader(app); }),
|
||||
moodbar_controller_([app]() { return new MoodbarController(app); }),
|
||||
#endif
|
||||
lastfm_import_([app]() { return new LastFMImport(app->network(), app); })
|
||||
lastfm_import_([app]() { return new LastFMImport(app->network()); })
|
||||
{}
|
||||
|
||||
Lazy<TagReaderClient> tag_reader_client_;
|
||||
@ -227,17 +232,13 @@ Application::Application(QObject *parent)
|
||||
collection()->Init();
|
||||
tag_reader_client();
|
||||
|
||||
QObject::connect(database(), &Database::Error, this, &Application::ErrorAdded);
|
||||
QObject::connect(&*database(), &Database::Error, this, &Application::ErrorAdded);
|
||||
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
|
||||
// It's important that the device manager is deleted before the database.
|
||||
// Deleting the database deletes all objects that have been created in its thread, including some device collection backends.
|
||||
#ifndef Q_OS_WIN
|
||||
p_->device_manager_.reset();
|
||||
#endif
|
||||
qLog(Debug) << "Terminating application";
|
||||
|
||||
for (QThread *thread : threads_) {
|
||||
thread->quit();
|
||||
@ -271,37 +272,37 @@ void Application::MoveToThread(QObject *object, QThread *thread) {
|
||||
|
||||
void Application::Exit() {
|
||||
|
||||
wait_for_exit_ << tag_reader_client()
|
||||
<< collection()
|
||||
<< playlist_backend()
|
||||
<< album_cover_loader()
|
||||
wait_for_exit_ << &*tag_reader_client()
|
||||
<< &*collection()
|
||||
<< &*playlist_backend()
|
||||
<< &*album_cover_loader()
|
||||
#ifndef Q_OS_WIN
|
||||
<< device_manager()
|
||||
<< &*device_manager()
|
||||
#endif
|
||||
<< internet_services()
|
||||
<< radio_services()->radio_backend();
|
||||
<< &*internet_services()
|
||||
<< &*radio_services()->radio_backend();
|
||||
|
||||
QObject::connect(tag_reader_client(), &TagReaderClient::ExitFinished, this, &Application::ExitReceived);
|
||||
QObject::connect(&*tag_reader_client(), &TagReaderClient::ExitFinished, this, &Application::ExitReceived);
|
||||
tag_reader_client()->ExitAsync();
|
||||
|
||||
QObject::connect(collection(), &SCollection::ExitFinished, this, &Application::ExitReceived);
|
||||
QObject::connect(&*collection(), &SCollection::ExitFinished, this, &Application::ExitReceived);
|
||||
collection()->Exit();
|
||||
|
||||
QObject::connect(playlist_backend(), &PlaylistBackend::ExitFinished, this, &Application::ExitReceived);
|
||||
QObject::connect(&*playlist_backend(), &PlaylistBackend::ExitFinished, this, &Application::ExitReceived);
|
||||
playlist_backend()->ExitAsync();
|
||||
|
||||
QObject::connect(album_cover_loader(), &AlbumCoverLoader::ExitFinished, this, &Application::ExitReceived);
|
||||
QObject::connect(&*album_cover_loader(), &AlbumCoverLoader::ExitFinished, this, &Application::ExitReceived);
|
||||
album_cover_loader()->ExitAsync();
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
QObject::connect(device_manager(), &DeviceManager::ExitFinished, this, &Application::ExitReceived);
|
||||
QObject::connect(&*device_manager(), &DeviceManager::ExitFinished, this, &Application::ExitReceived);
|
||||
device_manager()->Exit();
|
||||
#endif
|
||||
|
||||
QObject::connect(internet_services(), &InternetServices::ExitFinished, this, &Application::ExitReceived);
|
||||
QObject::connect(&*internet_services(), &InternetServices::ExitFinished, this, &Application::ExitReceived);
|
||||
internet_services()->Exit();
|
||||
|
||||
QObject::connect(radio_services()->radio_backend(), &RadioBackend::ExitFinished, this, &Application::ExitReceived);
|
||||
QObject::connect(&*radio_services()->radio_backend(), &RadioBackend::ExitFinished, this, &Application::ExitReceived);
|
||||
radio_services()->radio_backend()->ExitAsync();
|
||||
|
||||
}
|
||||
@ -316,7 +317,7 @@ void Application::ExitReceived() {
|
||||
wait_for_exit_.removeAll(obj);
|
||||
if (wait_for_exit_.isEmpty()) {
|
||||
database()->Close();
|
||||
QObject::connect(database(), &Database::ExitFinished, this, &Application::ExitFinished);
|
||||
QObject::connect(&*database(), &Database::ExitFinished, this, &Application::ExitFinished);
|
||||
database()->ExitAsync();
|
||||
}
|
||||
|
||||
@ -326,29 +327,29 @@ void Application::AddError(const QString &message) { emit ErrorAdded(message); }
|
||||
void Application::ReloadSettings() { emit SettingsChanged(); }
|
||||
void Application::OpenSettingsDialogAtPage(SettingsDialog::Page page) { emit SettingsDialogRequested(page); }
|
||||
|
||||
TagReaderClient *Application::tag_reader_client() const { return p_->tag_reader_client_.get(); }
|
||||
Database *Application::database() const { return p_->database_.get(); }
|
||||
TaskManager *Application::task_manager() const { return p_->task_manager_.get(); }
|
||||
Player *Application::player() const { return p_->player_.get(); }
|
||||
NetworkAccessManager *Application::network() const { return p_->network_.get(); }
|
||||
DeviceFinders *Application::device_finders() const { return p_->device_finders_.get(); }
|
||||
SharedPtr<TagReaderClient> Application::tag_reader_client() const { return p_->tag_reader_client_.ptr(); }
|
||||
SharedPtr<Database> Application::database() const { return p_->database_.ptr(); }
|
||||
SharedPtr<TaskManager> Application::task_manager() const { return p_->task_manager_.ptr(); }
|
||||
SharedPtr<Player> Application::player() const { return p_->player_.ptr(); }
|
||||
SharedPtr<NetworkAccessManager> Application::network() const { return p_->network_.ptr(); }
|
||||
SharedPtr<DeviceFinders> Application::device_finders() const { return p_->device_finders_.ptr(); }
|
||||
#ifndef Q_OS_WIN
|
||||
DeviceManager *Application::device_manager() const { return p_->device_manager_.get(); }
|
||||
SharedPtr<DeviceManager> Application::device_manager() const { return p_->device_manager_.ptr(); }
|
||||
#endif
|
||||
SCollection *Application::collection() const { return p_->collection_.get(); }
|
||||
CollectionBackend *Application::collection_backend() const { return collection()->backend(); }
|
||||
SharedPtr<SCollection> Application::collection() const { return p_->collection_.ptr(); }
|
||||
SharedPtr<CollectionBackend> Application::collection_backend() const { return collection()->backend(); }
|
||||
CollectionModel *Application::collection_model() const { return collection()->model(); }
|
||||
AlbumCoverLoader *Application::album_cover_loader() const { return p_->album_cover_loader_.get(); }
|
||||
CoverProviders *Application::cover_providers() const { return p_->cover_providers_.get(); }
|
||||
CurrentAlbumCoverLoader *Application::current_albumcover_loader() const { return p_->current_albumcover_loader_.get(); }
|
||||
LyricsProviders *Application::lyrics_providers() const { return p_->lyrics_providers_.get(); }
|
||||
PlaylistBackend *Application::playlist_backend() const { return p_->playlist_backend_.get(); }
|
||||
PlaylistManager *Application::playlist_manager() const { return p_->playlist_manager_.get(); }
|
||||
InternetServices *Application::internet_services() const { return p_->internet_services_.get(); }
|
||||
RadioServices *Application::radio_services() const { return p_->radio_services_.get(); }
|
||||
AudioScrobbler *Application::scrobbler() const { return p_->scrobbler_.get(); }
|
||||
LastFMImport *Application::lastfm_import() const { return p_->lastfm_import_.get(); }
|
||||
SharedPtr<AlbumCoverLoader> Application::album_cover_loader() const { return p_->album_cover_loader_.ptr(); }
|
||||
SharedPtr<CoverProviders> Application::cover_providers() const { return p_->cover_providers_.ptr(); }
|
||||
SharedPtr<CurrentAlbumCoverLoader> Application::current_albumcover_loader() const { return p_->current_albumcover_loader_.ptr(); }
|
||||
SharedPtr<LyricsProviders> Application::lyrics_providers() const { return p_->lyrics_providers_.ptr(); }
|
||||
SharedPtr<PlaylistBackend> Application::playlist_backend() const { return p_->playlist_backend_.ptr(); }
|
||||
SharedPtr<PlaylistManager> Application::playlist_manager() const { return p_->playlist_manager_.ptr(); }
|
||||
SharedPtr<InternetServices> Application::internet_services() const { return p_->internet_services_.ptr(); }
|
||||
SharedPtr<RadioServices> Application::radio_services() const { return p_->radio_services_.ptr(); }
|
||||
SharedPtr<AudioScrobbler> Application::scrobbler() const { return p_->scrobbler_.ptr(); }
|
||||
SharedPtr<LastFMImport> Application::lastfm_import() const { return p_->lastfm_import_.ptr(); }
|
||||
#ifdef HAVE_MOODBAR
|
||||
MoodbarController *Application::moodbar_controller() const { return p_->moodbar_controller_.get(); }
|
||||
MoodbarLoader *Application::moodbar_loader() const { return p_->moodbar_loader_.get(); }
|
||||
SharedPtr<MoodbarController> Application::moodbar_controller() const { return p_->moodbar_controller_.ptr(); }
|
||||
SharedPtr<MoodbarLoader> Application::moodbar_loader() const { return p_->moodbar_loader_.ptr(); }
|
||||
#endif
|
||||
|
@ -25,12 +25,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "scoped_ptr.h"
|
||||
#include "shared_ptr.h"
|
||||
|
||||
#include "settings/settingsdialog.h"
|
||||
|
||||
class QThread;
|
||||
@ -71,40 +72,40 @@ class Application : public QObject {
|
||||
explicit Application(QObject *parent = nullptr);
|
||||
~Application() override;
|
||||
|
||||
TagReaderClient *tag_reader_client() const;
|
||||
Database *database() const;
|
||||
TaskManager *task_manager() const;
|
||||
Player *player() const;
|
||||
NetworkAccessManager *network() const;
|
||||
DeviceFinders *device_finders() const;
|
||||
SharedPtr<TagReaderClient> tag_reader_client() const;
|
||||
SharedPtr<Database> database() const;
|
||||
SharedPtr<TaskManager> task_manager() const;
|
||||
SharedPtr<Player> player() const;
|
||||
SharedPtr<NetworkAccessManager> network() const;
|
||||
SharedPtr<DeviceFinders> device_finders() const;
|
||||
#ifndef Q_OS_WIN
|
||||
DeviceManager *device_manager() const;
|
||||
SharedPtr<DeviceManager> device_manager() const;
|
||||
#endif
|
||||
|
||||
SCollection *collection() const;
|
||||
CollectionBackend *collection_backend() const;
|
||||
SharedPtr<SCollection> collection() const;
|
||||
SharedPtr<CollectionBackend> collection_backend() const;
|
||||
CollectionModel *collection_model() const;
|
||||
|
||||
PlaylistBackend *playlist_backend() const;
|
||||
PlaylistManager *playlist_manager() const;
|
||||
SharedPtr<PlaylistBackend> playlist_backend() const;
|
||||
SharedPtr<PlaylistManager> playlist_manager() const;
|
||||
|
||||
CoverProviders *cover_providers() const;
|
||||
AlbumCoverLoader *album_cover_loader() const;
|
||||
CurrentAlbumCoverLoader *current_albumcover_loader() const;
|
||||
SharedPtr<CoverProviders> cover_providers() const;
|
||||
SharedPtr<AlbumCoverLoader> album_cover_loader() const;
|
||||
SharedPtr<CurrentAlbumCoverLoader> current_albumcover_loader() const;
|
||||
|
||||
LyricsProviders *lyrics_providers() const;
|
||||
SharedPtr<LyricsProviders> lyrics_providers() const;
|
||||
|
||||
AudioScrobbler *scrobbler() const;
|
||||
SharedPtr<AudioScrobbler> scrobbler() const;
|
||||
|
||||
InternetServices *internet_services() const;
|
||||
RadioServices *radio_services() const;
|
||||
SharedPtr<InternetServices> internet_services() const;
|
||||
SharedPtr<RadioServices> radio_services() const;
|
||||
|
||||
#ifdef HAVE_MOODBAR
|
||||
MoodbarController *moodbar_controller() const;
|
||||
MoodbarLoader *moodbar_loader() const;
|
||||
SharedPtr<MoodbarController> moodbar_controller() const;
|
||||
SharedPtr<MoodbarLoader> moodbar_loader() const;
|
||||
#endif
|
||||
|
||||
LastFMImport *lastfm_import() const;
|
||||
SharedPtr<LastFMImport> lastfm_import() const;
|
||||
|
||||
void Exit();
|
||||
|
||||
@ -127,7 +128,7 @@ class Application : public QObject {
|
||||
void ClearPixmapDiskCache();
|
||||
|
||||
private:
|
||||
std::unique_ptr<ApplicationImpl> p_;
|
||||
ScopedPtr<ApplicationImpl> p_;
|
||||
QList<QThread*> threads_;
|
||||
QList<QObject*> wait_for_exit_;
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QUrl>
|
||||
#include <QMetaObject>
|
||||
|
||||
#include "shared_ptr.h"
|
||||
#include "taskmanager.h"
|
||||
#include "song.h"
|
||||
#include "deletefiles.h"
|
||||
@ -35,7 +36,7 @@
|
||||
|
||||
const int DeleteFiles::kBatchSize = 50;
|
||||
|
||||
DeleteFiles::DeleteFiles(TaskManager *task_manager, std::shared_ptr<MusicStorage> storage, const bool use_trash, QObject *parent)
|
||||
DeleteFiles::DeleteFiles(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> storage, const bool use_trash, QObject *parent)
|
||||
: QObject(parent),
|
||||
thread_(nullptr),
|
||||
task_manager_(task_manager),
|
||||
|
@ -24,11 +24,10 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
#include "shared_ptr.h"
|
||||
#include "song.h"
|
||||
|
||||
class QThread;
|
||||
@ -39,7 +38,7 @@ class DeleteFiles : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeleteFiles(TaskManager *task_manager, std::shared_ptr<MusicStorage> storage, const bool use_trash, QObject *parent = nullptr);
|
||||
explicit DeleteFiles(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> storage, const bool use_trash, QObject *parent = nullptr);
|
||||
~DeleteFiles() override;
|
||||
|
||||
static const int kBatchSize;
|
||||
@ -56,8 +55,8 @@ class DeleteFiles : public QObject {
|
||||
private:
|
||||
QThread *thread_;
|
||||
QThread *original_thread_;
|
||||
TaskManager *task_manager_;
|
||||
std::shared_ptr<MusicStorage> storage_;
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
SharedPtr<MusicStorage> storage_;
|
||||
|
||||
SongList songs_;
|
||||
bool use_trash_;
|
||||
|
@ -19,7 +19,11 @@
|
||||
#define LAZY_H
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "core/logging.h"
|
||||
|
||||
#include "shared_ptr.h"
|
||||
|
||||
// Helper for lazy initialization of objects.
|
||||
// Usage:
|
||||
@ -38,6 +42,11 @@ class Lazy {
|
||||
return ptr_.get();
|
||||
}
|
||||
|
||||
SharedPtr<T> ptr() const {
|
||||
CheckInitialized();
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
typename std::add_lvalue_reference<T>::type operator*() const {
|
||||
CheckInitialized();
|
||||
return *ptr_;
|
||||
@ -54,12 +63,13 @@ class Lazy {
|
||||
private:
|
||||
void CheckInitialized() const {
|
||||
if (!ptr_) {
|
||||
ptr_.reset(init_(), [](T*obj) { obj->deleteLater(); });
|
||||
ptr_ = SharedPtr<T>(init_(), [](T*obj) { qLog(Debug) << obj << "deleted"; delete obj; });
|
||||
qLog(Debug) << &*ptr_ << "created";
|
||||
}
|
||||
}
|
||||
|
||||
const std::function<T*()> init_;
|
||||
mutable std::shared_ptr<T> ptr_;
|
||||
mutable SharedPtr<T> ptr_;
|
||||
};
|
||||
|
||||
#endif // LAZY_H
|
||||
|
@ -24,13 +24,12 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
#include <QPixmap>
|
||||
#include <QAction>
|
||||
|
||||
#include "scoped_ptr.h"
|
||||
#include "song.h"
|
||||
|
||||
class MacSystemTrayIconPrivate;
|
||||
@ -85,7 +84,7 @@ class SystemTrayIcon : public QObject {
|
||||
void PlayPause();
|
||||
|
||||
private:
|
||||
std::unique_ptr<MacSystemTrayIconPrivate> p_;
|
||||
ScopedPtr<MacSystemTrayIconPrivate> p_;
|
||||
|
||||
QPixmap normal_icon_;
|
||||
QPixmap grey_icon_;
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include "config.h"
|
||||
#include "version.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QApplication>
|
||||
@ -79,6 +79,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include "shared_ptr.h"
|
||||
#include "commandlineoptions.h"
|
||||
#include "mimedata.h"
|
||||
#include "iconloader.h"
|
||||
@ -166,7 +167,6 @@
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#ifdef HAVE_SUBSONIC
|
||||
# include "settings/subsonicsettingspage.h"
|
||||
# include "scrobbler/subsonicscrobbler.h"
|
||||
#endif
|
||||
#ifdef HAVE_TIDAL
|
||||
# include "tidal/tidalservice.h"
|
||||
@ -212,6 +212,8 @@
|
||||
# endif
|
||||
#endif // HAVE_QTSPARKLE
|
||||
|
||||
using std::make_unique;
|
||||
using std::make_shared;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
const char *MainWindow::kSettingsGroup = "MainWindow";
|
||||
@ -238,7 +240,7 @@ constexpr char QTSPARKLE_URL[] = "https://www.strawberrymusicplayer.org/sparkle-
|
||||
# endif
|
||||
#endif
|
||||
|
||||
MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_icon, OSDBase *osd, const CommandlineOptions &options, QWidget *parent)
|
||||
MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OSDBase *osd, const CommandlineOptions &options, QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
ui_(new Ui_MainWindow),
|
||||
#ifdef Q_OS_WIN
|
||||
@ -397,7 +399,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
// Start initializing the player
|
||||
qLog(Debug) << "Initializing player";
|
||||
app_->player()->SetAnalyzer(ui_->analyzer);
|
||||
app_->player()->SetEqualizer(equalizer_.get());
|
||||
app_->player()->SetEqualizer(equalizer_);
|
||||
app_->player()->Init();
|
||||
EngineChanged(app_->player()->engine()->type());
|
||||
const uint volume = app_->player()->GetVolume();
|
||||
@ -504,17 +506,17 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
file_view_->SetTaskManager(app_->task_manager());
|
||||
|
||||
// Action connections
|
||||
QObject::connect(ui_->action_next_track, &QAction::triggered, app_->player(), &Player::Next);
|
||||
QObject::connect(ui_->action_previous_track, &QAction::triggered, app_->player(), &Player::Previous);
|
||||
QObject::connect(ui_->action_play_pause, &QAction::triggered, app_->player(), &Player::PlayPauseHelper);
|
||||
QObject::connect(ui_->action_stop, &QAction::triggered, app_->player(), &Player::Stop);
|
||||
QObject::connect(ui_->action_next_track, &QAction::triggered, &*app_->player(), &Player::Next);
|
||||
QObject::connect(ui_->action_previous_track, &QAction::triggered, &*app_->player(), &Player::Previous);
|
||||
QObject::connect(ui_->action_play_pause, &QAction::triggered, &*app_->player(), &Player::PlayPauseHelper);
|
||||
QObject::connect(ui_->action_stop, &QAction::triggered, &*app_->player(), &Player::Stop);
|
||||
QObject::connect(ui_->action_quit, &QAction::triggered, this, &MainWindow::Exit);
|
||||
QObject::connect(ui_->action_stop_after_this_track, &QAction::triggered, this, &MainWindow::StopAfterCurrent);
|
||||
QObject::connect(ui_->action_mute, &QAction::triggered, app_->player(), &Player::Mute);
|
||||
QObject::connect(ui_->action_mute, &QAction::triggered, &*app_->player(), &Player::Mute);
|
||||
|
||||
QObject::connect(ui_->action_clear_playlist, &QAction::triggered, this, &MainWindow::PlaylistClearCurrent);
|
||||
QObject::connect(ui_->action_remove_duplicates, &QAction::triggered, app_->playlist_manager(), &PlaylistManager::RemoveDuplicatesCurrent);
|
||||
QObject::connect(ui_->action_remove_unavailable, &QAction::triggered, app_->playlist_manager(), &PlaylistManager::RemoveUnavailableCurrent);
|
||||
QObject::connect(ui_->action_remove_duplicates, &QAction::triggered, &*app_->playlist_manager(), &PlaylistManager::RemoveDuplicatesCurrent);
|
||||
QObject::connect(ui_->action_remove_unavailable, &QAction::triggered, &*app_->playlist_manager(), &PlaylistManager::RemoveUnavailableCurrent);
|
||||
QObject::connect(ui_->action_remove_from_playlist, &QAction::triggered, this, &MainWindow::PlaylistRemoveCurrent);
|
||||
QObject::connect(ui_->action_edit_track, &QAction::triggered, this, &MainWindow::EditTracks);
|
||||
QObject::connect(ui_->action_renumber_tracks, &QAction::triggered, this, &MainWindow::RenumberTracks);
|
||||
@ -528,7 +530,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
QObject::connect(ui_->action_toggle_show_sidebar, &QAction::toggled, this, &MainWindow::ToggleSidebar);
|
||||
QObject::connect(ui_->action_about_strawberry, &QAction::triggered, this, &MainWindow::ShowAboutDialog);
|
||||
QObject::connect(ui_->action_about_qt, &QAction::triggered, qApp, &QApplication::aboutQt);
|
||||
QObject::connect(ui_->action_shuffle, &QAction::triggered, app_->playlist_manager(), &PlaylistManager::ShuffleCurrent);
|
||||
QObject::connect(ui_->action_shuffle, &QAction::triggered, &*app_->playlist_manager(), &PlaylistManager::ShuffleCurrent);
|
||||
QObject::connect(ui_->action_open_file, &QAction::triggered, this, &MainWindow::AddFile);
|
||||
QObject::connect(ui_->action_open_cd, &QAction::triggered, this, &MainWindow::AddCDTracks);
|
||||
QObject::connect(ui_->action_add_file, &QAction::triggered, this, &MainWindow::AddFile);
|
||||
@ -542,9 +544,9 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
ui_->action_transcoder->setDisabled(true);
|
||||
#endif
|
||||
QObject::connect(ui_->action_jump, &QAction::triggered, ui_->playlist->view(), &PlaylistView::JumpToCurrentlyPlayingTrack);
|
||||
QObject::connect(ui_->action_update_collection, &QAction::triggered, app_->collection(), &SCollection::IncrementalScan);
|
||||
QObject::connect(ui_->action_full_collection_scan, &QAction::triggered, app_->collection(), &SCollection::FullScan);
|
||||
QObject::connect(ui_->action_abort_collection_scan, &QAction::triggered, app_->collection(), &SCollection::AbortScan);
|
||||
QObject::connect(ui_->action_update_collection, &QAction::triggered, &*app_->collection(), &SCollection::IncrementalScan);
|
||||
QObject::connect(ui_->action_full_collection_scan, &QAction::triggered, &*app_->collection(), &SCollection::FullScan);
|
||||
QObject::connect(ui_->action_abort_collection_scan, &QAction::triggered, &*app_->collection(), &SCollection::AbortScan);
|
||||
#if defined(HAVE_GSTREAMER)
|
||||
QObject::connect(ui_->action_add_files_to_transcoder, &QAction::triggered, this, &MainWindow::AddFilesToTranscoder);
|
||||
ui_->action_add_files_to_transcoder->setIcon(IconLoader::Load("tools-wizard"));
|
||||
@ -552,9 +554,9 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
ui_->action_add_files_to_transcoder->setDisabled(true);
|
||||
#endif
|
||||
|
||||
QObject::connect(ui_->action_toggle_scrobbling, &QAction::triggered, app_->scrobbler(), &AudioScrobbler::ToggleScrobbling);
|
||||
QObject::connect(ui_->action_toggle_scrobbling, &QAction::triggered, &*app_->scrobbler(), &AudioScrobbler::ToggleScrobbling);
|
||||
QObject::connect(ui_->action_love, &QAction::triggered, this, &MainWindow::Love);
|
||||
QObject::connect(app_->scrobbler(), &AudioScrobbler::ErrorMessage, this, &MainWindow::ShowErrorDialog);
|
||||
QObject::connect(&*app_->scrobbler(), &AudioScrobbler::ErrorMessage, this, &MainWindow::ShowErrorDialog);
|
||||
|
||||
// Playlist view actions
|
||||
ui_->action_next_playlist->setShortcuts(QList<QKeySequence>() << QKeySequence::fromString("Ctrl+Tab") << QKeySequence::fromString("Ctrl+PgDown"));
|
||||
@ -584,55 +586,55 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
ui_->stop_button->setMenu(stop_menu);
|
||||
|
||||
// Player connections
|
||||
QObject::connect(ui_->volume, &VolumeSlider::valueChanged, app_->player(), &Player::SetVolumeFromSlider);
|
||||
QObject::connect(ui_->volume, &VolumeSlider::valueChanged, &*app_->player(), &Player::SetVolumeFromSlider);
|
||||
|
||||
QObject::connect(app_->player(), &Player::EngineChanged, this, &MainWindow::EngineChanged);
|
||||
QObject::connect(app_->player(), &Player::Error, this, &MainWindow::ShowErrorDialog);
|
||||
QObject::connect(app_->player(), &Player::SongChangeRequestProcessed, app_->playlist_manager(), &PlaylistManager::SongChangeRequestProcessed);
|
||||
QObject::connect(&*app_->player(), &Player::EngineChanged, this, &MainWindow::EngineChanged);
|
||||
QObject::connect(&*app_->player(), &Player::Error, this, &MainWindow::ShowErrorDialog);
|
||||
QObject::connect(&*app_->player(), &Player::SongChangeRequestProcessed, &*app_->playlist_manager(), &PlaylistManager::SongChangeRequestProcessed);
|
||||
|
||||
QObject::connect(app_->player(), &Player::Paused, this, &MainWindow::MediaPaused);
|
||||
QObject::connect(app_->player(), &Player::Playing, this, &MainWindow::MediaPlaying);
|
||||
QObject::connect(app_->player(), &Player::Stopped, this, &MainWindow::MediaStopped);
|
||||
QObject::connect(app_->player(), &Player::Seeked, this, &MainWindow::Seeked);
|
||||
QObject::connect(app_->player(), &Player::TrackSkipped, this, &MainWindow::TrackSkipped);
|
||||
QObject::connect(app_->player(), &Player::VolumeChanged, this, &MainWindow::VolumeChanged);
|
||||
QObject::connect(&*app_->player(), &Player::Paused, this, &MainWindow::MediaPaused);
|
||||
QObject::connect(&*app_->player(), &Player::Playing, this, &MainWindow::MediaPlaying);
|
||||
QObject::connect(&*app_->player(), &Player::Stopped, this, &MainWindow::MediaStopped);
|
||||
QObject::connect(&*app_->player(), &Player::Seeked, this, &MainWindow::Seeked);
|
||||
QObject::connect(&*app_->player(), &Player::TrackSkipped, this, &MainWindow::TrackSkipped);
|
||||
QObject::connect(&*app_->player(), &Player::VolumeChanged, this, &MainWindow::VolumeChanged);
|
||||
|
||||
QObject::connect(app_->player(), &Player::Paused, ui_->playlist, &PlaylistContainer::ActivePaused);
|
||||
QObject::connect(app_->player(), &Player::Playing, ui_->playlist, &PlaylistContainer::ActivePlaying);
|
||||
QObject::connect(app_->player(), &Player::Stopped, ui_->playlist, &PlaylistContainer::ActiveStopped);
|
||||
QObject::connect(&*app_->player(), &Player::Paused, ui_->playlist, &PlaylistContainer::ActivePaused);
|
||||
QObject::connect(&*app_->player(), &Player::Playing, ui_->playlist, &PlaylistContainer::ActivePlaying);
|
||||
QObject::connect(&*app_->player(), &Player::Stopped, ui_->playlist, &PlaylistContainer::ActiveStopped);
|
||||
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, osd_, &OSDBase::SongChanged);
|
||||
QObject::connect(app_->player(), &Player::Paused, osd_, &OSDBase::Paused);
|
||||
QObject::connect(app_->player(), &Player::Resumed, osd_, &OSDBase::Resumed);
|
||||
QObject::connect(app_->player(), &Player::Stopped, osd_, &OSDBase::Stopped);
|
||||
QObject::connect(app_->player(), &Player::PlaylistFinished, osd_, &OSDBase::PlaylistFinished);
|
||||
QObject::connect(app_->player(), &Player::VolumeChanged, osd_, &OSDBase::VolumeChanged);
|
||||
QObject::connect(app_->player(), &Player::VolumeChanged, ui_->volume, &VolumeSlider::SetValue);
|
||||
QObject::connect(app_->player(), &Player::ForceShowOSD, this, &MainWindow::ForceShowOSD);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, osd_, &OSDBase::SongChanged);
|
||||
QObject::connect(&*app_->player(), &Player::Paused, osd_, &OSDBase::Paused);
|
||||
QObject::connect(&*app_->player(), &Player::Resumed, osd_, &OSDBase::Resumed);
|
||||
QObject::connect(&*app_->player(), &Player::Stopped, osd_, &OSDBase::Stopped);
|
||||
QObject::connect(&*app_->player(), &Player::PlaylistFinished, osd_, &OSDBase::PlaylistFinished);
|
||||
QObject::connect(&*app_->player(), &Player::VolumeChanged, osd_, &OSDBase::VolumeChanged);
|
||||
QObject::connect(&*app_->player(), &Player::VolumeChanged, ui_->volume, &VolumeSlider::SetValue);
|
||||
QObject::connect(&*app_->player(), &Player::ForceShowOSD, this, &MainWindow::ForceShowOSD);
|
||||
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &MainWindow::SongChanged);
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, app_->player(), &Player::CurrentMetadataChanged);
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::EditingFinished, this, &MainWindow::PlaylistEditFinished);
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::Error, this, &MainWindow::ShowErrorDialog);
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::SummaryTextChanged, ui_->playlist_summary, &QLabel::setText);
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::PlayRequested, this, &MainWindow::PlayIndex);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &MainWindow::SongChanged);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, &*app_->player(), &Player::CurrentMetadataChanged);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::EditingFinished, this, &MainWindow::PlaylistEditFinished);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::Error, this, &MainWindow::ShowErrorDialog);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::SummaryTextChanged, ui_->playlist_summary, &QLabel::setText);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::PlayRequested, this, &MainWindow::PlayIndex);
|
||||
|
||||
QObject::connect(ui_->playlist->view(), &PlaylistView::doubleClicked, this, &MainWindow::PlaylistDoubleClick);
|
||||
QObject::connect(ui_->playlist->view(), &PlaylistView::PlayItem, this, &MainWindow::PlayIndex);
|
||||
QObject::connect(ui_->playlist->view(), &PlaylistView::PlayPause, app_->player(), &Player::PlayPause);
|
||||
QObject::connect(ui_->playlist->view(), &PlaylistView::PlayPause, &*app_->player(), &Player::PlayPause);
|
||||
QObject::connect(ui_->playlist->view(), &PlaylistView::RightClicked, this, &MainWindow::PlaylistRightClick);
|
||||
QObject::connect(ui_->playlist->view(), &PlaylistView::SeekForward, app_->player(), &Player::SeekForward);
|
||||
QObject::connect(ui_->playlist->view(), &PlaylistView::SeekBackward, app_->player(), &Player::SeekBackward);
|
||||
QObject::connect(ui_->playlist->view(), &PlaylistView::SeekForward, &*app_->player(), &Player::SeekForward);
|
||||
QObject::connect(ui_->playlist->view(), &PlaylistView::SeekBackward, &*app_->player(), &Player::SeekBackward);
|
||||
QObject::connect(ui_->playlist->view(), &PlaylistView::BackgroundPropertyChanged, this, &MainWindow::RefreshStyleSheet);
|
||||
|
||||
QObject::connect(ui_->track_slider, &TrackSlider::ValueChangedSeconds, app_->player(), &Player::SeekTo);
|
||||
QObject::connect(ui_->track_slider, &TrackSlider::SeekForward, app_->player(), &Player::SeekForward);
|
||||
QObject::connect(ui_->track_slider, &TrackSlider::SeekBackward, app_->player(), &Player::SeekBackward);
|
||||
QObject::connect(ui_->track_slider, &TrackSlider::Previous, app_->player(), &Player::Previous);
|
||||
QObject::connect(ui_->track_slider, &TrackSlider::Next, app_->player(), &Player::Next);
|
||||
QObject::connect(ui_->track_slider, &TrackSlider::ValueChangedSeconds, &*app_->player(), &Player::SeekTo);
|
||||
QObject::connect(ui_->track_slider, &TrackSlider::SeekForward, &*app_->player(), &Player::SeekForward);
|
||||
QObject::connect(ui_->track_slider, &TrackSlider::SeekBackward, &*app_->player(), &Player::SeekBackward);
|
||||
QObject::connect(ui_->track_slider, &TrackSlider::Previous, &*app_->player(), &Player::Previous);
|
||||
QObject::connect(ui_->track_slider, &TrackSlider::Next, &*app_->player(), &Player::Next);
|
||||
|
||||
// Collection connections
|
||||
QObject::connect(app_->collection(), &SCollection::Error, this, &MainWindow::ShowErrorDialog);
|
||||
QObject::connect(&*app_->collection(), &SCollection::Error, this, &MainWindow::ShowErrorDialog);
|
||||
QObject::connect(collection_view_->view(), &CollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
|
||||
QObject::connect(collection_view_->view(), &CollectionView::ShowConfigDialog, this, &MainWindow::ShowCollectionConfig);
|
||||
QObject::connect(collection_view_->view(), &CollectionView::Error, this, &MainWindow::ShowErrorDialog);
|
||||
@ -642,10 +644,10 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
QObject::connect(app_->collection_model(), &CollectionModel::modelAboutToBeReset, collection_view_->view(), &CollectionView::SaveFocus);
|
||||
QObject::connect(app_->collection_model(), &CollectionModel::modelReset, collection_view_->view(), &CollectionView::RestoreFocus);
|
||||
|
||||
QObject::connect(app_->task_manager(), &TaskManager::PauseCollectionWatchers, app_->collection(), &SCollection::PauseWatcher);
|
||||
QObject::connect(app_->task_manager(), &TaskManager::ResumeCollectionWatchers, app_->collection(), &SCollection::ResumeWatcher);
|
||||
QObject::connect(&*app_->task_manager(), &TaskManager::PauseCollectionWatchers, &*app_->collection(), &SCollection::PauseWatcher);
|
||||
QObject::connect(&*app_->task_manager(), &TaskManager::ResumeCollectionWatchers, &*app_->collection(), &SCollection::ResumeWatcher);
|
||||
|
||||
QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &MainWindow::AlbumCoverLoaded);
|
||||
QObject::connect(&*app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &MainWindow::AlbumCoverLoaded);
|
||||
QObject::connect(album_cover_choice_controller_, &AlbumCoverChoiceController::Error, this, &MainWindow::ShowErrorDialog);
|
||||
QObject::connect(album_cover_choice_controller_->cover_from_file_action(), &QAction::triggered, this, &MainWindow::LoadCoverFromFile);
|
||||
QObject::connect(album_cover_choice_controller_->cover_to_file_action(), &QAction::triggered, this, &MainWindow::SaveCoverToFile);
|
||||
@ -700,8 +702,8 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
QObject::connect(tidal_view_->albums_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
|
||||
QObject::connect(tidal_view_->songs_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
|
||||
QObject::connect(tidal_view_->search_view(), &InternetSearchView::AddToPlaylist, this, &MainWindow::AddToPlaylist);
|
||||
if (TidalService *tidalservice = qobject_cast<TidalService*>(app_->internet_services()->ServiceBySource(Song::Source::Tidal))) {
|
||||
QObject::connect(this, &MainWindow::AuthorizationUrlReceived, tidalservice, &TidalService::AuthorizationUrlReceived);
|
||||
if (TidalServicePtr tidalservice = app_->internet_services()->Service<TidalService>()) {
|
||||
QObject::connect(this, &MainWindow::AuthorizationUrlReceived, &*tidalservice, &TidalService::AuthorizationUrlReceived);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -712,8 +714,8 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
QObject::connect(qobuz_view_->search_view(), &InternetSearchView::AddToPlaylist, this, &MainWindow::AddToPlaylist);
|
||||
#endif
|
||||
|
||||
QObject::connect(radio_view_, &RadioViewContainer::Refresh, app_->radio_services(), &RadioServices::RefreshChannels);
|
||||
QObject::connect(radio_view_->view(), &RadioView::GetChannels, app_->radio_services(), &RadioServices::GetChannels);
|
||||
QObject::connect(radio_view_, &RadioViewContainer::Refresh, &*app_->radio_services(), &RadioServices::RefreshChannels);
|
||||
QObject::connect(radio_view_->view(), &RadioView::GetChannels, &*app_->radio_services(), &RadioServices::GetChannels);
|
||||
QObject::connect(radio_view_->view(), &RadioView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
|
||||
|
||||
// Playlist menu
|
||||
@ -777,22 +779,22 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
QObject::connect(app_->device_manager()->connected_devices_model(), &DeviceStateFilterModel::IsEmptyChanged, playlist_copy_to_device_, &QAction::setDisabled);
|
||||
#endif
|
||||
|
||||
QObject::connect(app_->scrobbler(), &AudioScrobbler::ScrobblingEnabledChanged, this, &MainWindow::ScrobblingEnabledChanged);
|
||||
QObject::connect(app_->scrobbler(), &AudioScrobbler::ScrobbleButtonVisibilityChanged, this, &MainWindow::ScrobbleButtonVisibilityChanged);
|
||||
QObject::connect(app_->scrobbler(), &AudioScrobbler::LoveButtonVisibilityChanged, this, &MainWindow::LoveButtonVisibilityChanged);
|
||||
QObject::connect(&*app_->scrobbler()->settings(), &ScrobblerSettings::ScrobblingEnabledChanged, this, &MainWindow::ScrobblingEnabledChanged);
|
||||
QObject::connect(&*app_->scrobbler()->settings(), &ScrobblerSettings::ScrobbleButtonVisibilityChanged, this, &MainWindow::ScrobbleButtonVisibilityChanged);
|
||||
QObject::connect(&*app_->scrobbler()->settings(), &ScrobblerSettings::LoveButtonVisibilityChanged, this, &MainWindow::LoveButtonVisibilityChanged);
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
mac::SetApplicationHandler(this);
|
||||
#endif
|
||||
// Tray icon
|
||||
tray_icon_->SetupMenu(ui_->action_previous_track, ui_->action_play_pause, ui_->action_stop, ui_->action_stop_after_this_track, ui_->action_next_track, ui_->action_mute, ui_->action_love, ui_->action_quit);
|
||||
QObject::connect(tray_icon_.get(), &SystemTrayIcon::PlayPause, app_->player(), &Player::PlayPauseHelper);
|
||||
QObject::connect(tray_icon_.get(), &SystemTrayIcon::SeekForward, app_->player(), &Player::SeekForward);
|
||||
QObject::connect(tray_icon_.get(), &SystemTrayIcon::SeekBackward, app_->player(), &Player::SeekBackward);
|
||||
QObject::connect(tray_icon_.get(), &SystemTrayIcon::NextTrack, app_->player(), &Player::Next);
|
||||
QObject::connect(tray_icon_.get(), &SystemTrayIcon::PreviousTrack, app_->player(), &Player::Previous);
|
||||
QObject::connect(tray_icon_.get(), &SystemTrayIcon::ShowHide, this, &MainWindow::ToggleShowHide);
|
||||
QObject::connect(tray_icon_.get(), &SystemTrayIcon::ChangeVolume, this, &MainWindow::VolumeWheelEvent);
|
||||
QObject::connect(&*tray_icon_, &SystemTrayIcon::PlayPause, &*app_->player(), &Player::PlayPauseHelper);
|
||||
QObject::connect(&*tray_icon_, &SystemTrayIcon::SeekForward, &*app_->player(), &Player::SeekForward);
|
||||
QObject::connect(&*tray_icon_, &SystemTrayIcon::SeekBackward, &*app_->player(), &Player::SeekBackward);
|
||||
QObject::connect(&*tray_icon_, &SystemTrayIcon::NextTrack, &*app_->player(), &Player::Next);
|
||||
QObject::connect(&*tray_icon_, &SystemTrayIcon::PreviousTrack, &*app_->player(), &Player::Previous);
|
||||
QObject::connect(&*tray_icon_, &SystemTrayIcon::ShowHide, this, &MainWindow::ToggleShowHide);
|
||||
QObject::connect(&*tray_icon_, &SystemTrayIcon::ChangeVolume, this, &MainWindow::VolumeWheelEvent);
|
||||
|
||||
// Windows 7 thumbbar buttons
|
||||
#ifdef Q_OS_WIN
|
||||
@ -806,35 +808,35 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
|
||||
#ifdef HAVE_GLOBALSHORTCUTS
|
||||
// Global shortcuts
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Play, app_->player(), &Player::PlayHelper);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Pause, app_->player(), &Player::Pause);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Play, &*app_->player(), &Player::PlayHelper);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Pause, &*app_->player(), &Player::Pause);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::PlayPause, ui_->action_play_pause, &QAction::trigger);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Stop, ui_->action_stop, &QAction::trigger);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::StopAfter, ui_->action_stop_after_this_track, &QAction::trigger);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Next, ui_->action_next_track, &QAction::trigger);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Previous, ui_->action_previous_track, &QAction::trigger);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::IncVolume, app_->player(), &Player::VolumeUp);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::DecVolume, app_->player(), &Player::VolumeDown);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Mute, app_->player(), &Player::Mute);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::SeekForward, app_->player(), &Player::SeekForward);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::SeekBackward, app_->player(), &Player::SeekBackward);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::IncVolume, &*app_->player(), &Player::VolumeUp);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::DecVolume, &*app_->player(), &Player::VolumeDown);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Mute, &*app_->player(), &Player::Mute);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::SeekForward, &*app_->player(), &Player::SeekForward);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::SeekBackward, &*app_->player(), &Player::SeekBackward);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ShowHide, this, &MainWindow::ToggleShowHide);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ShowOSD, app_->player(), &Player::ShowOSD);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::TogglePrettyOSD, app_->player(), &Player::TogglePrettyOSD);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ToggleScrobbling, app_->scrobbler(), &AudioScrobbler::ToggleScrobbling);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Love, app_->scrobbler(), &AudioScrobbler::Love);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ShowOSD, &*app_->player(), &Player::ShowOSD);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::TogglePrettyOSD, &*app_->player(), &Player::TogglePrettyOSD);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ToggleScrobbling, &*app_->scrobbler(), &AudioScrobbler::ToggleScrobbling);
|
||||
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Love, &*app_->scrobbler(), &AudioScrobbler::Love);
|
||||
#endif
|
||||
|
||||
// Fancy tabs
|
||||
QObject::connect(ui_->tabs, &FancyTabWidget::CurrentChanged, this, &MainWindow::TabSwitched);
|
||||
|
||||
// Context
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, context_view_, &ContextView::SongChanged);
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::SongMetadataChanged, context_view_, &ContextView::SongChanged);
|
||||
QObject::connect(app_->player(), &Player::PlaylistFinished, context_view_, &ContextView::Stopped);
|
||||
QObject::connect(app_->player(), &Player::Playing, context_view_, &ContextView::Playing);
|
||||
QObject::connect(app_->player(), &Player::Stopped, context_view_, &ContextView::Stopped);
|
||||
QObject::connect(app_->player(), &Player::Error, context_view_, &ContextView::Error);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, context_view_, &ContextView::SongChanged);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::SongMetadataChanged, context_view_, &ContextView::SongChanged);
|
||||
QObject::connect(&*app_->player(), &Player::PlaylistFinished, context_view_, &ContextView::Stopped);
|
||||
QObject::connect(&*app_->player(), &Player::Playing, context_view_, &ContextView::Playing);
|
||||
QObject::connect(&*app_->player(), &Player::Stopped, context_view_, &ContextView::Stopped);
|
||||
QObject::connect(&*app_->player(), &Player::Error, context_view_, &ContextView::Error);
|
||||
QObject::connect(this, &MainWindow::AlbumCoverReady, context_view_, &ContextView::AlbumCoverLoaded);
|
||||
QObject::connect(this, &MainWindow::SearchCoverInProgress, context_view_->album_widget(), &ContextAlbum::SearchCoverInProgress);
|
||||
QObject::connect(context_view_, &ContextView::AlbumEnabledChanged, this, &MainWindow::TabSwitched);
|
||||
@ -851,17 +853,17 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
|
||||
#ifdef HAVE_MOODBAR
|
||||
// Moodbar connections
|
||||
QObject::connect(app_->moodbar_controller(), &MoodbarController::CurrentMoodbarDataChanged, ui_->track_slider->moodbar_style(), &MoodbarProxyStyle::SetMoodbarData);
|
||||
QObject::connect(&*app_->moodbar_controller(), &MoodbarController::CurrentMoodbarDataChanged, ui_->track_slider->moodbar_style(), &MoodbarProxyStyle::SetMoodbarData);
|
||||
#endif
|
||||
|
||||
// Playing widget
|
||||
qLog(Debug) << "Creating playing widget";
|
||||
ui_->widget_playing->set_ideal_height(ui_->status_bar->sizeHint().height() + ui_->player_controls->sizeHint().height());
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, ui_->widget_playing, &PlayingWidget::SongChanged);
|
||||
QObject::connect(app_->player(), &Player::PlaylistFinished, ui_->widget_playing, &PlayingWidget::Stopped);
|
||||
QObject::connect(app_->player(), &Player::Playing, ui_->widget_playing, &PlayingWidget::Playing);
|
||||
QObject::connect(app_->player(), &Player::Stopped, ui_->widget_playing, &PlayingWidget::Stopped);
|
||||
QObject::connect(app_->player(), &Player::Error, ui_->widget_playing, &PlayingWidget::Error);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, ui_->widget_playing, &PlayingWidget::SongChanged);
|
||||
QObject::connect(&*app_->player(), &Player::PlaylistFinished, ui_->widget_playing, &PlayingWidget::Stopped);
|
||||
QObject::connect(&*app_->player(), &Player::Playing, ui_->widget_playing, &PlayingWidget::Playing);
|
||||
QObject::connect(&*app_->player(), &Player::Stopped, ui_->widget_playing, &PlayingWidget::Stopped);
|
||||
QObject::connect(&*app_->player(), &Player::Error, ui_->widget_playing, &PlayingWidget::Error);
|
||||
QObject::connect(ui_->widget_playing, &PlayingWidget::ShowAboveStatusBarChanged, this, &MainWindow::PlayingWidgetPositionChanged);
|
||||
QObject::connect(this, &MainWindow::AlbumCoverReady, ui_->widget_playing, &PlayingWidget::AlbumCoverLoaded);
|
||||
QObject::connect(this, &MainWindow::SearchCoverInProgress, ui_->widget_playing, &PlayingWidget::SearchCoverInProgress);
|
||||
@ -891,15 +893,15 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
// Smart playlists
|
||||
QObject::connect(smartplaylists_view_, &SmartPlaylistsViewContainer::AddToPlaylist, this, &MainWindow::AddToPlaylist);
|
||||
|
||||
ScrobbleButtonVisibilityChanged(app_->scrobbler()->ScrobbleButton());
|
||||
LoveButtonVisibilityChanged(app_->scrobbler()->LoveButton());
|
||||
ScrobblingEnabledChanged(app_->scrobbler()->IsEnabled());
|
||||
ScrobbleButtonVisibilityChanged(app_->scrobbler()->scrobble_button());
|
||||
LoveButtonVisibilityChanged(app_->scrobbler()->love_button());
|
||||
ScrobblingEnabledChanged(app_->scrobbler()->enabled());
|
||||
|
||||
// Last.fm ImportData
|
||||
QObject::connect(app_->lastfm_import(), &LastFMImport::Finished, lastfm_import_dialog_, &LastFMImportDialog::Finished);
|
||||
QObject::connect(app_->lastfm_import(), &LastFMImport::FinishedWithError, lastfm_import_dialog_, &LastFMImportDialog::FinishedWithError);
|
||||
QObject::connect(app_->lastfm_import(), &LastFMImport::UpdateTotal, lastfm_import_dialog_, &LastFMImportDialog::UpdateTotal);
|
||||
QObject::connect(app_->lastfm_import(), &LastFMImport::UpdateProgress, lastfm_import_dialog_, &LastFMImportDialog::UpdateProgress);
|
||||
QObject::connect(&*app_->lastfm_import(), &LastFMImport::Finished, lastfm_import_dialog_, &LastFMImportDialog::Finished);
|
||||
QObject::connect(&*app_->lastfm_import(), &LastFMImport::FinishedWithError, lastfm_import_dialog_, &LastFMImportDialog::FinishedWithError);
|
||||
QObject::connect(&*app_->lastfm_import(), &LastFMImport::UpdateTotal, lastfm_import_dialog_, &LastFMImportDialog::UpdateTotal);
|
||||
QObject::connect(&*app_->lastfm_import(), &LastFMImport::UpdateProgress, lastfm_import_dialog_, &LastFMImportDialog::UpdateProgress);
|
||||
|
||||
// Load settings
|
||||
qLog(Debug) << "Loading settings";
|
||||
@ -1008,7 +1010,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
if (!options.contains_play_options()) {
|
||||
LoadPlaybackStatus();
|
||||
}
|
||||
if (app_->scrobbler()->IsEnabled() && !app_->scrobbler()->IsOffline()) {
|
||||
if (app_->scrobbler()->enabled() && !app_->scrobbler()->offline()) {
|
||||
app_->scrobbler()->Submit();
|
||||
}
|
||||
|
||||
@ -1134,7 +1136,6 @@ void MainWindow::ReloadSettings() {
|
||||
else {
|
||||
ui_->tabs->DisableTab(subsonic_view_);
|
||||
}
|
||||
app_->scrobbler()->Service<SubsonicScrobbler>()->ReloadSettings();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIDAL
|
||||
@ -1239,7 +1240,7 @@ void MainWindow::Exit() {
|
||||
else {
|
||||
if (app_->player()->engine()->is_fadeout_enabled()) {
|
||||
// To shut down the application when fadeout will be finished
|
||||
QObject::connect(app_->player()->engine(), &EngineBase::FadeoutFinishedSignal, this, &MainWindow::DoExit);
|
||||
QObject::connect(&*app_->player()->engine(), &EngineBase::FadeoutFinishedSignal, this, &MainWindow::DoExit);
|
||||
if (app_->player()->GetState() == EngineBase::State::Playing) {
|
||||
app_->player()->Stop();
|
||||
ignore_close_ = true;
|
||||
@ -1355,7 +1356,7 @@ void MainWindow::SendNowPlaying() {
|
||||
|
||||
// Send now playing to scrobble services
|
||||
Playlist *playlist = app_->playlist_manager()->active();
|
||||
if (app_->scrobbler()->IsEnabled() && playlist && playlist->current_item() && playlist->current_item()->Metadata().is_metadata_good()) {
|
||||
if (app_->scrobbler()->enabled() && playlist && playlist->current_item() && playlist->current_item()->Metadata().is_metadata_good()) {
|
||||
app_->scrobbler()->UpdateNowPlaying(playlist->current_item()->Metadata());
|
||||
ui_->action_love->setEnabled(true);
|
||||
ui_->button_love->setEnabled(true);
|
||||
@ -1480,8 +1481,8 @@ void MainWindow::LoadPlaybackStatus() {
|
||||
s.endGroup();
|
||||
|
||||
if (resume_playback && playback_state != EngineBase::State::Empty && playback_state != EngineBase::State::Idle) {
|
||||
std::shared_ptr<QMetaObject::Connection> connection = std::make_shared<QMetaObject::Connection>();
|
||||
*connection = QObject::connect(app_->playlist_manager(), &PlaylistManager::AllPlaylistsLoaded, this, [this, connection]() {
|
||||
SharedPtr<QMetaObject::Connection> connection = make_shared<QMetaObject::Connection>();
|
||||
*connection = QObject::connect(&*app_->playlist_manager(), &PlaylistManager::AllPlaylistsLoaded, this, [this, connection]() {
|
||||
QObject::disconnect(*connection);
|
||||
QTimer::singleShot(400ms, this, &MainWindow::ResumePlayback);
|
||||
});
|
||||
@ -1504,10 +1505,10 @@ void MainWindow::ResumePlayback() {
|
||||
// Set active to current to resume playback on correct playlist.
|
||||
app_->playlist_manager()->SetActiveToCurrent();
|
||||
if (playback_state == EngineBase::State::Paused) {
|
||||
std::shared_ptr<QMetaObject::Connection> connection = std::make_shared<QMetaObject::Connection>();
|
||||
*connection = QObject::connect(app_->player(), &Player::Playing, app_->player(), [this, connection]() {
|
||||
SharedPtr<QMetaObject::Connection> connection = make_shared<QMetaObject::Connection>();
|
||||
*connection = QObject::connect(&*app_->player(), &Player::Playing, &*app_->player(), [this, connection]() {
|
||||
QObject::disconnect(*connection);
|
||||
QTimer::singleShot(300, app_->player(), &Player::PlayPauseHelper);
|
||||
QTimer::singleShot(300, &*app_->player(), &Player::PlayPauseHelper);
|
||||
});
|
||||
}
|
||||
app_->player()->Play(playback_position * kNsecPerSec);
|
||||
@ -1682,7 +1683,7 @@ void MainWindow::UpdateTrackPosition() {
|
||||
if (position % 10 == 0) tray_icon_->SetProgress(static_cast<int>(static_cast<double>(position) / static_cast<double>(length) * 100.0));
|
||||
|
||||
// Send Scrobble
|
||||
if (app_->scrobbler()->IsEnabled() && item->Metadata().is_metadata_good()) {
|
||||
if (app_->scrobbler()->enabled() && item->Metadata().is_metadata_good()) {
|
||||
Playlist *playlist = app_->playlist_manager()->active();
|
||||
if (playlist && !playlist->scrobbled()) {
|
||||
const qint64 scrobble_point = (playlist->scrobble_point_nanosec() / kNsecPerSec);
|
||||
@ -2926,15 +2927,15 @@ void MainWindow::AutoCompleteTags() {
|
||||
|
||||
// Create the tag fetching stuff if it hasn't been already
|
||||
if (!tag_fetcher_) {
|
||||
tag_fetcher_ = std::make_unique<TagFetcher>(app_->network());
|
||||
track_selection_dialog_ = std::make_unique<TrackSelectionDialog>();
|
||||
tag_fetcher_ = make_unique<TagFetcher>(app_->network());
|
||||
track_selection_dialog_ = make_unique<TrackSelectionDialog>();
|
||||
track_selection_dialog_->set_save_on_close(true);
|
||||
|
||||
QObject::connect(tag_fetcher_.get(), &TagFetcher::ResultAvailable, track_selection_dialog_.get(), &TrackSelectionDialog::FetchTagFinished, Qt::QueuedConnection);
|
||||
QObject::connect(tag_fetcher_.get(), &TagFetcher::Progress, track_selection_dialog_.get(), &TrackSelectionDialog::FetchTagProgress);
|
||||
QObject::connect(track_selection_dialog_.get(), &TrackSelectionDialog::accepted, this, &MainWindow::AutoCompleteTagsAccepted);
|
||||
QObject::connect(track_selection_dialog_.get(), &TrackSelectionDialog::finished, tag_fetcher_.get(), &TagFetcher::Cancel);
|
||||
QObject::connect(track_selection_dialog_.get(), &TrackSelectionDialog::Error, this, &MainWindow::ShowErrorDialog);
|
||||
QObject::connect(&*tag_fetcher_, &TagFetcher::ResultAvailable, &*track_selection_dialog_, &TrackSelectionDialog::FetchTagFinished, Qt::QueuedConnection);
|
||||
QObject::connect(&*tag_fetcher_, &TagFetcher::Progress, &*track_selection_dialog_, &TrackSelectionDialog::FetchTagProgress);
|
||||
QObject::connect(&*track_selection_dialog_, &TrackSelectionDialog::accepted, this, &MainWindow::AutoCompleteTagsAccepted);
|
||||
QObject::connect(&*track_selection_dialog_, &TrackSelectionDialog::finished, &*tag_fetcher_, &TagFetcher::Cancel);
|
||||
QObject::connect(&*track_selection_dialog_, &TrackSelectionDialog::Error, this, &MainWindow::ShowErrorDialog);
|
||||
}
|
||||
|
||||
// Get the selected songs and start fetching tags for them
|
||||
@ -3104,14 +3105,14 @@ void MainWindow::GetCoverAutomatically() {
|
||||
}
|
||||
|
||||
void MainWindow::ScrobblingEnabledChanged(const bool value) {
|
||||
if (app_->scrobbler()->ScrobbleButton()) SetToggleScrobblingIcon(value);
|
||||
if (app_->scrobbler()->scrobble_button()) SetToggleScrobblingIcon(value);
|
||||
}
|
||||
|
||||
void MainWindow::ScrobbleButtonVisibilityChanged(const bool value) {
|
||||
|
||||
ui_->button_scrobble->setVisible(value);
|
||||
ui_->action_toggle_scrobbling->setVisible(value);
|
||||
if (value) SetToggleScrobblingIcon(app_->scrobbler()->IsEnabled());
|
||||
if (value) SetToggleScrobblingIcon(app_->scrobbler()->enabled());
|
||||
|
||||
}
|
||||
|
||||
@ -3180,7 +3181,7 @@ void MainWindow::PlaylistDelete() {
|
||||
app_->player()->Next();
|
||||
}
|
||||
|
||||
std::shared_ptr<MusicStorage> storage = std::make_shared<FilesystemMusicStorage>(Song::Source::LocalFile, "/");
|
||||
SharedPtr<MusicStorage> storage = make_shared<FilesystemMusicStorage>(Song::Source::LocalFile, "/");
|
||||
DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true);
|
||||
//QObject::connect(delete_files, &DeleteFiles::Finished, this, &MainWindow::DeleteFinished);
|
||||
delete_files->Start(selected_songs);
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
@ -48,6 +46,8 @@
|
||||
#include <QSettings>
|
||||
#include <QtEvents>
|
||||
|
||||
#include "scoped_ptr.h"
|
||||
#include "shared_ptr.h"
|
||||
#include "lazy.h"
|
||||
#include "platforminterface.h"
|
||||
#include "song.h"
|
||||
@ -104,7 +104,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_icon, OSDBase *osd, const CommandlineOptions &options, QWidget *parent = nullptr);
|
||||
explicit MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OSDBase *osd, const CommandlineOptions &options, QWidget *parent = nullptr);
|
||||
~MainWindow() override;
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
@ -297,7 +297,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
#endif
|
||||
|
||||
Application *app_;
|
||||
std::shared_ptr<SystemTrayIcon> tray_icon_;
|
||||
SharedPtr<SystemTrayIcon> tray_icon_;
|
||||
OSDBase *osd_;
|
||||
Lazy<About> about_dialog_;
|
||||
Lazy<Console> console_;
|
||||
@ -318,7 +318,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
Lazy<ErrorDialog> error_dialog_;
|
||||
Lazy<SettingsDialog> settings_dialog_;
|
||||
Lazy<AlbumCoverManager> cover_manager_;
|
||||
std::unique_ptr<Equalizer> equalizer_;
|
||||
SharedPtr<Equalizer> equalizer_;
|
||||
Lazy<OrganizeDialog> organize_dialog_;
|
||||
#ifdef HAVE_GSTREAMER
|
||||
Lazy<TranscodeDialog> transcode_dialog_;
|
||||
@ -326,9 +326,9 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
Lazy<AddStreamDialog> add_stream_dialog_;
|
||||
|
||||
#ifdef HAVE_MUSICBRAINZ
|
||||
std::unique_ptr<TagFetcher> tag_fetcher_;
|
||||
ScopedPtr<TagFetcher> tag_fetcher_;
|
||||
#endif
|
||||
std::unique_ptr<TrackSelectionDialog> track_selection_dialog_;
|
||||
ScopedPtr<TrackSelectionDialog> track_selection_dialog_;
|
||||
PlaylistItemPtrList autocomplete_tag_items_;
|
||||
|
||||
SmartPlaylistsViewContainer *smartplaylists_view_;
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
|
||||
#include <QObject>
|
||||
@ -36,6 +35,8 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
|
||||
class QMimeData;
|
||||
|
||||
std::size_t hash_value(const QModelIndex &idx);
|
||||
@ -112,7 +113,7 @@ class MergedProxyModel : public QAbstractProxyModel {
|
||||
|
||||
QHash<QAbstractItemModel*, QModelIndex> old_merge_points_;
|
||||
|
||||
std::unique_ptr<MergedProxyModelPrivate> p_;
|
||||
ScopedPtr<MergedProxyModelPrivate> p_;
|
||||
};
|
||||
|
||||
#endif // MERGEDPROXYMODEL_H
|
||||
|
@ -118,16 +118,16 @@ Mpris2::Mpris2(Application *app, QObject *parent)
|
||||
return;
|
||||
}
|
||||
|
||||
QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &Mpris2::AlbumCoverLoaded);
|
||||
QObject::connect(&*app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &Mpris2::AlbumCoverLoaded);
|
||||
|
||||
QObject::connect(app_->player()->engine(), &EngineBase::StateChanged, this, &Mpris2::EngineStateChanged);
|
||||
QObject::connect(app_->player(), &Player::VolumeChanged, this, &Mpris2::VolumeChanged);
|
||||
QObject::connect(app_->player(), &Player::Seeked, this, &Mpris2::Seeked);
|
||||
QObject::connect(&*app_->player()->engine(), &EngineBase::StateChanged, this, &Mpris2::EngineStateChanged);
|
||||
QObject::connect(&*app_->player(), &Player::VolumeChanged, this, &Mpris2::VolumeChanged);
|
||||
QObject::connect(&*app_->player(), &Player::Seeked, this, &Mpris2::Seeked);
|
||||
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::PlaylistManagerInitialized, this, &Mpris2::PlaylistManagerInitialized);
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &Mpris2::CurrentSongChanged);
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::PlaylistChanged, this, &Mpris2::PlaylistChangedSlot);
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentChanged, this, &Mpris2::PlaylistCollectionChanged);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::PlaylistManagerInitialized, this, &Mpris2::PlaylistManagerInitialized);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &Mpris2::CurrentSongChanged);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::PlaylistChanged, this, &Mpris2::PlaylistChangedSlot);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentChanged, this, &Mpris2::PlaylistCollectionChanged);
|
||||
|
||||
app_name_[0] = app_name_[0].toUpper();
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <QList>
|
||||
#include <QImage>
|
||||
|
||||
#include "shared_ptr.h"
|
||||
#include "song.h"
|
||||
|
||||
class MusicStorage {
|
||||
@ -102,6 +103,6 @@ class MusicStorage {
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(MusicStorage*)
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<MusicStorage>)
|
||||
Q_DECLARE_METATYPE(SharedPtr<MusicStorage>)
|
||||
|
||||
#endif // MUSICSTORAGE_H
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "core/logging.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
|
||||
#include "scoped_ptr.h"
|
||||
#include "shared_ptr.h"
|
||||
#include "song.h"
|
||||
#include "urlhandler.h"
|
||||
#include "application.h"
|
||||
@ -65,6 +67,8 @@
|
||||
#include "settings/behavioursettingspage.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
const char *Player::kSettingsGroup = "Player";
|
||||
|
||||
Player::Player(Application *app, QObject *parent)
|
||||
@ -108,7 +112,7 @@ EngineBase::Type Player::CreateEngine(EngineBase::Type enginetype) {
|
||||
#ifdef HAVE_GSTREAMER
|
||||
case EngineBase::Type::GStreamer:{
|
||||
use_enginetype=EngineBase::Type::GStreamer;
|
||||
std::unique_ptr<GstEngine> gst_engine(new GstEngine(app_->task_manager()));
|
||||
ScopedPtr<GstEngine> gst_engine(new GstEngine(app_->task_manager()));
|
||||
gst_engine->SetStartup(gst_startup_);
|
||||
engine_.reset(gst_engine.release());
|
||||
break;
|
||||
@ -117,7 +121,7 @@ EngineBase::Type Player::CreateEngine(EngineBase::Type enginetype) {
|
||||
#ifdef HAVE_VLC
|
||||
case EngineBase::Type::VLC:
|
||||
use_enginetype = EngineBase::Type::VLC;
|
||||
engine_ = std::make_shared<VLCEngine>(app_->task_manager());
|
||||
engine_ = make_shared<VLCEngine>(app_->task_manager());
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@ -163,23 +167,23 @@ void Player::Init() {
|
||||
qFatal("Error initializing audio engine");
|
||||
}
|
||||
|
||||
analyzer_->SetEngine(engine_.get());
|
||||
analyzer_->SetEngine(engine_);
|
||||
|
||||
QObject::connect(engine_.get(), &EngineBase::Error, this, &Player::Error);
|
||||
QObject::connect(engine_.get(), &EngineBase::FatalError, this, &Player::FatalError);
|
||||
QObject::connect(engine_.get(), &EngineBase::ValidSongRequested, this, &Player::ValidSongRequested);
|
||||
QObject::connect(engine_.get(), &EngineBase::InvalidSongRequested, this, &Player::InvalidSongRequested);
|
||||
QObject::connect(engine_.get(), &EngineBase::StateChanged, this, &Player::EngineStateChanged);
|
||||
QObject::connect(engine_.get(), &EngineBase::TrackAboutToEnd, this, &Player::TrackAboutToEnd);
|
||||
QObject::connect(engine_.get(), &EngineBase::TrackEnded, this, &Player::TrackEnded);
|
||||
QObject::connect(engine_.get(), &EngineBase::MetaData, this, &Player::EngineMetadataReceived);
|
||||
QObject::connect(engine_.get(), &EngineBase::VolumeChanged, this, &Player::SetVolumeFromEngine);
|
||||
QObject::connect(&*engine_, &EngineBase::Error, this, &Player::Error);
|
||||
QObject::connect(&*engine_, &EngineBase::FatalError, this, &Player::FatalError);
|
||||
QObject::connect(&*engine_, &EngineBase::ValidSongRequested, this, &Player::ValidSongRequested);
|
||||
QObject::connect(&*engine_, &EngineBase::InvalidSongRequested, this, &Player::InvalidSongRequested);
|
||||
QObject::connect(&*engine_, &EngineBase::StateChanged, this, &Player::EngineStateChanged);
|
||||
QObject::connect(&*engine_, &EngineBase::TrackAboutToEnd, this, &Player::TrackAboutToEnd);
|
||||
QObject::connect(&*engine_, &EngineBase::TrackEnded, this, &Player::TrackEnded);
|
||||
QObject::connect(&*engine_, &EngineBase::MetaData, this, &Player::EngineMetadataReceived);
|
||||
QObject::connect(&*engine_, &EngineBase::VolumeChanged, this, &Player::SetVolumeFromEngine);
|
||||
|
||||
// Equalizer
|
||||
QObject::connect(equalizer_, &Equalizer::StereoBalancerEnabledChanged, app_->player()->engine(), &EngineBase::SetStereoBalancerEnabled);
|
||||
QObject::connect(equalizer_, &Equalizer::StereoBalanceChanged, app_->player()->engine(), &EngineBase::SetStereoBalance);
|
||||
QObject::connect(equalizer_, &Equalizer::EqualizerEnabledChanged, app_->player()->engine(), &EngineBase::SetEqualizerEnabled);
|
||||
QObject::connect(equalizer_, &Equalizer::EqualizerParametersChanged, app_->player()->engine(), &EngineBase::SetEqualizerParameters);
|
||||
QObject::connect(&*equalizer_, &Equalizer::StereoBalancerEnabledChanged, &*app_->player()->engine(), &EngineBase::SetStereoBalancerEnabled);
|
||||
QObject::connect(&*equalizer_, &Equalizer::StereoBalanceChanged, &*app_->player()->engine(), &EngineBase::SetStereoBalance);
|
||||
QObject::connect(&*equalizer_, &Equalizer::EqualizerEnabledChanged, &*app_->player()->engine(), &EngineBase::SetEqualizerEnabled);
|
||||
QObject::connect(&*equalizer_, &Equalizer::EqualizerParametersChanged, &*app_->player()->engine(), &EngineBase::SetEqualizerParameters);
|
||||
|
||||
engine_->SetStereoBalancerEnabled(equalizer_->is_stereo_balancer_enabled());
|
||||
engine_->SetStereoBalance(equalizer_->stereo_balance());
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
@ -33,6 +31,7 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "shared_ptr.h"
|
||||
#include "urlhandler.h"
|
||||
#include "engine/enginebase.h"
|
||||
#include "engine/enginemetadata.h"
|
||||
@ -54,7 +53,7 @@ class PlayerInterface : public QObject {
|
||||
public:
|
||||
explicit PlayerInterface(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
virtual EngineBase *engine() const = 0;
|
||||
virtual SharedPtr<EngineBase> engine() const = 0;
|
||||
virtual EngineBase::State GetState() const = 0;
|
||||
virtual uint GetVolume() const = 0;
|
||||
|
||||
@ -130,14 +129,14 @@ class Player : public PlayerInterface {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Player(Application *app, QObject *parent);
|
||||
explicit Player(Application *app, QObject *parent = nullptr);
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
EngineBase::Type CreateEngine(EngineBase::Type Type);
|
||||
void Init();
|
||||
|
||||
EngineBase *engine() const override { return engine_.get(); }
|
||||
SharedPtr<EngineBase> engine() const override { return engine_; }
|
||||
EngineBase::State GetState() const override { return last_state_; }
|
||||
uint GetVolume() const override;
|
||||
|
||||
@ -152,7 +151,7 @@ class Player : public PlayerInterface {
|
||||
bool PreviousWouldRestartTrack() const;
|
||||
|
||||
void SetAnalyzer(AnalyzerContainer *analyzer) { analyzer_ = analyzer; }
|
||||
void SetEqualizer(Equalizer *equalizer) { equalizer_ = equalizer; }
|
||||
void SetEqualizer(SharedPtr<Equalizer> equalizer) { equalizer_ = equalizer; }
|
||||
|
||||
public slots:
|
||||
void ReloadSettings() override;
|
||||
@ -218,12 +217,12 @@ class Player : public PlayerInterface {
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
std::shared_ptr<EngineBase> engine_;
|
||||
SharedPtr<EngineBase> engine_;
|
||||
#ifdef HAVE_GSTREAMER
|
||||
GstStartup *gst_startup_;
|
||||
#endif
|
||||
AnalyzerContainer *analyzer_;
|
||||
Equalizer *equalizer_;
|
||||
SharedPtr<Equalizer> equalizer_;
|
||||
|
||||
PlaylistItemPtr current_item_;
|
||||
|
||||
|
28
src/core/scoped_ptr.h
Normal file
28
src/core/scoped_ptr.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2023, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SCOPED_PTR_H
|
||||
#define SCOPED_PTR_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
template <typename T, typename D = std::default_delete<T>>
|
||||
using ScopedPtr = std::unique_ptr<T, D>;
|
||||
|
||||
#endif // SCOPED_PTR_H
|
@ -21,11 +21,11 @@
|
||||
#ifndef SCOPEDWCHARARRAY_H
|
||||
#define SCOPEDWCHARARRAY_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "scoped_ptr.h"
|
||||
|
||||
class ScopedWCharArray {
|
||||
public:
|
||||
explicit ScopedWCharArray(const QString &str);
|
||||
@ -42,7 +42,7 @@ class ScopedWCharArray {
|
||||
Q_DISABLE_COPY(ScopedWCharArray)
|
||||
|
||||
qint64 chars_;
|
||||
std::unique_ptr<wchar_t[]> data_;
|
||||
ScopedPtr<wchar_t[]> data_;
|
||||
};
|
||||
|
||||
#endif // SCOPEDWCHARARRAY_H
|
||||
|
28
src/core/shared_ptr.h
Normal file
28
src/core/shared_ptr.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2023, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARED_PTR_H
|
||||
#define SHARED_PTR_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
template<typename T>
|
||||
using SharedPtr = std::shared_ptr<T>;
|
||||
|
||||
#endif // SHARED_PTR_H
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef HAVE_GSTREAMER
|
||||
@ -44,6 +43,7 @@
|
||||
|
||||
#include "core/logging.h"
|
||||
|
||||
#include "shared_ptr.h"
|
||||
#include "signalchecker.h"
|
||||
#include "player.h"
|
||||
#include "song.h"
|
||||
@ -65,13 +65,13 @@
|
||||
QSet<QString> SongLoader::sRawUriSchemes;
|
||||
const int SongLoader::kDefaultTimeout = 5000;
|
||||
|
||||
SongLoader::SongLoader(CollectionBackendInterface *collection, const Player *player, QObject *parent)
|
||||
SongLoader::SongLoader(SharedPtr<CollectionBackendInterface> collection_backend, const SharedPtr<Player> player, QObject *parent)
|
||||
: QObject(parent),
|
||||
player_(player),
|
||||
collection_(collection),
|
||||
collection_backend_(collection_backend),
|
||||
timeout_timer_(new QTimer(this)),
|
||||
playlist_parser_(new PlaylistParser(collection, this)),
|
||||
cue_parser_(new CueParser(collection, this)),
|
||||
playlist_parser_(new PlaylistParser(collection_backend, this)),
|
||||
cue_parser_(new CueParser(collection_backend, this)),
|
||||
parser_(nullptr),
|
||||
state_(State::WaitingForType),
|
||||
timeout_(kDefaultTimeout),
|
||||
@ -233,10 +233,10 @@ SongLoader::Result SongLoader::LoadLocal(const QString &filename) {
|
||||
// Search in the database.
|
||||
QUrl url = QUrl::fromLocalFile(filename);
|
||||
|
||||
QMutexLocker l(collection_->db()->Mutex());
|
||||
QSqlDatabase db(collection_->db()->Connect());
|
||||
QMutexLocker l(collection_backend_->db()->Mutex());
|
||||
QSqlDatabase db(collection_backend_->db()->Connect());
|
||||
|
||||
CollectionQuery query(db, collection_->songs_table(), collection_->fts_table());
|
||||
CollectionQuery query(db, collection_backend_->songs_table(), collection_backend_->fts_table());
|
||||
query.SetColumnSpec("%songs_table.ROWID, " + Song::kColumnSpec);
|
||||
query.AddWhere("url", url.toEncoded());
|
||||
|
||||
@ -348,7 +348,7 @@ void SongLoader::EffectiveSongLoad(Song *song) {
|
||||
}
|
||||
|
||||
// First, try to get the song from the collection
|
||||
Song collection_song = collection_->GetSongByUrl(song->url());
|
||||
Song collection_song = collection_backend_->GetSongByUrl(song->url());
|
||||
if (collection_song.is_valid()) {
|
||||
*song = collection_song;
|
||||
}
|
||||
@ -429,7 +429,7 @@ void SongLoader::StopTypefind() {
|
||||
#ifdef HAVE_GSTREAMER
|
||||
// Destroy the pipeline
|
||||
if (pipeline_) {
|
||||
gst_element_set_state(pipeline_.get(), GST_STATE_NULL);
|
||||
gst_element_set_state(&*pipeline_, GST_STATE_NULL);
|
||||
CleanupPipeline();
|
||||
}
|
||||
#endif
|
||||
@ -471,7 +471,7 @@ SongLoader::Result SongLoader::LoadRemote() {
|
||||
ScheduleTimeoutAsync();
|
||||
|
||||
// Create the pipeline - it gets unreffed if it goes out of scope
|
||||
std::shared_ptr<GstElement> pipeline(gst_pipeline_new(nullptr), std::bind(&gst_object_unref, std::placeholders::_1));
|
||||
SharedPtr<GstElement> pipeline(gst_pipeline_new(nullptr), std::bind(&gst_object_unref, std::placeholders::_1));
|
||||
|
||||
// Create the source element automatically based on the URL
|
||||
GstElement *source = gst_element_make_from_uri(GST_URI_SRC, url_.toEncoded().constData(), nullptr, nullptr);
|
||||
@ -479,7 +479,7 @@ SongLoader::Result SongLoader::LoadRemote() {
|
||||
errors_ << tr("Couldn't create GStreamer source element for %1").arg(url_.toString());
|
||||
return Result::Error;
|
||||
}
|
||||
gst_bin_add(GST_BIN(pipeline.get()), source);
|
||||
gst_bin_add(GST_BIN(&*pipeline), source);
|
||||
|
||||
g_object_set(source, "ssl-strict", FALSE, nullptr);
|
||||
|
||||
@ -489,14 +489,14 @@ SongLoader::Result SongLoader::LoadRemote() {
|
||||
errors_ << tr("Couldn't create GStreamer typefind element for %1").arg(url_.toString());
|
||||
return Result::Error;
|
||||
}
|
||||
gst_bin_add(GST_BIN(pipeline.get()), typefind);
|
||||
gst_bin_add(GST_BIN(&*pipeline), typefind);
|
||||
|
||||
fakesink_ = gst_element_factory_make("fakesink", nullptr);
|
||||
if (!fakesink_) {
|
||||
errors_ << tr("Couldn't create GStreamer fakesink element for %1").arg(url_.toString());
|
||||
return Result::Error;
|
||||
}
|
||||
gst_bin_add(GST_BIN(pipeline.get()), fakesink_);
|
||||
gst_bin_add(GST_BIN(&*pipeline), fakesink_);
|
||||
|
||||
if (!gst_element_link_many(source, typefind, fakesink_, nullptr)) {
|
||||
errors_ << tr("Couldn't link GStreamer source, typefind and fakesink elements for %1").arg(url_.toString());
|
||||
@ -505,7 +505,7 @@ SongLoader::Result SongLoader::LoadRemote() {
|
||||
|
||||
// Connect callbacks
|
||||
CHECKED_GCONNECT(typefind, "have-type", &TypeFound, this);
|
||||
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline.get()));
|
||||
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(&*pipeline));
|
||||
if (bus) {
|
||||
gst_bus_set_sync_handler(bus, BusCallbackSync, this, nullptr);
|
||||
gst_bus_add_watch(bus, BusWatchCallback, this);
|
||||
@ -524,7 +524,7 @@ SongLoader::Result SongLoader::LoadRemote() {
|
||||
|
||||
// Start "playing"
|
||||
pipeline_ = pipeline;
|
||||
gst_element_set_state(pipeline.get(), GST_STATE_PLAYING);
|
||||
gst_element_set_state(&*pipeline, GST_STATE_PLAYING);
|
||||
|
||||
// Wait until loading is finished
|
||||
loop.exec();
|
||||
@ -718,7 +718,7 @@ bool SongLoader::IsPipelinePlaying() {
|
||||
|
||||
GstState state = GST_STATE_NULL;
|
||||
GstState pending_state = GST_STATE_NULL;
|
||||
GstStateChangeReturn ret = gst_element_get_state(pipeline_.get(), &state, &pending_state, GST_SECOND);
|
||||
GstStateChangeReturn ret = gst_element_get_state(&*pipeline_, &state, &pending_state, GST_SECOND);
|
||||
|
||||
if (ret == GST_STATE_CHANGE_ASYNC && pending_state == GST_STATE_PLAYING) {
|
||||
// We're still on the way to playing
|
||||
@ -763,7 +763,7 @@ void SongLoader::CleanupPipeline() {
|
||||
|
||||
if (pipeline_) {
|
||||
|
||||
gst_element_set_state(pipeline_.get(), GST_STATE_NULL);
|
||||
gst_element_set_state(&*pipeline_, GST_STATE_NULL);
|
||||
|
||||
if (fakesink_ && buffer_probe_cb_id_ != 0) {
|
||||
GstPad *pad = gst_element_get_static_pad(fakesink_, "src");
|
||||
@ -774,7 +774,7 @@ void SongLoader::CleanupPipeline() {
|
||||
}
|
||||
|
||||
{
|
||||
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline_.get()));
|
||||
GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(&*pipeline_));
|
||||
if (bus) {
|
||||
gst_bus_remove_watch(bus);
|
||||
gst_bus_set_sync_handler(bus, nullptr, nullptr, nullptr);
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
#include "shared_ptr.h"
|
||||
#include "song.h"
|
||||
|
||||
class QTimer;
|
||||
@ -58,7 +59,7 @@ class SongLoader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SongLoader(CollectionBackendInterface *collection, const Player *player, QObject *parent = nullptr);
|
||||
explicit SongLoader(SharedPtr<CollectionBackendInterface> collection_backend, const SharedPtr<Player> player, QObject *parent = nullptr);
|
||||
~SongLoader() override;
|
||||
|
||||
enum class Result {
|
||||
@ -143,8 +144,8 @@ class SongLoader : public QObject {
|
||||
QUrl url_;
|
||||
SongList songs_;
|
||||
|
||||
const Player *player_;
|
||||
CollectionBackendInterface *collection_;
|
||||
const SharedPtr<Player> player_;
|
||||
SharedPtr<CollectionBackendInterface> collection_backend_;
|
||||
QTimer *timeout_timer_;
|
||||
PlaylistParser *playlist_parser_;
|
||||
CueParser *cue_parser_;
|
||||
@ -158,7 +159,7 @@ class SongLoader : public QObject {
|
||||
int timeout_;
|
||||
|
||||
#ifdef HAVE_GSTREAMER
|
||||
std::shared_ptr<GstElement> pipeline_;
|
||||
SharedPtr<GstElement> pipeline_;
|
||||
GstElement *fakesink_;
|
||||
gulong buffer_probe_cb_id_;
|
||||
#endif
|
||||
|
@ -35,9 +35,12 @@
|
||||
#include <QPalette>
|
||||
#include <QEvent>
|
||||
|
||||
#include "shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "stylesheetloader.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
StyleSheetLoader::StyleSheetLoader(QObject *parent) : QObject(parent) {}
|
||||
|
||||
void StyleSheetLoader::SetStyleSheet(QWidget *widget, const QString &filename) {
|
||||
@ -57,7 +60,7 @@ void StyleSheetLoader::SetStyleSheet(QWidget *widget, const QString &filename) {
|
||||
}
|
||||
file.close();
|
||||
|
||||
std::shared_ptr<StyleSheetData> styledata = std::make_shared<StyleSheetData>();
|
||||
SharedPtr<StyleSheetData> styledata = make_shared<StyleSheetData>();
|
||||
styledata->filename_ = filename;
|
||||
styledata->stylesheet_template_ = stylesheet;
|
||||
styledata->stylesheet_current_ = widget->styleSheet();
|
||||
@ -68,7 +71,7 @@ void StyleSheetLoader::SetStyleSheet(QWidget *widget, const QString &filename) {
|
||||
|
||||
}
|
||||
|
||||
void StyleSheetLoader::UpdateStyleSheet(QWidget *widget, std::shared_ptr<StyleSheetData> styledata) {
|
||||
void StyleSheetLoader::UpdateStyleSheet(QWidget *widget, SharedPtr<StyleSheetData> styledata) {
|
||||
|
||||
QString stylesheet = styledata->stylesheet_template_;
|
||||
|
||||
|
@ -24,14 +24,14 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPair>
|
||||
#include <QHash>
|
||||
#include <QPalette>
|
||||
#include <QString>
|
||||
|
||||
#include "shared_ptr.h"
|
||||
|
||||
class QWidget;
|
||||
class QEvent;
|
||||
|
||||
@ -58,11 +58,11 @@ class StyleSheetLoader : public QObject {
|
||||
};
|
||||
|
||||
private:
|
||||
void UpdateStyleSheet(QWidget *widget, std::shared_ptr<StyleSheetData> styledata);
|
||||
void UpdateStyleSheet(QWidget *widget, SharedPtr<StyleSheetData> styledata);
|
||||
static void ReplaceColor(QString *css, const QString &name, const QPalette &palette, const QPalette::ColorRole role);
|
||||
|
||||
private:
|
||||
QHash<QWidget*, std::shared_ptr<StyleSheetData>> styledata_;
|
||||
QHash<QWidget*, SharedPtr<StyleSheetData>> styledata_;
|
||||
};
|
||||
|
||||
#endif // STYLESHEETLOADER_H
|
||||
|
@ -577,7 +577,7 @@ void AlbumCoverChoiceController::SaveArtManualToSong(Song *song, const QUrl &art
|
||||
case Song::Source::Tidal:
|
||||
case Song::Source::Qobuz:
|
||||
case Song::Source::Subsonic:
|
||||
InternetService *service = app_->internet_services()->ServiceBySource(song->source());
|
||||
InternetServicePtr service = app_->internet_services()->ServiceBySource(song->source());
|
||||
if (!service) break;
|
||||
if (service->artists_collection_backend()) {
|
||||
service->artists_collection_backend()->UpdateManualAlbumArtAsync(song->effective_albumartist(), song->album(), art_manual);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QTimer>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/song.h"
|
||||
#include "albumcoverfetcher.h"
|
||||
@ -37,7 +38,7 @@ using namespace std::chrono_literals;
|
||||
|
||||
const int AlbumCoverFetcher::kMaxConcurrentRequests = 5;
|
||||
|
||||
AlbumCoverFetcher::AlbumCoverFetcher(CoverProviders *cover_providers, NetworkAccessManager *network, QObject *parent)
|
||||
AlbumCoverFetcher::AlbumCoverFetcher(SharedPtr<CoverProviders> cover_providers, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QObject(parent),
|
||||
cover_providers_(cover_providers),
|
||||
network_(network),
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include <QUrl>
|
||||
#include <QImage>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
#include "coversearchstatistics.h"
|
||||
#include "albumcoverimageresult.h"
|
||||
|
||||
@ -107,7 +109,7 @@ class AlbumCoverFetcher : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumCoverFetcher(CoverProviders *cover_providers, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit AlbumCoverFetcher(SharedPtr<CoverProviders> cover_providers, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~AlbumCoverFetcher() override;
|
||||
|
||||
static const int kMaxConcurrentRequests;
|
||||
@ -129,8 +131,8 @@ class AlbumCoverFetcher : public QObject {
|
||||
private:
|
||||
void AddRequest(const CoverSearchRequest &req);
|
||||
|
||||
CoverProviders *cover_providers_;
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<CoverProviders> cover_providers_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
quint64 next_id_;
|
||||
|
||||
QQueue<CoverSearchRequest> queued_requests_;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/networktimeouts.h"
|
||||
#include "utilities/imageutils.h"
|
||||
@ -51,7 +52,7 @@ const int AlbumCoverFetcherSearch::kImageLoadTimeoutMs = 6000;
|
||||
const int AlbumCoverFetcherSearch::kTargetSize = 500;
|
||||
const float AlbumCoverFetcherSearch::kGoodScore = 4.0;
|
||||
|
||||
AlbumCoverFetcherSearch::AlbumCoverFetcherSearch(const CoverSearchRequest &request, NetworkAccessManager *network, QObject *parent)
|
||||
AlbumCoverFetcherSearch::AlbumCoverFetcherSearch(const CoverSearchRequest &request, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: QObject(parent),
|
||||
request_(request),
|
||||
image_load_timeout_(new NetworkTimeouts(kImageLoadTimeoutMs, this)),
|
||||
@ -79,7 +80,7 @@ void AlbumCoverFetcherSearch::TerminateSearch() {
|
||||
|
||||
}
|
||||
|
||||
void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) {
|
||||
void AlbumCoverFetcherSearch::Start(SharedPtr<CoverProviders> cover_providers) {
|
||||
|
||||
// Ignore Radio Paradise "commercial" break.
|
||||
if (request_.artist.compare("commercial-free", Qt::CaseInsensitive) == 0 && request_.title.compare("listener-supported", Qt::CaseInsensitive) == 0) {
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <QUrl>
|
||||
#include <QImage>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "albumcoverfetcher.h"
|
||||
#include "coversearchstatistics.h"
|
||||
#include "albumcoverimageresult.h"
|
||||
@ -52,10 +53,10 @@ class AlbumCoverFetcherSearch : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumCoverFetcherSearch(const CoverSearchRequest &request, NetworkAccessManager *network, QObject *parent);
|
||||
explicit AlbumCoverFetcherSearch(const CoverSearchRequest &request, SharedPtr<NetworkAccessManager> network, QObject *parent);
|
||||
~AlbumCoverFetcherSearch() override;
|
||||
|
||||
void Start(CoverProviders *cover_providers);
|
||||
void Start(SharedPtr<CoverProviders> cover_providers);
|
||||
|
||||
// Cancels all pending requests. No Finished signals will be emitted, and it is the caller's responsibility to delete the AlbumCoverFetcherSearch.
|
||||
void Cancel();
|
||||
@ -114,7 +115,7 @@ class AlbumCoverFetcherSearch : public QObject {
|
||||
};
|
||||
QMultiMap<float, CandidateImage> candidate_images_;
|
||||
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
|
||||
bool cancel_requested_;
|
||||
|
||||
|
@ -102,7 +102,7 @@ void AlbumCoverLoader::CancelTasks(const QSet<quint64> &ids) {
|
||||
|
||||
quint64 AlbumCoverLoader::LoadImageAsync(const AlbumCoverLoaderOptions &options, const Song &song) {
|
||||
|
||||
TaskPtr task = std::make_shared<Task>();
|
||||
TaskPtr task = make_shared<Task>();
|
||||
task->options = options;
|
||||
task->art_embedded = song.art_embedded();
|
||||
task->art_automatic = song.art_automatic();
|
||||
@ -118,7 +118,7 @@ quint64 AlbumCoverLoader::LoadImageAsync(const AlbumCoverLoaderOptions &options,
|
||||
|
||||
quint64 AlbumCoverLoader::LoadImageAsync(const AlbumCoverLoaderOptions &options, const bool art_embedded, const QUrl &art_automatic, const QUrl &art_manual, const bool art_unset, const QUrl &song_url, const Song::Source song_source) {
|
||||
|
||||
TaskPtr task = std::make_shared<Task>();
|
||||
TaskPtr task = make_shared<Task>();
|
||||
task->options = options;
|
||||
task->art_embedded = art_embedded;
|
||||
task->art_automatic = art_automatic;
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
@ -34,6 +32,7 @@
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "albumcoverloaderoptions.h"
|
||||
#include "albumcoverloaderresult.h"
|
||||
@ -43,8 +42,6 @@ class QThread;
|
||||
class QNetworkReply;
|
||||
class NetworkAccessManager;
|
||||
|
||||
using std::shared_ptr;
|
||||
|
||||
class AlbumCoverLoader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
@ -94,7 +91,7 @@ class AlbumCoverLoader : public QObject {
|
||||
QUrl art_automatic_updated;
|
||||
int redirects;
|
||||
};
|
||||
using TaskPtr = shared_ptr<Task>;
|
||||
using TaskPtr = SharedPtr<Task>;
|
||||
|
||||
class LoadImageResult {
|
||||
public:
|
||||
@ -127,7 +124,7 @@ class AlbumCoverLoader : public QObject {
|
||||
|
||||
private:
|
||||
static const int kMaxRedirects = 3;
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
bool stop_requested_;
|
||||
QMutex mutex_load_image_async_;
|
||||
QQueue<TaskPtr> tasks_;
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
#include <QObject>
|
||||
@ -64,6 +63,8 @@
|
||||
#include <QSize>
|
||||
#include <QtEvents>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
@ -97,7 +98,7 @@
|
||||
const char *AlbumCoverManager::kSettingsGroup = "CoverManager";
|
||||
constexpr int AlbumCoverManager::kThumbnailSize = 120;
|
||||
|
||||
AlbumCoverManager::AlbumCoverManager(Application *app, CollectionBackend *collection_backend, QMainWindow *mainwindow, QWidget *parent)
|
||||
AlbumCoverManager::AlbumCoverManager(Application *app, SharedPtr<CollectionBackend> collection_backend, QMainWindow *mainwindow, QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
ui_(new Ui_CoverManager),
|
||||
mainwindow_(mainwindow),
|
||||
@ -231,7 +232,7 @@ void AlbumCoverManager::Init() {
|
||||
|
||||
s.endGroup();
|
||||
|
||||
QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &AlbumCoverManager::AlbumCoverLoaded);
|
||||
QObject::connect(&*app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &AlbumCoverManager::AlbumCoverLoaded);
|
||||
|
||||
cover_searcher_->Init(cover_fetcher_);
|
||||
|
||||
@ -255,7 +256,7 @@ void AlbumCoverManager::showEvent(QShowEvent *e) {
|
||||
void AlbumCoverManager::closeEvent(QCloseEvent *e) {
|
||||
|
||||
if (!cover_fetching_tasks_.isEmpty()) {
|
||||
std::unique_ptr<QMessageBox> message_box(new QMessageBox(QMessageBox::Question, tr("Really cancel?"), tr("Closing this window will stop searching for album covers."), QMessageBox::Abort, this));
|
||||
ScopedPtr<QMessageBox> message_box(new QMessageBox(QMessageBox::Question, tr("Really cancel?"), tr("Closing this window will stop searching for album covers."), QMessageBox::Abort, this));
|
||||
message_box->addButton(tr("Don't stop!"), QMessageBox::AcceptRole);
|
||||
|
||||
if (message_box->exec() != QMessageBox::Abort) {
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <QImage>
|
||||
#include <QIcon>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "albumcoverloaderoptions.h"
|
||||
@ -76,7 +77,7 @@ class AlbumCoverManager : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AlbumCoverManager(Application *app, CollectionBackend *collection_backend, QMainWindow *mainwindow, QWidget *parent = nullptr);
|
||||
explicit AlbumCoverManager(Application *app, SharedPtr<CollectionBackend> collection_backend, QMainWindow *mainwindow, QWidget *parent = nullptr);
|
||||
~AlbumCoverManager() override;
|
||||
|
||||
void Reset();
|
||||
@ -87,7 +88,7 @@ class AlbumCoverManager : public QMainWindow {
|
||||
|
||||
SongList GetSongsInAlbum(const QModelIndex &idx) const;
|
||||
|
||||
CollectionBackend *backend() const { return collection_backend_; }
|
||||
SharedPtr<CollectionBackend> collection_backend() const { return collection_backend_; }
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *e) override;
|
||||
@ -190,7 +191,7 @@ class AlbumCoverManager : public QMainWindow {
|
||||
Ui_CoverManager *ui_;
|
||||
QMainWindow *mainwindow_;
|
||||
Application *app_;
|
||||
CollectionBackend *collection_backend_;
|
||||
SharedPtr<CollectionBackend> collection_backend_;
|
||||
AlbumCoverChoiceController *album_cover_choice_controller_;
|
||||
|
||||
QAction *filter_all_;
|
||||
|
@ -21,8 +21,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
@ -33,6 +31,7 @@
|
||||
#include <QMimeData>
|
||||
#include <QDropEvent>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "playlist/songmimedata.h"
|
||||
@ -63,10 +62,10 @@ QMimeData *AlbumCoverManagerList::mimeData(const QList<QListWidgetItem*> items)
|
||||
}
|
||||
|
||||
// Get the QAbstractItemModel data so the picture works
|
||||
std::unique_ptr<QMimeData> orig_data(QListWidget::mimeData(items));
|
||||
ScopedPtr<QMimeData> orig_data(QListWidget::mimeData(items));
|
||||
|
||||
SongMimeData *mime_data = new SongMimeData;
|
||||
mime_data->backend = manager_->backend();
|
||||
mime_data->backend = manager_->collection_backend();
|
||||
mime_data->songs = songs;
|
||||
mime_data->setUrls(urls);
|
||||
mime_data->setData(orig_data->formats()[0], orig_data->data(orig_data->formats()[0]));
|
||||
|
@ -128,7 +128,7 @@ AlbumCoverSearcher::AlbumCoverSearcher(const QIcon &no_cover_icon, Application *
|
||||
ui_->covers->setItemDelegate(new SizeOverlayDelegate(this));
|
||||
ui_->covers->setModel(model_);
|
||||
|
||||
QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &AlbumCoverSearcher::AlbumCoverLoaded);
|
||||
QObject::connect(&*app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &AlbumCoverSearcher::AlbumCoverLoaded);
|
||||
QObject::connect(ui_->search, &QPushButton::clicked, this, &AlbumCoverSearcher::Search);
|
||||
QObject::connect(ui_->covers, &GroupedIconView::doubleClicked, this, &AlbumCoverSearcher::CoverDoubleClicked);
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <QNetworkRequest>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/mimeutils.h"
|
||||
#include "widgets/busyindicator.h"
|
||||
@ -38,7 +39,7 @@
|
||||
#include "coverfromurldialog.h"
|
||||
#include "ui_coverfromurldialog.h"
|
||||
|
||||
CoverFromURLDialog::CoverFromURLDialog(NetworkAccessManager *network, QWidget *parent)
|
||||
CoverFromURLDialog::CoverFromURLDialog(SharedPtr<NetworkAccessManager> network, QWidget *parent)
|
||||
: QDialog(parent),
|
||||
network_(network),
|
||||
ui_(new Ui_CoverFromURLDialog) {
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "albumcoverimageresult.h"
|
||||
|
||||
class QWidget;
|
||||
@ -40,7 +41,7 @@ class CoverFromURLDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CoverFromURLDialog(NetworkAccessManager *network, QWidget *parent = nullptr);
|
||||
explicit CoverFromURLDialog(SharedPtr<NetworkAccessManager> network, QWidget *parent = nullptr);
|
||||
~CoverFromURLDialog() override;
|
||||
|
||||
// Opens the dialog. This returns an image found at the URL chosen by user or null image if the dialog got rejected.
|
||||
@ -51,7 +52,7 @@ class CoverFromURLDialog : public QDialog {
|
||||
void LoadCoverFromURLFinished();
|
||||
|
||||
private:
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
Ui_CoverFromURLDialog *ui_;
|
||||
AlbumCoverImageResult last_album_cover_;
|
||||
};
|
||||
|
@ -24,7 +24,8 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "coverprovider.h"
|
||||
|
||||
CoverProvider::CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, NetworkAccessManager *network, QObject *parent) : QObject(parent), app_(app), network_(network), name_(name), enabled_(enabled), order_(0), authentication_required_(authentication_required), quality_(quality), batch_(batch), allow_missing_album_(allow_missing_album) {}
|
||||
CoverProvider::CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent) : QObject(parent), app_(app), network_(network), name_(name), enabled_(enabled), order_(0), authentication_required_(authentication_required), quality_(quality), batch_(batch), allow_missing_album_(allow_missing_album) {}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "albumcoverfetcher.h"
|
||||
|
||||
class Application;
|
||||
@ -41,7 +42,7 @@ class CoverProvider : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, NetworkAccessManager *network, QObject *parent);
|
||||
explicit CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent);
|
||||
|
||||
// A name (very short description) of this provider, like "last.fm".
|
||||
QString name() const { return name_; }
|
||||
@ -79,7 +80,7 @@ class CoverProvider : public QObject {
|
||||
using ParamList = QList<Param>;
|
||||
|
||||
Application *app_;
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
QString name_;
|
||||
bool enabled_;
|
||||
int order_;
|
||||
|
@ -36,6 +36,8 @@
|
||||
#include "albumcoverloaderresult.h"
|
||||
#include "currentalbumcoverloader.h"
|
||||
|
||||
using std::make_unique;
|
||||
|
||||
CurrentAlbumCoverLoader::CurrentAlbumCoverLoader(Application *app, QObject *parent)
|
||||
: QObject(parent),
|
||||
app_(app),
|
||||
@ -46,8 +48,8 @@ CurrentAlbumCoverLoader::CurrentAlbumCoverLoader(Application *app, QObject *pare
|
||||
options_.desired_scaled_size = QSize(120, 120);
|
||||
options_.default_cover = ":/pictures/cdcase.png";
|
||||
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &CurrentAlbumCoverLoader::LoadAlbumCover);
|
||||
QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &CurrentAlbumCoverLoader::AlbumCoverReady);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &CurrentAlbumCoverLoader::LoadAlbumCover);
|
||||
QObject::connect(&*app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &CurrentAlbumCoverLoader::AlbumCoverReady);
|
||||
|
||||
ReloadSettingsAsync();
|
||||
|
||||
@ -85,7 +87,7 @@ void CurrentAlbumCoverLoader::AlbumCoverReady(const quint64 id, AlbumCoverLoader
|
||||
id_ = 0;
|
||||
|
||||
if (!result.album_cover.image.isNull()) {
|
||||
temp_cover_ = std::make_unique<QTemporaryFile>(temp_file_pattern_);
|
||||
temp_cover_ = make_unique<QTemporaryFile>(temp_file_pattern_);
|
||||
temp_cover_->setAutoRemove(true);
|
||||
if (temp_cover_->open()) {
|
||||
if (result.album_cover.image.save(temp_cover_->fileName(), "JPEG")) {
|
||||
@ -102,7 +104,7 @@ void CurrentAlbumCoverLoader::AlbumCoverReady(const quint64 id, AlbumCoverLoader
|
||||
|
||||
QUrl thumbnail_url;
|
||||
if (!result.image_scaled.isNull()) {
|
||||
temp_cover_thumbnail_ = std::make_unique<QTemporaryFile>(temp_file_pattern_);
|
||||
temp_cover_thumbnail_ = make_unique<QTemporaryFile>(temp_file_pattern_);
|
||||
temp_cover_thumbnail_->setAutoRemove(true);
|
||||
if (temp_cover_thumbnail_->open()) {
|
||||
if (result.image_scaled.save(temp_cover_thumbnail_->fileName(), "JPEG")) {
|
||||
|
@ -24,14 +24,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "albumcoverloaderoptions.h"
|
||||
#include "albumcoverloaderresult.h"
|
||||
@ -67,12 +66,11 @@ class CurrentAlbumCoverLoader : public QObject {
|
||||
|
||||
QString temp_file_pattern_;
|
||||
|
||||
std::unique_ptr<QTemporaryFile> temp_cover_;
|
||||
std::unique_ptr<QTemporaryFile> temp_cover_thumbnail_;
|
||||
ScopedPtr<QTemporaryFile> temp_cover_;
|
||||
ScopedPtr<QTemporaryFile> temp_cover_thumbnail_;
|
||||
quint64 id_;
|
||||
|
||||
Song last_song_;
|
||||
|
||||
};
|
||||
|
||||
#endif // CURRENTALBUMCOVERLOADER_H
|
||||
|
@ -50,7 +50,7 @@
|
||||
const char *DeezerCoverProvider::kApiUrl = "https://api.deezer.com";
|
||||
const int DeezerCoverProvider::kLimit = 10;
|
||||
|
||||
DeezerCoverProvider::DeezerCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
DeezerCoverProvider::DeezerCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Deezer", true, false, 2.0, true, true, app, network, parent) {}
|
||||
|
||||
DeezerCoverProvider::~DeezerCoverProvider() {
|
||||
|
@ -40,7 +40,7 @@ class DeezerCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeezerCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit DeezerCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~DeezerCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <QJsonValue>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
@ -49,12 +50,14 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "discogscoverprovider.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
const char *DiscogsCoverProvider::kUrlSearch = "https://api.discogs.com/database/search";
|
||||
const char *DiscogsCoverProvider::kAccessKeyB64 = "dGh6ZnljUGJlZ1NEeXBuSFFxSVk=";
|
||||
const char *DiscogsCoverProvider::kSecretKeyB64 = "ZkFIcmlaSER4aHhRSlF2U3d0bm5ZVmdxeXFLWUl0UXI=";
|
||||
const int DiscogsCoverProvider::kRequestsDelay = 1000;
|
||||
|
||||
DiscogsCoverProvider::DiscogsCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
DiscogsCoverProvider::DiscogsCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Discogs", false, false, 0.0, false, false, app, network, parent),
|
||||
timer_flush_requests_(new QTimer(this)) {
|
||||
|
||||
@ -86,7 +89,7 @@ bool DiscogsCoverProvider::StartSearch(const QString &artist, const QString &alb
|
||||
|
||||
if (artist.isEmpty() || album.isEmpty()) return false;
|
||||
|
||||
std::shared_ptr<DiscogsCoverSearchContext> search = std::make_shared<DiscogsCoverSearchContext>(id, artist, album);
|
||||
SharedPtr<DiscogsCoverSearchContext> search = make_shared<DiscogsCoverSearchContext>(id, artist, album);
|
||||
|
||||
requests_search_.insert(search->id, search);
|
||||
queue_search_requests_.enqueue(search);
|
||||
@ -121,7 +124,7 @@ void DiscogsCoverProvider::FlushRequests() {
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::SendSearchRequest(std::shared_ptr<DiscogsCoverSearchContext> search) {
|
||||
void DiscogsCoverProvider::SendSearchRequest(SharedPtr<DiscogsCoverSearchContext> search) {
|
||||
|
||||
ParamList params = ParamList() << Param("format", "album")
|
||||
<< Param("artist", search->artist.toLower())
|
||||
@ -227,7 +230,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
reply->deleteLater();
|
||||
|
||||
if (!requests_search_.contains(id)) return;
|
||||
std::shared_ptr<DiscogsCoverSearchContext> search = requests_search_.value(id);
|
||||
SharedPtr<DiscogsCoverSearchContext> search = requests_search_.value(id);
|
||||
|
||||
QByteArray data = GetReplyData(reply);
|
||||
if (data.isEmpty()) {
|
||||
@ -307,7 +310,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::StartReleaseRequest(std::shared_ptr<DiscogsCoverSearchContext> search, const quint64 release_id, const QUrl &url) {
|
||||
void DiscogsCoverProvider::StartReleaseRequest(SharedPtr<DiscogsCoverSearchContext> search, const quint64 release_id, const QUrl &url) {
|
||||
|
||||
DiscogsCoverReleaseContext release(search->id, release_id, url);
|
||||
search->requests_release_.insert(release_id, release);
|
||||
@ -334,7 +337,7 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
||||
reply->deleteLater();
|
||||
|
||||
if (!requests_search_.contains(search_id)) return;
|
||||
std::shared_ptr<DiscogsCoverSearchContext> search = requests_search_.value(search_id);
|
||||
SharedPtr<DiscogsCoverSearchContext> search = requests_search_.value(search_id);
|
||||
|
||||
if (!search->requests_release_.contains(release_id)) return;
|
||||
const DiscogsCoverReleaseContext &release = search->requests_release_.value(release_id);
|
||||
@ -447,7 +450,7 @@ void DiscogsCoverProvider::HandleReleaseReply(QNetworkReply *reply, const int se
|
||||
|
||||
}
|
||||
|
||||
void DiscogsCoverProvider::EndSearch(std::shared_ptr<DiscogsCoverSearchContext> search, const quint64 release_id) {
|
||||
void DiscogsCoverProvider::EndSearch(SharedPtr<DiscogsCoverSearchContext> search, const quint64 release_id) {
|
||||
|
||||
if (search->requests_release_.contains(release_id)) {
|
||||
search->requests_release_.remove(release_id);
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QMetaType>
|
||||
#include <QPair>
|
||||
@ -37,6 +35,7 @@
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "albumcoverfetcher.h"
|
||||
|
||||
@ -49,7 +48,7 @@ class DiscogsCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DiscogsCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit DiscogsCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~DiscogsCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
@ -77,12 +76,12 @@ class DiscogsCoverProvider : public JsonCoverProvider {
|
||||
};
|
||||
|
||||
private:
|
||||
void SendSearchRequest(std::shared_ptr<DiscogsCoverSearchContext> search);
|
||||
void SendSearchRequest(SharedPtr<DiscogsCoverSearchContext> search);
|
||||
void SendReleaseRequest(const DiscogsCoverReleaseContext &release);
|
||||
QNetworkReply *CreateRequest(QUrl url, const ParamList ¶ms_provided = ParamList());
|
||||
QByteArray GetReplyData(QNetworkReply *reply);
|
||||
void StartReleaseRequest(std::shared_ptr<DiscogsCoverSearchContext> search, const quint64 release_id, const QUrl &url);
|
||||
void EndSearch(std::shared_ptr<DiscogsCoverSearchContext> search, const quint64 release_id = 0);
|
||||
void StartReleaseRequest(SharedPtr<DiscogsCoverSearchContext> search, const quint64 release_id, const QUrl &url);
|
||||
void EndSearch(SharedPtr<DiscogsCoverSearchContext> search, const quint64 release_id = 0);
|
||||
void Error(const QString &error, const QVariant &debug = QVariant()) override;
|
||||
|
||||
private slots:
|
||||
@ -97,9 +96,9 @@ class DiscogsCoverProvider : public JsonCoverProvider {
|
||||
static const int kRequestsDelay;
|
||||
|
||||
QTimer *timer_flush_requests_;
|
||||
QQueue<std::shared_ptr<DiscogsCoverSearchContext>> queue_search_requests_;
|
||||
QQueue<SharedPtr<DiscogsCoverSearchContext>> queue_search_requests_;
|
||||
QQueue<DiscogsCoverReleaseContext> queue_release_requests_;
|
||||
QMap<int, std::shared_ptr<DiscogsCoverSearchContext>> requests_search_;
|
||||
QMap<int, SharedPtr<DiscogsCoverSearchContext>> requests_search_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
};
|
||||
|
||||
|
@ -25,12 +25,13 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "coverprovider.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
|
||||
JsonCoverProvider::JsonCoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
JsonCoverProvider::JsonCoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: CoverProvider(name, enabled, authentication_required, quality, batch, allow_missing_album, app, network, parent) {}
|
||||
|
||||
QJsonObject JsonCoverProvider::ExtractJsonObj(const QByteArray &data) {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "coverprovider.h"
|
||||
|
||||
class Application;
|
||||
@ -36,7 +37,7 @@ class JsonCoverProvider : public CoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit JsonCoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, NetworkAccessManager *network, QObject *parent);
|
||||
explicit JsonCoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool batch, const bool allow_missing_album, Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent);
|
||||
|
||||
protected:
|
||||
QJsonObject ExtractJsonObj(const QByteArray &data);
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/logging.h"
|
||||
@ -49,7 +50,7 @@ const char *LastFmCoverProvider::kUrl = "https://ws.audioscrobbler.com/2.0/";
|
||||
const char *LastFmCoverProvider::kApiKey = "211990b4c96782c05d1536e7219eb56e";
|
||||
const char *LastFmCoverProvider::kSecret = "80fd738f49596e9709b1bf9319c444a8";
|
||||
|
||||
LastFmCoverProvider::LastFmCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
LastFmCoverProvider::LastFmCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Last.fm", true, false, 1.0, true, false, app, network, parent) {}
|
||||
|
||||
LastFmCoverProvider::~LastFmCoverProvider() {
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
|
||||
class NetworkAccessManager;
|
||||
@ -39,7 +40,7 @@ class LastFmCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LastFmCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit LastFmCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~LastFmCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/logging.h"
|
||||
@ -48,7 +49,7 @@ const char *MusicbrainzCoverProvider::kAlbumCoverUrl = "https://coverartarchive.
|
||||
const int MusicbrainzCoverProvider::kLimit = 8;
|
||||
const int MusicbrainzCoverProvider::kRequestsDelay = 1000;
|
||||
|
||||
MusicbrainzCoverProvider::MusicbrainzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
MusicbrainzCoverProvider::MusicbrainzCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("MusicBrainz", true, false, 1.5, true, false, app, network, parent),
|
||||
timer_flush_requests_(new QTimer(this)) {
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
|
||||
class QNetworkReply;
|
||||
@ -41,7 +42,7 @@ class MusicbrainzCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MusicbrainzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit MusicbrainzCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~MusicbrainzCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "providers/musixmatchprovider.h"
|
||||
@ -39,7 +40,7 @@
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "musixmatchcoverprovider.h"
|
||||
|
||||
MusixmatchCoverProvider::MusixmatchCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
MusixmatchCoverProvider::MusixmatchCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Musixmatch", true, false, 1.0, true, false, app, network, parent) {}
|
||||
|
||||
MusixmatchCoverProvider::~MusixmatchCoverProvider() {
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "providers/musixmatchprovider.h"
|
||||
|
||||
@ -38,7 +39,7 @@ class MusixmatchCoverProvider : public JsonCoverProvider, MusixmatchProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MusixmatchCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit MusixmatchCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~MusixmatchCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/logging.h"
|
||||
@ -47,7 +48,7 @@
|
||||
|
||||
constexpr int QobuzCoverProvider::kLimit = 10;
|
||||
|
||||
QobuzCoverProvider::QobuzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
QobuzCoverProvider::QobuzCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Qobuz", true, true, 2.0, true, true, app, network, parent),
|
||||
service_(app->internet_services()->Service<QobuzService>()) {}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QSslError>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "qobuz/qobuzservice.h"
|
||||
|
||||
@ -41,7 +42,7 @@ class QobuzCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QobuzCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit QobuzCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~QobuzCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
@ -60,7 +61,7 @@ class QobuzCoverProvider : public JsonCoverProvider {
|
||||
private:
|
||||
static const int kLimit;
|
||||
|
||||
QobuzService *service_;
|
||||
QobuzServicePtr service_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
};
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/logging.h"
|
||||
@ -60,7 +61,7 @@ const char *SpotifyCoverProvider::kClientSecretB64 = "N2ZlMDMxODk1NTBlNDE3ZGI1ZW
|
||||
const char *SpotifyCoverProvider::kApiUrl = "https://api.spotify.com/v1";
|
||||
const int SpotifyCoverProvider::kLimit = 10;
|
||||
|
||||
SpotifyCoverProvider::SpotifyCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
SpotifyCoverProvider::SpotifyCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Spotify", true, true, 2.5, true, true, app, network, parent),
|
||||
server_(nullptr),
|
||||
expires_in_(0),
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QTimer>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
|
||||
class QNetworkReply;
|
||||
@ -45,7 +46,7 @@ class SpotifyCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SpotifyCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit SpotifyCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~SpotifyCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "core/logging.h"
|
||||
@ -46,7 +47,7 @@
|
||||
|
||||
constexpr int TidalCoverProvider::kLimit = 10;
|
||||
|
||||
TidalCoverProvider::TidalCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent)
|
||||
TidalCoverProvider::TidalCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: JsonCoverProvider("Tidal", true, true, 2.5, true, true, app, network, parent),
|
||||
service_(app->internet_services()->Service<TidalService>()) {}
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <QJsonValue>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "jsoncoverprovider.h"
|
||||
#include "tidal/tidalservice.h"
|
||||
|
||||
@ -43,7 +44,7 @@ class TidalCoverProvider : public JsonCoverProvider {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TidalCoverProvider(Application *app, NetworkAccessManager *network, QObject *parent = nullptr);
|
||||
explicit TidalCoverProvider(Application *app, SharedPtr<NetworkAccessManager> network, QObject *parent = nullptr);
|
||||
~TidalCoverProvider() override;
|
||||
|
||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) override;
|
||||
@ -64,7 +65,7 @@ class TidalCoverProvider : public JsonCoverProvider {
|
||||
private:
|
||||
static const int kLimit;
|
||||
|
||||
TidalService *service_;
|
||||
TidalServicePtr service_;
|
||||
QList<QNetworkReply*> replies_;
|
||||
};
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "cddasongloader.h"
|
||||
#include "connecteddevice.h"
|
||||
@ -33,7 +34,7 @@ class Application;
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
|
||||
CddaDevice::CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, int database_id, bool first_time, QObject *parent)
|
||||
CddaDevice::CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, int database_id, bool first_time, QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time, parent),
|
||||
cdda_song_loader_(url) {
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <cdio/cdio.h>
|
||||
#include <gst/audio/gstaudiocdsrc.h>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "cddasongloader.h"
|
||||
@ -46,7 +47,7 @@ class CddaDevice : public ConnectedDevice {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE explicit CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
Q_INVOKABLE explicit CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
|
||||
bool Init() override;
|
||||
void Refresh() override;
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <cstddef>
|
||||
#include <glib.h>
|
||||
#include <glib/gtypes.h>
|
||||
@ -39,13 +41,16 @@
|
||||
|
||||
#include "cddasongloader.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
CddaSongLoader::CddaSongLoader(const QUrl &url, QObject *parent)
|
||||
: QObject(parent),
|
||||
url_(url),
|
||||
network_(new NetworkAccessManager(this)),
|
||||
network_(make_shared<NetworkAccessManager>()),
|
||||
cdda_(nullptr),
|
||||
cdio_(nullptr) {}
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <gst/gstelement.h>
|
||||
#include <gst/audio/gstaudiocdsrc.h>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#ifdef HAVE_MUSICBRAINZ
|
||||
# include "musicbrainz/musicbrainzclient.h"
|
||||
@ -71,7 +72,7 @@ class CddaSongLoader : public QObject {
|
||||
|
||||
private:
|
||||
const QUrl url_;
|
||||
NetworkAccessManager *network_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
GstElement *cdda_;
|
||||
CdIo_t *cdio_;
|
||||
QMutex mutex_load_;
|
||||
|
@ -19,12 +19,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/database.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
@ -35,7 +38,9 @@
|
||||
#include "devicemanager.h"
|
||||
#include "deviceinfo.h"
|
||||
|
||||
ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
using std::make_shared;
|
||||
|
||||
ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
: QObject(parent),
|
||||
app_(app),
|
||||
url_(url),
|
||||
@ -51,12 +56,12 @@ ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QS
|
||||
qLog(Info) << "Connected" << url << unique_id << first_time;
|
||||
|
||||
// Create the backend in the database thread.
|
||||
backend_ = new CollectionBackend();
|
||||
backend_ = make_shared<CollectionBackend>();
|
||||
backend_->moveToThread(app_->database()->thread());
|
||||
qLog(Debug) << backend_ << "for device" << unique_id_ << "moved to thread" << app_->database()->thread();
|
||||
qLog(Debug) << &*backend_ << "for device" << unique_id_ << "moved to thread" << app_->database()->thread();
|
||||
|
||||
if (url_.scheme() != "cdda") {
|
||||
QObject::connect(backend_, &CollectionBackend::TotalSongCountUpdated, this, &ConnectedDevice::BackendTotalSongCountUpdated);
|
||||
QObject::connect(&*backend_, &CollectionBackend::TotalSongCountUpdated, this, &ConnectedDevice::BackendTotalSongCountUpdated);
|
||||
}
|
||||
|
||||
backend_->Init(app_->database(),
|
||||
@ -72,10 +77,6 @@ ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QS
|
||||
|
||||
}
|
||||
|
||||
ConnectedDevice::~ConnectedDevice() {
|
||||
backend_->deleteLater();
|
||||
}
|
||||
|
||||
void ConnectedDevice::InitBackendDirectory(const QString &mount_point, const bool first_time, const bool rewrite_path) {
|
||||
|
||||
QList<CollectionDirectory> directories = backend_->GetAllDirectories();
|
||||
@ -108,7 +109,7 @@ void ConnectedDevice::ConnectAsync() { emit DeviceConnectFinished(unique_id_, tr
|
||||
|
||||
void ConnectedDevice::Close() {
|
||||
|
||||
QObject::connect(backend_, &CollectionBackend::ExitFinished, this, &ConnectedDevice::BackendCloseFinished);
|
||||
QObject::connect(&*backend_, &CollectionBackend::ExitFinished, this, &ConnectedDevice::BackendCloseFinished);
|
||||
backend_->ExitAsync();
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/song.h"
|
||||
|
||||
@ -39,12 +40,13 @@ class CollectionModel;
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
|
||||
class ConnectedDevice : public QObject, public virtual MusicStorage, public std::enable_shared_from_this<ConnectedDevice> {
|
||||
using std::enable_shared_from_this;
|
||||
|
||||
class ConnectedDevice : public QObject, public virtual MusicStorage, public enable_shared_from_this<ConnectedDevice> {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
~ConnectedDevice() override;
|
||||
explicit ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
|
||||
Song::Source source() const override { return Song::Source::Device; }
|
||||
|
||||
@ -91,9 +93,9 @@ class ConnectedDevice : public QObject, public virtual MusicStorage, public std:
|
||||
DeviceLister *lister_;
|
||||
QString unique_id_;
|
||||
int database_id_;
|
||||
DeviceManager *manager_;
|
||||
SharedPtr<DeviceManager> manager_;
|
||||
|
||||
CollectionBackend *backend_;
|
||||
SharedPtr<CollectionBackend> backend_;
|
||||
CollectionModel *model_;
|
||||
|
||||
qint64 song_count_;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QString>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/database.h"
|
||||
#include "core/sqlquery.h"
|
||||
#include "core/scopedtransaction.h"
|
||||
@ -46,7 +47,7 @@ DeviceDatabaseBackend::DeviceDatabaseBackend(QObject *parent)
|
||||
|
||||
}
|
||||
|
||||
void DeviceDatabaseBackend::Init(Database *db) { db_ = db; }
|
||||
void DeviceDatabaseBackend::Init(SharedPtr<Database> db) { db_ = db; }
|
||||
|
||||
void DeviceDatabaseBackend::Close() {
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/musicstorage.h"
|
||||
|
||||
@ -57,11 +58,11 @@ class DeviceDatabaseBackend : public QObject {
|
||||
|
||||
static const int kDeviceSchemaVersion;
|
||||
|
||||
void Init(Database *db);
|
||||
void Init(SharedPtr<Database> db);
|
||||
void Close();
|
||||
void ExitAsync();
|
||||
|
||||
Database *db() const { return db_; }
|
||||
SharedPtr<Database> db() const { return db_; }
|
||||
|
||||
DeviceList GetAllDevices();
|
||||
int AddDevice(const Device &device);
|
||||
@ -76,7 +77,7 @@ class DeviceDatabaseBackend : public QObject {
|
||||
void ExitFinished();
|
||||
|
||||
private:
|
||||
Database *db_;
|
||||
SharedPtr<Database> db_;
|
||||
QThread *original_thread_;
|
||||
|
||||
};
|
||||
|
@ -102,7 +102,7 @@ class DeviceInfo : public SimpleTreeItem<DeviceInfo> {
|
||||
const Backend *BestBackend() const;
|
||||
|
||||
int database_id_; // -1 if not remembered in the database
|
||||
std::shared_ptr<ConnectedDevice> device_; // nullptr if not connected
|
||||
SharedPtr<ConnectedDevice> device_; // nullptr if not connected
|
||||
QList<Backend> backends_;
|
||||
|
||||
QString friendly_name_;
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QApplication>
|
||||
@ -45,6 +45,8 @@
|
||||
#include "devicemanager.h"
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/database.h"
|
||||
#include "core/iconloader.h"
|
||||
@ -81,6 +83,8 @@
|
||||
# include "giolister.h" // Needs to be last because of #undef signals.
|
||||
#endif
|
||||
|
||||
using std::make_unique;
|
||||
|
||||
const int DeviceManager::kDeviceIconSize = 32;
|
||||
const int DeviceManager::kDeviceIconOverlaySize = 16;
|
||||
|
||||
@ -90,10 +94,10 @@ DeviceManager::DeviceManager(Application *app, QObject *parent)
|
||||
not_connected_overlay_(IconLoader::Load("edit-delete")) {
|
||||
|
||||
thread_pool_.setMaxThreadCount(1);
|
||||
QObject::connect(app_->task_manager(), &TaskManager::TasksChanged, this, &DeviceManager::TasksChanged);
|
||||
QObject::connect(&*app_->task_manager(), &TaskManager::TasksChanged, this, &DeviceManager::TasksChanged);
|
||||
|
||||
// Create the backend in the database thread
|
||||
backend_ = new DeviceDatabaseBackend;
|
||||
backend_ = make_unique<DeviceDatabaseBackend>();
|
||||
backend_->moveToThread(app_->database()->thread());
|
||||
backend_->Init(app_->database());
|
||||
|
||||
@ -151,9 +155,6 @@ DeviceManager::~DeviceManager() {
|
||||
delete root_;
|
||||
root_ = nullptr;
|
||||
|
||||
backend_->deleteLater();
|
||||
backend_ = nullptr;
|
||||
|
||||
}
|
||||
|
||||
void DeviceManager::Exit() {
|
||||
@ -164,9 +165,9 @@ void DeviceManager::CloseDevices() {
|
||||
|
||||
for (DeviceInfo *info : devices_) {
|
||||
if (!info->device_) continue;
|
||||
if (wait_for_exit_.contains(info->device_.get())) continue;
|
||||
wait_for_exit_ << info->device_.get();
|
||||
QObject::connect(info->device_.get(), &ConnectedDevice::destroyed, this, &DeviceManager::DeviceDestroyed);
|
||||
if (wait_for_exit_.contains(&*info->device_)) continue;
|
||||
wait_for_exit_ << &*info->device_;
|
||||
QObject::connect(&*info->device_, &ConnectedDevice::destroyed, this, &DeviceManager::DeviceDestroyed);
|
||||
info->device_->Close();
|
||||
}
|
||||
if (wait_for_exit_.isEmpty()) CloseListers();
|
||||
@ -187,9 +188,9 @@ void DeviceManager::CloseListers() {
|
||||
|
||||
void DeviceManager::CloseBackend() {
|
||||
|
||||
if (!backend_ || wait_for_exit_.contains(backend_)) return;
|
||||
wait_for_exit_ << backend_;
|
||||
QObject::connect(backend_, &DeviceDatabaseBackend::ExitFinished, this, &DeviceManager::BackendClosed);
|
||||
if (!backend_ || wait_for_exit_.contains(&*backend_)) return;
|
||||
wait_for_exit_ << &*backend_;
|
||||
QObject::connect(&*backend_, &DeviceDatabaseBackend::ExitFinished, this, &DeviceManager::BackendClosed);
|
||||
backend_->ExitAsync();
|
||||
|
||||
}
|
||||
@ -290,7 +291,7 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const {
|
||||
if (info->size_ > 0) {
|
||||
text = text + QString(" (%1)").arg(Utilities::PrettySize(info->size_));
|
||||
}
|
||||
if (info->device_.get()) info->device_->Refresh();
|
||||
if (&*info->device_) info->device_->Refresh();
|
||||
return text;
|
||||
}
|
||||
|
||||
@ -341,14 +342,14 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const {
|
||||
const_cast<DeviceManager*>(this)->Connect(info);
|
||||
}
|
||||
if (!info->device_) return QVariant();
|
||||
return QVariant::fromValue<std::shared_ptr<MusicStorage>>(info->device_);
|
||||
return QVariant::fromValue<SharedPtr<MusicStorage>>(info->device_);
|
||||
|
||||
case MusicStorage::Role_StorageForceConnect:
|
||||
if (!info->BestBackend()) return QVariant();
|
||||
if (!info->device_) {
|
||||
if (info->database_id_ == -1 && !info->BestBackend()->lister_->DeviceNeedsMount(info->BestBackend()->unique_id_)) {
|
||||
if (info->BestBackend()->lister_->AskForScan(info->BestBackend()->unique_id_)) {
|
||||
std::unique_ptr<QMessageBox> dialog(new QMessageBox(QMessageBox::Information, tr("Connect device"), tr("This is the first time you have connected this device. Strawberry will now scan the device to find music files - this may take some time."), QMessageBox::Cancel));
|
||||
ScopedPtr<QMessageBox> dialog(new QMessageBox(QMessageBox::Information, tr("Connect device"), tr("This is the first time you have connected this device. Strawberry will now scan the device to find music files - this may take some time."), QMessageBox::Cancel));
|
||||
QPushButton *pushbutton = dialog->addButton(tr("Connect device"), QMessageBox::AcceptRole);
|
||||
dialog->exec();
|
||||
if (dialog->clickedButton() != pushbutton) return QVariant();
|
||||
@ -357,7 +358,7 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const {
|
||||
const_cast<DeviceManager*>(this)->Connect(info);
|
||||
}
|
||||
if (!info->device_) return QVariant();
|
||||
return QVariant::fromValue<std::shared_ptr<MusicStorage>>(info->device_);
|
||||
return QVariant::fromValue<SharedPtr<MusicStorage>>(info->device_);
|
||||
|
||||
case Role_MountPath: {
|
||||
if (!info->device_) return QVariant();
|
||||
@ -551,9 +552,9 @@ void DeviceManager::PhysicalDeviceChanged(const QString &id) {
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<ConnectedDevice> DeviceManager::Connect(const QModelIndex &idx) {
|
||||
SharedPtr<ConnectedDevice> DeviceManager::Connect(const QModelIndex &idx) {
|
||||
|
||||
std::shared_ptr<ConnectedDevice> ret;
|
||||
SharedPtr<ConnectedDevice> ret;
|
||||
|
||||
DeviceInfo *info = IndexToItem(idx);
|
||||
if (!info) return ret;
|
||||
@ -562,9 +563,9 @@ std::shared_ptr<ConnectedDevice> DeviceManager::Connect(const QModelIndex &idx)
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
|
||||
std::shared_ptr<ConnectedDevice> ret;
|
||||
SharedPtr<ConnectedDevice> ret;
|
||||
|
||||
if (!info) return ret;
|
||||
if (info->device_) { // Already connected
|
||||
@ -661,10 +662,10 @@ std::shared_ptr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
|
||||
emit dataChanged(idx, idx);
|
||||
|
||||
QObject::connect(info->device_.get(), &ConnectedDevice::TaskStarted, this, &DeviceManager::DeviceTaskStarted);
|
||||
QObject::connect(info->device_.get(), &ConnectedDevice::SongCountUpdated, this, &DeviceManager::DeviceSongCountUpdated);
|
||||
QObject::connect(info->device_.get(), &ConnectedDevice::DeviceConnectFinished, this, &DeviceManager::DeviceConnectFinished);
|
||||
QObject::connect(info->device_.get(), &ConnectedDevice::DeviceCloseFinished, this, &DeviceManager::DeviceCloseFinished);
|
||||
QObject::connect(&*info->device_, &ConnectedDevice::TaskStarted, this, &DeviceManager::DeviceTaskStarted);
|
||||
QObject::connect(&*info->device_, &ConnectedDevice::SongCountUpdated, this, &DeviceManager::DeviceSongCountUpdated);
|
||||
QObject::connect(&*info->device_, &ConnectedDevice::DeviceConnectFinished, this, &DeviceManager::DeviceConnectFinished);
|
||||
QObject::connect(&*info->device_, &ConnectedDevice::DeviceCloseFinished, this, &DeviceManager::DeviceCloseFinished);
|
||||
ret->ConnectAsync();
|
||||
return ret;
|
||||
|
||||
@ -717,18 +718,18 @@ DeviceInfo *DeviceManager::GetDevice(const QModelIndex &idx) const {
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<ConnectedDevice> DeviceManager::GetConnectedDevice(const QModelIndex &idx) const {
|
||||
SharedPtr<ConnectedDevice> DeviceManager::GetConnectedDevice(const QModelIndex &idx) const {
|
||||
|
||||
std::shared_ptr<ConnectedDevice> ret;
|
||||
SharedPtr<ConnectedDevice> ret;
|
||||
DeviceInfo *info = IndexToItem(idx);
|
||||
if (!info) return ret;
|
||||
return info->device_;
|
||||
|
||||
}
|
||||
|
||||
std::shared_ptr<ConnectedDevice> DeviceManager::GetConnectedDevice(DeviceInfo *info) const {
|
||||
SharedPtr<ConnectedDevice> DeviceManager::GetConnectedDevice(DeviceInfo *info) const {
|
||||
|
||||
std::shared_ptr<ConnectedDevice> ret;
|
||||
SharedPtr<ConnectedDevice> ret;
|
||||
if (!info) return ret;
|
||||
return info->device_;
|
||||
|
||||
@ -829,7 +830,7 @@ void DeviceManager::DeviceTaskStarted(const int id) {
|
||||
|
||||
for (int i = 0; i < devices_.count(); ++i) {
|
||||
DeviceInfo *info = devices_[i];
|
||||
if (info->device_.get() == device) {
|
||||
if (&*info->device_ == device) {
|
||||
QModelIndex index = ItemToIndex(info);
|
||||
if (!index.isValid()) continue;
|
||||
active_tasks_[id] = index;
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QMetaObject>
|
||||
#include <QThreadPool>
|
||||
@ -39,6 +37,8 @@
|
||||
#include <QUrl>
|
||||
#include <QIcon>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/simpletreemodel.h"
|
||||
@ -95,8 +95,8 @@ class DeviceManager : public SimpleTreeModel<DeviceInfo> {
|
||||
int GetDatabaseId(const QModelIndex &idx) const;
|
||||
DeviceLister *GetLister(const QModelIndex &idx) const;
|
||||
DeviceInfo *GetDevice(const QModelIndex &idx) const;
|
||||
std::shared_ptr<ConnectedDevice> GetConnectedDevice(const QModelIndex &idx) const;
|
||||
std::shared_ptr<ConnectedDevice> GetConnectedDevice(DeviceInfo *info) const;
|
||||
SharedPtr<ConnectedDevice> GetConnectedDevice(const QModelIndex &idx) const;
|
||||
SharedPtr<ConnectedDevice> GetConnectedDevice(DeviceInfo *info) const;
|
||||
|
||||
DeviceInfo *FindDeviceById(const QString &id) const;
|
||||
DeviceInfo *FindDeviceByUrl(const QList<QUrl> &url) const;
|
||||
@ -104,8 +104,8 @@ class DeviceManager : public SimpleTreeModel<DeviceInfo> {
|
||||
DeviceInfo *FindEquivalentDevice(DeviceInfo *info) const;
|
||||
|
||||
// Actions on devices
|
||||
std::shared_ptr<ConnectedDevice> Connect(DeviceInfo *info);
|
||||
std::shared_ptr<ConnectedDevice> Connect(const QModelIndex &idx);
|
||||
SharedPtr<ConnectedDevice> Connect(DeviceInfo *info);
|
||||
SharedPtr<ConnectedDevice> Connect(const QModelIndex &idx);
|
||||
void Disconnect(DeviceInfo *info, const QModelIndex &idx);
|
||||
void Forget(const QModelIndex &idx);
|
||||
void UnmountAsync(const QModelIndex &idx);
|
||||
@ -153,7 +153,7 @@ class DeviceManager : public SimpleTreeModel<DeviceInfo> {
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
DeviceDatabaseBackend *backend_;
|
||||
ScopedPtr<DeviceDatabaseBackend> backend_;
|
||||
|
||||
DeviceStateFilterModel *connected_devices_model_;
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QWidget>
|
||||
@ -46,6 +45,7 @@
|
||||
#include <QStackedWidget>
|
||||
#include <QTableWidget>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "widgets/freespacebar.h"
|
||||
@ -75,12 +75,12 @@ DeviceProperties::DeviceProperties(QWidget *parent)
|
||||
|
||||
DeviceProperties::~DeviceProperties() { delete ui_; }
|
||||
|
||||
void DeviceProperties::SetDeviceManager(DeviceManager *manager) {
|
||||
void DeviceProperties::SetDeviceManager(SharedPtr<DeviceManager> manager) {
|
||||
|
||||
manager_ = manager;
|
||||
QObject::connect(manager_, &DeviceManager::dataChanged, this, &DeviceProperties::ModelChanged);
|
||||
QObject::connect(manager_, &DeviceManager::rowsInserted, this, &DeviceProperties::ModelChanged);
|
||||
QObject::connect(manager_, &DeviceManager::rowsRemoved, this, &DeviceProperties::ModelChanged);
|
||||
QObject::connect(&*manager_, &DeviceManager::dataChanged, this, &DeviceProperties::ModelChanged);
|
||||
QObject::connect(&*manager_, &DeviceManager::rowsInserted, this, &DeviceProperties::ModelChanged);
|
||||
QObject::connect(&*manager_, &DeviceManager::rowsRemoved, this, &DeviceProperties::ModelChanged);
|
||||
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ void DeviceProperties::UpdateHardwareInfo() {
|
||||
void DeviceProperties::UpdateFormats() {
|
||||
|
||||
DeviceLister *lister = manager_->GetLister(index_);
|
||||
std::shared_ptr<ConnectedDevice> device = manager_->GetConnectedDevice(index_);
|
||||
SharedPtr<ConnectedDevice> device = manager_->GetConnectedDevice(index_);
|
||||
|
||||
// Transcode mode
|
||||
MusicStorage::TranscodeMode mode = static_cast<MusicStorage::TranscodeMode>(index_.data(DeviceManager::Role_TranscodeMode).toInt());
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
#include <QFuture>
|
||||
@ -31,6 +33,7 @@
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class QWidget;
|
||||
@ -45,7 +48,7 @@ class DeviceProperties : public QDialog {
|
||||
explicit DeviceProperties(QWidget *parent = nullptr);
|
||||
~DeviceProperties() override;
|
||||
|
||||
void SetDeviceManager(DeviceManager *manager);
|
||||
void SetDeviceManager(SharedPtr<DeviceManager> manager);
|
||||
void ShowDevice(const QModelIndex &idx);
|
||||
|
||||
public slots:
|
||||
@ -64,7 +67,7 @@ class DeviceProperties : public QDialog {
|
||||
private:
|
||||
Ui_DeviceProperties *ui_;
|
||||
|
||||
DeviceManager *manager_;
|
||||
SharedPtr<DeviceManager> manager_;
|
||||
QPersistentModelIndex index_;
|
||||
|
||||
bool updating_formats_;
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QtEvents>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/application.h"
|
||||
#include "core/deletefiles.h"
|
||||
@ -66,6 +67,8 @@
|
||||
#include "deviceproperties.h"
|
||||
#include "deviceview.h"
|
||||
|
||||
using std::make_unique;
|
||||
|
||||
const int DeviceItemDelegate::kIconPadding = 6;
|
||||
|
||||
DeviceItemDelegate::DeviceItemDelegate(QObject *parent) : CollectionItemDelegate(parent) {}
|
||||
@ -203,11 +206,11 @@ void DeviceView::SetApplication(Application *app) {
|
||||
Q_ASSERT(app_ == nullptr);
|
||||
app_ = app;
|
||||
|
||||
QObject::connect(app_->device_manager(), &DeviceManager::DeviceConnected, this, &DeviceView::DeviceConnected);
|
||||
QObject::connect(app_->device_manager(), &DeviceManager::DeviceDisconnected, this, &DeviceView::DeviceDisconnected);
|
||||
QObject::connect(&*app_->device_manager(), &DeviceManager::DeviceConnected, this, &DeviceView::DeviceConnected);
|
||||
QObject::connect(&*app_->device_manager(), &DeviceManager::DeviceDisconnected, this, &DeviceView::DeviceDisconnected);
|
||||
|
||||
sort_model_ = new QSortFilterProxyModel(this);
|
||||
sort_model_->setSourceModel(app_->device_manager());
|
||||
sort_model_->setSourceModel(&*app_->device_manager());
|
||||
sort_model_->setDynamicSortFilter(true);
|
||||
sort_model_->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
sort_model_->sort(0);
|
||||
@ -220,7 +223,7 @@ void DeviceView::SetApplication(Application *app) {
|
||||
|
||||
properties_dialog_->SetDeviceManager(app_->device_manager());
|
||||
|
||||
organize_dialog_ = std::make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
organize_dialog_ = make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
organize_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||
|
||||
}
|
||||
@ -266,7 +269,7 @@ void DeviceView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
|
||||
bool is_filesystem_device = false;
|
||||
if (parent_device_index.isValid()) {
|
||||
std::shared_ptr<ConnectedDevice> device = app_->device_manager()->GetConnectedDevice(parent_device_index);
|
||||
SharedPtr<ConnectedDevice> device = app_->device_manager()->GetConnectedDevice(parent_device_index);
|
||||
if (device && !device->LocalPath().isEmpty()) is_filesystem_device = true;
|
||||
}
|
||||
|
||||
@ -312,7 +315,7 @@ void DeviceView::DeviceConnected(const QModelIndex &idx) {
|
||||
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
std::shared_ptr<ConnectedDevice> device = app_->device_manager()->GetConnectedDevice(idx);
|
||||
SharedPtr<ConnectedDevice> device = app_->device_manager()->GetConnectedDevice(idx);
|
||||
if (!device) return;
|
||||
|
||||
QModelIndex sort_idx = sort_model_->mapFromSource(idx);
|
||||
@ -339,7 +342,7 @@ void DeviceView::Forget() {
|
||||
QModelIndex device_idx = MapToDevice(menu_index_);
|
||||
QString unique_id = app_->device_manager()->data(device_idx, DeviceManager::Role_UniqueId).toString();
|
||||
if (app_->device_manager()->GetLister(device_idx) && app_->device_manager()->GetLister(device_idx)->AskForScan(unique_id)) {
|
||||
std::unique_ptr<QMessageBox> dialog(new QMessageBox(
|
||||
ScopedPtr<QMessageBox> dialog(new QMessageBox(
|
||||
QMessageBox::Question, tr("Forget device"),
|
||||
tr("Forgetting a device will remove it from this list and Strawberry will have to rescan all the songs again next time you connect it."),
|
||||
QMessageBox::Cancel, this));
|
||||
@ -427,7 +430,7 @@ void DeviceView::Delete() {
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<MusicStorage> storage = device_index.data(MusicStorage::Role_Storage).value<std::shared_ptr<MusicStorage>>();
|
||||
SharedPtr<MusicStorage> storage = device_index.data(MusicStorage::Role_Storage).value<SharedPtr<MusicStorage>>();
|
||||
|
||||
DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, false);
|
||||
QObject::connect(delete_files, &DeleteFiles::Finished, this, &DeviceView::DeleteFinished);
|
||||
|
@ -24,14 +24,13 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QStyleOption>
|
||||
#include <QStyleOptionViewItem>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QString>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "collection/collectionitemdelegate.h"
|
||||
#include "widgets/autoexpandingtreeview.h"
|
||||
@ -107,8 +106,8 @@ class DeviceView : public AutoExpandingTreeView {
|
||||
MergedProxyModel *merged_model_;
|
||||
QSortFilterProxyModel *sort_model_;
|
||||
|
||||
std::unique_ptr<DeviceProperties> properties_dialog_;
|
||||
std::unique_ptr<OrganizeDialog> organize_dialog_;
|
||||
ScopedPtr<DeviceProperties> properties_dialog_;
|
||||
ScopedPtr<OrganizeDialog> organize_dialog_;
|
||||
|
||||
QMenu *device_menu_;
|
||||
QAction *eject_action_;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/song.h"
|
||||
|
||||
@ -38,7 +39,7 @@
|
||||
|
||||
class DeviceLister;
|
||||
|
||||
FilesystemDevice::FilesystemDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
FilesystemDevice::FilesystemDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
: FilesystemMusicStorage(Song::Source::Device, url.toLocalFile()),
|
||||
ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time, parent),
|
||||
watcher_(new CollectionWatcher(Song::Source::Device)),
|
||||
@ -52,17 +53,17 @@ FilesystemDevice::FilesystemDevice(const QUrl &url, DeviceLister *lister, const
|
||||
watcher_->set_backend(backend_);
|
||||
watcher_->set_task_manager(app_->task_manager());
|
||||
|
||||
QObject::connect(backend_, &CollectionBackend::DirectoryDiscovered, watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(backend_, &CollectionBackend::DirectoryDeleted, watcher_, &CollectionWatcher::RemoveDirectory);
|
||||
QObject::connect(watcher_, &CollectionWatcher::NewOrUpdatedSongs, backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsMTimeUpdated, backend_, &CollectionBackend::UpdateMTimesOnly);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsDeleted, backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsUnavailable, backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsReadded, backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SubdirsDiscovered, backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SubdirsMTimeUpdated, backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::CompilationsNeedUpdating, backend_, &CollectionBackend::CompilationsNeedUpdating);
|
||||
QObject::connect(watcher_, &CollectionWatcher::UpdateLastSeen, backend_, &CollectionBackend::UpdateLastSeen);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDiscovered, watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDeleted, watcher_, &CollectionWatcher::RemoveDirectory);
|
||||
QObject::connect(watcher_, &CollectionWatcher::NewOrUpdatedSongs, &*backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsMTimeUpdated, &*backend_, &CollectionBackend::UpdateMTimesOnly);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsDeleted, &*backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsUnavailable, &*backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsReadded, &*backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SubdirsDiscovered, &*backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SubdirsMTimeUpdated, &*backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::CompilationsNeedUpdating, &*backend_, &CollectionBackend::CompilationsNeedUpdating);
|
||||
QObject::connect(watcher_, &CollectionWatcher::UpdateLastSeen, &*backend_, &CollectionBackend::UpdateLastSeen);
|
||||
QObject::connect(watcher_, &CollectionWatcher::ScanStarted, this, &FilesystemDevice::TaskStarted);
|
||||
|
||||
}
|
||||
@ -92,12 +93,12 @@ void FilesystemDevice::Close() {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
|
||||
wait_for_exit_ << backend_ << watcher_;
|
||||
wait_for_exit_ << &*backend_ << watcher_;
|
||||
|
||||
QObject::disconnect(backend_, nullptr, watcher_, nullptr);
|
||||
QObject::disconnect(watcher_, nullptr, backend_, nullptr);
|
||||
QObject::disconnect(&*backend_, nullptr, watcher_, nullptr);
|
||||
QObject::disconnect(watcher_, nullptr, &*backend_, nullptr);
|
||||
|
||||
QObject::connect(backend_, &CollectionBackend::ExitFinished, this, &FilesystemDevice::ExitFinished);
|
||||
QObject::connect(&*backend_, &CollectionBackend::ExitFinished, this, &FilesystemDevice::ExitFinished);
|
||||
QObject::connect(watcher_, &CollectionWatcher::ExitFinished, this, &FilesystemDevice::ExitFinished);
|
||||
backend_->ExitAsync();
|
||||
watcher_->ExitAsync();
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/filesystemmusicstorage.h"
|
||||
#include "connecteddevice.h"
|
||||
|
||||
@ -43,7 +44,7 @@ class FilesystemDevice : public ConnectedDevice, public virtual FilesystemMusicS
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE FilesystemDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
Q_INVOKABLE FilesystemDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
~FilesystemDevice() override;
|
||||
|
||||
Song::Source source() const final { return Song::Source::Device; }
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
@ -50,7 +51,9 @@
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
|
||||
GPodDevice::GPodDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
using std::make_shared;
|
||||
|
||||
GPodDevice::GPodDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time, parent),
|
||||
loader_(nullptr),
|
||||
loader_thread_(nullptr),
|
||||
@ -197,7 +200,7 @@ bool GPodDevice::CopyToStorage(const CopyJob &job) {
|
||||
QString temp_path = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
||||
#endif
|
||||
if (!QDir(temp_path).exists()) QDir().mkpath(temp_path);
|
||||
std::shared_ptr<QTemporaryFile> cover_file = std::make_shared<QTemporaryFile>(temp_path + "/track-albumcover-XXXXXX.jpg");
|
||||
SharedPtr<QTemporaryFile> cover_file = make_shared<QTemporaryFile>(temp_path + "/track-albumcover-XXXXXX.jpg");
|
||||
cover_file->setAutoRemove(true);
|
||||
if (cover_file->open()) {
|
||||
cover_file->close();
|
||||
|
@ -24,8 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <gpod/itdb.h>
|
||||
|
||||
#include <QObject>
|
||||
@ -37,6 +35,7 @@
|
||||
#include <QUrl>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "connecteddevice.h"
|
||||
@ -51,7 +50,7 @@ class GPodDevice : public ConnectedDevice, public virtual MusicStorage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE GPodDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, DeviceManager *manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
Q_INVOKABLE GPodDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
~GPodDevice() override;
|
||||
|
||||
bool Init() override;
|
||||
@ -98,7 +97,7 @@ class GPodDevice : public ConnectedDevice, public virtual MusicStorage {
|
||||
QMutex db_busy_;
|
||||
SongList songs_to_add_;
|
||||
SongList songs_to_remove_;
|
||||
QList<std::shared_ptr<QTemporaryFile>> cover_files_;
|
||||
QList<SharedPtr<QTemporaryFile>> cover_files_;
|
||||
};
|
||||
|
||||
#endif // GPODDEVICE_H
|
||||
|
@ -30,12 +30,13 @@
|
||||
#include <QString>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "gpodloader.h"
|
||||
|
||||
GPodLoader::GPodLoader(const QString &mount_point, TaskManager *task_manager, CollectionBackend *backend, std::shared_ptr<ConnectedDevice> device, QObject *parent)
|
||||
GPodLoader::GPodLoader(const QString &mount_point, SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackend> backend, SharedPtr<ConnectedDevice> device, QObject *parent)
|
||||
: QObject(parent),
|
||||
device_(device),
|
||||
mount_point_(mount_point),
|
||||
|
@ -24,12 +24,12 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <gpod/itdb.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class QThread;
|
||||
@ -41,7 +41,7 @@ class GPodLoader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GPodLoader(const QString &mount_point, TaskManager *task_manager, CollectionBackend *backend, std::shared_ptr<ConnectedDevice> device, QObject *parent = nullptr);
|
||||
explicit GPodLoader(const QString &mount_point, SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackend> backend, SharedPtr<ConnectedDevice> device, QObject *parent = nullptr);
|
||||
~GPodLoader() override;
|
||||
|
||||
void set_music_path_prefix(const QString &prefix) { path_prefix_ = prefix; }
|
||||
@ -61,14 +61,14 @@ class GPodLoader : public QObject {
|
||||
Itdb_iTunesDB *TryLoad();
|
||||
|
||||
private:
|
||||
std::shared_ptr<ConnectedDevice> device_;
|
||||
SharedPtr<ConnectedDevice> device_;
|
||||
QThread *original_thread_;
|
||||
|
||||
QString mount_point_;
|
||||
QString path_prefix_;
|
||||
Song::FileType type_;
|
||||
TaskManager *task_manager_;
|
||||
CollectionBackend *backend_;
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
SharedPtr<CollectionBackend> backend_;
|
||||
bool abort_;
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,9 @@
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
class MtpConnection : public QObject, public std::enable_shared_from_this<MtpConnection> {
|
||||
using std::enable_shared_from_this;
|
||||
|
||||
class MtpConnection : public QObject, public enable_shared_from_this<MtpConnection> {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user