-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfilemanager.cpp
55 lines (49 loc) · 1.45 KB
/
filemanager.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
#include "filemanager.h"
#include "modooperacion.h"
FileManager::FileManager(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::FileManager){
ui->setupUi(this);
}
FileManager::~FileManager(){
delete ui;
}
void FileManager::on_action_Open_File_triggered(){
QString fileName = QFileDialog::getOpenFileName(
this,
"Text Editor Open File",
"home/",
"Texts Files (*.txt);;All Files(*.*)");
if (!fileName.isEmpty()){
QFile file(fileName);
if (file.open(QFile::ReadOnly)){
ui->textEdit->setPlainText(file.readAll());
ui->textEdit_2->setPlainText(fileName);
this->Direcc = fileName;
} else {
QMessageBox::warning(
this,
"Text Editor",
tr("Cannot read File %1. \nError: %2")
.arg(fileName)
.arg(file.errorString()));
}
}
}
void FileManager::on_AceptarF_clicked(){
QString fileName = this->Direcc;
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)){
QMessageBox::information(nullptr, "error", file.errorString());
}
QTextStream in(&file);
this->program = in.readAll();
this->br->loadProgram(this->Direcc);
this->hide();
}
void FileManager::on_CancelarF_clicked(){
this->hide();
}
QString FileManager::getProgram(){
return this->program;
}