-
Notifications
You must be signed in to change notification settings - Fork 0
/
clickableimagelabel.h
81 lines (55 loc) · 1.95 KB
/
clickableimagelabel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef CLICKABLEIMAGELABEL_H
#define CLICKABLEIMAGELABEL_H
#include <QLabel>
#include <QImage>
#include <QMouseEvent>
#include <QDialog>
#include <QVBoxLayout>
#include <QLabel>
#include "ext/maybe_ptr.hpp"
/*
ClickableImageLabel: A widget for display of result images
It's designed to only own its images in specific scenarios, hence the heavy use of pointers
*/
class ClickableImageLabel : public QLabel {
Q_OBJECT
public:
explicit ClickableImageLabel(QWidget *parent = nullptr);
~ClickableImageLabel() override;
void loadImage(const QString& imagePath);
void SetImage(QImage *Img, QString *Path = nullptr, bool TransferOwnership = false);
void ResetImage();
void SetImagePreview(QImage& Img);
QImage* GetOriginalImage() {return OriginalImage.get();};
QSize getPreviewSize() const;
void setPreviewSize(const QSize &newPreviewSize);
bool isUpscaleResult = false;
private:
// shared_ptr is not applicable here since TopBarImg allocates its image as an owning class member
// also, it would take too much refactoring
maybe_ptr<QImage> OriginalImage;
QString OriginalFilePath = "";
QSize PreviewSize = QSize(430,430);
protected:
void contextMenuEvent(QContextMenuEvent *event) override;
void mousePressEvent(QMouseEvent* event) override; // Handle mouse press event
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
signals:
void OnMenuOpen(QMenu* InMenu);
void SendImageToInpaint(QImage* Img);
void SendImageToImg2Img(QImage* Img);
void SendImageToUpscale(QImage* Img, bool TransOwnership);
private slots:
void showInFolder();
void Favorite();
void OnClickSendToImg2Img();
void OnClickSendToInpaint();
void OnClickSendToUpscale();
private:
QAction* actSendToInpaint;
QAction* actSendToImg2Img;
QAction* actSendToUpscale;
QAction* actSendToFavorites;
};
#endif // CLICKABLEIMAGELABEL_H