File indexing completed on 2024-06-23 04:27:01
0001 /* 0002 * This file is part of Krita 0003 * 0004 * SPDX-FileCopyrightText: 2006 Cyrille Berger <cberger@cberger.net> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #include "kis_wdg_unsharp.h" 0010 #include <QLayout> 0011 #include <QToolButton> 0012 0013 #include <filter/kis_filter.h> 0014 #include <filter/kis_filter_configuration.h> 0015 #include <kis_processing_information.h> 0016 #include <KisGlobalResourcesInterface.h> 0017 0018 #include "ui_wdgunsharp.h" 0019 0020 KisWdgUnsharp::KisWdgUnsharp(QWidget * parent) : KisConfigWidget(parent) 0021 { 0022 m_widget = new Ui_WdgUnsharp(); 0023 m_widget->setupUi(this); 0024 0025 widget()->doubleHalfSize->setRange(0.0, 99.99, 2); 0026 widget()->doubleHalfSize->setSingleStep(1.0); 0027 widget()->doubleAmount->setRange(0.0, 99.99, 2); 0028 widget()->doubleAmount->setSingleStep(0.2); 0029 0030 connect(widget()->doubleHalfSize, SIGNAL(valueChanged(double)), SIGNAL(sigConfigurationItemChanged())); 0031 connect(widget()->doubleAmount, SIGNAL(valueChanged(double)), SIGNAL(sigConfigurationItemChanged())); 0032 connect(widget()->intThreshold, SIGNAL(valueChanged(int)), SIGNAL(sigConfigurationItemChanged())); 0033 connect(widget()->chkLightnessOnly, SIGNAL(stateChanged(int)), SIGNAL(sigConfigurationItemChanged())); 0034 } 0035 0036 KisWdgUnsharp::~KisWdgUnsharp() 0037 { 0038 delete m_widget; 0039 } 0040 0041 void KisWdgUnsharp::setConfiguration(const KisPropertiesConfigurationSP config) 0042 { 0043 QVariant value; 0044 widget()->doubleHalfSize->setValue((config->getProperty("halfSize", value)) ? value.toDouble() : 1.0); 0045 widget()->doubleAmount->setValue((config->getProperty("amount", value)) ? value.toDouble() : 0.0); 0046 widget()->intThreshold->setValue((config->getProperty("threshold", value)) ? value.toUInt() : 2); 0047 widget()->chkLightnessOnly->setChecked((config->getProperty("lightnessOnly", value)) ? value.toBool() : true); 0048 } 0049 0050 KisPropertiesConfigurationSP KisWdgUnsharp::configuration() const 0051 { 0052 KisFilterConfigurationSP config = new KisFilterConfiguration("unsharp", 1, KisGlobalResourcesInterface::instance()); 0053 config->setProperty("halfSize", widget()->doubleHalfSize->value()); 0054 config->setProperty("amount", widget()->doubleAmount->value()); 0055 config->setProperty("threshold", widget()->intThreshold->value()); 0056 config->setProperty("lightnessOnly", widget()->chkLightnessOnly->isChecked()); 0057 return config; 0058 } 0059 0060