-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputDialog.cpp
More file actions
67 lines (50 loc) · 1.66 KB
/
InputDialog.cpp
File metadata and controls
67 lines (50 loc) · 1.66 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
#include "stdafx.h"
#include "InputDialog.h"
#include "GObjectHandler.h"
using namespace LarasEngine;
std::string LarasEngine::InputDialog::GetInput (const QString& text)
{
QString val;
LarasEngine::InputDialog d (text, val);
d.exec ();
return (std::string) val.toLatin1 ();
}
void LarasEngine::InputDialog::ReadJson (const QJsonObject& json)
{
if (json.contains("DialogStyle"))
setStyleSheet (json["DialogStyle"].toString());
if (json.contains("LineEditStyle"))
lineEdit->setStyleSheet (json["LineEditStyle"].toString());
if (json.contains("LabelStyle"))
labelText->setStyleSheet (json["LabelStyle"].toString());
if (json.contains("TextureId"))
pixmap = LE_OH.LoadImage (json["TextureId"].toString().toStdString());
}
LarasEngine::InputDialog::InputDialog (const QString& text, QString& val)
: _val (val)
, JsonObject ("InputDialog")
{
setModal (true);
setWindowFlags (Qt::Window | Qt::FramelessWindowHint);
lineEdit = new QLineEdit (this);
labelText = new QLabel (text, this);
LoadJson ();
//Background Image
setFixedSize (pixmap.size ());
QLabel* label = new QLabel (this);
label->setPixmap (pixmap);
label->move (0, 0);
int padding = pixmap.width () * 0.05;
int paddingV = pixmap.height () * 0.2;
labelText->setFixedSize (pixmap.width () - padding * 2, paddingV);
labelText->move (padding, paddingV);
lineEdit->setFixedSize (pixmap.width() - padding * 2, paddingV);
lineEdit->move (padding, paddingV * 3);
connect (lineEdit, &QLineEdit::returnPressed, this, &InputDialog::on_returnPressed);
}
void LarasEngine::InputDialog::on_returnPressed ()
{
_val = lineEdit->text ();
if (!_val.isEmpty())
accept ();
}