52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include "APP/APP_KeypadModel.h"
|
|
#include <QtGui/QColor>
|
|
#include <QtWidgets/QPushButton>
|
|
|
|
namespace APP {
|
|
|
|
/*
|
|
* 这是小键盘界面里的单个按键控件。
|
|
*
|
|
* 它的职责很单纯:
|
|
* 1. 保存这颗键自己的显示信息
|
|
* 2. 根据“锁定态 / 按下态”切换颜色
|
|
* 3. 自己完成绘制
|
|
*
|
|
* 它不负责协议解析,也不直接参与 DRI / LGC 逻辑。
|
|
*/
|
|
class APP_KeyButton : public QPushButton
|
|
{
|
|
public:
|
|
explicit APP_KeyButton(const APP_KeyInfo& KeyInfo, QWidget* parent = nullptr);
|
|
|
|
// 锁定态通常表示这颗键处于某种功能模式。
|
|
void App_Func_SetLatched(bool IsLatched);
|
|
|
|
// 按下态表示实体键或逻辑键当前真的处于按下中。
|
|
void App_Func_SetPressed(bool IsPressed);
|
|
|
|
protected:
|
|
// 每颗键都自己画背景、边框、提示文字和主文字。
|
|
void paintEvent(QPaintEvent* event) override;
|
|
|
|
private:
|
|
// 下面这些函数只负责给 paintEvent 提供颜色。
|
|
QColor App_Func_GetAccentColor() const;
|
|
QColor App_Func_GetBackgroundColor() const;
|
|
QColor App_Func_GetBorderColor() const;
|
|
QColor App_Func_GetTextColor() const;
|
|
|
|
// 这颗键对应的显示信息。
|
|
APP_KeyInfo appKeyInfo;
|
|
|
|
// 是否处于锁定态。
|
|
bool appIsLatched = false;
|
|
|
|
// 是否处于按下态。
|
|
bool appIsPressed = false;
|
|
};
|
|
|
|
} // namespace APP
|