Commit aee27d23 authored by Benjamin Meyer's avatar Benjamin Meyer
Browse files

Converted to use KAutoConfigDialog and bug fixes

svn path=/trunk/kdegames/ktron/; revision=220582
parent 352d0afe
......@@ -34,9 +34,7 @@
#include "general.h"
#include "ai.h"
#include "appearance.h"
#include <kiconloader.h>
#include <qvbox.h>
#include <kautoconfig.h>
#include <kautoconfigdialog.h>
#define ID_STATUS_BASE 40
#define MESSAGE_TIME 2000
......@@ -45,10 +43,10 @@
/**
* Constuctor
*/
KTron::KTron() : settings(0) {
KTron::KTron(QWidget *parent, const char *name) : KMainWindow(parent, name) {
playerPoints[0]=playerPoints[1]=0;
tron=new Tron(this);
tron=new Tron(this, "Tron");
connect(tron,SIGNAL(gameEnds(Player)),SLOT(changeStatus(Player)));
setCentralWidget(tron);
tron->setMinimumSize(200,180);
......@@ -86,10 +84,10 @@ KTron::KTron() : settings(0) {
createGUI();
resize(400,300);
setAutoSaveSettings();
readSettings();
loadSettings();
}
void KTron::readSettings() {
void KTron::loadSettings() {
KConfig *config=kapp->config();
config->setGroup("Game");
playerName[0]=config->readEntry("Name_Pl1");
......@@ -102,11 +100,6 @@ void KTron::readSettings() {
updateStatusbar();
}
// Destructor
KTron::~KTron(){
delete tron;
}
void KTron::updateStatusbar(){
for(int i=0;i<2;i++){
Player player;
......@@ -192,37 +185,16 @@ void KTron::configureKeys(){
* Show Settings dialog.
*/
void KTron::showSettings(){
settings = new KDialogBase(KDialogBase::IconList, i18n("Configure"), KDialogBase::Default | KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel , KDialogBase::Ok, this, "SettingsDialog", false, WDestructiveClose );
KAutoConfig *kautoconfig = new KAutoConfig(settings, "KAutoConfig");
//KAutoConfig_KURLRequester *r = new KAutoConfig_KURLRequester();
//kautoconfig->addKAutoConfigWidget("KURLRequester", r);
connect(settings, SIGNAL(okClicked()), kautoconfig, SLOT(saveSettings()));
connect(settings, SIGNAL(okClicked()), this, SLOT(closeSettings()));
connect(settings, SIGNAL(applyClicked()), kautoconfig, SLOT(saveSettings()));
connect(settings, SIGNAL(defaultClicked()), kautoconfig, SLOT(resetSettings()));
QVBox *frame = settings->addVBoxPage(i18n("General"),i18n("General"), SmallIcon("package_settings", 32));
General *general = new General(frame, "General");
kautoconfig->addWidget(general, "Game");
frame = settings->addVBoxPage(i18n("Ai"),i18n("Ai"), SmallIcon("package_system", 32));
Ai *ai = new Ai(frame, "Ai");
kautoconfig->addWidget(ai, "Game");
frame = settings->addVBoxPage(i18n("Appearance"),i18n("Appearance"), SmallIcon("style", 32));
Appearance *appearance = new Appearance(frame, "Appearance");
kautoconfig->addWidget(appearance, "Game");
kautoconfig->retrieveSettings();
connect(kautoconfig, SIGNAL(settingsChanged()), tron, SLOT(loadSettings()));
connect(kautoconfig, SIGNAL(settingsChanged()), this, SLOT(readSettings()));
if(KAutoConfigDialog::showDialog("settings"))
return;
settings->show();
}
void KTron::closeSettings(){
settings->close(true);
KAutoConfigDialog *dialog = new KAutoConfigDialog(this, "settings");
dialog->addPage(new General(0, "General"), i18n("General"), "General", "package_settings");
dialog->addPage(new Ai(0, "Ai"), i18n("Ai"), "Game", "package_system");
dialog->addPage(new Appearance(0, "Appearance"), i18n("Appearance"), "Game", "style");
connect(dialog, SIGNAL(settingsChanged()), tron, SLOT(loadSettings()));
connect(dialog, SIGNAL(settingsChanged()), this, SLOT(loadSettings()));
dialog->show();
}
#include "ktron.moc"
......
......@@ -31,7 +31,6 @@
class KAccel;
class KSelectAction;
class KDialogBase;
class Tron;
/**
......@@ -42,16 +41,13 @@ class KTron : public KMainWindow {
Q_OBJECT
public:
KTron();
~KTron();
KTron(QWidget *parent=0, const char *name=0);
private:
KAccel *accel;
Tron *tron;
QString playerName[2];
int playerPoints[2];
KDialogBase *settings;
void updateStatusbar();
protected:
......@@ -59,15 +55,14 @@ protected:
void paletteChange(const QPalette &oldPalette);
private slots:
void readSettings();
void loadSettings();
/** updates players points in statusbar and checks if someone has won */
void changeStatus(Player);
void showWinner(Player winner);
void configureKeys();
void showSettings();
void closeSettings();
};
#endif
#endif // KTRON_H
......@@ -194,19 +194,3 @@ private slots:
#endif // TRON_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment