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

0001 /*
0002     This file is part of Killbots.
0003 
0004     SPDX-FileCopyrightText: 2007-2009 Parker Coates <coates@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #include "optionspage.h"
0010 
0011 #include <KComboBox>
0012 #include <KLocalizedString>
0013 
0014 #include <QCheckBox>
0015 #include <QFormLayout>
0016 #include <QGridLayout>
0017 #include <QLabel>
0018 #include <QSlider>
0019 
0020 Killbots::OptionsPage::OptionsPage(QWidget *parent)
0021     : QWidget(parent)
0022 {
0023     const QStringList clickActionList {
0024         i18nc("@item:inlistbox No action on click", "Nothing"),
0025         i18nc("@action", "Step"),
0026         i18nc("@action", "Repeated Step"),
0027         i18nc("@action", "Teleport"),
0028         i18nc("@action", "Teleport Safely"),
0029         i18nc("@action", "Teleport (Safely if Possible)"),
0030         i18nc("@action", "Wait Out Round"),
0031     };
0032 
0033     kcfg_MiddleClickAction = new KComboBox();
0034     kcfg_MiddleClickAction->setObjectName(QStringLiteral("kcfg_MiddleClickAction"));
0035     kcfg_MiddleClickAction->addItems(clickActionList);
0036 
0037     kcfg_RightClickAction = new KComboBox();
0038     kcfg_RightClickAction->setObjectName(QStringLiteral("kcfg_RightClickAction"));
0039     kcfg_RightClickAction->addItems(clickActionList);
0040 
0041     kcfg_AnimationSpeed = new QSlider(Qt::Horizontal);
0042     kcfg_AnimationSpeed->setObjectName(QStringLiteral("kcfg_AnimationSpeed"));
0043     kcfg_AnimationSpeed->setSingleStep(1);
0044     kcfg_AnimationSpeed->setMinimumWidth(200);
0045     QLabel *slowLabel = new QLabel(i18nc("@item:inrange", "Slow"));
0046     slowLabel->setAlignment(Qt::AlignLeft);
0047     QLabel *fastLabel = new QLabel(i18nc("@item:inrange", "Fast"));
0048     fastLabel->setAlignment(Qt::AlignCenter);
0049     QLabel *instantLabel = new QLabel(i18nc("@item:inrange", "Instant"));
0050     instantLabel->setAlignment(Qt::AlignRight);
0051 
0052     QGridLayout *speedLayout = new QGridLayout();
0053     speedLayout->setContentsMargins(0, 0, 0, 0);
0054     speedLayout->setSpacing(0);
0055     speedLayout->addWidget(kcfg_AnimationSpeed, 0, 0, 1, 3);
0056     speedLayout->addWidget(slowLabel, 1, 0);
0057     speedLayout->addWidget(fastLabel, 1, 1);
0058     speedLayout->addWidget(instantLabel, 1, 2);
0059 
0060     QLabel *speedLabel = new QLabel(i18nc("@label:slider", "Animation &speed:"));
0061     speedLabel->setBuddy(kcfg_AnimationSpeed);
0062 
0063     kcfg_PreventUnsafeMoves = new QCheckBox(i18nc("@option:check", "Prevent &unsafe moves"));
0064     kcfg_PreventUnsafeMoves->setObjectName(QStringLiteral("kcfg_PreventUnsafeMoves"));
0065 
0066     QFormLayout *formLayout = new QFormLayout(this);
0067     formLayout->setContentsMargins(0, 0, 0, 0);
0068     formLayout->addRow(i18nc("@label:listbox", "&Middle-click action:"), kcfg_MiddleClickAction);
0069     formLayout->addRow(i18nc("@label:listbox", "&Right-click action:"), kcfg_RightClickAction);
0070     formLayout->addItem(new QSpacerItem(0, 16, QSizePolicy::Minimum, QSizePolicy::Fixed));
0071     formLayout->addRow(speedLabel, speedLayout);
0072     formLayout->addItem(new QSpacerItem(0, 16, QSizePolicy::Minimum, QSizePolicy::Fixed));
0073     formLayout->addRow(nullptr, kcfg_PreventUnsafeMoves);
0074 }
0075 
0076 Killbots::OptionsPage::~OptionsPage()
0077 {
0078 }
0079 
0080 #include "moc_optionspage.cpp"