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