@@ -27,18 +27,24 @@
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QPair>
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
#include <QImage>
|
||||
#include <QMutex>
|
||||
|
||||
#include "core/song.h"
|
||||
#include "settings/collectionsettingspage.h"
|
||||
#include "albumcoverimageresult.h"
|
||||
|
||||
class QFileDialog;
|
||||
class QAction;
|
||||
class QActionGroup;
|
||||
class QMenu;
|
||||
class QDragEnterEvent;
|
||||
class QDropEvent;
|
||||
|
||||
@@ -63,6 +69,9 @@ class AlbumCoverChoiceController : public QWidget {
|
||||
void Init(Application *app);
|
||||
void ReloadSettings();
|
||||
|
||||
CollectionSettingsPage::SaveCoverType get_save_album_cover_type() const { return (save_embedded_cover_override_ ? CollectionSettingsPage::SaveCoverType_Embedded : save_cover_type_); }
|
||||
void set_save_embedded_cover_override(const bool value) { save_embedded_cover_override_ = value; }
|
||||
|
||||
// Getters for all QActions implemented by this controller.
|
||||
|
||||
QAction *cover_from_file_action() const { return cover_from_file_; }
|
||||
@@ -70,6 +79,8 @@ class AlbumCoverChoiceController : public QWidget {
|
||||
QAction *cover_from_url_action() const { return cover_from_url_; }
|
||||
QAction *search_for_cover_action() const { return search_for_cover_; }
|
||||
QAction *unset_cover_action() const { return unset_cover_; }
|
||||
QAction *delete_cover_action() const { return delete_cover_; }
|
||||
QAction *clear_cover_action() const { return clear_cover_; }
|
||||
QAction *show_cover_action() const { return show_cover_; }
|
||||
QAction *search_cover_auto_action() const { return search_cover_auto_; }
|
||||
|
||||
@@ -87,40 +98,54 @@ class AlbumCoverChoiceController : public QWidget {
|
||||
|
||||
// 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.
|
||||
AlbumCoverImageResult LoadImageFromFile(Song *song);
|
||||
QUrl 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.
|
||||
void SaveCoverToFileManual(const Song &song, const QImage &image);
|
||||
void SaveCoverToFileManual(const Song &song, const AlbumCoverImageResult &result);
|
||||
|
||||
// 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.
|
||||
QUrl LoadCoverFromURL(Song *song);
|
||||
AlbumCoverImageResult LoadImageFromURL();
|
||||
|
||||
// Lets the user choose a cover among all that have been found on last.fm.
|
||||
// Returns the chosen cover or null cover if user didn't choose anything.
|
||||
QUrl SearchForCover(Song *song);
|
||||
AlbumCoverImageResult SearchForImage(Song *song);
|
||||
|
||||
// Returns a path which indicates that the cover has been unset manually.
|
||||
QUrl UnsetCover(Song *song);
|
||||
|
||||
// Clears any album cover art associated with the song.
|
||||
void ClearCover(Song *song);
|
||||
|
||||
// Physically deletes associated album covers from disk.
|
||||
bool DeleteCover(Song *song);
|
||||
|
||||
// Shows the cover of given song in it's original size.
|
||||
void ShowCover(const Song &song);
|
||||
void ShowCover(const Song &song, const QImage &image);
|
||||
void ShowCover(const Song &song, const QImage &image = QImage());
|
||||
void ShowCover(const Song &song, const QPixmap &pixmap);
|
||||
|
||||
// Search for covers automatically
|
||||
qint64 SearchCoverAutomatically(const Song &song);
|
||||
|
||||
// Saves the chosen cover as manual cover path of this song in collection.
|
||||
void SaveCoverToSong(Song *song, const QUrl &cover_url);
|
||||
void SaveArtAutomaticToSong(Song *song, const QUrl &art_automatic);
|
||||
void SaveArtManualToSong(Song *song, const QUrl &art_manual, const bool clear_art_automatic = false);
|
||||
|
||||
// Saves the cover that the user picked through a drag and drop operation.
|
||||
QUrl SaveCover(Song *song, const QDropEvent *e);
|
||||
|
||||
// Saves the given image in album directory or cache as a cover for 'album artist' - 'album'. The method returns path of the image.
|
||||
QUrl SaveCoverToFileAutomatic(const Song *song, const QUrl &cover_url, const QImage &image, const bool overwrite = false);
|
||||
QUrl SaveCoverToFileAutomatic(const Song::Source source, const QString &artist, const QString &album, const QString &album_id, const QString &album_dir, const QUrl &cover_url, const QImage &image, const bool overwrite = false);
|
||||
QUrl SaveCoverAutomatic(Song *song, const AlbumCoverImageResult &result);
|
||||
QUrl SaveCoverToFileAutomatic(const Song *song, const AlbumCoverImageResult &result, const bool force_overwrite = false);
|
||||
QUrl SaveCoverToFileAutomatic(const Song::Source source, const QString &artist, const QString &album, const QString &album_id, const QString &album_dir, const AlbumCoverImageResult &result, const bool force_overwrite = false);
|
||||
void SaveCoverEmbeddedAutomatic(const Song &song, const AlbumCoverImageResult &result);
|
||||
void SaveCoverEmbeddedAutomatic(const Song &song, const QUrl &cover_url);
|
||||
void SaveCoverEmbeddedAutomatic(const Song &song, const QString &cover_filename);
|
||||
void SaveCoverEmbeddedAutomatic(const QList<QUrl> urls, const QImage &image);
|
||||
|
||||
static bool CanAcceptDrag(const QDragEnterEvent *e);
|
||||
|
||||
@@ -128,9 +153,11 @@ class AlbumCoverChoiceController : public QWidget {
|
||||
void AutomaticCoverSearchDone();
|
||||
|
||||
private slots:
|
||||
void AlbumCoverFetched(const quint64 id, const QUrl &cover_url, const QImage &image, const CoverSearchStatistics &statistics);
|
||||
void AlbumCoverFetched(const quint64 id, const AlbumCoverImageResult &result, const CoverSearchStatistics &statistics);
|
||||
void SaveEmbeddedCoverAsyncFinished(quint64 id, const bool success);
|
||||
|
||||
private:
|
||||
|
||||
QString GetInitialPathForFileDialog(const Song &song, const QString &filename);
|
||||
|
||||
static bool IsKnownImageExtension(const QString &suffix);
|
||||
@@ -145,21 +172,27 @@ class AlbumCoverChoiceController : public QWidget {
|
||||
|
||||
QAction *cover_from_file_;
|
||||
QAction *cover_to_file_;
|
||||
QAction *separator_;
|
||||
QAction *cover_from_url_;
|
||||
QAction *search_for_cover_;
|
||||
QAction *separator1_;
|
||||
QAction *unset_cover_;
|
||||
QAction *delete_cover_;
|
||||
QAction *clear_cover_;
|
||||
QAction *separator2_;
|
||||
QAction *show_cover_;
|
||||
QAction *search_cover_auto_;
|
||||
|
||||
QMap<quint64, Song> cover_fetching_tasks_;
|
||||
QMap<qint64, Song> cover_save_tasks_;
|
||||
QMutex mutex_cover_save_tasks_;
|
||||
|
||||
bool cover_album_dir_;
|
||||
CollectionSettingsPage::SaveCover cover_filename_;
|
||||
CollectionSettingsPage::SaveCoverType save_cover_type_;
|
||||
CollectionSettingsPage::SaveCoverFilename save_cover_filename_;
|
||||
QString cover_pattern_;
|
||||
bool cover_overwrite_;
|
||||
bool cover_lowercase_;
|
||||
bool cover_replace_spaces_;
|
||||
bool save_embedded_cover_override_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user