Verified Commit 04275bdf authored by Linus Jahn's avatar Linus Jahn 🍙

Fix compatibility with Qt 5.8/5.9

Now the sizes on Ubuntu Touch (and all other builds using Qt 5.8/5.9)
will always be given in MiB, because in these Qt versions no
formattedDataSize(bytes) existed.
parent b696fd3f
......@@ -277,6 +277,12 @@ QString Kaidan::fileNameFromUrl(QString url)
QString Kaidan::fileSizeFromUrl(QString url)
{
#if QT_VERSION >= 0x051000 // Qt 5.10 or later
qint64 size = QFileInfo(QUrl(url).toLocalFile()).size();
return QLocale::system().formattedDataSize(size);
#else
// before Qt 5.10: sizes will always be in MiB
double size = QFileInfo(QUrl(url).toLocalFile()).size();
return QString::number(qRound(size / 1024.0 / 10.24) / 100.0).append(" MiB");
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment