diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3e5a688..514d4e0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -67,12 +67,11 @@ MainWindow::MainWindow(QWidget *parent) badColor = QColor(Qt::red); naColor = QColor(Qt::gray); - actionCyclic_Navigation = ui->actionCyclic_Navigation; - ui->actionIgnore_C4_Reallocation_Event_Count->setChecked(settings.value("IgnoreC4", true).toBool()); ui->actionHEX->setChecked(settings.value("HEX", true).toBool()); ui->actionUse_Fahrenheit->setChecked(settings.value("Fahrenheit", false).toBool()); - actionCyclic_Navigation->setChecked(settings.value("CyclicNavigation", false).toBool()); + ui->actionCyclic_Navigation->setChecked(settings.value("CyclicNavigation", false).toBool()); + ui->actionUse_GB_instead_of_TB->setChecked(settings.value("UseGB", false).toBool()); QAction *toggleEchoModeAction = serialNumberLineEdit->addAction(QIcon::fromTheme(QStringLiteral("visibility")), QLineEdit::TrailingPosition); connect(toggleEchoModeAction, &QAction::triggered, this, [=]() { @@ -113,8 +112,8 @@ void MainWindow::onPrevButtonClicked() void MainWindow::updateNavigationButtons(int currentIndex) { - prevButton->setEnabled(currentIndex > 0||actionCyclic_Navigation->isChecked()); // We can use setVisible if we want to mimic CrystalDiskInfo - nextButton->setEnabled(currentIndex < buttonGroup->buttons().size() - 1||actionCyclic_Navigation->isChecked()); + prevButton->setEnabled(currentIndex > 0||ui->actionCyclic_Navigation->isChecked()); // We can use setVisible if we want to mimic CrystalDiskInfo + nextButton->setEnabled(currentIndex < buttonGroup->buttons().size() - 1||ui->actionCyclic_Navigation->isChecked()); } QString getSmartctlPath() { @@ -202,9 +201,17 @@ void MainWindow::updateUI() QString health; QColor healthColor; - float userCapacityGB = localObj.value("user_capacity").toObject().value("bytes").toDouble() / 1e9; - QString gbSymbol = QLocale().formattedDataSize(1 << 30, 1, QLocale::DataSizeTraditionalFormat).split(' ')[1]; - QString userCapacityString = locale.toString(userCapacityGB, 'f', 1) + " " + gbSymbol; + float diskCapacityGB = localObj.value("user_capacity").toObject().value("bytes").toDouble() / 1e9; + QString gbSymbol = locale.formattedDataSize(1 << 30, 1, QLocale::DataSizeTraditionalFormat).split(' ')[1]; + QString tbSymbol = locale.formattedDataSize(qint64(1) << 40, 1, QLocale::DataSizeTraditionalFormat).split(' ')[1]; + QString diskCapacityString; + int diskCapacityGbInt = static_cast(diskCapacityGB); + bool useGB = ui->actionUse_GB_instead_of_TB->isChecked(); + if (diskCapacityGbInt < 1000 || useGB) { + diskCapacityString = locale.toString(diskCapacityGB, 'f', 1) + " " + gbSymbol; + } else { + diskCapacityString = QString::number(diskCapacityGbInt/1000) + " " + tbSymbol; + } QString protocol = localObj["device"].toObject()["protocol"].toString(); bool isNvme = (protocol == "NVMe"); @@ -273,12 +280,12 @@ void MainWindow::updateUI() } CustomButton *button = new CustomButton(health, temperature, deviceName, healthColor, this); - button->setToolTip(tr("Disk") + " " + QString::number(i) + " : " + modelName + " : " + userCapacityString); + button->setToolTip(tr("Disk") + " " + QString::number(i) + " : " + modelName + " : " + diskCapacityString); buttonGroup->addButton(button); horizontalLayout->addWidget(button); - QAction *diskAction = new QAction("(" + QString::number(i+1) + ") " + modelName + " " + userCapacityString, this); + QAction *diskAction = new QAction("(" + QString::number(i+1) + ") " + modelName + " " + diskCapacityString, this); diskAction->setCheckable(true); menuDisk->addAction(diskAction); disksGroup->addAction(diskAction); @@ -288,7 +295,7 @@ void MainWindow::updateUI() int buttonIndex = buttonGroup->buttons().indexOf(button); - auto populateAndNavigate = [=]() { + auto updateWindow = [=]() { if (isNvme) { populateWindow(localObj, health, nvmeSmartOrdered); } else { @@ -298,12 +305,12 @@ void MainWindow::updateUI() }; connect(button, &QPushButton::clicked, this, [=]() { - populateAndNavigate(); + updateWindow(); disksGroup->actions().at(buttonIndex)->setChecked(true); }); connect(diskAction, &QAction::triggered, this, [=]() { - populateAndNavigate(); + updateWindow(); }); if (firstTime) { @@ -391,12 +398,22 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal QJsonObject nvmeLog = localObj["nvme_smart_health_information_log"].toObject(); QString modelName = localObj["model_name"].toString(); QString firmwareVersion = localObj["firmware_version"].toString(); - float userCapacityGB = localObj.value("user_capacity").toObject().value("bytes").toDouble() / 1e9; + float diskCapacityGB = localObj.value("user_capacity").toObject().value("bytes").toDouble() / 1e9; + int diskCapacityGbInt = static_cast(diskCapacityGB); int temperatureInt = localObj["temperature"].toObject()["current"].toInt(); int totalWritesInt = 0; int totalReadsInt = 0; - QString gbSymbol = QLocale().formattedDataSize(1 << 30, 1, QLocale::DataSizeTraditionalFormat).split(' ')[1]; - QString userCapacityString = locale.toString(userCapacityGB, 'f', 1) + " " + gbSymbol; + bool useGB = ui->actionUse_GB_instead_of_TB->isChecked(); + + QString gbSymbol = locale.formattedDataSize(1 << 30, 1, QLocale::DataSizeTraditionalFormat).split(' ')[1]; + QString tbSymbol = locale.formattedDataSize(qint64(1) << 40, 1, QLocale::DataSizeTraditionalFormat).split(' ')[1]; + QString diskCapacityString; + if (diskCapacityGbInt < 1000 || useGB) { + diskCapacityString = locale.toString(diskCapacityGB, 'f', 1) + " " + gbSymbol; + } else { + diskCapacityString = QString::number(diskCapacityGbInt/1000) + " " + tbSymbol; + } + QString totalReads; QString totalWrites; QString percentage = ""; @@ -457,7 +474,7 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal deviceJson = localObj; - diskName->setText("

" + modelName + " " + userCapacityString + "

"); + diskName->setText("

" + modelName + " " + diskCapacityString + "

"); firmwareLineEdit->setText(firmwareVersion); serialNumberLineEdit->setText(serialNumber); typeLineEdit->setText(type); @@ -600,13 +617,21 @@ void MainWindow::populateWindow(const QJsonObject &localObj, const QString &heal } if (totalReadsInt) { - totalReads = QString::number(static_cast(totalReadsInt)) + " " + gbSymbol; + if (totalReadsInt < 1000 || useGB) { + totalReads = QString::number(totalReadsInt) + " " + gbSymbol; + } else { + totalReads = QString::number(totalReadsInt/1000) + " " + tbSymbol; + } } else { totalReads = "----"; } if (totalWritesInt) { - totalWrites = QString::number(static_cast(totalWritesInt)) + " " + gbSymbol; + if (totalWritesInt < 1000 || useGB) { + totalWrites = QString::number(totalWritesInt) + " " + gbSymbol; + } else { + totalWrites = QString::number(totalWritesInt/1000) + " " + tbSymbol; + } } else { totalWrites = "----"; } @@ -1190,3 +1215,12 @@ 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) { + clearButtonGroup(); + updateUI(); + } +} diff --git a/src/mainwindow.h b/src/mainwindow.h index effb5de..efa67a8 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -58,6 +58,8 @@ private slots: void on_actionCyclic_Navigation_toggled(bool arg1); + void on_actionUse_GB_instead_of_TB_toggled(bool arg1); + private: Ui::MainWindow *ui; QLocale locale; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index c0f36e6..beeb97f 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -345,6 +345,7 @@ + @@ -452,7 +453,15 @@ true - Cyclic Navigation + Cyclic &Navigation + + + + + true + + + Use GB instead of TB diff --git a/translations/kdiskinfo_el_GR.qm b/translations/kdiskinfo_el_GR.qm index 5521282..a689005 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 96e72eb..91e0b9d 100644 --- a/translations/kdiskinfo_el_GR.ts +++ b/translations/kdiskinfo_el_GR.ts @@ -55,7 +55,7 @@ - + Type Τύπος @@ -81,7 +81,7 @@ - + Power On Hours Ώρες Λειτουργίας @@ -96,170 +96,176 @@ Ρυθμίσεις - + &Quit Έξοδος - + &Refresh Devices Ανανέωση Συσκευών - + &Convert Raw values to HEX Μετατροπή των τιμών σε δεκαεξαδικές - + Self Test Αυτοδιάγνωση - - Cyclic Navigation - Κυκλική Πλοήγηση + + Cyclic &Navigation + Kυκλική Πλοήγηση - + + 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 Καταγραφολόγιο Αυτοδιάγνωσης @@ -269,165 +275,165 @@ Εκκίνηση Αυτοδιάγνωσης - + 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 - + 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