代码拉取完成,页面将自动刷新
#include "mainwindow.h"
#include <DMainWindow>
#include <dapplication.h>
#include <dtitlebar.h>
#include <DButtonBox>
#include <QScreen>
#include <dlabel.h>
#include <QGridLayout>
DWIDGET_USE_NAMESPACE
MainWindow::MainWindow(QWidget *parent)
: DMainWindow(),m_layout(new QStackedLayout),m_controlsPage(new ControlsPage),m_encryptionPage(new Encryptionpage)
{
initUI();
initConnections();
}
MainWindow::~MainWindow()
{
}
void MainWindow::initUI()
{
//设置界面初始显示大小
setMinimumSize(qApp->primaryScreen()->availableSize() / 7 * 4);
m_seg = new DSegmentedControl;
// 为DSegmentedControl中添加选项
m_seg->addSegmented("MD5/SHA256/DES/RSA");
m_seg->addSegmented("base64与图文转换");
// 在标题栏中显示DSegmentedControl控件
titlebar()->setCustomWidget(m_seg, true);
m_layout->addWidget(m_encryptionPage);
m_layout->addWidget(m_controlsPage);
DTitlebar *titlebar = this->titlebar();
DButtonBox *buttonBox = new DButtonBox(titlebar);
buttonBox->setFixedWidth(170);
buttonBox->setButtonList({new DButtonBoxButton("浅色模式"), new DButtonBoxButton("深色模式")}, true);
buttonBox->setId(buttonBox->buttonList().at(0), 0);
buttonBox->setId(buttonBox->buttonList().at(1), 1);
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
buttonBox->buttonList().at(0)->click();
} else {
buttonBox->buttonList().at(1)->click();
}
connect(buttonBox, &DButtonBox::buttonClicked, this, [buttonBox](QAbstractButton *button) {
if (buttonBox->id(button) == 0) {
DGuiApplicationHelper::instance()->setPaletteType(DGuiApplicationHelper::LightType);
} else {
DGuiApplicationHelper::instance()->setPaletteType(DGuiApplicationHelper::DarkType);
}
});
//titlebar->setTitle("图片文字base64编码互换");
titlebar->addWidget(buttonBox);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(m_layout);
// mainLayout->addStretch(); //没生效?
//mainLayout->addWidget(new DSeparatorHorizontal());
// 设置主窗口内容
QFrame *content = new QFrame;
content->setLayout(mainLayout);
setCentralWidget(content);
}
void MainWindow::initConnections()
{
connect(m_seg, &DSegmentedControl::currentChanged, this, [this] (int index) {
m_layout->setCurrentIndex(index);
});
// connect(pRecommend, &DPushButton::clicked, this, [] {
// DDialog dialog("", "这里现实简要出错信息XXXXXXXX", nullptr);
// dialog.setIcon(DStyle().standardIcon(DStyle::SP_MessageBoxWarning));
// dialog.addButton("显示详情");
// dialog.addButton("确定");
// dialog.exec();
// });
qDebug() << "initConnections()";
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。