Includes, comments and bugfixes

- Fix includes
- Use common regex (Song::kCoverRemoveDisc) for removing Disc/CD from album
- Remove Disc/CD from album when creating hash
- Make imobiledevice support compile
- Fix setting device on windows
This commit is contained in:
Jonas Kvinge
2018-05-01 00:41:33 +02:00
parent fccbd6790c
commit e337b7933b
518 changed files with 7003 additions and 4693 deletions

View File

@@ -20,33 +20,43 @@
#include "config.h"
#include <QAction>
#include <QDesktopWidget>
#include <QtGlobal>
#include <QWidget>
#include <QDialog>
#include <QDragEnterEvent>
#include <QFileDialog>
#include <QImageWriter>
#include <QLabel>
#include <QDir>
#include <QFileInfo>
#include <QList>
#include <QMenu>
#include <QUrl>
#include <QSet>
#include <QMimeData>
#include <QByteArray>
#include <QVariant>
#include <QString>
#include <QStringBuilder>
#include <QRegExp>
#include <QUrl>
#include <QImage>
#include <QImageWriter>
#include <QPixmap>
#include <QIcon>
#include <QRect>
#include <QAction>
#include <QFileDialog>
#include <QLabel>
#include <QDesktopWidget>
#include <QtEvents>
#include "covermanager/albumcoverchoicecontroller.h"
#include "core/application.h"
#include "core/logging.h"
#include "core/utilities.h"
#include "core/song.h"
#include "core/iconloader.h"
#include "collection/collectionbackend.h"
#include "core/application.h"
#include "covermanager/albumcoverfetcher.h"
#include "covermanager/albumcoverloader.h"
#include "covermanager/currentartloader.h"
#include "covermanager/albumcovermanager.h"
#include "covermanager/albumcoversearcher.h"
#include "covermanager/coverfromurldialog.h"
#include "collection/collectionbackend.h"
#include "albumcoverchoicecontroller.h"
#include "albumcoverfetcher.h"
#include "albumcoverloader.h"
#include "albumcoversearcher.h"
#include "coverfromurldialog.h"
#include "currentartloader.h"
const char *AlbumCoverChoiceController::kLoadImageFileFilter = QT_TR_NOOP("Images (*.png *.jpg *.jpeg *.bmp *.gif *.xpm *.pbm *.pgm *.ppm *.xbm)");
const char *AlbumCoverChoiceController::kSaveImageFileFilter = QT_TR_NOOP("Images (*.png *.jpg *.jpeg *.bmp *.xpm *.pbm *.ppm *.xbm)");
@@ -134,18 +144,16 @@ void AlbumCoverChoiceController::SaveCoverToFile(const Song &song, const QImage
QString AlbumCoverChoiceController::GetInitialPathForFileDialog(const Song &song, const QString &filename) {
// art automatic is first to show user which cover the album may be
// using now; the song is using it if there's no manual path but we
// cannot use manual path here because it can contain cached paths
// Art automatic is first to show user which cover the album may be using now;
// The song is using it if there's no manual path but we cannot use manual path here because it can contain cached paths
if (!song.art_automatic().isEmpty() && !song.has_embedded_cover()) {
return song.art_automatic();
// if no automatic art, start in the song's folder
// If no automatic art, start in the song's folder
}
else if (!song.url().isEmpty() && song.url().toLocalFile().contains('/')) {
return song.url().toLocalFile().section('/', 0, -2) + filename;
// fallback - start in home
// Fallback - start in home
}
else {
return QDir::home().absolutePath() + filename;
@@ -172,7 +180,7 @@ QString AlbumCoverChoiceController::LoadCoverFromURL(Song *song) {
QString AlbumCoverChoiceController::SearchForCover(Song *song) {
QString album = song->effective_album();
album = album.remove(QRegExp(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$"));
album.remove(Song::kCoverRemoveDisc);
// Get something sensible to stick in the search box
QImage image = cover_searcher_->Exec(song->effective_albumartist(), album);
@@ -208,16 +216,16 @@ void AlbumCoverChoiceController::ShowCover(const Song &song) {
QLabel *label = new QLabel(dialog);
label->setPixmap(AlbumCoverLoader::TryLoadPixmap(song.art_automatic(), song.art_manual(), song.url().toLocalFile()));
// add (WxHpx) to the title before possibly resizing
// Add (WxHpx) to the title before possibly resizing
title_text += " (" + QString::number(label->pixmap()->width()) + "x" + QString::number(label->pixmap()->height()) + "px)";
// if the cover is larger than the screen, resize the window 85% seems to be enough to account for title bar and taskbar etc.
// If the cover is larger than the screen, resize the window 85% seems to be enough to account for title bar and taskbar etc.
QDesktopWidget desktop;
int current_screen = desktop.screenNumber(this);
int desktop_height = desktop.screenGeometry(current_screen).height();
int desktop_width = desktop.screenGeometry(current_screen).width();
// resize differently if monitor is in portrait mode
// Resize differently if monitor is in portrait mode
if (desktop_width < desktop_height) {
const int new_width = (double)desktop_width * 0.95;
if (new_width < label->pixmap()->width()) {
@@ -276,8 +284,11 @@ void AlbumCoverChoiceController::SaveCover(Song *song, const QString &cover) {
QString AlbumCoverChoiceController::SaveCoverInCache(const QString &artist, const QString &album, const QImage &image) {
QString album2(album);
album2.remove(Song::kCoverRemoveDisc);
// Hash the artist and album into a filename for the image
QString filename(Utilities::Sha1CoverHash(artist, album).toHex() + ".jpg");
QString filename(Utilities::Sha1CoverHash(artist, album2).toHex() + ".jpg");
QString path(AlbumCoverLoader::ImageCacheDir() + "/" + filename);
// Make sure this directory exists first

View File

@@ -23,18 +23,25 @@
#include "config.h"
#include <QAction>
#include <QList>
#include <QMenu>
#include <QWidget>
#include <stdbool.h>
#include <QtGlobal>
#include <QObject>
#include <QWidget>
#include <QList>
#include <QMap>
#include <QSet>
#include <QString>
#include <QImage>
#include <QAction>
#include <QFileDialog>
#include <QtEvents>
class Song;
class Application;
class AlbumCoverFetcher;
class AlbumCoverSearcher;
class Application;
class CoverFromURLDialog;
class QFileDialog;
class Song;
struct CoverSearchStatistics;
// Controller for the common album cover related menu options.
@@ -70,23 +77,19 @@ class AlbumCoverChoiceController : public QWidget {
// 5. showing the cover in original size
QList<QAction*> GetAllActions();
// All of the methods below require a currently selected song as an
// input parameter. Also - LoadCoverFromFile, LoadCoverFromURL,
// SearchForCover, UnsetCover and SaveCover all update manual path
// of the given song in collection to the new cover.
// All of the methods below require a currently selected song as an input parameter.
// Also - LoadCoverFromFile, LoadCoverFromURL, SearchForCover, UnsetCover and SaveCover all update manual path of the given song in collection to the new cover.
// Lets the user choose a cover from disk. If no cover will be chosen or the chosen
// cover will not be a proper image, this returns an empty string. Otherwise, the
// path to the chosen cover will be returned.
// Lets the user choose a cover from disk. If no cover will be chosen or the chosen cover will not be a proper image, this returns an empty string.
// Otherwise, the path to the chosen cover will be returned.
QString LoadCoverFromFile(Song *song);
// Shows a dialog that allows user to save the given image on disk. The image
// is supposed to be the cover of the given song's album.
// Shows a dialog that allows user to save the given image on disk.
// The image is supposed to be the cover of the given song's album.
void SaveCoverToFile(const Song &song, const QImage &image);
// Downloads the cover from an URL given by user. This returns the downloaded image
// or null image if something went wrong for example when user cancelled the
// dialog.
// Downloads the cover from an URL given by user.
// This returns the downloaded image or null image if something went wrong for example when user cancelled the dialog.
QString LoadCoverFromURL(Song *song);
// Lets the user choose a cover among all that have been found on last.fm.
@@ -108,8 +111,7 @@ class AlbumCoverChoiceController : public QWidget {
// Saves the cover that the user picked through a drag and drop operation.
QString SaveCover(Song *song, const QDropEvent *e);
// Saves the given image in cache as a cover for 'artist' - 'album'.
// The method returns path of the cached image.
// Saves the given image in cache as a cover for 'artist' - 'album'. The method returns path of the cached image.
QString SaveCoverInCache(const QString &artist, const QString &album, const QImage &image);
static bool CanAcceptDrag(const QDragEnterEvent *e);

View File

@@ -20,11 +20,18 @@
#include "config.h"
#include <QWidget>
#include <QDialog>
#include <QVariant>
#include <QString>
#include <QSettings>
#include <QLineEdit>
#include <QCheckBox>
#include <QRadioButton>
#include "albumcoverexport.h"
#include "ui_albumcoverexport.h"
#include <QSettings>
const char *AlbumCoverExport::kSettingsGroup = "AlbumCoverExport";
AlbumCoverExport::AlbumCoverExport(QWidget *parent) : QDialog(parent), ui_(new Ui_AlbumCoverExport) {
@@ -42,7 +49,7 @@ AlbumCoverExport::DialogResult AlbumCoverExport::Exec() {
QSettings s;
s.beginGroup(kSettingsGroup);
// restore last accepted settings
// Restore last accepted settings
ui_->fileName->setText(s.value("fileName", "cover").toString());
ui_->doNotOverwrite->setChecked(s.value("overwrite", OverwriteMode_None).toInt() == OverwriteMode_None);
ui_->overwriteAll->setChecked(s.value("overwrite", OverwriteMode_All).toInt() == OverwriteMode_All);

View File

@@ -23,7 +23,12 @@
#include "config.h"
#include <stdbool.h>
#include <QObject>
#include <QWidget>
#include <QDialog>
#include <QString>
class Ui_AlbumCoverExport;

View File

@@ -20,12 +20,12 @@
#include "config.h"
#include <QFile>
#include <QObject>
#include <QThreadPool>
#include "core/song.h"
#include "albumcoverexporter.h"
#include "coverexportrunnable.h"
#include "core/song.h"
const int AlbumCoverExporter::kMaxConcurrentRequests = 3;

View File

@@ -23,15 +23,15 @@
#include "config.h"
#include "coverexportrunnable.h"
#include "core/song.h"
#include "covermanager/albumcoverexport.h"
#include <QObject>
#include <QThreadPool>
#include <QQueue>
#include <QTimer>
#include <QString>
class QThreadPool;
#include "albumcoverexport.h"
class Song;
class CoverExportRunnable;
class AlbumCoverExporter : public QObject {
Q_OBJECT

View File

@@ -20,14 +20,18 @@
#include "config.h"
#include <QtGlobal>
#include <QObject>
#include <QTimer>
#include <QString>
#include <QRegExp>
#include <QDebug>
#include <QImage>
#include <QNetworkAccessManager>
#include "core/network.h"
#include "core/song.h"
#include "albumcoverfetcher.h"
#include "albumcoverfetchersearch.h"
#include "core/network.h"
#include "core/logging.h"
const int AlbumCoverFetcher::kMaxConcurrentRequests = 5;
@@ -43,12 +47,10 @@ AlbumCoverFetcher::AlbumCoverFetcher(CoverProviders *cover_providers, QObject *p
quint64 AlbumCoverFetcher::FetchAlbumCover(const QString &artist, const QString &album, bool fetchall) {
QString album2(album);
album2 = album2.remove(QRegExp(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$"));
CoverSearchRequest request;
request.artist = artist;
request.album = album2;
request.album = album;
request.album.remove(Song::kCoverRemoveDisc);
request.search = false;
request.id = next_id_++;
request.fetchall = fetchall;
@@ -60,12 +62,10 @@ quint64 AlbumCoverFetcher::FetchAlbumCover(const QString &artist, const QString
quint64 AlbumCoverFetcher::SearchForCovers(const QString &artist, const QString &album) {
QString album2(album);
album2 = album2.remove(QRegExp(" ?-? ((\\(|\\[)?)(Disc|CD) ?([0-9]{1,2})((\\)|\\])?)$"));
CoverSearchRequest request;
request.artist = artist;
request.album = album2;
request.album = album;
request.album.remove(Song::kCoverRemoveDisc);
request.search = true;
request.id = next_id_++;
request.fetchall = false;
@@ -108,7 +108,7 @@ void AlbumCoverFetcher::StartRequests() {
CoverSearchRequest request = queued_requests_.dequeue();
// search objects are this fetcher's children so worst case scenario - they get deleted with it
// Search objects are this fetcher's children so worst case scenario - they get deleted with it
AlbumCoverFetcherSearch *search = new AlbumCoverFetcherSearch(request, network_, this);
active_requests_.insert(request.id, search);

View File

@@ -23,60 +23,61 @@
#include "config.h"
#include "coversearchstatistics.h"
#include <stdbool.h>
#include <QHash>
#include <QImage>
#include <QList>
#include <QMetaType>
#include <QNetworkAccessManager>
#include <QtGlobal>
#include <QObject>
#include <QQueue>
#include <QTimer>
#include <QMetaType>
#include <QHash>
#include <QList>
#include <QSet>
#include <QString>
#include <QUrl>
#include <QImage>
#include <QVector>
#include <QNetworkAccessManager>
class QNetworkReply;
class QString;
class AlbumCoverFetcherSearch;
class CoverProviders;
class AlbumCoverFetcherSearch;
struct CoverSearchStatistics;
// This class represents a single search-for-cover request. It identifies and describes the request.
struct CoverSearchRequest {
// an unique (for one AlbumCoverFetcher) request identifier
// An unique (for one AlbumCoverFetcher) request identifier
quint64 id;
// a search query
// A search query
QString artist;
QString album;
// is this only a search request or should we also fetch the first cover that's found?
// Is this only a search request or should we also fetch the first cover that's found?
bool search;
// is the request part of fetchall (fetching all missing covers)
// Is the request part of fetchall (fetching all missing covers)
bool fetchall;
};
// This structure represents a single result of some album's cover search request.
// It contains an URL that leads to a found cover plus its description (usually the "artist - album" string).
struct CoverSearchResult {
// used for grouping in the user interface. This is set automatically - don't set it manually in your cover provider.
// Used for grouping in the user interface. This is set automatically - don't set it manually in your cover provider.
QString provider;
// description of this result (we suggest using the "artist - album" format)
// Description of this result (we suggest using the "artist - album" format)
QString description;
// an URL of a cover image described by this CoverSearchResult
// An URL of a cover image described by this CoverSearchResult
QUrl image_url;
};
Q_DECLARE_METATYPE(CoverSearchResult);
// This is a complete result of a single search request (a list of results, each
// describing one image, actually).
// This is a complete result of a single search request (a list of results, each describing one image, actually).
typedef QList<CoverSearchResult> CoverSearchResults;
Q_DECLARE_METATYPE(QList<CoverSearchResult>);
// This class searches for album covers for a given query or artist/album and
// returns URLs. It's NOT thread-safe.
// This class searches for album covers for a given query or artist/album and returns URLs. It's NOT thread-safe.
class AlbumCoverFetcher : public QObject {
Q_OBJECT

View File

@@ -20,21 +20,28 @@
#include "config.h"
#include "albumcoverfetchersearch.h"
#include <algorithm>
#include <cmath>
#include <QMutexLocker>
#include <QNetworkReply>
#include <QObject>
#include <QtAlgorithms>
#include <QTimer>
#include <QList>
#include <QString>
#include <QUrl>
#include <QImage>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QtDebug>
#include "albumcoverfetcher.h"
#include "coverprovider.h"
#include "coverproviders.h"
#include "core/closure.h"
#include "core/logging.h"
#include "core/network.h"
#include "albumcoverfetcher.h"
#include "albumcoverfetchersearch.h"
#include "coverprovider.h"
#include "coverproviders.h"
const int AlbumCoverFetcherSearch::kSearchTimeoutMs = 12000;
const int AlbumCoverFetcherSearch::kImageLoadTimeoutMs = 3000;
@@ -84,7 +91,7 @@ void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) {
}
}
// end this search before it even began if there are no providers...
// End this search before it even began if there are no providers...
if (pending_requests_.isEmpty()) {
TerminateSearch();
}
@@ -111,7 +118,7 @@ void AlbumCoverFetcherSearch::ProviderSearchFinished(int id, const QList<CoverSe
results_.append(results_copy);
statistics_.total_images_by_provider_[provider->name()]++;
// do we have more providers left?
// Do we have more providers left?
if (!pending_requests_.isEmpty()) {
return;
}
@@ -125,13 +132,13 @@ void AlbumCoverFetcherSearch::AllProvidersFinished() {
return;
}
// if we only wanted to do the search then we're done
// If we only wanted to do the search then we're done
if (request_.search) {
emit SearchFinished(request_.id, results_);
return;
}
// no results?
// No results?
if (results_.isEmpty()) {
statistics_.missing_images_++;
emit AlbumCoverFetched(request_.id, QImage());
@@ -139,10 +146,8 @@ void AlbumCoverFetcherSearch::AllProvidersFinished() {
}
// Now we have to load some images and figure out which one is the best.
// We'll sort the list of results by category, then load the first few images
// from each category and use some heuristics to score them. If no images
// are good enough we'll keep loading more images until we find one that is
// or we run out of results.
// We'll sort the list of results by category, then load the first few images from each category and use some heuristics to score them.
// If no images are good enough we'll keep loading more images until we find one that is or we run out of results.
qStableSort(results_.begin(), results_.end(), CompareProviders);
FetchMoreImages();
@@ -205,8 +210,7 @@ void AlbumCoverFetcherSearch::ProviderCoverFetchFinished(RedirectFollower *reply
}
if (pending_image_loads_.isEmpty()) {
// We've fetched everything we wanted to fetch for now, check if we have an
// image that's good enough.
// We've fetched everything we wanted to fetch for now, check if we have an image that's good enough.
float best_score = 0.0;
if (!candidate_images_.isEmpty()) {

View File

@@ -23,21 +23,28 @@
#include "config.h"
#include "albumcoverfetcher.h"
#include <stdbool.h>
#include <QMap>
#include <QtGlobal>
#include <QObject>
#include <QList>
#include <QMap>
#include <QPair>
#include <QString>
#include <QImage>
#include <QNetworkAccessManager>
#include "albumcoverfetcher.h"
#include "coversearchstatistics.h"
class CoverProvider;
class CoverProviders;
class NetworkTimeouts;
class NetworkAccessManager;
class RedirectFollower;
// This class encapsulates a single search for covers initiated by an
// AlbumCoverFetcher. The search engages all of the known cover providers.
// AlbumCoverFetcherSearch signals search results to an interested
// AlbumCoverFetcher when all of the providers have done their part.
// This class encapsulates a single search for covers initiated by an AlbumCoverFetcher.
// The search engages all of the known cover providers.
// AlbumCoverFetcherSearch signals search results to an interested AlbumCoverFetcher when all of the providers have done their part.
class AlbumCoverFetcherSearch : public QObject {
Q_OBJECT
@@ -46,8 +53,7 @@ class AlbumCoverFetcherSearch : public QObject {
void Start(CoverProviders *cover_providers);
// Cancels all pending requests. No Finished signals will be emitted, and it
// is the caller's responsibility to delete the AlbumCoverFetcherSearch.
// Cancels all pending requests. No Finished signals will be emitted, and it is the caller's responsibility to delete the AlbumCoverFetcherSearch.
void Cancel();
CoverSearchStatistics statistics() const { return statistics_; }

View File

@@ -20,24 +20,30 @@
#include "config.h"
#include "albumcoverloader.h"
#include <QCoreApplication>
#include <QtGlobal>
#include <QObject>
#include <QQueue>
#include <QMutex>
#include <QStandardPaths>
#include <QSize>
#include <QList>
#include <QSet>
#include <QVariant>
#include <QString>
#include <QDir>
#include <QStringBuilder>
#include <QUrl>
#include <QNetworkReply>
#include <QImage>
#include <QPixmap>
#include <QPainter>
#include <QMutexLocker>
#include <QNetworkReply>
#include <QNetworkRequest>
#include "config.h"
#include "core/closure.h"
#include "core/logging.h"
#include "core/network.h"
#include "core/song.h"
#include "core/tagreaderclient.h"
#include "albumcoverloader.h"
#include "albumcoverloaderoptions.h"
AlbumCoverLoader::AlbumCoverLoader(QObject *parent)
: QObject(parent),
@@ -171,7 +177,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(const Task &task)
if (filename.toLower().startsWith("http://") || filename.toLower().startsWith("https://")) {
QUrl url(filename);
QNetworkReply* reply = network_->get(QNetworkRequest(url));
QNetworkReply *reply = network_->get(QNetworkRequest(url));
NewClosure(reply, SIGNAL(finished()), this, SLOT(RemoteFetchFinished(QNetworkReply*)), reply);
remote_tasks_.insert(reply, task);
@@ -201,7 +207,7 @@ void AlbumCoverLoader::RemoteFetchFinished(QNetworkReply *reply) {
}
QNetworkRequest request = reply->request();
request.setUrl(redirect.toUrl());
QNetworkReply* redirected_reply = network_->get(request);
QNetworkReply *redirected_reply = network_->get(request);
NewClosure(redirected_reply, SIGNAL(finished()), this, SLOT(RemoteFetchFinished(QNetworkReply*)), redirected_reply);
remote_tasks_.insert(redirected_reply, task);

View File

@@ -23,17 +23,24 @@
#include "config.h"
#include "albumcoverloaderoptions.h"
#include "core/song.h"
#include <stdbool.h>
#include <QImage>
#include <QMutex>
#include <QtGlobal>
#include <QObject>
#include <QMutex>
#include <QQueue>
#include <QUrl>
#include <QMap>
#include <QSet>
#include <QString>
#include <QImage>
#include <QPixmap>
#include <QNetworkReply>
#include "core/song.h"
#include "albumcoverloaderoptions.h"
class Song;
class NetworkAccessManager;
class QNetworkReply;
class AlbumCoverLoader : public QObject {
Q_OBJECT
@@ -60,7 +67,7 @@ signals:
protected slots:
void ProcessTasks();
void RemoteFetchFinished(QNetworkReply* reply);
void RemoteFetchFinished(QNetworkReply *reply);
protected:
enum State {
@@ -90,8 +97,8 @@ signals:
QImage image;
};
void ProcessTask(Task* task);
void NextState(Task* task);
void ProcessTask(Task *task);
void NextState(Task *task);
TryLoadResult TryLoadImage(const Task &task);
bool stop_requested_;

View File

@@ -1,2 +1 @@
#include "config.h"
#include "albumcoverloaderoptions.h"

View File

@@ -23,6 +23,7 @@
#include "config.h"
#include <stdbool.h>
#include <QImage>
struct AlbumCoverLoaderOptions {

View File

@@ -15,47 +15,71 @@
*
* 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 <memory>
#include <QtGlobal>
#include <QObject>
#include <QMainWindow>
#include <QWidget>
#include <QModelIndex>
#include <QItemSelectionModel>
#include <QListWidgetItem>
#include <QAction>
#include <QActionGroup>
#include <QPushButton>
#include <QContextMenuEvent>
#include <QEvent>
#include <QFileDialog>
#include <QKeySequence>
#include <QFile>
#include <QMenu>
#include <QSet>
#include <QTimer>
#include <QVariant>
#include <QString>
#include <QStringBuilder>
#include <QStringList>
#include <QUrl>
#include <QImage>
#include <QPixmap>
#include <QPainter>
#include <QNetworkAccessManager>
#include <QShortcut>
#include <QSplitter>
#include <QStatusBar>
#include <QLabel>
#include <QListWidget>
#include <QMenu>
#include <QMessageBox>
#include <QPainter>
#include <QProgressBar>
#include <QPushButton>
#include <QToolButton>
#include <QKeySequence>
#include <QtAlgorithms>
#include <QtEvents>
#include <QSettings>
#include <QShortcut>
#include <QTimer>
#include "albumcovermanager.h"
#include "albumcoversearcher.h"
#include "ui_albumcovermanager.h"
#include "core/application.h"
#include "core/logging.h"
#include "core/utilities.h"
#include "core/iconloader.h"
#include "covermanager/albumcoverexporter.h"
#include "covermanager/albumcoverfetcher.h"
#include "covermanager/albumcoverloader.h"
#include "covermanager/coverproviders.h"
#include "covermanager/coversearchstatisticsdialog.h"
#include "core/utilities.h"
#include "widgets/forcescrollperpixel.h"
#include "3rdparty/qocoa/qsearchfield.h"
#include "collection/sqlrow.h"
#include "collection/collectionbackend.h"
#include "collection/collectionquery.h"
#include "collection/sqlrow.h"
#include "playlist/songmimedata.h"
#include "widgets/forcescrollperpixel.h"
#include "covermanager/albumcoverchoicecontroller.h"
#include "covermanager/albumcoverexport.h"
#include "coverproviders.h"
#include "albumcovermanager.h"
#include "albumcoversearcher.h"
#include "albumcoverchoicecontroller.h"
#include "albumcoverexport.h"
#include "albumcoverexporter.h"
#include "albumcoverfetcher.h"
#include "albumcoverloader.h"
#include "albumcovermanagerlist.h"
#include "coversearchstatistics.h"
#include "coversearchstatisticsdialog.h"
#include "ui_albumcovermanager.h"
const char *AlbumCoverManager::kSettingsGroup = "CoverManager";
@@ -255,7 +279,7 @@ static bool CompareAlbumNameNocase(const CollectionBackend::Album &left, const C
}
void AlbumCoverManager::Reset() {
EnableCoversButtons();
ui_->artists->clear();
@@ -598,7 +622,7 @@ void AlbumCoverManager::SaveCoverToFile() {
QImage image;
// load the image from disk
// Load the image from disk
if (song.has_manually_unset_cover()) {
image = no_cover_image_;
}
@@ -643,9 +667,9 @@ void AlbumCoverManager::SearchForCover() {
QString cover = album_cover_choice_controller_->SearchForCover(&song);
if (cover.isEmpty()) return;
// force the found cover on all of the selected items
// Force the found cover on all of the selected items
for (QListWidgetItem *current : context_menu_items_) {
// don't save the first one twice
// Don't save the first one twice
if (current != item) {
Song current_song = ItemAsSong(current);
album_cover_choice_controller_->SaveCover(&current_song, cover);
@@ -665,12 +689,12 @@ void AlbumCoverManager::UnsetCover() {
QString cover = album_cover_choice_controller_->UnsetCover(&song);
// force the 'none' cover on all of the selected items
// Force the 'none' cover on all of the selected items
for (QListWidgetItem *current : context_menu_items_) {
current->setIcon(no_cover_item_icon_);
current->setData(Role_PathManual, cover);
// don't save the first one twice
// Don't save the first one twice
if (current != item) {
Song current_song = ItemAsSong(current);
album_cover_choice_controller_->SaveCover(&current_song, cover);
@@ -824,7 +848,7 @@ void AlbumCoverManager::UpdateExportStatus(int exported, int skipped, int max) {
.arg(skipped);
statusBar()->showMessage(message);
// end of the current process
// End of the current process
if (exported + skipped >= max) {
QTimer::singleShot(2000, statusBar(), SLOT(clearMessage()));
@@ -865,7 +889,7 @@ QImage AlbumCoverManager::GenerateNoCoverImage(const QIcon &no_cover_icon) const
}
bool AlbumCoverManager::ItemHasCover(const QListWidgetItem& item) const {
bool AlbumCoverManager::ItemHasCover(const QListWidgetItem &item) const {
return item.icon().cacheKey() != no_cover_item_icon_.cacheKey();
}

View File

@@ -23,29 +23,41 @@
#include "config.h"
#include <stdbool.h>
#include <QtGlobal>
#include <QObject>
#include <QWidget>
#include <QMainWindow>
#include <QAbstractItemModel>
#include <QNetworkAccessManager>
#include <QList>
#include <QListWidgetItem>
#include <QMap>
#include <QString>
#include <QImage>
#include <QIcon>
#include <QModelIndex>
#include <QAction>
#include <QMenu>
#include <QMimeData>
#include <QProgressBar>
#include <QPushButton>
#include <QtEvents>
#include "core/song.h"
#include "covermanager/albumcoverloaderoptions.h"
#include "covermanager/coversearchstatistics.h"
#include "albumcoverloaderoptions.h"
#include "coversearchstatistics.h"
class Application;
class CollectionBackend;
class SongMimeData;
class AlbumCoverChoiceController;
class AlbumCoverExport;
class AlbumCoverExporter;
class AlbumCoverFetcher;
class AlbumCoverSearcher;
class Application;
class CollectionBackend;
class SongMimeData;
class Ui_CoverManager;
class QListWidgetItem;
class QMenu;
class QNetworkAccessManager;
class QPushButton;
class QProgressBar;
class Ui_CoverManager;
class AlbumCoverManager : public QMainWindow {
Q_OBJECT
@@ -130,13 +142,9 @@ class AlbumCoverManager : public QMainWindow {
QString InitialPathForOpenCoverDialog(const QString &path_automatic, const QString &first_file_name) const;
QString EffectiveAlbumArtistName(const QListWidgetItem &item) const;
// Returns the selected element in form of a Song ready to be used
// by AlbumCoverChoiceController or invalid song if there's nothing
// or multiple elements selected.
// Returns the selected element in form of a Song ready to be used by AlbumCoverChoiceController or invalid song if there's nothing or multiple elements selected.
Song GetSingleSelectionAsSong();
// Returns the first of the selected elements in form of a Song ready
// to be used by AlbumCoverChoiceController or invalid song if there's nothing
// selected.
// Returns the first of the selected elements in form of a Song ready to be used by AlbumCoverChoiceController or invalid song if there's nothing selected.
Song GetFirstSelectedAsSong();
Song ItemAsSong(QListWidgetItem *item);

View File

@@ -20,16 +20,22 @@
#include "config.h"
#include "albumcovermanagerlist.h"
#include <memory>
#include <QDropEvent>
#include <QWidget>
#include <QList>
#include <QListView>
#include <QListWidget>
#include <QListWidgetItem>
#include <QMimeData>
#include <QUrl>
#include <QDropEvent>
#include "albumcovermanager.h"
#include "core/song.h"
#include "collection/collectionbackend.h"
#include "playlist/songmimedata.h"
#include "albumcovermanager.h"
#include "albumcovermanagerlist.h"
AlbumCoverManagerList::AlbumCoverManagerList(QWidget *parent) : QListWidget(parent), manager_(nullptr) {}
@@ -62,9 +68,8 @@ QMimeData *AlbumCoverManagerList::mimeData(const QList<QListWidgetItem*> items)
void AlbumCoverManagerList::dropEvent(QDropEvent *e) {
// Set movement to Static just for this dropEvent so the user can't move the
// album covers. If it's set to Static all the time then the user can't even
// drag to the playlist
// Set movement to Static just for this dropEvent so the user can't move the album covers.
// If it's set to Static all the time then the user can't even drag to the playlist
QListWidget::Movement old_movement = movement();
setMovement(QListWidget::Static);
QListWidget::dropEvent(e);

View File

@@ -23,7 +23,14 @@
#include "config.h"
#include <QObject>
#include <QWidget>
#include <QList>
#include <QListWidget>
#include <QListWidgetItem>
#include <QString>
#include <QMimeData>
#include <QDropEvent>
class AlbumCoverManager;
@@ -32,7 +39,7 @@ class AlbumCoverManagerList : public QListWidget {
public:
AlbumCoverManagerList(QWidget *parent = nullptr);
void set_cover_manager(AlbumCoverManager* manager) { manager_ = manager; }
void set_cover_manager(AlbumCoverManager *manager) { manager_ = manager; }
protected:
QMimeData *mimeData(const QList<QListWidgetItem*> items) const;

View File

@@ -20,20 +20,43 @@
#include "config.h"
#include "albumcoversearcher.h"
#include "ui_albumcoversearcher.h"
#include <stdbool.h>
#include <QWidget>
#include <QDialog>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QAbstractItemModel>
#include <QStyledItemDelegate>
#include <QStyleOptionViewItem>
#include <QSize>
#include <QList>
#include <QVariant>
#include <QString>
#include <QUrl>
#include <QImage>
#include <QPixmap>
#include <QPainter>
#include <QIcon>
#include <QFont>
#include <QFontMetrics>
#include <QColor>
#include <QRect>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QKeySequence>
#include <QtEvents>
#include "core/application.h"
#include "core/logging.h"
#include "core/utilities.h"
#include "covermanager/albumcoverfetcher.h"
#include "covermanager/albumcoverloader.h"
#include "widgets/busyindicator.h"
#include "widgets/forcescrollperpixel.h"
#include "widgets/groupediconview.h"
#include <QKeyEvent>
#include <QListWidgetItem>
#include <QPainter>
#include <QStandardItemModel>
#include "3rdparty/qocoa/qsearchfield.h"
#include "albumcoversearcher.h"
#include "albumcoverfetcher.h"
#include "albumcoverloader.h"
#include "ui_albumcoversearcher.h"
const int SizeOverlayDelegate::kMargin = 4;
const int SizeOverlayDelegate::kPaddingX = 3;

View File

@@ -23,20 +23,29 @@
#include "config.h"
#include <QtGlobal>
#include <QObject>
#include <QWidget>
#include <QDialog>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QMap>
#include <QString>
#include <QImage>
#include <QIcon>
#include <QPainter>
#include <QStyleOption>
#include <QStyledItemDelegate>
#include <QStyleOptionViewItem>
#include <QtEvents>
#include "covermanager/albumcoverfetcher.h"
#include "covermanager/albumcoverloaderoptions.h"
class AlbumCoverLoader;
class Application;
class Ui_AlbumCoverSearcher;
#include "albumcoverfetcher.h"
#include "albumcoverloaderoptions.h"
class QModelIndex;
class QStandardItem;
class QStandardItemModel;
class Application;
class Ui_AlbumCoverSearcher;
class SizeOverlayDelegate : public QStyledItemDelegate {
public:

View File

@@ -21,19 +21,30 @@
#include "config.h"
#include <QtGlobal>
#include <QObject>
#include <QByteArray>
#include <QDateTime>
#include <QNetworkReply>
#include <QList>
#include <QPair>
#include <QSet>
#include <QString>
#include <QStringBuilder>
#include <QStringList>
#include <QXmlStreamReader>
#include <QUrl>
#include <QUrlQuery>
#include "amazoncoverprovider.h"
#include <QVector>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QXmlStreamReader>
#include <QtDebug>
#include "core/closure.h"
#include "core/logging.h"
#include "core/network.h"
#include "core/utilities.h"
#include "coverprovider.h"
#include "amazoncoverprovider.h"
const char *AmazonCoverProvider::kUrl = "http://ecs.amazonaws.com/onca/xml";
const char *AmazonCoverProvider::kAssociateTag = "jonas052-20";
@@ -54,7 +65,6 @@ bool AmazonCoverProvider::StartSearch(const QString &artist, const QString &albu
// Must be sorted by parameter name
ArgList args = ArgList()
<< Arg("AWSAccessKeyId", QByteArray::fromBase64(kAccessKeyB64))
//<< Arg("AWSAccessKeyId", kAccessKey)
<< Arg("AssociateTag", kAssociateTag)
<< Arg("Keywords", artist + " " + album)
<< Arg("Operation", "ItemSearch")
@@ -78,7 +88,6 @@ bool AmazonCoverProvider::StartSearch(const QString &artist, const QString &albu
// Sign the request
const QByteArray data_to_sign = QString("GET\n%1\n%2\n%3").arg(url.host(), url.path(), query_items.join("&")).toUtf8();
//const QByteArray signature(Utilities::HmacSha256(kSecretAccessKey, data_to_sign));
const QByteArray signature(Utilities::HmacSha256(QByteArray::fromBase64(kSecretAccessKeyB64), data_to_sign));
// Add the signature to the request
@@ -92,24 +101,17 @@ bool AmazonCoverProvider::StartSearch(const QString &artist, const QString &albu
NewClosure(reply, SIGNAL(finished()), this, SLOT(QueryFinished(QNetworkReply*, int)), reply, id);
return true;
}
void AmazonCoverProvider::QueryError(QNetworkReply::NetworkError error, QNetworkReply *reply, int id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
}
void AmazonCoverProvider::QueryFinished(QNetworkReply *reply, int id) {
//qLog(Debug) << __PRETTY_FUNCTION__;
reply->deleteLater();
QString data=(QString)reply->readAll();
//qDebug() << data;
CoverSearchResults results;
@@ -129,8 +131,6 @@ void AmazonCoverProvider::QueryFinished(QNetworkReply *reply, int id) {
void AmazonCoverProvider::ReadItem(QXmlStreamReader *reader, CoverSearchResults *results) {
//qLog(Debug) << __PRETTY_FUNCTION__ << "name: " << reader->name() << " text: " << reader->text();
while (!reader->atEnd()) {
switch (reader->readNext()) {
case QXmlStreamReader::StartElement:
@@ -153,8 +153,6 @@ void AmazonCoverProvider::ReadItem(QXmlStreamReader *reader, CoverSearchResults
void AmazonCoverProvider::ReadLargeImage(QXmlStreamReader *reader, CoverSearchResults *results) {
//qLog(Debug) << __PRETTY_FUNCTION__;
while (!reader->atEnd()) {
switch (reader->readNext()) {
case QXmlStreamReader::StartElement:

View File

@@ -24,12 +24,16 @@
#include "config.h"
#include <QXmlStreamReader>
#include <stdbool.h>
#include <QObject>
#include <QString>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QXmlStreamReader>
#include "coverprovider.h"
class QNetworkAccessManager;
#include "albumcoverfetcher.h"
class AmazonCoverProvider : public CoverProvider {
Q_OBJECT

View File

@@ -21,12 +21,14 @@
#include "config.h"
#include <QFile>
#include <QSize>
#include <QString>
#include <QStringBuilder>
#include <QUrl>
#include <QImage>
#include "albumcoverexporter.h"
#include "core/song.h"
#include "core/tagreaderclient.h"
#include "coverexportrunnable.h"
CoverExportRunnable::CoverExportRunnable(const AlbumCoverExport::DialogResult &dialog_result, const Song &song)
@@ -36,7 +38,7 @@ void CoverExportRunnable::run() {
QString cover_path = GetCoverPath();
// manually unset?
// Manually unset?
if (cover_path.isEmpty()) {
EmitCoverSkipped();
}
@@ -69,9 +71,7 @@ QString CoverExportRunnable::GetCoverPath() {
}
// Exports a single album cover using a "save QImage to file" approach.
// For performance reasons this method will be invoked only if loading
// and in memory processing of images is necessary for current settings
// which means that:
// For performance reasons this method will be invoked only if loading and in memory processing of images is necessary for current settings which means that:
// - either the force size flag is being used
// - or the "overwrite smaller" mode is used
// In all other cases, the faster ExportCover() method will be used.
@@ -123,12 +123,10 @@ void CoverExportRunnable::ProcessAndExportCover() {
return;
}
// we're handling overwrite as remove + copy so we need to delete the old file
// first
// we're handling overwrite as remove + copy so we need to delete the old file first
if (QFile::exists(new_file) && dialog_result_.overwrite_ != AlbumCoverExport::OverwriteMode_None) {
// if the mode is "overwrite smaller" then skip the cover if a bigger one
// is already available in the folder
// if the mode is "overwrite smaller" then skip the cover if a bigger one is already available in the folder
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode_Smaller) {
QImage existing;
existing.load(new_file);

View File

@@ -25,9 +25,10 @@
#include <QObject>
#include <QRunnable>
#include <QString>
#include "core/song.h"
#include "covermanager/albumcoverexport.h"
#include "albumcoverexport.h"
class AlbumCoverExporter;

View File

@@ -20,23 +20,27 @@
#include "config.h"
#include <QWidget>
#include <QDialog>
#include <QApplication>
#include <QClipboard>
#include <QImage>
#include <QLineEdit>
#include <QMessageBox>
#include <QNetworkReply>
#include <QNetworkRequest>
#include "coverfromurldialog.h"
#include "ui_coverfromurldialog.h"
#include <QUrl>
#include "core/network.h"
#include "covermanager/albumcoverloader.h"
#include "widgets/busyindicator.h"
#include "coverfromurldialog.h"
#include "ui_coverfromurldialog.h"
CoverFromURLDialog::CoverFromURLDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_CoverFromURLDialog), network_(new NetworkAccessManager(this)) {
ui_->setupUi(this);
ui_->busy->hide();
}
CoverFromURLDialog::~CoverFromURLDialog() {
@@ -44,6 +48,7 @@ CoverFromURLDialog::~CoverFromURLDialog() {
}
QImage CoverFromURLDialog::Exec() {
// reset state
ui_->url->setText("");;
last_image_ = QImage();
@@ -53,6 +58,7 @@ QImage CoverFromURLDialog::Exec() {
exec();
return last_image_;
}
void CoverFromURLDialog::accept() {
@@ -63,6 +69,7 @@ void CoverFromURLDialog::accept() {
QNetworkReply *reply = network_->get(network_request);
connect(reply, SIGNAL(finished()), SLOT(LoadCoverFromURLFinished()));
}
void CoverFromURLDialog::LoadCoverFromURLFinished() {
@@ -87,5 +94,6 @@ void CoverFromURLDialog::LoadCoverFromURLFinished() {
else {
QMessageBox::information(this, tr("Fetching cover error"), tr("The site you requested is not an image!"));
}
}

View File

@@ -23,11 +23,13 @@
#include "config.h"
#include <QObject>
#include <QWidget>
#include <QDialog>
#include <QString>
#include <QImage>
class NetworkAccessManager;
class Song;
class Ui_CoverFromURLDialog;
// Controller for a dialog which fetches covers from the given URL.
@@ -38,8 +40,7 @@ class CoverFromURLDialog : public QDialog {
CoverFromURLDialog(QWidget *parent = nullptr);
~CoverFromURLDialog();
// Opens the dialog. This returns an image found at the URL chosen by user
// or null image if the dialog got rejected.
// Opens the dialog. This returns an image found at the URL chosen by user or null image if the dialog got rejected.
QImage Exec();
private slots:

View File

@@ -20,6 +20,9 @@
#include "config.h"
#include <QObject>
#include <QString>
#include "coverprovider.h"
CoverProvider::CoverProvider(const QString &name, const bool &fetchall, QObject *parent)

View File

@@ -23,18 +23,16 @@
#include "config.h"
#include <QObject>
#include "albumcoverfetcher.h"
#include "coverproviders.h"
#include <stdbool.h>
#include <QObject>
#include <QList>
#include <QString>
class QNetworkReply;
struct CoverSearchResult;
// Each implementation of this interface downloads covers from one online
// service. There are no limitations on what this service might be - last.fm,
// Amazon, Google Images - you name it.
// Each implementation of this interface downloads covers from one online service.
// There are no limitations on what this service might be - last.fm, Amazon, Google Images - you name it.
class CoverProvider : public QObject {
Q_OBJECT
@@ -45,9 +43,9 @@ public:
QString name() const { return name_; }
bool fetchall() const { return fetchall_; }
// Starts searching for covers matching the given query text. 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.
// Starts searching for covers matching the given query text.
// 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.
virtual bool StartSearch(const QString &artist, const QString &album, int id) = 0;
virtual void CancelSearch(int id) {}

View File

@@ -20,10 +20,14 @@
#include "config.h"
#include "coverprovider.h"
#include "coverproviders.h"
#include <QObject>
#include <QMutex>
#include <QString>
#include <QtDebug>
#include "core/logging.h"
#include "coverprovider.h"
#include "coverproviders.h"
CoverProviders::CoverProviders(QObject *parent) : QObject(parent) {}
@@ -43,8 +47,7 @@ void CoverProviders::RemoveProvider(CoverProvider *provider) {
if (!provider) return;
// It's not safe to dereference provider at this pointbecause it might have
// already been destroyed.
// It's not safe to dereference provider at this pointbecause it might have already been destroyed.
QString name;

View File

@@ -23,11 +23,16 @@
#include "config.h"
#include <QMap>
#include <QMutex>
#include <QObject>
#include <stdbool.h>
#include <QtGlobal>
#include <QObject>
#include <QMutex>
#include <QList>
#include <QMap>
#include <QString>
#include <QAtomicInt>
class AlbumCoverFetcherSearch;
class CoverProvider;
// This is a repository for cover providers.

View File

@@ -20,6 +20,9 @@
#include "config.h"
#include <QtGlobal>
#include <QString>
#include "coversearchstatistics.h"
CoverSearchStatistics::CoverSearchStatistics()
@@ -35,10 +38,10 @@ CoverSearchStatistics &CoverSearchStatistics::operator +=(const CoverSearchStati
network_requests_made_ += other.network_requests_made_;
bytes_transferred_ += other.bytes_transferred_;
for (const QString& key : other.chosen_images_by_provider_.keys()) {
for (const QString &key : other.chosen_images_by_provider_.keys()) {
chosen_images_by_provider_[key] += other.chosen_images_by_provider_[key];
}
for (const QString& key : other.total_images_by_provider_.keys()) {
for (const QString &key : other.total_images_by_provider_.keys()) {
total_images_by_provider_[key] += other.total_images_by_provider_[key];
}

View File

@@ -23,6 +23,7 @@
#include "config.h"
#include <QtGlobal>
#include <QMap>
#include <QString>

View File

@@ -20,8 +20,18 @@
#include "config.h"
#include "coversearchstatisticsdialog.h"
#include <QWidget>
#include <QMap>
#include <QString>
#include <QStringList>
#include <QBoxLayout>
#include <QLabel>
#include <QFrame>
#include <QtAlgorithms>
#include "core/utilities.h"
#include "coversearchstatistics.h"
#include "coversearchstatisticsdialog.h"
#include "ui_coversearchstatisticsdialog.h"
CoverSearchStatisticsDialog::CoverSearchStatisticsDialog(QWidget *parent)
@@ -94,4 +104,3 @@ void CoverSearchStatisticsDialog::AddLine(const QString &label, const QString &v
void CoverSearchStatisticsDialog::AddSpacer() {
details_layout_->addSpacing(20);
}

View File

@@ -23,13 +23,14 @@
#include "config.h"
#include <QObject>
#include <QDialog>
#include "coversearchstatistics.h"
#include <QWidget>
#include <QString>
#include <QBoxLayout>
class Ui_CoverSearchStatisticsDialog;
class QVBoxLayout;
struct CoverSearchStatistics;
class CoverSearchStatisticsDialog : public QDialog {
Q_OBJECT

View File

@@ -20,15 +20,20 @@
#include "config.h"
#include <QDir>
#include <QTemporaryFile>
#include <QUrl>
#include <stdbool.h>
#include <QtGlobal>
#include <QObject>
#include <QDir>
#include <QString>
#include <QStringBuilder>
#include <QImage>
#include <QTemporaryFile>
#include "currentartloader.h"
#include "core/application.h"
#include "core/iconloader.h"
#include "covermanager/albumcoverloader.h"
#include "playlist/playlistmanager.h"
#include "albumcoverloader.h"
#include "currentartloader.h"
CurrentArtLoader::CurrentArtLoader(Application *app, QObject *parent)
: QObject(parent),
@@ -69,8 +74,7 @@ void CurrentArtLoader::TempArtLoaded(quint64 id, const QImage &image) {
temp_art_->open();
image.save(temp_art_->fileName(), "JPEG");
// Scale the image down to make a thumbnail. It's a bit crap doing it here
// since it's the GUI thread, but the alternative is hard.
// Scale the image down to make a thumbnail. It's a bit crap doing it here since it's the GUI thread, but the alternative is hard.
temp_art_thumbnail_.reset(new QTemporaryFile(temp_file_pattern_));
temp_art_thumbnail_->open();
temp_art_thumbnail_->setAutoRemove(true);

View File

@@ -25,16 +25,17 @@
#include <memory>
#include <QtGlobal>
#include <QObject>
#include <QString>
#include <QImage>
#include <QTemporaryFile>
#include "core/song.h"
#include "covermanager/albumcoverloaderoptions.h"
#include "albumcoverloaderoptions.h"
class Application;
class QImage;
class QTemporaryFile;
class CurrentArtLoader : public QObject {
Q_OBJECT

View File

@@ -21,24 +21,32 @@
#include "config.h"
#include <QObject>
#include <QByteArray>
#include <QVariant>
#include <QPair>
#include <QList>
#include <QPair>
#include <QMap>
#include <QSet>
#include <QVariant>
#include <QString>
#include <QStringBuilder>
#include <QStringList>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QUrl>
#include <QUrlQuery>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonObject>
#include "discogscoverprovider.h"
#include <QVector>
#include "core/closure.h"
#include "core/logging.h"
#include "core/network.h"
#include "core/utilities.h"
#include "coverprovider.h"
#include "albumcoverfetcher.h"
#include "discogscoverprovider.h"
const char *DiscogsCoverProvider::kUrlSearch = "https://api.discogs.com/database/search";
const char *DiscogsCoverProvider::kUrlReleases = "https://api.discogs.com/releases";

View File

@@ -24,20 +24,25 @@
#include "config.h"
#include <QXmlStreamReader>
#include <stdbool.h>
#include <QObject>
#include <QHash>
#include <QMetaType>
#include <QString>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "coverprovider.h"
class QNetworkAccessManager;
#include "albumcoverfetcher.h"
// This struct represents a single search-for-cover request. It identifies and describes the request.
struct DiscogsCoverSearchContext {
// the unique request identifier
// The unique request identifier
int id;
// the search query
// The search query
QString artist;
QString album;
QString title;
@@ -47,12 +52,11 @@ struct DiscogsCoverSearchContext {
};
Q_DECLARE_METATYPE(DiscogsCoverSearchContext)
// This struct represents a single release request. It identifies and describes
// the request.
// This struct represents a single release request. It identifies and describes the request.
struct DiscogsCoverReleaseContext {
int id; // the unique request identifier
int s_id; // the search request identifier
int id; // The unique request identifier
int s_id; // The search request identifier
QString resource_url;
};

View File

@@ -20,8 +20,13 @@
#include "config.h"
#include <lastfm5/ws.h>
#include <QByteArray>
#include <QList>
#include <QNetworkReply>
#include "lastfmcompat.h"
#include "core/logging.h"
namespace lastfm {
namespace compat {

View File

@@ -23,16 +23,22 @@
#include "config.h"
#include <stdbool.h>
#include <QByteArray>
#include <QList>
#include <QNetworkReply>
#ifdef HAVE_LIBLASTFM1
#include <lastfm5/misc.h>
#include <lastfm5/User.h>
#include <lastfm5/ws.h>
#include <lastfm5/XmlQuery.h>
# include <lastfm5/User.h>
# include <lastfm5/XmlQuery.h>
# include <lastfm5/misc.h>
# include <lastfm5/ws.h>
#else
#include <lastfm5/misc.h>
#include <lastfm5/User>
#include <lastfm5/ws.h>
#include <lastfm5/XmlQuery>
# include <lastfm5/misc.h>
# include <lastfm5/ws.h>
# include <lastfm5/User>
# include <lastfm5/XmlQuery>
#endif
namespace lastfm {

View File

@@ -18,29 +18,22 @@
*
*/
/*
Application name Strawberry Music Player
API key 211990b4c96782c05d1536e7219eb56e
Shared secret 80fd738f49596e9709b1bf9319c444a8
Registered to jonaskvinge
*/
#include "config.h"
#include <QObject>
#include <QByteArray>
#include <QList>
#include <QString>
#include <QStringBuilder>
#include <QUrl>
#include <QNetworkReply>
#include <QtDebug>
#include "lastfmcoverprovider.h"
#include "lastfmcompat.h"
#include "coverprovider.h"
#include "albumcoverfetcher.h"
#include "core/closure.h"
#include "core/network.h"
#include "core/logging.h"
#include "coverprovider.h"
#include "albumcoverfetcher.h"
#include "lastfmcompat.h"
#include "lastfmcoverprovider.h"
const char *LastFmCoverProvider::kApiKey = "211990b4c96782c05d1536e7219eb56e";
const char *LastFmCoverProvider::kSecret = "80fd738f49596e9709b1bf9319c444a8";

View File

@@ -23,18 +23,16 @@
#include "config.h"
#include <QMap>
#include <QObject>
#include <stdbool.h>
#include <QObject>
#include <QMap>
#include <QString>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "albumcoverfetcher.h"
#include "coverprovider.h"
#include <QMap>
#include <QObject>
class QNetworkAccessManager;
class QNetworkReply;
// A built-in cover provider which fetches covers from last.fm.
class LastFmCoverProvider : public CoverProvider {
Q_OBJECT

View File

@@ -23,13 +23,21 @@
#include <algorithm>
#include <functional>
#include <QXmlStreamReader>
#include <QObject>
#include <QList>
#include <QVariant>
#include <QString>
#include <QUrl>
#include <QUrlQuery>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QXmlStreamReader>
#include "core/closure.h"
#include "core/network.h"
#include "core/logging.h"
#include "albumcoverfetcher.h"
#include "coverprovider.h"
#include "musicbrainzcoverprovider.h"
using std::mem_fun;

View File

@@ -23,13 +23,17 @@
#include "config.h"
#include <stdbool.h>
#include <QObject>
#include <QMap>
#include <QMultiMap>
#include <QString>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include "coverprovider.h"
class QNetworkAccessManager;
class QNetworkReply;
class MusicbrainzCoverProvider : public CoverProvider {
Q_OBJECT
public: