parent
d398c86b0c
commit
1dae80a633
@ -68,6 +68,7 @@ class AudioScrobbler : public QObject {
|
||||
int submit_delay() const { return settings_->submit_delay(); }
|
||||
bool prefer_albumartist() const { return settings_->prefer_albumartist(); }
|
||||
bool ShowErrorDialog() const { return settings_->show_error_dialog(); }
|
||||
bool strip_remastered() const { return settings_->strip_remastered(); }
|
||||
QList<Song::Source> sources() const { return settings_->sources(); }
|
||||
|
||||
void ShowConfig();
|
||||
|
@ -67,8 +67,7 @@ const char *ListenBrainzScrobbler::kCacheFile = "listenbrainzscrobbler.cache";
|
||||
const int ListenBrainzScrobbler::kScrobblesPerRequest = 10;
|
||||
|
||||
ListenBrainzScrobbler::ListenBrainzScrobbler(SharedPtr<ScrobblerSettings> settings, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: ScrobblerService(kName, parent),
|
||||
settings_(settings),
|
||||
: ScrobblerService(kName, settings, parent),
|
||||
network_(network),
|
||||
cache_(new ScrobblerCache(kCacheFile, this)),
|
||||
server_(nullptr),
|
||||
|
@ -110,7 +110,6 @@ class ListenBrainzScrobbler : public ScrobblerService {
|
||||
static const char *kCacheFile;
|
||||
static const int kScrobblesPerRequest;
|
||||
|
||||
SharedPtr<ScrobblerSettings> settings_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
ScrobblerCache *cache_;
|
||||
LocalRedirectServer *server_;
|
||||
|
@ -27,10 +27,11 @@
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "scrobblerservice.h"
|
||||
#include "scrobblersettings.h"
|
||||
|
||||
#include "core/song.h"
|
||||
|
||||
ScrobblerService::ScrobblerService(const QString &name, QObject *parent) : QObject(parent), name_(name) {}
|
||||
ScrobblerService::ScrobblerService(const QString &name, SharedPtr<ScrobblerSettings> settings, QObject *parent) : QObject(parent), name_(name), settings_(settings) {}
|
||||
|
||||
bool ScrobblerService::ExtractJsonObj(const QByteArray &data, QJsonObject &json_obj, QString &error_description) {
|
||||
|
||||
@ -52,12 +53,20 @@ bool ScrobblerService::ExtractJsonObj(const QByteArray &data, QJsonObject &json_
|
||||
|
||||
QString ScrobblerService::StripAlbum(const QString &album) const {
|
||||
|
||||
return Song::AlbumRemoveDisc(album);
|
||||
if (settings_->strip_remastered()) {
|
||||
return Song::AlbumRemoveDiscMisc(album);
|
||||
}
|
||||
|
||||
return Song::AlbumRemoveDisc(album);;
|
||||
|
||||
}
|
||||
|
||||
QString ScrobblerService::StripTitle(const QString &title) const {
|
||||
|
||||
return Song::TitleRemoveMisc(title);
|
||||
if (settings_->strip_remastered()) {
|
||||
return Song::TitleRemoveMisc(title);
|
||||
}
|
||||
|
||||
return title;
|
||||
|
||||
}
|
||||
|
@ -33,11 +33,13 @@
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
#include "scrobblersettings.h"
|
||||
|
||||
class ScrobblerService : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ScrobblerService(const QString &name, QObject *parent);
|
||||
explicit ScrobblerService(const QString &name, SharedPtr<ScrobblerSettings> settings, QObject *parent);
|
||||
|
||||
QString name() const { return name_; }
|
||||
|
||||
@ -71,8 +73,9 @@ class ScrobblerService : public QObject {
|
||||
signals:
|
||||
void ErrorMessage(const QString &error);
|
||||
|
||||
private:
|
||||
protected:
|
||||
QString name_;
|
||||
SharedPtr<ScrobblerSettings> settings_;
|
||||
};
|
||||
|
||||
using ScrobblerServicePtr = SharedPtr<ScrobblerService>;
|
||||
|
@ -38,7 +38,8 @@ ScrobblerSettings::ScrobblerSettings(Application *app, QObject *parent)
|
||||
love_button_(false),
|
||||
submit_delay_(0),
|
||||
prefer_albumartist_(false),
|
||||
show_error_dialog_(false) {
|
||||
show_error_dialog_(false),
|
||||
strip_remastered_(false) {
|
||||
|
||||
ReloadSettings();
|
||||
|
||||
@ -55,6 +56,7 @@ void ScrobblerSettings::ReloadSettings() {
|
||||
submit_delay_ = s.value("submit", 0).toInt();
|
||||
prefer_albumartist_ = s.value("albumartist", false).toBool();
|
||||
show_error_dialog_ = s.value("show_error_dialog", true).toBool();
|
||||
strip_remastered_ = s.value("strip_remastered", true).toBool();
|
||||
QStringList sources = s.value("sources").toStringList();
|
||||
s.endGroup();
|
||||
|
||||
|
@ -47,6 +47,7 @@ class ScrobblerSettings : public QObject {
|
||||
int submit_delay() const { return submit_delay_; }
|
||||
bool prefer_albumartist() const { return prefer_albumartist_; }
|
||||
bool show_error_dialog() const { return show_error_dialog_; }
|
||||
bool strip_remastered() const { return strip_remastered_; }
|
||||
QList<Song::Source> sources() const { return sources_; }
|
||||
|
||||
void ShowConfig();
|
||||
@ -73,6 +74,7 @@ class ScrobblerSettings : public QObject {
|
||||
int submit_delay_;
|
||||
bool prefer_albumartist_;
|
||||
bool show_error_dialog_;
|
||||
bool strip_remastered_;
|
||||
QList<Song::Source> sources_;
|
||||
|
||||
Q_DISABLE_COPY(ScrobblerSettings)
|
||||
|
@ -64,13 +64,12 @@ const char *ScrobblingAPI20::kSecret = "80fd738f49596e9709b1bf9319c444a8";
|
||||
const int ScrobblingAPI20::kScrobblesPerRequest = 50;
|
||||
|
||||
ScrobblingAPI20::ScrobblingAPI20(const QString &name, const QString &settings_group, const QString &auth_url, const QString &api_url, const bool batch, const QString &cache_file, SharedPtr<ScrobblerSettings> settings, SharedPtr<NetworkAccessManager> network, QObject *parent)
|
||||
: ScrobblerService(name, parent),
|
||||
: ScrobblerService(name, settings, parent),
|
||||
name_(name),
|
||||
settings_group_(settings_group),
|
||||
auth_url_(auth_url),
|
||||
api_url_(api_url),
|
||||
batch_(batch),
|
||||
settings_(settings),
|
||||
network_(network),
|
||||
cache_(new ScrobblerCache(cache_file, this)),
|
||||
server_(nullptr),
|
||||
|
@ -141,7 +141,6 @@ class ScrobblingAPI20 : public ScrobblerService {
|
||||
QString api_url_;
|
||||
bool batch_;
|
||||
|
||||
SharedPtr<ScrobblerSettings> settings_;
|
||||
SharedPtr<NetworkAccessManager> network_;
|
||||
ScrobblerCache *cache_;
|
||||
LocalRedirectServer *server_;
|
||||
|
@ -43,8 +43,7 @@
|
||||
const char *SubsonicScrobbler::kName = "Subsonic";
|
||||
|
||||
SubsonicScrobbler::SubsonicScrobbler(SharedPtr<ScrobblerSettings> settings, Application *app, QObject *parent)
|
||||
: ScrobblerService(kName, parent),
|
||||
settings_(settings),
|
||||
: ScrobblerService(kName, settings, parent),
|
||||
app_(app),
|
||||
service_(nullptr),
|
||||
enabled_(false),
|
||||
|
@ -65,7 +65,6 @@ class SubsonicScrobbler : public ScrobblerService {
|
||||
void Submit() override;
|
||||
|
||||
private:
|
||||
SharedPtr<ScrobblerSettings> settings_;
|
||||
Application *app_;
|
||||
SharedPtr<SubsonicService> service_;
|
||||
bool enabled_;
|
||||
|
@ -98,6 +98,7 @@ void ScrobblerSettingsPage::Load() {
|
||||
ui_->spinbox_submit->setValue(scrobbler_->submit_delay());
|
||||
ui_->checkbox_albumartist->setChecked(scrobbler_->prefer_albumartist());
|
||||
ui_->checkbox_show_error_dialog->setChecked(scrobbler_->ShowErrorDialog());
|
||||
ui_->checkbox_strip_remastered->setChecked(scrobbler_->strip_remastered());
|
||||
|
||||
ui_->checkbox_source_collection->setChecked(scrobbler_->sources().contains(Song::Source::Collection));
|
||||
ui_->checkbox_source_local->setChecked(scrobbler_->sources().contains(Song::Source::LocalFile));
|
||||
@ -139,6 +140,7 @@ void ScrobblerSettingsPage::Save() {
|
||||
s.setValue("submit", ui_->spinbox_submit->value());
|
||||
s.setValue("albumartist", ui_->checkbox_albumartist->isChecked());
|
||||
s.setValue("show_error_dialog", ui_->checkbox_show_error_dialog->isChecked());
|
||||
s.setValue("strip_remastered", ui_->checkbox_strip_remastered->isChecked());
|
||||
|
||||
QStringList sources;
|
||||
if (ui_->checkbox_source_collection->isChecked()) sources << Song::TextForSource(Song::Source::Collection);
|
||||
|
@ -119,6 +119,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_strip_remastered">
|
||||
<property name="text">
|
||||
<string>Strip "remastered" and similar from album and title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupbox_sources">
|
||||
<property name="title">
|
||||
|
Loading…
x
Reference in New Issue
Block a user