Commit 16c8832c authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Port the last areas to use the KisColorButton as far as possible.

There's still the grid docker, which has a bit of a UI problem, and then rest is flake and friends.

Ref T2438
parent ef9aeb29
......@@ -51,7 +51,7 @@
</widget>
</item>
<item>
<widget class="QFrame" name="">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
......@@ -59,7 +59,7 @@
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>0</number>
<number>2</number>
</property>
<property name="midLineWidth">
<number>2</number>
......@@ -68,6 +68,18 @@
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="KoColorPatch" name="currentColor" native="true">
<property name="sizePolicy">
......
......@@ -30,6 +30,8 @@
#include <KoCanvasResourceManager.h>
#include <KoCanvasBase.h>
#include <kis_color_button.h>
class DigitalMixerPatch : public KoColorPatch {
public:
DigitalMixerPatch(QWidget* parent) : KoColorPatch(parent) {}
......@@ -43,7 +45,13 @@ DigitalMixerDock::DigitalMixerDock( )
: QDockWidget(i18n("Digital Colors Mixer")), m_canvas(0)
, m_tellCanvas(true)
{
QColor initColors[6] = { Qt::black, Qt::white, Qt::red, Qt::green, Qt::blue, Qt::yellow };
const KoColorSpace *sRGB = KoColorSpaceRegistry::instance()->rgb8();
KoColor initColors[6] = { KoColor(Qt::black, sRGB),
KoColor(Qt::white, sRGB),
KoColor(Qt::red, sRGB),
KoColor(Qt::green, sRGB),
KoColor(Qt::blue, sRGB),
KoColor(Qt::yellow, sRGB) };
QWidget* widget = new QWidget(this);
QGridLayout* layout = new QGridLayout( widget );
......@@ -75,16 +83,14 @@ DigitalMixerDock::DigitalMixerDock( )
mixer.targetSlider->setFixedWidth(22);
mixer.targetSlider->setMinimumHeight(66);
layout->addWidget(mixer.targetSlider, 1, i + 1);
QToolButton* colorSelector = new QToolButton( this );
mixer.actionColor = new KoColorPopupAction(this);
mixer.actionColor->setCurrentColor(initColors[i]);
colorSelector->setDefaultAction(mixer.actionColor);
colorSelector->setFixedSize(colorSelector->sizeHint());
layout->addWidget(colorSelector, 2, i + 1);
mixer.actionColor = new KisColorButton( this );
mixer.actionColor->setColor(initColors[i]);
mixer.actionColor->setFixedWidth(22);
layout->addWidget(mixer.actionColor, 2, i + 1);
m_mixers.push_back(mixer);
connect(mixer.actionColor, SIGNAL(colorChanged(KoColor)), signalMapperSelectColor, SLOT(map()));
connect(mixer.actionColor, SIGNAL(changed(KoColor)), signalMapperSelectColor, SLOT(map()));
signalMapperSelectColor->setMapping(mixer.actionColor, i);
connect(mixer.targetSlider, SIGNAL(valueChanged(int)), signalMapperColorSlider, SLOT(map()));
......@@ -120,7 +126,7 @@ void DigitalMixerDock::setCanvas(KoCanvasBase * canvas)
void DigitalMixerDock::popupColorChanged(int i)
{
KoColor color = m_mixers[i].actionColor->currentKoColor();
KoColor color = m_mixers[i].actionColor->color();
color.convertTo(m_currentColor.colorSpace());
m_mixers[i].targetSlider->setColors( color, m_currentColor);
colorSliderChanged(i);
......
......@@ -25,6 +25,7 @@
class KoColorPopupAction;
class KoColorSlider;
class KoColorPatch;
class KisColorButton;
class DigitalMixerDock : public QDockWidget, public KoCanvasObserverBase {
Q_OBJECT
......@@ -48,7 +49,7 @@ private:
struct Mixer {
KoColorPatch* targetColor;
KoColorSlider* targetSlider;
KoColorPopupAction* actionColor;
KisColorButton* actionColor;
};
QList<Mixer> m_mixers;
bool m_tellCanvas;
......
......@@ -28,7 +28,7 @@
#include "kis_int_parse_spin_box.h"
#include <kcolorbutton.h>
#include <kis_color_button.h>
KisWdgIndexColors::KisWdgIndexColors(QWidget* parent, Qt::WFlags f, int delay): KisConfigWidget(parent, f, delay)
{
......@@ -100,7 +100,7 @@ void KisWdgIndexColors::setup(QStringList shadesLabels, int ramps)
for(int y = 0; y < rows; ++y)
for(int x = 0; x < collumns; ++x)
{
KColorButton* b = new KColorButton;
KisColorButton* b = new KisColorButton;
QCheckBox* c = new QCheckBox;
c->setChecked(false);
b->setEnabled(false);
......@@ -109,7 +109,7 @@ void KisWdgIndexColors::setup(QStringList shadesLabels, int ramps)
connect(c, SIGNAL(toggled(bool)), b, SLOT(setEnabled(bool)));
connect(c, SIGNAL(toggled(bool)), this, SIGNAL(sigConfigurationItemChanged()));
connect(b, SIGNAL(changed(QColor)), this, SIGNAL(sigConfigurationItemChanged()));
connect(b, SIGNAL(changed(KoColor)), this, SIGNAL(sigConfigurationItemChanged()));
QHBoxLayout* cell = new QHBoxLayout();
cell->setSpacing(0);
......@@ -133,7 +133,7 @@ KisPropertiesConfiguration* KisWdgIndexColors::configuration() const
for(int y = 0; y < 4; ++y)
for(int x = 0; x < 4; ++x)
{
palCfg.colors[y][x] = m_colorSelectors[y][x].button->color();
palCfg.colors[y][x] = m_colorSelectors[y][x].button->color().toQColor();
palCfg.colorsEnabled[y][x] = m_colorSelectors[y][x].button->isEnabled();
}
......@@ -179,7 +179,9 @@ void KisWdgIndexColors::setConfiguration(const KisPropertiesConfiguration* confi
{
m_colorSelectors[y][x].checkbox->setChecked(palCfg.colorsEnabled[y][x]);
m_colorSelectors[y][x].button->setEnabled(palCfg.colorsEnabled[y][x]);
m_colorSelectors[y][x].button->setColor(palCfg.colors[y][x]);
KoColor c;
c.fromQColor(palCfg.colors[y][x]);
m_colorSelectors[y][x].button->setColor(c);
}
for(int y = 0; y < 3; ++y)
......
......@@ -27,7 +27,7 @@
#include <QSpinBox>
class QCheckBox;
class KColorButton;
class KisColorButton;
namespace Ui
{
class KisWdgIndexColors;
......@@ -48,7 +48,7 @@ private Q_SLOTS:
private:
struct ColorWidgets
{
KColorButton* button;
KisColorButton* button;
QCheckBox* checkbox;
};
QVector< QVector<ColorWidgets> > m_colorSelectors;
......
......@@ -52,10 +52,10 @@
</widget>
</item>
<item row="1" column="1">
<widget class="KColorButton" name="bnColor"/>
<widget class="KisColorButton" name="bnColor"/>
</item>
<item row="0" column="1">
<widget class="KisPatternChooser" name="patternChooser">
<widget class="KisPatternChooser" name="patternChooser" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
......@@ -70,9 +70,9 @@
</widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<class>KisColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
<header>kis_color_button.h</header>
</customwidget>
<customwidget>
<class>KisPatternChooser</class>
......
......@@ -31,6 +31,7 @@
#include <QFileInfo>
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
#include <KoColorProfile.h>
#include <KisImportExportManager.h>
#include <KisFilterChain.h>
......@@ -120,8 +121,11 @@ KisImportExportFilter::ConversionStatus KisJPEGExport::convert(const QByteArray&
wdgUi.chkSaveProfile->setChecked(cfg.getBool("saveProfile", true));
QStringList rgb = cfg.getString("transparencyFillcolor", "255,255,255").split(',');
wdgUi.bnTransparencyFillColor->setDefaultColor(Qt::white);
wdgUi.bnTransparencyFillColor->setColor(QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt()));
KoColor background(KoColorSpaceRegistry::instance()->rgb8());
background.fromQColor(Qt::white);
wdgUi.bnTransparencyFillColor->setDefaultColor(background);
background.fromQColor(QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt()));
wdgUi.bnTransparencyFillColor->setColor(background);
frm.setEnabledFilters(cfg.getString("filters").split(','));
......@@ -170,7 +174,7 @@ KisImportExportFilter::ConversionStatus KisJPEGExport::convert(const QByteArray&
options.xmp = wdgUi.xmp->isChecked();
cfg.setProperty("xmp", options.xmp);
QColor c = wdgUi.bnTransparencyFillColor->color();
QColor c = wdgUi.bnTransparencyFillColor->color().toQColor();
options.transparencyFillColor = c;
cfg.setProperty("transparencyFillcolor", QString("%1,%2,%3").arg(c.red()).arg(c.green()).arg(c.blue()));
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>537</width>
<width>545</width>
<height>390</height>
</rect>
</property>
......@@ -41,7 +41,7 @@
<number>20</number>
</property>
<item row="0" column="1">
<widget class="KisDoubleSliderSpinBox" name="qualityLevel">
<widget class="KisDoubleSliderSpinBox" name="qualityLevel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
......@@ -89,7 +89,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="KColorButton" name="bnTransparencyFillColor">
<widget class="KisColorButton" name="bnTransparencyFillColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -145,7 +145,7 @@
<number>20</number>
</property>
<item row="0" column="1">
<widget class="KisDoubleSliderSpinBox" name="smoothLevel">
<widget class="KisDoubleSliderSpinBox" name="smoothLevel" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
......@@ -342,17 +342,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
</customwidget>
<customwidget>
<class>KisDoubleSliderSpinBox</class>
<extends>QWidget</extends>
<header>kis_slider_spin_box.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KisColorButton</class>
<extends>QPushButton</extends>
<header>kis_color_button.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
......
......@@ -28,6 +28,7 @@
#include <QMessageBox>
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
#include <KisFilterChain.h>
#include <KisImportExportManager.h>
#include <KoColorProfile.h>
......@@ -165,8 +166,11 @@ KisImportExportFilter::ConversionStatus KisPNGExport::convert(const QByteArray&
wdg->chkForceSRGB->setChecked(cfg.getBool("forceSRGB", false));
QStringList rgb = cfg.getString("transparencyFillcolor", "0,0,0").split(',');
wdg->bnTransparencyFillColor->setDefaultColor(Qt::white);
wdg->bnTransparencyFillColor->setColor(QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt()));
KoColor background(KoColorSpaceRegistry::instance()->rgb8());
background.fromQColor(Qt::white);
wdg->bnTransparencyFillColor->setDefaultColor(background);
background.fromQColor(QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt()));
wdg->bnTransparencyFillColor->setColor(background);
kdb->setMainWidget(wdg);
QApplication::restoreOverrideCursor();
......@@ -182,7 +186,7 @@ KisImportExportFilter::ConversionStatus KisPNGExport::convert(const QByteArray&
bool interlace = wdg->interlacing->isChecked();
int compression = (int)wdg->compressionLevel->value();
bool tryToSaveAsIndexed = wdg->tryToSaveAsIndexed->isChecked();
QColor c = wdg->bnTransparencyFillColor->color();
QColor c = wdg->bnTransparencyFillColor->color().toQColor();
bool saveSRGB = wdg->chkSRGB->isChecked();
bool forceSRGB = wdg->chkForceSRGB->isChecked();
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>476</width>
<width>546</width>
<height>243</height>
</rect>
</property>
......@@ -52,7 +52,7 @@
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="KisDoubleSliderSpinBox" name="compressionLevel">
<widget class="KisDoubleSliderSpinBox" name="compressionLevel" native="true">
<property name="toolTip">
<string>Note: the compression level does not change the quality of the result</string>
</property>
......@@ -159,7 +159,7 @@ Enabling interlacing will cause the image to be displayed by the browser even wh
</widget>
</item>
<item row="8" column="1">
<widget class="KColorButton" name="bnTransparencyFillColor">
<widget class="KisColorButton" name="bnTransparencyFillColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
......@@ -205,9 +205,9 @@ Enabling interlacing will cause the image to be displayed by the browser even wh
<container>1</container>
</customwidget>
<customwidget>
<class>KColorButton</class>
<class>KisColorButton</class>
<extends>QPushButton</extends>
<header>kcolorbutton.h</header>
<header>kis_color_button.h</header>
</customwidget>
</customwidgets>
<resources/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment