mirror of
https://github.com/edisionnano/QDiskInfo.git
synced 2026-04-18 14:41:29 +03:00
Capitalize first letter
This commit is contained in:
@@ -302,10 +302,14 @@ void MainWindow::addNvmeLogTable(const QJsonObject &nvmeLog)
|
|||||||
int row = 0;
|
int row = 0;
|
||||||
for (auto smartItem = nvmeLog.constBegin(); smartItem != nvmeLog.constEnd(); ++smartItem) {
|
for (auto smartItem = nvmeLog.constBegin(); smartItem != nvmeLog.constEnd(); ++smartItem) {
|
||||||
QString id = QString("%1").arg(row, 2, 16, QChar('0')).toUpper();
|
QString id = QString("%1").arg(row, 2, 16, QChar('0')).toUpper();
|
||||||
|
|
||||||
QString name = smartItem.key().replace("_", " ");
|
QString name = smartItem.key().replace("_", " ");
|
||||||
|
name = toTitleCase(name);
|
||||||
|
|
||||||
QString raw = QString::number(smartItem.value().toInt());
|
QString raw = QString::number(smartItem.value().toInt());
|
||||||
raw = QString("%1").arg(raw.toUInt(nullptr), 14, 16, QChar('0')).toUpper();
|
raw = QString("%1").arg(raw.toUInt(nullptr), 14, 16, QChar('0')).toUpper();
|
||||||
|
|
||||||
|
|
||||||
QColor statusColor;
|
QColor statusColor;
|
||||||
statusColor = Qt::green; // For now leave it all green
|
statusColor = Qt::green; // For now leave it all green
|
||||||
|
|
||||||
@@ -436,3 +440,27 @@ QString MainWindow::getSmartctlOutput(const QStringList &arguments, bool root)
|
|||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
return process.readAllStandardOutput();
|
return process.readAllStandardOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -43,5 +43,6 @@ private:
|
|||||||
void addNvmeLogTable(const QJsonObject &nvmeLog);
|
void addNvmeLogTable(const QJsonObject &nvmeLog);
|
||||||
void addSmartAttributesTable(const QJsonArray &attributes);
|
void addSmartAttributesTable(const QJsonArray &attributes);
|
||||||
QString getSmartctlOutput(const QStringList &arguments, bool root);
|
QString getSmartctlOutput(const QStringList &arguments, bool root);
|
||||||
|
QString toTitleCase(const QString& sentence);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user