2010-06-12 19:13:01 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-06-12 19:13:01 +02:00
|
|
|
|
|
|
|
Clementine 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.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ALBUMCOVERSEARCHER_H
|
|
|
|
#define ALBUMCOVERSEARCHER_H
|
|
|
|
|
|
|
|
#include <QDialog>
|
2010-12-20 16:46:38 +01:00
|
|
|
#include <QIcon>
|
2011-07-26 14:02:59 +02:00
|
|
|
#include <QStyledItemDelegate>
|
2010-06-12 19:13:01 +02:00
|
|
|
|
2014-02-06 14:48:00 +01:00
|
|
|
#include "covers/albumcoverfetcher.h"
|
|
|
|
#include "covers/albumcoverloaderoptions.h"
|
2010-06-12 19:13:01 +02:00
|
|
|
|
|
|
|
class AlbumCoverLoader;
|
2012-02-12 14:41:50 +01:00
|
|
|
class Application;
|
2010-06-12 19:13:01 +02:00
|
|
|
class Ui_AlbumCoverSearcher;
|
|
|
|
|
|
|
|
class QModelIndex;
|
2011-06-20 01:15:29 +02:00
|
|
|
class QStandardItem;
|
|
|
|
class QStandardItemModel;
|
|
|
|
|
2011-07-26 14:02:59 +02:00
|
|
|
class SizeOverlayDelegate : public QStyledItemDelegate {
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2011-07-26 14:02:59 +02:00
|
|
|
static const int kMargin;
|
|
|
|
static const int kPaddingX;
|
|
|
|
static const int kPaddingY;
|
|
|
|
static const qreal kBorder;
|
|
|
|
static const qreal kFontPointSize;
|
|
|
|
static const int kBorderAlpha;
|
|
|
|
static const int kBackgroundAlpha;
|
|
|
|
|
2014-02-21 17:24:49 +01:00
|
|
|
SizeOverlayDelegate(QObject* parent = nullptr);
|
2011-07-26 14:02:59 +02:00
|
|
|
|
|
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
|
|
|
const QModelIndex& index) const;
|
|
|
|
};
|
|
|
|
|
2010-12-26 21:19:12 +01:00
|
|
|
// This is a dialog that lets the user search for album covers
|
2010-06-12 19:13:01 +02:00
|
|
|
class AlbumCoverSearcher : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
|
|
|
AlbumCoverSearcher(const QIcon& no_cover_icon, Application* app,
|
|
|
|
QWidget* parent);
|
2010-06-12 19:13:01 +02:00
|
|
|
~AlbumCoverSearcher();
|
|
|
|
|
|
|
|
enum Role {
|
|
|
|
Role_ImageURL = Qt::UserRole + 1,
|
|
|
|
Role_ImageRequestId,
|
2011-06-20 01:15:29 +02:00
|
|
|
Role_ImageFetchFinished,
|
2014-02-07 16:34:20 +01:00
|
|
|
Role_ImageDimensions, // width * height
|
2011-07-26 14:02:59 +02:00
|
|
|
Role_ImageSize,
|
2010-06-12 19:13:01 +02:00
|
|
|
};
|
|
|
|
|
2010-12-26 21:19:12 +01:00
|
|
|
void Init(AlbumCoverFetcher* fetcher);
|
2010-06-12 19:13:01 +02:00
|
|
|
|
2011-06-22 21:07:15 +02:00
|
|
|
QImage Exec(const QString& artist, const QString& album);
|
2010-06-12 19:13:01 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
|
|
|
void keyPressEvent(QKeyEvent*);
|
2010-06-12 19:13:01 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2010-06-12 19:13:01 +02:00
|
|
|
void Search();
|
2011-04-02 15:34:06 +02:00
|
|
|
void SearchFinished(quint64 id, const CoverSearchResults& results);
|
2010-06-12 19:13:01 +02:00
|
|
|
void ImageLoaded(quint64 id, const QImage& image);
|
|
|
|
|
|
|
|
void CoverDoubleClicked(const QModelIndex& index);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-06-12 19:13:01 +02:00
|
|
|
Ui_AlbumCoverSearcher* ui_;
|
|
|
|
|
2012-02-12 14:41:50 +01:00
|
|
|
Application* app_;
|
2011-06-20 01:15:29 +02:00
|
|
|
QStandardItemModel* model_;
|
|
|
|
|
2010-12-20 16:46:38 +01:00
|
|
|
QIcon no_cover_icon_;
|
2012-02-13 21:44:04 +01:00
|
|
|
AlbumCoverLoaderOptions options_;
|
2010-06-12 19:13:01 +02:00
|
|
|
AlbumCoverFetcher* fetcher_;
|
|
|
|
|
|
|
|
quint64 id_;
|
2011-06-20 01:15:29 +02:00
|
|
|
QMap<quint64, QStandardItem*> cover_loading_tasks_;
|
2010-06-12 19:13:01 +02:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // ALBUMCOVERSEARCHER_H
|