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);
184 if (displayRenderer) {
188 connect(
d->
displayRenderer, SIGNAL(displayConfigurationChanged()),
this, SLOT(update()));
219 QPainter painter(
this );
221 QBrush defBrush = palette().brush( QPalette::Button );
227 foregroundBrush = Qt::black;
228 backgroundBrush = Qt::white;
232 isEnabled() ? &backgroundBrush : &defBrush );
235 isEnabled() ? &foregroundBrush : &defBrush );
237 painter.setPen( palette().color( QPalette::Shadow ) );
250 event->setAccepted( isEnabled() && KColorMimeData::canDecode(
event->mimeData() ) );
306 if (usePlatformDialog) {
308 c = QColorDialog::getColor(c,
this);
323 if (usePlatformDialog) {
325 c = QColorDialog::getColor(c,
this);
388 int delay = QApplication::startDragDistance();
411 KConfigGroup cfg = KSharedConfig::openConfig()->group(
"colorselector");
412 bool usePlatformDialog = cfg.readEntry(
"UsePlatformColorDialog",
false);
440 QWidget::changeEvent(
event);
442 switch (
event->type()) {
443 case QEvent::StyleChange:
444 case QEvent::PaletteChange:
453 if (
event->type() == QEvent::ToolTip) {
455 const QHelpEvent *helpEvent =
static_cast<QHelpEvent*
>(
event);
457 if (this->mapFromGlobal(helpEvent->globalPos()).x() <
backgroundRect.x() ) {
458 if (this->mapFromGlobal(helpEvent->globalPos()).y() <
backgroundRect.y()){
459 this->setToolTip(i18n(
"Foreground color selector"));
462 this->setToolTip(i18n(
"Set foreground and background colors to black and white"));
466 if (this->mapFromGlobal(helpEvent->globalPos()).y() <
backgroundRect.y() ) {
467 this->setToolTip(i18n(
"Swap foreground and background colors"));
470 this->setToolTip(i18n(
"Background color selector"));
474 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)