1 /*
2  * Copyright (c) 2010 Lukáš Tvrdý <lukast.dev@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #include <QWidget>
21 #include <QCheckBox>
22 #include <QHBoxLayout>
23 #include <QVBoxLayout>
24 
25 
26 #include <klocalizedstring.h>
27 
28 #include <kis_slider_spin_box.h>
29 
30 #include "kis_curve_option_widget.h"
31 #include "kis_pressure_spacing_option.h"
32 #include "kis_pressure_spacing_option_widget.h"
33 
KisPressureSpacingOptionWidget()34 KisPressureSpacingOptionWidget::KisPressureSpacingOptionWidget():
35     KisCurveOptionWidget(new KisPressureSpacingOption(), i18n("0%"), i18n("100%"))
36 {
37     m_isotropicSpacing = new QCheckBox(i18n("Isotropic Spacing"));
38     m_useSpacingUpdates = new QCheckBox(i18n("Update Between Dabs"));
39 
40     QHBoxLayout *hl = new QHBoxLayout;
41     hl->addWidget(m_isotropicSpacing);
42     hl->addWidget(m_useSpacingUpdates);
43 
44     QVBoxLayout *vl = new QVBoxLayout;
45     vl->setMargin(0);
46     vl->addLayout(hl);
47     vl->addWidget(KisCurveOptionWidget::curveWidget());
48 
49     QWidget *w = new QWidget;
50     w->setLayout(vl);
51 
52     KisCurveOptionWidget::setConfigurationPage(w);
53 
54     connect(m_isotropicSpacing, SIGNAL(stateChanged(int)),
55             this, SLOT(setIsotropicSpacing(int)));
56     connect(m_useSpacingUpdates, SIGNAL(stateChanged(int)),
57             this, SLOT(setUseSpacingUpdates(int)));
58 
59     setIsotropicSpacing(false);
60 }
61 
readOptionSetting(const KisPropertiesConfigurationSP setting)62 void KisPressureSpacingOptionWidget::readOptionSetting(const KisPropertiesConfigurationSP setting)
63 {
64     // First invoke superclass behavior.
65     KisCurveOptionWidget::readOptionSetting(setting);
66 
67     KisPressureSpacingOption *option = dynamic_cast<KisPressureSpacingOption*>(curveOption());
68     m_isotropicSpacing->setChecked(option->isotropicSpacing());
69     m_useSpacingUpdates->setChecked(option->usingSpacingUpdates());
70 }
71 
setIsotropicSpacing(int isotropic)72 void KisPressureSpacingOptionWidget::setIsotropicSpacing(int isotropic)
73 {
74     dynamic_cast<KisPressureSpacingOption*>(KisCurveOptionWidget::curveOption())->setIsotropicSpacing(isotropic);
75     emitSettingChanged();
76 }
77 
setUseSpacingUpdates(int useSpacingUpdates)78 void KisPressureSpacingOptionWidget::setUseSpacingUpdates(int useSpacingUpdates)
79 {
80     dynamic_cast<KisPressureSpacingOption*>(KisCurveOptionWidget::curveOption())->setUsingSpacingUpdates(useSpacingUpdates);
81     emitSettingChanged();
82 }
83