File indexing completed on 2024-04-28 07:51:19
0001 /* 0002 SPDX-FileCopyrightText: 2006, 2007 Nicolas Roffet <nicolas-kde@roffet.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kbblevelconfigurationwidget.h" 0008 0009 0010 0011 #include <QGridLayout> 0012 0013 #include <KLocalizedString> 0014 #include <KPluralHandlingSpinBox> 0015 0016 #include "kbblevelconfigurationpreview.h" 0017 #include "kbbscalablegraphicwidget.h" 0018 #include "kbbthememanager.h" 0019 0020 0021 0022 KBBLevelConfigurationWidget::KBBLevelConfigurationWidget(QWidget *parent, int c, int r, int b, KBBThemeManager* themeManager) : QWidget(parent) 0023 { 0024 QGridLayout *l = new QGridLayout(this); 0025 0026 kcfg_balls = new KPluralHandlingSpinBox(this); 0027 kcfg_balls->setObjectName( QStringLiteral("kcfg_balls" )); 0028 l->addWidget(kcfg_balls, 0, 0, 1, 2); 0029 kcfg_balls->setMinimum(1); 0030 kcfg_balls->setValue(b); 0031 kcfg_balls->setSuffix(ki18ncp("A number between 1 and 99 is displayed in front of it.", " ball", " balls")); 0032 connect(kcfg_balls, static_cast<void (KPluralHandlingSpinBox::*)(int)>(&KPluralHandlingSpinBox::valueChanged), this, &KBBLevelConfigurationWidget::boxSizeChanged); 0033 0034 kcfg_columns = new KPluralHandlingSpinBox(this); 0035 kcfg_columns->setObjectName( QStringLiteral("kcfg_columns" )); 0036 l->addWidget(kcfg_columns, 1, 1); 0037 kcfg_columns->setMinimum(2); 0038 kcfg_columns->setMaximum(30); 0039 kcfg_columns->setValue(c); 0040 kcfg_columns->setSuffix(ki18ncp("A number between 2 and 30 is displayed in front of it.", " column", " columns")); 0041 connect(kcfg_columns, static_cast<void (KPluralHandlingSpinBox::*)(int)>(&KPluralHandlingSpinBox::valueChanged), this, &KBBLevelConfigurationWidget::boxSizeChanged); 0042 0043 kcfg_rows = new KPluralHandlingSpinBox(this); 0044 kcfg_rows->setObjectName( QStringLiteral("kcfg_rows" )); 0045 l->addWidget(kcfg_rows, 2, 0); 0046 kcfg_rows->setMinimum(2); 0047 kcfg_rows->setMaximum(30); 0048 kcfg_rows->setValue(r); 0049 kcfg_rows->setSuffix(ki18ncp("A number between 2 and 30 is displayed in front of it.", " row", " rows")); 0050 connect(kcfg_rows, static_cast<void (KPluralHandlingSpinBox::*)(int)>(&KPluralHandlingSpinBox::valueChanged), this, &KBBLevelConfigurationWidget::boxSizeChanged); 0051 0052 m_view = new KBBLevelConfigurationPreview(this, themeManager); 0053 l->addWidget(m_view, 2, 1); 0054 0055 boxSizeChanged(); 0056 } 0057 0058 0059 int KBBLevelConfigurationWidget::balls() const 0060 { 0061 return kcfg_balls->value(); 0062 } 0063 0064 0065 int KBBLevelConfigurationWidget::columns() const 0066 { 0067 return kcfg_columns->value(); 0068 } 0069 0070 0071 int KBBLevelConfigurationWidget::rows() const 0072 { 0073 return kcfg_rows->value(); 0074 } 0075 0076 0077 void KBBLevelConfigurationWidget::boxSizeChanged() 0078 { 0079 kcfg_balls->setMaximum(qMin(99, columns()*rows() - 1)); 0080 m_view->preview(balls(), columns(), rows()); 0081 } 0082 0083 #include "moc_kbblevelconfigurationwidget.cpp"