132 lines
4.2 KiB
C++
132 lines
4.2 KiB
C++
#pragma once
|
|
|
|
#include "APP/APP_KeypadModel.h"
|
|
#include "DEBUG/Debug_Config.h"
|
|
#include "LOGIC/Lgc_Core.h"
|
|
#include <QtCore/QHash>
|
|
#include <QtCore/QTimer>
|
|
#include <QtWidgets/QWidget>
|
|
|
|
#if APP_ENABLE_DEBUG_WINDOW
|
|
#include "DEBUG/Debug_Panel.h"
|
|
#endif
|
|
|
|
class QLabel;
|
|
class QButtonGroup;
|
|
class QComboBox;
|
|
class QLineEdit;
|
|
|
|
namespace APP {
|
|
|
|
class APP_KeyButton;
|
|
|
|
/*
|
|
* APP 主窗口负责把界面搭起来,并把 UI 事件转交给逻辑层。
|
|
* 它只做三件事:
|
|
* 1. 创建界面
|
|
* 2. 周期性刷新 UI
|
|
* 3. 把 Windows 原生消息转给 LGC / DRI
|
|
*/
|
|
class App_UIWindow : public QWidget
|
|
{
|
|
public:
|
|
// 构造主窗口并完成 UI、信号和逻辑初始化。
|
|
explicit App_UIWindow(QWidget* parent = nullptr);
|
|
// 析构时负责收尾逻辑层资源。
|
|
~App_UIWindow() override;
|
|
|
|
protected:
|
|
// 自绘主窗口背景和简单装饰。
|
|
void paintEvent(QPaintEvent* event) override;
|
|
// 接收 Windows 原生消息,再转给 LGC / DRI 处理。
|
|
bool nativeEvent(const QByteArray& EventType, void* p_Message, long* p_Result) override;
|
|
|
|
private:
|
|
// 设置窗口标题、大小和基础属性。
|
|
void App_Func_InitWindow();
|
|
// 创建主界面控件和布局。
|
|
void App_Func_InitUi();
|
|
// 连接按钮、定时器等信号。
|
|
void App_Func_InitConnect();
|
|
// 初始化逻辑层状态和设备配置。
|
|
void App_Func_InitLogic();
|
|
// 执行一轮完整 UI 刷新。
|
|
void App_Func_RefreshUi();
|
|
// 刷新主键盘区状态摘要。
|
|
void App_Func_RefreshKeypadState();
|
|
// 刷新主键盘按钮显示。
|
|
void App_Func_RefreshKeypadButtons();
|
|
// 刷新功能键按钮显示。
|
|
void App_Func_RefreshFunctionButtons();
|
|
// 刷新功能配置区状态文字。
|
|
void App_Func_RefreshFunctionStatus();
|
|
// 刷新调试页显示内容。
|
|
void App_Func_RefreshDebugView();
|
|
// 逻辑状态改变后集中刷新必要区域。
|
|
void App_Func_RefreshAfterLogicChange();
|
|
// 把界面里的功能配置回写到逻辑层。
|
|
void App_Func_UpdateFunctionConfigFromUi();
|
|
// 处理功能键区按钮点击。
|
|
void App_Func_OnFunctionKeyClicked(quint16 Usage);
|
|
// 定时轮询设备输入与状态。
|
|
void App_Func_OnPollTimer();
|
|
|
|
#if APP_ENABLE_DEBUG_WINDOW
|
|
/*
|
|
* 如果后续要整体删除调试功能,
|
|
* 可以优先从这些入口和 APP_ENABLE_DEBUG_WINDOW 宏开始删。
|
|
*/
|
|
// 处理“应用 VID/PID”按钮点击。
|
|
void App_Func_OnApplyDeviceConfigClicked();
|
|
// 处理“刷新设备”按钮点击。
|
|
void App_Func_OnRefreshDeviceClicked();
|
|
// 处理“清空日志”按钮点击。
|
|
void App_Func_OnClearLogClicked();
|
|
// 用逻辑层当前状态刷新调试页输入框。
|
|
void App_Func_RefreshDeviceConfigFromState();
|
|
#endif
|
|
|
|
// 创建左侧主键盘卡片。
|
|
QWidget* App_Func_CreatePadCard();
|
|
// 创建右侧功能键配置卡片。
|
|
QWidget* App_Func_CreateFunctionRegisterCard();
|
|
QWidget* App_Func_CreateFunctionConfigCard();
|
|
|
|
#if APP_ENABLE_DEBUG_WINDOW
|
|
// 创建调试卡片。
|
|
QWidget* App_Func_CreateDebugCard();
|
|
#endif
|
|
|
|
// 键盘布局模型,负责提供按键元数据。
|
|
APP_KeypadModel appKeypadModel;
|
|
// 主键盘按钮映射表:键名 -> 按钮对象。
|
|
QHash<QString, APP_KeyButton*> appKeypadButtonMap;
|
|
// 功能键按钮映射表:键名 -> 按钮对象。
|
|
QHash<QString, APP_KeyButton*> appFunctionButtonMap;
|
|
// 功能键按钮组,用来统一处理点击。
|
|
QButtonGroup* appFunctionButtonGroup = nullptr;
|
|
|
|
// 功能区状态说明标签。
|
|
QLabel* appFunctionLabelStatus = nullptr;
|
|
// 功能键 0 的文本宏输入框。
|
|
QLineEdit* appFunctionEditMacroText = nullptr;
|
|
// 功能键 1 左侧交换键选择框。
|
|
QComboBox* appFunctionComboSwapLeft = nullptr;
|
|
// 功能键 1 右侧交换键选择框。
|
|
QComboBox* appFunctionComboSwapRight = nullptr;
|
|
// 功能键 2 的网址输入框。
|
|
QLineEdit* appFunctionEditWebsite = nullptr;
|
|
|
|
#if APP_ENABLE_DEBUG_WINDOW
|
|
// 调试面板实例。
|
|
DEBUG::Debug_Panel* appDebugPanel = nullptr;
|
|
#endif
|
|
|
|
// 周期轮询逻辑层的定时器。
|
|
QTimer appTimerPoll;
|
|
// APP 层持有的逻辑总状态。
|
|
Lgc_Core_Struct_State appLgcState;
|
|
};
|
|
|
|
} // namespace APP
|