You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.7 KiB
64 lines
1.7 KiB
4 years ago
|
#ifndef BUTTON_H
|
||
|
#define BUTTON_H
|
||
|
|
||
|
#include <QObject>
|
||
|
#include <QElapsedTimer>
|
||
|
#include <QMutex>
|
||
|
|
||
|
#include "model/csm/core/consoleComponent/ControlAbstract.h"
|
||
|
|
||
|
/*****************************************************************************/
|
||
|
/**
|
||
|
* @brief Button Class, this class is a part of console button
|
||
|
* @author Mohammad Mohsen Talaie
|
||
|
* @details
|
||
|
* @date 12 Jan 2021
|
||
|
*/
|
||
|
/*****************************************************************************/
|
||
|
class Button : public ControlAbstract
|
||
|
{
|
||
|
private:
|
||
|
bool _down;
|
||
|
QMutex _downLoker;
|
||
|
QElapsedTimer _timer;
|
||
|
|
||
|
QList<CommandControl_t> _currentCommandList;
|
||
|
QList<CommandControl_t> _longPressCommands;
|
||
|
QList<CommandControl_t> _commonLongPressCommands;
|
||
|
QMap<EConsole::eConsoleState, QList<CommandControl_t> > _longPressCommandListBasedOnState;
|
||
|
|
||
|
bool _longPressEnable;
|
||
|
|
||
|
public:
|
||
|
Button()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
QList<CommandControl_t> getCommandList(const EConsole::eConsoleState& consoleState) override;
|
||
|
QList<CommandControl_t> getLongPressCommandList(const EConsole::eConsoleState& consoleState);
|
||
|
EConsole::eControlType getType() const override;
|
||
|
|
||
|
void loadLongPressCommands(const EConsole::eConsoleState& consoleState);
|
||
|
void enable() override;
|
||
|
void disable() override;
|
||
|
|
||
|
void appendCommonLongPressCommandList(const CommandControl_t& commandControl);
|
||
|
|
||
|
void appendLongPressCommandListBasedOnConsoleState(const QString& consoleState,
|
||
|
const CommandControl_t& commandControl);
|
||
|
|
||
|
//start timer
|
||
|
void keyDown();
|
||
|
|
||
|
//calculate timer between down and up
|
||
|
long keyUp();
|
||
|
|
||
|
bool isDown() const;
|
||
|
|
||
|
bool hasLongPress() const;
|
||
|
|
||
|
bool hasTimeOutExpired(const long& timeOut);
|
||
|
};
|
||
|
|
||
|
#endif //BUTTON_H
|