-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialog.cpp
60 lines (53 loc) · 1.53 KB
/
dialog.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
#include "dialog.h"
#include "ui_dialog.h"
#include "savelevelsystem.h"
#include "component.h"
#include "errorsystem.h"
#include <QMessageBox>
#include <QPainter>
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
QRegExp rex("[1-9 a-z A-Z]*");
QValidator* validator = new QRegExpValidator(rex, this);
ui->fileNameEdit->setValidator(validator);
ui->fileNameEdit->setMaxLength(15);
ui->fileNameEdit->setToolTip("Cool charecters are 1 to 9 and a to z");
this->setStyleSheet("Dialog{background-color:white;}");
}
void Dialog::paintEvent(QPaintEvent *pe)
{
QStyleOption o;
o.initFrom(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::on_saveBtn_clicked() //TODO check for emty or just space and restrict the lenght of the file name
{
QString error_message;
QMessageBox messageBox;
messageBox.setFixedSize(500,200);
messageBox.setWindowTitle("Message");
//messageBox.setWindowFlags(Qt::WindowContextHelpButtonHint);
int error_code = SaveLevelSystem(ui->fileNameEdit->text(), false);
if(error_code == NO_ERROR) {
error_message = get_error_message(error_code);
messageBox.setText(error_message);
this->hide();
messageBox.exec();
}else{
error_message = get_error_message(error_code);
messageBox.setText(error_message);
messageBox.exec();
}
}
void Dialog::on_cancelBtn_clicked()
{
this->hide();
}