Files

41 lines
738 B
C++

#pragma once
#include <qcursor.h>
#include <qguiapplication.h>
#include <qlogging.h>
#include <qnamespace.h>
#include <qobject.h>
#include <qqmlintegration.h>
namespace ZShell::internal {
class Cursor : public QObject {
Q_OBJECT
QML_SINGLETON
QML_ELEMENT
public:
Q_INVOKABLE void setOverride(Qt::CursorShape shape) {
if (m_shape == shape) return;
if (m_shape)
QGuiApplication::changeOverrideCursor(QCursor(shape));
else {
QGuiApplication::setOverrideCursor(QCursor(shape));
}
m_shape = shape;
}
Q_INVOKABLE void clearOverride() {
if (!m_shape) return;
QGuiApplication::restoreOverrideCursor();
m_shape.reset();
}
private:
std::optional<Qt::CursorShape> m_shape;
};
} // namespace ZShell::internal