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>
|
|
|
|
|
2018-08-20 21:43:17 +02:00
|
|
|
#include <QSize>
|
2015-04-22 19:33:53 +02:00
|
|
|
#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
|
|
|
|
2019-07-07 12:00:16 +02:00
|
|
|
#define TAGEDITOR_ENUM_CLASS enum class
|
2018-03-06 23:10:13 +01:00
|
|
|
namespace TagParser {
|
2015-04-22 19:33:53 +02:00
|
|
|
class Tag;
|
|
|
|
class TagValue;
|
2019-07-07 12:00:16 +02:00
|
|
|
TAGEDITOR_ENUM_CLASS KnownField : unsigned int;
|
2018-03-07 01:18:01 +01:00
|
|
|
} // namespace TagParser
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
namespace QtGui {
|
|
|
|
|
2019-07-07 12:00:16 +02:00
|
|
|
TAGEDITOR_ENUM_CLASS PreviousValueHandling : int;
|
|
|
|
#undef TAGEDITOR_ENUM_CLASS
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class PicturePreviewSelection;
|
2019-07-21 23:44:37 +02:00
|
|
|
class ImageConversionDialog;
|
|
|
|
} // namespace Ui
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2018-03-07 01:18:01 +01:00
|
|
|
class PicturePreviewSelection : public QWidget {
|
2015-04-22 19:33:53 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-03-07 01:18:01 +01:00
|
|
|
explicit PicturePreviewSelection(
|
|
|
|
TagParser::Tag *tag = nullptr, TagParser::KnownField field = TagParser::KnownField::Invalid, QWidget *parent = nullptr);
|
2019-06-01 12:45:12 +02:00
|
|
|
~PicturePreviewSelection() override;
|
2018-03-07 01:18:01 +01:00
|
|
|
|
2018-03-06 23:10:13 +01:00
|
|
|
TagParser::Tag *tag() const;
|
|
|
|
TagParser::KnownField field() const;
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2020-03-08 14:04:29 +01:00
|
|
|
public Q_SLOTS:
|
2019-06-01 12:53:44 +02:00
|
|
|
bool setTagField(TagParser::Tag *tag, TagParser::KnownField field, PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear);
|
|
|
|
bool setValue(const TagParser::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);
|
2019-02-13 18:20:34 +01:00
|
|
|
#ifndef QT_NO_CLIPBOARD
|
|
|
|
void pasteOfSelectedTypeAsJpeg();
|
|
|
|
void pasteOfSelectedTypeAsPng();
|
|
|
|
void pasteOfSelectedType(const char *format);
|
|
|
|
#endif
|
2015-04-22 19:33:53 +02:00
|
|
|
void removeSelected();
|
|
|
|
void extractSelected();
|
|
|
|
void displaySelected();
|
2016-05-16 21:01:01 +02:00
|
|
|
void changeMimeTypeOfSelected();
|
2019-07-21 23:44:37 +02:00
|
|
|
void convertSelected();
|
2016-05-16 21:01:01 +02:00
|
|
|
void setCoverButtonsHidden(bool hideCoverButtons);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2020-03-09 18:46:08 +01:00
|
|
|
Q_SIGNALS:
|
2015-04-22 19:33:53 +02:00
|
|
|
void pictureChanged();
|
|
|
|
|
|
|
|
protected:
|
2023-03-26 22:19:27 +02:00
|
|
|
bool event(QEvent *event) override;
|
2019-06-01 12:45:12 +02:00
|
|
|
void changeEvent(QEvent *event) override;
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
|
|
|
void dropEvent(QDropEvent *event) override;
|
2015-04-22 19:33:53 +02:00
|
|
|
|
2020-03-08 14:04:29 +01:00
|
|
|
private Q_SLOTS:
|
2021-04-28 00:47:55 +02:00
|
|
|
void typeSwitched(std::size_t index);
|
|
|
|
void updateDescription(std::size_t newIndex);
|
|
|
|
void updateDescription(std::size_t lastIndex, std::size_t newIndex);
|
|
|
|
void updatePreview(std::size_t index);
|
2019-07-20 18:49:32 +02:00
|
|
|
void showContextMenu(const QPoint &position);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
private:
|
2019-06-01 12:53:44 +02:00
|
|
|
bool setup(PreviousValueHandling previousValueHandling = PreviousValueHandling::Clear);
|
2018-08-20 21:43:17 +02:00
|
|
|
void updateSizeAndMimeType(std::size_t fileSize, const QSize &resolution, const QString &mimeType);
|
2019-07-21 23:44:37 +02:00
|
|
|
QImage convertTagValueToImage(const TagParser::TagValue &value);
|
|
|
|
void assignImageToTagValue(const QImage &image, TagParser::TagValue &tagValue, const char *format);
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
std::unique_ptr<Ui::PicturePreviewSelection> m_ui;
|
2019-07-21 23:44:37 +02:00
|
|
|
std::unique_ptr<Ui::ImageConversionDialog> m_imageConversionUI;
|
|
|
|
QDialog *m_imageConversionDialog;
|
2015-04-22 19:33:53 +02:00
|
|
|
QGraphicsScene *m_scene;
|
|
|
|
QGraphicsTextItem *m_textItem;
|
|
|
|
QPixmap m_pixmap;
|
|
|
|
QGraphicsPixmapItem *m_pixmapItem;
|
|
|
|
QGraphicsRectItem *m_rectItem;
|
2018-03-06 23:10:13 +01:00
|
|
|
TagParser::Tag *m_tag;
|
|
|
|
TagParser::KnownField m_field;
|
2021-04-28 00:47:55 +02:00
|
|
|
std::vector<TagParser::TagValue> m_values;
|
2018-08-20 21:43:17 +02:00
|
|
|
std::size_t m_currentFileSize;
|
|
|
|
QSize m_currentResolution;
|
|
|
|
QString m_currentMimeType;
|
2021-04-28 00:47:55 +02:00
|
|
|
std::size_t 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.
|
|
|
|
*/
|
2018-03-06 23:10:13 +01:00
|
|
|
inline TagParser::Tag *PicturePreviewSelection::tag() const
|
2015-04-22 19:33:53 +02:00
|
|
|
{
|
|
|
|
return m_tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the field. This is commonly KnownField::Cover.
|
|
|
|
*/
|
2018-03-06 23:10:13 +01:00
|
|
|
inline TagParser::KnownField PicturePreviewSelection::field() const
|
2015-04-22 19:33:53 +02:00
|
|
|
{
|
|
|
|
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.
|
|
|
|
*/
|
2019-06-01 12:53:44 +02:00
|
|
|
inline bool PicturePreviewSelection::setTagField(TagParser::Tag *tag, TagParser::KnownField field, PreviousValueHandling previousValueHandling)
|
2015-04-22 19:33:53 +02:00
|
|
|
{
|
|
|
|
m_tag = tag;
|
|
|
|
m_field = field;
|
2019-06-01 12:53:44 +02:00
|
|
|
return setup(previousValueHandling);
|
2015-04-22 19:33:53 +02:00
|
|
|
}
|
|
|
|
|
2018-03-07 01:18:01 +01:00
|
|
|
} // namespace QtGui
|
2015-04-22 19:33:53 +02:00
|
|
|
|
|
|
|
#endif // COVEREDIT_H
|