Files
GUI/src/forms/settings/SettingFormWidget.cpp

78 lines
2.3 KiB
C++
Raw Normal View History

//
// Created by Krad on 2021/11/22.
//
#include "SettingFormWidget.h"
2022-06-14 18:04:44 +08:00
#include <QHBoxLayout>
#include <QStackedWidget>
#include <QStringListModel>
#include <QListWidget>
2022-06-14 18:04:44 +08:00
#include "ui_tabformwidget.h"
2021-11-23 13:22:00 +08:00
#include "UserOperationLogForm.h"
2021-12-07 14:13:55 +08:00
#include "generalform.h"
2022-06-14 18:04:44 +08:00
#include "SystemSettingform.h"
2021-12-08 15:10:56 +08:00
#include "AccountTableForm.h"
2021-12-21 16:06:21 +08:00
#include "event/EventCenter.h"
2022-06-14 18:04:44 +08:00
#include "AboutWidget.h"
SettingFormWidget::SettingFormWidget(QWidget* aParent, Qt::WindowFlags f)
2022-06-14 18:04:44 +08:00
: TabFormWidget(aParent)
{
QHBoxLayout* layout = new QHBoxLayout(ui->contentWidget);
2022-07-14 14:41:54 +08:00
// layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
2022-07-12 16:13:09 +08:00
ui->contentWidget->setObjectName("settingContentWidget");
2022-07-14 14:41:54 +08:00
QListWidget* widget = new QListWidget(ui->contentWidget);
2022-06-14 18:04:44 +08:00
widget->setFixedWidth(250);
QStringList menus;
menus << tr("General") << tr("Account") << tr("System") << tr("About");
widget->addItems(menus);
widget->setSpacing(3);
for (int i = 0; i < menus.count(); ++i)
{
widget->item(i)->setTextAlignment(Qt::AlignCenter);
}
layout->addWidget(widget);
2022-07-14 14:41:54 +08:00
QStackedWidget* stackedWidget = new QStackedWidget(ui->contentWidget);
2022-06-14 18:04:44 +08:00
QWidget* spacerLine = new QWidget(this);
spacerLine->setObjectName("verSpaceLine");
layout->addWidget(spacerLine);
layout->addWidget(stackedWidget);
ui->commandWidget->hide();
2021-12-08 15:10:56 +08:00
2022-07-14 14:41:54 +08:00
GeneralForm* generalForm = new GeneralForm(ui->commandWidget);
2022-06-14 18:04:44 +08:00
stackedWidget->addWidget(generalForm);
2022-07-14 14:41:54 +08:00
AccountTableForm* acc = new AccountTableForm(ui->commandWidget);
2022-06-14 18:04:44 +08:00
stackedWidget->addWidget(acc);
2021-11-23 13:22:00 +08:00
2022-07-14 14:41:54 +08:00
SystemSettingForm* systemSetting = new SystemSettingForm(ui->commandWidget);
2022-06-14 18:04:44 +08:00
stackedWidget->addWidget(systemSetting);
2022-01-04 17:10:14 +08:00
2022-07-14 14:41:54 +08:00
AboutWidget* about = new AboutWidget(ui->commandWidget);
2022-06-14 18:04:44 +08:00
stackedWidget->addWidget(about);
2022-01-04 17:10:14 +08:00
2022-06-14 18:04:44 +08:00
widget->setCurrentRow(0);
connect(widget, &QListWidget::currentRowChanged, [=](int rowindex) {
stackedWidget->setCurrentIndex(rowindex);
});
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
QStringList menus;
menus << tr("General") << tr("Account") << tr("System") << tr("About");
widget->clear();
widget->addItems(menus);
for (int i = 0; i < menus.count(); ++i)
{
widget->item(i)->setTextAlignment(Qt::AlignCenter);
}
});
}
SettingFormWidget::~SettingFormWidget()
2022-06-14 18:04:44 +08:00
{
}