Skip to content

Commit 5f68760

Browse files
committed
feat: frontend gelistirmeleri yapıldı. Arayuz yenilendi.
1 parent 86132e3 commit 5f68760

9 files changed

Lines changed: 2006 additions & 910 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ set(BACKEND_SOURCES
7575
src/backend/system/capabilityprobe.cpp
7676
src/backend/system/languagemanager.cpp
7777
src/backend/system/uipreferencesmanager.cpp
78+
src/backend/system/systeminfoprovider.cpp
7879
)
7980

8081
set(APP_SOURCES
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#include "systeminfoprovider.h"
2+
3+
#include "commandrunner.h"
4+
5+
#include <QFile>
6+
#include <QRegularExpression>
7+
#include <QSysInfo>
8+
#include <QTextStream>
9+
10+
#if defined(Q_OS_UNIX)
11+
#include <sys/utsname.h>
12+
#endif
13+
14+
namespace {
15+
16+
QString valueFromOsRelease(const QString &key) {
17+
QFile file(QStringLiteral("/etc/os-release"));
18+
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
19+
return {};
20+
}
21+
22+
QTextStream stream(&file);
23+
while (!stream.atEnd()) {
24+
const QString line = stream.readLine().trimmed();
25+
if (!line.startsWith(key + QLatin1Char('='))) {
26+
continue;
27+
}
28+
29+
QString value = line.mid(key.size() + 1).trimmed();
30+
if (value.startsWith(QLatin1Char('"')) && value.endsWith(QLatin1Char('"')) &&
31+
value.size() >= 2) {
32+
value = value.mid(1, value.size() - 2);
33+
}
34+
return value;
35+
}
36+
37+
return {};
38+
}
39+
40+
} // namespace
41+
42+
SystemInfoProvider::SystemInfoProvider(QObject *parent) : QObject(parent) {
43+
refresh();
44+
}
45+
46+
void SystemInfoProvider::refresh() {
47+
const QString nextOsName = detectOsName();
48+
const QString nextDesktopEnvironment = detectDesktopEnvironment();
49+
const QString nextKernelVersion = detectKernelVersion();
50+
const QString nextCpuModel = detectCpuModel();
51+
52+
if (m_osName == nextOsName &&
53+
m_desktopEnvironment == nextDesktopEnvironment &&
54+
m_kernelVersion == nextKernelVersion && m_cpuModel == nextCpuModel) {
55+
return;
56+
}
57+
58+
m_osName = nextOsName;
59+
m_desktopEnvironment = nextDesktopEnvironment;
60+
m_kernelVersion = nextKernelVersion;
61+
m_cpuModel = nextCpuModel;
62+
emit infoChanged();
63+
}
64+
65+
QString SystemInfoProvider::detectOsName() const {
66+
const QString prettyName = valueFromOsRelease(QStringLiteral("PRETTY_NAME"));
67+
if (!prettyName.isEmpty()) {
68+
return prettyName;
69+
}
70+
71+
const QString productName = QSysInfo::prettyProductName();
72+
if (!productName.isEmpty()) {
73+
return productName;
74+
}
75+
76+
return QSysInfo::productType();
77+
}
78+
79+
QString SystemInfoProvider::detectKernelVersion() const {
80+
#if defined(Q_OS_UNIX)
81+
utsname name {};
82+
if (uname(&name) == 0) {
83+
return QString::fromLocal8Bit(name.release);
84+
}
85+
#endif
86+
return QSysInfo::kernelVersion();
87+
}
88+
89+
QString SystemInfoProvider::detectCpuModel() const {
90+
#if defined(Q_OS_LINUX)
91+
QFile cpuInfo(QStringLiteral("/proc/cpuinfo"));
92+
if (cpuInfo.open(QIODevice::ReadOnly | QIODevice::Text)) {
93+
QTextStream stream(&cpuInfo);
94+
while (!stream.atEnd()) {
95+
const QString line = stream.readLine();
96+
if (line.startsWith(QStringLiteral("model name"))) {
97+
const int separatorIndex = line.indexOf(QLatin1Char(':'));
98+
if (separatorIndex >= 0) {
99+
return line.mid(separatorIndex + 1).trimmed();
100+
}
101+
}
102+
}
103+
}
104+
#elif defined(Q_OS_MACOS)
105+
CommandRunner runner;
106+
const auto result =
107+
runner.run(QStringLiteral("sysctl"),
108+
{QStringLiteral("-n"), QStringLiteral("machdep.cpu.brand_string")});
109+
if (result.success()) {
110+
const QString value = result.stdout.trimmed();
111+
if (!value.isEmpty()) {
112+
return value;
113+
}
114+
}
115+
#endif
116+
117+
const QString architecture = QSysInfo::currentCpuArchitecture();
118+
return architecture.isEmpty() ? QStringLiteral("Unknown CPU") : architecture;
119+
}
120+
121+
QString SystemInfoProvider::detectDesktopEnvironment() const {
122+
QString desktop = qEnvironmentVariable("XDG_CURRENT_DESKTOP").trimmed();
123+
if (desktop.isEmpty()) {
124+
desktop = qEnvironmentVariable("DESKTOP_SESSION").trimmed();
125+
}
126+
127+
if (desktop.isEmpty()) {
128+
return {};
129+
}
130+
131+
desktop.replace(QLatin1Char(':'), QLatin1String(" / "));
132+
const QStringList parts = desktop.split(QLatin1Char('/'), Qt::SkipEmptyParts);
133+
QStringList normalizedParts;
134+
for (const QString &part : parts) {
135+
const QString trimmed = part.trimmed();
136+
if (trimmed.isEmpty()) {
137+
continue;
138+
}
139+
140+
if (trimmed.compare(QStringLiteral("KDE"), Qt::CaseInsensitive) == 0) {
141+
normalizedParts << QStringLiteral("KDE Plasma");
142+
} else if (trimmed.compare(QStringLiteral("GNOME"), Qt::CaseInsensitive) == 0) {
143+
normalizedParts << QStringLiteral("GNOME");
144+
} else {
145+
normalizedParts << trimmed;
146+
}
147+
}
148+
149+
return normalizedParts.join(QStringLiteral(" / "));
150+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#pragma once
2+
3+
#include <QObject>
4+
#include <QString>
5+
6+
class SystemInfoProvider : public QObject {
7+
Q_OBJECT
8+
9+
Q_PROPERTY(QString osName READ osName NOTIFY infoChanged)
10+
Q_PROPERTY(QString desktopEnvironment READ desktopEnvironment NOTIFY infoChanged)
11+
Q_PROPERTY(QString kernelVersion READ kernelVersion NOTIFY infoChanged)
12+
Q_PROPERTY(QString cpuModel READ cpuModel NOTIFY infoChanged)
13+
14+
public:
15+
explicit SystemInfoProvider(QObject *parent = nullptr);
16+
17+
QString osName() const { return m_osName; }
18+
QString desktopEnvironment() const { return m_desktopEnvironment; }
19+
QString kernelVersion() const { return m_kernelVersion; }
20+
QString cpuModel() const { return m_cpuModel; }
21+
22+
Q_INVOKABLE void refresh();
23+
24+
signals:
25+
void infoChanged();
26+
27+
private:
28+
QString detectOsName() const;
29+
QString detectKernelVersion() const;
30+
QString detectCpuModel() const;
31+
QString detectDesktopEnvironment() const;
32+
33+
QString m_osName;
34+
QString m_desktopEnvironment;
35+
QString m_kernelVersion;
36+
QString m_cpuModel;
37+
};

src/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "backend/nvidia/installer.h"
2323
#include "backend/nvidia/updater.h"
2424
#include "backend/system/languagemanager.h"
25+
#include "backend/system/systeminfoprovider.h"
2526
#include "backend/system/uipreferencesmanager.h"
2627
#include "cli/cli.h"
2728

@@ -265,6 +266,7 @@ int main(int argc, char *argv[]) {
265266
CpuMonitor cpuMonitor;
266267
GpuMonitor gpuMonitor;
267268
RamMonitor ramMonitor;
269+
SystemInfoProvider systemInfo;
268270

269271
QQmlApplicationEngine engine;
270272
LanguageManager languageManager(&app, &engine, &translator);
@@ -277,6 +279,7 @@ int main(int argc, char *argv[]) {
277279
engine.rootContext()->setContextProperty("cpuMonitor", &cpuMonitor);
278280
engine.rootContext()->setContextProperty("gpuMonitor", &gpuMonitor);
279281
engine.rootContext()->setContextProperty("ramMonitor", &ramMonitor);
282+
engine.rootContext()->setContextProperty("systemInfo", &systemInfo);
280283
engine.rootContext()->setContextProperty("languageManager", &languageManager);
281284
engine.rootContext()->setContextProperty("uiPreferences",
282285
&uiPreferencesManager);

0 commit comments

Comments
 (0)