File indexing completed on 2025-04-20 03:48:11
0001 /* This file is part of KsirK. 0002 Copyright (C) 2006 Gael de Chalendar <kleag@free.fr> 0003 0004 KsirK is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU General Public 0006 License as published by the Free Software Foundation, either version 2 0007 of the License, or (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 General Public License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program; if not, write to the Free Software 0016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0017 02110-1301, USA 0018 */ 0019 0020 #include "ksirkConfigDialog.h" 0021 #include "ksirksettings.h" 0022 #include "ui_preferences.h" 0023 #include "ksirk_debug.h" 0024 0025 using namespace Ksirk; 0026 0027 KsirkConfigurationDialog::KsirkConfigurationDialog ( 0028 QWidget *parent, const char *name, KConfigSkeleton *config) : 0029 KConfigDialog (parent, name, config), 0030 m_widget(new Ui::KsirkPreferencesWidget()) 0031 0032 { 0033 setModal(true); 0034 QWidget* w = new QWidget(); 0035 m_widget->setupUi(w); 0036 0037 addPage( w, i18n("Preferences"), "games-config-options"/*, i18n("Preferences"), false*/); 0038 connect(m_widget->kcfg_showArmiesNumbers, &QCheckBox::stateChanged, this, &KsirkConfigurationDialog::armiesNumberShowingChanged); 0039 connect(this, &KConfigDialog::settingsChanged, this, &KsirkConfigurationDialog::updateSettings); 0040 setHelp(QStringLiteral("configuration"), QStringLiteral("ksirk")); 0041 } 0042 0043 KsirkConfigurationDialog::~KsirkConfigurationDialog () 0044 { 0045 delete m_widget; 0046 } 0047 0048 void KsirkConfigurationDialog::updateSettings() 0049 { 0050 qCDebug(KSIRK_LOG); 0051 KsirkSettings::setSpritesSpeed(m_widget->kcfg_spritesSpeed->value()); 0052 KsirkSettings::setSoundEnabled(m_widget->kcfg_soundEnabled->isChecked()); 0053 KsirkSettings::setHelpEnabled(m_widget->kcfg_helpEnabled->isChecked()); 0054 KsirkSettings::setShowArmiesNumbers(m_widget->kcfg_showArmiesNumbers->isChecked()); 0055 KsirkSettings::self()->save(); 0056 } 0057 0058 void KsirkConfigurationDialog::updateWidgets() 0059 { 0060 qCDebug(KSIRK_LOG); 0061 m_widget->kcfg_spritesSpeed->setValue(KsirkSettings::spritesSpeed()); 0062 m_widget->kcfg_soundEnabled->setChecked(KsirkSettings::soundEnabled()); 0063 m_widget->kcfg_helpEnabled->setChecked(KsirkSettings::helpEnabled()); 0064 m_widget->kcfg_showArmiesNumbers->setChecked(KsirkSettings::showArmiesNumbers()); 0065 } 0066 0067 #include "moc_ksirkConfigDialog.cpp"