File indexing completed on 2024-05-12 16:34:29

0001 /* This file is part of the KDE project
0002  * Copyright (c) 2009 Jan Hambrecht <jaham@gmx.net>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesser General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #include "FloodEffectConfigWidget.h"
0021 #include "FloodEffect.h"
0022 #include "KoFilterEffect.h"
0023 
0024 #include <KoColorPopupAction.h>
0025 
0026 #include <klocalizedstring.h>
0027 
0028 #include <QGridLayout>
0029 #include <QLabel>
0030 #include <QToolButton>
0031 
0032 FloodEffectConfigWidget::FloodEffectConfigWidget(QWidget *parent)
0033         : KoFilterEffectConfigWidgetBase(parent), m_effect(0)
0034 {
0035     QGridLayout * g = new QGridLayout(this);
0036 
0037     g->addWidget(new QLabel(i18n("Flood color"), this), 0, 0);
0038     QToolButton * button = new QToolButton(this);
0039     g->addWidget(button, 0, 1);
0040     m_actionStopColor = new KoColorPopupAction(this);
0041     button->setDefaultAction(m_actionStopColor);
0042     setLayout(g);
0043 
0044     connect(m_actionStopColor, SIGNAL(colorChanged(KoColor)), this, SLOT(colorChanged()));
0045 }
0046 
0047 bool FloodEffectConfigWidget::editFilterEffect(KoFilterEffect * filterEffect)
0048 {
0049     m_effect = dynamic_cast<FloodEffect*>(filterEffect);
0050     if (!m_effect)
0051         return false;
0052 
0053     m_actionStopColor->setCurrentColor(m_effect->floodColor());
0054     return true;
0055 }
0056 
0057 void FloodEffectConfigWidget::colorChanged()
0058 {
0059     if (!m_effect)
0060         return;
0061 
0062     m_effect->setFloodColor(m_actionStopColor->currentColor());
0063     emit filterChanged();
0064 }