feat: progress on changing interactions to mousearea again
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <qcursor.h>
|
||||
#include <qguiapplication.h>
|
||||
#include <qlogging.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qobject.h>
|
||||
#include <qqmlintegration.h>
|
||||
|
||||
@@ -14,23 +16,25 @@ class Cursor : public QObject {
|
||||
|
||||
public:
|
||||
Q_INVOKABLE void setOverride(Qt::CursorShape shape) {
|
||||
if (m_override)
|
||||
if (m_shape == shape) return;
|
||||
|
||||
if (m_shape)
|
||||
QGuiApplication::changeOverrideCursor(QCursor(shape));
|
||||
else {
|
||||
QGuiApplication::setOverrideCursor(QCursor(shape));
|
||||
m_override = true;
|
||||
}
|
||||
m_shape = shape;
|
||||
}
|
||||
|
||||
Q_INVOKABLE void clearOverride() {
|
||||
if (!m_override) return;
|
||||
if (!m_shape) return;
|
||||
|
||||
QGuiApplication::restoreOverrideCursor();
|
||||
m_override = false;
|
||||
m_shape.reset();
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_override = false;
|
||||
std::optional<Qt::CursorShape> m_shape;
|
||||
};
|
||||
|
||||
} // namespace ZShell::internal
|
||||
|
||||
Reference in New Issue
Block a user