diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ace8d68..17ddd01 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -286,7 +286,7 @@ void MainWindow::updateUI() } void MainWindow::selfTestHandler(const QString &mode, const QString &name, const QString &minutes) { - QString output = initiateSelfTest(mode, name); + QString output = Utils.initiateSelfTest(mode, name); if (output.isEmpty()) { QMessageBox::critical(this, tr("KDiskInfo Error"), tr("KDiskInfo needs root access in order to request a self-test!")); } else { @@ -324,7 +324,7 @@ void MainWindow::selfTestHandler(const QString &mode, const QString &name, const msgBox.exec(); if (msgBox.clickedButton() == abortButton) { - cancelSelfTest(name); + Utils.cancelSelfTest(name); } } else if (exitStatus == 0) { QString infoMessage = tr("A self-test has been requested successfully"); @@ -786,7 +786,7 @@ void MainWindow::addNvmeLogTable(const QVector>& nvmeLogOrde QString key = pair.first; QString name = key.replace("_", " "); - name = toTitleCase(name); + name = Utils.toTitleCase(name); int rawInt = pair.second; QString raw = QString::number(rawInt); @@ -963,29 +963,6 @@ void MainWindow::addSmartAttributesTable(const QJsonArray &attributes) tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); } -QString MainWindow::toTitleCase(const QString& sentence) { - QString result; - bool capitalizeNext = true; - - for (const QChar& c : sentence) { - if (c.isLetter()) { - if (capitalizeNext) { - result += c.toUpper(); - capitalizeNext = false; - } else { - result += c.toLower(); - } - } else { - result += c; - if (c == ' ') { - capitalizeNext = true; - } - } - } - - return result; -} - void MainWindow::on_actionQuit_triggered() { qApp->quit(); @@ -1020,13 +997,11 @@ void MainWindow::on_actionSave_JSON_triggered() } } - void MainWindow::on_actionGitHub_triggered() { QDesktopServices::openUrl(QUrl("https://github.com/edisionnano/KDiskInfo")); } - void MainWindow::on_actionRescan_Refresh_triggered() { QPair values = Utils.scanDevices(initializing); @@ -1038,7 +1013,6 @@ void MainWindow::on_actionRescan_Refresh_triggered() } } - void MainWindow::on_actionAbout_triggered() { QString message = tr("An ATA and NVMe S.M.A.R.T. data viewer for Linux") + "\n"; @@ -1058,7 +1032,6 @@ void MainWindow::on_actionIgnore_C4_Reallocation_Event_Count_toggled(bool enable } } - void MainWindow::on_actionHEX_toggled(bool enabled) { settings.setValue("HEX", ui->actionHEX->isChecked()); @@ -1085,39 +1058,12 @@ void MainWindow::on_actionCyclic_Navigation_toggled(bool cyclicNavigation) updateNavigationButtons(currentIndex); } -QString MainWindow::initiateSelfTest(const QString &testType, const QString &deviceNode) +void MainWindow::on_actionUse_GB_instead_of_TB_toggled(bool gigabytes) { - QProcess process; - QString command = Utils.getSmartctlPath(initializing); - QStringList arguments; - arguments << command << "--json=o" << "-t" << testType << deviceNode; - - process.start("pkexec", arguments); - process.waitForFinished(-1); - - if (process.isOpen()) { - return process.readAllStandardOutput(); - } else { - return QString(); - } -} - -void MainWindow::cancelSelfTest(const QString &deviceNode) -{ - QProcess process; - QString command = Utils.getSmartctlPath(initializing); - QStringList arguments; - arguments << command << "-X" << deviceNode; - - process.start("pkexec", arguments); - process.waitForFinished(-1); - - if (process.exitCode() == 127) { - QMessageBox::critical(this, tr("KDiskInfo Error"), tr("KDiskInfo needs root access in order to abort a self-test!")); - } else if (process.exitCode() == QProcess::NormalExit) { - QMessageBox::information(this, tr("Test Requested"), tr("The self-test has been aborted")); - } else { - QMessageBox::critical(this, tr("KDiskInfo Error"), tr("Error: Something went wrong")); + settings.setValue("UseGB", ui->actionUse_GB_instead_of_TB->isChecked()); + if (!initializing) { + Utils.clearButtonGroup(buttonGroup, horizontalLayout, buttonStretch, menuDisk); + updateUI(); } } @@ -1129,12 +1075,3 @@ void MainWindow::mousePressEvent(QMouseEvent *event) onPrevButtonClicked(); } } - -void MainWindow::on_actionUse_GB_instead_of_TB_toggled(bool gigabytes) -{ - settings.setValue("UseGB", ui->actionUse_GB_instead_of_TB->isChecked()); - if (!initializing) { - Utils.clearButtonGroup(buttonGroup, horizontalLayout, buttonStretch, menuDisk); - updateUI(); - } -} diff --git a/src/mainwindow.h b/src/mainwindow.h index e1389b6..1ed78c7 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -99,10 +99,6 @@ private: void populateWindow(const QJsonObject &tempObj, const QString &health, const QVector>& nvmeLogOrdered = QVector>()); void addNvmeLogTable(const QVector>& nvmeLogOrdered); void addSmartAttributesTable(const QJsonArray &attributes); - QString getSmartctlOutput(const QStringList &arguments, bool root); - QString toTitleCase(const QString& sentence); - QString initiateSelfTest(const QString &testType, const QString &deviceNode); - void cancelSelfTest(const QString &deviceNode); void mousePressEvent(QMouseEvent*); }; #endif diff --git a/src/utils.cpp b/src/utils.cpp index e5a79a3..d416847 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -108,3 +108,62 @@ QPair utils::scanDevices(bool initializing) return QPair(QStringList(), QJsonArray()); } } + +QString utils::initiateSelfTest(const QString &testType, const QString &deviceNode) +{ + QProcess process; + QString command = getSmartctlPath(false); + QStringList arguments; + arguments << command << "--json=o" << "-t" << testType << deviceNode; + + process.start("pkexec", arguments); + process.waitForFinished(-1); + + if (process.isOpen()) { + return process.readAllStandardOutput(); + } else { + return QString(); + } +} + +void utils::cancelSelfTest(const QString &deviceNode) +{ + QProcess process; + QString command = getSmartctlPath(false); + QStringList arguments; + arguments << command << "-X" << deviceNode; + + process.start("pkexec", arguments); + process.waitForFinished(-1); + + if (process.exitCode() == 127) { + QMessageBox::critical(nullptr, QObject::tr("KDiskInfo Error"), QObject::tr("KDiskInfo needs root access in order to abort a self-test!")); + } else if (process.exitCode() == QProcess::NormalExit) { + QMessageBox::information(nullptr, QObject::tr("Test Requested"), QObject::tr("The self-test has been aborted")); + } else { + QMessageBox::critical(nullptr, QObject::tr("KDiskInfo Error"), QObject::tr("Error: Something went wrong")); + } +} + +QString utils::toTitleCase(const QString& sentence) { + QString result; + bool capitalizeNext = true; + + for (const QChar& c : sentence) { + if (c.isLetter()) { + if (capitalizeNext) { + result += c.toUpper(); + capitalizeNext = false; + } else { + result += c.toLower(); + } + } else { + result += c; + if (c == ' ') { + capitalizeNext = true; + } + } + } + + return result; +} diff --git a/src/utils.h b/src/utils.h index ad25b3c..e56dc68 100644 --- a/src/utils.h +++ b/src/utils.h @@ -32,6 +32,9 @@ public: QString getSmartctlPath(bool initializing); QString getSmartctlOutput(const QStringList &arguments, bool root, bool initializing); QPair scanDevices(bool initializing); + QString initiateSelfTest(const QString &testType, const QString &deviceNode); + void cancelSelfTest(const QString &deviceNode); + QString toTitleCase(const QString& sentence); }; #endif // UTILS_H diff --git a/translations/kdiskinfo_el_GR.qm b/translations/kdiskinfo_el_GR.qm index b0b2133..9b05c91 100644 Binary files a/translations/kdiskinfo_el_GR.qm and b/translations/kdiskinfo_el_GR.qm differ diff --git a/translations/kdiskinfo_el_GR.ts b/translations/kdiskinfo_el_GR.ts index cb23e20..369c0d7 100644 --- a/translations/kdiskinfo_el_GR.ts +++ b/translations/kdiskinfo_el_GR.ts @@ -14,258 +14,247 @@ - + <html><head/><body><p align="center">Health Status</p></body></html> <html><head/><body><p align="center">Κατάστ. Υγειας</p></body></html> - + <html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:700; color:#000000;">Good</span></p><p align="center"><span style=" font-size:12pt; font-weight:700; color:#000000;">100 %</span></p></body></html> - + <html><head/><body><p align="center">Temperature</p></body></html> <html><head/><body><p align="center">Θερμοκρασία</p></body></html> - + <html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:700; color:#000000;">23° C</span></p></body></html> - + Firmware Έκδοση Λογισμικού - + Serial Number Σειριακός Αριθμός - + Protocol Πρωτόκολλο - + Device Node Διαδρομή - - + + Type Τύπος - + Total Host Reads Συνολικές Αναγνώσεις - + Total Host Writes Συνολικές Εγγραφές - + Rotation Rate Ρυθμός Περιστροφής - + Power On Count Μετρητής Λειτουργίας - - + + Power On Hours Ώρες Λειτουργίας - + File &Αρχείο - + Settings &Ρυθμίσεις - + &Quit Έ&ξοδος - + &Refresh Devices &Ανανέωση Συσκευών - + &Convert Raw values to HEX &Μετατροπή των τιμών σε δεκαεξαδικές - + Self Test Αυτοδιάγνωση - + Cyclic &Navigation &Κυκλική Πλοήγηση - + Use &GB instead of TB Χρήση &GB αντί για TB - + &Help &Βοήθεια - + De&vice &Συσκευή - - + + Disk &Δίσκος - + &Save JSON Αποθήκευση &JSON - + &GitHub - + &About &Σχετικά - + &Ignore C4 (Reallocated Event Count) &Αγνόησε το C4 (Reallocated Event Count) - + &Use Fahrenheit Χρήση &Fahrenheit - - + + Good Καλή - - + + Caution Προσοχή - - + + Bad Κακή - + Unknown Άγνωστη - - + + Attribute Name Ιδιότητα - - + + Raw Values Τιμή - + Current Τρέχουσα - + Worst Χειρότερη - + Threshold Όριο - - - - - - + + KDiskInfo Error Σφάλμα KDiskInfo - - smartctl was not found, please install it! - Το smartctl δε βρέθηκε, παρακαλείσθε να το εγκαταστήσετε! - - - + KDiskInfo needs root access in order to request a self-test! Το KDiskInfo χρειάζεται δικαιώματα υπερχρήστη για να εκτελέσει την αυτοδιάγνωση! - + Test Already Running Μία αυτοδιάγνωση είναι ήδη σε εκτέλεση - + A self-test has been requested successfully Η αυτοδιάγνωση ξεκίνησε επιτυχώς - - + Test Requested Η αυτοδιάγνωση ξεκίνησε - - + Error: Something went wrong Σφάλμα: Κάτι πήγε στραβά - + Status Κατάσταση - + Self Test Log &Καταγραφολόγιο Αυτοδιάγνωσης @@ -275,172 +264,198 @@ &Εκκίνηση Αυτοδιάγνωσης - + A self-test is already being performed Μία αυτοδιάγνωση εκτελείτε αυτή τη στιγμή - + You can press the Ok button in order to abort the test that is currently running Μπορείτε να πατήσετε το κουμπί Εντάξει για να ακυρώσετε την τρέχουσα αυτοδιάγνωση - + minutes λεπτά - + Min.) Λεπ.) - - + + Short Σύντομο - + remaining απομένει - + completed ολοκληρώθηκε - + It will be completed after Θα τελειώσει μετά από - + count μονάδες - + hours ώρες - + Conveyance Μεταφορά - - + + Extended Εμπεριστατωμένο - - + + ID - + Available spare capacity has fallen below the threshold Η υγεία του δίσκου έχει πέσει κάτω από το όριο - + Temperature error (Overheat or Overcool) Σφάλμα θερμοκρασίας (Υπερθέρμανση ή Υπερψύξη) - + NVM subsystem reliability has been degraded Η αξιοπιστία του NVMe έχει μειωθεί - + Media has been placed in Read Only Mode Το μέσο έχει τεθεί αποκλειστικά σε λειτουργία ανάγνωσης - + Volatile memory backup device has Failed Η δημιουργία αρχείου επαναφοράς της μη διατηρήσιμης μνήμης απέτυχε - + Persistent memory region has become Read-Only Η διατηρήσιμη μνήμη έχει μεταβεί αποκλειστικά σε λειτουργία ανάγνωσης - + Critical Warning Σημαντική Προειδοποίηση - - KDiskInfo needs root access in order to read S.M.A.R.T. data! - Το KDiskInfo χρειάζεται δικαιώματα υπερχρήστη για να προσπελάσει τα δεδομένα S.M.A.R.T.! - - - + Empty JSON Κενό JSON - + The JSON is empty Αυτό το JSON είναι κενό - + Save JSON Αποθήκευση JSON - + JSON (*.json);;All Files (*) JSON (*.json);;;Όλα τα αρχεία (*) - + Unable to open file for writing Δεν είναι δυνατό το άνοιγμα αυτού του αρχείου για εγγραφή - + An ATA and NVMe S.M.A.R.T. data viewer for Linux Ένας αναγνώστης S.M.A.R.T. για τα Linux - + Licensed under the GNU G.P.L. Version 3 Διατίθεται υπό την άδεια GNU G.P.L. Έκδοση 3 - + Version Έκδοση - - KDiskInfo needs root access in order to abort a self-test! - Το KDiskInfo χρειάζεται δικαιώματα υπερχρήστη για να ακυρώσει μία αυτοδιάγνωση! - - - - The self-test has been aborted - Η τρέχουσα αυτοδιάγνωση ακυρώθηκε - - - + Made by Samantas5855 Δημιουργήθηκε από τον Samantas5855 - + About KDiskInfo Σχετικά με το KDiskInfo + + QObject + + + + + + KDiskInfo Error + Σφάλμα KDiskInfo + + + + KDiskInfo needs root access in order to read S.M.A.R.T. data! + Το KDiskInfo χρειάζεται δικαιώματα υπερχρήστη για να προσπελάσει τα δεδομένα S.M.A.R.T.! + + + + smartctl was not found, please install it! + Το smartctl δε βρέθηκε, παρακαλείσθε να το εγκαταστήσετε! + + + + KDiskInfo needs root access in order to abort a self-test! + Το KDiskInfo χρειάζεται δικαιώματα υπερχρήστη για να ακυρώσει μία αυτοδιάγνωση! + + + + Test Requested + Η αυτοδιάγνωση ξεκίνησε + + + + The self-test has been aborted + Η τρέχουσα αυτοδιάγνωση ακυρώθηκε + + + + Error: Something went wrong + Σφάλμα: Κάτι πήγε στραβά + +