-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
137 lines (122 loc) · 3.63 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
first(true)
{
ui->setupUi(this);
directories << "/home/schvarcz/Desktop/balance_test/original/"
<< "/home/schvarcz/Desktop/balance_test/colorEnhanced/"
<< "/home/schvarcz/Desktop/balance_test/whiteBalance/";
savePath = "/home/schvarcz/Desktop/balance_test/selected/";
editPath = "/home/schvarcz/Desktop/balance_test/editar/";
diretory.mkdir(savePath);
diretory.mkdir(editPath);
diretory.setPath(savePath);
listImgsProcessed = diretory.entryList(QStringList("*.jpg"));
diretory.setPath(directories.at(0));
listImgs = diretory.entryList(QStringList("*.jpg"));
aniImgTrans = new QPropertyAnimation(ui->imgWidget,"geometry");
aniImgTrans->setDuration(300);
aniImgFade = new QPropertyAnimation(ui->imgAux,"geometry");
aniImgFade->setDuration(300);
currentIndex = listImgsProcessed.size();
currentDirectory = 0;
showImages(0);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::showImages(int sentido)
{
if (!first)
{
if (sentido ==2)
{
}
aniImgTrans->stop();
ui->imgAux->setPixmap(ui->imgWidget->pixmap()->copy());
ui->imgAux->setGeometry(QRect(0,0,desktop.width(),desktop.height()));
if (sentido ==1)
ui->imgWidget->setGeometry(QRect(desktop.width()*0.1,desktop.height(),desktop.width()*0.8,desktop.height()*0.8));
if (sentido ==2)
ui->imgWidget->setGeometry(QRect(desktop.width()*0.1,-desktop.height(),desktop.width()*0.8,desktop.height()*0.8));
if (sentido ==3)
ui->imgWidget->setGeometry(QRect(desktop.width(),desktop.height()*0.1,desktop.width()*0.8,desktop.height()*0.8));;
if (sentido ==4)
ui->imgWidget->setGeometry(QRect(-desktop.width(),desktop.height()*0.1,desktop.width()*0.8,desktop.height()*0.8));
aniImgTrans->setEndValue(QRect(0,0,desktop.width(),desktop.height()));
aniImgTrans->start();
}
else
{
ui->imgWidget->setGeometry(QRect(0,0,desktop.width(),desktop.height()));
}
ui->imgWidget->setPixmap(QPixmap(directories.at(currentDirectory)+listImgs.at(currentIndex)));
first = false;
}
void MainWindow::next()
{
currentIndex++;
showImages(3);
}
void MainWindow::back()
{
if (currentIndex > 0)
{
currentIndex--;
QFile::remove(savePath+listImgs.at(currentIndex));
QFile::remove(editPath+listImgs.at(currentIndex));
showImages(4);
}
}
void MainWindow::backwardSelected()
{
if (currentDirectory > 0)
{
currentDirectory--;
showImages(2);
}
}
void MainWindow::fordwardSelected()
{
if (currentDirectory < directories.size()-1)
{
currentDirectory++;
showImages(1);
}
}
void MainWindow::editSelected()
{
QFile::copy(directories.at(currentDirectory)+listImgs.at(currentIndex),editPath+listImgs.at(currentIndex));
next();
}
void MainWindow::originalSelected()
{
QFile::copy(directories.at(currentDirectory)+listImgs.at(currentIndex),savePath+listImgs.at(currentIndex));
next();
}
void MainWindow::keyReleaseEvent(QKeyEvent *event)
{
QMainWindow::keyReleaseEvent(event);
switch(event->key())
{
case Qt::Key_Left:
back();
break;
case Qt::Key_Right:
originalSelected();
break;
case Qt::Key_Up:
backwardSelected();
break;
case Qt::Key_Down:
fordwardSelected();
break;
case Qt::Key_Escape:
editSelected();
break;
}
}