mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
- Optimised GUI class a little
This commit is contained in:
parent
29a290264e
commit
c064e5877c
3 changed files with 33 additions and 39 deletions
22
src/misc.h
22
src/misc.h
|
@ -116,29 +116,21 @@ class misc : public QObject{
|
|||
const QString units[4] = {tr("B", "bytes"), tr("KiB", "kibibytes (1024 bytes)"), tr("MiB", "mebibytes (1024 kibibytes)"), tr("GiB", "gibibytes (1024 mibibytes)")};
|
||||
for(unsigned int i=0; i<5; ++i) {
|
||||
if (val < 1024.) {
|
||||
snprintf(tmp, MAX_CHAR_TMP, "%.1f", val);
|
||||
return QString::fromUtf8(tmp) + QString::fromUtf8(" ") + units[i];
|
||||
snprintf(tmp, MAX_CHAR_TMP, "%.1f ", val);
|
||||
return QString::fromUtf8(tmp) + units[i];
|
||||
}
|
||||
val /= 1024.;
|
||||
}
|
||||
snprintf(tmp, MAX_CHAR_TMP, "%.1f", val);
|
||||
return QString::fromUtf8(tmp) + QString::fromUtf8(" ") + tr("TiB", "tebibytes (1024 gibibytes)");
|
||||
snprintf(tmp, MAX_CHAR_TMP, "%.1f ", val);
|
||||
return QString::fromUtf8(tmp) + tr("TiB", "tebibytes (1024 gibibytes)");
|
||||
}
|
||||
|
||||
// return qBittorrent config path
|
||||
static QString qBittorrentPath() {
|
||||
QString qBtPath = QDir::homePath();
|
||||
if(qBtPath.isNull()) {
|
||||
return QString();
|
||||
}
|
||||
if(qBtPath[qBtPath.length()-1] == QDir::separator()) {
|
||||
qBtPath = qBtPath + QString::fromUtf8(".qbittorrent") + QDir::separator();
|
||||
}else{
|
||||
qBtPath = qBtPath + QDir::separator() + QString::fromUtf8(".qbittorrent") + QDir::separator();
|
||||
}
|
||||
QString qBtPath = QDir::cleanPath(QDir::homePath()+QDir::separator()+QString::fromUtf8(".qbittorrent") + QDir::separator());
|
||||
// Create dir if it does not exist
|
||||
QDir dir(qBtPath);
|
||||
if(!dir.exists()) {
|
||||
if(!QFile::exists(qBtPath)){
|
||||
QDir dir(qBtPath);
|
||||
dir.mkpath(qBtPath);
|
||||
}
|
||||
return qBtPath;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue