Files
0417_QT_code/APP/APP_KeyButton.h

52 lines
1.3 KiB
C
Raw Normal View History

2026-03-26 10:45:29 +08:00
#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