-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainWindow.h
More file actions
95 lines (79 loc) · 2.15 KB
/
mainWindow.h
File metadata and controls
95 lines (79 loc) · 2.15 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QRadioButton>
#include <QLineEdit>
#include <QCheckBox>
#include <QPushButton>
#include "ImgView.h"
#include <QVector>
#include <QDialogButtonBox>
#include <QDialog>
#include <QVBoxLayout>
#include <QKeyEvent>
#include <QGraphicsBlurEffect>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget* parent = nullptr);
protected:
void keyPressEvent(QKeyEvent* event) override;
private:
//Ui::MainWindow* ui;
QWidget* centralWidget;
// ImageDisplay* imageDisplay;
ImgView* imageDisplay;
QRadioButton* rgbMode;
QRadioButton* grayMode;
QLineEdit* minR;
QLineEdit* maxR;
QLineEdit* minG;
QLineEdit* maxG;
QLineEdit* minB;
QLineEdit* maxB;
QLineEdit* minGray;
QLineEdit* maxGray;
QPushButton* btnLoadImg;
QPushButton* btnClearBg;
QPushButton* btnChangeBg;
QPushButton* btnSaveResult;
QPushButton* btnShowOrigImg;
QPushButton* btnMarkFrontMode;
QPushButton* btnMarkBgMode;
QPushButton* btnGetPixelMode;
QPushButton* btnShowResultImg;
QVector<QWidget*> controlsToDisable;
QImage origImg;
QImage processedImg;
bool cleaned;
void disableControls();
QImage getAlphaChannel(const QImage& image); // 获取 alpha 通道
// 抗锯齿融合
QImage antialiasedBlend(const QImage& foreground, const QImage& background, int blurRadius);
private slots:
void loadImg(QImage image);
void enterMarkMode(bool isFront);
void enterColorInfoMode();
void validateInput();
void clearImgBg();
void changeImgBg();
void showOrigImg();
void showResultImg();
void saveResult();
void enableControls();
};
class ClickedClearLineEdit : public QLineEdit {
Q_OBJECT
public:
ClickedClearLineEdit(QWidget* parent = nullptr) : QLineEdit(parent) {}
protected:
// QLineEdit不触发单纯的鼠标点击信号,在鼠标按下事件中添加清空输入文本的功能
void mousePressEvent(QMouseEvent* event) override {
QLineEdit::mouseReleaseEvent(event);
if (event->button() == Qt::LeftButton && !isReadOnly()) {
clear();
}
}
};
#endif // MAINWINDOW_H