Skip to content

Commit 2807d42

Browse files
committed
feat: add Q_PROPERTY bindings, Secure Boot detection, and refresh() to NvidiaDetector
- Add Q_PROPERTY for gpuFound, gpuName, driverVersion, driverLoaded, nouveauActive, secureBootEnabled with infoChanged signal - Add Q_INVOKABLE refresh() for QML to re-scan GPU info - Add detectSecureBoot() using mokutil --sb-state - Initialize GpuInfo struct members with defaults
1 parent 12042bb commit 2807d42

2 files changed

Lines changed: 60 additions & 6 deletions

File tree

src/backend/nvidia/detector.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ NvidiaDetector::GpuInfo NvidiaDetector::detect() const
1818
info.driverVersion = detectDriverVersion();
1919
info.driverLoaded = isModuleLoaded(QStringLiteral("nvidia"));
2020
info.nouveauActive = isModuleLoaded(QStringLiteral("nouveau"));
21+
info.secureBootEnabled = detectSecureBoot();
2122

2223
return info;
2324
}
@@ -118,3 +119,29 @@ bool NvidiaDetector::isModuleLoaded(const QString &moduleName) const
118119

119120
return false;
120121
}
122+
123+
bool NvidiaDetector::detectSecureBoot() const
124+
{
125+
// mokutil --sb-state: Secure Boot durumunu raporlar
126+
// "SecureBoot enabled" veya "SecureBoot disabled" döner
127+
CommandRunner runner;
128+
const auto result = runner.run(
129+
QStringLiteral("mokutil"),
130+
{ QStringLiteral("--sb-state") }
131+
);
132+
133+
if (result.success() || result.exitCode == 1) {
134+
// mokutil çıktısı "enabled" içeriyorsa Secure Boot açık
135+
return result.stdout.contains(QStringLiteral("enabled"),
136+
Qt::CaseInsensitive);
137+
}
138+
139+
// mokutil yoksa durum bilinmez — kullanıcıyı uyarmayız
140+
return false;
141+
}
142+
143+
void NvidiaDetector::refresh()
144+
{
145+
m_info = detect();
146+
emit infoChanged();
147+
}

src/backend/nvidia/detector.h

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,37 @@ class NvidiaDetector : public QObject
99
{
1010
Q_OBJECT
1111

12+
Q_PROPERTY(bool gpuFound READ gpuFound NOTIFY infoChanged)
13+
Q_PROPERTY(QString gpuName READ gpuName NOTIFY infoChanged)
14+
Q_PROPERTY(QString driverVersion READ driverVersion NOTIFY infoChanged)
15+
Q_PROPERTY(bool driverLoaded READ driverLoaded NOTIFY infoChanged)
16+
Q_PROPERTY(bool nouveauActive READ nouveauActive NOTIFY infoChanged)
17+
Q_PROPERTY(bool secureBootEnabled READ secureBootEnabled NOTIFY infoChanged)
18+
1219
public:
1320
struct GpuInfo {
14-
bool found; // NVIDIA GPU var mı?
15-
QString name; // GPU adı (ör: "NVIDIA GeForce RTX 3060")
16-
QString driverVersion; // Kurulu sürücü versiyonu (ör: "535.154.05")
17-
QString vbiosVersion; // VBIOS versiyonu
18-
bool driverLoaded; // nvidia.ko kernel modülü yüklü mü?
19-
bool nouveauActive; // Nouveau (açık kaynak) sürücü aktif mi?
21+
bool found = false; // NVIDIA GPU var mı?
22+
QString name; // GPU adı (ör: "NVIDIA GeForce RTX 3060")
23+
QString driverVersion; // Kurulu sürücü versiyonu (ör: "535.154.05")
24+
QString vbiosVersion; // VBIOS versiyonu
25+
bool driverLoaded = false; // nvidia.ko kernel modülü yüklü mü?
26+
bool nouveauActive = false; // Nouveau (açık kaynak) sürücü aktif mi?
27+
bool secureBootEnabled = false; // UEFI Secure Boot açık mı?
2028
};
2129

2230
explicit NvidiaDetector(QObject *parent = nullptr);
2331

32+
// QML property getters
33+
bool gpuFound() const { return m_info.found; }
34+
QString gpuName() const { return m_info.name; }
35+
QString driverVersion() const { return m_info.driverVersion; }
36+
bool driverLoaded() const { return m_info.driverLoaded; }
37+
bool nouveauActive() const { return m_info.nouveauActive; }
38+
bool secureBootEnabled() const { return m_info.secureBootEnabled; }
39+
40+
// GPU bilgisini yeniden tara — QML'den çağrılabilir
41+
Q_INVOKABLE void refresh();
42+
2443
// Tüm GPU bilgisini toplar ve döner
2544
GpuInfo detect() const;
2645

@@ -29,6 +48,9 @@ class NvidiaDetector : public QObject
2948
bool isDriverInstalled() const;
3049
QString installedDriverVersion() const;
3150

51+
signals:
52+
void infoChanged();
53+
3254
private:
3355
// lspci çıktısından GPU adını çıkar
3456
QString detectGpuName() const;
@@ -38,5 +60,10 @@ class NvidiaDetector : public QObject
3860

3961
// /proc/modules'dan modül durumunu kontrol et
4062
bool isModuleLoaded(const QString &moduleName) const;
63+
64+
// mokutil ile Secure Boot durumunu kontrol et
65+
bool detectSecureBoot() const;
66+
67+
GpuInfo m_info;
4168
};
4269

0 commit comments

Comments
 (0)