Changeset View
Changeset View
Standalone View
Standalone View
src/kxyselector.cpp
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | 186 | { | |||
---|---|---|---|---|---|
189 | valuesFromPosition(e->pos().x() - w, e->pos().y() - w, xVal, yVal); | 189 | valuesFromPosition(e->pos().x() - w, e->pos().y() - w, xVal, yVal); | ||
190 | setValues(xVal, yVal); | 190 | setValues(xVal, yVal); | ||
191 | 191 | | |||
192 | emit valueChanged(d->xPos, d->yPos); | 192 | emit valueChanged(d->xPos, d->yPos); | ||
193 | } | 193 | } | ||
194 | 194 | | |||
195 | void KXYSelector::wheelEvent(QWheelEvent *e) | 195 | void KXYSelector::wheelEvent(QWheelEvent *e) | ||
196 | { | 196 | { | ||
197 | if (e->orientation() == Qt::Horizontal) { | 197 | setValues(xValue() + e->angleDelta().x() / 120, yValue() + e->angleDelta().y() / 120); | ||
198 | setValues(xValue() + e->delta() / 120, yValue()); | | |||
199 | } else { | | |||
200 | setValues(xValue(), yValue() + e->delta() / 120); | | |||
201 | } | | |||
202 | | ||||
203 | emit valueChanged(d->xPos, d->yPos); | 198 | emit valueChanged(d->xPos, d->yPos); | ||
204 | } | 199 | } | ||
205 | 200 | | |||
206 | void KXYSelector::valuesFromPosition(int x, int y, int &xVal, int &yVal) const | 201 | void KXYSelector::valuesFromPosition(int x, int y, int &xVal, int &yVal) const | ||
207 | { | 202 | { | ||
208 | int w = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); | 203 | int w = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); | ||
209 | 204 | | |||
210 | xVal = ((d->maxX - d->minX) * (x - w)) / (width() - 2 * w); | 205 | xVal = ((d->maxX - d->minX) * (x - w)) / (width() - 2 * w); | ||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |