File indexing completed on 2024-04-28 04:03:11

0001 /***************************************************************************
0002     File                 : DifficultyDialog.cpp
0003     Project              : Knights
0004     Description          : Dialogs for setting custom difficulty
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2016 Alexander Semke (alexander.semke@web.de)
0007 
0008  ***************************************************************************/
0009 
0010 /***************************************************************************
0011  *                                                                         *
0012  *  SPDX-License-Identifier: GPL-2.0-or-later
0013  *                                                                         *
0014  *  This program is distributed in the hope that it will be useful,        *
0015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0017  *  GNU General Public License for more details.                           *
0018  *                                                                         *
0019  *   You should have received a copy of the GNU General Public License     *
0020  *   along with this program; if not, write to the Free Software           *
0021  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0022  *   Boston, MA  02110-1301  USA                                           *
0023  *                                                                         *
0024  ***************************************************************************/
0025 #include "difficultydialog.h"
0026 #include "ui_customdifficultydialog.h"
0027 #include "settings.h"
0028 
0029 #include <QDialogButtonBox>
0030 
0031 DifficultyDialog::DifficultyDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f) {
0032     QFrame* mainFrame = new QFrame(this);
0033     ui = new Ui::CustomDifficultyDialog();
0034     ui->setupUi(mainFrame);
0035     ui->sbSearchDepth->setSuffix(ki18ncp("Search depth suffix", " move", " moves"));
0036     ui->sbSearchDepth->setValue(Settings::computerSearchDepth());
0037     ui->sbMemorySize->setValue(Settings::computerMemorySize());
0038 
0039     QDialogButtonBox *bBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
0040 
0041     QVBoxLayout* layout = new QVBoxLayout(this);
0042     layout->addWidget(mainFrame);
0043     layout->addWidget(bBox);
0044 
0045     setLayout(layout);
0046     setWindowTitle(i18nc("@title:window", "Difficulty Level"));
0047 
0048     connect(bBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
0049     connect(bBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
0050 }
0051 
0052 DifficultyDialog::~DifficultyDialog() {
0053     delete ui;
0054 }
0055 
0056 int DifficultyDialog::memorySize() const {
0057     return ui->sbMemorySize->value();
0058 }
0059 
0060 int DifficultyDialog::searchDepth() const {
0061     return ui->sbSearchDepth->value();
0062 }
0063 
0064 #include "moc_difficultydialog.cpp"