diff --git a/debian/changelog b/debian/changelog index aca640602ba22be28889cc1a3ffab3ce1e4bdf97..65e66343ea788829a1bba4ed2d89cd3c9b0eae0d 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 cf6b8773814e9f599122432179bdc28ae1126c71..0e70044a73d9cc6d00362f9ed9026f88cd356fad 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 fa521ef18e50ffa064ba84f7f2715c49fe6e63e4..cd00586042b1a67d6a069153d9142da2ed555951 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 84073943710d1e0460794991c2b9013a7689ab6b..6d7d36fa02ab50402826e1ebaafb638502ac849a 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 71f0b5d58dafea512c077ce07076ec299aeea76c..f6cc3a3c9ee85b6a3e859e3057675fbe2ab095f5 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();