File indexing completed on 2025-01-12 04:00:37
0001 0002 /* 0003 Copyright (c) 2007 Mike Gashler <gashlerm@yahoo.com> 0004 All rights reserved. 0005 0006 Redistribution and use in source and binary forms, with or without 0007 modification, are permitted provided that the following conditions 0008 are met: 0009 0010 1. Redistributions of source code must retain the above copyright 0011 notice, this list of conditions and the following disclaimer. 0012 2. Redistributions in binary form must reproduce the above copyright 0013 notice, this list of conditions and the following disclaimer in the 0014 documentation and/or other materials provided with the distribution. 0015 0016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0020 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0021 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0022 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0023 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0025 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0026 */ 0027 0028 0029 #include "kpEffectHSVWidget.h" 0030 0031 #include <QGridLayout> 0032 #include <QLabel> 0033 0034 #include "kpLogCategories.h" 0035 #include <KLocalizedString> 0036 0037 #include "imagelib/effects/kpEffectHSV.h" 0038 #include "commands/imagelib/effects/kpEffectHSVCommand.h" 0039 0040 0041 kpEffectHSVWidget::kpEffectHSVWidget (bool actOnSelection, QWidget *parent) 0042 : kpEffectWidgetBase (actOnSelection, parent) 0043 { 0044 auto *lay = new QGridLayout (this); 0045 lay->setContentsMargins(0, 0, 0, 0); 0046 0047 auto *hueLabel = new QLabel (i18n ("&Hue:"), this); 0048 auto *saturationLabel = new QLabel (i18n ("&Saturation:"), this); 0049 auto *valueLabel = new QLabel (i18nc ("The V of HSV", "&Value:"), this); 0050 0051 m_hueInput = new kpDoubleNumInput (this); 0052 m_hueInput->setRange (-180, 180, 15/*step*/); 0053 0054 m_saturationInput = new kpDoubleNumInput (this); 0055 m_saturationInput->setRange (-1, 1, 0.1/*step*/); 0056 0057 m_valueInput = new kpDoubleNumInput (this); 0058 m_valueInput->setRange (-1, 1, 0.1/*step*/); 0059 0060 hueLabel->setBuddy (m_hueInput); 0061 saturationLabel->setBuddy (m_saturationInput); 0062 valueLabel->setBuddy (m_valueInput); 0063 0064 lay->addWidget (hueLabel, 0, 0); 0065 lay->addWidget (m_hueInput, 0, 1); 0066 0067 lay->addWidget (saturationLabel, 1, 0); 0068 lay->addWidget (m_saturationInput, 1, 1); 0069 0070 lay->addWidget (valueLabel, 2, 0); 0071 lay->addWidget (m_valueInput, 2, 1); 0072 0073 lay->setColumnStretch (1, 1); 0074 0075 0076 connect (m_hueInput, &kpDoubleNumInput::valueChanged, 0077 this, &kpEffectHSVWidget::settingsChangedDelayed); 0078 0079 connect (m_saturationInput, &kpDoubleNumInput::valueChanged, 0080 this, &kpEffectHSVWidget::settingsChangedDelayed); 0081 0082 connect (m_valueInput, &kpDoubleNumInput::valueChanged, 0083 this, &kpEffectHSVWidget::settingsChangedDelayed); 0084 } 0085 0086 kpEffectHSVWidget::~kpEffectHSVWidget () = default; 0087 0088 0089 // public virtual [base kpEffectWidgetBase] 0090 QString kpEffectHSVWidget::caption () const 0091 { 0092 // TODO: Why doesn't this have a caption? Ditto for the other effects. 0093 return {}; 0094 } 0095 0096 0097 // public virtual [base kpEffectWidgetBase] 0098 bool kpEffectHSVWidget::isNoOp () const 0099 { 0100 return m_hueInput->value () == 0 && m_saturationInput->value () == 0 && m_valueInput->value () == 0; 0101 } 0102 0103 // public virtual [base kpEffectWidgetBase] 0104 kpImage kpEffectHSVWidget::applyEffect (const kpImage &image) 0105 { 0106 return kpEffectHSV::applyEffect (image, 0107 m_hueInput->value (), m_saturationInput->value (), m_valueInput->value ()); 0108 } 0109 0110 // public virtual [base kpEffectWidgetBase] 0111 kpEffectCommandBase *kpEffectHSVWidget::createCommand ( 0112 kpCommandEnvironment *cmdEnviron) const 0113 { 0114 return new kpEffectHSVCommand ( 0115 m_hueInput->value (), m_saturationInput->value (), m_valueInput->value (), 0116 m_actOnSelection, 0117 cmdEnviron); 0118 } 0119 0120 #include "moc_kpEffectHSVWidget.cpp"