jianbin.chang常健彬 ce734d1af1 厂家提供原始代码
2025-07-17 08:39:15 +08:00

378 lines
8.3 KiB
C++

#include "twobars.h"
#include "ui_twobars.h"
#include<QDebug>
#include<QGraphicsDropShadowEffect>
QString id;
extern bool save;
twobars::twobars(QWidget *parent) :
QWidget(parent),
ui(new Ui::twobars)
{
ui->setupUi(this);
m_setupuers=new setupuers;
m_setsystem=new setsystem;
m_bacteria=new bacteria;
m_micjishu=new micjishu;
m_addusers=new addusers;
m_bachistoricalrecords=new bachistoricalrecords;
m_michistoricalrecords=new michistoricalrecords;
m_ziwai=new ziwai;
m_zongmic=new zongmic;
m_zongjunluo=new zongjunluo;
ui->stackedWidget->setCurrentIndex(0);
ui->stackedWidget->setFixedHeight(1020);
ui->gridLayout_7->addWidget(m_setupuers);
ui->gridLayout_10->addWidget(m_setsystem);
ui->gridLayout_12->addWidget(m_zongjunluo);
ui->gridLayout_14->addWidget(m_zongmic);
ui->gridLayout_16->addWidget(m_bachistoricalrecords);
ui->gridLayout_18->addWidget(m_michistoricalrecords);
m_cammer=new cammer;
connect(this, SIGNAL(guan()), m_zongjunluo, SLOT(getguan()));
connect(this, SIGNAL(guan2()), m_zongmic, SLOT(getguan()));
connect(this, SIGNAL(kai()), m_zongjunluo, SLOT(getkai()));
connect(this, SIGNAL(kai2()), m_zongmic, SLOT(getkai()));
connect(m_bacteria,&bacteria::tuichu,this,[=](){qDebug()<<"退出登录";this->close();});
connect(m_micjishu,&micjishu::tuichu,this,[=](){qDebug()<<"退出登录";this->close();});
QTimer *timer;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(gettime()));
timer->start(1000);
this->setWindowFlags(Qt::FramelessWindowHint); // 隐藏标题栏
ui->pushButton->setAutoFillBackground(true);
ui->pushButton->setFixedSize(200,200);
ui->pushButton_2->setAutoFillBackground(true);
ui->pushButton_2->setFixedSize(200,200);
ui->pushButton_5->setAutoFillBackground(true);
ui->pushButton_5->setFixedSize(200,200);
ui->pushButton_10->setAutoFillBackground(true);
ui->pushButton_10->setFixedSize(200,200);
ui->widget_2->setFixedHeight(40);
ui->stackedWidget->setFixedHeight(930);
ui->widget->setFixedHeight(60);
ui->label_3->setScaledContents(true);
ui->label_3->setFixedSize(150,42);
ui->label->setFixedSize(20,20);
ui->label->setScaledContents(true);
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
//设置阴影距离
shadow->setOffset(0, 0);
//设置阴影颜色
shadow->setColor(QColor(214, 214, 214));
//设置阴影圆角
shadow->setBlurRadius(30);
ui->widget_3->setFixedSize(1920,40);
ui->widget_3->setGraphicsEffect(shadow);
// QGraphicsDropShadowEffect *shadow2 = new QGraphicsDropShadowEffect(this);
// //设置阴影距离
// shadow2->setOffset(0, 0);
// //设置阴影颜色
// shadow2->setColor(QColor(214, 214, 214));
// //设置阴影圆角
// shadow2->setBlurRadius(30);
// //给嵌套QWidget设置阴影
// ui->widget_2->setFixedSize(1920,40);
// ui->widget_2->setGraphicsEffect(shadow2);
}
twobars::~twobars()
{
delete ui;
}
void twobars::getzhu()
{
ui->stackedWidget->setCurrentIndex(0);
}
QString twobars::gettime()
{
QDateTime dateTime= QDateTime::currentDateTime();//获取系统当前的时间
QString str = dateTime .toString("yyyy-MM-dd hh:mm:ss");//格式化时间
ui->label_32->setText(str);
return ui->label_32->text();
}
void twobars::getname()
{
ui->label_5->setText(id);
QString sql2=QString("select juese from users where id='%1'").arg(id);
qDebug()<<sql2;
QSqlQuery query2;
if(query2.exec(sql2))
{
if(query2.first()){
QString juese=query2.value(0).toString();
qDebug()<<juese;
ui->label_7->setText(juese);
if(juese=="管理员"){ui->radioButton_6->setHidden(false);ui->radioButton_7->setHidden(false);
}
else{ui->radioButton_6->setHidden(true);ui->radioButton_7->setHidden(true);
}
}
}
else
{
qDebug()<<"没查到角色";
}
}
//返回
void twobars::on_pushButton_7_clicked()
{
if(save==false)
{
int ok=QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
if (ok == QMessageBox::Ok) {
}
}else{
ui->stackedWidget->setCurrentIndex(0);
ui->radioButton_6->setHidden(false);
ui->radioButton_7->setHidden(false);
emit guan();
}
}
//细菌计数
void twobars::on_pushButton_clicked()
{
if(save==false)
{
int ok=QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
if (ok == QMessageBox::Ok) {
}
}else{
ui->stackedWidget->setCurrentIndex(3);
ui->radioButton_2->setChecked(true);
emit kai();
}
}
//mic计数
void twobars::on_pushButton_2_clicked()
{
if(save==false)
{
int ok=QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
if (ok == QMessageBox::Ok) {
}
}else{
ui->stackedWidget->setCurrentIndex(4);
ui->radioButton->setChecked(true);
m_micjishu->getshui();
emit kai2();
}
}
void twobars::on_pushButton_6_clicked()
{
if(save==false)
{
int ok=QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
if (ok == QMessageBox::Ok) {
}
}else{
int result = QMessageBox::information(NULL, "提示", "确定要退出登录吗", QMessageBox::Ok | QMessageBox::Cancel);
if (result == QMessageBox::Ok) {
emit denglu();
emit guan();
emit guan2();
this->close();
}
}
}
//紫外线
void twobars::on_pushButton_10_clicked()
{
if(save==false)
{
int ok=QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
}else{
m_ziwai->show();
m_ziwai->qidong();
}
}
void twobars::on_toolButton_3_clicked()
{
this->showMinimized();
}
void twobars::on_toolButton_2_clicked()
{
this->showFullScreen();
}
void twobars::on_toolButton_clicked()
{
if(save==false)
{
QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
}else{
int result = QMessageBox::information(NULL, "提示", "确定要退出运行吗", QMessageBox::Ok | QMessageBox::Cancel);
if (result == QMessageBox::Ok) {
emit guan();
emit guan2();
QTimer::singleShot(500,this,[=](){qApp->quit();
}) ;
}
}
}
void twobars::on_pushButton_8_clicked()
{
ui->stackedWidget->setCurrentIndex(0);
ui->radioButton_6->setHidden(false);
ui->radioButton_7->setHidden(false);
emit guan2();
}
//主页
void twobars::on_radioButton_5_clicked()
{
if(save==false)
{
QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
}else{
ui->stackedWidget->setCurrentIndex(0);
}
}
//MIC
void twobars::on_radioButton_clicked()
{
if(save==false)
{
QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
}else{
emit guan();
ui->stackedWidget->setCurrentIndex(4);
m_micjishu->getshui();
emit kai2();
}
}
void twobars::on_radioButton_2_clicked()
{
if(save==false)
{
QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
}else{
emit guan2();
ui->stackedWidget->setCurrentIndex(3);
emit kai();
}
}
void twobars::on_radioButton_3_clicked()
{
if(save==false)
{
QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
}else{
m_ziwai->show();
m_ziwai->qidong();
}
}
void twobars::on_radioButton_6_clicked()
{
if(save==false)
{
QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
}else{
ui->stackedWidget->setCurrentIndex(2);
}
}
void twobars::on_radioButton_7_clicked()
{
if(save==false)
{
QMessageBox::information(NULL,"保存","请先保存照片", QMessageBox::Ok | QMessageBox::Cancel);
}else{
ui->stackedWidget->setCurrentIndex(1);
m_bachistoricalrecords->getname();
}
}