diff --git a/krita/plugins/extensions/dockers/colorslider/kis_color_slider_input.cpp b/krita/plugins/extensions/dockers/colorslider/kis_color_slider_input.cpp index fba99113024..2ec33a33579 100644 --- a/krita/plugins/extensions/dockers/colorslider/kis_color_slider_input.cpp +++ b/krita/plugins/extensions/dockers/colorslider/kis_color_slider_input.cpp @@ -1,709 +1,708 @@ /* * Copyright (c) 2008 Cyrille Berger * Copyright (c) 2014 Wolthera van Hövell * Copyright (c) 2015 Moritz Molch * * 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; version 2.1 of the License. * * 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_color_slider_input.h" #include #ifdef HAVE_OPENEXR #include #endif #include #include #include #include #include #include #include #include #include #include #include #include "kis_hsv_slider.h" #include "kis_display_color_converter.h" KisColorSliderInput::KisColorSliderInput(QWidget* parent, KoColor* color, const int type, KoColorDisplayRendererInterface *displayRenderer, KisCanvas2* canvas) : QWidget(parent), m_type(type), m_color(color), m_displayRenderer(displayRenderer), m_canvas(canvas) { //init } void KisColorSliderInput::init() { QHBoxLayout* m_layout = new QHBoxLayout(this); m_layout->setContentsMargins(0, 0, 0, 0); m_layout->setSpacing(1); QString m_name; switch (m_type){ case 0: m_name=i18n("Hue"); break; case 1: m_name=i18n("Saturation"); break; case 2: m_name=i18n("Value"); break; case 3: m_name=i18n("Hue"); break; case 4: m_name=i18n("Saturation"); break; case 5: m_name=i18n("Lightness"); break; case 6: m_name=i18n("Hue"); break; case 7: m_name=i18n("Saturation"); break; case 8: m_name=i18n("Intensity"); break; case 9: m_name=i18n("Hue"); break; case 10: m_name=i18n("Saturation"); break; case 11: m_name=i18n("Luma"); break; } QLabel* m_label = new QLabel(i18n("%1:", m_name), this); - m_label->setMinimumWidth(60); m_layout->addWidget(m_label); m_hsvSlider = new KisHSVSlider(Qt::Horizontal, this, m_displayRenderer, m_canvas); m_hsvSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); m_layout->addWidget(m_hsvSlider); connect (m_hsvSlider, SIGNAL(sliderPressed()), SLOT(sliderIn())); connect (m_hsvSlider, SIGNAL(sliderReleased()), SLOT(sliderOut())); QWidget* m_input = createInput(); m_hsvSlider->setFixedHeight(m_input->sizeHint().height()); m_layout->addWidget(m_input); } KisHSXColorSliderInput::KisHSXColorSliderInput(QWidget* parent, const int type, KoColor* color, KoColorDisplayRendererInterface *displayRenderer, KisCanvas2* canvas) : KisColorSliderInput(parent, color, type, displayRenderer, canvas), m_canvas(canvas), m_hue(0), m_sat(0), m_val(0), R(0), G(0), B(0) { m_hueupdating = false; m_satupdating = false; m_toneupdating = false; m_sliderisupdating = false; init(); } void KisHSXColorSliderInput::setValue(double v) { //This function returns the colour based on the type of the slider as well as the value// qreal h=0.0; qreal s=0.0; qreal l=0.0; KConfigGroup cfg = KGlobal::config()->group("advancedColorSelector"); R = cfg.readEntry("lumaR", 0.2126); G = cfg.readEntry("lumaG", 0.7152); B = cfg.readEntry("lumaB", 0.0722); switch (m_type) { case 0: m_hue = v; h=m_hue/360.0; s=m_sat/100.0; l=m_val/100.0; *m_color = this->converter()->fromHsvF(h, s, l); if (m_hueupdating==false) { emit(hueUpdated(static_cast(m_hue))); } else { m_hueupdating=false; } break; case 3: m_hue = v; h=m_hue/360.0; s=m_sat/100.0; l=m_val/100.0; *m_color = this->converter()->fromHslF(h, s, l); if (m_hueupdating==false) { emit(hueUpdated(static_cast(m_hue))); } else { m_hueupdating=false; } break; case 6: m_hue = v; h=m_hue/360.0; s=m_sat/100.0; l=m_val/100.0; *m_color = this->converter()->fromHsiF(h, s, l); if (m_hueupdating==false) { emit(hueUpdated(static_cast(m_hue))); } else { m_hueupdating=false; } break; case 9: m_hue = v; h=m_hue/360.0f; s=m_sat/100.0f; l=m_val/100.0f; *m_color = this->converter()->fromHsyF(h, s, l, R, G, B); if (m_hueupdating==false) { emit(hueUpdated(static_cast(m_hue))); } else { m_hueupdating=false; } break; case 1: m_sat = v; h=m_hue/360.0f; s=m_sat/100.0f; l=m_val/100.0f; *m_color = this->converter()->fromHsvF(h, s, l); if (m_satupdating==false) { emit(satUpdated(static_cast(m_sat), m_type)); } else { m_satupdating=false; } break; case 2: m_val = v; h=m_hue/360.0f; s=m_sat/100.0f; l=m_val/100.0f; *m_color = this->converter()->fromHsvF(h, s, l); if (m_toneupdating==false) { emit(toneUpdated(static_cast(m_val), m_type)); } else { m_toneupdating=false; } break; case 4: m_sat = v; h=m_hue/360.0f; s=m_sat/100.0f; l=m_val/100.0f; *m_color = this->converter()->fromHslF(h, s, l); if (m_satupdating==false) { emit(satUpdated(static_cast(m_sat), m_type)); } else { m_satupdating=false; } break; case 5: m_val = v; h=m_hue/360.0f; s=m_sat/100.0f; l=m_val/100.0f; *m_color = this->converter()->fromHslF(h, s, l); if (m_toneupdating==false) { emit(toneUpdated(static_cast(m_val), m_type)); } else { m_toneupdating=false; } break; case 7: m_sat = v; h=m_hue/360.0f; s=m_sat/100.0f; l=m_val/100.0f; *m_color = this->converter()->fromHsiF(h, s, l); if (m_satupdating==false) { emit(satUpdated(static_cast(m_sat), m_type)); } else { m_satupdating=false; } break; case 8: m_val = v; h=m_hue/360.0f; s=m_sat/100.0f; l=m_val/100.0f; *m_color = this->converter()->fromHsiF(h, s, l); if (m_toneupdating==false) { emit(toneUpdated(static_cast(m_val), m_type)); } else { m_toneupdating=false; } break; case 10: m_sat = v; h=m_hue/360.0f; s=m_sat/100.0f; l=m_val/100.0f; *m_color = this->converter()->fromHsyF(h, s, l, R, G, B); if (m_satupdating==false) { emit(satUpdated(static_cast(m_sat), m_type)); } else { m_satupdating=false; } break; case 11: m_val = v; h=m_hue/360.0f; s=m_sat/100.0f; l=m_val/100.0f; *m_color = this->converter()->fromHsyF(h, s, l, R, G, B); if (m_toneupdating==false) { emit(toneUpdated(static_cast(m_val), m_type)); } else { m_toneupdating=false; } break; default: Q_ASSERT(false); } emit(updated()); } //update void KisHSXColorSliderInput::update() { KoColor min = *m_color; KoColor max = *m_color; qreal hue, sat, val, hue_backup, sat_backup, val_backup; //gets the hsv for the appropriate type// hue_backup = m_hue; sat_backup = m_sat; val_backup = m_val; switch (m_type) { case 0: this->converter()->getHsvF(*m_color, &hue, &sat, &val); if (m_sliderisupdating==true) { if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } if((val*100.0)m_val-2) { val = (val_backup*0.01); } } else{ if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } } break; case 1: this->converter()->getHsvF(*m_color, &hue, &sat, &val); if (m_sliderisupdating==true) { if( (hue*360.0)m_hue-2 ) { hue = (hue_backup/360.0); } if((val*100.0)m_val-2) { val = (val_backup*0.01); } } else{ if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } } break; case 2: this->converter()->getHsvF(*m_color, &hue, &sat, &val); if (m_sliderisupdating==true) { if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } } else{ if((val*100.0)m_val-2) { val = (val_backup*0.01); } } break; case 3: this->converter()->getHslF(*m_color, &hue, &sat, &val); if (m_sliderisupdating==true) { if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } if((val*100.0)m_val-2) { val = (val_backup*0.01); } } else{ if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } } break; case 4: this->converter()->getHslF(*m_color, &hue, &sat, &val); if (m_sliderisupdating==true) { if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } if((val*100.0)m_val-2) { val = (val_backup*0.01); } } else{ if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } } break; case 5: this->converter()->getHslF(*m_color, &hue, &sat, &val); if (m_sliderisupdating==true) { if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } } else{ if((val*100.0)m_val-2) { val = (val_backup*0.01); } } break; case 6: this->converter()->getHsiF(*m_color, &hue, &sat, &val); if (m_sliderisupdating==true) { if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } if((val*100.0)m_val-2) { val = (val_backup*0.01); } } else{ if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } } break; case 7: this->converter()->getHsiF(*m_color, &hue, &sat, &val); if (m_sliderisupdating==true) { if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } if((val*100.0)m_val-2) { val = (val_backup*0.01); } } else{ if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } } break; case 8: this->converter()->getHsiF(*m_color, &hue, &sat, &val); if (m_sliderisupdating==true) { if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } } else{ if((val*100.0)m_val-2) { val = (val_backup*0.01); } } break; case 9: this->converter()->getHsyF(*m_color, &hue, &sat, &val, R, G, B); if (m_sliderisupdating==true) { if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } if((val*100.0)m_val-2) { val = (val_backup*0.01); } } else{ if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } } break; case 10: this->converter()->getHsyF(*m_color, &hue, &sat, &val, R, G, B); if (m_sliderisupdating==true) { if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } if((val*100.0)m_val-2) { val = (val_backup*0.01); } } else{ if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } } break; case 11: this->converter()->getHsyF(*m_color, &hue, &sat, &val, R, G, B); if (m_sliderisupdating == true) { if((sat*100.0)m_sat-2) { sat = (sat_backup*0.01); } if((hue*360.0)m_hue-2) { hue = (hue_backup/360.0); } } else{ if((val*100.0)m_val-2) { val = (val_backup*0.01); } } break; } //this prevents the hue going to 0 when used with grey// if (sat<=0.0) { m_hue = hue_backup; } else{ m_hue=(hue*360.0); } if (val==0 || val>0.999) { m_sat = sat_backup; } else{ m_sat=(sat*100.0); } m_val=(val*100.0); if (m_hueupdating==true){m_val=val_backup; m_sat = sat_backup; m_hueupdating=false;} else if (m_satupdating==true){m_val=val_backup; m_hue = hue_backup; m_satupdating=false;} else if (m_toneupdating==true){m_sat=sat_backup; m_hue = hue_backup;m_toneupdating=false;} //sets slider and num-input according to type// switch (m_type) { case 0: case 3: case 6: case 9: m_NumInput->setValue(m_hue); m_hsvSlider->setValue(static_cast(m_hue)); break; case 1: m_NumInput->setValue(m_sat); m_hsvSlider->setValue(static_cast(m_sat)); break; case 2: m_NumInput->setValue(m_val); m_hsvSlider->setValue(static_cast(m_val)); break; case 4: m_NumInput->setValue(m_sat); m_hsvSlider->setValue(static_cast(m_sat)); break; case 5: m_NumInput->setValue(m_val); m_hsvSlider->setValue(static_cast(m_val)); break; case 7: m_NumInput->setValue(m_sat); m_hsvSlider->setValue(static_cast(m_sat)); break; case 8: m_NumInput->setValue(m_val); m_hsvSlider->setValue(static_cast(m_val)); break; case 10: m_NumInput->setValue(m_sat); m_hsvSlider->setValue(static_cast(m_sat)); break; case 11: m_NumInput->setValue(m_val); m_hsvSlider->setValue(static_cast(m_val)); break; default: Q_ASSERT(false); } m_hsvSlider->setColors(*m_color,m_type, m_hue, R, G, B); } QWidget* KisHSXColorSliderInput::createInput() { m_NumInput = new QDoubleSpinBox(this); m_NumInput->setMinimum(0); m_NumInput->setMaximum(100.0); m_NumInput->setKeyboardTracking(false);//this makes sure that only full values are sent after loss of focus. Much more user friendly// m_hsvSlider->setMaximum(100); switch (m_type) { case 0: case 3: case 6: case 9: m_NumInput->setMaximum(360.0); m_NumInput->setWrapping(true); m_hsvSlider->setMaximum(360); m_NumInput->setSingleStep (5.0); break; case 1: case 2: case 4: case 5: case 7: case 8: case 10: case 11: m_NumInput->setMaximum(100.0); m_hsvSlider->setMaximum(100); m_NumInput->setSingleStep (10.0); break; default: Q_ASSERT(false); } connect(m_hsvSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int))); connect(m_NumInput, SIGNAL(valueChanged(double)), this, SLOT(numInputChanged(double))); return m_NumInput; } void KisHSXColorSliderInput::sliderChanged(int i) { m_NumInput->setValue(i*1.0); setValue(i*1.0); } void KisHSXColorSliderInput::sliderIn(){ m_sliderisupdating=true; } void KisHSXColorSliderInput::sliderOut(){ m_sliderisupdating=false; } //attempt at getting rid of dancing sliders... #2859 //The nminput should not be changing the sliders if the sliders are the one changing the input. //As numinpit rounds off at 2 decimals(and there's no point at letting it continue the signal circle). void KisHSXColorSliderInput::numInputChanged(double v) { if (m_sliderisupdating==true){ return; } else { setValue(v); } } //this connects to the display converter. Important for OCIO, breaks on missing of m_canvas somehow. KisDisplayColorConverter* KisHSXColorSliderInput::converter() const { return m_canvas ? m_canvas->displayColorConverter() : KisDisplayColorConverter::dumbConverterInstance(); } void KisHSXColorSliderInput::hueUpdate(int h) { if (h<=m_hue-2 || h>=m_hue+2) { m_hue=h; m_hueupdating=true; update(); } } void KisHSXColorSliderInput::satUpdate(int s, int type) { if (m_type==type+1 || m_type==type-1) { if (s<=m_sat-3 || s>=m_sat+3) { m_sat=s; m_satupdating=true; update(); } } } void KisHSXColorSliderInput::toneUpdate(int l, int type) { if (m_type==type-1 || m_type==type-2) { if (l<25 || l>75){ if (l<=m_val-10 || l>=m_val+10) { m_val=l; m_toneupdating=true; update(); } } else { if (l<=m_val-3 || l>=m_val+3) { m_val=l; m_toneupdating=true; update(); } } } } #include "kis_color_slider_input.moc" diff --git a/krita/plugins/extensions/dockers/colorslider/kis_color_slider_widget.cpp b/krita/plugins/extensions/dockers/colorslider/kis_color_slider_widget.cpp index a6a5bc23c86..74efb3ca3c6 100644 --- a/krita/plugins/extensions/dockers/colorslider/kis_color_slider_widget.cpp +++ b/krita/plugins/extensions/dockers/colorslider/kis_color_slider_widget.cpp @@ -1,455 +1,483 @@ /* * Copyright (c) 2008 Cyrille Berger * Copyright (c) 2014 Wolthera van Hövell * Copyright (c) 2015 Moritz Molch * * 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; version 2.1 of the License. * * 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_color_slider_widget.h" #include #include #include #include #include #include #include #include #include #include #include #include "kis_color_slider_input.h" #include #include "kis_debug.h" #include "kis_signal_compressor.h" //#include "kis_color_space_selector.h" KisColorSliderWidget::KisColorSliderWidget(KoColorDisplayRendererInterface *displayRenderer, QWidget* parent, KisCanvas2* canvas, QBitArray SlidersConfigArray) : QWidget(parent) //, m_colorSpace(0) //, m_customColorSpaceSelected(false) , m_updateCompressor(new KisSignalCompressor(10, KisSignalCompressor::POSTPONE, this)) , m_displayRenderer(displayRenderer) , m_canvas(canvas) { m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(0,0,0,0); m_layout->setSpacing(1); m_updateAllowed = true; connect(m_updateCompressor, SIGNAL(timeout()), SLOT(updateTimeout())); m_configCompressor = new KisSignalCompressor(10, KisSignalCompressor::POSTPONE, this); connect(m_configCompressor, SIGNAL(timeout()), SLOT(setConfig())); //qDebug()<<"m_canvas:"<addWidget(hsvH); hsvH->setVisible(false); hsvS = new KisHSXColorSliderInput(this, 1, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hsvS); m_layout->addWidget(hsvS); hsvS->setVisible(false); hsvV = new KisHSXColorSliderInput(this, 2, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hsvV); m_layout->addWidget(hsvV); hsvV->setVisible(false); //hsl sliders// hslH = new KisHSXColorSliderInput(this, 3, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hslH); m_layout->addWidget(hslH); hslH->setVisible(false); hslS = new KisHSXColorSliderInput(this, 4, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hslS); m_layout->addWidget(hslS); hslS->setVisible(false); hslL = new KisHSXColorSliderInput(this, 5, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hslL); m_layout->addWidget(hslL); hslL->setVisible(false); //hsi sliders// hsiH = new KisHSXColorSliderInput(this, 6, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hsiH); m_layout->addWidget(hsiH); hsiH->setVisible(false); hsiS = new KisHSXColorSliderInput(this, 7, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hsiS); m_layout->addWidget(hsiS); hsiS->setVisible(false); hsiI = new KisHSXColorSliderInput(this, 8, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hsiI); m_layout->addWidget(hsiI); hsiI->setVisible(false); //hsy'sliders// hsyH = new KisHSXColorSliderInput(this, 9, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hsyH); m_layout->addWidget(hsyH); hsyH->setVisible(false); hsyS = new KisHSXColorSliderInput(this, 10, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hsyS); m_layout->addWidget(hsyS); hsyS->setVisible(false); hsyY = new KisHSXColorSliderInput(this, 11, &m_color, m_displayRenderer, m_canvas); m_inputs.append(hsyY); m_layout->addWidget(hsyY); hsyY->setVisible(false); m_layout->addStretch(1); setSlidersVisible(SlidersConfigArray); } KisColorSliderWidget::~KisColorSliderWidget() { //KConfigGroup cfg = KGlobal::config()->group(""); //cfg.writeEntry("SpecificColorSelector/ShowColorSpaceSelector", m_chkShowColorSpaceSelector->isChecked()); } void KisColorSliderWidget::update() { if (m_updateAllowed) { m_updateCompressor->start(); } } void KisColorSliderWidget::setColor(const KoColor& c) { m_updateAllowed = false; m_color.fromKoColor(c); emit(updated()); m_updateAllowed = true; } void KisColorSliderWidget::updateTimeout() { emit(colorChanged(m_color)); } void KisColorSliderWidget::setSlidersVisible(QBitArray SlidersConfigArray) { //qDebug()<<"check2"; + QList visibleInputs; if (SlidersConfigArray[0]==true) { + visibleInputs.append(hsvH); hsvH->setVisible(true); connect(hsvH, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hsvH, SLOT(update())); connect(hsvH, SIGNAL(hueUpdated(int)), this, SLOT(hueUpdate(int))); connect(this, SIGNAL(hueUpdated(int)), hsvH, SLOT(hueUpdate(int))); connect(this, SIGNAL(satUpdated(int, int)), hsvH, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hsvH, SLOT(toneUpdate(int, int))); } else { hsvH->setVisible(false); disconnect(hsvH, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hsvH, SLOT(update())); disconnect(hsvH, SIGNAL(hueUpdated(int)), this, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(hueUpdated(int)), hsvH, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(satUpdated(int, int)), hsvH, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hsvH, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[1]==true) { + visibleInputs.append(hsvS); hsvS->setVisible(true); connect(hsvS, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hsvS, SLOT(update())); connect(this, SIGNAL(hueUpdated(int)), hsvS, SLOT(hueUpdate(int))); connect(hsvS, SIGNAL(satUpdated(int, int)), this, SLOT(satUpdate(int, int))); connect(this, SIGNAL(satUpdated(int, int)), hsvS, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hsvS, SLOT(toneUpdate(int, int))); } else { hsvS->setVisible(false); disconnect(hsvS, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hsvS, SLOT(update())); disconnect(this, SIGNAL(hueUpdated(int)), hsvS, SLOT(hueUpdate(int))); disconnect(hsvS, SIGNAL(satUpdated(int, int)), this, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(satUpdated(int, int)), hsvS, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hsvS, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[2]==true) { + visibleInputs.append(hsvV); hsvV->setVisible(true); connect(hsvV, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hsvV, SLOT(update())); connect(this, SIGNAL(hueUpdated(int)), hsvV, SLOT(hueUpdate(int))); connect(this, SIGNAL(satUpdated(int, int)), hsvV, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hsvV, SLOT(toneUpdate(int, int))); connect(hsvV, SIGNAL(toneUpdated(int, int)), this, SLOT(toneUpdate(int, int))); } else { hsvV->setVisible(false); disconnect(hsvV, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hsvV, SLOT(update())); disconnect(this, SIGNAL(hueUpdated(int)), hsvV, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(satUpdated(int, int)), hsvV, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hsvV, SLOT(toneUpdate(int, int))); disconnect(hsvV, SIGNAL(toneUpdated(int, int)), this, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[3]==true) { + visibleInputs.append(hslH); hslH->setVisible(true); connect(hslH, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hslH, SLOT(update())); connect(hslH, SIGNAL(hueUpdated(int)), this, SLOT(hueUpdate(int))); connect(this, SIGNAL(hueUpdated(int)), hslH, SLOT(hueUpdate(int))); connect(this, SIGNAL(satUpdated(int, int)), hslH, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hslH, SLOT(toneUpdate(int, int))); } else { hslH->setVisible(false); disconnect(hslH, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hslH, SLOT(update())); disconnect(hslH, SIGNAL(hueUpdated(int)), this, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(hueUpdated(int)), hslH, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(satUpdated(int, int)), hslH, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hslH, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[4]==true) { + visibleInputs.append(hslS); hslS->setVisible(true); connect(hslS, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hslS, SLOT(update())); connect(this, SIGNAL(hueUpdated(int)), hslS, SLOT(hueUpdate(int))); connect(hslS, SIGNAL(satUpdated(int, int)), this, SLOT(satUpdate(int, int))); connect(this, SIGNAL(satUpdated(int, int)), hslS, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hslS, SLOT(toneUpdate(int, int))); } else { hslS->setVisible(false); disconnect(hslS, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hslS, SLOT(update())); disconnect(this, SIGNAL(hueUpdated(int)), hslS, SLOT(hueUpdate(int))); disconnect(hslS, SIGNAL(satUpdated(int, int)), this, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(satUpdated(int, int)), hslS, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hslS, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[5]==true) { + visibleInputs.append(hslL); hslL->setVisible(true); connect(hslL, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hslL, SLOT(update())); connect(this, SIGNAL(hueUpdated(int)), hslL, SLOT(hueUpdate(int))); connect(this, SIGNAL(satUpdated(int, int)), hslL, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hslL, SLOT(toneUpdate(int, int))); connect(hslL, SIGNAL(toneUpdated(int, int)), this, SLOT(toneUpdate(int, int))); } else { hslL->setVisible(false); disconnect(hslL, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hslL, SLOT(update())); disconnect(this, SIGNAL(hueUpdated(int)), hslL, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(satUpdated(int, int)), hslL, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hslL, SLOT(toneUpdate(int, int))); disconnect(hslL, SIGNAL(toneUpdated(int, int)), this, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[6]==true) { + visibleInputs.append(hsiH); hsiH->setVisible(true); connect(hsiH, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hsiH, SLOT(update())); connect(hsiH, SIGNAL(hueUpdated(int)), this, SLOT(hueUpdate(int))); connect(this, SIGNAL(hueUpdated(int)), hsiH, SLOT(hueUpdate(int))); connect(this, SIGNAL(satUpdated(int, int)), hsiH, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hsiH, SLOT(toneUpdate(int, int))); } else { hsiH->setVisible(false); disconnect(hsiH, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hsiH, SLOT(update())); disconnect(hsiH, SIGNAL(hueUpdated(int)), this, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(hueUpdated(int)), hsiH, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(satUpdated(int, int)), hsiH, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hsiH, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[7]==true) { + visibleInputs.append(hsiS); hsiS->setVisible(true); connect(hsiS, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hsiS, SLOT(update())); connect(this, SIGNAL(hueUpdated(int)), hsiS, SLOT(hueUpdate(int))); connect(hsiS, SIGNAL(satUpdated(int, int)), this, SLOT(satUpdate(int, int))); connect(this, SIGNAL(satUpdated(int, int)), hsiS, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hsiS, SLOT(toneUpdate(int, int))); } else { hsiS->setVisible(false); disconnect(hsiS, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hsiS, SLOT(update())); disconnect(this, SIGNAL(hueUpdated(int)), hsiS, SLOT(hueUpdate(int))); disconnect(hsiS, SIGNAL(satUpdated(int, int)), this, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(satUpdated(int, int)), hsiS, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hsiS, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[8]==true) { + visibleInputs.append(hsiI); hsiI->setVisible(true); connect(hsiI, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hsiI, SLOT(update())); connect(this, SIGNAL(hueUpdated(int)), hsiI, SLOT(hueUpdate(int))); connect(this, SIGNAL(satUpdated(int, int)), hsiI, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hsiI, SLOT(toneUpdate(int, int))); connect(hsiI, SIGNAL(toneUpdated(int, int)), this, SLOT(toneUpdate(int, int))); } else { hsiI->setVisible(false); disconnect(hsiI, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hsiI, SLOT(update())); disconnect(this, SIGNAL(hueUpdated(int)), hsiI, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(satUpdated(int, int)), hsiI, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hsiI, SLOT(toneUpdate(int, int))); disconnect(hsiI, SIGNAL(toneUpdated(int, int)), this, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[9]==true) { + visibleInputs.append(hsyH); hsyH->setVisible(true); connect(hsyH, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hsyH, SLOT(update())); connect(hsyH, SIGNAL(hueUpdated(int)), this, SLOT(hueUpdate(int))); connect(this, SIGNAL(hueUpdated(int)), hsyH, SLOT(hueUpdate(int))); connect(this, SIGNAL(satUpdated(int, int)), hsyH, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hsyH, SLOT(toneUpdate(int, int))); } else { hsyH->setVisible(false); disconnect(hsyH, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hsyH, SLOT(update())); disconnect(hsyH, SIGNAL(hueUpdated(int)), this, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(hueUpdated(int)), hsyH, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(satUpdated(int, int)), hsyH, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hsyH, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[10]==true) { + visibleInputs.append(hsyS); hsyS->setVisible(true); connect(hsyS, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hsyS, SLOT(update())); connect(this, SIGNAL(hueUpdated(int)), hsyS, SLOT(hueUpdate(int))); connect(hsyS, SIGNAL(satUpdated(int, int)), this, SLOT(satUpdate(int, int))); connect(this, SIGNAL(satUpdated(int, int)), hsyS, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hsyS, SLOT(toneUpdate(int, int))); } else { hsyS->setVisible(false); disconnect(hsyS, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hsyS, SLOT(update())); disconnect(this, SIGNAL(hueUpdated(int)), hsyS, SLOT(hueUpdate(int))); disconnect(hsyS, SIGNAL(satUpdated(int, int)), this, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(satUpdated(int, int)), hsyS, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hsyS, SLOT(toneUpdate(int, int))); } if (SlidersConfigArray[11]==true) { + visibleInputs.append(hsyY); hsyY->setVisible(true); connect(hsyY, SIGNAL(updated()), this, SLOT(update())); connect(this, SIGNAL(updated()), hsyY, SLOT(update())); connect(this, SIGNAL(hueUpdated(int)), hsyY, SLOT(hueUpdate(int))); connect(this, SIGNAL(satUpdated(int, int)), hsyY, SLOT(satUpdate(int, int))); connect(this, SIGNAL(toneUpdated(int, int)), hsyY, SLOT(toneUpdate(int, int))); connect(hsyY, SIGNAL(toneUpdated(int, int)), this, SLOT(toneUpdate(int, int))); } else { hsyY->setVisible(false); disconnect(hsyY, SIGNAL(updated()), this, SLOT(update())); disconnect(this, SIGNAL(updated()), hsyY, SLOT(update())); disconnect(this, SIGNAL(hueUpdated(int)), hsyY, SLOT(hueUpdate(int))); disconnect(this, SIGNAL(satUpdated(int, int)), hsyY, SLOT(satUpdate(int, int))); disconnect(this, SIGNAL(toneUpdated(int, int)), hsyY, SLOT(toneUpdate(int, int))); disconnect(hsyY, SIGNAL(toneUpdated(int, int)), this, SLOT(toneUpdate(int, int))); } + QList labels; + int labelWidth = 0; + + Q_FOREACH (KisColorSliderInput* input, visibleInputs) { + Q_FOREACH (QLabel* label, input->findChildren()) { + labels.append(label); + labelWidth = qMax(labelWidth, label->sizeHint().width()); + } + } + + Q_FOREACH (QLabel *label, labels) { + label->setMinimumWidth(labelWidth); + } + + updateTimeout(); } void KisColorSliderWidget::slotConfigChanged() { if (m_updateAllowed) { m_configCompressor->start(); } } void KisColorSliderWidget::setConfig() { //QTimer::singleShot(1, this, SLOT(update()));//need to wait a bit before accessing the config. QBitArray m_SlidersConfigArray(12); //qDebug()<<"check"; KConfigGroup cfg = KGlobal::config()->group("hsxColorSlider"); m_SlidersConfigArray[0] =cfg.readEntry("hsvH", false); m_SlidersConfigArray[1] =cfg.readEntry("hsvS", false); m_SlidersConfigArray[2] =cfg.readEntry("hsvV", false); m_SlidersConfigArray[3] =cfg.readEntry("hslH", true); m_SlidersConfigArray[4] =cfg.readEntry("hslS", true); m_SlidersConfigArray[5] =cfg.readEntry("hslL", true); m_SlidersConfigArray[6] =cfg.readEntry("hsiH", false); m_SlidersConfigArray[7] =cfg.readEntry("hsiS", false); m_SlidersConfigArray[8] =cfg.readEntry("hsiI", false); m_SlidersConfigArray[9] =cfg.readEntry("hsyH", false); m_SlidersConfigArray[10]=cfg.readEntry("hsyS", false); m_SlidersConfigArray[11]=cfg.readEntry("hsyY", false); setSlidersVisible(m_SlidersConfigArray); } void KisColorSliderWidget::hueUpdate(int h) { emit(hueUpdated(h)); } void KisColorSliderWidget::satUpdate(int s, int type) { emit(satUpdated(s, type)); } void KisColorSliderWidget::toneUpdate(int l, int type) { emit(toneUpdated(l, type)); } #include "kis_color_slider_widget.moc"