2015-04-22 19:33:53 +02:00
|
|
|
#ifndef COVEREDIT_H
|
|
|
|
#define COVEREDIT_H
|
|
|
|
|
2015-09-06 20:20:00 +02:00
|
|
|
#include "./previousvaluehandling.h"
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
#include <tagparser/tag.h>
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2015-08-25 19:10:16 +02:00
|
|
|
QT_FORWARD_DECLARE_CLASS(QEvent)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QGraphicsScene)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QGraphicsTextItem)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QGraphicsPixmapItem)
|
|
|
|
QT_FORWARD_DECLARE_CLASS(QGraphicsRectItem)
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
class Tag;
|
|
|
|
class TagValue;
|
2016-07-11 21:34:05 +02:00
|
|
|
DECLARE_ENUM_CLASS(KnownField, unsigned int);
|
2015-04-22 19:33:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
2016-07-11 21:34:05 +02:00
|
|
|
DECLARE_ENUM_CLASS(PreviousValueHandling, int);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class PicturePreviewSelection;
|
|
|
|
}
|
|
|
|
|
|
|
|
class PicturePreviewSelection : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit PicturePreviewSelection(Media::Tag *tag = nullptr, Media::KnownField field = Media::KnownField::Invalid, QWidget *parent = nullptr);
|
2016-01-09 02:56:56 +01:00
|
|
|
~PicturePreviewSelection();
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
Media::Tag *tag() const;
|
|
|
|
Media::KnownField field() const;
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setTagField(Media::Tag *tag, Media::KnownField field, PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear);
|
2016-03-06 17:52:33 +01:00
|
|
|
void setValue(const Media::TagValue &value, PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
void apply();
|
|
|
|
void clear();
|
|
|
|
void addOfSelectedType();
|
2015-08-25 19:10:16 +02:00
|
|
|
void addOfSelectedType(const QString &path);
|
2015-04-22 19:33:53 +02:00
|
|
|
void removeSelected();
|
|
|
|
void extractSelected();
|
|
|
|
void displaySelected();
|
2016-05-16 21:01:01 +02:00
|
|
|
void changeMimeTypeOfSelected();
|
|
|
|
void setCoverButtonsHidden(bool hideCoverButtons);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void pictureChanged();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void changeEvent(QEvent *event);
|
|
|
|
void resizeEvent(QResizeEvent *event);
|
2015-08-25 19:10:16 +02:00
|
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
|
|
|
void dropEvent(QDropEvent *event);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void typeSwitched(int index);
|
|
|
|
void updateDescription(int newIndex);
|
|
|
|
void updateDescription(int lastIndex, int newIndex);
|
|
|
|
void updatePreview(int index);
|
2016-05-16 21:01:01 +02:00
|
|
|
void showContextMenu();
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void setup(PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear);
|
|
|
|
|
|
|
|
std::unique_ptr<Ui::PicturePreviewSelection> m_ui;
|
|
|
|
QGraphicsScene *m_scene;
|
|
|
|
QGraphicsTextItem *m_textItem;
|
|
|
|
QPixmap m_pixmap;
|
|
|
|
QGraphicsPixmapItem *m_pixmapItem;
|
|
|
|
QGraphicsRectItem *m_rectItem;
|
|
|
|
Media::Tag *m_tag;
|
|
|
|
Media::KnownField m_field;
|
|
|
|
QList<Media::TagValue> m_values;
|
2017-03-07 16:50:49 +01:00
|
|
|
int m_currentTypeIndex;
|
2015-04-22 19:33:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the tied tag if one is assigned; returns nullptr otherwise.
|
|
|
|
*
|
|
|
|
* This might have been set initially using the constructor or using the setTagField() method.
|
|
|
|
*/
|
|
|
|
inline Media::Tag *PicturePreviewSelection::tag() const
|
|
|
|
{
|
|
|
|
return m_tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the field. This is commonly KnownField::Cover.
|
|
|
|
*/
|
|
|
|
inline Media::KnownField PicturePreviewSelection::field() const
|
|
|
|
{
|
|
|
|
return m_field;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Sets the specified \a tag, \a field and \a previousValueHandling.
|
|
|
|
*
|
|
|
|
* If \a tag is nullptr the widget is disabled. The widget will be re-setup.
|
|
|
|
*/
|
|
|
|
inline void PicturePreviewSelection::setTagField(Media::Tag *tag, Media::KnownField field, PreviousValueHandling previousValueHandling)
|
|
|
|
{
|
|
|
|
m_tag = tag;
|
|
|
|
m_field = field;
|
|
|
|
setup(previousValueHandling);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // COVEREDIT_H
|