Commit 763a373b authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Add Hex code widget that only outputs and reads sRGB colors.

Nothing else understands having hexcode in other spaces anyway.

Ref T2438
parent 04707daf
......@@ -36,17 +36,20 @@
#include "kis_internal_color_selector.h"
#include "ui_wdgdlginternalcolorselector.h"
#include "kis_config.h"
#include "kis_color_input.h"
struct KisInternalColorSelector::Private
{
bool allowUpdates = true;
KoColor currentColor;
KoColor previousColor;
KoColor sRGB = KoColor(KoColorSpaceRegistry::instance()->rgb8());
const KoColorSpace *currentColorSpace;
bool lockUsedCS = false;
bool chooseAlpha = false;
KisSignalCompressor *compressColorChanges;
const KoColorDisplayRendererInterface *displayRenderer;
KisHexColorInput *hexColorInput;
};
KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor color, bool modal, const QString &caption, const KoColorDisplayRendererInterface *displayRenderer)
......@@ -96,6 +99,12 @@ KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor colo
connect(this, SIGNAL(accepted()), this, SLOT(setPreviousColor()));
connect(m_ui->previousColor, SIGNAL(triggered(KoColorPatch*)), SLOT(slotSetColorFromPatch(KoColorPatch*)));
m_d->sRGB.fromKoColor(m_d->currentColor);
m_d->hexColorInput = new KisHexColorInput(this, &m_d->sRGB);
connect(m_d->hexColorInput, SIGNAL(updated()), SLOT(slotSetColorFromHex()));
m_ui->leftPane->addWidget(m_d->hexColorInput);
m_d->hexColorInput->setToolTip(i18n("This is a hexcode input, for webcolors. It can only get colors in the sRGB space."));
connect(this, SIGNAL(signalForegroundColorChosen(KoColor)), this, SLOT(slotLockSelector()));
m_d->compressColorChanges = new KisSignalCompressor(100 /* ms */, KisSignalCompressor::POSTPONE, this);
connect(m_d->compressColorChanges, SIGNAL(timeout()), this, SLOT(endUpdateWithNewColor()));
......@@ -203,6 +212,11 @@ void KisInternalColorSelector::updateAllElements(QObject *source)
m_ui->visualSelector->slotSetColor(m_d->currentColor);
}
if (source != m_d->hexColorInput) {
m_d->sRGB.fromKoColor(m_d->currentColor);
m_d->hexColorInput->update();
}
m_ui->previousColor->setColor(m_d->previousColor);
m_ui->currentColor->setColor(m_d->currentColor);
......@@ -228,3 +242,8 @@ void KisInternalColorSelector::slotSetColorFromPatch(KoColorPatch* patch)
{
slotColorUpdated(patch->color());
}
void KisInternalColorSelector::slotSetColorFromHex()
{
slotColorUpdated(m_d->sRGB);
}
......@@ -120,8 +120,19 @@ private Q_SLOTS:
*/
void setPreviousColor();
/**
* @brief slotSetColorFromPatch
* update current color from kocolorpatch.
* @param patch
*/
void slotSetColorFromPatch(KoColorPatch* patch);
/**
* @brief slotSetColorFromHex
* Update from the hex color input.
*/
void slotSetColorFromHex();
private:
Ui_WdgDlgInternalColorSelector *m_ui; //the UI
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>430</width>
<width>505</width>
<height>483</height>
</rect>
</property>
......@@ -17,7 +17,7 @@
<item>
<layout class="QHBoxLayout" name="horizontal">
<item>
<layout class="QVBoxLayout" name="rightPane">
<layout class="QVBoxLayout" name="leftPane">
<item>
<widget class="KisVisualColorSelector" name="visualSelector" native="true">
<property name="sizePolicy">
......@@ -47,7 +47,7 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="leftPane">
<layout class="QVBoxLayout" name="rightPane">
<item>
<widget class="KoColorSetWidget" name="paletteBox">
<property name="sizePolicy">
......
......@@ -37,7 +37,7 @@ class KRITAUI_EXPORT KisColorInput : public QWidget
{
Q_OBJECT
public:
KisColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer);
KisColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
protected:
void init();
virtual QWidget* createInput() = 0;
......@@ -54,7 +54,7 @@ class KRITAUI_EXPORT KisIntegerColorInput : public KisColorInput
{
Q_OBJECT
public:
KisIntegerColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer);
KisIntegerColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
protected:
virtual QWidget* createInput();
public Q_SLOTS:
......@@ -69,7 +69,7 @@ class KRITAUI_EXPORT KisFloatColorInput : public KisColorInput
{
Q_OBJECT
public:
KisFloatColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer);
KisFloatColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
protected:
virtual QWidget* createInput();
public Q_SLOTS:
......@@ -86,7 +86,7 @@ class KRITAUI_EXPORT KisHexColorInput : public KisColorInput
{
Q_OBJECT
public:
KisHexColorInput(QWidget* parent, KoColor* color, KoColorDisplayRendererInterface *displayRenderer);
KisHexColorInput(QWidget* parent, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
protected:
virtual QWidget* createInput();
public Q_SLOTS:
......
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