Commit 00b8d54f authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Attempt to further add displayconverter integration...

I can't get much further here due the inability for kodualcolorbutton
to have a display renderer, due MVC. Fun times...

Ref T2337
parent 0eee3399
...@@ -40,10 +40,10 @@ struct KisInternalColorSelector::Private ...@@ -40,10 +40,10 @@ struct KisInternalColorSelector::Private
const KoColorSpace *currentColorSpace; const KoColorSpace *currentColorSpace;
bool chooseAlpha = false; bool chooseAlpha = false;
KisSignalCompressor *compressColorChanges; KisSignalCompressor *compressColorChanges;
QPointer<KoColorDisplayRendererInterface> displayRenderer; const KoColorDisplayRendererInterface *displayRenderer;
}; };
KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor color, bool modal, const QString &caption, KoColorDisplayRendererInterface *displayRenderer) KisInternalColorSelector::KisInternalColorSelector(QWidget *parent, KoColor color, bool modal, const QString &caption, const KoColorDisplayRendererInterface *displayRenderer)
: QDialog(parent) : QDialog(parent)
,m_d(new Private) ,m_d(new Private)
{ {
......
...@@ -37,7 +37,7 @@ class KRITAUI_EXPORT KisInternalColorSelector : public QDialog ...@@ -37,7 +37,7 @@ class KRITAUI_EXPORT KisInternalColorSelector : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
KisInternalColorSelector(QWidget* parent, KoColor color, bool modal, const QString &caption, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance()); KisInternalColorSelector(QWidget* parent, KoColor color, bool modal, const QString &caption, const KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
~KisInternalColorSelector(); ~KisInternalColorSelector();
/** /**
......
...@@ -96,8 +96,8 @@ void KoDualColorButton::Private::init(KoDualColorButton *q) ...@@ -96,8 +96,8 @@ void KoDualColorButton::Private::init(KoDualColorButton *q)
q->setMinimumSize( q->sizeHint() ); q->setMinimumSize( q->sizeHint() );
q->setAcceptDrops( true ); q->setAcceptDrops( true );
QString caption = "Select a color"; QString caption = i18n("Select a color");
colorSelectorDialog = new KisInternalColorSelector(q, foregroundColor, false, caption, KoDumbColorDisplayRenderer::instance()); colorSelectorDialog = new KisInternalColorSelector(q, foregroundColor, false, caption, displayRenderer);
connect(colorSelectorDialog, SIGNAL(signalForegroundColorChosen(KoColor)), q, SLOT(slotSetForeGroundColorFromDialog(KoColor))); connect(colorSelectorDialog, SIGNAL(signalForegroundColorChosen(KoColor)), q, SLOT(slotSetForeGroundColorFromDialog(KoColor)));
connect(q, SIGNAL(foregroundColorChanged(KoColor)), colorSelectorDialog, SLOT(slotColorUpdated(KoColor))); connect(q, SIGNAL(foregroundColorChanged(KoColor)), colorSelectorDialog, SLOT(slotColorUpdated(KoColor)));
} }
......
...@@ -37,7 +37,7 @@ struct KisVisualColorSelector::Private ...@@ -37,7 +37,7 @@ struct KisVisualColorSelector::Private
const KoColorSpace *currentCS; const KoColorSpace *currentCS;
QList <KisVisualColorSelectorShape*> widgetlist; QList <KisVisualColorSelectorShape*> widgetlist;
bool updateSelf = false; bool updateSelf = false;
QPointer<KoColorDisplayRendererInterface> displayRenderer; const KoColorDisplayRendererInterface *displayRenderer = 0;
//Current coordinates. //Current coordinates.
QVector <float> currentCoordinates; QVector <float> currentCoordinates;
}; };
...@@ -85,8 +85,15 @@ void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs) ...@@ -85,8 +85,15 @@ void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs)
layout->addWidget(bar); layout->addWidget(bar);
m_d->widgetlist.append(bar); m_d->widgetlist.append(bar);
} else if (m_d->currentCS->colorChannelCount() == 3) { } else if (m_d->currentCS->colorChannelCount() == 3) {
KisVisualRectangleSelectorShape *bar = new KisVisualRectangleSelectorShape(this, KisVisualRectangleSelectorShape::onedimensional,KisVisualColorSelectorShape::HSL, cs, 0, 0); KisVisualRectangleSelectorShape *bar = new KisVisualRectangleSelectorShape(this,
KisVisualRectangleSelectorShape *block = new KisVisualRectangleSelectorShape(this, KisVisualRectangleSelectorShape::twodimensional,KisVisualColorSelectorShape::HSL, cs, 1, 2); KisVisualRectangleSelectorShape::onedimensional,
KisVisualColorSelectorShape::HSL,
cs, 0, 0,
m_d->displayRenderer);
KisVisualRectangleSelectorShape *block = new KisVisualRectangleSelectorShape(this, KisVisualRectangleSelectorShape::twodimensional,
KisVisualColorSelectorShape::HSL,
cs, 1, 2,
m_d->displayRenderer);
bar->setMaximumWidth(width()*0.1); bar->setMaximumWidth(width()*0.1);
bar->setMaximumHeight(height()); bar->setMaximumHeight(height());
block->setMaximumWidth(width()*0.9); block->setMaximumWidth(width()*0.9);
...@@ -121,7 +128,7 @@ void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs) ...@@ -121,7 +128,7 @@ void KisVisualColorSelector::slotsetColorSpace(const KoColorSpace *cs)
} }
void KisVisualColorSelector::setDisplayRenderer (KoColorDisplayRendererInterface *displayRenderer) { void KisVisualColorSelector::setDisplayRenderer (const KoColorDisplayRendererInterface *displayRenderer) {
m_d->displayRenderer = displayRenderer; m_d->displayRenderer = displayRenderer;
if (m_d->widgetlist.size()>0) { if (m_d->widgetlist.size()>0) {
Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) { Q_FOREACH (KisVisualColorSelectorShape *shape, m_d->widgetlist) {
...@@ -177,7 +184,7 @@ struct KisVisualColorSelectorShape::Private ...@@ -177,7 +184,7 @@ struct KisVisualColorSelectorShape::Private
int channel2; int channel2;
KisSignalCompressor *updateTimer; KisSignalCompressor *updateTimer;
bool mousePressActive = false; bool mousePressActive = false;
QPointer<KoColorDisplayRendererInterface> displayRenderer; const KoColorDisplayRendererInterface *displayRenderer = 0;
}; };
KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent, KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent,
...@@ -186,10 +193,8 @@ KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent, ...@@ -186,10 +193,8 @@ KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent,
const KoColorSpace *cs, const KoColorSpace *cs,
int channel1, int channel1,
int channel2, int channel2,
KoColorDisplayRendererInterface *displayRenderer): QWidget(parent), m_d(new Private) const KoColorDisplayRendererInterface *displayRenderer): QWidget(parent), m_d(new Private)
{ {
m_d->displayRenderer = displayRenderer;
connect(m_d->displayRenderer, SIGNAL(displayConfigurationChanged()), SLOT(update()));
m_d->dimension = dimension; m_d->dimension = dimension;
m_d->model = model; m_d->model = model;
m_d->cs = cs; m_d->cs = cs;
...@@ -201,6 +206,13 @@ KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent, ...@@ -201,6 +206,13 @@ KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent,
m_d->channel2 = qBound(0, channel2, maxchannel); m_d->channel2 = qBound(0, channel2, maxchannel);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_d->updateTimer = new KisSignalCompressor(100 /* ms */, KisSignalCompressor::POSTPONE, this); m_d->updateTimer = new KisSignalCompressor(100 /* ms */, KisSignalCompressor::POSTPONE, this);
if (displayRenderer) {
m_d->displayRenderer = displayRenderer;
connect(m_d->displayRenderer, SIGNAL(displayConfigurationChanged()), this, SLOT(update()), Qt::UniqueConnection);
} else {
KoDumbColorDisplayRenderer::instance();
}
} }
KisVisualColorSelectorShape::~KisVisualColorSelectorShape() KisVisualColorSelectorShape::~KisVisualColorSelectorShape()
...@@ -242,8 +254,18 @@ void KisVisualColorSelectorShape::setColorFromSibling(KoColor c) ...@@ -242,8 +254,18 @@ void KisVisualColorSelectorShape::setColorFromSibling(KoColor c)
update(); update();
} }
void KisVisualColorSelectorShape::setDisplayRenderer (KoColorDisplayRendererInterface *displayRenderer) { void KisVisualColorSelectorShape::setDisplayRenderer (const KoColorDisplayRendererInterface *displayRenderer)
m_d->displayRenderer = displayRenderer; {
if (displayRenderer) {
if (m_d->displayRenderer) {
m_d->displayRenderer->disconnect(this);
}
m_d->displayRenderer = displayRenderer;
connect(m_d->displayRenderer, SIGNAL(displayConfigurationChanged()),
SLOT(update()), Qt::UniqueConnection);
} else {
m_d->displayRenderer = KoDumbColorDisplayRenderer::instance();
}
} }
QColor KisVisualColorSelectorShape::getColorFromConverter(KoColor c){ QColor KisVisualColorSelectorShape::getColorFromConverter(KoColor c){
...@@ -442,7 +464,8 @@ KisVisualRectangleSelectorShape::KisVisualRectangleSelectorShape(QWidget *parent ...@@ -442,7 +464,8 @@ KisVisualRectangleSelectorShape::KisVisualRectangleSelectorShape(QWidget *parent
ColorModel model, ColorModel model,
const KoColorSpace *cs, const KoColorSpace *cs,
int channel1, int channel2, int channel1, int channel2,
singelDTypes d, KoColorDisplayRendererInterface *displayRenderer) const KoColorDisplayRendererInterface *displayRenderer,
singelDTypes d)
: KisVisualColorSelectorShape(parent, dimension, model, cs, channel1, channel2, displayRenderer) : KisVisualColorSelectorShape(parent, dimension, model, cs, channel1, channel2, displayRenderer)
{ {
m_type = d; m_type = d;
......
...@@ -50,7 +50,7 @@ public Q_SLOTS: ...@@ -50,7 +50,7 @@ public Q_SLOTS:
void slotSetColor(KoColor c); void slotSetColor(KoColor c);
void slotsetColorSpace(const KoColorSpace *cs); void slotsetColorSpace(const KoColorSpace *cs);
void setDisplayRenderer (KoColorDisplayRendererInterface *displayRenderer); void setDisplayRenderer (const KoColorDisplayRendererInterface *displayRenderer);
private Q_SLOTS: private Q_SLOTS:
void updateFromWidgets(KoColor c); void updateFromWidgets(KoColor c);
protected: protected:
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
KisVisualColorSelectorShape::ColorModel model, KisVisualColorSelectorShape::ColorModel model,
const KoColorSpace *cs, const KoColorSpace *cs,
int channel1, int channel2, int channel1, int channel2,
KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance()); const KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
~KisVisualColorSelectorShape(); ~KisVisualColorSelectorShape();
QPointF getCursorPosition(); QPointF getCursorPosition();
...@@ -92,7 +92,7 @@ public: ...@@ -92,7 +92,7 @@ public:
QPixmap getPixmap(); QPixmap getPixmap();
void setFullImage(QPixmap full); void setFullImage(QPixmap full);
KoColor getCurrentColor(); KoColor getCurrentColor();
void setDisplayRenderer (KoColorDisplayRendererInterface *displayRenderer); void setDisplayRenderer (const KoColorDisplayRendererInterface *displayRenderer);
QColor getColorFromConverter(KoColor c); QColor getColorFromConverter(KoColor c);
Q_SIGNALS: Q_SIGNALS:
void sigNewColor(KoColor col); void sigNewColor(KoColor col);
...@@ -151,8 +151,9 @@ public: ...@@ -151,8 +151,9 @@ public:
ColorModel model, ColorModel model,
const KoColorSpace *cs, const KoColorSpace *cs,
int channel1, int channel2, int channel1, int channel2,
KisVisualRectangleSelectorShape::singelDTypes d = KisVisualRectangleSelectorShape::vertical, const KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(),
KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance()); KisVisualRectangleSelectorShape::singelDTypes d = KisVisualRectangleSelectorShape::vertical
);
~KisVisualRectangleSelectorShape(); ~KisVisualRectangleSelectorShape();
void setBarWidth(); void setBarWidth();
......
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