-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
146 lines (132 loc) · 4.12 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
138
139
140
141
142
143
144
145
146
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent, Qt::FramelessWindowHint ) // making da window frameless
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
setAttribute(Qt::WA_TranslucentBackground); // window transparent
// Manual Actions
QMenu *menu = new QMenu();
menu->addAction(ui->actionSave);
menu->addAction(ui->actionSave_Sliced_Output);
QToolButton* toolButton = new QToolButton();
toolButton->setIcon(QIcon(":/icons/save2.png"));
toolButton->setMenu(menu);
toolButton->setPopupMode(QToolButton::InstantPopup);
ui->toolBar->addWidget(toolButton);
//
// Lcd number digit clr
ui->counts->setPalette(Qt::black);
// Connections
//connect(ui->actionLoad, SIGNAL(triggered()), this, SLOT(on_actionLoad_triggered()));
connect(ui->checkBox, SIGNAL(clicked(bool)), this, SLOT(ischecked(bool)));
//
// panel buttons
connect(ui->btn_min, SIGNAL(clicked(bool)), this, SLOT(showMinimized()));
connect(ui->btn_max, SIGNAL(clicked(bool)), this, SLOT(showMax()));
connect(ui->btn_close, SIGNAL(clicked(bool)), qApp, SLOT(quit()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionLoad_triggered()
{
extract.load(this);
// page count of pdf
ui->pgcount->display(extract.pgcount);
}
void MainWindow::on_actionRead_triggered()
{
// if document is laoded
if(extract.document->status() == 2) {
int page = ui->spinBox->text().toInt();
if(ui->checkBox->isChecked()) {
extract.checkboxc = true;
extract.extr(page);
ui->plainTextEdit->appendPlainText(*extract.allText);
} else {
extract.checkboxc = false;
extract.extr(page);
ui->plainTextEdit->setPlainText(*extract.allText);
}
// appending to splitter
for(int i = 0 ; i < extract.rawSliced->length() ; i++) {
ui->splitter->appendPlainText(extract.rawSliced->at(i));
}
// counting the list
int counter = ui->splitter->document()->blockCount();
ui->counts->display(counter);
delete extract.allText;
} else {
QMessageBox::information(this, "Error", "PDF File Not Loaded", QMessageBox::Ok);
}
}
void MainWindow::ischecked(bool checked)
{
if(checked) {
ui->spinBox->setDisabled(true);
}
if(!checked) {
// enabling spinbox if !ticked
ui->spinBox->setEnabled(true);
}
}
void MainWindow::on_actionDuplicates_triggered()
{
if(extract.document->status() == 2 && extract.extracted == true) {
nonDuplicated = new QStringList;
ui->splitter->clear();
extract.rawSliced->removeDuplicates();
nonDuplicated = extract.rawSliced;
for(int i = 0 ; i < nonDuplicated->length() ; i++) {
ui->splitter->appendPlainText(nonDuplicated->at(i));
}
// --
// redisplay list count
int counter = ui->splitter->document()->blockCount();
ui->counts->display(counter);
delete nonDuplicated;
extract.extracted = false;
} else {
QMessageBox::information(this, "Error", "PDF File Not Loaded or not extracted", QMessageBox::Ok);
}
}
void MainWindow::on_actionClear_triggered()
{
ui->splitter->clear();
ui->plainTextEdit->clear();
extract.extracted = false;
}
void MainWindow::on_actionSave_triggered()
{
// getting plain text frm textedit n pass arg
QString text = ui->plainTextEdit->toPlainText();
extract.save(text);
}
void MainWindow::on_actionSave_Sliced_Output_triggered()
{
QString text2 = ui->splitter->toPlainText();
extract.save(text2);
}
void MainWindow::showMax()
{
// func to max / normal window
if(this->isMaximized()) {
this->showNormal();
} else {
this->showMaximized();
}
}
void MainWindow::mousePressEvent(QMouseEvent *event)
{
// click evnt on window
m_x = event->x();
m_y = event->y();
}
void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
// moving da widget to current cursor position
move(event->globalX() - m_x, event->globalY() - m_y);
}