11#include <kcolormimedata.h>
12#include <kconfiggroup.h>
13#include <ksharedconfig.h>
15#include "dcolorreset.xpm"
17#include <QColorDialog>
26#include <QDragEnterEvent>
30#include <QApplication>
37 QWidget *_dialogParent,
76 q->setAcceptDrops(
true );
77 QString caption = i18n(
"Select a Color");
87 QWidget *parent, QWidget* dialogParent)
89 d( new
Private(canvasResourceProvider->fgColor(),canvasResourceProvider->bgColor(),
102 resetPixmap = QPixmap( (
const char **)dcolorreset_xpm );
104 QColor windowText =
d->
dialogParent->palette().windowText().color();
110 pen.setCompositionMode(QPainter::CompositionMode_SourceIn);
118 pen.setCompositionMode(QPainter::CompositionMode_SourceIn);
147 return QSize(34, 34);
181 if (!displayRenderer) {
193 if (displayRenderer) {
232 QPainter painter(
this );
234 QBrush defBrush = palette().brush( QPalette::Button );
240 foregroundBrush = Qt::black;
241 backgroundBrush = Qt::white;
245 isEnabled() ? &backgroundBrush : &defBrush );
248 isEnabled() ? &foregroundBrush : &defBrush );
250 painter.setPen( palette().color( QPalette::Shadow ) );
263 event->setAccepted( isEnabled() && KColorMimeData::canDecode(
event->mimeData() ) );
319 if (usePlatformDialog) {
321 c = QColorDialog::getColor(c,
this);
336 if (usePlatformDialog) {
338 c = QColorDialog::getColor(c,
this);
401 int delay = QApplication::startDragDistance();
424 KConfigGroup cfg = KSharedConfig::openConfig()->group(
"colorselector");
425 bool usePlatformDialog = cfg.readEntry(
"UsePlatformColorDialog",
false);
453 QWidget::changeEvent(
event);
455 switch (
event->type()) {
456 case QEvent::StyleChange:
457 case QEvent::PaletteChange:
466 if (
event->type() == QEvent::ToolTip) {
468 const QHelpEvent *helpEvent =
static_cast<QHelpEvent*
>(
event);
470 if (this->mapFromGlobal(helpEvent->globalPos()).x() <
backgroundRect.x() ) {
471 if (this->mapFromGlobal(helpEvent->globalPos()).y() <
backgroundRect.y()){
472 this->setToolTip(i18n(
"Foreground color selector"));
475 this->setToolTip(i18n(
"Set foreground and background colors to black and white"));
479 if (this->mapFromGlobal(helpEvent->globalPos()).y() <
backgroundRect.y() ) {
480 this->setToolTip(i18n(
"Swap foreground and background colors"));
483 this->setToolTip(i18n(
"Background color selector"));
487 return QWidget::event(
event);
The KisInternalColorSelector class.
void setPreviousColor(KoColor c)
setPreviousColor set the previous color.
void setDisplayRenderer(const KoColorDisplayRendererInterface *displayRenderer)
setDisplayRenderer Set the display renderer. This is necessary for HDR color manage support.
void lockUsedColorSpace(const KoColorSpace *cs)
lockUsedColorSpace Lock the used colorspace of this selector.
void slotColorUpdated(KoColor newColor)
slotColorUpdated Very important slot. Is connected to krita's resources to make sure it has the curre...
void convertTo(const KoColorSpace *cs, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags)
void toQColor(QColor *c) const
a convenience method for the above.
static KoColorDisplayRendererInterface * instance()
QIcon loadIcon(const QString &name)