Client: DownloadsWidget

This commit is contained in:
Ralf
2024-11-17 10:24:04 +03:00
parent 495eb2e06d
commit 93399b848a
12 changed files with 349 additions and 15 deletions
+17 -1
View File
@@ -68,4 +68,20 @@ QString FormatSecToStr(int seconds)
QString TrimmedEnds(QString str)
{
return str.remove(QRegularExpression("\\s+$"));
}
}
QString BytesToFormat(int bytes)
{
const double KB = 1024.0;
const double MB = KB * 1024;
const double GB = MB * 1024;
if (bytes >= GB) {
return QString::number(bytes / GB, 'f', 2) + " Gb";
} else if (bytes >= MB) {
return QString::number(bytes / MB, 'f', 2) + " Mb";
} else {
return QString::number(bytes / KB, 'f', 2) + " Kb";
}
}