-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.cpp
115 lines (95 loc) · 3.02 KB
/
MainWindow.cpp
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "MainWindow.hpp"
#include "ui_MainWindow.h"
#include <QCloseEvent>
#include <QFileDialog>
#include <QMessageBox>
#include "ImagesDialog.hpp"
#include "ProcessingEngine.hpp"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
m_engine(nullptr)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
if(nullptr != m_engine) {
delete m_engine;
}
}
void MainWindow::SetEngine(const ProcessingEngine *_engine)
{
m_engine = _engine;
}
void MainWindow::on_actionOpen_triggered()
{
QString filename = QFileDialog::getOpenFileName(this,
"Open image",
"",
"Image files (*.jpg *.bmp *.png *.tif);;All files (*.*)",
0,
QFileDialog::DontUseNativeDialog);
if(true == filename.isEmpty()) {
return;
}
ImagesDialog *image;
image = new ImagesDialog(this, m_engine);
image->setWindowTitle(filename);
image->OpenImage(filename);
image->show();
}
void MainWindow::on_actionExit_triggered()
{
this->closeEvent(nullptr);
}
void MainWindow::on_actionUser_manual_triggered()
{
QString brief = "This application was designed for linear filtering of greyscale or color images.";
QString open = "1. step: Open image: File -> Open [Ctrl+O]";
QString setFilter = "2. step: Set filter";
QString applyFilter = "3. step: Apply specified filter";
QString saveImage = "4. step: Save filtered image";
QString repeat = "[repeat]";
QString nl = "\n";
QMessageBox msgBox;
msgBox.setIconPixmap(QPixmap(":/icons/pg.bmp"));
msgBox.addButton(QMessageBox::Close);
msgBox.setWindowTitle("Mini tutorial");
msgBox.setText(brief);
msgBox.setDetailedText(open +nl+
setFilter +nl+
applyFilter +nl+
saveImage +nl+
repeat);
msgBox.exec();
}
void MainWindow::on_actionAbout_triggered()
{
QString nl = "\n";
QString brief = "This application was designed for linear filtering of greyscale or color images.";
QString author = "Author: Mateusz Kacprzak";
QString faculty = "wfis.uni.lodz.pl 2014";
QString uses = "Stworzono przy wykorzystaniu";
QString qt = "Qt 5.2.0 (http://qt-project.org/)";
QString opencv = "OpenCV 2.4.8 (http://opencv.org/)";
QMessageBox msgBox;
msgBox.setIconPixmap(QPixmap(":/icons/pg.bmp"));
msgBox.addButton(QMessageBox::Close);
msgBox.setWindowTitle("About");
msgBox.setText(brief +nl+nl+
author +nl+
faculty +nl+nl+
uses +nl+
qt +nl+
opencv);
msgBox.exec();
}
void MainWindow::closeEvent(QCloseEvent *_event)
{
if(nullptr != _event) {
_event->accept();
}
qApp->quit();
}