1 | /* |
2 | Copyright (c) 2006, 2007, Nicolas Roffet, <nicolas-kde@roffet.com> |
3 | |
4 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
5 | |
6 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
7 | |
8 | You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
9 | */ |
10 | |
11 | #include "kbblevelconfigurationwidget.h" |
12 | |
13 | |
14 | |
15 | #include <QGridLayout> |
16 | |
17 | #include <klocale.h> |
18 | #include <KNumInput> |
19 | |
20 | #include "kbblevelconfigurationpreview.h" |
21 | #include "kbbscalablegraphicwidget.h" |
22 | #include "kbbthememanager.h" |
23 | |
24 | |
25 | |
26 | KBBLevelConfigurationWidget::KBBLevelConfigurationWidget(QWidget *parent, int c, int r, int b, KBBThemeManager* themeManager) : QWidget(parent) |
27 | { |
28 | QGridLayout *l = new QGridLayout(this); |
29 | |
30 | kcfg_balls = new KIntSpinBox(this); |
31 | kcfg_balls->setObjectName( QLatin1String("kcfg_balls" )); |
32 | l->addWidget(kcfg_balls, 0, 0, 1, 2); |
33 | kcfg_balls->setMinimum(1); |
34 | kcfg_balls->setValue(b); |
35 | kcfg_balls->setSuffix(ki18ncp("A number between 1 and 99 is displayed in front of it." , " ball" , " balls" )); |
36 | connect(kcfg_balls, SIGNAL(valueChanged(int)), this, SLOT(boxSizeChanged())); |
37 | |
38 | kcfg_columns = new KIntSpinBox(this); |
39 | kcfg_columns->setObjectName( QLatin1String("kcfg_columns" )); |
40 | l->addWidget(kcfg_columns, 1, 1); |
41 | kcfg_columns->setMinimum(2); |
42 | kcfg_columns->setMaximum(30); |
43 | kcfg_columns->setValue(c); |
44 | kcfg_columns->setSuffix(ki18ncp("A number between 2 and 30 is displayed in front of it." , " column" , " columns" )); |
45 | connect(kcfg_columns, SIGNAL(valueChanged(int)), this, SLOT(boxSizeChanged())); |
46 | |
47 | kcfg_rows = new KIntSpinBox(this); |
48 | kcfg_rows->setObjectName( QLatin1String("kcfg_rows" )); |
49 | l->addWidget(kcfg_rows, 2, 0); |
50 | kcfg_rows->setMinimum(2); |
51 | kcfg_rows->setMaximum(30); |
52 | kcfg_rows->setValue(r); |
53 | kcfg_rows->setSuffix(ki18ncp("A number between 2 and 30 is displayed in front of it." , " row" , " rows" )); |
54 | connect(kcfg_rows, SIGNAL(valueChanged(int)), this, SLOT(boxSizeChanged())); |
55 | |
56 | m_view = new KBBLevelConfigurationPreview(this, themeManager); |
57 | l->addWidget(m_view, 2, 1); |
58 | |
59 | boxSizeChanged(); |
60 | } |
61 | |
62 | |
63 | int KBBLevelConfigurationWidget::balls() const |
64 | { |
65 | return kcfg_balls->value(); |
66 | } |
67 | |
68 | |
69 | int KBBLevelConfigurationWidget::columns() const |
70 | { |
71 | return kcfg_columns->value(); |
72 | } |
73 | |
74 | |
75 | int KBBLevelConfigurationWidget::rows() const |
76 | { |
77 | return kcfg_rows->value(); |
78 | } |
79 | |
80 | |
81 | void KBBLevelConfigurationWidget::boxSizeChanged() |
82 | { |
83 | kcfg_balls->setMaximum(qMin(99, columns()*rows() - 1)); |
84 | m_view->preview(balls(), columns(), rows()); |
85 | } |
86 | |
87 | |
88 | #include "kbblevelconfigurationwidget.moc" |
89 | |