From cf27fae386a4c0ff75eec8d5994295266867a1c9 Mon Sep 17 00:00:00 2001 From: stli Date: Sat, 11 Apr 2026 09:05:20 +0800 Subject: [PATCH] Add APP settings page --- KeyBorad/KeyBorad/APP/AppSettingsPage.cpp | 61 +++++++++++++++++++++++ KeyBorad/KeyBorad/APP/AppSettingsPage.h | 23 +++++++++ 2 files changed, 84 insertions(+) create mode 100644 KeyBorad/KeyBorad/APP/AppSettingsPage.cpp create mode 100644 KeyBorad/KeyBorad/APP/AppSettingsPage.h diff --git a/KeyBorad/KeyBorad/APP/AppSettingsPage.cpp b/KeyBorad/KeyBorad/APP/AppSettingsPage.cpp new file mode 100644 index 0000000..b185441 --- /dev/null +++ b/KeyBorad/KeyBorad/APP/AppSettingsPage.cpp @@ -0,0 +1,61 @@ +#include "APP/AppSettingsPage.h" + +#include "APP/AppTheme.h" + +#include +#include +#include +#include + +namespace APP +{ + +App_SettingsPage::App_SettingsPage(QWidget* p_Parent) + : QWidget(p_Parent) +{ + QVBoxLayout* const p_RootLayout = new QVBoxLayout(this); + p_RootLayout->setContentsMargins(0, 0, 0, 0); + p_RootLayout->setSpacing(12); + + QFrame* const p_Card = new QFrame(this); + p_Card->setStyleSheet(App_Theme_BuildCardStyleSheet()); + p_RootLayout->addWidget(p_Card); + + QVBoxLayout* const p_CardLayout = new QVBoxLayout(p_Card); + p_CardLayout->setContentsMargins(20, 20, 20, 20); + p_CardLayout->setSpacing(14); + + QLabel* const p_Title = new QLabel(QStringLiteral("Settings"), p_Card); + p_Title->setProperty("role", "title"); + p_CardLayout->addWidget(p_Title); + + QLabel* const p_Body = new QLabel( + QStringLiteral("Use this page to present transport status and the latest function result."), + p_Card); + p_Body->setProperty("role", "body"); + p_Body->setWordWrap(true); + p_CardLayout->addWidget(p_Body); + + QFormLayout* const p_FormLayout = new QFormLayout(); + p_FormLayout->setHorizontalSpacing(12); + p_FormLayout->setVerticalSpacing(12); + p_CardLayout->addLayout(p_FormLayout); + + appConnectionLabel = new QLabel(QStringLiteral("Disconnected"), p_Card); + appLastActionLabel = new QLabel(QStringLiteral("Idle"), p_Card); + + p_FormLayout->addRow(QStringLiteral("Transport"), appConnectionLabel); + p_FormLayout->addRow(QStringLiteral("Last Action"), appLastActionLabel); +} + +void App_SettingsPage::App_Func_SetConnectionText(const QString& Text) +{ + appConnectionLabel->setText(Text.trimmed().isEmpty() ? QStringLiteral("Disconnected") : Text.trimmed()); +} + +void App_SettingsPage::App_Func_SetLastActionText(const QString& Text) +{ + appLastActionLabel->setText(Text.trimmed().isEmpty() ? QStringLiteral("Idle") : Text.trimmed()); +} + +} // namespace APP diff --git a/KeyBorad/KeyBorad/APP/AppSettingsPage.h b/KeyBorad/KeyBorad/APP/AppSettingsPage.h new file mode 100644 index 0000000..bb65b0f --- /dev/null +++ b/KeyBorad/KeyBorad/APP/AppSettingsPage.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +class QLabel; + +namespace APP +{ + +class App_SettingsPage : public QWidget +{ +public: + explicit App_SettingsPage(QWidget* p_Parent = nullptr); + + void App_Func_SetConnectionText(const QString& Text); + void App_Func_SetLastActionText(const QString& Text); + +private: + QLabel* appConnectionLabel = nullptr; + QLabel* appLastActionLabel = nullptr; +}; + +} // namespace APP