33 lines
702 B
C
33 lines
702 B
C
|
#ifndef MODETHREAD_H
|
||
|
#define MODETHREAD_H
|
||
|
|
||
|
#include <QThread>
|
||
|
|
||
|
#include "wl_numlock.h"
|
||
|
|
||
|
class ModeThread : public QThread
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
ModeThread(){}
|
||
|
~ModeThread(){ delete key_manager; }
|
||
|
|
||
|
void setMode(int m){ mode = m; }
|
||
|
|
||
|
private:
|
||
|
int mode = 0; // 0 - on/off, 1 - on, 2 - off
|
||
|
WLKeyManager * key_manager = new WLKeyManager();
|
||
|
|
||
|
protected:
|
||
|
void run() override{
|
||
|
forever{
|
||
|
if (mode == 0) return;
|
||
|
msleep(50);
|
||
|
if ((mode == 1 && !key_manager->getNumLockState()) || (mode == 2 && key_manager->getNumLockState()))
|
||
|
key_manager->pressNumLock();
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
#endif // MODETHREAD_H
|