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

Add colorspace locking to the internal selector.

So it doesn't flip between colorspaces all the time.

Also fixes a crash in KoDualColorButton

Ref T2438
parent c33f2ae2
......@@ -43,6 +43,7 @@ struct KisInternalColorSelector::Private
KoColor currentColor;
KoColor previousColor;
const KoColorSpace *currentColorSpace;
bool lockUsedCS = false;
bool chooseAlpha = false;
KisSignalCompressor *compressColorChanges;
const KoColorDisplayRendererInterface *displayRenderer;
......@@ -113,7 +114,12 @@ void KisInternalColorSelector::slotColorUpdated(KoColor newColor)
{
//if the update did not come from this selector...
if (m_d->allowUpdates || QObject::sender() == this->parent()) {
m_d->currentColor = newColor;
if (m_d->lockUsedCS){
newColor.convertTo(m_d->currentColorSpace);
m_d->currentColor = newColor;
} else {
m_d->currentColor = newColor;
}
updateAllElements(QObject::sender());
}
}
......@@ -126,7 +132,14 @@ void KisInternalColorSelector::colorSpaceChanged(const KoColorSpace *cs)
m_d->currentColorSpace = KoColorSpaceRegistry::instance()->colorSpace(cs->colorModelId().id(), cs->colorDepthId().id(), cs->profile());
m_ui->spinboxselector->slotSetColorSpace(m_d->currentColorSpace);
m_ui->visualSelector->slotsetColorSpace(m_d->currentColorSpace);
}
void KisInternalColorSelector::lockUsedColorSpace(const KoColorSpace *cs)
{
colorSpaceChanged(cs);
m_d->lockUsedCS = true;
}
void KisInternalColorSelector::setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer)
......
......@@ -46,6 +46,13 @@ public:
*/
void colorSpaceChanged(const KoColorSpace *cs);
/**
* @brief lockUsedColorSpace
* Lock the used colorspace of this selector.
* @param cs
*/
void lockUsedColorSpace(const KoColorSpace *cs);
/**
* @brief setDisplayRenderer
* Set the display renderer. This is necessary for HDR color manage support.
......
......@@ -46,6 +46,7 @@
#include <KoResourceServerAdapter.h>
#include <KoResourceServerProvider.h>
#include <KoColorSpaceRegistry.h>
#include <kis_image.h>
#include <resources/KoPattern.h>
#include "kis_resource_server_provider.h"
......@@ -138,6 +139,9 @@ void KisControlFrame::slotUpdateDisplayRenderer()
{
if (m_viewManager->canvasBase()){
m_dual->setDisplayRenderer(m_viewManager->canvasBase()->displayColorConverter()->displayRendererInterface());
m_dual->setColorSpace(m_viewManager->canvasBase()->image()->colorSpace());
} else if (m_viewManager->viewCount()==0) {
m_dual->setDisplayRenderer();
}
}
......
......@@ -165,11 +165,17 @@ void KoDualColorButton::setDisplayRenderer(const KoColorDisplayRendererInterface
if (displayRenderer) {
d->displayRenderer = displayRenderer;
d->colorSelectorDialog->setDisplayRenderer(displayRenderer);
connect(d->displayRenderer, SIGNAL(destroyed()), this, SLOT(setDisplayRenderer()), Qt::UniqueConnection);
} else {
d->displayRenderer = KoDumbColorDisplayRenderer::instance();
}
}
void KoDualColorButton::setColorSpace(const KoColorSpace *cs)
{
d->colorSelectorDialog->lockUsedColorSpace(cs);
}
QColor KoDualColorButton::getColorFromDisplayRenderer(KoColor c)
{
QColor col;
......
......@@ -22,12 +22,11 @@
#define KODUALCOLORBUTTON_H
#include "kritawidgets_export.h"
#include <KoColorDisplayRendererInterface.h>
#include <QWidget>
class KoColor;
class KoColorDisplayRendererInterface;
class KoColorSpace;
/**
* @short A widget for selecting two related colors.
*
......@@ -117,7 +116,14 @@ class KRITAWIDGETS_EXPORT KoDualColorButton : public QWidget
void slotSetForeGroundColorFromDialog (const KoColor color);
void setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer);
void setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance());
/**
* @brief setColorSpace
* set ColorSpace so we can lock the selector. Right now this'll be changed per view-change.
* @param cs
*/
void setColorSpace(const KoColorSpace *cs);
/**
* @brief getColorFromDisplayRenderer
......
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