utils: Make hotspot in CursorTheme QPointF

As far as I know, the reason that the CursorTheme provides a QPoint
hotspot is mostly due to the historical reasons. At the time, all
hotspot math had relied upon integer hotspots. After
4cd25cf571 it is no longer the case.
wilder/Plasma/6.2
Vlad Zahorodnii 2 years ago
parent 5837d042c9
commit b26eb86310
  1. 6
      src/utils/cursortheme.cpp
  2. 4
      src/utils/cursortheme.h
  3. 2
      src/utils/svgcursorreader.cpp
  4. 2
      src/utils/xcursorreader.cpp

@ -25,7 +25,7 @@ class CursorSpritePrivate : public QSharedData
{
public:
QImage data;
QPoint hotspot;
QPointF hotspot;
std::chrono::milliseconds delay;
};
@ -90,7 +90,7 @@ CursorSprite &CursorSprite::operator=(const CursorSprite &other)
return *this;
}
CursorSprite::CursorSprite(const QImage &data, const QPoint &hotspot, const std::chrono::milliseconds &delay)
CursorSprite::CursorSprite(const QImage &data, const QPointF &hotspot, const std::chrono::milliseconds &delay)
: d(new CursorSpritePrivate)
{
d->data = data;
@ -103,7 +103,7 @@ QImage CursorSprite::data() const
return d->data;
}
QPoint CursorSprite::hotspot() const
QPointF CursorSprite::hotspot() const
{
return d->hotspot;
}

@ -39,7 +39,7 @@ public:
/**
* Constructs an CursorSprite with the specified @a data, @a hotspot, and @a delay.
*/
CursorSprite(const QImage &data, const QPoint &hotspot, const std::chrono::milliseconds &delay);
CursorSprite(const QImage &data, const QPointF &hotspot, const std::chrono::milliseconds &delay);
/**
* Destructs the CursorSprite object.
@ -61,7 +61,7 @@ public:
*
* The coordinates of the hotspot are in device independent pixels.
*/
QPoint hotspot() const;
QPointF hotspot() const;
/**
* Returns the time interval between this sprite and the next one, in milliseconds.

@ -138,7 +138,7 @@ QList<CursorSprite> SvgCursorReader::load(const QString &containerPath, int desi
renderer.render(&painter, bounds);
painter.end();
sprites.append(CursorSprite(image, (entry.hotspot * scale).toPoint(), entry.delay));
sprites.append(CursorSprite(image, entry.hotspot * scale, entry.delay));
}
return sprites;

@ -44,7 +44,7 @@ QList<CursorSprite> XCursorReader::load(const QString &filePath, int desiredSize
for (int i = 0; i < images->nimage; ++i) {
const XcursorImage *nativeCursorImage = images->images[i];
const qreal scale = std::max(qreal(1), qreal(nativeCursorImage->size) / desiredSize);
const QPoint hotspot(nativeCursorImage->xhot, nativeCursorImage->yhot);
const QPointF hotspot(nativeCursorImage->xhot, nativeCursorImage->yhot);
const std::chrono::milliseconds delay(nativeCursorImage->delay);
QImage data(nativeCursorImage->width, nativeCursorImage->height, QImage::Format_ARGB32_Premultiplied);

Loading…
Cancel
Save