#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "git_version.h" #include #include #include #include class configSettingWidget :public QWidget{ Q_OBJECT public: QVBoxLayout* m_layout; QScrollArea* scrollArea; QWidget* contentWidget; QHBoxLayout* btnLayout; std::vectorbtns; QLabel* icon, * Title; int currentPageIndex = 0; configSettingWidget(appConfig* _configIn):_config(_configIn){ QPalette palette; palette.setColor(QPalette::WindowText, Qt::white); QFont font("微软雅黑", 24, QFont::Bold); QFont font2("微软雅黑", 8, QFont::Bold); this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); this->setObjectName("configSettingWidget"); this->setStyleSheet(R"( QWidget#configSettingWidget { background: rgb(40, 45, 50); } )"); // 创建主布局 QVBoxLayout* mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setSpacing(0); // 创建滚动区域 scrollArea = new QScrollArea(); scrollArea->setObjectName("configScrollArea"); scrollArea->setStyleSheet(R"( QScrollArea#configScrollArea { border: none; background: transparent; } QScrollBar:vertical { background: rgb(60, 65, 70); width: 12px; border-radius: 6px; } QScrollBar::handle:vertical { background: rgb(100, 105, 110); border-radius: 6px; min-height: 20px; } QScrollBar::handle:vertical:hover { background: rgb(120, 125, 130); } )"); scrollArea->setWidgetResizable(true); scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); // 创建内容容器 contentWidget = new QWidget(); contentWidget->setObjectName("contentWidget"); contentWidget->setStyleSheet("QWidget#contentWidget { background: transparent; }"); m_layout = new QVBoxLayout(contentWidget); m_layout->setContentsMargins(20, 20, 20, 20); m_layout->setSpacing(15); m_layout->setAlignment(Qt::AlignLeft|Qt::AlignTop); // 创建标题区域容器 QWidget* titleWidget = new QWidget(); titleWidget->setObjectName("titleWidget"); titleWidget->setStyleSheet(R"( QWidget#titleWidget { background: rgb(50, 55, 60); border-radius: 10px; padding: 15px; } )"); QVBoxLayout* titleContainerLayout = new QVBoxLayout(titleWidget); titleContainerLayout->setContentsMargins(15, 15, 15, 15); titleContainerLayout->setSpacing(10); // 主标题和版本信息布局 QHBoxLayout* titleLayout = new QHBoxLayout(); titleLayout->setContentsMargins(0, 0, 0, 0); Title = new QLabel(QString::fromStdString(Translation::getInstance().translate("Setting"))); Title->setFont(font); Title->setPalette(palette); Title->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); QLabel* versionShow = new QLabel(QString(u8"当前版本: v%1 | 提交版本: %2").arg(QString::fromStdString(softwareVersion)).arg(GIT_COMMIT_HASH)); versionShow->setFont(font2); versionShow->setPalette(palette); versionShow->setAlignment(Qt::AlignRight | Qt::AlignVCenter); versionShow->setStyleSheet("color: rgb(180, 180, 180);"); titleLayout->addWidget(Title); titleLayout->addStretch(); titleLayout->addWidget(versionShow); titleContainerLayout->addLayout(titleLayout); m_layout->addWidget(titleWidget); //语言设置 { // 创建语言设置分组容器 QGroupBox* languageGroupBox = new QGroupBox(QString::fromStdString(Translation::getInstance().translate("Language Settings"))); languageGroupBox->setObjectName("languageGroupBox"); languageGroupBox->setStyleSheet(R"( QGroupBox#languageGroupBox { background: rgb(50, 55, 60); border-radius: 10px; font-family: "微软雅黑"; font-size: 14px; font-weight: bold; color: white; padding-top: 20px; } QGroupBox#languageGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 10px 0 10px; } )"); QVBoxLayout* languageMainLayout = new QVBoxLayout(languageGroupBox); languageMainLayout->setContentsMargins(15, 15, 15, 15); languageMainLayout->setSpacing(10); QHBoxLayout* languageSelectLayout = new QHBoxLayout(); languageSelectLayout->setSpacing(15); QLabel* languageSelectLabel = new QLabel(u8"选择语言/Language/Bahasa:"); languageSelectLabel->setFont(font2); languageSelectLabel->setPalette(palette); languageSelectLabel->setMinimumWidth(200); QComboBox* languageSelect = new QComboBox(); languageSelect->setMinimumWidth(150); languageSelect->setStyleSheet(R"( QComboBox { background-color: rgb(70, 75, 80); border: 2px solid rgb(100, 105, 110); border-radius: 5px; padding: 5px; color: white; font-family: "微软雅黑"; font-size: 12px; } QComboBox:hover { border-color: rgb(120, 125, 130); } QComboBox::drop-down { border: none; } QComboBox::down-arrow { image: url(:/icons/down-arrow.png); } )"); auto languagesKeys = _configIn->_translation->getSections(); int index = 0; for (int i = 0; i < languagesKeys.size(); i++) { languageSelect->addItem(QString::fromStdString(languagesKeys[i])); if (languagesKeys[i] == _configIn->_translation->getCurrentLanguage()) index = i; } languageSelect->setCurrentIndex(index); QLabel* languageSelectTip = new QLabel(); languageSelectTip->setFont(font2); languageSelectTip->setPalette(palette); languageSelectTip->setStyleSheet("color: rgb(255, 200, 100);"); languageSelectLayout->addWidget(languageSelectLabel); languageSelectLayout->addWidget(languageSelect); languageSelectLayout->addStretch(); languageSelectLayout->addWidget(languageSelectTip); languageMainLayout->addLayout(languageSelectLayout); connect(languageSelect, &QComboBox::currentTextChanged, [=](const QString& str) { _configIn->_translation->setLanguage(str.toStdString()); languageSelectTip->setText(QString::fromStdString(Translation::getInstance().translate("will change after restart"))); }); m_layout->addWidget(languageGroupBox); } //控制台 { // 创建控制台设置分组容器 QGroupBox* consoleGroupBox = new QGroupBox(QString::fromStdString(Translation::getInstance().translate("Window Settings"))); consoleGroupBox->setObjectName("consoleGroupBox"); consoleGroupBox->setStyleSheet(R"( QGroupBox#consoleGroupBox { background: rgb(50, 55, 60); border-radius: 10px; font-family: "微软雅黑"; font-size: 14px; font-weight: bold; color: white; padding-top: 20px; } QGroupBox#consoleGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 10px 0 10px; } )"); QVBoxLayout* consoleMainLayout = new QVBoxLayout(consoleGroupBox); consoleMainLayout->setContentsMargins(15, 15, 15, 15); consoleMainLayout->setSpacing(10); // 添加说明文字 QLabel* consoleDescription = new QLabel(QString::fromStdString(Translation::getInstance().translate("Control the visibility of the debug console window"))); consoleDescription->setFont(font2); consoleDescription->setPalette(palette); consoleDescription->setStyleSheet("color: rgb(180, 180, 180);"); consoleMainLayout->addWidget(consoleDescription); QHBoxLayout* consoletLayout = new QHBoxLayout(); consoletLayout->setSpacing(15); fancyButtonText* showConsoleBtn = new fancyButtonText(QString::fromStdString(Translation::getInstance().translate("showConsole")), 120, 35, ""); showConsoleBtn->setStyleSheet(R"( fancyButtonText { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(80, 180, 80), stop:1 rgb(60, 140, 60)); border-radius: 8px; color: white; font-weight: bold; } fancyButtonText:hover { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(100, 200, 100), stop:1 rgb(80, 160, 80)); } )"); fancyButtonText* hideConsoleBtn = new fancyButtonText(QString::fromStdString(Translation::getInstance().translate("hideConsole")), 120, 35, ""); hideConsoleBtn->setStyleSheet(R"( fancyButtonText { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(180, 80, 80), stop:1 rgb(140, 60, 60)); border-radius: 8px; color: white; font-weight: bold; } fancyButtonText:hover { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(200, 100, 100), stop:1 rgb(160, 80, 80)); } )"); fancyButtonText* setResolutionBtn = new fancyButtonText( u8"设置1920x1040"); setResolutionBtn->setStyleSheet(R"( fancyButtonText { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(80, 130, 180), stop:1 rgb(60, 100, 140)); border-radius: 8px; color: white; font-weight: bold; } fancyButtonText:hover { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(100, 150, 200), stop:1 rgb(80, 120, 160)); } )"); consoletLayout->addWidget(showConsoleBtn); consoletLayout->addWidget(hideConsoleBtn); consoletLayout->addWidget(setResolutionBtn); consoletLayout->addStretch(); consoleMainLayout->addLayout(consoletLayout); connect(showConsoleBtn, &QPushButton::clicked, [=]() { ShowWindow(_config->consoleHandle, SW_SHOW); }); connect(hideConsoleBtn, &QPushButton::clicked, [=]() { ShowWindow(_config->consoleHandle, SW_HIDE); }); connect(setResolutionBtn, &QPushButton::clicked, [=]() { // 获取当前窗口的顶级窗口 QWidget* topWidget = this; while (topWidget->parentWidget()) { topWidget = topWidget->parentWidget(); } // 设置窗口大小为1920x1080 topWidget->resize(1920, 1080); // 可选:将窗口居中显示 QScreen* screen = QApplication::primaryScreen(); if (screen) { QRect screenGeometry = screen->geometry(); int x = (screenGeometry.width() - 1920) / 2; int y = (screenGeometry.height() - 1080) / 2; if (x >= 0 && y >= 0) { topWidget->move(x, y); } } }); m_layout->addWidget(consoleGroupBox); } // 硬件信息区域 { // 创建硬件信息分组容器 QGroupBox* hardwareGroupBox = new QGroupBox(QString::fromStdString(Translation::getInstance().translate("Hardware Information"))); hardwareGroupBox->setObjectName("hardwareGroupBox"); hardwareGroupBox->setStyleSheet(R"( QGroupBox#hardwareGroupBox { background: rgb(50, 55, 60); border-radius: 10px; font-family: "微软雅黑"; font-size: 14px; font-weight: bold; color: white; padding-top: 20px; } QGroupBox#hardwareGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 10px 0 10px; } )"); QVBoxLayout* hardwareMainLayout = new QVBoxLayout(hardwareGroupBox); hardwareMainLayout->setContentsMargins(15, 15, 15, 15); hardwareMainLayout->setSpacing(10); // 设置硬件信息组件的样式 _hardwareInfoWidget.setStyleSheet(R"( QWidget { background: transparent; color: white; font-family: "微软雅黑"; } QLabel { color: rgb(220, 220, 220); font-size: 12px; } )"); hardwareMainLayout->addWidget(&_hardwareInfoWidget); m_layout->addWidget(hardwareGroupBox); } // 添加底部伸缩空间 m_layout->addStretch(); // 设置滚动区域 scrollArea->setWidget(contentWidget); mainLayout->addWidget(scrollArea); } protected: private: appConfig* _config; hardwareInfoWidget _hardwareInfoWidget; //std::vector> privateJsondatas;//路径与数据 //std::vector> privateWidgets;//路径与数据 //std::vectorjsonLayouts; }; #pragma once