From af2b0b5b9d2aab71807cd2a597c811ca114808dd Mon Sep 17 00:00:00 2001 From: ruizhe Date: Thu, 19 Oct 2023 10:24:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BC=9A=E8=AF=9D=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=97=A5=E5=BF=97=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- debian/changelog | 6 ++++++ getcontent.cpp | 27 ++++++++++++++++++++++++- getcontent.h | 2 ++ logtools.cpp | 51 +++++++++++++++++++++++++++--------------------- logtools.h | 1 + 5 files changed, 64 insertions(+), 23 deletions(-) diff --git a/debian/changelog b/debian/changelog index aca6406..65e6634 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +nfs-logtools (1.0.0-3) unstable; urgency=medium + + * fix: adjust xsession-error log path. + + -- ruizhe Thu, 19 Oct 2023 10:22:13 +0800 + nfs-logtools (1.0.0-2) unstable; urgency=medium * fix: about dialog show version error diff --git a/getcontent.cpp b/getcontent.cpp index cf6b877..0e70044 100644 --- a/getcontent.cpp +++ b/getcontent.cpp @@ -4,6 +4,31 @@ GetContent::GetContent() { } +QString GetContent::getHomePath() +{ + QProcess *execCmd = new QProcess(); + QStringList params; + QStringList getUserName; + QStringList curHome; + QString curUser = ""; + QString curUsrPawdInfo = ""; + + execCmd->start("who", params); + execCmd->waitForFinished(); + curUser = execCmd->readAllStandardOutput(); + getUserName = curUser.split(" "); + curUser = getUserName[0]; + + execCmd->start("bash", QStringList() << "-c" << "cat /etc/passwd | grep " + curUser); + execCmd->waitForFinished(); + curUsrPawdInfo = execCmd->readAllStandardOutput(); + execCmd->close(); + + curHome = curUsrPawdInfo.split(':'); + + return curHome[5]; +} + bool GetContent::checkLogPathExists(QString &logPath) { QFile file(logPath); @@ -444,7 +469,7 @@ void GetContent::getSessionContent(QStringList &logAll) QString line = ""; int limitCountItems = 10000; - logFile = QDir::homePath() + "/.xsession-errors"; + logFile = getHomePath() + "/.xsession-errors"; // qDebug() << logFile; if (!(fileExist = checkLogPathExists(logFile))) { return; diff --git a/getcontent.h b/getcontent.h index fa521ef..cd00586 100644 --- a/getcontent.h +++ b/getcontent.h @@ -9,6 +9,7 @@ #include #include #include +#include #include "parserlog.h" extern bool fileExist; @@ -18,6 +19,7 @@ class GetContent { public: GetContent(); + QString getHomePath(); bool checkLogPathExists(QString &); //判断文件存在统一判断接口 bool checkLogPathEmpty(QString &); //判断文件为空统一判断接口 bool checkDirPathExists(QString &); //判断目录存在统一判断接口 diff --git a/logtools.cpp b/logtools.cpp index 8407394..6d7d36f 100644 --- a/logtools.cpp +++ b/logtools.cpp @@ -276,7 +276,14 @@ void Logtools::logtoolsGetHomePath() curUser = getUserName[0]; this->exportPath = "/home/" + curUser + "/桌面/"; execCmd->close(); -// qDebug() << this->exportPath; + // qDebug() << this->exportPath; +} + +void Logtools::logtoolsMessagesBox() +{ + QMessageBox box(QMessageBox::Information, "提示", "该日志文件为空或不存在!"); + box.setButtonText(QMessageBox::OK, QString(" 确 定")); + box.exec(); } void Logtools::logtoolsSaveCurAlreadyTofindData(QList > &logList) @@ -1235,7 +1242,7 @@ void Logtools::logtoolsSwitchSlots() logtoolsSetFilterBarShow(); } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1259,7 +1266,7 @@ void Logtools::logtoolsSysInfoSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1278,7 +1285,7 @@ void Logtools::logtoolsSysBootSlots() this->logtoolsSetFilterBarHide(); } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1301,7 +1308,7 @@ void Logtools::logtoolsPackageSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1323,7 +1330,7 @@ void Logtools::logtoolsKernelSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1345,7 +1352,7 @@ void Logtools::logtoolsSoftwareUpdateSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1367,7 +1374,7 @@ void Logtools::logtoolsPrintSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1385,7 +1392,7 @@ void Logtools::logtoolsBurnSlots() this->logtoolsSetFilterBarHide(); } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1403,7 +1410,7 @@ void Logtools::logtoolsAuditSlots() this->logtoolsSetFilterBarHide(); } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1421,7 +1428,7 @@ void Logtools::logtoolsSessionSlots() this->logtoolsSetFilterBarHide(); } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1439,7 +1446,7 @@ void Logtools::logtoolsXorgSlots() this->logtoolsSetFilterBarHide(); } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1458,7 +1465,7 @@ void Logtools::logtoolsApplicationSlots() this->logtoolsSetComboAppShow(); } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1482,7 +1489,7 @@ void Logtools::logtoolsSwitchTimesSlots() ui->labelInfo->setText(QString("开关机次数统计:")); } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1504,7 +1511,7 @@ void Logtools::logtoolsDebugSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1526,7 +1533,7 @@ void Logtools::logtoolsInfoSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1548,7 +1555,7 @@ void Logtools::logtoolsNoticeSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1570,7 +1577,7 @@ void Logtools::logtoolsWarningSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1592,7 +1599,7 @@ void Logtools::logtoolsErrorSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1614,7 +1621,7 @@ void Logtools::logtoolsCriticalSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1636,7 +1643,7 @@ void Logtools::logtoolsAlertSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } @@ -1658,7 +1665,7 @@ void Logtools::logtoolsEmergSlots() #endif } else { - QMessageBox::critical(NULL, "提示", "文件为空,请检查"); + logtoolsMessagesBox(); } } diff --git a/logtools.h b/logtools.h index 71f0b5d..f6cc3a3 100644 --- a/logtools.h +++ b/logtools.h @@ -115,6 +115,7 @@ public: //公用函数 void logtoolsGetHomePath(); + void logtoolsMessagesBox(); void logtoolsSaveCurAlreadyTofindData(QList > &); void logtoolsSaveCurStateHandle(functionIndex, void (*funcShowTable)(QList > &, QTableView *, QStandardItemModel *));/*保存数据状态的统一入口*/ void logtoolsProcessFilterEvent(); -- Gitee