第一次上传
This commit is contained in:
38
PublicFunctions/CursorController.h
Normal file
38
PublicFunctions/CursorController.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef CURSORCONTROLLER_H
|
||||
#define CURSORCONTROLLER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
#include <QKeyEvent>
|
||||
|
||||
class CursorController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CursorController(QObject *parent = nullptr);
|
||||
|
||||
// 可调参数
|
||||
struct Config {
|
||||
int step = 20; // 每步像素
|
||||
bool wrap = false;// 边缘回绕
|
||||
bool emulate = true; // 是否发送点击事件
|
||||
int edgeGap = 5; // 离边缘空隙
|
||||
};
|
||||
|
||||
Config cfg; // 直接改成员即可实时生效
|
||||
|
||||
public slots:
|
||||
void handleKey(int key); // 接受 Qt::Key_xxx
|
||||
|
||||
signals:
|
||||
void cursorMoved(const QPoint &globalPos);
|
||||
void clicked(QWidget *target);
|
||||
|
||||
private:
|
||||
QPoint m_pos;
|
||||
bool m_useRealCursor; // true: 系统光标 false: 自绘光标
|
||||
void move(const QPoint &delta);
|
||||
void emulateClick();
|
||||
};
|
||||
|
||||
#endif // CURSORCONTROLLER_H
|
||||
Reference in New Issue
Block a user