Skip to content

Commit

Permalink
add function
Browse files Browse the repository at this point in the history
  • Loading branch information
frankwang98 committed Nov 21, 2024
1 parent d405a53 commit 8a5e463
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
Binary file modified log4qt.dll
Binary file not shown.
25 changes: 15 additions & 10 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>180</x>
<x>170</x>
<y>10</y>
<width>231</width>
<width>281</width>
<height>51</height>
</rect>
</property>
Expand Down Expand Up @@ -108,7 +108,7 @@
</rect>
</property>
<property name="currentIndex">
<number>7</number>
<number>1</number>
</property>
<widget class="QWidget" name="pageHome">
<widget class="QGroupBox" name="groupBox_4">
Expand Down Expand Up @@ -272,8 +272,8 @@
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>80</x>
<y>50</y>
<x>50</x>
<y>20</y>
<width>151</width>
<height>31</height>
</rect>
Expand All @@ -285,12 +285,17 @@
<widget class="QTextBrowser" name="tbOS">
<property name="geometry">
<rect>
<x>70</x>
<y>110</y>
<width>421</width>
<height>461</height>
<x>40</x>
<y>60</y>
<width>491</width>
<height>571</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
</widget>
</widget>
<widget class="QWidget" name="pageClock">
Expand Down Expand Up @@ -679,7 +684,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
<height>22</height>
<height>25</height>
</rect>
</property>
</widget>
Expand Down
36 changes: 33 additions & 3 deletions utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,41 @@ QString getSysInfo()
{
QString info;

// 1. 获取操作系统信息
// 获取系统信息等
info += QString("操作系统: %1\n").arg(QSysInfo::prettyProductName());
info += QString("版本: %1\n").arg(QSysInfo::productVersion());
info += QString("架构: %1\n").arg(QSysInfo::currentCpuArchitecture());

info += QString("\nCPU Information:\n");
QProcess cpuProcess;
cpuProcess.start("wmic cpu get Name");
cpuProcess.waitForFinished();
QString cpuResult = cpuProcess.readAllStandardOutput();
QString cpuName = cpuResult.split("\n").at(1).trimmed();
info += QString(" CPU Name: %1\n").arg(cpuName);

info += QString("GPU Information:\n");
QProcess gpuProcess;
gpuProcess.start("wmic path win32_VideoController get Name");
gpuProcess.waitForFinished();
QString gpuResult = gpuProcess.readAllStandardOutput();
QStringList gpuList = gpuResult.split("\n", QString::SkipEmptyParts);
for (int i = 1; i < gpuList.size(); i++) {
QString gpuName = gpuList.at(i).trimmed();
info += QString(" GPU Name: %1\n").arg(gpuName);
}

QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
for (const QNetworkInterface &networkInterface : interfaces) {
info += QString("\n网络接口: %1\n").arg(networkInterface.humanReadableName());

QList<QNetworkAddressEntry> addressEntries = networkInterface.addressEntries();
for (const QNetworkAddressEntry &entry : addressEntries) {
QHostAddress ip = entry.ip();
info += QString(" IP 地址: %1\n").arg(ip.toString());
}
}

return info;
}

Expand All @@ -32,9 +62,9 @@ QString getBmiInfo(double height, double weight)
} else if (bmi >= 18.5 && bmi <= 24.9) {
healthAdvice = "您的体重正常,继续保持健康的生活方式。";
} else if (bmi >= 25 && bmi <= 29.9) {
healthAdvice = "您的体重偏重,建议适当控制饮食并增加运动";
healthAdvice = "您偏胖-强壮doge,建议控制饮食并增加运动";
} else {
healthAdvice = "您的体重属于肥胖范围,建议制定减重计划。";
healthAdvice = "您肥胖了(强壮doge),建议制定减重计划。";
}

return QString("您的 BMI 值: %1 \n健康建议: %2")
Expand Down
2 changes: 2 additions & 0 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <QSysInfo>
#include <QProcess>
#include <QHostAddress>
#include <QNetworkInterface>
#include <QDateTime>
#include <QMessageBox>
#include <QUuid>
Expand Down

0 comments on commit 8a5e463

Please sign in to comment.