2 #include "namedialog.h"
4 NameDialog::NameDialog(QWidget *parent, EmuFrontObject *efObj)
5 : EmuFrontDialog(parent), efObject(efObj)
7 nameLabel = new QLabel(tr("&Name: "));
8 nameEdit = new QLineEdit;
9 nameLabel->setBuddy(nameEdit);
10 buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Abort, Qt::Horizontal);
11 /*saveButton = new QPushButton(tr("&Save"));
12 saveButton->setDefault(true);
13 saveButton->setEnabled(false);
14 closeButton = new QPushButton(tr("Close"));*/
17 setWindowTitle(tr("Set names"));
20 NameDialog::~NameDialog()
24 /* deleting objects in heap is not needed here
25 * because when deleting a parent widget
26 * the child widgets will be also deleted:
34 void NameDialog::connectSignals()
36 connect(nameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(enableSaveButton(const QString &)));
37 connect(buttonBox, SIGNAL(accepted()), this, SLOT(acceptChanges()));
38 connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
40 /*connect(saveButton, SIGNAL(clicked()), this, SLOT(saveButtonClicked()));
41 connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));*/
44 void NameDialog::layout()
46 QHBoxLayout *topLayout = new QHBoxLayout;
47 topLayout->addWidget(nameLabel);
48 topLayout->addWidget(nameEdit);
50 QHBoxLayout *bottomLayout = new QHBoxLayout;
51 bottomLayout->addWidget(buttonBox);
52 /*bottomLayout->addStretch();
53 bottomLayout->addWidget(saveButton);
54 bottomLayout->addWidget(closeButton);*/
56 QVBoxLayout *mainLayout = new QVBoxLayout;
57 mainLayout->addLayout(topLayout);
58 mainLayout->addLayout(bottomLayout);
59 setLayout(mainLayout);
62 void NameDialog::acceptChanges()
64 if (nameEdit->text() == 0 || nameEdit->text().trimmed().isEmpty())
66 QMessageBox::warning(this, tr("Invalid input"), tr("Empty string is not accepted as name!"));
70 QString name = nameEdit->text().simplified();
72 emit dataObjectUpdated();
76 void NameDialog::enableSaveButton(const QString &text)
78 //saveButton->setEnabled(!text.isEmpty());