krita

kis_multi_bool_filter_widget.cc

00001 /*
00002  *  Copyright (c) 2005 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 #include "kis_multi_bool_filter_widget.h"
00020 
00021 #include <qlabel.h>
00022 #include <qlayout.h>
00023 #include <qcheckbox.h>
00024 
00025 #include <klocale.h>
00026 
00027 KisBoolWidgetParam::KisBoolWidgetParam(  bool ninitvalue, QString nlabel, QString nname) :
00028     initvalue(ninitvalue),
00029     label(nlabel),
00030     name(nname)
00031 {
00032 
00033 }
00034 
00035 KisMultiBoolFilterWidget::KisMultiBoolFilterWidget(QWidget * parent, const char * name, const char * caption, vKisBoolWidgetParam iwparam) : 
00036     KisFilterConfigWidget( parent, name )
00037 {
00038     Q_INT32 m_nbboolWidgets = iwparam.size();
00039 
00040     this->setCaption(caption);
00041 
00042     QVBoxLayout *widgetLayout = new QVBoxLayout(this, m_nbboolWidgets + 1);
00043 
00044     m_boolWidgets = new QCheckBox*[ m_nbboolWidgets ];
00045 
00046     for( Q_INT32 i = 0; i < m_nbboolWidgets; ++i)
00047     {
00048         m_boolWidgets[i] = new QCheckBox( this, iwparam[i].name.ascii());
00049         m_boolWidgets[i]->setChecked( iwparam[i].initvalue );
00050         m_boolWidgets[i]->setText( iwparam[i].label );
00051         connect(m_boolWidgets[i], SIGNAL(toggled( bool ) ), SIGNAL(sigPleaseUpdatePreview()));
00052         widgetLayout->add( m_boolWidgets[i]);
00053     }
00054 //     QSpacerItem * sp = new QSpacerItem(1, 1);
00055     widgetLayout->addStretch();
00056 }
00057 
00058 
00059 void KisMultiBoolFilterWidget::setConfiguration(KisFilterConfiguration * config)
00060 {
00061     
00062     for (int i = 0; i < m_nbboolWidgets; ++i) {
00063         double val = config->getBool(m_boolWidgets[i]->name());
00064         m_boolWidgets[i]->setChecked(val);
00065     }
00066 }
00067 
00068 #include "kis_multi_bool_filter_widget.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys