49 : KSelector(o, parent), d(new
Private)
53 connect(
d->displayRenderer, SIGNAL(displayConfigurationChanged()), SLOT(update()), Qt::UniqueConnection);
54 connect(&
d->updateCompressor, SIGNAL(timeout()), SLOT(update()), Qt::UniqueConnection);
72 QPixmap checker(8, 8);
74 p.fillRect(0, 0, 4, 4, Qt::lightGray);
75 p.fillRect(4, 0, 4, 4, Qt::darkGray);
76 p.fillRect(0, 4, 4, 4, Qt::darkGray);
77 p.fillRect(4, 4, 4, 4, Qt::lightGray);
79 QRect contentsRect_(contentsRect());
80 painter->fillRect(contentsRect_, QBrush(checker));
82 if( !
d->upToDate ||
d->pixmap.isNull() ||
d->pixmap.width() != contentsRect_.width()
83 ||
d->pixmap.height() != contentsRect_.height() )
88 const quint8 *colors[2];
89 colors[0] =
d->minColor.data();
90 colors[1] =
d->maxColor.data();
94 QImage image(contentsRect_.width(), contentsRect_.height(), QImage::Format_ARGB32 );
96 if( orientation() == Qt::Horizontal ) {
97 for (
int x = 0; x < contentsRect_.width(); x++) {
99 qreal t =
static_cast<qreal
>(x) / (contentsRect_.width() - 1);
101 qint16 colorWeights[2];
102 colorWeights[0] =
static_cast<quint8
>((1.0 - t) * 255 + 0.5);
103 colorWeights[1] = 255 - colorWeights[0];
107 if (
d->displayRenderer) {
108 color =
d->displayRenderer->toQColor(c);
114 for (
int y = 0; y < contentsRect_.height(); y++)
115 image.setPixel(x, y, color.rgba());
119 for (
int y = 0; y < contentsRect_.height(); y++) {
121 qreal t =
static_cast<qreal
>(y) / (contentsRect_.height() - 1);
123 qint16 colorWeights[2];
124 colorWeights[0] =
static_cast<quint8
>((t) * 255 + 0.5);
125 colorWeights[1] = 255 - colorWeights[0];
129 if (
d->displayRenderer) {
130 color =
d->displayRenderer->toQColor(c);
136 for (
int x = 0; x < contentsRect_.width(); x++)
137 image.setPixel(x, y, color.rgba());
140 d->pixmap = QPixmap::fromImage(image);
143 painter->drawPixmap( contentsRect_,
d->pixmap, QRect( 0, 0,
d->pixmap.width(),
d->pixmap.height()) );
162 painter->setPen(QPen(
palette().text().color(), 0));
163 painter->setBrush(
palette().text());
167 o.state &= ~QStyle::State_MouseOver;
169 if ( orientation() == Qt::Vertical ) {
170 o.rect = QRect( pos.x(), pos.y() -
ARROWSIZE / 2,
173 o.rect = QRect( pos.x() -
ARROWSIZE / 2, pos.y(),
177 QStyle::PrimitiveElement arrowPE;
178 switch (arrowDirection()) {
180 arrowPE = QStyle::PE_IndicatorArrowUp;
183 arrowPE = QStyle::PE_IndicatorArrowDown;
186 arrowPE = QStyle::PE_IndicatorArrowRight;
190 arrowPE = QStyle::PE_IndicatorArrowLeft;
194 style()->drawPrimitive(arrowPE, &o, painter,
this);
virtual void mixColors(const quint8 *const *colors, const qint16 *weights, int nColors, quint8 *dst, int weightSum=255) const =0