| 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 "rotatedialog.hpp" |
| 17 | |
| 18 | #include <QHBoxLayout> |
| 19 | #include <QIntValidator> |
| 20 | #include <QLabel> |
| 21 | #include <QLineEdit> |
| 22 | #include <QPushButton> |
| 23 | #include <QVBoxLayout> |
| 24 | |
| 25 | RotateDialog::RotateDialog(QWidget * parent) |
| 26 | : QDialog(parent) |
| 27 | , m_layout(new QGridLayout(this)) |
| 28 | , m_okButton(new QPushButton(tr("Ok"))) |
| 29 | , m_cancelButton(new QPushButton(tr("Cancel"))) |
| 30 | , m_angleEdit(new QLineEdit) |
| 31 | , m_angleLabel(new QLabel(tr("Angle in degrees:"))) |
| 32 | { |
| 33 | setWindowTitle(tr("Rotate Object")); |
| 34 | |
| 35 | QIntValidator * validator = new QIntValidator(this); |
| 36 | validator->setRange(-360, 360); |
| 37 | m_angleEdit->setValidator(validator); |
| 38 | m_angleEdit->setText("90"); |
| 39 | |
| 40 | m_layout->addWidget(m_angleLabel, 0, 0); |
| 41 | m_layout->addWidget(m_angleEdit, 0, 1); |
| 42 | m_layout->addWidget(m_okButton, 3, 0); |
| 43 | m_layout->addWidget(m_cancelButton, 3, 1); |
| 44 | |
| 45 | connect(m_okButton, &QPushButton::clicked, this, &RotateDialog::accept); |
| 46 | connect(m_cancelButton, &QPushButton::clicked, this, &RotateDialog::reject); |
| 47 | } |
| 48 | |
| 49 | int RotateDialog::angle() const |
| 50 | { |
| 51 | return m_angleEdit->text().toInt(); |
| 52 | } |