Debian Codegraph @

src/editor/trackpropertiesdialog.cpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2012 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #include "trackpropertiesdialog.hpp"
17
18 #include <QCheckBox>
19 #include <QHBoxLayout>
20 #include <QIntValidator>
21 #include <QLabel>
22 #include <QLineEdit>
23 #include <QPushButton>
24 #include <QString>
25 #include <QVBoxLayout>
26
27 TrackPropertiesDialog::TrackPropertiesDialog(QString name, unsigned int index, bool isUserTrack, QWidget * parent)
28 : QDialog(parent)
29 , m_layout(new QGridLayout(this))
30 , m_okButton(new QPushButton(tr("Ok")))
31 , m_cancelButton(new QPushButton(tr("Cancel")))
32 , m_nameEdit(new QLineEdit)
33 , m_nameLabel(new QLabel(tr("Name:")))
34 , m_indexEdit(new QLineEdit)
35 , m_indexLabel(new QLabel(tr("Index:")))
36 , m_isUserTrackCheckBox(new QCheckBox)
37 , m_isUserTrackLabel(new QLabel(tr("User track:")))
38 {
39 setWindowTitle(tr("Set track properties"));
40
41 m_nameEdit->setText(name);
42 QIntValidator * indexValidator = new QIntValidator(this);
43 indexValidator->setRange(0, 999);
44 m_indexEdit->setValidator(indexValidator);
45 m_indexEdit->setText(QString("%1").arg(index));
46 m_isUserTrackCheckBox->setChecked(isUserTrack);
47
48 m_layout->addWidget(m_nameLabel, 0, 0);
49 m_layout->addWidget(m_nameEdit, 0, 1);
50 m_layout->addWidget(m_indexLabel, 1, 0);
51 m_layout->addWidget(m_indexEdit, 1, 1);
52 m_layout->addWidget(m_isUserTrackLabel, 2, 0);
53 m_layout->addWidget(m_isUserTrackCheckBox, 2, 1);
54 m_layout->addWidget(m_okButton, 3, 0);
55 m_layout->addWidget(m_cancelButton, 3, 1);
56
57 connect(m_okButton, &QPushButton::clicked, this, &TrackPropertiesDialog::accept);
58 connect(m_cancelButton, &QPushButton::clicked, this, &TrackPropertiesDialog::reject);
59 }
60
61 unsigned int TrackPropertiesDialog::index() const
62 {
63 return m_indexEdit->text().toInt();
64 }
65
66 QString TrackPropertiesDialog::name() const
67 {
68 return m_nameEdit->text();
69 }
70
71 bool TrackPropertiesDialog::isUserTrack() const
72 {
73 return m_isUserTrackCheckBox->isChecked();
74 }