summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNemanja Hiršl <[email protected]>2017-07-11 14:12:40 +0200
committerNemanja Hiršl <[email protected]>2017-07-11 14:12:40 +0200
commitf87080e78d2c18e8731ccef6a506d5db21f4438d (patch)
tree75f035d095f0b402b3cceb9f7a74063ab5a75c9c
parenta39bce32bd992583d1e7e9bb447a6bb2e343e9bb (diff)
Fix ksirk configuration dialog and settings.
- All settings names in preferences.ui prefixed with appropriate kcfg_ - preferences.ui auto updated by qtcreator - Removed default values for KsirkConfigurationDialog c-tor. Default usage of KConfigDialog. - Includes cleaned up - Dialog set to be modal - Removed unused code
-rw-r--r--ksirk/ksirkConfigDialog.cpp74
-rw-r--r--ksirk/ksirkConfigDialog.h16
-rw-r--r--ksirk/preferences.ui75
3 files changed, 55 insertions, 110 deletions
diff --git a/ksirk/ksirkConfigDialog.cpp b/ksirk/ksirkConfigDialog.cpp
index 278a5c2..9a122ce 100644
--- a/ksirk/ksirkConfigDialog.cpp
+++ b/ksirk/ksirkConfigDialog.cpp
@@ -16,96 +16,50 @@
02110-1301, USA
*/
-
#include "ksirkConfigDialog.h"
#include "ksirksettings.h"
#include "ui_preferences.h"
-
-#include <QPushButton>
-#include <kfiledialog.h>
-#include <kconfig.h>
-#include <kurl.h>
-#include <ktabwidget.h>
-#include <kedittoolbar.h>
#include "ksirk_debug.h"
-#include <kstandardaction.h>
-
-#include <klibloader.h>
-#include <kmessagebox.h>
-#include <kstatusbar.h>
-#include <KLocalizedString>
-#include <kconfigdialog.h>
-
-#include <kapplication.h>
-
-#include <qslider.h>
-#include <qcheckbox.h>
-#include <iostream>
-
using namespace Ksirk;
KsirkConfigurationDialog::KsirkConfigurationDialog (
- QWidget *parent, const char *name, KConfigSkeleton *config,
- FaceType dialogType, QDialogButtonBox::StandardButtons dialogButtons,
- QDialogButtonBox::StandardButton defaultButton, bool modal) :
- KConfigDialog (parent, name, config) , m_changed(false),
+ QWidget *parent, const char *name, KConfigSkeleton *config) :
+ KConfigDialog (parent, name, config),
m_widget(new Ui::KsirkPreferencesWidget())
{
- setFaceType(dialogType);
- setStandardButtons(dialogButtons);
- button(defaultButton)->setDefault(true);
- setModal(modal);
+ setModal(true);
QWidget* w = new QWidget();
m_widget->setupUi(w);
-
addPage( w, i18n("Preferences"), "games-config-options"/*, i18n("Preferences"), false*/);
- // below, connection to activate the apply button
-// connect(m_widget->reloadOnChangeMode, SIGNAL(clicked(int)), this, SLOT(settingChanged(int)));
- connect(m_widget->armiesNumbers, SIGNAL(stateChanged(int)), this, SIGNAL(armiesNumberShowingChanged(int)));
+ connect(m_widget->kcfg_showArmiesNumbers, SIGNAL(stateChanged(int)), this, SIGNAL(armiesNumberShowingChanged(int)));
+ connect(this, SIGNAL(settingsChanged()), this, SLOT(updateSettings()) );
}
-KsirkConfigurationDialog::~KsirkConfigurationDialog ()
+KsirkConfigurationDialog::~KsirkConfigurationDialog ()
{
delete m_widget;
}
-void KsirkConfigurationDialog::settingChanged(int)
-{
- qCDebug(KSIRK_LOG);
- m_changed = true;
- //settingsChangedSlot();
- //updateButtons ();
-}
-
-bool KsirkConfigurationDialog::hasChanged()
-{
- qCDebug(KSIRK_LOG);
- return m_changed;
-}
-
void KsirkConfigurationDialog::updateSettings()
{
qCDebug(KSIRK_LOG);
- m_changed = false;
- KsirkSettings::setSpritesSpeed(m_widget->spritesSpeed->value());
- KsirkSettings::setSoundEnabled(m_widget->soundEnabled->isChecked());
- KsirkSettings::setHelpEnabled(m_widget->helpEnabled->isChecked());
- KsirkSettings::setShowArmiesNumbers(m_widget->armiesNumbers->isChecked());
+ KsirkSettings::setSpritesSpeed(m_widget->kcfg_spritesSpeed->value());
+ KsirkSettings::setSoundEnabled(m_widget->kcfg_soundEnabled->isChecked());
+ KsirkSettings::setHelpEnabled(m_widget->kcfg_helpEnabled->isChecked());
+ KsirkSettings::setShowArmiesNumbers(m_widget->kcfg_showArmiesNumbers->isChecked());
KsirkSettings::self()->save();
}
void KsirkConfigurationDialog::updateWidgets()
{
qCDebug(KSIRK_LOG);
-
- m_changed = false;
- m_widget->spritesSpeed->setValue(KsirkSettings::spritesSpeed());
- m_widget->soundEnabled->setChecked(KsirkSettings::soundEnabled());
- m_widget->helpEnabled->setChecked(KsirkSettings::helpEnabled());
- m_widget->armiesNumbers->setChecked(KsirkSettings::showArmiesNumbers());
+ m_widget->kcfg_spritesSpeed->setValue(KsirkSettings::spritesSpeed());
+ m_widget->kcfg_soundEnabled->setChecked(KsirkSettings::soundEnabled());
+ m_widget->kcfg_helpEnabled->setChecked(KsirkSettings::helpEnabled());
+ m_widget->kcfg_showArmiesNumbers->setChecked(KsirkSettings::showArmiesNumbers());
}
diff --git a/ksirk/ksirkConfigDialog.h b/ksirk/ksirkConfigDialog.h
index 200aa13..ad14497 100644
--- a/ksirk/ksirkConfigDialog.h
+++ b/ksirk/ksirkConfigDialog.h
@@ -20,9 +20,8 @@
#ifndef _KSIRKCONFIGDIALOG_H_
#define _KSIRKCONFIGDIALOG_H_
-#include <kconfigdialog.h>
+#include <KConfigDialog>
#include <KConfigSkeleton>
-#include <QDialogButtonBox>
namespace Ui
{
class KsirkPreferencesWidget;
@@ -41,11 +40,7 @@ public:
/**
* Constructor
*/
- KsirkConfigurationDialog (
- QWidget *parent, const char *name, KConfigSkeleton *config,
- FaceType faceType=List,
- QDialogButtonBox::StandardButtons dialogButtons=QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Ok|QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help,
- QDialogButtonBox::StandardButton defaultButton=QDialogButtonBox::Ok, bool modal=false);
+ KsirkConfigurationDialog (QWidget *parent, const char *name, KConfigSkeleton *config);
/** Destructor */
virtual ~KsirkConfigurationDialog ();
@@ -56,13 +51,8 @@ Q_SIGNALS:
protected Q_SLOTS:
virtual void updateSettings();
virtual void updateWidgets();
- void settingChanged(int);
-// void slotArmiesNumberChanged(int);
-
-protected:
- virtual bool hasChanged();
- bool m_changed;
+protected:
Ui::KsirkPreferencesWidget* m_widget;
};
diff --git a/ksirk/preferences.ui b/ksirk/preferences.ui
index 2fa3ef9..e2e9601 100644
--- a/ksirk/preferences.ui
+++ b/ksirk/preferences.ui
@@ -1,7 +1,8 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>KsirkPreferencesWidget</class>
- <widget class="QWidget" name="KsirkPreferencesWidget" >
- <property name="geometry" >
+ <widget class="QWidget" name="KsirkPreferencesWidget">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@@ -9,95 +10,95 @@
<height>294</height>
</rect>
</property>
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>15</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize" >
+ <property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string>KsirK Preferences</string>
</property>
- <layout class="QGridLayout" name="gridLayout" >
- <item row="0" column="0" >
- <widget class="QCheckBox" name="soundEnabled" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="kcfg_soundEnabled">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text" >
+ <property name="text">
<string>Sound enabled</string>
</property>
</widget>
</item>
- <item row="1" column="0" >
- <widget class="QLabel" name="textLabel1" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text" >
+ <property name="text">
<string>Sprites speed (slow, normal, rapid, immediate)</string>
</property>
- <property name="wordWrap" >
+ <property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="2" column="0" >
- <widget class="QSlider" name="spritesSpeed" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
+ <item row="2" column="0">
+ <widget class="QSlider" name="kcfg_spritesSpeed">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimum" >
+ <property name="minimum">
<number>0</number>
</property>
- <property name="maximum" >
+ <property name="maximum">
<number>3</number>
</property>
- <property name="pageStep" >
+ <property name="pageStep">
<number>1</number>
</property>
- <property name="value" >
+ <property name="value">
<number>1</number>
</property>
- <property name="orientation" >
+ <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="tickInterval" >
+ <property name="tickInterval">
<number>1</number>
</property>
</widget>
</item>
- <item row="3" column="0" >
- <widget class="QCheckBox" name="helpEnabled" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="MinimumExpanding" hsizetype="MinimumExpanding" >
+ <item row="3" column="0">
+ <widget class="QCheckBox" name="kcfg_helpEnabled">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text" >
+ <property name="text">
<string>Show help</string>
</property>
</widget>
</item>
- <item row="4" column="0" >
- <widget class="QCheckBox" name="armiesNumbers" >
- <property name="text" >
+ <item row="4" column="0">
+ <widget class="QCheckBox" name="kcfg_showArmiesNumbers">
+ <property name="text">
<string>Show number of armies on countries</string>
</property>
</widget>