-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparametersdialog.cpp
More file actions
78 lines (73 loc) · 1.65 KB
/
parametersdialog.cpp
File metadata and controls
78 lines (73 loc) · 1.65 KB
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
#include "parametersdialog.h"
ParametersDialog::ParametersDialog(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::ParametersDialog)
{
m_ui->setupUi(this);
this->chars = new QList<QString>();
}
ParametersDialog::~ParametersDialog() { }
void ParametersDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
m_ui->retranslateUi(this);
break;
default:
break;
}
}
void ParametersDialog::on_startApp_clicked()
{
if (fileName == "")
{
QMessageBox box;
box.setText("No *.pra file loaded");
box.exec();
}
else
{
this->setBaseSize(610, 610);
this->setMinimumSize(610, 610);
myView = new QGraphicsView(this);
myView->setBaseSize(610, 610);
myView->setMinimumSize(610, 610);
myScene = new InputScene(this, chars, m_ui->isEndless->isChecked());
myView->setScene(myScene);
myView->show();
myView->setFocus();
}
}
void ParametersDialog::on_loadButton_clicked()
{
fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("Practise File (*.pra)"));
QString word;
if (fileName == "")
{
QMessageBox box;
box.setText("No *.pra file choosen");
box.exec();
}
else
{
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QMessageBox::warning(this, tr("Open file"), tr("Error, cannot load file").arg(fileName).arg(file.errorString()));
}
else
{
QTextStream fileStream(&file);
chars->clear();
while (!fileStream.atEnd())
{
fileStream >> word;
chars->append(word);
}
chars->removeLast();
m_ui->fileNameLabel->setText(fileName);
m_ui->fileNameLabel->adjustSize();
}
}
}