-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaceitemproperties.cpp
More file actions
82 lines (67 loc) · 2.67 KB
/
interfaceitemproperties.cpp
File metadata and controls
82 lines (67 loc) · 2.67 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
79
80
81
82
#include "interfaceitemproperties.h"
#include <QGridLayout>
#include <QLabel>
#include "project.h"
CommonItemMECS *InterfaceItemProperties::m_DefaultItem = NULL;
bool InterfaceItemProperties::isDefault = false;
InterfaceItemProperties::InterfaceItemProperties(CommonItemMECS &item) :
QDialog(0)
{
if (!item.isInitialized() && m_DefaultItem != NULL)
item.Copy(m_DefaultItem);
this->m_item = &item;
QLabel *lblLabelType = new QLabel("Type:");
QLabel *lblType = new QLabel();
lblType->setText(item.GetName());
lblType->setFixedHeight(25);
QLabel *lblLabelWidth = new QLabel("Width:");
txtWidth = new QLineEdit;
txtWidth->setAlignment(Qt::AlignRight);
txtWidth->setText(QString::number(item.boundingRect().width()));
QLabel *lblLabelHeight = new QLabel("Height:");
txtHeight = new QLineEdit;
txtHeight->setText(QString::number(item.boundingRect().height()));
txtHeight->setAlignment(Qt::AlignRight);
QLabel *lblLabelText = new QLabel(item.GetTextName() + ":");
txtText = new QLineEdit;
txtText->setAlignment(Qt::AlignRight);
txtText->setText(item.getText());
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel);
QGridLayout *mainLayout = new QGridLayout();
mainLayout->addWidget(lblLabelType, 0, 0);
mainLayout->addWidget(lblType, 0, 1);
mainLayout->addWidget(lblLabelWidth, 1, 0);
mainLayout->addWidget(txtWidth, 1, 1);
mainLayout->addWidget(lblLabelHeight, 2, 0);
mainLayout->addWidget(txtHeight, 2, 1);
mainLayout->addWidget(lblLabelText, 3, 0);
mainLayout->addWidget(txtText, 3, 1);
mainLayout->addLayout(item.GetPropertiesWidgets(), 5, 0, 1, 2);
QHBoxLayout *bottomLayout = new QHBoxLayout;
chkSaveAsDefault = new QCheckBox("Save as default");
chkSaveAsDefault->setChecked(isDefault);
bottomLayout->addWidget(chkSaveAsDefault);
bottomLayout->addStretch();
bottomLayout->addWidget(buttonBox);
mainLayout->addLayout(bottomLayout, 6, 0, 1, 2);
setLayout(mainLayout);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
setMaximumHeight(350);
setFixedHeight(350);
}
void InterfaceItemProperties::accept()
{
m_item->setWidth(txtWidth->text().toInt());
m_item->setHeight(txtHeight->text().toInt());
m_item->setText(txtText->text());
m_item->AcceptWidgetsProperties();
m_item->setInitialized();
if (chkSaveAsDefault->isChecked())
m_DefaultItem = m_item;
else
m_DefaultItem = NULL;
isDefault = chkSaveAsDefault->isChecked();
QDialog::accept();
}