11#include " updater.h"
22#include " detector.h"
33#include " system/commandrunner.h"
4+ #include " system/sessionutil.h"
45#include " versionparser.h"
56
67#include < QMetaObject>
@@ -49,37 +50,15 @@ struct UpdateStatusSnapshot {
4950 QString message;
5051};
5152
52- QString detectSessionTypeImpl () {
53- const QString envType =
54- qEnvironmentVariable (" XDG_SESSION_TYPE" ).trimmed ().toLower ();
55- if (!envType.isEmpty ()) {
56- return envType;
57- }
5853
59- CommandRunner runner;
60- const auto loginctl =
61- runner.run (QStringLiteral (" loginctl" ),
62- {QStringLiteral (" show-session" ),
63- qEnvironmentVariable (" XDG_SESSION_ID" ), QStringLiteral (" -p" ),
64- QStringLiteral (" Type" ), QStringLiteral (" --value" )});
65-
66- if (loginctl.success ()) {
67- const QString type = loginctl.stdout .trimmed ().toLower ();
68- if (!type.isEmpty ()) {
69- return type;
70- }
71- }
72-
73- return QStringLiteral (" unknown" );
74- }
7554
7655UpdateStatusSnapshot collectUpdateStatus () {
7756 UpdateStatusSnapshot snapshot;
7857 NvidiaDetector detector;
7958 snapshot.currentVersion = detector.installedDriverVersion ();
8059
8160 if (QStandardPaths::findExecutable (QStringLiteral (" dnf" )).isEmpty ()) {
82- snapshot.message = QStringLiteral (" dnf bulunamadi ." );
61+ snapshot.message = NvidiaUpdater::tr (" dnf not found ." );
8362 return snapshot;
8463 }
8564
@@ -96,7 +75,7 @@ UpdateStatusSnapshot collectUpdateStatus() {
9675 }
9776
9877 if (snapshot.currentVersion .isEmpty ()) {
99- snapshot.message = QStringLiteral ( " Kurulu NVIDIA surucusu bulunamadi ." );
78+ snapshot.message = NvidiaUpdater::tr ( " No installed NVIDIA driver found ." );
10079 return snapshot;
10180 }
10281
@@ -110,13 +89,13 @@ UpdateStatusSnapshot collectUpdateStatus() {
11089 snapshot.updateAvailable = true ;
11190 snapshot.message =
11291 snapshot.latestVersion .isEmpty ()
113- ? QStringLiteral ( " Guncelleme bulundu (surum ayrintisi alinamadi )." )
114- : QStringLiteral ( " Guncelleme bulundu : %1" )
92+ ? NvidiaUpdater::tr ( " Update found (version details unavailable )." )
93+ : NvidiaUpdater::tr ( " Update found : %1" )
11594 .arg (snapshot.latestVersion );
11695 } else if (checkResult.exitCode == 0 ) {
117- snapshot.message = QStringLiteral ( " Surucu guncel. Yeni surum bulunamadi ." );
96+ snapshot.message = NvidiaUpdater::tr ( " Driver is up to date. No new version found ." );
11897 } else {
119- snapshot.message = QStringLiteral ( " Guncelleme kontrolu basarisiz : %1" )
98+ snapshot.message = NvidiaUpdater::tr ( " Update check failed : %1" )
12099 .arg (checkResult.stderr .trimmed ().isEmpty ()
121100 ? checkResult.stdout .trimmed ()
122101 : checkResult.stderr .trimmed ());
@@ -141,7 +120,7 @@ void NvidiaUpdater::setBusy(bool busy) {
141120void NvidiaUpdater::runAsyncTask (const std::function<void ()> &task) {
142121 if (m_busy) {
143122 emit progressMessage (
144- QStringLiteral ( " Baska bir surucu islemi zaten calisiyor ." ));
123+ tr ( " Another driver operation is already running ." ));
145124 return ;
146125 }
147126
@@ -174,7 +153,7 @@ void NvidiaUpdater::setAvailableVersions(const QStringList &versions) {
174153}
175154
176155QString NvidiaUpdater::detectSessionType () const {
177- return detectSessionTypeImpl ();
156+ return SessionUtil::detectSessionType ();
178157}
179158
180159QStringList
@@ -196,23 +175,23 @@ bool NvidiaUpdater::finalizeDriverChange(CommandRunner &runner,
196175 runner.runAsRoot (QStringLiteral (" akmods" ), {QStringLiteral (" --force" )});
197176 if (!result.success ()) {
198177 if (errorMessage != nullptr ) {
199- *errorMessage = QStringLiteral (" Kernel modulu derlenemedi : " ) +
200- commandError (result, QStringLiteral ( " bilinmeyen hata " ));
178+ *errorMessage = tr (" Kernel module build failed : " ) +
179+ commandError (result, tr ( " unknown error " ));
201180 }
202181 return false ;
203182 }
204183
205184 if (sessionType == QStringLiteral (" wayland" )) {
206- emit progressMessage (QStringLiteral (
207- " Wayland tespit edildi: nvidia-drm.modeset=1 ayari guncelleniyor ..." ));
185+ emit progressMessage (
186+ tr ( " Wayland detected: applying nvidia-drm.modeset=1..." ));
208187 result = runner.runAsRoot (QStringLiteral (" grubby" ),
209188 {QStringLiteral (" --update-kernel=ALL" ),
210189 QStringLiteral (" --args=nvidia-drm.modeset=1" )});
211190 if (!result.success ()) {
212191 if (errorMessage != nullptr ) {
213192 *errorMessage =
214- QStringLiteral ( " Wayland kernel parametresi guncellenemedi : " ) +
215- commandError (result, QStringLiteral ( " bilinmeyen hata " ));
193+ tr ( " Failed to update the Wayland kernel parameter : " ) +
194+ commandError (result, tr ( " unknown error " ));
216195 }
217196 return false ;
218197 }
@@ -239,8 +218,8 @@ void NvidiaUpdater::refreshAvailableVersions() {
239218 guard->setAvailableVersions (snapshot.availableVersions );
240219 emit guard->progressMessage (
241220 snapshot.availableVersions .isEmpty ()
242- ? QStringLiteral ( " Kullanilabilir surum bulunamadi ." )
243- : QStringLiteral ( " Kullanilabilir surum sayisi : %1" )
221+ ? guard-> tr ( " No available versions found ." )
222+ : guard-> tr ( " Available versions : %1" )
244223 .arg (snapshot.availableVersions .size ()));
245224 },
246225 Qt::QueuedConnection);
@@ -250,7 +229,7 @@ void NvidiaUpdater::refreshAvailableVersions() {
250229void NvidiaUpdater::checkForUpdate () {
251230 // TR: Her kontrol denemesinde UI'ye gorunur bir baslangic mesaji gonder.
252231 // EN: Always emit a visible start message for each check request.
253- emit progressMessage (QStringLiteral ( " Guncelleme kontrolu baslatildi ..." ));
232+ emit progressMessage (tr ( " Starting update check ..." ));
254233
255234 QPointer<NvidiaUpdater> guard (this );
256235 runAsyncTask ([guard]() {
@@ -318,7 +297,7 @@ void NvidiaUpdater::applyVersion(const QString &version) {
318297 [guard]() {
319298 if (guard) {
320299 emit guard->updateFinished (false ,
321- QStringLiteral (" dnf bulunamadi ." ));
300+ guard-> tr (" dnf not found ." ));
322301 }
323302 },
324303 Qt::QueuedConnection);
@@ -327,7 +306,7 @@ void NvidiaUpdater::applyVersion(const QString &version) {
327306
328307 NvidiaDetector detector;
329308 const QString installedVersion = detector.installedDriverVersion ();
330- const QString sessionType = detectSessionTypeImpl ();
309+ const QString sessionType = SessionUtil::detectSessionType ();
331310
332311 if (!trimmedVersion.isEmpty () && !knownVersions.contains (trimmedVersion)) {
333312 QMetaObject::invokeMethod (
@@ -336,7 +315,7 @@ void NvidiaUpdater::applyVersion(const QString &version) {
336315 if (guard) {
337316 emit guard->updateFinished (
338317 false ,
339- QStringLiteral ( " Secilen surum repo listesinde bulunamadi ." ));
318+ guard-> tr ( " Selected version not found in the repository ." ));
340319 }
341320 },
342321 Qt::QueuedConnection);
@@ -352,10 +331,10 @@ void NvidiaUpdater::applyVersion(const QString &version) {
352331
353332 emit guard->progressMessage (
354333 trimmedVersion.isEmpty ()
355- ? QStringLiteral (
356- " NVIDIA surucusu en son surume guncelleniyor ..." )
357- : QStringLiteral (
358- " NVIDIA surucusu secilen surume geciriliyor : %1" )
334+ ? guard-> tr (
335+ " Updating NVIDIA driver to the latest version ..." )
336+ : guard-> tr (
337+ " Switching NVIDIA driver to selected version : %1" )
359338 .arg (trimmedVersion));
360339 },
361340 Qt::QueuedConnection);
@@ -374,8 +353,8 @@ void NvidiaUpdater::applyVersion(const QString &version) {
374353 auto result = runner.runAsRoot (QStringLiteral (" dnf" ), args);
375354 if (!result.success ()) {
376355 const QString error =
377- QStringLiteral ( " Guncelleme basarisiz : " ) +
378- commandError (result, QStringLiteral ( " bilinmeyen hata " ));
356+ guard-> tr ( " Update failed : " ) +
357+ commandError (result, guard-> tr ( " unknown error " ));
379358 QMetaObject::invokeMethod (
380359 guard,
381360 [guard, error]() {
@@ -392,7 +371,7 @@ void NvidiaUpdater::applyVersion(const QString &version) {
392371 [guard]() {
393372 if (guard) {
394373 emit guard->progressMessage (
395- QStringLiteral ( " Kernel modulu yeniden derleniyor ..." ));
374+ guard-> tr ( " Rebuilding kernel module ..." ));
396375 }
397376 },
398377 Qt::QueuedConnection);
@@ -414,13 +393,13 @@ void NvidiaUpdater::applyVersion(const QString &version) {
414393 const QString successMessage =
415394 trimmedVersion.isEmpty ()
416395 ? (installedVersion.isEmpty ()
417- ? QStringLiteral ( " En son surum basariyla kuruldu. Lutfen "
418- " sistemi yeniden baslatin ." )
419- : QStringLiteral ( " Surucu basariyla guncellendi. Lutfen "
420- " sistemi yeniden baslatin ." ))
421- : QStringLiteral (
422- " Secilen surum basariyla uygulandi. Lutfen sistemi "
423- " yeniden baslatin ." );
396+ ? guard-> tr ( " Latest version installed successfully. "
397+ " Please restart the system ." )
398+ : guard-> tr ( " Driver updated successfully. "
399+ " Please restart the system ." ))
400+ : guard-> tr (
401+ " Selected version applied successfully. "
402+ " Please restart the system ." );
424403
425404 QMetaObject::invokeMethod (
426405 guard,
0 commit comments