diff --git a/plugins/paintops/libpaintop/forms/wdgcurveoption.ui b/plugins/paintops/libpaintop/forms/wdgcurveoption.ui
index a01ffd4d68..ebe74e3cbc 100644
--- a/plugins/paintops/libpaintop/forms/wdgcurveoption.ui
+++ b/plugins/paintops/libpaintop/forms/wdgcurveoption.ui
@@ -1,485 +1,455 @@
WdgCurveOption
0
0
- 503
- 464
+ 318
+ 539
-
15
-
0
0
20
20
16777215
16777215
-
-
-
-
-
-
+
+
+
+ 190
+ 0
+
+
+
+ Enable Pen Settings
+
+
+
+ -
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
- 190
- 0
+ 2
+ 2
+
+
+ -
+
- Enable Pen Settings
+ Share curve across all settings
+
+
+ true
+ -
+
+
-
+
+
+ <html><head/><body>
+<p>Curve calculation mode changes how 2 or more curve works together<br/></p>
+<p> multiply (default): all values from curves multiplies </p><p>(0.8 pressure) * (0.5 speed) = 0.4 <br/></p>
+<p> addition: all values from curves adds</p><p>(0.6 pressure) + (0.3 speed) = 0.9<br/></p>
+<p> maximum value</p><p>(0.7 pressure), (0.3 speed) = 0.7<br/></p>
+<p> minimum value </p><p>(0.7 pressure), (0.3 speed) = 0.3<br/></p>
+<p> difference between min and max values</p><p>(0.8 pressure), (0.3 speed), (0.6 fade) = 0.5</p></body></html>
+
+
+ Curves calculation mode:
+
+
+
+ -
+
+
+ <html><head/><body>
+<p>Curve calculation mode changes how 2 or more curve works together<br/></p>
+<p> multiply (default): all values from curves multiplies </p><p>(0.8 pressure) * (0.5 speed) = 0.4 <br/></p>
+<p> addition: all values from curves adds</p><p>(0.6 pressure) + (0.3 speed) = 0.9<br/></p>
+<p> maximum value</p><p>(0.7 pressure), (0.3 speed) = 0.7<br/></p>
+<p> minimum value </p><p>(0.7 pressure), (0.3 speed) = 0.3<br/></p>
+<p> difference between min and max values</p><p>(0.8 pressure), (0.3 speed), (0.6 fade) = 0.5</p></body></html>
+
+
+ false
+
+
-
+
+ multiply
+
+
+ -
+
+ addition
+
+
+ -
+
+ maximum
+
+
+ -
+
+ minimum
+
+
+ -
+
+ difference
+
+
+
+
+
+
+ -
+
+
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ TextLabel
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 10
+ 10
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ TextLabel
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ TextLabel
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 10
+ 10
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ TextLabel
+
+
+
+
+
+ -
+
+
+
+ 1
+ 0
+
+
+
+
+ 200
+ 200
+
+
+
+
+
+
+
+
+ -
+
-
-
+
24
24
16
16
-
-
+
24
24
16
16
-
24
24
16
16
-
-
+
24
24
16
16
-
-
+
24
24
16
16
-
-
+
24
24
16
16
-
-
+
24
24
16
16
-
24
24
16
16
Ctrl+S
- -
-
-
- Qt::Horizontal
-
-
-
- 2
- 2
-
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 2
- 2
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 2
- 2
-
-
-
-
- -
-
-
- Share curve across all settings
-
-
- true
-
-
-
- -
-
-
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- TextLabel
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 10
- 10
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- TextLabel
-
-
-
-
-
- -
-
-
-
-
-
-
- 0
- 0
-
-
-
- TextLabel
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 10
- 10
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
- TextLabel
-
-
-
-
-
- -
-
-
-
- 1
- 0
-
-
-
-
- 200
- 200
-
-
-
-
-
-
- -
-
-
-
-
-
- <html><head/><body>
-<p>Curve calculation mode changes how 2 or more curve works together<br/></p>
-<p> multiply (default): all values from curves multiplies </p><p>(0.8 pressure) * (0.5 speed) = 0.4 <br/></p>
-<p> addition: all values from curves adds</p><p>(0.6 pressure) + (0.3 speed) = 0.9<br/></p>
-<p> maximum value</p><p>(0.7 pressure), (0.3 speed) = 0.7<br/></p>
-<p> minimum value </p><p>(0.7 pressure), (0.3 speed) = 0.3<br/></p>
-<p> difference between min and max values</p><p>(0.8 pressure), (0.3 speed), (0.6 fade) = 0.5</p></body></html>
-
-
- Curves calculation mode:
-
-
-
- -
-
-
- <html><head/><body>
-<p>Curve calculation mode changes how 2 or more curve works together<br/></p>
-<p> multiply (default): all values from curves multiplies </p><p>(0.8 pressure) * (0.5 speed) = 0.4 <br/></p>
-<p> addition: all values from curves adds</p><p>(0.6 pressure) + (0.3 speed) = 0.9<br/></p>
-<p> maximum value</p><p>(0.7 pressure), (0.3 speed) = 0.7<br/></p>
-<p> minimum value </p><p>(0.7 pressure), (0.3 speed) = 0.3<br/></p>
-<p> difference between min and max values</p><p>(0.8 pressure), (0.3 speed), (0.6 fade) = 0.5</p></body></html>
-
-
- false
-
-
-
-
- multiply
-
-
- -
-
- addition
-
-
- -
-
- maximum
-
-
- -
-
- minimum
-
-
- -
-
- difference
-
-
-
-
-
-
-
-
KisDoubleSliderSpinBox
QWidget
1
KisMultiSensorsSelector
QWidget
kis_multi_sensors_selector.h
1
KisCurveWidget
QWidget
widgets/kis_curve_widget.h
1
diff --git a/plugins/paintops/libpaintop/forms/wdgmultisensorsselector.ui b/plugins/paintops/libpaintop/forms/wdgmultisensorsselector.ui
index 089358361f..9a468c14d7 100644
--- a/plugins/paintops/libpaintop/forms/wdgmultisensorsselector.ui
+++ b/plugins/paintops/libpaintop/forms/wdgmultisensorsselector.ui
@@ -1,28 +1,71 @@
WdgMultiSensorsSelector
0
0
- 400
- 300
+ 274
+ 259
+
+
+ 0
+ 0
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ -
+
+
+ true
+
+
+ Enabled
+
+
+
+
+
-
+
+
+ 0
+ 0
+
+
2
-
-
+
+
+
+ 0
+ 0
+
+
+
diff --git a/plugins/paintops/libpaintop/kis_curve_option_widget.cpp b/plugins/paintops/libpaintop/kis_curve_option_widget.cpp
index 22483bd198..d8560928c7 100644
--- a/plugins/paintops/libpaintop/kis_curve_option_widget.cpp
+++ b/plugins/paintops/libpaintop/kis_curve_option_widget.cpp
@@ -1,303 +1,311 @@
/* This file is part of the KDE project
* Copyright (C) 2008 Boudewijn Rempt
* Copyright (C) 2009 Sven Langkamp
* Copyright (C) 2011 Silvio Heinrich
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kis_curve_option_widget.h"
#include "ui_wdgcurveoption.h"
#include "widgets/kis_curve_widget.h"
#include "kis_dynamic_sensor.h"
#include "kis_global.h"
#include "kis_curve_option.h"
#include "kis_signals_blocker.h"
#include "kis_icon_utils.h"
inline void setLabel(QLabel* label, const KisCurveLabel& curve_label)
{
if (curve_label.icon().isNull()) {
label->setText(curve_label.name());
}
else {
label->setPixmap(QPixmap::fromImage(curve_label.icon()));
}
}
KisCurveOptionWidget::KisCurveOptionWidget(KisCurveOption* curveOption, const QString &minLabel, const QString &maxLabel, bool hideSlider)
: KisPaintOpOption(curveOption->category(), curveOption->isChecked())
, m_widget(new QWidget)
, m_curveOptionWidget(new Ui_WdgCurveOption())
, m_curveOption(curveOption)
{
setObjectName("KisCurveOptionWidget");
m_curveOptionWidget->setupUi(m_widget);
setConfigurationPage(m_widget);
m_curveOptionWidget->sensorSelector->setCurveOption(curveOption);
+ // TODO: Populate the widget with the different sensors
+ // add the checked state to each one
+ // add an "enabled" option to the right for the sensor
+ // hook up the "enabled" option for the selected sensor to track clicks
+ //m_curveOptionWidget->penSensorComboBox
+
+
+
updateSensorCurveLabels(m_curveOptionWidget->sensorSelector->currentHighlighted());
updateCurve(m_curveOptionWidget->sensorSelector->currentHighlighted());
connect(m_curveOptionWidget->curveWidget, SIGNAL(modified()), this, SLOT(transferCurve()));
connect(m_curveOptionWidget->sensorSelector, SIGNAL(parametersChanged()), SLOT(emitSettingChanged()));
connect(m_curveOptionWidget->sensorSelector, SIGNAL(parametersChanged()), SLOT(updateLabelsOfCurrentSensor()));
connect(m_curveOptionWidget->sensorSelector, SIGNAL(highlightedSensorChanged(KisDynamicSensorSP )), SLOT(updateSensorCurveLabels(KisDynamicSensorSP )));
connect(m_curveOptionWidget->sensorSelector, SIGNAL(highlightedSensorChanged(KisDynamicSensorSP )), SLOT(updateCurve(KisDynamicSensorSP )));
connect(m_curveOptionWidget->checkBoxUseSameCurve, SIGNAL(stateChanged(int)), SLOT(transferCurve()));
// set all the icons for the curve preset shapes
updateThemedIcons();
// various curve preset buttons with predefined curves
connect(m_curveOptionWidget->linearCurveButton, SIGNAL(clicked(bool)), this, SLOT(changeCurveLinear()));
connect(m_curveOptionWidget->revLinearButton, SIGNAL(clicked(bool)), this, SLOT(changeCurveReverseLinear()));
connect(m_curveOptionWidget->jCurveButton, SIGNAL(clicked(bool)), this, SLOT(changeCurveJShape()));
connect(m_curveOptionWidget->lCurveButton, SIGNAL(clicked(bool)), this, SLOT(changeCurveLShape()));
connect(m_curveOptionWidget->sCurveButton, SIGNAL(clicked(bool)), this, SLOT(changeCurveSShape()));
connect(m_curveOptionWidget->reverseSCurveButton, SIGNAL(clicked(bool)), this, SLOT(changeCurveReverseSShape()));
connect(m_curveOptionWidget->uCurveButton, SIGNAL(clicked(bool)), this, SLOT(changeCurveUShape()));
connect(m_curveOptionWidget->revUCurveButton, SIGNAL(clicked(bool)), this, SLOT(changeCurveArchShape()));
m_curveOptionWidget->label_ymin->setText(minLabel);
m_curveOptionWidget->label_ymax->setText(maxLabel);
// strength settings is shown as 0-100%
m_curveOptionWidget->strengthSlider->setRange(curveOption->minValue()*100, curveOption->maxValue()*100, 0);
m_curveOptionWidget->strengthSlider->setValue(curveOption->value()*100);
m_curveOptionWidget->strengthSlider->setPrefix(i18n("Strength: "));
m_curveOptionWidget->strengthSlider->setSuffix(i18n("%"));
if (hideSlider) {
m_curveOptionWidget->strengthSlider->hide();
}
connect(m_curveOptionWidget->checkBoxUseCurve, SIGNAL(stateChanged(int)) , SLOT(updateValues()));
connect(m_curveOptionWidget->curveMode, SIGNAL(currentIndexChanged(int)), SLOT(updateMode()));
connect(m_curveOptionWidget->strengthSlider, SIGNAL(valueChanged(qreal)), SLOT(updateValues()));
}
KisCurveOptionWidget::~KisCurveOptionWidget()
{
delete m_curveOption;
delete m_curveOptionWidget;
}
void KisCurveOptionWidget::writeOptionSetting(KisPropertiesConfigurationSP setting) const
{
m_curveOption->writeOptionSetting(setting);
}
void KisCurveOptionWidget::readOptionSetting(const KisPropertiesConfigurationSP setting)
{
//setting->dump();
m_curveOption->readOptionSetting(setting);
m_curveOptionWidget->checkBoxUseCurve->setChecked(m_curveOption->isCurveUsed());
m_curveOptionWidget->strengthSlider->setValue(m_curveOption->value()*100);
m_curveOptionWidget->checkBoxUseSameCurve->setChecked(m_curveOption->isSameCurveUsed());
m_curveOptionWidget->curveMode->setCurrentIndex(m_curveOption->getCurveMode());
disableWidgets(!m_curveOption->isCurveUsed());
m_curveOptionWidget->sensorSelector->reload();
m_curveOptionWidget->sensorSelector->setCurrent(m_curveOption->activeSensors().first());
updateSensorCurveLabels(m_curveOptionWidget->sensorSelector->currentHighlighted());
updateCurve(m_curveOptionWidget->sensorSelector->currentHighlighted());
}
void KisCurveOptionWidget::lodLimitations(KisPaintopLodLimitations *l) const
{
m_curveOption->lodLimitations(l);
}
bool KisCurveOptionWidget::isCheckable() const
{
return m_curveOption->isCheckable();
}
bool KisCurveOptionWidget::isChecked() const
{
return m_curveOption->isChecked();
}
void KisCurveOptionWidget::setChecked(bool checked)
{
m_curveOption->setChecked(checked);
}
KisCurveOption* KisCurveOptionWidget::curveOption()
{
return m_curveOption;
}
QWidget* KisCurveOptionWidget::curveWidget()
{
return m_widget;
}
void KisCurveOptionWidget::transferCurve()
{
m_curveOptionWidget->sensorSelector->setCurrentCurve(m_curveOptionWidget->curveWidget->curve(), m_curveOptionWidget->checkBoxUseSameCurve->isChecked());
emitSettingChanged();
}
void KisCurveOptionWidget::updateSensorCurveLabels(KisDynamicSensorSP sensor)
{
if (sensor) {
m_curveOptionWidget->label_xmin->setText(KisDynamicSensor::minimumLabel(sensor->sensorType()));
m_curveOptionWidget->label_xmax->setText(KisDynamicSensor::maximumLabel(sensor->sensorType(), sensor->length()));
}
}
void KisCurveOptionWidget::updateCurve(KisDynamicSensorSP sensor)
{
if (sensor) {
bool blockSignal = m_curveOptionWidget->curveWidget->blockSignals(true);
m_curveOptionWidget->curveWidget->setCurve(sensor->curve());
m_curveOptionWidget->curveWidget->blockSignals(blockSignal);
}
}
void KisCurveOptionWidget::updateLabelsOfCurrentSensor()
{
updateSensorCurveLabels(m_curveOptionWidget->sensorSelector->currentHighlighted());
updateCurve(m_curveOptionWidget->sensorSelector->currentHighlighted());
}
void KisCurveOptionWidget::updateValues()
{
m_curveOption->setValue(m_curveOptionWidget->strengthSlider->value()/100.0); // convert back to 0-1 for data
m_curveOption->setCurveUsed(m_curveOptionWidget->checkBoxUseCurve->isChecked());
disableWidgets(!m_curveOptionWidget->checkBoxUseCurve->isChecked());
emitSettingChanged();
}
void KisCurveOptionWidget::updateMode()
{
m_curveOption->setCurveMode(m_curveOptionWidget->curveMode->currentIndex());
emitSettingChanged();
}
void KisCurveOptionWidget::changeCurveLinear()
{
QList points;
points.push_back(QPointF(0,0));
points.push_back(QPointF(1,1));
m_curveOptionWidget->curveWidget->setCurve(KisCubicCurve(points));
}
void KisCurveOptionWidget::changeCurveReverseLinear()
{
QList points;
points.push_back(QPointF(0,1));
points.push_back(QPointF(1,0));
m_curveOptionWidget->curveWidget->setCurve(KisCubicCurve(points));
}
void KisCurveOptionWidget::changeCurveSShape()
{
QList points;
points.push_back(QPointF(0,0));
points.push_back(QPointF(0.25,0.1));
points.push_back(QPointF(0.75,0.9));
points.push_back(QPointF(1, 1));
m_curveOptionWidget->curveWidget->setCurve(KisCubicCurve(points));
}
void KisCurveOptionWidget::changeCurveReverseSShape()
{
QList points;
points.push_back(QPointF(0,1));
points.push_back(QPointF(0.25,0.9));
points.push_back(QPointF(0.75,0.1));
points.push_back(QPointF(1,0));
m_curveOptionWidget->curveWidget->setCurve(KisCubicCurve(points));
}
void KisCurveOptionWidget::changeCurveJShape()
{
QList points;
points.push_back(QPointF(0,0));
points.push_back(QPointF(0.35,0.1));
points.push_back(QPointF(1,1));
m_curveOptionWidget->curveWidget->setCurve(KisCubicCurve(points));
}
void KisCurveOptionWidget::changeCurveLShape()
{
QList points;
points.push_back(QPointF(0,1));
points.push_back(QPointF(0.25,0.48));
points.push_back(QPointF(1,0));
m_curveOptionWidget->curveWidget->setCurve(KisCubicCurve(points));
}
void KisCurveOptionWidget::changeCurveUShape()
{
QList points;
points.push_back(QPointF(0,1));
points.push_back(QPointF(0.5,0));
points.push_back(QPointF(1,1));
m_curveOptionWidget->curveWidget->setCurve(KisCubicCurve(points));
}
void KisCurveOptionWidget::changeCurveArchShape()
{
QList points;
points.push_back(QPointF(0,0));
points.push_back(QPointF(0.5,1));
points.push_back(QPointF(1,0));
m_curveOptionWidget->curveWidget->setCurve(KisCubicCurve(points));
}
void KisCurveOptionWidget::disableWidgets(bool disable)
{
m_curveOptionWidget->checkBoxUseSameCurve->setDisabled(disable);
m_curveOptionWidget->curveWidget->setDisabled(disable);
m_curveOptionWidget->sensorSelector->setDisabled(disable);
m_curveOptionWidget->label_xmax->setDisabled(disable);
m_curveOptionWidget->label_xmin->setDisabled(disable);
m_curveOptionWidget->label_ymax->setDisabled(disable);
m_curveOptionWidget->label_ymin->setDisabled(disable);
}
void KisCurveOptionWidget::updateThemedIcons()
{
// set all the icons for the curve preset shapes
m_curveOptionWidget->linearCurveButton->setIcon(KisIconUtils::loadIcon("curve-preset-linear"));
m_curveOptionWidget->revLinearButton->setIcon(KisIconUtils::loadIcon("curve-preset-linear-reverse"));
m_curveOptionWidget->jCurveButton->setIcon(KisIconUtils::loadIcon("curve-preset-j"));
m_curveOptionWidget->lCurveButton->setIcon(KisIconUtils::loadIcon("curve-preset-l"));
m_curveOptionWidget->sCurveButton->setIcon(KisIconUtils::loadIcon("curve-preset-s"));
m_curveOptionWidget->reverseSCurveButton->setIcon(KisIconUtils::loadIcon("curve-preset-s-reverse"));
m_curveOptionWidget->uCurveButton->setIcon(KisIconUtils::loadIcon("curve-preset-u"));
m_curveOptionWidget->revUCurveButton->setIcon(KisIconUtils::loadIcon("curve-preset-arch"));
}
diff --git a/plugins/paintops/libpaintop/kis_multi_sensors_selector.cpp b/plugins/paintops/libpaintop/kis_multi_sensors_selector.cpp
index d8a7eccbf8..aa6a6e75b5 100644
--- a/plugins/paintops/libpaintop/kis_multi_sensors_selector.cpp
+++ b/plugins/paintops/libpaintop/kis_multi_sensors_selector.cpp
@@ -1,103 +1,151 @@
/*
* Copyright (c) 2011 Cyrille Berger
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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_multi_sensors_selector.h"
#include "ui_wdgmultisensorsselector.h"
#include "kis_multi_sensors_model_p.h"
#include "kis_dynamic_sensor.h"
#include "kis_curve_option.h"
+#include "kis_icon_utils.h"
+#include
+#include
+#include
+
struct KisMultiSensorsSelector::Private {
Ui_WdgMultiSensorsSelector form;
KisMultiSensorsModel* model;
QWidget* currentConfigWidget;
QHBoxLayout* layout;
};
KisMultiSensorsSelector::KisMultiSensorsSelector(QWidget* parent)
: QWidget(parent)
, d(new Private)
{
d->currentConfigWidget = 0;
d->form.setupUi(this);
d->model = new KisMultiSensorsModel(this);
connect(d->model, SIGNAL(sensorChanged(KisDynamicSensorSP )), SIGNAL(sensorChanged(KisDynamicSensorSP )));
connect(d->model, SIGNAL(parametersChanged()), SIGNAL(parametersChanged()));
+
+
connect(d->form.sensorsList, SIGNAL(activated(QModelIndex)), SLOT(sensorActivated(QModelIndex)));
- connect(d->form.sensorsList, SIGNAL(clicked(QModelIndex)), SLOT(sensorActivated(QModelIndex)));
+ connect(d->form.sensorsList, SIGNAL(entered(QModelIndex)), SLOT(sensorActivated(QModelIndex)));
+
d->form.sensorsList->setModel(d->model);
+ d->form.penSensorCombobox->setModel(d->model);
+ d->form.penSensorCombobox->setView(d->form.sensorsList);
+
+
+ connect(d->form.currentSensorEnabledCheckbox, SIGNAL(clicked(bool)), this, SLOT(slotSensorEnableChange(bool)));
+
+
d->layout = new QHBoxLayout(d->form.widgetConfiguration);
}
KisMultiSensorsSelector::~KisMultiSensorsSelector()
{
delete d;
}
void KisMultiSensorsSelector::setCurveOption(KisCurveOption *curveOption)
{
d->model->setCurveOption(curveOption);
KisDynamicSensorSP s = curveOption->activeSensors().first();
if (!s) {
s = curveOption->sensors().first();
}
setCurrent(s);
}
void KisMultiSensorsSelector::setCurrent(KisDynamicSensorSP _sensor)
{
d->form.sensorsList->setCurrentIndex(d->model->sensorIndex(_sensor)); // make sure the first element is selected
// HACK ALERT: make sure the signal is delivered to us. Without this line it isn't.
sensorActivated(d->model->sensorIndex(_sensor));
KisDynamicSensorSP sensor = currentHighlighted();
if (!sensor) {
sensor = d->model->getSensor(d->model->index(0, 0));
}
emit(highlightedSensorChanged(sensor));
}
KisDynamicSensorSP KisMultiSensorsSelector::currentHighlighted()
{
return d->model->getSensor(d->form.sensorsList->currentIndex());
}
void KisMultiSensorsSelector::sensorActivated(const QModelIndex& index)
{
delete d->currentConfigWidget;
KisDynamicSensorSP sensor = d->model->getSensor(index);
if (sensor) {
d->currentConfigWidget = sensor->createConfigurationWidget(d->form.widgetConfiguration, this);
if (d->currentConfigWidget) {
d->layout->addWidget(d->currentConfigWidget);
}
+
+ d->form.penSensorCombobox->setCurrentIndex(index.row());
+
+ d->form.currentSensorEnabledCheckbox->setChecked(sensor->isActive());
+
+
+ // how many sensors are active?
+ int sensorsActive = 0;
+ for( int i =0; i <= d->model->rowCount()-1 ; i++) {
+ QModelIndex row = d->model->index(i, 0);
+ KisDynamicSensorSP loopSensor = d->model->getSensor(row);
+ if ( loopSensor->isActive()) {
+ sensorsActive++;
+ }
+ }
+
+ // if the sensor selected is the only one, don't allow the person
+ // to disable it. You need at least one sensor active for it to be valid
+ if (d->form.currentSensorEnabledCheckbox->isChecked() && sensorsActive == 1 ) {
+ d->form.currentSensorEnabledCheckbox->setEnabled(false);
+ } else {
+ d->form.currentSensorEnabledCheckbox->setEnabled(true);
+ }
+
+
emit(highlightedSensorChanged(sensor));
}
}
void KisMultiSensorsSelector::setCurrentCurve(const KisCubicCurve& curve, bool useSameCurve)
{
d->model->setCurrentCurve(d->form.sensorsList->currentIndex(), curve, useSameCurve);
}
void KisMultiSensorsSelector::reload()
{
d->model->resetCurveOption();
}
+
+void KisMultiSensorsSelector::slotSensorEnableChange(bool enabled) {
+ // get current index
+ KisDynamicSensorSP sensor = currentHighlighted();
+
+ // change the data model index so the enabled state is changed
+ sensor->setActive(enabled);
+}
diff --git a/plugins/paintops/libpaintop/kis_multi_sensors_selector.h b/plugins/paintops/libpaintop/kis_multi_sensors_selector.h
index 6537fd60f2..b3d32eae4c 100644
--- a/plugins/paintops/libpaintop/kis_multi_sensors_selector.h
+++ b/plugins/paintops/libpaintop/kis_multi_sensors_selector.h
@@ -1,60 +1,61 @@
/*
* Copyright (c) 2011 Cyrille Berger
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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.
*/
#ifndef KIS_MULTI_SENSORS_SELECTOR_H
#define KIS_MULTI_SENSORS_SELECTOR_H
#include
class KisCubicCurve;
class QModelIndex;
class KisCurveOption;
#include
class KisMultiSensorsSelector : public QWidget
{
Q_OBJECT
public:
KisMultiSensorsSelector(QWidget* parent);
~KisMultiSensorsSelector() override;
void setCurveOption(KisCurveOption *curveOption);
void setCurrent(KisDynamicSensorSP _sensor);
KisDynamicSensorSP currentHighlighted();
void setCurrentCurve(const KisCubicCurve& curve, bool useSameCurve);
void reload();
private Q_SLOTS:
void sensorActivated(const QModelIndex& index);
+ void slotSensorEnableChange(bool enabled);
Q_SIGNALS:
void sensorChanged(KisDynamicSensorSP sensor);
/**
* This signal is emitted when the parameters of sensor are changed.
*/
void parametersChanged();
void highlightedSensorChanged(KisDynamicSensorSP sensor);
private:
struct Private;
Private* const d;
};
#endif