From 903cdd8cc1a6363d5d6c0a112ef42b9772e2314e Mon Sep 17 00:00:00 2001 From: DuanRay Date: Sun, 8 Oct 2023 16:29:00 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BF=AE=E5=A4=8D=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 0002-adj-xsession-error-log-path.patch | 286 +++++++++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 0002-adj-xsession-error-log-path.patch diff --git a/0002-adj-xsession-error-log-path.patch b/0002-adj-xsession-error-log-path.patch new file mode 100644 index 0000000..03be3f8 --- /dev/null +++ b/0002-adj-xsession-error-log-path.patch @@ -0,0 +1,286 @@ +diff --git a/nfs-logtools-1.0.0/getcontent.cpp b/nfs-logtools-1.0.0/getcontent.cpp +index cf6b877..0e70044 100644 +--- a/nfs-logtools-1.0.0/getcontent.cpp ++++ b/nfs-logtools-1.0.0/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/nfs-logtools-1.0.0/getcontent.h b/nfs-logtools-1.0.0/getcontent.h +index fa521ef..cd00586 100644 +--- a/nfs-logtools-1.0.0/getcontent.h ++++ b/nfs-logtools-1.0.0/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/nfs-logtools-1.0.0/logtools.cpp b/nfs-logtools-1.0.0/logtools.cpp +index 8407394..6d7d36f 100644 +--- a/nfs-logtools-1.0.0/logtools.cpp ++++ b/nfs-logtools-1.0.0/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/nfs-logtools-1.0.0/logtools.h b/nfs-logtools-1.0.0/logtools.h +index 71f0b5d..f6cc3a3 100644 +--- a/nfs-logtools-1.0.0/logtools.h ++++ b/nfs-logtools-1.0.0/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