removed clock pref widget. clock prefs are definitively part of the lua theme.
[kboard.git] / src / pref_preferences.cpp
blob8cfa980b9110ff14b5925e9e69e3d97dcaa1f4d6
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include <QApplication>
12 #include <QHBoxLayout>
13 #include <kicon.h>
14 #include "mastersettings.h"
15 #include "pref_board.h"
16 #include "pref_movelist.h"
17 #include "pref_theme.h"
18 #include "pref_engines.h"
19 #include "pref_preferences.h"
21 template<typename T>
22 class PrefWrapper : public PrefBase {
23 private:
24 T *m_inner;
26 public:
27 PrefWrapper(QWidget *parent = 0)
28 : PrefBase(parent)
29 , m_inner(NULL) {
32 virtual void apply() {
33 if(m_inner)
34 m_inner->apply();
37 virtual void showEvent( QShowEvent * /*event*/ ) {
38 if(m_inner)
39 return;
41 m_inner = new T(this);
42 QHBoxLayout *l = new QHBoxLayout(this);
43 l->addWidget(m_inner);
44 m_inner->show();
49 Preferences::Preferences(QWidget *parent)
50 : QDialog(parent) {
52 setupUi(this);
53 setWindowIcon(KIcon("kboard"));
54 connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
56 pagePref->hide();
57 PrefBase *b;
58 KPageWidgetItem *i;
60 b = new PrefWrapper<PrefBoard>(this);
61 connect(this, SIGNAL(applied()), b, SLOT(apply()));
62 i = pagePref->addPage(b, "Board");
63 i->setHeader("Board preferences:");
64 i->setIcon(KIcon("prefBoard"));
66 b = new PrefWrapper<PrefMoveList>(this);
67 connect(this, SIGNAL(applied()), b, SLOT(apply()));
68 i = pagePref->addPage(b, "Move list");
69 i->setHeader("Move list preferences:");
70 i->setIcon(KIcon("prefMoveList"));
72 b = new PrefWrapper<PrefTheme>(this);
73 connect(this, SIGNAL(applied()), b, SLOT(apply()));
74 i = pagePref->addPage(b, "Theme");
75 i->setHeader("Pieces & squares theme:");
76 i->setIcon(KIcon("prefTheme"));
77 pagePref->show();
79 b = new PrefWrapper<PrefEngines>(this);
80 connect(this, SIGNAL(applied()), b, SLOT(apply()));
81 i = pagePref->addPage(b, "Engines");
82 i->setHeader("Engines:");
83 i->setIcon(KIcon("brain"));
84 pagePref->show();
87 Preferences::~Preferences() {
90 void Preferences::apply() {
91 emit applied();
92 settings.changed();