Changeset View
Changeset View
Standalone View
Standalone View
src/kselector.cpp
Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | |||||
163 | void KSelector::mouseReleaseEvent(QMouseEvent *e) | 163 | void KSelector::mouseReleaseEvent(QMouseEvent *e) | ||
164 | { | 164 | { | ||
165 | moveArrow(e->pos()); | 165 | moveArrow(e->pos()); | ||
166 | setSliderDown(false); | 166 | setSliderDown(false); | ||
167 | } | 167 | } | ||
168 | 168 | | |||
169 | void KSelector::wheelEvent(QWheelEvent *e) | 169 | void KSelector::wheelEvent(QWheelEvent *e) | ||
170 | { | 170 | { | ||
171 | int val = value() + e->delta() / 120; | 171 | int val = value() + e->angleDelta().y() / 120; | ||
172 | setSliderDown(true); | 172 | setSliderDown(true); | ||
173 | setValue(val); | 173 | setValue(val); | ||
174 | setSliderDown(false); | 174 | setSliderDown(false); | ||
175 | } | 175 | } | ||
176 | 176 | | |||
177 | void KSelector::moveArrow(const QPoint &pos) | 177 | void KSelector::moveArrow(const QPoint &pos) | ||
178 | { | 178 | { | ||
179 | int val; | 179 | int val; | ||
▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Line(s) | 321 | if (!gradientBrush.isOpaque()) { | |||
328 | patternPainter.end(); | 328 | patternPainter.end(); | ||
329 | painter->fillRect(contentsRect(), QBrush(chessboardPattern)); | 329 | painter->fillRect(contentsRect(), QBrush(chessboardPattern)); | ||
330 | } | 330 | } | ||
331 | painter->fillRect(contentsRect(), gradientBrush); | 331 | painter->fillRect(contentsRect(), gradientBrush); | ||
332 | 332 | | |||
333 | if (orientation() == Qt::Vertical) { | 333 | if (orientation() == Qt::Vertical) { | ||
334 | int yPos = contentsRect().top() + painter->fontMetrics().ascent() + 2; | 334 | int yPos = contentsRect().top() + painter->fontMetrics().ascent() + 2; | ||
335 | int xPos = contentsRect().left() + (contentsRect().width() - | 335 | int xPos = contentsRect().left() + (contentsRect().width() - | ||
336 | painter->fontMetrics().width(d->text2)) / 2; | 336 | painter->fontMetrics().horizontalAdvance(d->text2)) / 2; | ||
337 | QPen pen(qGray(firstColor().rgb()) > 180 ? Qt::black : Qt::white); | 337 | QPen pen(qGray(firstColor().rgb()) > 180 ? Qt::black : Qt::white); | ||
338 | painter->setPen(pen); | 338 | painter->setPen(pen); | ||
339 | painter->drawText(xPos, yPos, d->text2); | 339 | painter->drawText(xPos, yPos, d->text2); | ||
340 | 340 | | |||
341 | yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2; | 341 | yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2; | ||
342 | xPos = contentsRect().left() + (contentsRect().width() - | 342 | xPos = contentsRect().left() + (contentsRect().width() - | ||
343 | painter->fontMetrics().width(d->text1)) / 2; | 343 | painter->fontMetrics().horizontalAdvance(d->text1)) / 2; | ||
344 | pen.setColor(qGray(secondColor().rgb()) > 180 ? Qt::black : Qt::white); | 344 | pen.setColor(qGray(secondColor().rgb()) > 180 ? Qt::black : Qt::white); | ||
345 | painter->setPen(pen); | 345 | painter->setPen(pen); | ||
346 | painter->drawText(xPos, yPos, d->text1); | 346 | painter->drawText(xPos, yPos, d->text1); | ||
347 | } else { | 347 | } else { | ||
348 | int yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2; | 348 | int yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2; | ||
349 | 349 | | |||
350 | QPen pen(qGray(firstColor().rgb()) > 180 ? Qt::black : Qt::white); | 350 | QPen pen(qGray(firstColor().rgb()) > 180 ? Qt::black : Qt::white); | ||
351 | painter->setPen(pen); | 351 | painter->setPen(pen); | ||
352 | painter->drawText(contentsRect().left() + 2, yPos, d->text1); | 352 | painter->drawText(contentsRect().left() + 2, yPos, d->text1); | ||
353 | 353 | | |||
354 | pen.setColor(qGray(secondColor().rgb()) > 180 ? Qt::black : Qt::white); | 354 | pen.setColor(qGray(secondColor().rgb()) > 180 ? Qt::black : Qt::white); | ||
355 | painter->setPen(pen); | 355 | painter->setPen(pen); | ||
356 | painter->drawText(contentsRect().right() - | 356 | painter->drawText(contentsRect().right() - | ||
357 | painter->fontMetrics().width(d->text2) - 2, yPos, d->text2); | 357 | painter->fontMetrics().horizontalAdvance(d->text2) - 2, yPos, d->text2); | ||
358 | } | 358 | } | ||
359 | } | 359 | } | ||
360 | 360 | | |||
361 | QSize KGradientSelector::minimumSize() const | 361 | QSize KGradientSelector::minimumSize() const | ||
362 | { | 362 | { | ||
363 | return sizeHint(); | 363 | return sizeHint(); | ||
364 | } | 364 | } | ||
365 | 365 | | |||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |