-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmainwindow.cpp
101 lines (80 loc) · 2.16 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
#include <memory>
#include "opencv2/opencv.hpp"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "histogramcalculator.h"
#include "splitterdecoration.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
// Init menus and actions
createActions();
createMenus();
// Init histograms
//picPathStr = "D:/temp/P1070216.JPG";
pic = new PictureData(this, tr("D:/temp/P1070216.JPG"));
updatePicInUse();
// Decorate Splitter
helper::decorateSplitter(ui->splitter, 1);
}
MainWindow::~MainWindow()
{
delete ui;
if (pic)
{
delete pic;
}
}
void MainWindow::open()
{
// Get path to picture
QString picPathStr;
PictureData * oldPic = pic;
picPathStr = QFileDialog::getOpenFileName(this,
tr("Open Image"), "D:/temp/",
tr("Image Files (*.jpg *.jpeg *.tiff *.bmp);;All files (*.*)"));
pic = new PictureData(this, picPathStr);
if (oldPic)
{
delete oldPic;
}
updatePicInUse();
}
void MainWindow::save()
{
}
void MainWindow::exit()
{
QWidget::close();
}
void MainWindow::updatePicInUse()
{
// Init histograms
ui->histsViewer->setHist(&pic->histGraphs);
// Init OpenGL view
ui->glViewer->setPixmap(&pic->pixmapInitial);
}
void MainWindow::createMenus()
{
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(openAct);
fileMenu->addAction(saveAct);
fileMenu->addAction(exitAct);
}
void MainWindow::createActions()
{
openAct = new QAction(tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open a picture"));
connect(openAct, &QAction::triggered, this, &MainWindow::open);
saveAct = new QAction(tr("&Save"), this);
saveAct->setShortcuts(QKeySequence::Save);
saveAct->setStatusTip(tr("Save the document to disk"));
connect(saveAct, &QAction::triggered, this, &MainWindow::save);
exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, &QAction::triggered, this, &MainWindow::exit);
}