#ifndef BUTTONHELPER_H #define BUTTONHELPER_H #define PUSH_BUTTON(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \ private: \ PushButton _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \ void init ## CAPITAL_NAME() \ { \ connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \ SIGNAL(SMALL_NAME ## LedChanged(char))); \ } \ public: \ void press ## CAPITAL_NAME() \ { \ auto arr = _ ## SMALL_NAME.press(); \ _dataSender->send(arr); \ } \ void release ## CAPITAL_NAME() \ { \ auto arr = _ ## SMALL_NAME.release(); \ _dataSender->send(arr); \ } \ Q_SIGNAL void SMALL_NAME ## LedChanged(char value) /*************************************************************************************************/ #define PUSH_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \ private: \ PushButton _ ## SMALL_NAME{FUNC_CODE}; \ void init ## CAPITAL_NAME() \ { \ connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \ SIGNAL(SMALL_NAME ## LedChanged(char))); \ } \ public: \ void press ## CAPITAL_NAME() \ { \ auto arr = _ ## SMALL_NAME.press(); \ _dataSender->send(arr); \ } \ void release ## CAPITAL_NAME() \ { \ auto arr = _ ## SMALL_NAME.release(); \ _dataSender->send(arr); \ } \ Q_SIGNAL void SMALL_NAME ## LedChanged(char value) /*************************************************************************************************/ #define ROTARY_BUTTON(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \ private: \ RotaryButton _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \ void init ## CAPITAL_NAME() \ { \ connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \ SIGNAL(SMALL_NAME ## LedChanged(char))); \ } \ public: \ void rotate ## CAPITAL_NAME(int value) \ { \ auto arr = _ ## SMALL_NAME.rotate(value); \ _dataSender->send(arr); \ } \ Q_SIGNAL void SMALL_NAME ## LedChanged(char value) /*************************************************************************************************/ #define ROTARY_BUTTON_NO_LED(CAPITAL_NAME, SMALL_NAME, FUNC_CODE) \ private: \ RotaryButton _ ## SMALL_NAME{FUNC_CODE}; \ void init ## CAPITAL_NAME() \ { \ connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \ SIGNAL(SMALL_NAME ## LedChanged(char))); \ } \ public: \ void rotate ## CAPITAL_NAME(int value) \ { \ auto arr = _ ## SMALL_NAME.rotate(value); \ _dataSender->send(arr); \ } \ Q_SIGNAL void SMALL_NAME ## LedChanged(char value) /*************************************************************************************************/ #define DROP_DOWN(CAPITAL_NAME, SMALL_NAME, FUNC_CODE, LED_FUNC_CODE) \ private: \ DropDown _ ## SMALL_NAME{FUNC_CODE, LED_FUNC_CODE}; \ void init ## CAPITAL_NAME() \ { \ connect(this, &Console::dataReady, _ ## SMALL_NAME.getLed(), &Led::newData); \ connect(_ ## SMALL_NAME.getLed(), SIGNAL(ledChanged(char)), this, \ SIGNAL(SMALL_NAME ## LedChanged(char))); \ } \ public: \ void select ## CAPITAL_NAME(int value) \ { \ auto arr = _ ## SMALL_NAME.select(value); \ _dataSender->send(arr); \ } \ Q_SIGNAL void SMALL_NAME ## LedChanged(char value) #endif //BUTTONHELPER_H