summaryrefslogtreecommitdiffstats
path: root/chalk/plugins/filters/blur/kis_wdg_blur.cc
blob: d4213bb58eb00da74ae2599b4cff39913ed8ed05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * This file is part of Chalk
 *
 * Copyright (c) 2006 Cyrille Berger <cberger@cberger.net>
 *
 *  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.
 *
 *  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.
 *
 *  You should have received a copy of the GNU 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.
 */

#include "kis_wdg_blur.h"

#include <tqlayout.h>
#include <tqtoolbutton.h>

#include <kcombobox.h>
#include <knuminput.h>

#include <KoImageResource.h>

#include <kis_filter.h>

#include "wdgblur.h"

KisWdgBlur::KisWdgBlur( KisFilter* nfilter, TQWidget * parent, const char * name) : KisFilterConfigWidget ( parent, name )
{
    Q_UNUSED( nfilter );

    TQGridLayout *widgetLayout = new TQGridLayout(this, 1, 1);
    m_widget = new WdgBlur(this);
    widgetLayout -> addWidget(m_widget,0,0);

    linkSpacingToggled(true);

    connect( widget()->bnLinkSize, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(linkSpacingToggled( bool )));
    connect( widget()->intHalfWidth, TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(spinBoxHalfWidthChanged(int)));
    connect( widget()->intHalfHeight, TQT_SIGNAL(valueChanged(int)),this,TQT_SLOT(spinBoxHalfHeightChanged(int)));

    connect( widget()->intStrength, TQT_SIGNAL( valueChanged(int)), TQT_SIGNAL(sigPleaseUpdatePreview()));
    connect( widget()->intAngle, TQT_SIGNAL( valueChanged(int)), TQT_SIGNAL(sigPleaseUpdatePreview()));
    connect( widget()->cbShape, TQT_SIGNAL( activated(int)), TQT_SIGNAL(sigPleaseUpdatePreview()));
}


void KisWdgBlur::setConfiguration(KisFilterConfiguration* config)
{
    TQVariant value;
    if (config->getProperty("shape", value))
    {
        widget()->cbShape->setCurrentItem( value.toUInt() );
    }
    if (config->getProperty("halfWidth", value))
    {
        widget()->intHalfWidth->setValue( value.toUInt() );
    }
    if (config->getProperty("halfHeight", value))
    {
        widget()->intHalfHeight->setValue( value.toUInt() );
    }
    if (config->getProperty("rotate", value))
    {
        widget()->intAngle->setValue( value.toUInt() );
    }
    if (config->getProperty("strength", value))
    {
        widget()->intStrength->setValue( value.toUInt() );
    }
}

void KisWdgBlur::linkSpacingToggled(bool b)
{
    m_halfSizeLink = b;
    KoImageResource kir;
    if (b) {
        widget()->bnLinkSize->setPixmap(kir.chain());
    }
    else {
        widget()->bnLinkSize->setPixmap(kir.chainBroken());
    }
}

void KisWdgBlur::spinBoxHalfWidthChanged(int v)
{
    if(m_halfSizeLink) {
        widget()->intHalfHeight->setValue(v);
    }
/*    if( widget()->intHalfHeight->value() == v && widget()->cbShape->currentItem() != 1)
        widget()->intAngle->setEnabled(false);
    else
        widget()->intAngle->setEnabled(true);*/
    emit sigPleaseUpdatePreview();
}

void KisWdgBlur::spinBoxHalfHeightChanged(int v)
{
    if(m_halfSizeLink) {
        widget()->intHalfWidth->setValue(v);
    }
/*    if( widget()->intHalfWidth->value() == v && widget()->cbShape->currentItem() != 1)
        widget()->intAngle->setEnabled(false);
    else
        widget()->intAngle->setEnabled(true);*/
    emit sigPleaseUpdatePreview();
}

#include "kis_wdg_blur.moc"