@@ -171,7 +171,11 @@ GradientView::updateView(void)
171
171
void
172
172
GradientView::mousePressEvent (QMouseEvent * e)
173
173
{
174
+ #if QT_VERSION >= 0x050D00
175
+ QPoint p = transform ().inverted ().map (e->pos ());
176
+ #else
174
177
QPoint p = matrix ().inverted ().map (e->pos ());
178
+ #endif
175
179
176
180
switch (e->button ()) {
177
181
case Qt::LeftButton:
@@ -206,7 +210,11 @@ GradientView::mousePressEvent(QMouseEvent * e)
206
210
case Qt::RightButton:
207
211
if ((this ->currenttick != -1 ) || (this ->segmentidx != -1 )) {
208
212
this ->buildMenu ();
213
+ #if QT_VERSION >= 0x060000
214
+ if (this ->menu ->exec (e->globalPosition ().toPoint ())) {
215
+ #else
209
216
if (this ->menu ->exec (e->globalPos ())) {
217
+ #endif
210
218
// FIXME: this seems unnecessary. 20031008 mortene.
211
219
delete this ->menu ;
212
220
this ->menu = NULL ;
@@ -230,7 +238,11 @@ GradientView::mouseMoveEvent(QMouseEvent * e)
230
238
{
231
239
if (this ->mousepressed ) {
232
240
if (this ->currenttick == -1 ) { return ; }
241
+ #if QT_VERSION >= 0x050D00
242
+ QPoint p = transform ().inverted ().map (e->pos ());
243
+ #else
233
244
QPoint p = matrix ().inverted ().map (e->pos ());
245
+ #endif
234
246
int x = p.x ();
235
247
236
248
assert (this ->currenttick > 0 );
@@ -253,21 +265,33 @@ GradientView::mouseMoveEvent(QMouseEvent * e)
253
265
254
266
const float value = t * (this ->max - this ->min ) + 0 .5f ;
255
267
QString s;
268
+ #if QT_VERSION >= 0x050E00
269
+ s = QString (" Color table index: %1" ).arg ((int )(value + 0 .5f ));
270
+ #else
256
271
s.sprintf (" Color table index: %d" , (int )(value + 0 .5f ));
272
+ #endif
257
273
this ->statusbar ->showMessage (s);
258
274
259
275
emit this ->viewChanged ();
260
276
}
261
277
} else {
278
+ #if QT_VERSION >= 0x050D00
279
+ QPoint p = transform ().inverted ().map (e->pos ());
280
+ #else
262
281
QPoint p = matrix ().inverted ().map (e->pos ());
282
+ #endif
263
283
float t = (float )p.x () / (float )this ->width ();
264
284
// this test should not be necessary, however the mouse coordinates from
265
285
// the mouse event can sometimes be out of bounds, i.e. they can sometimes
266
286
// be smaller than 0 or larger than canvas.width or canvas.height.
267
287
if ((t >= 0 .0f ) && (t <= 1 .0f )) {
268
288
QRgb col = this ->grad .eval (t);
269
289
QString s;
290
+ #if QT_VERSION >= 0x050E00
291
+ s = QString (" RGBA: 0x%1%2%3%4" ).arg (qRed (col), 2 , 16 , ' 0' ).arg (qGreen (col), 2 , 16 , ' 0' ).arg (qBlue (col, 2 , 16 , ' 0' ).arg (qAlpha (col, 2 , 16 , ' 0' ));
292
+ #else
270
293
s.sprintf (" RGBA: 0x%02x%02x%02x%02x" , qRed (col), qGreen (col), qBlue (col), qAlpha (col));
294
+ #endif
271
295
this ->statusbar ->showMessage (s);
272
296
}
273
297
}
0 commit comments