32 m_delayTimer.setSingleShot(
true);
33 connect(&m_delayTimer, &QTimer::timeout,
this, &ShapeCursorSource::selectNextSprite);
48 if (m_shape !=
shape) {
66 if (m_theme !=
theme) {
72void ShapeCursorSource::refresh()
77 m_sprites = m_theme.
shape(m_shape);
78 if (m_sprites.isEmpty()) {
80 for (
const QByteArray &alternativeName : alternativeNames) {
81 m_sprites = m_theme.
shape(alternativeName);
82 if (!m_sprites.isEmpty()) {
88 if (!m_sprites.isEmpty()) {
93void ShapeCursorSource::selectNextSprite()
95 selectSprite((m_currentSprite + 1) % m_sprites.size());
98void ShapeCursorSource::selectSprite(
int index)
100 if (m_currentSprite == index) {
103 const KXcursorSprite &sprite = m_sprites[index];
104 m_currentSprite = index;
105 m_image = sprite.data();
106 m_size = QSizeF(m_image.size()) / m_image.devicePixelRatio();
108 if (sprite.delay().count() && m_sprites.size() > 1) {
109 m_delayTimer.start(sprite.delay());
124void SurfaceCursorSource::refresh()
131void SurfaceCursorSource::reset()
153 disconnect(m_surface, &SurfaceInterface::destroyed,
this, &SurfaceCursorSource::reset);
162 connect(m_surface, &SurfaceInterface::destroyed,
this, &SurfaceCursorSource::reset);
175#include "moc_cursorsource.cpp"
Wrapper round Qt::CursorShape with extensions enums into a single entity.
static QList< QByteArray > alternatives(const QByteArray &name)
CursorSource(QObject *parent=nullptr)
QList< KXcursorSprite > shape(const QByteArray &name) const
void setTheme(const KXcursorTheme &theme)
KXcursorTheme theme() const
void setShape(Qt::CursorShape shape)
ShapeCursorSource(QObject *parent=nullptr)
void setShape(const QByteArray &shape)
SurfaceCursorSource(QObject *parent=nullptr)
SurfaceInterface * surface() const
void update(SurfaceInterface *surface, const QPointF &hotspot)
Resource representing a wl_surface.