-
Notifications
You must be signed in to change notification settings - Fork 0
/
pathdialog.cpp
41 lines (32 loc) · 879 Bytes
/
pathdialog.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
#include "pathdialog.h"
#include "ui_dialog.h"
#include <QPushButton>
#include <QFile>
#include <QTextStream>
#include <QMessageBox>
PathDialog::PathDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &PathDialog::okClicked);
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked, this, &PathDialog::close);
}
void PathDialog::okClicked()
{
QString path = ui->lineEdit->text();
if(path.trimmed().isEmpty()) {
return;
}
QFile *file = new QFile (path);
if(file->open(QFile::ReadOnly | QFile::Text)) {
emit flashFile(file);
close();
return;
}
QMessageBox::information(this, "Error", "Path is not correct!");
}
PathDialog::~PathDialog()
{
delete ui;
}