27#include <QSignalBlocker>
34 setObjectName(
"tool_colorsampler");
79 if (
m_config->addColorToCurrentPalette) {
88 KisSwatchGroup::SwatchInfo info =
89 palette->getClosestSwatchInfo(color);
91 if (info.swatch.color() != color) {
92 palette->addSwatch(swatch);
103 KisConfig(
true).colorSamplerPreviewStyle());
199 QRectF colorPreviewDocUpdateRect;
204 qreal xoffset = 2.0/zoomX;
205 qreal yoffset = 2.0/zoomY;
211 if (!colorPreviewDocUpdateRect.isEmpty()) {
212 colorPreviewDocUpdateRect = colorPreviewDocUpdateRect.adjusted(-xoffset,-yoffset,xoffset,yoffset);
219 if (!colorPreviewDocUpdateRect.isEmpty()){
240 for (
int i = 0; i < channels.count(); ++i) {
244 for (
int i = 0; i < channels.count(); ++i) {
247 pc.
name = channels[i]->name();
255 sampledChannels[channels[i]->displayPosition()] = pc;
260 QTreeWidgetItem *item =
new QTreeWidgetItem(
m_optionsWidget->listViewChannels);
261 item->setText(0, pc.
name);
266 if (qEnvironmentVariableIsSet(
"KRITA_DEBUG_DISPLAY_COLOR")) {
275 for (
int i = 0; i < values.size(); i++) {
276 QTreeWidgetItem *item =
new QTreeWidgetItem(
m_optionsWidget->listViewChannels);
277 item->setText(0, QString(
"DisplayCh%1").arg(i));
278 item->setText(1, QString::number(values[i]));
292 specialSpacer->setObjectName(
"SpecialSpacer");
293 specialSpacer->setFixedSize(0, 0);
302 QOverload<int>::of(&QComboBox::activated),
309 i18nc(
"{n} is the number value, % is the percent sign",
"{n}%"));
330 KConfigGroup config = KSharedConfig::openConfig()->group(
toolId());
331 QString paletteName = config.readEntry(
"ColorSamplerPalette",
"");
332 if (!paletteName.isEmpty()) {
336 if (name == paletteName) {
375 m_config->addColorToCurrentPalette = state;
396 KConfigGroup config = KSharedConfig::openConfig()->group(
toolId());
397 config.writeEntry(
"ColorSamplerPalette", paletteName);
float value(const T *src, size_t ch)
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
static KisConfig::ColorSamplerPreviewStyle getColorSamplerPreviewStyleValue(const QComboBox *cmb)
static void setColorSamplerPreviewStyleItems(QComboBox *cmb)
static void setColorSamplerPreviewStyleIndexByValue(QComboBox *cmb, KisConfig::ColorSamplerPreviewStyle style)
void updateCursor(KisToolUtils::ColorSamplerSource sampleSource, bool pickFgColor)
void setUpdateGlobalColor(bool value)
void paint(QPainter &gc, const KoViewConverter &converter)
void continueAction(const QPointF &docPoint)
void startAction(const QPointF &docPoint, int radius, int blend)
void activate(KisToolUtils::ColorSamplerSource sampleSource, bool pickFgColor)
QRectF colorPreviewDocRect(const QPointF &docPoint)
KisDisplayColorConverter displayColorConverter
void updateCanvas(const QRectF &rc) override
const KoViewConverter * viewConverter() const override
static KisConfigNotifier * instance()
void sigColorSamplerPreviewStyleChanged()
void setColorSamplerPreviewStyle(ColorSamplerPreviewStyle style)
KoColor applyDisplayFiltering(const KoColor &srcColor, const KoID &bitDepthId) const
void setColor(const KoColor &color)
The KisTagFilterResourceProxyModel class filters the resources by tag or resource name.
KoResourceSP resourceForIndex(QModelIndex index=QModelIndex()) const override
resourceForIndex returns a properly versioned and id'ed resource object
QPointer< KoCanvasResourceProvider > resourceManager
virtual QString channelValueText(const quint8 *pixel, quint32 channelIndex) const =0
QList< KoChannelInfo * > channels
virtual KoID colorModelId() const =0
virtual void normalisedChannelsValue(const quint8 *pixel, QVector< float > &channels) const =0
virtual QString normalisedChannelValueText(const quint8 *pixel, quint32 channelIndex) const =0
const KoColorSpace * colorSpace() const
return the current colorSpace
QPointF point
The point in document coordinates.
virtual void zoom(qreal *zoomX, qreal *zoomY) const
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
void setText(QSpinBox *spinBox, const QStringView textTemplate)