加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
kidsprotect.cpp 3.52 KB
一键复制 编辑 原始数据 按行查看 历史
hudejie 提交于 2023-02-10 15:06 . 初始化提交
#include "kidsprotect.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QLabel>
#include <QCheckBox>
#include <QPushButton>
#include "utils.h"
QWidget *CreateCfgItem(QString icon, QString title, QString tip)
{
QPushButton *item = new QPushButton();
item->setStyleSheet("QPushButton{border-style:none;background: #fff; border: 0; }"
"QPushButton:hover {background: #fffcf8; border: 1px solid #ffe7c1; }");
item->setFixedHeight(90);
QLabel *labelIcon = new QLabel();
QLabel *labelTitle = CreateCustomLabel(title, "#444444", 14);
QLabel *labelTip = CreateCustomLabel(tip, "#777777", 12);
QCheckBox *checkBox = new QCheckBox();
checkBox->setStyleSheet("QCheckBox::indicator{width: 32px; height: 32px; }"
"QCheckBox::indicator:checked {border-image:url(:/img/100/switch-ON.png);}"
"QCheckBox::indicator:unchecked {border-image:url(:/img/100/switch-OFF.png);}");
checkBox->setCursor(Qt::PointingHandCursor);
labelIcon->setPixmap(QPixmap(icon));
labelIcon->setFixedWidth(36);
QHBoxLayout *layoutTop = new QHBoxLayout();
layoutTop->addWidget(labelTitle);
layoutTop->addStretch(1);
layoutTop->addWidget(checkBox);
QVBoxLayout *layoutRight = new QVBoxLayout();
layoutRight->addStretch(1);
layoutRight->addLayout(layoutTop);
layoutRight->addWidget(labelTip);
layoutRight->addStretch(1);
layoutRight->setSpacing(2);
layoutRight->setContentsMargins(10, 0, 0, 0);
QHBoxLayout *layoutMain = new QHBoxLayout(item);
layoutMain->addWidget(labelIcon);
layoutMain->addWidget(CreateSeparator(true));
layoutMain->addLayout(layoutRight);
layoutMain->setContentsMargins(20, 10, 20, 10);
layoutMain->setSpacing(10);
return item;
}
KidsProtect::KidsProtect(QWidget *parent) : BaseChildPane(parent)
{
m_strTitle = "访问控制";
InitCtrl();
}
void KidsProtect::InitCtrl()
{
QVBoxLayout *layoutTitle = new QVBoxLayout();
layoutTitle->addWidget(CreateCustomLabel("将计算机调整为更适合访客使用的状态"));
layoutTitle->addWidget(CreateCustomLabel("为防止访问控制配置以及其它配置被修改,推荐使用密码保护", "#777777", 14));
layoutTitle->setSpacing(10);
QVBoxLayout *layoutTopBtn = new QVBoxLayout();
layoutTopBtn->addWidget(CreateCustomButton("密码保护"));
layoutTopBtn->addStretch();
QHBoxLayout *layoutTop = new QHBoxLayout();
layoutTop->addLayout(layoutTitle);
layoutTop->addStretch(1);
layoutTop->addLayout(layoutTopBtn);
QGridLayout *layoutCfg = new QGridLayout();
layoutCfg->addWidget(CreateCfgItem(":/img/100/kidprotect/online.png", "上网时间段控制", "控制计算机上网的时间段或者累计的上网时长"), 0, 0, 1, 1);
layoutCfg->addWidget(CreateCfgItem(":/img/100/kidprotect/website.png", "网站内容控制", "限制计算机访问特定类型网站"), 0, 1, 1, 1);
layoutCfg->addWidget(CreateCfgItem(":/img/100/kidprotect/program.png", "程序执行控制", "限制指定应用程序的执行"), 1, 0, 1, 1);
layoutCfg->addWidget(CreateCfgItem(":/img/100/kidprotect/udisk.png", "U盘使用控制", "限制未信任的U盘接入计算机"), 1, 1, 1, 1);
QVBoxLayout *layoutMain = new QVBoxLayout(this);
layoutMain->addLayout(layoutTop);
layoutMain->addWidget(CreateSeparator());
layoutMain->addLayout(layoutCfg);
layoutMain->addStretch(1);
layoutMain->setContentsMargins(40, 30, 40, 30);
layoutMain->setSpacing(20);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化