diff --git a/plugins/filters/colors/kis_wdg_color_to_alpha.cpp b/plugins/filters/colors/kis_wdg_color_to_alpha.cpp index 03d233207d..c07b3d7a6c 100644 --- a/plugins/filters/colors/kis_wdg_color_to_alpha.cpp +++ b/plugins/filters/colors/kis_wdg_color_to_alpha.cpp @@ -1,127 +1,125 @@ /* * This file is part of Krita * * Copyright (c) 2006 Cyrille Berger * * 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_color_to_alpha.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ui_wdgcolortoalphabase.h" KisWdgColorToAlpha::KisWdgColorToAlpha(QWidget * parent) : KisConfigWidget(parent), m_view(0) { m_widget = new Ui_WdgColorToAlphaBase(); m_widget->setupUi(this); m_widget->textLabel1->hide(); m_widget->intThreshold->setRange(1, 255, 0); connect(m_widget->colorSelector, SIGNAL(sigNewColor(KoColor)), SLOT(slotColorSelectorChanged(const KoColor&))); connect(m_widget->intThreshold, SIGNAL(valueChanged(qreal)), SIGNAL(sigConfigurationItemChanged())); connect(m_widget->btnCustomColor, SIGNAL(changed(const KoColor)), SLOT(slotCustomColorSelected(const KoColor&))); KoColor c(Qt::white, KoColorSpaceRegistry::instance()->rgb8()); m_widget->btnCustomColor->setColor(c); } KisWdgColorToAlpha::~KisWdgColorToAlpha() { delete m_widget; } void KisWdgColorToAlpha::setView(KisViewManager *view) { m_view = view; } void KisWdgColorToAlpha::slotFgColorChanged(const KoColor &color) { m_widget->btnCustomColor->setColor(color); } void KisWdgColorToAlpha::slotColorSelectorChanged(const KoColor &color) { m_widget->btnCustomColor->setColor(color); } void KisWdgColorToAlpha::slotCustomColorSelected(const KoColor &color) { KoColor c(color, KoColorSpaceRegistry::instance()->rgb8()); m_widget->colorSelector->slotSetColor(color); emit sigConfigurationItemChanged(); } void KisWdgColorToAlpha::setConfiguration(const KisPropertiesConfigurationSP config) { QVariant value; if (config->getProperty("targetcolor", value)) { KoColor c; if (value.value().isValid()) { c = KoColor(value.value(), KoColorSpaceRegistry::instance()->rgb8()); } else { c = value.value(); } m_widget->colorSelector->slotSetColor(c); } if (config->getProperty("threshold", value)) { m_widget->intThreshold->setValue(value.toInt()); } } KisPropertiesConfigurationSP KisWdgColorToAlpha::configuration() const { KisFilterConfigurationSP config = new KisFilterConfiguration("colortoalpha", 1); config->setProperty("targetcolor", widget()->colorSelector->getCurrentColor().toQColor()); config->setProperty("threshold", widget()->intThreshold->value()); return config; } void KisWdgColorToAlpha::hideEvent(QHideEvent *) { if (m_view) { disconnect(m_view->resourceProvider(), SIGNAL(sigFGColorChanged(const KoColor&)), this, SLOT(slotFgColorChanged(const KoColor&))); - KoToolManager::instance()->switchBackRequested(); } } void KisWdgColorToAlpha::showEvent(QShowEvent *) { if (m_view) { connect(m_view->resourceProvider(), SIGNAL(sigFGColorChanged(const KoColor&)), this, SLOT(slotFgColorChanged(const KoColor&))); - KoToolManager::instance()->switchToolTemporaryRequested("KritaSelected/KisToolColorPicker"); } }