Add setting for cover providers
This commit is contained in:
parent
40f9dafa44
commit
7bccc21878
|
@ -32,7 +32,7 @@ You can also make a one-time payment through [paypal.me/jonaskvinge](https://pay
|
||||||
* Advanced audio output and device configuration for bit-perfect playback on Linux
|
* Advanced audio output and device configuration for bit-perfect playback on Linux
|
||||||
* Edit tags on music files
|
* Edit tags on music files
|
||||||
* Fetch tags from MusicBrainz
|
* Fetch tags from MusicBrainz
|
||||||
* Album cover art from [Last.fm](https://www.last.fm/), [Musicbrainz](https://musicbrainz.org/), [Discogs](https://www.discogs.com/), [Musixmatch](https://www.musixmatch.com/), [Deezer](https://www.deezer.com/), [Tidal](https://www.tidal.com/) and [Qobuz](https://www.qobuz.com/)
|
* Album cover art from [Last.fm](https://www.last.fm/), [Musicbrainz](https://musicbrainz.org/), [Discogs](https://www.discogs.com/), [Musixmatch](https://www.musixmatch.com/), [Deezer](https://www.deezer.com/), [Tidal](https://www.tidal.com/), [Qobuz](https://www.qobuz.com/) and [Spotify](https://www.spotify.com/)
|
||||||
* Song lyrics from [AudD](https://audd.io/), [Genius](https://genius.com/), [Musixmatch](https://www.musixmatch.com/), [ChartLyrics](http://www.chartlyrics.com/), [lyrics.ovh](https://lyrics.ovh/) and [lololyrics.com](https://www.lololyrics.com/)
|
* Song lyrics from [AudD](https://audd.io/), [Genius](https://genius.com/), [Musixmatch](https://www.musixmatch.com/), [ChartLyrics](http://www.chartlyrics.com/), [lyrics.ovh](https://lyrics.ovh/) and [lololyrics.com](https://www.lololyrics.com/)
|
||||||
* Support for multiple backends
|
* Support for multiple backends
|
||||||
* Audio analyzer
|
* Audio analyzer
|
||||||
|
|
|
@ -55,7 +55,7 @@ Description: Audio player and music collection organizer
|
||||||
- Advanced audio output and device configuration for bit-perfect playback on Linux
|
- Advanced audio output and device configuration for bit-perfect playback on Linux
|
||||||
- Edit tags on music files
|
- Edit tags on music files
|
||||||
- Fetch tags from MusicBrainz
|
- Fetch tags from MusicBrainz
|
||||||
- Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal and Qobuz
|
- Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal, Qobuz and Spotify
|
||||||
- Song lyrics from AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com
|
- Song lyrics from AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com
|
||||||
- Support for multiple backends
|
- Support for multiple backends
|
||||||
- Audio analyzer
|
- Audio analyzer
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<li>Advanced audio output and device configuration for bit-perfect playback on Linux</li>
|
<li>Advanced audio output and device configuration for bit-perfect playback on Linux</li>
|
||||||
<li>Edit tags on music files</li>
|
<li>Edit tags on music files</li>
|
||||||
<li>Fetch tags from MusicBrainz</li>
|
<li>Fetch tags from MusicBrainz</li>
|
||||||
<li>Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal and Qobuz</li>
|
<li>Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal, Qobuz and Spotify</li>
|
||||||
<li>Song lyrics from AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com</li>
|
<li>Song lyrics from AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com</li>
|
||||||
<li>Support for multiple backends</li>
|
<li>Support for multiple backends</li>
|
||||||
<li>Audio analyzer and equalizer</li>
|
<li>Audio analyzer and equalizer</li>
|
||||||
|
|
|
@ -25,7 +25,7 @@ Features:
|
||||||
.br
|
.br
|
||||||
- Fetch tags from MusicBrainz
|
- Fetch tags from MusicBrainz
|
||||||
.br
|
.br
|
||||||
- Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal and Qobuz
|
- Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal, Qobuz and Spotify
|
||||||
.br
|
.br
|
||||||
- Song lyrics from AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com
|
- Song lyrics from AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com
|
||||||
.br
|
.br
|
||||||
|
|
|
@ -104,7 +104,7 @@ Features:
|
||||||
- Advanced audio output and device configuration for bit-perfect playback on Linux
|
- Advanced audio output and device configuration for bit-perfect playback on Linux
|
||||||
- Edit tags on music files
|
- Edit tags on music files
|
||||||
- Fetch tags from MusicBrainz
|
- Fetch tags from MusicBrainz
|
||||||
- Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal and Qobuz
|
- Album cover art from Last.fm, Musicbrainz, Discogs, Musixmatch, Deezer, Tidal, Qobuz and Spotify
|
||||||
- Song lyrics from AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com
|
- Song lyrics from AudD, Genius, Musixmatch, ChartLyrics, lyrics.ovh and lololyrics.com
|
||||||
- Support for multiple backends
|
- Support for multiple backends
|
||||||
- Audio analyzer
|
- Audio analyzer
|
||||||
|
|
|
@ -188,6 +188,7 @@ set(SOURCES
|
||||||
covermanager/deezercoverprovider.cpp
|
covermanager/deezercoverprovider.cpp
|
||||||
covermanager/qobuzcoverprovider.cpp
|
covermanager/qobuzcoverprovider.cpp
|
||||||
covermanager/musixmatchcoverprovider.cpp
|
covermanager/musixmatchcoverprovider.cpp
|
||||||
|
covermanager/spotifycoverprovider.cpp
|
||||||
|
|
||||||
lyrics/lyricsproviders.cpp
|
lyrics/lyricsproviders.cpp
|
||||||
lyrics/lyricsprovider.cpp
|
lyrics/lyricsprovider.cpp
|
||||||
|
@ -206,13 +207,14 @@ set(SOURCES
|
||||||
settings/behavioursettingspage.cpp
|
settings/behavioursettingspage.cpp
|
||||||
settings/collectionsettingspage.cpp
|
settings/collectionsettingspage.cpp
|
||||||
settings/backendsettingspage.cpp
|
settings/backendsettingspage.cpp
|
||||||
settings/contextsettingspage.cpp
|
|
||||||
settings/playlistsettingspage.cpp
|
settings/playlistsettingspage.cpp
|
||||||
|
settings/scrobblersettingspage.cpp
|
||||||
|
settings/coverssettingspage.cpp
|
||||||
|
settings/lyricssettingspage.cpp
|
||||||
settings/networkproxysettingspage.cpp
|
settings/networkproxysettingspage.cpp
|
||||||
settings/appearancesettingspage.cpp
|
settings/appearancesettingspage.cpp
|
||||||
|
settings/contextsettingspage.cpp
|
||||||
settings/notificationssettingspage.cpp
|
settings/notificationssettingspage.cpp
|
||||||
settings/scrobblersettingspage.cpp
|
|
||||||
settings/lyricssettingspage.cpp
|
|
||||||
|
|
||||||
dialogs/about.cpp
|
dialogs/about.cpp
|
||||||
dialogs/console.cpp
|
dialogs/console.cpp
|
||||||
|
@ -381,6 +383,7 @@ set(HEADERS
|
||||||
covermanager/deezercoverprovider.h
|
covermanager/deezercoverprovider.h
|
||||||
covermanager/qobuzcoverprovider.h
|
covermanager/qobuzcoverprovider.h
|
||||||
covermanager/musixmatchcoverprovider.h
|
covermanager/musixmatchcoverprovider.h
|
||||||
|
covermanager/spotifycoverprovider.h
|
||||||
|
|
||||||
lyrics/lyricsproviders.h
|
lyrics/lyricsproviders.h
|
||||||
lyrics/lyricsprovider.h
|
lyrics/lyricsprovider.h
|
||||||
|
@ -399,13 +402,14 @@ set(HEADERS
|
||||||
settings/behavioursettingspage.h
|
settings/behavioursettingspage.h
|
||||||
settings/collectionsettingspage.h
|
settings/collectionsettingspage.h
|
||||||
settings/backendsettingspage.h
|
settings/backendsettingspage.h
|
||||||
settings/contextsettingspage.h
|
|
||||||
settings/playlistsettingspage.h
|
settings/playlistsettingspage.h
|
||||||
|
settings/scrobblersettingspage.h
|
||||||
|
settings/coverssettingspage.h
|
||||||
|
settings/lyricssettingspage.h
|
||||||
settings/networkproxysettingspage.h
|
settings/networkproxysettingspage.h
|
||||||
settings/appearancesettingspage.h
|
settings/appearancesettingspage.h
|
||||||
|
settings/contextsettingspage.h
|
||||||
settings/notificationssettingspage.h
|
settings/notificationssettingspage.h
|
||||||
settings/scrobblersettingspage.h
|
|
||||||
settings/lyricssettingspage.h
|
|
||||||
|
|
||||||
dialogs/about.h
|
dialogs/about.h
|
||||||
dialogs/errordialog.h
|
dialogs/errordialog.h
|
||||||
|
@ -498,11 +502,12 @@ set(UI
|
||||||
settings/backendsettingspage.ui
|
settings/backendsettingspage.ui
|
||||||
settings/contextsettingspage.ui
|
settings/contextsettingspage.ui
|
||||||
settings/playlistsettingspage.ui
|
settings/playlistsettingspage.ui
|
||||||
|
settings/scrobblersettingspage.ui
|
||||||
|
settings/coverssettingspage.ui
|
||||||
|
settings/lyricssettingspage.ui
|
||||||
settings/networkproxysettingspage.ui
|
settings/networkproxysettingspage.ui
|
||||||
settings/appearancesettingspage.ui
|
settings/appearancesettingspage.ui
|
||||||
settings/notificationssettingspage.ui
|
settings/notificationssettingspage.ui
|
||||||
settings/scrobblersettingspage.ui
|
|
||||||
settings/lyricssettingspage.ui
|
|
||||||
|
|
||||||
equalizer/equalizer.ui
|
equalizer/equalizer.ui
|
||||||
equalizer/equalizerslider.ui
|
equalizer/equalizerslider.ui
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
#include "covermanager/deezercoverprovider.h"
|
#include "covermanager/deezercoverprovider.h"
|
||||||
#include "covermanager/qobuzcoverprovider.h"
|
#include "covermanager/qobuzcoverprovider.h"
|
||||||
#include "covermanager/musixmatchcoverprovider.h"
|
#include "covermanager/musixmatchcoverprovider.h"
|
||||||
|
#include "covermanager/spotifycoverprovider.h"
|
||||||
|
|
||||||
#include "lyrics/lyricsproviders.h"
|
#include "lyrics/lyricsproviders.h"
|
||||||
#include "lyrics/auddlyricsprovider.h"
|
#include "lyrics/auddlyricsprovider.h"
|
||||||
|
@ -123,9 +124,11 @@ class ApplicationImpl {
|
||||||
cover_providers->AddProvider(new DeezerCoverProvider(app, app));
|
cover_providers->AddProvider(new DeezerCoverProvider(app, app));
|
||||||
cover_providers->AddProvider(new QobuzCoverProvider(app, app));
|
cover_providers->AddProvider(new QobuzCoverProvider(app, app));
|
||||||
cover_providers->AddProvider(new MusixmatchCoverProvider(app, app));
|
cover_providers->AddProvider(new MusixmatchCoverProvider(app, app));
|
||||||
|
cover_providers->AddProvider(new SpotifyCoverProvider(app, app));
|
||||||
#ifdef HAVE_TIDAL
|
#ifdef HAVE_TIDAL
|
||||||
cover_providers->AddProvider(new TidalCoverProvider(app, app));
|
cover_providers->AddProvider(new TidalCoverProvider(app, app));
|
||||||
#endif
|
#endif
|
||||||
|
cover_providers->ReloadSettings();
|
||||||
return cover_providers;
|
return cover_providers;
|
||||||
}),
|
}),
|
||||||
album_cover_loader_([=]() {
|
album_cover_loader_([=]() {
|
||||||
|
@ -136,6 +139,7 @@ class ApplicationImpl {
|
||||||
current_albumcover_loader_([=]() { return new CurrentAlbumCoverLoader(app, app); }),
|
current_albumcover_loader_([=]() { return new CurrentAlbumCoverLoader(app, app); }),
|
||||||
lyrics_providers_([=]() {
|
lyrics_providers_([=]() {
|
||||||
LyricsProviders *lyrics_providers = new LyricsProviders(app);
|
LyricsProviders *lyrics_providers = new LyricsProviders(app);
|
||||||
|
// Initialize the repository of lyrics providers.
|
||||||
lyrics_providers->AddProvider(new AuddLyricsProvider(app));
|
lyrics_providers->AddProvider(new AuddLyricsProvider(app));
|
||||||
lyrics_providers->AddProvider(new GeniusLyricsProvider(app));
|
lyrics_providers->AddProvider(new GeniusLyricsProvider(app));
|
||||||
lyrics_providers->AddProvider(new OVHLyricsProvider(app));
|
lyrics_providers->AddProvider(new OVHLyricsProvider(app));
|
||||||
|
|
|
@ -53,6 +53,7 @@ class DeviceManager;
|
||||||
class CoverProviders;
|
class CoverProviders;
|
||||||
class AlbumCoverLoader;
|
class AlbumCoverLoader;
|
||||||
class CurrentAlbumCoverLoader;
|
class CurrentAlbumCoverLoader;
|
||||||
|
class CoverProviders;
|
||||||
class LyricsProviders;
|
class LyricsProviders;
|
||||||
class AudioScrobbler;
|
class AudioScrobbler;
|
||||||
class InternetServices;
|
class InternetServices;
|
||||||
|
|
|
@ -134,6 +134,7 @@
|
||||||
#include "covermanager/albumcoverchoicecontroller.h"
|
#include "covermanager/albumcoverchoicecontroller.h"
|
||||||
#include "covermanager/albumcoverloaderresult.h"
|
#include "covermanager/albumcoverloaderresult.h"
|
||||||
#include "covermanager/currentalbumcoverloader.h"
|
#include "covermanager/currentalbumcoverloader.h"
|
||||||
|
#include "covermanager/coverproviders.h"
|
||||||
#include "lyrics/lyricsproviders.h"
|
#include "lyrics/lyricsproviders.h"
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
# include "device/devicemanager.h"
|
# include "device/devicemanager.h"
|
||||||
|
@ -951,6 +952,7 @@ void MainWindow::ReloadAllSettings() {
|
||||||
album_cover_choice_controller_->ReloadSettings();
|
album_cover_choice_controller_->ReloadSettings();
|
||||||
if (cover_manager_.get()) cover_manager_->ReloadSettings();
|
if (cover_manager_.get()) cover_manager_->ReloadSettings();
|
||||||
context_view_->ReloadSettings();
|
context_view_->ReloadSettings();
|
||||||
|
app_->cover_providers()->ReloadSettings();
|
||||||
app_->lyrics_providers()->ReloadSettings();
|
app_->lyrics_providers()->ReloadSettings();
|
||||||
#ifdef HAVE_SUBSONIC
|
#ifdef HAVE_SUBSONIC
|
||||||
subsonic_view_->ReloadSettings();
|
subsonic_view_->ReloadSettings();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
|
* Copyright 2018-2020, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
*
|
*
|
||||||
* Strawberry is free software: you can redistribute it and/or modify
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -72,12 +73,23 @@ void AlbumCoverFetcherSearch::TerminateSearch() {
|
||||||
|
|
||||||
void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) {
|
void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) {
|
||||||
|
|
||||||
for (CoverProvider *provider : cover_providers->List()) {
|
QList<CoverProvider*> cover_providers_sorted = cover_providers->List();
|
||||||
|
std::stable_sort(cover_providers_sorted.begin(), cover_providers_sorted.end(), ProviderCompareOrder);
|
||||||
|
|
||||||
// Skip provider if it does not have fetchall set, and we are doing fetchall - "Fetch Missing Covers".
|
for (CoverProvider *provider : cover_providers_sorted) {
|
||||||
|
|
||||||
|
if (!provider->is_enabled()) continue;
|
||||||
|
|
||||||
|
// Skip any provider that requires authentication but is not authenticated.
|
||||||
|
if (provider->AuthenticationRequired() && !provider->IsAuthenticated()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip provider if it does not have fetchall set and we are doing fetchall - "Fetch Missing Covers".
|
||||||
if (!provider->fetchall() && request_.fetchall) {
|
if (!provider->fetchall() && request_.fetchall) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If album is missing, check if we can still use this provider by searching using artist + title.
|
// If album is missing, check if we can still use this provider by searching using artist + title.
|
||||||
if (!provider->allow_missing_album() && request_.album.isEmpty()) {
|
if (!provider->allow_missing_album() && request_.album.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -299,6 +311,10 @@ void AlbumCoverFetcherSearch::Cancel() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AlbumCoverFetcherSearch::ProviderCompareOrder(CoverProvider *a, CoverProvider *b) {
|
||||||
|
return a->order() < b->order();
|
||||||
|
}
|
||||||
|
|
||||||
bool AlbumCoverFetcherSearch::CoverSearchResultCompareScore(const CoverSearchResult &a, const CoverSearchResult &b) {
|
bool AlbumCoverFetcherSearch::CoverSearchResultCompareScore(const CoverSearchResult &a, const CoverSearchResult &b) {
|
||||||
return a.score > b.score;
|
return a.score > b.score;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
|
* Copyright 2018-2020, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
*
|
*
|
||||||
* Strawberry is free software: you can redistribute it and/or modify
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -69,13 +70,15 @@ class AlbumCoverFetcherSearch : public QObject {
|
||||||
void TerminateSearch();
|
void TerminateSearch();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool CoverSearchResultCompareScore(const CoverSearchResult &a, const CoverSearchResult &b);
|
|
||||||
void AllProvidersFinished();
|
void AllProvidersFinished();
|
||||||
|
|
||||||
void FetchMoreImages();
|
void FetchMoreImages();
|
||||||
float ScoreImage(const QImage &image) const;
|
float ScoreImage(const QImage &image) const;
|
||||||
void SendBestImage();
|
void SendBestImage();
|
||||||
|
|
||||||
|
static bool ProviderCompareOrder(CoverProvider *a, CoverProvider *b);
|
||||||
|
static bool CoverSearchResultCompareScore(const CoverSearchResult &a, const CoverSearchResult &b);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int kSearchTimeoutMs;
|
static const int kSearchTimeoutMs;
|
||||||
static const int kImageLoadTimeoutMs;
|
static const int kImageLoadTimeoutMs;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
|
* Copyright 2018-2020, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
*
|
*
|
||||||
* Strawberry is free software: you can redistribute it and/or modify
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,5 +27,4 @@
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "coverprovider.h"
|
#include "coverprovider.h"
|
||||||
|
|
||||||
CoverProvider::CoverProvider(const QString &name, const float quality, const bool fetchall, const bool allow_missing_album, Application *app, QObject *parent)
|
CoverProvider::CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool fetchall, const bool allow_missing_album, Application *app, QObject *parent) : QObject(parent), app_(app), name_(name), enabled_(enabled), order_(0), authentication_required_(authentication_required), quality_(quality), fetchall_(fetchall), allow_missing_album_(allow_missing_album) {}
|
||||||
: QObject(parent), app_(app), name_(name), quality_(quality), fetchall_(fetchall), allow_missing_album_(allow_missing_album) {}
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
|
* Copyright 2018-2020, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
*
|
*
|
||||||
* Strawberry is free software: you can redistribute it and/or modify
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include "albumcoverfetcher.h"
|
#include "albumcoverfetcher.h"
|
||||||
|
|
||||||
|
@ -37,27 +39,42 @@ class CoverProvider : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CoverProvider(const QString &name, const float quality, const bool fetchall, const bool allow_missing_album, Application *app, QObject *parent);
|
explicit CoverProvider(const QString &name, const bool enabled, const bool authentication_required, const float quality, const bool fetchall, const bool allow_missing_album, Application *app, QObject *parent);
|
||||||
|
|
||||||
// A name (very short description) of this provider, like "last.fm".
|
// A name (very short description) of this provider, like "last.fm".
|
||||||
QString name() const { return name_; }
|
QString name() const { return name_; }
|
||||||
|
bool is_enabled() const { return enabled_; }
|
||||||
|
int order() const { return order_; }
|
||||||
bool quality() const { return quality_; }
|
bool quality() const { return quality_; }
|
||||||
bool fetchall() const { return fetchall_; }
|
bool fetchall() const { return fetchall_; }
|
||||||
bool allow_missing_album() const { return allow_missing_album_; }
|
bool allow_missing_album() const { return allow_missing_album_; }
|
||||||
|
|
||||||
|
void set_enabled(const bool enabled) { enabled_ = enabled; }
|
||||||
|
void set_order(const int order) { order_ = order; }
|
||||||
|
|
||||||
|
bool AuthenticationRequired() const { return authentication_required_; }
|
||||||
|
virtual bool IsAuthenticated() const { return true; }
|
||||||
|
virtual void Authenticate() {}
|
||||||
|
virtual void Deauthenticate() {}
|
||||||
|
|
||||||
// Starts searching for covers matching the given query text.
|
// Starts searching for covers matching the given query text.
|
||||||
// Returns true if the query has been started, or false if an error occurred.
|
// Returns true if the query has been started, or false if an error occurred.
|
||||||
// The provider should remember the ID and emit it along with the result when it finishes.
|
// The provider should remember the ID and emit it along with the result when it finishes.
|
||||||
virtual bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) = 0;
|
virtual bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id) = 0;
|
||||||
|
virtual void CancelSearch(const int id) { Q_UNUSED(id); }
|
||||||
virtual void CancelSearch(int id) { Q_UNUSED(id); }
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void SearchFinished(int id, const CoverSearchResults& results);
|
void AuthenticationComplete(bool, QStringList = QStringList());
|
||||||
|
void AuthenticationSuccess();
|
||||||
|
void AuthenticationFailure(QStringList);
|
||||||
|
void SearchFinished(int, CoverSearchResults);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Application *app_;
|
Application *app_;
|
||||||
QString name_;
|
QString name_;
|
||||||
|
bool enabled_;
|
||||||
|
int order_;
|
||||||
|
bool authentication_required_;
|
||||||
float quality_;
|
float quality_;
|
||||||
bool fetchall_;
|
bool fetchall_;
|
||||||
bool allow_missing_album_;
|
bool allow_missing_album_;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
|
* Copyright 2018-2020, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
*
|
*
|
||||||
* Strawberry is free software: you can redistribute it and/or modify
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,13 +23,23 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
#include <QList>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QVariantList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QSettings>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
#include "coverprovider.h"
|
#include "coverprovider.h"
|
||||||
#include "coverproviders.h"
|
#include "coverproviders.h"
|
||||||
|
|
||||||
|
#include "settings/coverssettingspage.h"
|
||||||
|
|
||||||
|
int CoverProviders::NextOrderId = 0;
|
||||||
|
|
||||||
CoverProviders::CoverProviders(QObject *parent) : QObject(parent) {}
|
CoverProviders::CoverProviders(QObject *parent) : QObject(parent) {}
|
||||||
|
|
||||||
CoverProviders::~CoverProviders() {
|
CoverProviders::~CoverProviders() {
|
||||||
|
@ -39,6 +50,48 @@ CoverProviders::~CoverProviders() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CoverProviders::ReloadSettings() {
|
||||||
|
|
||||||
|
QMap<int, QString> all_providers;
|
||||||
|
for (CoverProvider *provider : cover_providers_.keys()) {
|
||||||
|
if (!provider->is_enabled()) continue;
|
||||||
|
all_providers.insert(provider->order(), provider->name());
|
||||||
|
}
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(CoversSettingsPage::kSettingsGroup);
|
||||||
|
QStringList providers_enabled = s.value("providers", QStringList() << all_providers.values()).toStringList();
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
QList<CoverProvider*> providers;
|
||||||
|
for (const QString &name : providers_enabled) {
|
||||||
|
CoverProvider *provider = ProviderByName(name);
|
||||||
|
if (provider) {
|
||||||
|
provider->set_enabled(true);
|
||||||
|
provider->set_order(++i);
|
||||||
|
providers << provider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (CoverProvider *provider : cover_providers_.keys()) {
|
||||||
|
if (!providers.contains(provider)) {
|
||||||
|
provider->set_enabled(false);
|
||||||
|
provider->set_order(++i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CoverProvider *CoverProviders::ProviderByName(const QString &name) const {
|
||||||
|
|
||||||
|
for (CoverProvider *provider : cover_providers_.keys()) {
|
||||||
|
if (provider->name() == name) return provider;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CoverProviders::AddProvider(CoverProvider *provider) {
|
void CoverProviders::AddProvider(CoverProvider *provider) {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -47,6 +100,8 @@ void CoverProviders::AddProvider(CoverProvider *provider) {
|
||||||
connect(provider, SIGNAL(destroyed()), SLOT(ProviderDestroyed()));
|
connect(provider, SIGNAL(destroyed()), SLOT(ProviderDestroyed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provider->set_order(++NextOrderId);
|
||||||
|
|
||||||
qLog(Debug) << "Registered cover provider" << provider->name();
|
qLog(Debug) << "Registered cover provider" << provider->name();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* Strawberry Music Player
|
* Strawberry Music Player
|
||||||
* This file was part of Clementine.
|
* This file was part of Clementine.
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
|
* Copyright 2018-2020, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
*
|
*
|
||||||
* Strawberry is free software: you can redistribute it and/or modify
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -42,6 +43,10 @@ class CoverProviders : public QObject {
|
||||||
explicit CoverProviders(QObject *parent = nullptr);
|
explicit CoverProviders(QObject *parent = nullptr);
|
||||||
~CoverProviders();
|
~CoverProviders();
|
||||||
|
|
||||||
|
void ReloadSettings();
|
||||||
|
|
||||||
|
CoverProvider *ProviderByName(const QString &name) const;
|
||||||
|
|
||||||
// Lets a cover provider register itself in the repository.
|
// Lets a cover provider register itself in the repository.
|
||||||
void AddProvider(CoverProvider *provider);
|
void AddProvider(CoverProvider *provider);
|
||||||
void RemoveProvider(CoverProvider *provider);
|
void RemoveProvider(CoverProvider *provider);
|
||||||
|
@ -60,6 +65,8 @@ class CoverProviders : public QObject {
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(CoverProviders)
|
Q_DISABLE_COPY(CoverProviders)
|
||||||
|
|
||||||
|
static int NextOrderId;
|
||||||
|
|
||||||
QMap<CoverProvider*, QString> cover_providers_;
|
QMap<CoverProvider*, QString> cover_providers_;
|
||||||
QMutex mutex_;
|
QMutex mutex_;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
const char *DeezerCoverProvider::kApiUrl = "https://api.deezer.com";
|
const char *DeezerCoverProvider::kApiUrl = "https://api.deezer.com";
|
||||||
const int DeezerCoverProvider::kLimit = 10;
|
const int DeezerCoverProvider::kLimit = 10;
|
||||||
|
|
||||||
DeezerCoverProvider::DeezerCoverProvider(Application *app, QObject *parent): CoverProvider("Deezer", 2.0, true, true, app, parent), network_(new NetworkAccessManager(this)) {}
|
DeezerCoverProvider::DeezerCoverProvider(Application *app, QObject *parent): CoverProvider("Deezer", true, false, 2.0, true, true, app, parent), network_(new NetworkAccessManager(this)) {}
|
||||||
|
|
||||||
bool DeezerCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
bool DeezerCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ const char *DiscogsCoverProvider::kUrlSearch = "https://api.discogs.com/database
|
||||||
const char *DiscogsCoverProvider::kAccessKeyB64 = "dGh6ZnljUGJlZ1NEeXBuSFFxSVk=";
|
const char *DiscogsCoverProvider::kAccessKeyB64 = "dGh6ZnljUGJlZ1NEeXBuSFFxSVk=";
|
||||||
const char *DiscogsCoverProvider::kSecretKeyB64 = "ZkFIcmlaSER4aHhRSlF2U3d0bm5ZVmdxeXFLWUl0UXI=";
|
const char *DiscogsCoverProvider::kSecretKeyB64 = "ZkFIcmlaSER4aHhRSlF2U3d0bm5ZVmdxeXFLWUl0UXI=";
|
||||||
|
|
||||||
DiscogsCoverProvider::DiscogsCoverProvider(Application *app, QObject *parent) : CoverProvider("Discogs", 0.0, false, false, app, parent), network_(new NetworkAccessManager(this)) {}
|
DiscogsCoverProvider::DiscogsCoverProvider(Application *app, QObject *parent) : CoverProvider("Discogs", false, false, 0.0, false, false, app, parent), network_(new NetworkAccessManager(this)) {}
|
||||||
|
|
||||||
DiscogsCoverProvider::~DiscogsCoverProvider() {
|
DiscogsCoverProvider::~DiscogsCoverProvider() {
|
||||||
requests_search_.clear();
|
requests_search_.clear();
|
||||||
|
|
|
@ -53,7 +53,7 @@ const char *LastFmCoverProvider::kUrl = "https://ws.audioscrobbler.com/2.0/";
|
||||||
const char *LastFmCoverProvider::kApiKey = "211990b4c96782c05d1536e7219eb56e";
|
const char *LastFmCoverProvider::kApiKey = "211990b4c96782c05d1536e7219eb56e";
|
||||||
const char *LastFmCoverProvider::kSecret = "80fd738f49596e9709b1bf9319c444a8";
|
const char *LastFmCoverProvider::kSecret = "80fd738f49596e9709b1bf9319c444a8";
|
||||||
|
|
||||||
LastFmCoverProvider::LastFmCoverProvider(Application *app, QObject *parent) : CoverProvider("last.fm", 1.0, true, false, app, parent), network_(new NetworkAccessManager(this)) {}
|
LastFmCoverProvider::LastFmCoverProvider(Application *app, QObject *parent) : CoverProvider("Last.fm", true, false, 1.0, true, false, app, parent), network_(new NetworkAccessManager(this)) {}
|
||||||
|
|
||||||
bool LastFmCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
bool LastFmCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ const char *MusicbrainzCoverProvider::kReleaseSearchUrl = "https://musicbrainz.o
|
||||||
const char *MusicbrainzCoverProvider::kAlbumCoverUrl = "https://coverartarchive.org/release/%1/front";
|
const char *MusicbrainzCoverProvider::kAlbumCoverUrl = "https://coverartarchive.org/release/%1/front";
|
||||||
const int MusicbrainzCoverProvider::kLimit = 8;
|
const int MusicbrainzCoverProvider::kLimit = 8;
|
||||||
|
|
||||||
MusicbrainzCoverProvider::MusicbrainzCoverProvider(Application *app, QObject *parent): CoverProvider("MusicBrainz", 1.5, true, false, app, parent), network_(new NetworkAccessManager(this)) {}
|
MusicbrainzCoverProvider::MusicbrainzCoverProvider(Application *app, QObject *parent): CoverProvider("MusicBrainz", true, false, 1.5, true, false, app, parent), network_(new NetworkAccessManager(this)) {}
|
||||||
|
|
||||||
bool MusicbrainzCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
bool MusicbrainzCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include "coverprovider.h"
|
#include "coverprovider.h"
|
||||||
#include "musixmatchcoverprovider.h"
|
#include "musixmatchcoverprovider.h"
|
||||||
|
|
||||||
MusixmatchCoverProvider::MusixmatchCoverProvider(Application *app, QObject *parent): CoverProvider("Musixmatch", 1.0, true, false, app, parent), network_(new NetworkAccessManager(this)) {}
|
MusixmatchCoverProvider::MusixmatchCoverProvider(Application *app, QObject *parent): CoverProvider("Musixmatch", true, false, 1.0, true, false, app, parent), network_(new NetworkAccessManager(this)) {}
|
||||||
|
|
||||||
bool MusixmatchCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
bool MusixmatchCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ const char *QobuzCoverProvider::kApiUrl = "https://www.qobuz.com/api.json/0.2";
|
||||||
const char *QobuzCoverProvider::kAppID = "OTQyODUyNTY3";
|
const char *QobuzCoverProvider::kAppID = "OTQyODUyNTY3";
|
||||||
const int QobuzCoverProvider::kLimit = 10;
|
const int QobuzCoverProvider::kLimit = 10;
|
||||||
|
|
||||||
QobuzCoverProvider::QobuzCoverProvider(Application *app, QObject *parent) : CoverProvider("Qobuz", 2.0, true, true, app, parent), network_(new NetworkAccessManager(this)) {}
|
QobuzCoverProvider::QobuzCoverProvider(Application *app, QObject *parent) : CoverProvider("Qobuz", true, false, 2.0, true, true, app, parent), network_(new NetworkAccessManager(this)) {}
|
||||||
|
|
||||||
bool QobuzCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
bool QobuzCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,529 @@
|
||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2020, 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QList>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QUrlQuery>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QSslError>
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonValue>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include "core/application.h"
|
||||||
|
#include "core/network.h"
|
||||||
|
#include "core/logging.h"
|
||||||
|
#include "core/song.h"
|
||||||
|
#include "core/utilities.h"
|
||||||
|
#include "internet/localredirectserver.h"
|
||||||
|
#include "albumcoverfetcher.h"
|
||||||
|
#include "coverprovider.h"
|
||||||
|
#include "spotifycoverprovider.h"
|
||||||
|
|
||||||
|
const char *SpotifyCoverProvider::kSettingsGroup = "Spotify";
|
||||||
|
const char *SpotifyCoverProvider::kOAuthAuthorizeUrl = "https://accounts.spotify.com/authorize";
|
||||||
|
const char *SpotifyCoverProvider::kOAuthAccessTokenUrl = "https://accounts.spotify.com/api/token";
|
||||||
|
const char *SpotifyCoverProvider::kOAuthRedirectUrl = "http://localhost:63111/";
|
||||||
|
const char *SpotifyCoverProvider::kClientIDB64 = "ZTZjY2Y2OTQ5NzY1NGE3NThjOTAxNWViYzdiMWQzMTc=";
|
||||||
|
const char *SpotifyCoverProvider::kClientSecretB64 = "N2ZlMDMxODk1NTBlNDE3ZGI1ZWQ1MzE3ZGZlZmU2MTE=";
|
||||||
|
const char *SpotifyCoverProvider::kApiUrl = "https://api.spotify.com/v1";
|
||||||
|
const int SpotifyCoverProvider::kLimit = 10;
|
||||||
|
|
||||||
|
SpotifyCoverProvider::SpotifyCoverProvider(Application *app, QObject *parent) : CoverProvider("Spotify", true, true, 2.5, true, true, app, parent), network_(new NetworkAccessManager(this)), server_(nullptr) {
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
if (s.contains("access_token")) {
|
||||||
|
access_token_ = s.value("access_token").toString();
|
||||||
|
}
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpotifyCoverProvider::Authenticate() {
|
||||||
|
|
||||||
|
QUrl redirect_url(kOAuthRedirectUrl);
|
||||||
|
|
||||||
|
if (!server_) {
|
||||||
|
server_ = new LocalRedirectServer(this);
|
||||||
|
server_->set_https(false);
|
||||||
|
int port = redirect_url.port();
|
||||||
|
int port_max = port + 10;
|
||||||
|
bool success = false;
|
||||||
|
forever {
|
||||||
|
server_->set_port(port);
|
||||||
|
if (server_->Listen()) { success = true; break; }
|
||||||
|
++port;
|
||||||
|
if (port > port_max) break;
|
||||||
|
}
|
||||||
|
if (!success) {
|
||||||
|
AuthError(server_->error());
|
||||||
|
server_->deleteLater();
|
||||||
|
server_ = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
connect(server_, SIGNAL(Finished()), this, SLOT(RedirectArrived()));
|
||||||
|
}
|
||||||
|
|
||||||
|
code_verifier_ = Utilities::CryptographicRandomString(44);
|
||||||
|
code_challenge_ = QString(QCryptographicHash::hash(code_verifier_.toUtf8(), QCryptographicHash::Sha256).toBase64(QByteArray::Base64UrlEncoding));
|
||||||
|
if (code_challenge_.lastIndexOf(QChar('=')) == code_challenge_.length() - 1) {
|
||||||
|
code_challenge_.chop(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const ParamList params = ParamList() << Param("client_id", QByteArray::fromBase64(kClientIDB64))
|
||||||
|
<< Param("response_type", "code")
|
||||||
|
<< Param("redirect_uri", redirect_url.toString())
|
||||||
|
<< Param("state", code_challenge_);
|
||||||
|
|
||||||
|
|
||||||
|
QUrlQuery url_query;
|
||||||
|
for (const Param ¶m : params) {
|
||||||
|
url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl url(kOAuthAuthorizeUrl);
|
||||||
|
url.setQuery(url_query);
|
||||||
|
|
||||||
|
const bool result = QDesktopServices::openUrl(url);
|
||||||
|
if (!result) {
|
||||||
|
QMessageBox messagebox(QMessageBox::Information, tr("Spotify Authentication"), tr("Please open this URL in your browser") + QString(":<br /><a href=\"%1\">%1</a>").arg(url.toString()), QMessageBox::Ok);
|
||||||
|
messagebox.setTextFormat(Qt::RichText);
|
||||||
|
messagebox.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpotifyCoverProvider::Deauthenticate() {
|
||||||
|
|
||||||
|
access_token_.clear();
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
s.remove("access_token");
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpotifyCoverProvider::RedirectArrived() {
|
||||||
|
|
||||||
|
if (!server_) return;
|
||||||
|
|
||||||
|
if (server_->error().isEmpty()) {
|
||||||
|
QUrl url = server_->request_url();
|
||||||
|
if (url.isValid()) {
|
||||||
|
QUrlQuery url_query(url);
|
||||||
|
if (url_query.hasQueryItem("error")) {
|
||||||
|
AuthError(QUrlQuery(url).queryItemValue("error"));
|
||||||
|
}
|
||||||
|
else if (url_query.hasQueryItem("code")) {
|
||||||
|
QUrl redirect_url(kOAuthRedirectUrl);
|
||||||
|
redirect_url.setPort(server_->url().port());
|
||||||
|
RequestAccessToken(url, redirect_url);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
AuthError(tr("Redirect missing token code!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
AuthError(tr("Received invalid reply from web browser."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
AuthError(server_->error());
|
||||||
|
}
|
||||||
|
|
||||||
|
server_->close();
|
||||||
|
server_->deleteLater();
|
||||||
|
server_ = nullptr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpotifyCoverProvider::RequestAccessToken(const QUrl &url, const QUrl &redirect_url) {
|
||||||
|
|
||||||
|
qLog(Debug) << "Spotify: Authorization URL Received" << url;
|
||||||
|
|
||||||
|
QUrlQuery url_query(url);
|
||||||
|
|
||||||
|
if (url.hasQuery() && url_query.hasQueryItem("code") && url_query.hasQueryItem("state")) {
|
||||||
|
|
||||||
|
QString code = url_query.queryItemValue("code");
|
||||||
|
QString state = url_query.queryItemValue("state");
|
||||||
|
|
||||||
|
const ParamList params = ParamList() << Param("client_id", QByteArray::fromBase64(kClientIDB64))
|
||||||
|
<< Param("client_secret", QByteArray::fromBase64(kClientSecretB64))
|
||||||
|
<< Param("grant_type", "authorization_code")
|
||||||
|
<< Param("code", code)
|
||||||
|
<< Param("redirect_uri", redirect_url.toString());
|
||||||
|
|
||||||
|
QUrlQuery new_url_query;
|
||||||
|
for (const Param ¶m : params) {
|
||||||
|
new_url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl new_url(kOAuthAccessTokenUrl);
|
||||||
|
QNetworkRequest req = QNetworkRequest(new_url);
|
||||||
|
req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||||
|
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
|
QString auth_header_data = QByteArray::fromBase64(kClientIDB64) + QString(":") + QByteArray::fromBase64(kClientSecretB64);
|
||||||
|
req.setRawHeader("Authorization", "Basic " + auth_header_data.toUtf8().toBase64());
|
||||||
|
|
||||||
|
QByteArray query = new_url_query.toString(QUrl::FullyEncoded).toUtf8();
|
||||||
|
|
||||||
|
QNetworkReply *reply = network_->post(req, query);
|
||||||
|
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(HandleLoginSSLErrors(QList<QSslError>)));
|
||||||
|
connect(reply, &QNetworkReply::finished, [=] { AccessTokenRequestFinished(reply); });
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
AuthError(tr("Redirect from Spotify is missing query items code or state."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpotifyCoverProvider::HandleLoginSSLErrors(QList<QSslError> ssl_errors) {
|
||||||
|
|
||||||
|
for (const QSslError &ssl_error : ssl_errors) {
|
||||||
|
login_errors_ += ssl_error.errorString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpotifyCoverProvider::AccessTokenRequestFinished(QNetworkReply *reply) {
|
||||||
|
|
||||||
|
reply->deleteLater();
|
||||||
|
|
||||||
|
if (reply->error() != QNetworkReply::NoError || reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
|
||||||
|
if (reply->error() != QNetworkReply::NoError && reply->error() < 200) {
|
||||||
|
// This is a network error, there is nothing more to do.
|
||||||
|
AuthError(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// See if there is Json data containing "error" and "error_description" then use that instead.
|
||||||
|
QByteArray data = reply->readAll();
|
||||||
|
QJsonParseError json_error;
|
||||||
|
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
||||||
|
if (json_error.error == QJsonParseError::NoError && !json_doc.isNull() && !json_doc.isEmpty() && json_doc.isObject()) {
|
||||||
|
QJsonObject json_obj = json_doc.object();
|
||||||
|
if (!json_obj.isEmpty() && json_obj.contains("error") && json_obj.contains("error_description")) {
|
||||||
|
QString error = json_obj["error"].toString();
|
||||||
|
QString error_description = json_obj["error_description"].toString();
|
||||||
|
login_errors_ << QString("Authentication failure: %1 (%2)").arg(error).arg(error_description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (login_errors_.isEmpty()) {
|
||||||
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
|
login_errors_ << QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
login_errors_ << QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AuthError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray data = reply->readAll();
|
||||||
|
qLog(Debug) << data;
|
||||||
|
|
||||||
|
QJsonParseError json_error;
|
||||||
|
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
||||||
|
|
||||||
|
if (json_error.error != QJsonParseError::NoError) {
|
||||||
|
AuthError("Authentication reply from server missing Json data.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json_doc.isEmpty()) {
|
||||||
|
AuthError("Authentication reply from server has empty Json document.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!json_doc.isObject()) {
|
||||||
|
AuthError("Authentication reply from server has Json document that is not an object.", json_doc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject json_obj = json_doc.object();
|
||||||
|
if (json_obj.isEmpty()) {
|
||||||
|
AuthError("Authentication reply from server has empty Json object.", json_doc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!json_obj.contains("access_token")) {
|
||||||
|
AuthError("Authentication reply from server is missing access token.", json_obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
access_token_ = json_obj["access_token"].toString();
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
s.setValue("access_token", access_token_);
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
qLog(Debug) << "Spotify: Authentication was successful, got access token" << access_token_;
|
||||||
|
|
||||||
|
emit AuthenticationComplete(true);
|
||||||
|
emit AuthenticationSuccess();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SpotifyCoverProvider::StartSearch(const QString &artist, const QString &album, const QString &title, const int id) {
|
||||||
|
|
||||||
|
if (access_token_.isEmpty()) return false;
|
||||||
|
|
||||||
|
QString type;
|
||||||
|
QString query;
|
||||||
|
QString extract;
|
||||||
|
if (album.isEmpty()) {
|
||||||
|
type = "track";
|
||||||
|
query = artist + " " + title;
|
||||||
|
extract = "tracks";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
type = "album";
|
||||||
|
query = artist + " " + album;
|
||||||
|
extract = "albums";
|
||||||
|
}
|
||||||
|
|
||||||
|
ParamList params = ParamList() << Param("q", query)
|
||||||
|
<< Param("type", type)
|
||||||
|
<< Param("limit", QString::number(kLimit));
|
||||||
|
|
||||||
|
QUrlQuery url_query;
|
||||||
|
for (const Param ¶m : params) {
|
||||||
|
url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
|
||||||
|
}
|
||||||
|
|
||||||
|
QUrl url(kApiUrl + QString("/search"));
|
||||||
|
url.setQuery(url_query);
|
||||||
|
QNetworkRequest req(url);
|
||||||
|
req.setAttribute(QNetworkRequest::FollowRedirectsAttribute, true);
|
||||||
|
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
|
req.setRawHeader("Authorization", "Bearer " + access_token_.toUtf8());
|
||||||
|
|
||||||
|
QNetworkReply *reply = network_->get(req);
|
||||||
|
connect(reply, &QNetworkReply::finished, [=] { HandleSearchReply(reply, id, extract); });
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpotifyCoverProvider::CancelSearch(const int id) { Q_UNUSED(id); }
|
||||||
|
|
||||||
|
QByteArray SpotifyCoverProvider::GetReplyData(QNetworkReply *reply) {
|
||||||
|
|
||||||
|
QByteArray data;
|
||||||
|
|
||||||
|
if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 200) {
|
||||||
|
data = reply->readAll();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (reply->error() != QNetworkReply::NoError && reply->error() < 200) {
|
||||||
|
// This is a network error, there is nothing more to do.
|
||||||
|
Error(QString("%1 (%2)").arg(reply->errorString()).arg(reply->error()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data = reply->readAll();
|
||||||
|
QJsonParseError parse_error;
|
||||||
|
QJsonDocument json_doc = QJsonDocument::fromJson(data, &parse_error);
|
||||||
|
QString error;
|
||||||
|
if (parse_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
|
||||||
|
QJsonObject json_obj = json_doc.object();
|
||||||
|
if (!json_obj.isEmpty() && json_obj.contains("error") && json_obj["error"].isObject()) {
|
||||||
|
QJsonObject obj_error = json_obj["error"].toObject();
|
||||||
|
if (obj_error.contains("status") && obj_error.contains("message")) {
|
||||||
|
int status = obj_error["status"].toInt();
|
||||||
|
QString message = obj_error["message"].toString();
|
||||||
|
error = QString("%1 (%2)").arg(message).arg(status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (error.isEmpty()) {
|
||||||
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
|
if (reply->error() == 204) access_token_.clear();
|
||||||
|
error = QString("%1 (%2)").arg(reply->errorString()).arg(reply->error());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error = QString("Received HTTP code %1").arg(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Error(error);
|
||||||
|
}
|
||||||
|
return QByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject SpotifyCoverProvider::ExtractJsonObj(const QByteArray &data) {
|
||||||
|
|
||||||
|
QJsonParseError json_error;
|
||||||
|
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
|
||||||
|
|
||||||
|
if (json_error.error != QJsonParseError::NoError) {
|
||||||
|
Error(QString("Failed to parse json data: %1").arg(json_error.errorString()));
|
||||||
|
return QJsonObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json_doc.isEmpty()) {
|
||||||
|
Error("Received empty Json document.", data);
|
||||||
|
return QJsonObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!json_doc.isObject()) {
|
||||||
|
Error("Json document is not an object.", json_doc);
|
||||||
|
return QJsonObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject json_obj = json_doc.object();
|
||||||
|
if (json_obj.isEmpty()) {
|
||||||
|
Error("Received empty Json object.", json_doc);
|
||||||
|
return QJsonObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_obj;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpotifyCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id, const QString &extract) {
|
||||||
|
|
||||||
|
reply->deleteLater();
|
||||||
|
|
||||||
|
QByteArray data = GetReplyData(reply);
|
||||||
|
if (data.isEmpty()) {
|
||||||
|
emit SearchFinished(id, CoverSearchResults());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject json_obj = ExtractJsonObj(data);
|
||||||
|
if (json_obj.isEmpty()) {
|
||||||
|
emit SearchFinished(id, CoverSearchResults());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!json_obj.contains(extract) || !json_obj[extract].isObject()) {
|
||||||
|
Error(QString("Json object is missing %1 object.").arg(extract), json_obj);
|
||||||
|
emit SearchFinished(id, CoverSearchResults());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
json_obj = json_obj[extract].toObject();
|
||||||
|
|
||||||
|
if (!json_obj.contains("items") || !json_obj["items"].isArray()) {
|
||||||
|
Error(QString("%1 object is missing items array.").arg(extract), json_obj);
|
||||||
|
emit SearchFinished(id, CoverSearchResults());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonArray array_items = json_obj["items"].toArray();
|
||||||
|
if (array_items.isEmpty()) {
|
||||||
|
emit SearchFinished(id, CoverSearchResults());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoverSearchResults results;
|
||||||
|
for (const QJsonValue &value_item : array_items) {
|
||||||
|
|
||||||
|
if (!value_item.isObject()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QJsonObject obj_item = value_item.toObject();
|
||||||
|
|
||||||
|
QJsonObject obj_album = obj_item;
|
||||||
|
if (obj_item.contains("album") && obj_item["album"].isObject()) {
|
||||||
|
obj_album = obj_item["album"].toObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!obj_album.contains("artists") || !obj_album.contains("name") || !obj_album.contains("images") || !obj_album["artists"].isArray() || !obj_album["images"].isArray()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QJsonArray array_artists = obj_album["artists"].toArray();
|
||||||
|
QJsonArray array_images = obj_album["images"].toArray();
|
||||||
|
QString album = obj_album["name"].toString();
|
||||||
|
|
||||||
|
QStringList artists;
|
||||||
|
for (const QJsonValue &value_artist : array_artists) {
|
||||||
|
if (!value_artist.isObject()) continue;
|
||||||
|
QJsonObject obj_artist = value_artist.toObject();
|
||||||
|
if (!obj_artist.contains("name")) continue;
|
||||||
|
artists << obj_artist["name"].toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const QJsonValue &value_image : array_images) {
|
||||||
|
if (!value_image.isObject()) continue;
|
||||||
|
QJsonObject obj_image = value_image.toObject();
|
||||||
|
if (!obj_image.contains("url") || !obj_image.contains("width") || !obj_image.contains("height")) continue;
|
||||||
|
int width = obj_image["width"].toInt();
|
||||||
|
int height = obj_image["height"].toInt();
|
||||||
|
if (width < 300 || height < 300) continue;
|
||||||
|
QUrl url(obj_image["url"].toString());
|
||||||
|
CoverSearchResult result;
|
||||||
|
result.album = album;
|
||||||
|
result.image_url = url;
|
||||||
|
if (!artists.isEmpty()) result.artist = artists.first();
|
||||||
|
results << result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
emit SearchFinished(id, results);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpotifyCoverProvider::AuthError(const QString &error, const QVariant &debug) {
|
||||||
|
|
||||||
|
if (!error.isEmpty()) login_errors_ << error;
|
||||||
|
|
||||||
|
for (const QString &e : login_errors_) Error(e);
|
||||||
|
if (debug.isValid()) qLog(Debug) << debug;
|
||||||
|
|
||||||
|
emit AuthenticationFailure(login_errors_);
|
||||||
|
emit AuthenticationComplete(false, login_errors_);
|
||||||
|
|
||||||
|
login_errors_.clear();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpotifyCoverProvider::Error(const QString &error, const QVariant &debug) {
|
||||||
|
|
||||||
|
qLog(Error) << "Spotify:" << error;
|
||||||
|
if (debug.isValid()) qLog(Debug) << debug;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2018, 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 SPOTIFYCOVERPROVIDER_H
|
||||||
|
#define SPOTIFYCOVERPROVIDER_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QPair>
|
||||||
|
#include <QSet>
|
||||||
|
#include <QList>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QString>
|
||||||
|
#include <QSslError>
|
||||||
|
#include <QJsonValue>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#include "coverprovider.h"
|
||||||
|
|
||||||
|
class QNetworkAccessManager;
|
||||||
|
class QNetworkReply;
|
||||||
|
class Application;
|
||||||
|
class LocalRedirectServer;
|
||||||
|
|
||||||
|
class SpotifyCoverProvider : public CoverProvider {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SpotifyCoverProvider(Application *app, QObject *parent = nullptr);
|
||||||
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id);
|
||||||
|
void CancelSearch(const int id);
|
||||||
|
|
||||||
|
void Authenticate();
|
||||||
|
void Deauthenticate();
|
||||||
|
bool IsAuthenticated() const { return !access_token_.isEmpty(); }
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void HandleLoginSSLErrors(QList<QSslError> ssl_errors);
|
||||||
|
void RedirectArrived();
|
||||||
|
void AccessTokenRequestFinished(QNetworkReply *reply);
|
||||||
|
void HandleSearchReply(QNetworkReply *reply, const int id, const QString &extract);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void RequestAccessToken(const QUrl &url, const QUrl &redirect_url);
|
||||||
|
QByteArray GetReplyData(QNetworkReply *reply);
|
||||||
|
QJsonObject ExtractJsonObj(const QByteArray &data);
|
||||||
|
void AuthError(const QString &error = QString(), const QVariant &debug = QVariant());
|
||||||
|
void Error(const QString &error, const QVariant &debug = QVariant());
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef QPair<QString, QString> Param;
|
||||||
|
typedef QList<Param> ParamList;
|
||||||
|
|
||||||
|
static const char *kSettingsGroup;
|
||||||
|
static const char *kClientIDB64;
|
||||||
|
static const char *kClientSecretB64;
|
||||||
|
static const char *kOAuthAuthorizeUrl;
|
||||||
|
static const char *kOAuthAccessTokenUrl;
|
||||||
|
static const char *kOAuthRedirectUrl;
|
||||||
|
static const char *kApiUrl;
|
||||||
|
static const int kLimit;
|
||||||
|
|
||||||
|
QNetworkAccessManager *network_;
|
||||||
|
LocalRedirectServer *server_;
|
||||||
|
QStringList login_errors_;
|
||||||
|
QString code_verifier_;
|
||||||
|
QString code_challenge_;
|
||||||
|
QString access_token_;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SPOTIFYCOVERPROVIDER_H
|
|
@ -53,7 +53,7 @@ const char *TidalCoverProvider::kResourcesUrl = "https://resources.tidal.com";
|
||||||
const int TidalCoverProvider::kLimit = 10;
|
const int TidalCoverProvider::kLimit = 10;
|
||||||
|
|
||||||
TidalCoverProvider::TidalCoverProvider(Application *app, QObject *parent) :
|
TidalCoverProvider::TidalCoverProvider(Application *app, QObject *parent) :
|
||||||
CoverProvider("Tidal", 2.5, true, true, app, parent),
|
CoverProvider("Tidal", true, true, 2.5, true, true, app, parent),
|
||||||
service_(app->internet_services()->Service<TidalService>()),
|
service_(app->internet_services()->Service<TidalService>()),
|
||||||
network_(new NetworkAccessManager(this)) {
|
network_(new NetworkAccessManager(this)) {
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,11 @@
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
#include "coverprovider.h"
|
#include "coverprovider.h"
|
||||||
|
#include "tidal/tidalservice.h"
|
||||||
|
|
||||||
class QNetworkAccessManager;
|
class QNetworkAccessManager;
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
class Application;
|
class Application;
|
||||||
class TidalService;
|
|
||||||
|
|
||||||
class TidalCoverProvider : public CoverProvider {
|
class TidalCoverProvider : public CoverProvider {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -47,6 +47,9 @@ class TidalCoverProvider : public CoverProvider {
|
||||||
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id);
|
bool StartSearch(const QString &artist, const QString &album, const QString &title, const int id);
|
||||||
void CancelSearch(const int id);
|
void CancelSearch(const int id);
|
||||||
|
|
||||||
|
bool IsAuthenticated() const { return service_ && service_->authenticated(); }
|
||||||
|
void Deauthenticate() { if (service_) service_->Logout(); }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void HandleSearchReply(QNetworkReply *reply, const int id);
|
void HandleSearchReply(QNetworkReply *reply, const int id);
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QMap>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QVariantList>
|
#include <QVariantList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -35,6 +36,8 @@
|
||||||
|
|
||||||
#include "settings/lyricssettingspage.h"
|
#include "settings/lyricssettingspage.h"
|
||||||
|
|
||||||
|
int LyricsProviders::NextOrderId = 0;
|
||||||
|
|
||||||
LyricsProviders::LyricsProviders(QObject *parent) : QObject(parent) {}
|
LyricsProviders::LyricsProviders(QObject *parent) : QObject(parent) {}
|
||||||
|
|
||||||
LyricsProviders::~LyricsProviders() {
|
LyricsProviders::~LyricsProviders() {
|
||||||
|
@ -47,15 +50,15 @@ LyricsProviders::~LyricsProviders() {
|
||||||
|
|
||||||
void LyricsProviders::ReloadSettings() {
|
void LyricsProviders::ReloadSettings() {
|
||||||
|
|
||||||
QStringList all_providers;
|
QMap<int, QString> all_providers;
|
||||||
for (LyricsProvider *provider : lyrics_providers_.keys()) {
|
for (LyricsProvider *provider : lyrics_providers_.keys()) {
|
||||||
if (!provider->is_enabled()) continue;
|
if (!provider->is_enabled()) continue;
|
||||||
all_providers << provider->name();
|
all_providers.insert(provider->order(), provider->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(LyricsSettingsPage::kSettingsGroup);
|
s.beginGroup(LyricsSettingsPage::kSettingsGroup);
|
||||||
QStringList providers_enabled = s.value("providers", all_providers).toStringList();
|
QStringList providers_enabled = s.value("providers", QStringList() << all_providers.values()).toStringList();
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -95,6 +98,8 @@ void LyricsProviders::AddProvider(LyricsProvider *provider) {
|
||||||
connect(provider, SIGNAL(destroyed()), SLOT(ProviderDestroyed()));
|
connect(provider, SIGNAL(destroyed()), SLOT(ProviderDestroyed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
provider->set_order(++NextOrderId);
|
||||||
|
|
||||||
qLog(Debug) << "Registered lyrics provider" << provider->name();
|
qLog(Debug) << "Registered lyrics provider" << provider->name();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@ class LyricsProviders : public QObject {
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(LyricsProviders)
|
Q_DISABLE_COPY(LyricsProviders)
|
||||||
|
|
||||||
|
static int NextOrderId;
|
||||||
|
|
||||||
QMap<LyricsProvider*, QString> lyrics_providers_;
|
QMap<LyricsProvider*, QString> lyrics_providers_;
|
||||||
QList<LyricsProvider*> ordered_providers_;
|
QList<LyricsProvider*> ordered_providers_;
|
||||||
QMutex mutex_;
|
QMutex mutex_;
|
||||||
|
|
|
@ -0,0 +1,263 @@
|
||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2020, 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QList>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QPalette>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "settingsdialog.h"
|
||||||
|
#include "coverssettingspage.h"
|
||||||
|
#include "ui_coverssettingspage.h"
|
||||||
|
#include "core/application.h"
|
||||||
|
#include "core/iconloader.h"
|
||||||
|
#include "core/logging.h"
|
||||||
|
#include "covermanager/coverproviders.h"
|
||||||
|
#include "covermanager/coverprovider.h"
|
||||||
|
#include "widgets/loginstatewidget.h"
|
||||||
|
|
||||||
|
const char *CoversSettingsPage::kSettingsGroup = "Covers";
|
||||||
|
|
||||||
|
CoversSettingsPage::CoversSettingsPage(SettingsDialog *parent) : SettingsPage(parent), ui_(new Ui::CoversSettingsPage), provider_selected_(false) {
|
||||||
|
|
||||||
|
ui_->setupUi(this);
|
||||||
|
setWindowIcon(IconLoader::Load("cdcase"));
|
||||||
|
|
||||||
|
connect(ui_->providers_up, SIGNAL(clicked()), SLOT(ProvidersMoveUp()));
|
||||||
|
connect(ui_->providers_down, SIGNAL(clicked()), SLOT(ProvidersMoveDown()));
|
||||||
|
connect(ui_->providers, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), SLOT(CurrentItemChanged(QListWidgetItem*, QListWidgetItem*)));
|
||||||
|
connect(ui_->providers, SIGNAL(itemSelectionChanged()), SLOT(ItemSelectionChanged()));
|
||||||
|
connect(ui_->providers, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(ItemChanged(QListWidgetItem*)));
|
||||||
|
|
||||||
|
connect(ui_->button_authenticate, SIGNAL(clicked()), SLOT(AuthenticateClicked()));
|
||||||
|
connect(ui_->login_state, SIGNAL(LogoutClicked()), SLOT(LogoutClicked()));
|
||||||
|
|
||||||
|
NoProviderSelected();
|
||||||
|
DisableAuthentication();
|
||||||
|
|
||||||
|
dialog()->installEventFilter(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CoversSettingsPage::~CoversSettingsPage() { delete ui_; }
|
||||||
|
|
||||||
|
void CoversSettingsPage::Load() {
|
||||||
|
|
||||||
|
ui_->providers->clear();
|
||||||
|
|
||||||
|
QList<CoverProvider*> cover_providers_sorted = dialog()->app()->cover_providers()->List();
|
||||||
|
std::stable_sort(cover_providers_sorted.begin(), cover_providers_sorted.end(), ProviderCompareOrder);
|
||||||
|
|
||||||
|
for (CoverProvider *provider : cover_providers_sorted) {
|
||||||
|
QListWidgetItem *item = new QListWidgetItem(ui_->providers);
|
||||||
|
item->setText(provider->name());
|
||||||
|
item->setCheckState(provider->is_enabled() ? Qt::Checked : Qt::Unchecked);
|
||||||
|
item->setForeground(provider->is_enabled() ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::Save() {
|
||||||
|
|
||||||
|
QStringList providers;
|
||||||
|
for (int i = 0 ; i < ui_->providers->count() ; ++i) {
|
||||||
|
const QListWidgetItem *item = ui_->providers->item(i);
|
||||||
|
if (item->checkState() == Qt::Checked) providers << item->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
qLog(Debug) << providers;
|
||||||
|
|
||||||
|
QSettings s;
|
||||||
|
s.beginGroup(kSettingsGroup);
|
||||||
|
s.setValue("providers", providers);
|
||||||
|
s.endGroup();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::CurrentItemChanged(QListWidgetItem *item_current, QListWidgetItem *item_previous) {
|
||||||
|
|
||||||
|
if (item_previous) {
|
||||||
|
CoverProvider *provider = dialog()->app()->cover_providers()->ProviderByName(item_previous->text());
|
||||||
|
if (provider && provider->AuthenticationRequired()) DisconnectAuthentication(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item_current) {
|
||||||
|
const int row = ui_->providers->row(item_current);
|
||||||
|
ui_->providers_up->setEnabled(row != 0);
|
||||||
|
ui_->providers_down->setEnabled(row != ui_->providers->count() - 1);
|
||||||
|
CoverProvider *provider = dialog()->app()->cover_providers()->ProviderByName(item_current->text());
|
||||||
|
if (provider && provider->AuthenticationRequired()) {
|
||||||
|
if (provider->name() == "Tidal" && !provider->IsAuthenticated()) {
|
||||||
|
DisableAuthentication();
|
||||||
|
ui_->label_auth_info->setText(tr("Use Tidal settings to authenticate."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui_->login_state->SetLoggedIn(provider->IsAuthenticated() ? LoginStateWidget::LoggedIn : LoginStateWidget::LoggedOut);
|
||||||
|
ui_->button_authenticate->setEnabled(true);
|
||||||
|
ui_->button_authenticate->show();
|
||||||
|
ui_->login_state->show();
|
||||||
|
ui_->label_auth_info->setText(tr("%1 needs authentication.").arg(provider->name()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DisableAuthentication();
|
||||||
|
ui_->label_auth_info->setText(tr("%1 does not need authentication.").arg(provider->name()));
|
||||||
|
}
|
||||||
|
provider_selected_ = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DisableAuthentication();
|
||||||
|
NoProviderSelected();
|
||||||
|
ui_->providers_up->setEnabled(false);
|
||||||
|
ui_->providers_down->setEnabled(false);
|
||||||
|
provider_selected_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::ItemSelectionChanged() {
|
||||||
|
|
||||||
|
if (ui_->providers->selectedItems().count() == 0) {
|
||||||
|
DisableAuthentication();
|
||||||
|
NoProviderSelected();
|
||||||
|
ui_->providers_up->setEnabled(false);
|
||||||
|
ui_->providers_down->setEnabled(false);
|
||||||
|
provider_selected_ = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (ui_->providers->currentItem() && !provider_selected_) {
|
||||||
|
CurrentItemChanged(ui_->providers->currentItem(), nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::ProvidersMoveUp() { ProvidersMove(-1); }
|
||||||
|
|
||||||
|
void CoversSettingsPage::ProvidersMoveDown() { ProvidersMove(+1); }
|
||||||
|
|
||||||
|
void CoversSettingsPage::ProvidersMove(const int d) {
|
||||||
|
|
||||||
|
const int row = ui_->providers->currentRow();
|
||||||
|
QListWidgetItem *item = ui_->providers->takeItem(row);
|
||||||
|
ui_->providers->insertItem(row + d, item);
|
||||||
|
ui_->providers->setCurrentRow(row + d);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::ItemChanged(QListWidgetItem *item) {
|
||||||
|
|
||||||
|
item->setForeground((item->checkState() == Qt::Checked) ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::NoProviderSelected() {
|
||||||
|
ui_->label_auth_info->setText(tr("No provider selected."));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::DisableAuthentication() {
|
||||||
|
|
||||||
|
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedOut);
|
||||||
|
ui_->button_authenticate->setEnabled(false);
|
||||||
|
ui_->login_state->hide();
|
||||||
|
ui_->button_authenticate->hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::DisconnectAuthentication(CoverProvider *provider) {
|
||||||
|
|
||||||
|
disconnect(provider, SIGNAL(AuthenticationFailure(QStringList)), this, SLOT(AuthenticationFailure(QStringList)));
|
||||||
|
disconnect(provider, SIGNAL(AuthenticationSuccess()), this, SLOT(AuthenticationSuccess()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::AuthenticateClicked() {
|
||||||
|
|
||||||
|
if (!ui_->providers->currentItem()) return;
|
||||||
|
CoverProvider *provider = dialog()->app()->cover_providers()->ProviderByName(ui_->providers->currentItem()->text());
|
||||||
|
if (!provider) return;
|
||||||
|
ui_->button_authenticate->setEnabled(false);
|
||||||
|
connect(provider, SIGNAL(AuthenticationFailure(QStringList)), this, SLOT(AuthenticationFailure(QStringList)));
|
||||||
|
connect(provider, SIGNAL(AuthenticationSuccess()), this, SLOT(AuthenticationSuccess()));
|
||||||
|
provider->Authenticate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::LogoutClicked() {
|
||||||
|
|
||||||
|
if (!ui_->providers->currentItem()) return;
|
||||||
|
CoverProvider *provider = dialog()->app()->cover_providers()->ProviderByName(ui_->providers->currentItem()->text());
|
||||||
|
if (!provider) return;
|
||||||
|
provider->Deauthenticate();
|
||||||
|
|
||||||
|
if (provider->name() == "Tidal") {
|
||||||
|
DisableAuthentication();
|
||||||
|
ui_->label_auth_info->setText(tr("Use Tidal settings to authenticate."));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui_->button_authenticate->setEnabled(true);
|
||||||
|
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::AuthenticationSuccess() {
|
||||||
|
|
||||||
|
CoverProvider *provider = qobject_cast<CoverProvider*>(sender());
|
||||||
|
if (!provider) return;
|
||||||
|
DisconnectAuthentication(provider);
|
||||||
|
|
||||||
|
if (!this->isVisible() || !ui_->providers->currentItem() || ui_->providers->currentItem()->text() != provider->name()) return;
|
||||||
|
|
||||||
|
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn);
|
||||||
|
ui_->button_authenticate->setEnabled(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CoversSettingsPage::AuthenticationFailure(const QStringList &errors) {
|
||||||
|
|
||||||
|
CoverProvider *provider = qobject_cast<CoverProvider*>(sender());
|
||||||
|
if (!provider) return;
|
||||||
|
DisconnectAuthentication(provider);
|
||||||
|
|
||||||
|
if (!this->isVisible() || !ui_->providers->currentItem() || ui_->providers->currentItem()->text() != provider->name()) return;
|
||||||
|
|
||||||
|
QMessageBox::warning(this, tr("Authentication failed"), errors.join("\n"));
|
||||||
|
|
||||||
|
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedOut);
|
||||||
|
ui_->button_authenticate->setEnabled(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CoversSettingsPage::ProviderCompareOrder(CoverProvider *a, CoverProvider *b) {
|
||||||
|
return a->order() < b->order();
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2020, 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 COVERSSETTINGSPAGE_H
|
||||||
|
#define COVERSSETTINGSPAGE_H
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include "settings/settingspage.h"
|
||||||
|
|
||||||
|
class QListWidgetItem;
|
||||||
|
|
||||||
|
class CoverProvider;
|
||||||
|
class SettingsDialog;
|
||||||
|
class Ui_CoversSettingsPage;
|
||||||
|
|
||||||
|
class CoversSettingsPage : public SettingsPage {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CoversSettingsPage(SettingsDialog *parent = nullptr);
|
||||||
|
~CoversSettingsPage();
|
||||||
|
|
||||||
|
static const char *kSettingsGroup;
|
||||||
|
|
||||||
|
void Load();
|
||||||
|
void Save();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void NoProviderSelected();
|
||||||
|
void ProvidersMove(const int d);
|
||||||
|
void DisableAuthentication();
|
||||||
|
void DisconnectAuthentication(CoverProvider *provider);
|
||||||
|
static bool ProviderCompareOrder(CoverProvider *a, CoverProvider *b);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void CurrentItemChanged(QListWidgetItem *item_current, QListWidgetItem *item_previous);
|
||||||
|
void ItemSelectionChanged();
|
||||||
|
void ItemChanged(QListWidgetItem *item);
|
||||||
|
void ProvidersMoveUp();
|
||||||
|
void ProvidersMoveDown();
|
||||||
|
void AuthenticateClicked();
|
||||||
|
void LogoutClicked();
|
||||||
|
void AuthenticationSuccess();
|
||||||
|
void AuthenticationFailure(const QStringList &errors);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui_CoversSettingsPage *ui_;
|
||||||
|
bool provider_selected_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COVERSSETTINGSPAGE_H
|
|
@ -0,0 +1,166 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CoversSettingsPage</class>
|
||||||
|
<widget class="QWidget" name="CoversSettingsPage">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>460</width>
|
||||||
|
<height>600</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Covers</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="layout_tidalsettingspage">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupbox_providers">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Cover providers</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_enabled">
|
||||||
|
<property name="text">
|
||||||
|
<string>Choose the providers you want to use when searching for covers.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="layout_providers">
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="providers"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="layout_providers_updown">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="providers_up">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Move up</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="providers_down">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Move down</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="spacer_providers_updown">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="authentication">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Authentication</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_auth_info">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="LoginStateWidget" name="login_state" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="layout_button_authenticate">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="button_authenticate">
|
||||||
|
<property name="text">
|
||||||
|
<string>Authenticate</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="spacer_button_authenticate">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="spacer_bottom">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>30</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>LoginStateWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>widgets/loginstatewidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources>
|
||||||
|
<include location="../../data/data.qrc"/>
|
||||||
|
<include location="../../data/icons.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -61,6 +61,7 @@
|
||||||
#include "backendsettingspage.h"
|
#include "backendsettingspage.h"
|
||||||
#include "playlistsettingspage.h"
|
#include "playlistsettingspage.h"
|
||||||
#include "scrobblersettingspage.h"
|
#include "scrobblersettingspage.h"
|
||||||
|
#include "coverssettingspage.h"
|
||||||
#include "lyricssettingspage.h"
|
#include "lyricssettingspage.h"
|
||||||
#include "transcodersettingspage.h"
|
#include "transcodersettingspage.h"
|
||||||
#include "networkproxysettingspage.h"
|
#include "networkproxysettingspage.h"
|
||||||
|
@ -131,6 +132,7 @@ SettingsDialog::SettingsDialog(Application *app, QMainWindow *mainwindow, QWidge
|
||||||
AddPage(Page_Backend, new BackendSettingsPage(this), general);
|
AddPage(Page_Backend, new BackendSettingsPage(this), general);
|
||||||
AddPage(Page_Playlist, new PlaylistSettingsPage(this), general);
|
AddPage(Page_Playlist, new PlaylistSettingsPage(this), general);
|
||||||
AddPage(Page_Scrobbler, new ScrobblerSettingsPage(this), general);
|
AddPage(Page_Scrobbler, new ScrobblerSettingsPage(this), general);
|
||||||
|
AddPage(Page_Covers, new CoversSettingsPage(this), general);
|
||||||
AddPage(Page_Lyrics, new LyricsSettingsPage(this), general);
|
AddPage(Page_Lyrics, new LyricsSettingsPage(this), general);
|
||||||
#ifdef HAVE_GSTREAMER
|
#ifdef HAVE_GSTREAMER
|
||||||
AddPage(Page_Transcoding, new TranscoderSettingsPage(this), general);
|
AddPage(Page_Transcoding, new TranscoderSettingsPage(this), general);
|
||||||
|
|
|
@ -79,6 +79,7 @@ class SettingsDialog : public QDialog {
|
||||||
Page_Playback,
|
Page_Playback,
|
||||||
Page_Playlist,
|
Page_Playlist,
|
||||||
Page_Scrobbler,
|
Page_Scrobbler,
|
||||||
|
Page_Covers,
|
||||||
Page_Lyrics,
|
Page_Lyrics,
|
||||||
Page_Transcoding,
|
Page_Transcoding,
|
||||||
Page_Proxy,
|
Page_Proxy,
|
||||||
|
|
Loading…
Reference in New Issue