2010-10-10 20:57:23 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-10-10 20:57:23 +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 TAGWIDGET_H
|
|
|
|
#define TAGWIDGET_H
|
|
|
|
|
2010-10-16 17:22:14 +02:00
|
|
|
#include "playlist/playlistitem.h"
|
2010-12-04 17:19:30 +01:00
|
|
|
#include "smartplaylists/generator_fwd.h"
|
2010-10-16 17:22:14 +02:00
|
|
|
|
2010-10-10 20:57:23 +02:00
|
|
|
#include <QIcon>
|
|
|
|
#include <QWidget>
|
|
|
|
|
2010-12-04 17:19:30 +01:00
|
|
|
class QMenu;
|
2010-10-10 20:57:23 +02:00
|
|
|
class QPropertyAnimation;
|
|
|
|
|
|
|
|
class TagWidgetTag : public QWidget {
|
|
|
|
Q_OBJECT
|
2014-02-07 16:34:20 +01:00
|
|
|
Q_PROPERTY(float background_opacity READ background_opacity WRITE
|
2019-11-10 00:30:18 +01:00
|
|
|
set_background_opacity)
|
2010-10-10 20:57:23 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2010-10-10 20:57:23 +02:00
|
|
|
TagWidgetTag(const QIcon& icon, const QString& text, QWidget* parent);
|
|
|
|
|
|
|
|
static const int kIconSize;
|
|
|
|
static const int kIconTextSpacing;
|
2010-10-10 21:25:53 +02:00
|
|
|
static const int kHPadding;
|
|
|
|
static const int kVPadding;
|
2010-10-10 20:57:23 +02:00
|
|
|
|
|
|
|
float background_opacity() const { return opacity_; }
|
|
|
|
void set_background_opacity(float opacity);
|
|
|
|
|
|
|
|
QSize sizeHint() const;
|
2010-10-16 17:22:14 +02:00
|
|
|
QString text() const { return text_; }
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void Clicked();
|
2010-10-10 20:57:23 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
2010-10-10 20:57:23 +02:00
|
|
|
void enterEvent(QEvent*);
|
|
|
|
void leaveEvent(QEvent*);
|
|
|
|
void paintEvent(QPaintEvent*);
|
2010-10-16 17:22:14 +02:00
|
|
|
void mouseReleaseEvent(QMouseEvent*);
|
2010-12-04 17:19:30 +01:00
|
|
|
void contextMenuEvent(QContextMenuEvent*);
|
2010-10-10 20:57:23 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-10-10 20:57:23 +02:00
|
|
|
QString text_;
|
|
|
|
QIcon icon_;
|
|
|
|
float opacity_;
|
|
|
|
|
|
|
|
QPropertyAnimation* animation_;
|
|
|
|
};
|
|
|
|
|
|
|
|
class TagWidget : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
|
|
|
enum Type { Type_Tags, Type_Artists, };
|
2010-12-04 17:19:30 +01:00
|
|
|
|
2014-02-10 16:03:54 +01:00
|
|
|
TagWidget(Type type, QWidget* parent = nullptr);
|
2010-10-10 20:57:23 +02:00
|
|
|
|
|
|
|
void SetIcon(const QIcon& icon) { icon_ = icon; }
|
|
|
|
void AddTag(const QString& tag);
|
|
|
|
|
2010-10-10 23:45:01 +02:00
|
|
|
int count() const { return tags_.count(); }
|
|
|
|
|
2010-10-16 17:22:14 +02:00
|
|
|
signals:
|
2011-01-10 23:26:13 +01:00
|
|
|
void AddToPlaylist(QMimeData* data);
|
2011-11-11 22:35:25 +01:00
|
|
|
void DoGlobalSearch(const QString& query);
|
2010-10-16 17:22:14 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2010-10-16 17:22:14 +02:00
|
|
|
void TagClicked();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-12-04 17:19:30 +01:00
|
|
|
void PlayLastFm(const QString& url_pattern);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-12-04 17:19:30 +01:00
|
|
|
Type type_;
|
2010-10-10 20:57:23 +02:00
|
|
|
QIcon icon_;
|
2010-10-10 23:45:01 +02:00
|
|
|
QList<TagWidgetTag*> tags_;
|
2010-10-10 20:57:23 +02:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // TAGWIDGET_H
|