692 lines
24 KiB
C++
692 lines
24 KiB
C++
#include "LogInfo.h"
|
|
#include "ui_loginfo.h"
|
|
#include <QTime>
|
|
#include <QDir>
|
|
#include <QDebug>
|
|
#include <QFile>
|
|
#include <QIODevice>
|
|
#include <QTextDocumentWriter>
|
|
#include <QMessageBox>
|
|
#include "DevOp.h"
|
|
#include <stdio.h>
|
|
#include <QScrollBar>
|
|
#include <QSettings>
|
|
|
|
#ifndef LOGINFOFILE_DIR
|
|
#define LOGINFOFILE_DIR "/home/plg/loginfo/"
|
|
#endif
|
|
#define UDISK_LOGINFO_ROOT_DIR "/udisk/log/"
|
|
|
|
LogInfo::LogInfo(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::LogInfo)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
ui->textEditRunStatus->setReadOnly(true);
|
|
ui->textEditRunStatus_2->setReadOnly(true);
|
|
textEdit = ui->textEditRunStatus;
|
|
textEdit->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 40px; }");
|
|
textEdit2 = ui->textEditRunStatus_2;
|
|
textEdit2->verticalScrollBar()->setStyleSheet("QScrollBar:vertical { width: 40px; }");
|
|
|
|
|
|
textEditMachInfo = ui->machinInformation;
|
|
runStatusTextIndex = 0;
|
|
openFileName ="";
|
|
ui->labelPreFileName->setText("");
|
|
|
|
textEdit2->append(tr("请先打开历史状态文件!"));
|
|
if(!QDir("/home/plg").exists())
|
|
QDir("/home/plg").mkdir("/home/plg");
|
|
readRunStatusText();
|
|
runStatusTextIndex = textEdit->document()->lineCount();
|
|
fileDialog=0; // 先初始化为0 ,否则会死机
|
|
|
|
QFile file(SYS_ROOT_DIR"UseEn");
|
|
if(!file.exists()){
|
|
onReadRecorder( );
|
|
}
|
|
timerLogdel=new QTimer(this);
|
|
connect(timerLogdel, SIGNAL(timeout()), this, SLOT(deleteOldLog()));
|
|
//延时60秒删除日志文件
|
|
timerLogdel->start(60000);
|
|
setScrollBar();
|
|
|
|
init();
|
|
|
|
ui->label_11->setText(tr("齿轮泵转速"));
|
|
connect(ui->labelFaultResume,SIGNAL(pressed()),this,SIGNAL(faultTesumePress()));
|
|
|
|
|
|
timerCheckReclaimStatus = new QTimer(this);
|
|
connect(timerCheckReclaimStatus, &QTimer::timeout, this, &LogInfo::checkReclaimStatus);
|
|
timerCheckReclaimStatus->start(500);
|
|
}
|
|
|
|
LogInfo::~LogInfo()
|
|
{
|
|
textEdit = 0;
|
|
textEdit2 = 0;
|
|
textEditMachInfo = 0;
|
|
if(fileDialog)
|
|
delete fileDialog;
|
|
delete ui;
|
|
|
|
disconnect(timerLogdel, SIGNAL(timeout()), this, SLOT(deleteOldLog()));
|
|
timerLogdel->stop();
|
|
}
|
|
|
|
void LogInfo::init()
|
|
{
|
|
applyStyleSheet();
|
|
// 连接信号槽
|
|
connect(ui->closeBtn1, &QPushButton::clicked, this, &LogInfo::buttonClickedSlot);
|
|
|
|
connect(ui->closeBtn2,&QPushButton::clicked, this, &LogInfo::buttonClickedSlot);
|
|
|
|
connect(ui->closeBtn3,&QPushButton::clicked,this,&LogInfo::buttonClickedSlot);
|
|
|
|
connect(ui->closeBtn4,&QPushButton::clicked,this,&LogInfo::buttonClickedSlot);
|
|
|
|
const QString style_main2="QTabBar::tab {height:65px;border-top-left-radius: 6px;border-top-right-radius: 6px;padding-left: 11px;padding-right: 11px;border: 2px solid #C4C4C3;} \
|
|
QTabBar::tab:selected {background-color: rgb(255, 170, 127);height:70px;}\
|
|
QTabBar::tab:!selected {margin-top: 5px;}\
|
|
QTabBar::scroller{ width:80px;}";
|
|
// this->setStyleSheet(style_main2);
|
|
if (ctrl_loginfo == nullptr) ctrl_loginfo = LogInfoCtrl::instance();
|
|
connect(ctrl_loginfo, &LogInfoCtrl::sig_cleanOver, this, &LogInfo::slt_cleanOver);
|
|
}
|
|
|
|
void LogInfo::buttonClickedSlot()
|
|
{
|
|
QPushButton* btn = qobject_cast<QPushButton*>(sender());
|
|
if (btn == ui->closeBtn1)
|
|
{
|
|
emit sendButtonClickedSignal(1);
|
|
}else if(btn == ui->closeBtn2){
|
|
emit sendButtonClickedSignal(2);
|
|
}else if(btn == ui->closeBtn3){
|
|
emit sendButtonClickedSignal(3);
|
|
}else if(btn == ui->closeBtn4){
|
|
emit sendButtonClickedSignal(4);
|
|
}
|
|
}
|
|
|
|
QTextEdit *LogInfo::textEdit = 0;
|
|
QTextEdit *LogInfo::textEdit2 = 0;
|
|
QTextEdit *LogInfo::textEditMachInfo = 0;
|
|
|
|
int LogInfo::runStatusTextIndex = 0;
|
|
|
|
void LogInfo::showMachineInformation(QString Mac,QString SerialNum, QString VernonBachVer, QString FpgaVer)
|
|
{
|
|
QString machInfo;
|
|
machInfo = "Mac:" + Mac + "\n";
|
|
// machInfo += "Serial Number:" + SerialNum + "\n";
|
|
machInfo += "VernonBach Ver:" + VernonBachVer + "\n";
|
|
machInfo += "FPGA Ver:" + FpgaVer;
|
|
// QFile kernelVer("/proc/version");
|
|
// if (kernelVer.open(QFile::ReadOnly | QFile::Text)) {
|
|
// QTextStream in(&kernelVer);
|
|
// QString kernelVer=in.readLine();
|
|
// QStringList list=kernelVer.split(" ");
|
|
// QStringList list2=kernelVer.split("#");
|
|
// machInfo = machInfo + "Kernel: ";
|
|
// machInfo = machInfo + list.at(2);
|
|
// machInfo = machInfo + "(" + list2.at(1) + ")";
|
|
// }
|
|
|
|
textEditMachInfo->setText(machInfo);
|
|
}
|
|
|
|
void LogInfo::showVerionInformation(QString Mac,QString VernonBachVer, QString FpgaVer,QString STM32Ver)
|
|
{
|
|
static bool flag = false;
|
|
if(!flag){
|
|
QString machInfo;
|
|
machInfo = "Mac:" + Mac + "\n";
|
|
machInfo += "VernonBach Ver:" + VernonBachVer +"|"+STM32Ver+ "\n";
|
|
machInfo += "FPGA Ver: NO" + FpgaVer + "\n";
|
|
// machInfo += "PowerOnMode: " + QString::number(powerOnMode) + "\n";
|
|
textEditMachInfo->append(machInfo);
|
|
}
|
|
}
|
|
|
|
void LogInfo::showRemoteControll(QString SuperNode, QString edgeIP)
|
|
{
|
|
QString machInfo = textEditMachInfo->toPlainText();
|
|
machInfo += "SuperNode:" + SuperNode + "\n";
|
|
machInfo += "edgeIP:" + edgeIP + "\n";
|
|
textEditMachInfo->setText(machInfo);
|
|
}
|
|
|
|
//edit@01-11
|
|
void LogInfo::setRunStatusText(QString str){
|
|
if(!textEdit){
|
|
return;
|
|
}
|
|
const int maxTextEditHeight = 2000;
|
|
if(textEdit->document()->size().height() > maxTextEditHeight)
|
|
{
|
|
textEdit->clear(); //显示今天全部信息,加载太多可能会死机
|
|
}
|
|
str.prepend(QString("%1. %2:").arg(QString::number(runStatusTextIndex ++ )).arg(QTime::currentTime().toString("hh:mm:ss")));
|
|
textEdit->append(str);
|
|
{
|
|
const QString dts=QDate::currentDate().toString("yyyyMMdd") ;
|
|
QString fileNameL=QString(LOGINFOFILE_DIR)+dts +"_1.txt";
|
|
QFile file(fileNameL);
|
|
if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)){
|
|
QTextStream out(&file);
|
|
out<<str<<endl;
|
|
file.close();
|
|
}
|
|
truncatelog();
|
|
}
|
|
|
|
textEdit->moveCursor(QTextCursor::End);
|
|
|
|
qInfo() << "RunStatusText:"<< str;
|
|
}
|
|
|
|
QString LogInfo::getRunStatusText(void){
|
|
return "";
|
|
}
|
|
|
|
void LogInfo::readRunStatusText()
|
|
{
|
|
QString fileName;
|
|
if(textEdit){
|
|
QDir dir1;
|
|
dir1.setPath(LOGINFOFILE_DIR);
|
|
if(!dir1.exists())
|
|
dir1.mkdir(QString ("/home/plg/loginfo/"));
|
|
fileName=QString("/home/plg/loginfo/")+QDate::currentDate().toString("yyyyMMdd")+"_1.txt";
|
|
QFile file(fileName);
|
|
if(file.exists()){
|
|
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
|
QMessageBox::warning(this,tr("警告"),tr("无法打开文件") + file.fileName());
|
|
}
|
|
else{
|
|
QTextStream in (&file);
|
|
textEdit->setText(in.readAll());
|
|
}
|
|
file.close();
|
|
ui->tabWidget->setCurrentWidget(ui->tab);
|
|
}
|
|
|
|
QDate date1 = QDate::currentDate();
|
|
for(int i=0;i<8;i++)
|
|
{
|
|
fileName=QString("/home/plg/loginfo/")+date1.addDays(-i-5).toString("yyyyMMdd")+".txt";
|
|
file.setFileName(fileName);
|
|
if(file.exists()){
|
|
file.remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void LogInfo::on_pushButtonExportFile_pressed()
|
|
{
|
|
QMessageBox::StandardButton ret;
|
|
ret = QMessageBox::information(this, tr("提示"),
|
|
tr("是否确认将所有日志文件导出到U盘?"),
|
|
QMessageBox::Ok | QMessageBox::Cancel);
|
|
if (ret == QMessageBox::Ok){
|
|
//QString dirPath = ui->radioButtonLocal->isChecked()?DOC_ROOT_DIR:UDISK_LOGINFO_ROOT_DIR;
|
|
QDir dir(UDISK_LOGINFO_ROOT_DIR);
|
|
if(!dir.exists()){
|
|
// system((char *)((QString("mkdir -p %1").arg(UDISK_LOGINFO_ROOT_DIR)).toLatin1().data()));
|
|
system((char *)((QString("mkdir -p %1").arg(UDISK_LOGINFO_ROOT_DIR)).toLocal8Bit().data()));
|
|
}
|
|
|
|
if(!dir.exists()){
|
|
QMessageBox::warning(this,tr("警告"),tr("U盘目录创建失败"));
|
|
return;
|
|
}
|
|
|
|
//插入U盘后,检测目录usb-storage是否存在
|
|
if(!QDir("/proc/scsi/usb-storage/").exists()){
|
|
QMessageBox::warning(this,tr("警告"),tr("U盘未插入或无法识别,请重新插拔设备!"));
|
|
return;
|
|
}
|
|
|
|
// system((char *)((QString("cp -r %1/* %2/").arg(LOGINFOFILE_DIR).arg(UDISK_LOGINFO_ROOT_DIR)).toLatin1().data()));
|
|
system((char *)((QString("cp -r %1/* %2/").arg(LOGINFOFILE_DIR).arg(UDISK_LOGINFO_ROOT_DIR)).toLocal8Bit().data()));
|
|
//refreshListView(EditMode);
|
|
system("sync");
|
|
QMessageBox::information(this, tr("提示"),
|
|
tr("成功导出到U盘"));
|
|
}
|
|
}
|
|
|
|
void LogInfo::on_pushButtonPreState_pressed(){
|
|
|
|
if(textEdit2){
|
|
//setRunStatusText(QString("FILE COUNT:%1").arg( QDir("/home/plg/loginfo/").count()));
|
|
//if( QDir("/home/plg/loginfo/").count()<4) {
|
|
if( QDir("/home/plg/loginfo/").count()<1) {
|
|
//QMessageBox::warning(this,"警告","没有历史文件");
|
|
textEdit2->setText( "目前历史文件数量为0个");
|
|
return;
|
|
}
|
|
//qDebug()<<"3333";
|
|
if(openFileName.isEmpty()) textEdit2->clear();
|
|
if(fileDialog) {
|
|
// qDebug()<<"4444";
|
|
disconnect(fileDialog,SIGNAL(accepted()),0,0); // 如果对话框已经定义,则删除控件关联,否则也会出错。
|
|
|
|
}
|
|
else {//qDebug()<<"5";
|
|
fileDialog = new MyFileDialog(0);
|
|
//qDebug()<<"6";
|
|
}
|
|
//qDebug()<<"7";
|
|
QDir dir1;
|
|
dir1.setPath(QString ("/home/plg/loginfo/"));
|
|
|
|
if(!dir1.exists())
|
|
{dir1.mkdir(QString ("/home/plg/loginfo/"));}
|
|
if(fileDialog){
|
|
//qDebug()<<"8";
|
|
|
|
if(fileDialog->directory().path()!="/home/plg/loginfo")
|
|
fileDialog->setDirectory(QDir("/home/plg/loginfo"));
|
|
|
|
|
|
//qDebug()<<"read File 3.2"<<dir1.Name;
|
|
connect(fileDialog,SIGNAL(accepted()),this,SLOT(onOpen_FIle_select()));
|
|
//qDebug()<<"read File 4"<<dir1.Name;
|
|
fileDialog->showFileDialog(tr("选择历史记录文件"),dir1.path(),QString("Txt files (*.txt)"));
|
|
//qDebug()<<"read File 5";
|
|
}
|
|
//else qDebug()<<"read File:"<<dir1.path();
|
|
}
|
|
}
|
|
|
|
|
|
void LogInfo::onOpen_FIle_select()
|
|
{
|
|
QStringList files = fileDialog->selectedFiles();
|
|
if( files.size()==0) return ;
|
|
if(QString(files[0]).isNull()) return;
|
|
QString fileName = files[0];
|
|
|
|
if(!fileName.endsWith(".txt",Qt::CaseInsensitive)) return ;
|
|
|
|
openFileName = fileName;
|
|
QFile file(openFileName);
|
|
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
|
QMessageBox::warning(this,tr("警告"),tr("无法打开文件") + openFileName);
|
|
}
|
|
else{
|
|
QTextStream in (&file);
|
|
textEdit2->setText(in.readAll());
|
|
textEdit2->moveCursor(QTextCursor::End);//滚动条移到底部
|
|
//ui->labelPreFileName->setText(file.fileName());
|
|
QFileInfo info(file.fileName());
|
|
ui->labelPreFileName->setText(info.fileName());
|
|
}
|
|
file.close();
|
|
ui->tabWidget->setCurrentWidget(ui->tab_2);
|
|
|
|
}
|
|
|
|
void LogInfo::on_pushButtonClear_pressed()
|
|
{
|
|
QMessageBox::StandardButton ret;
|
|
ret = QMessageBox::information(this, tr("提示"),
|
|
tr("是否确认将历史日志文件全部清除?"),
|
|
QMessageBox::Ok | QMessageBox::Cancel);
|
|
if (ret == QMessageBox::Ok){
|
|
QDir dir1(QString("/home/plg/loginfo/"));
|
|
if(dir1.exists())
|
|
{
|
|
system((char *)QString("rm /home/plg/loginfo/*.*").toLatin1().data());
|
|
deleteDirectoryContents(dir1);
|
|
}
|
|
else system((char *)QString("mkdir /home/plg/loginfo/").toLatin1().data());
|
|
}
|
|
}
|
|
|
|
void LogInfo::on_pushButtonClearCurrent_pressed()
|
|
{
|
|
QMessageBox::StandardButton ret;
|
|
ret = QMessageBox::information(this, tr("提示"),
|
|
tr("是否确认将当前日志全部清除?"),
|
|
QMessageBox::Ok | QMessageBox::Cancel);
|
|
if (ret == QMessageBox::Ok){
|
|
textEdit->clear();
|
|
runStatusTextIndex=0;
|
|
}
|
|
}
|
|
|
|
void LogInfo::onReadRecorder()
|
|
{
|
|
QString fileName = ":/buge_record.txt";
|
|
|
|
if(!fileName.endsWith(".txt",Qt::CaseInsensitive)) return ;
|
|
QFile file(fileName);
|
|
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
|
|
QMessageBox::warning(this,tr("警告"),tr("无法打开文件") + openFileName);
|
|
}
|
|
else{
|
|
QTextStream in (&file);
|
|
textEditMachInfo->setText(in.readAll());
|
|
}
|
|
}
|
|
|
|
|
|
void LogInfo::deleteDirectoryContents(const QDir &directory) {
|
|
QList<QFileInfo> entries = directory.entryInfoList(
|
|
QDir::NoDotAndDotDot | QDir::AllEntries);
|
|
QString today = QDate::currentDate().toString(Qt::ISODate);
|
|
// 使用传统的 for 循环遍历所有条目
|
|
for (int i = 0; i < entries.size(); ++i) {
|
|
QFileInfo entryInfo = entries.at(i);
|
|
QString dirName=entryInfo.baseName();
|
|
if(today==dirName)
|
|
continue;
|
|
QString fullPath = entryInfo.absoluteFilePath();
|
|
|
|
if (entryInfo.isFile() || entryInfo.isSymLink()) {
|
|
// 如果是文件或符号链接,尝试删除
|
|
if (!QFile::remove(fullPath)) {
|
|
qDebug() << "Failed to remove file or symlink:" << fullPath;
|
|
}
|
|
} else if (entryInfo.isDir()) {
|
|
// 如果是目录,递归调用以删除其内容
|
|
QDir subDir(fullPath);
|
|
deleteDirectoryContents(subDir);
|
|
|
|
// 目录现在应该是空的,尝试删除它
|
|
if (!QDir().rmdir(fullPath)) {
|
|
qDebug() << "Failed to remove directory:" << fullPath;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 删除指定文件夹超过七天的文件
|
|
void LogInfo::deleteOldLog(const QString folderPath,int days){
|
|
QDir dir(folderPath); // 创建一个QDir对象用于操作传入的文件夹路径
|
|
if (!dir.exists()) { // 判断传入文件夹是否存在
|
|
qDebug() << "文件夹不存在";
|
|
return;
|
|
}
|
|
QDateTime currentDateTime = QDateTime::currentDateTime(); // 获取当前时间
|
|
QDateTime sevenDaysAgo = currentDateTime.addDays(-days); // 计算days天前的日期时间
|
|
// 目录下的文件和子目录的信息列表,列出所有文件和子目录并按照最后修改时间排序
|
|
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Time);
|
|
foreach (QFileInfo fileInfo ,fileInfoList) {
|
|
if (!fileInfo.isDir()){
|
|
QString fileExtension = fileInfo.suffix().toLower(); // 获取文件的扩展名并确保它是小写的
|
|
// 选择删除那种图片类型
|
|
if (fileExtension == "txt") {
|
|
if (fileInfo.lastModified() < sevenDaysAgo && fileInfo.fileName().indexOf('_')!=-1) { // 获取最后一个文件夹修改时间和days传入的时间最对比
|
|
if (QFile::remove(fileInfo.absoluteFilePath())) { // 删除满足条件的文件的绝对路径
|
|
qDebug() << "删除成功" << fileInfo.absoluteFilePath();
|
|
} else {
|
|
qDebug() << "文件删除失败" << fileInfo.absoluteFilePath();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void LogInfo::deleteOldLog()
|
|
{
|
|
qDebug()<<"延时60秒删除过期日志";
|
|
deleteOldLog(LOGINFOFILE_DIR,7);//删除一周前的日志
|
|
timerLogdel->stop();
|
|
}
|
|
|
|
void LogInfo::truncatelog()
|
|
{
|
|
const QString dts=QDate::currentDate().toString("yyyyMMdd") ;
|
|
const QString fileNameL=QString(LOGINFOFILE_DIR)+dts +"_1.txt";
|
|
QFile file(fileNameL);
|
|
|
|
if(file.size()>204800)//文件大小
|
|
{
|
|
QSettings settings("MySoft", "MyApp");
|
|
int filenum=settings.value(dts,2).toInt();
|
|
if(filenum==2)
|
|
settings.clear();
|
|
settings.setValue(dts,filenum+1);
|
|
|
|
qDebug()<<"rename="<<fileNameL << QString(LOGINFOFILE_DIR)+dts +QString("_%1.txt").arg(filenum);
|
|
file.rename(QString(LOGINFOFILE_DIR)+dts +QString("_%1.txt").arg(filenum));
|
|
}
|
|
}
|
|
|
|
void LogInfo::setScrollBar(){
|
|
QString styleSheet = "\n\
|
|
QTextEdit QScrollBar:vertical {\n\
|
|
width: 50px; /* 设置垂直滚动条的宽度 */\n\
|
|
background: rgba(0, 0, 0, 0); /* 滚动条背景透明 */\n\
|
|
margin: 20px 0 20px 0; /* 为按钮留出空间 */\n\
|
|
}\n\
|
|
QTextEdit QScrollBar::handle:vertical {\n\
|
|
background: rgb(125, 170, 177); /* 滑块颜色 */\n\
|
|
border-radius: 5px; /* 滑块圆角 */\n\
|
|
min-height: 40px; /* 滑块最小高度 */\n\
|
|
}\n\
|
|
QTextEdit QScrollBar::add-line:vertical {\n\
|
|
height: 40px; /* 设置向下按钮的高度 */\n\
|
|
background: rgb(255, 170, 127); /* 按钮颜色 */\n\
|
|
subcontrol-position: bottom;\n\
|
|
subcontrol-origin: margin;\n\
|
|
}\n\
|
|
QTextEdit QScrollBar::sub-line:vertical {\n\
|
|
height: 40px; /* 设置向上按钮的高度 */\n\
|
|
background: rgb(255, 170, 127); /* 按钮颜色 */\n\
|
|
subcontrol-position: top;\n\
|
|
subcontrol-origin: margin;\n\
|
|
}";
|
|
ui->textEditRunStatus->setStyleSheet(styleSheet);
|
|
ui->textEditRunStatus_2->setStyleSheet(styleSheet);
|
|
}
|
|
|
|
void LogInfo::updateSysStatusToUI(const AlarmStatus& alarmStatus){
|
|
if(!ui->systemStatusTab->isVisible())
|
|
return;
|
|
QPixmap lights[3] = {QPixmap(":/image/ALARMGreen.PNG"), QPixmap(":/image/ALARMRed.PNG"), QPixmap(":/image/ALARMYellow.PNG")};
|
|
|
|
ui->labelStatusInkSwint->setPixmap(lights[alarmStatus.inkSwint]);
|
|
ui->labelStatusInkLeak->setPixmap(lights[alarmStatus.inkLeak]);
|
|
ui->labelStatusInkWaterLevel->setPixmap(lights[alarmStatus.inkWaterLevel]);
|
|
ui->labelStatusSolvLevelWarn->setPixmap(lights[alarmStatus.solveLevelWarn]);
|
|
ui->labelStatusRecycleWarn->setPixmap(lights[alarmStatus.recycleWarn]);
|
|
ui->labelStatusViscosityWarn->setPixmap(lights[alarmStatus.viscosityWarn]);
|
|
ui->labelStatusChargefault->setPixmap(lights[alarmStatus.chargeFault]);
|
|
ui->labelStatusHighVoltageFault->setPixmap(lights[alarmStatus.highVoltageFault]);
|
|
|
|
ui->labPress->setText(alarmStatus.pressValue);
|
|
ui->labViso->setText(alarmStatus.visoValue);
|
|
ui->labPosition->setText(alarmStatus.gearPumpRunSpeed);
|
|
ui->labOscVol->setText(alarmStatus.highVol);
|
|
ui->label_size->setText(alarmStatus.dataSize);
|
|
|
|
}
|
|
|
|
void LogInfo::bindSysPara(SysPara *sysPara)
|
|
{
|
|
this->sysPara = sysPara;
|
|
}
|
|
|
|
void LogInfo::checkState()
|
|
{
|
|
ui->tabWidget->setCurrentIndex(3);
|
|
}
|
|
|
|
void LogInfo::applyStyleSheet()
|
|
{
|
|
QString styleSheet = R"(
|
|
QTabWidget::pane {
|
|
border: 1px solid #dddddd;
|
|
background-color: #ffffff;
|
|
}
|
|
|
|
QTabWidget::tab-bar {
|
|
top: -3px;
|
|
left: 10px;
|
|
}
|
|
|
|
QTabBar::tab {
|
|
min-width: 90px;
|
|
min-height: 45px;
|
|
padding: 4px 10px;
|
|
margin-right: 4px;
|
|
border: 1px solid #dddddd;
|
|
border-bottom: none;
|
|
border-top-left-radius: 4px;
|
|
border-top-right-radius: 4px;
|
|
background-color: #5396C1;
|
|
color: #ffffff;
|
|
}
|
|
|
|
QTabBar::tab:selected {
|
|
background-color: #6bb1e0;
|
|
color: #ffffff;
|
|
box-shadow: 0 -3px 8px rgba(44, 125, 232, 0.25);
|
|
}
|
|
|
|
QWidget#buttonWidget {
|
|
background-color: #95989D;
|
|
}
|
|
|
|
QPushButton#closeBtn1,QPushButton#closeBtn2,QPushButton#closeBtn3,QPushButton#closeBtn4 {
|
|
background-color: #E6F7FF;
|
|
border: 1px solid #87CEEB;
|
|
border-radius: 4px;
|
|
font-size: 24px;
|
|
color: #228B22;
|
|
}
|
|
|
|
QPushButton#closeBtn1:hover,QPushButton#closeBtn2:hover,QPushButton#closeBtn3:hover, QPushButton#closeBtn4:hover{
|
|
background-color: #D1E9FF;
|
|
}
|
|
|
|
QPushButton#closeBtn1:pressed,QPushButton#closeBtn2:pressed,QPushButton#closeBtn3:pressed, QPushButton#closeBtn4:pressed{
|
|
background-color: #BAE7FF;
|
|
}
|
|
|
|
QCheckBox {
|
|
font-size: 18px;
|
|
color: #000000;
|
|
font-weight:500;
|
|
}
|
|
|
|
QCheckBox::indicator {
|
|
width: 18px;
|
|
height: 18px;
|
|
border: 1px solid #96A0A9;
|
|
border-radius: 10px;
|
|
background-color: #ffffff;
|
|
}
|
|
|
|
QCheckBox::indicator:checked {
|
|
background-color: #95B2D4;
|
|
border-color: #95B2D4;
|
|
image: url(:/Demo/image/select.png);
|
|
}
|
|
|
|
QLabel {
|
|
font-size: 15px;
|
|
}
|
|
|
|
QPushButton {
|
|
background-color: #5396C1;
|
|
color: #ffffff;
|
|
border: 1px solid #000000;
|
|
border-radius: 3px;
|
|
font-size: 18px;
|
|
font-weight:500;
|
|
}
|
|
|
|
QPushButton:hover {
|
|
background-color: #5396C1;
|
|
}
|
|
|
|
QPushButton:disabled {
|
|
background-color: #7C828E;
|
|
color: #606060;
|
|
border-color: #808080;
|
|
}
|
|
|
|
QWidget#fileTab, QWidget#extraTab, QWidget#settingsTab, QWidget#serviceTab {
|
|
background-color: #E3E7EC;
|
|
}
|
|
)";
|
|
|
|
this->setStyleSheet(styleSheet);
|
|
}
|
|
|
|
void LogInfo::on_btn_clean_clicked()
|
|
{
|
|
if (ctrl_loginfo) ctrl_loginfo->emitSigClean();
|
|
}
|
|
|
|
void LogInfo::slt_cleanOver(bool flag)
|
|
{
|
|
if (flag) {
|
|
lockUI();
|
|
} else {
|
|
unlockUI();
|
|
}
|
|
}
|
|
|
|
void LogInfo::checkReclaimStatus()
|
|
{
|
|
if(!sysPara)
|
|
return;
|
|
|
|
static bool CleanUPEn=1,preCleanUP=0;
|
|
if(!sysPara->para.isCheckMagnet)
|
|
{
|
|
CleanUPEn = (sysPara->status.currReclaimTankPos<70) && (sysPara->status.statWarn & WARN_STATUS_HDINT);
|
|
}
|
|
else
|
|
{
|
|
CleanUPEn = (sysPara->status.currReclaimTankPos<70) ;
|
|
}
|
|
if(CleanUPEn != preCleanUP){
|
|
ui->btn_clean->setEnabled(CleanUPEn);
|
|
}
|
|
preCleanUP=CleanUPEn;
|
|
}
|
|
|
|
void LogInfo::lockUI()
|
|
{
|
|
ui->closeBtn4->setEnabled(false);
|
|
ui->gl_state->setEnabled(false);
|
|
ui->gridLayout_7->setEnabled(false);
|
|
ui->tabWidget->setTabEnabled(0,false);
|
|
ui->tabWidget->setTabEnabled(1,false);
|
|
ui->tabWidget->setTabEnabled(2,false);
|
|
ui->lb_clean->setText(tr("清洗中,界面锁死"));
|
|
}
|
|
|
|
void LogInfo::unlockUI()
|
|
{
|
|
ui->closeBtn4->setEnabled(true);
|
|
ui->gl_state->setEnabled(true);
|
|
ui->gridLayout_7->setEnabled(true);
|
|
ui->tabWidget->setTabEnabled(0,true);
|
|
ui->tabWidget->setTabEnabled(1,true);
|
|
ui->tabWidget->setTabEnabled(2,true);
|
|
ui->lb_clean->setText(tr(""));
|
|
}
|
|
|
|
void LogInfo::showEvent(QShowEvent *event)
|
|
{
|
|
// 先执行父类事件
|
|
QWidget::showEvent(event);
|
|
// 更新UI和状态
|
|
}
|