2021-11-18 14:58:01 +00:00
|
|
|
#ifndef DUST3D_APPLICATION_IMAGE_PREVIEW_WIDGET_H_
|
|
|
|
#define DUST3D_APPLICATION_IMAGE_PREVIEW_WIDGET_H_
|
|
|
|
|
2019-08-03 10:21:27 +00:00
|
|
|
#include <QImage>
|
|
|
|
#include <QMouseEvent>
|
2022-10-18 09:35:04 +00:00
|
|
|
#include <QPaintEvent>
|
|
|
|
#include <QWidget>
|
2019-08-03 10:21:27 +00:00
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
class ImagePreviewWidget : public QWidget {
|
2019-08-03 10:21:27 +00:00
|
|
|
Q_OBJECT
|
|
|
|
signals:
|
|
|
|
void clicked();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2019-08-03 10:21:27 +00:00
|
|
|
public:
|
2022-10-18 09:35:04 +00:00
|
|
|
ImagePreviewWidget(QWidget* parent = nullptr);
|
|
|
|
void updateImage(const QImage& image);
|
|
|
|
void updateBackgroundColor(const QColor& color);
|
|
|
|
|
2019-08-03 10:21:27 +00:00
|
|
|
protected:
|
2022-10-18 09:35:04 +00:00
|
|
|
void paintEvent(QPaintEvent* event);
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
|
2019-08-03 10:21:27 +00:00
|
|
|
private:
|
|
|
|
QImage m_image;
|
|
|
|
QColor m_backgroundColor;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
|
|
|
void resizeImage(QImage* image, const QSize& newSize);
|
2019-08-03 10:21:27 +00:00
|
|
|
};
|
2021-11-18 14:58:01 +00:00
|
|
|
|
|
|
|
#endif
|