removed clock pref widget. clock prefs are definitively part of the lua theme.
[kboard.git] / src / newgame.cpp
blob458bc718487182103558f17992ace767186abfc8
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 <iostream>
12 #include <QComboBox>
13 #include <QHBoxLayout>
14 #include "common.h"
15 #include "variants/variants.h"
16 #include "kboard.h"
17 #include "newgame.h"
19 NewGame::NewGame(QWidget* parent, bool allowCurrent)
20 : QDialog(parent)
21 , m_custom_opt_widget(NULL)
22 , m_custom_opt_layout(NULL) {
23 setupUi(this);
25 std::cout << "allow current = " << allowCurrent << std::endl;
26 m_allow_current = allowCurrent;
27 connect(cmbVariant, SIGNAL(currentIndexChanged(const QString&)),
28 this, SLOT(variantChanged(const QString&)));
30 m_custom_opt_layout = new QHBoxLayout(widgetCustom);
32 const Variant::Variants& all = Variant::allVariants();
33 for(Variant::Variants::const_iterator it = all.begin(); it != all.end(); ++it)
34 cmbVariant->addItem(it->first, QVariant(it->first));
37 QString NewGame::variant() const {
38 QString res = cmbVariant->itemData(cmbVariant->currentIndex()).toString();
39 return res;
42 bool NewGame::playFromCurrent() const {
43 return rdCurrent->isChecked();
46 bool NewGame::isCustom() const {
47 return rdCustom->isChecked();
50 void NewGame::variantChanged(const QString& var) {
51 std::cout << "var = " << var << std::endl;
52 bool enabled = m_allow_current && var == "Chess";
53 rdCurrent->setEnabled(enabled);
54 if (!enabled)
55 rdStandard->setChecked(true);
57 if(m_custom_opt_widget)
58 delete m_custom_opt_widget;
59 m_custom_options = OptList();
60 VariantInfo* vi = Variant::variant(var);
61 if(vi) {
62 m_custom_options = vi->positionOptions();
63 m_custom_opt_widget = new OptionWidget(m_custom_options, widgetCustom);
64 m_custom_opt_layout->addWidget(m_custom_opt_widget);