#pragma execution_character_set("utf-8") #include "frmmain.h" #include "ui_frmmain.h" #include "quihelper.h" frmMain::frmMain(QWidget *parent) : QWidget(parent), ui(new Ui::frmMain) { ui->setupUi(this); this->initForm(); } frmMain::~frmMain() { delete ui; } void frmMain::initForm() { //设置无边框 QUIHelper::setFramelessForm(this); ui->labTitle->setText("智能访客管理平台"); this->setWindowTitle("智能访客管理平台"); //文字加粗显示 ui->widgetRight->setStyleSheet("QLabel{color:#F0F0F0;font:60px;}"); QStringList qss; qss.append("QWidget#widgetLeft>QAbstractButton{background:none;border-radius:0px;}"); qss.append("QWidget#widgetMenu>QAbstractButton{border:0px solid #FF0000;border-radius:0px;padding:0px;margin:0px;}"); this->setStyleSheet(qss.join("")); //添加自定义属性,用于切换ico用 ui->btnInfoExtend->setProperty("icoName", "infoextend"); ui->btnTroubleCheck->setProperty("icoName", "troublecheck"); ui->btnWifiTest->setProperty("icoName", "wifitest"); ui->btnSpeedTest->setProperty("icoName", "speedtest"); ui->btnWebsiteTest->setProperty("icoName", "websitetest"); QList btns = ui->widgetLeft->findChildren(); foreach (QToolButton *btn, btns) { btn->setMaximumHeight(80); btn->setCheckable(true); connect(btn, SIGNAL(clicked(bool)), this, SLOT(buttonClick())); } ui->btnInfoExtend->click(); } void frmMain::buttonClick() { QToolButton *b = (QToolButton *)sender(); QString text = b->text(); QList btns = ui->widgetLeft->findChildren(); foreach (QToolButton *btn, btns) { QString icoName = btn->property("icoName").toString(); if (btn != b) { btn->setChecked(false); btn->setIcon(QIcon(QString(":/image/%1.png").arg(icoName))); } else { btn->setChecked(true); btn->setIcon(QIcon(QString(":/image/%1_focus.png").arg(icoName))); } } if (text == "访客信息") { ui->stackedWidget->setCurrentIndex(0); } else if (text == "访客管理") { ui->stackedWidget->setCurrentIndex(1); } else if (text == "信息查询") { ui->stackedWidget->setCurrentIndex(2); } else if (text == "一键发卡") { ui->stackedWidget->setCurrentIndex(3); } else if (text == "系统设置") { ui->stackedWidget->setCurrentIndex(4); } } void frmMain::on_btnMenu_Min_clicked() { showMinimized(); } void frmMain::on_btnMenu_Max_clicked() { static bool max = false; static QRect location = this->geometry(); if (max) { this->setGeometry(location); } else { location = this->geometry(); this->setGeometry(QUIHelper::getScreenRect()); } this->setProperty("canMove", max); max = !max; } void frmMain::on_btnMenu_Close_clicked() { close(); }