Files
RRJClient/Core/tools.cpp
2025-01-20 10:59:06 +03:00

83 lines
1.7 KiB
C++

#include "tools.h"
#include <qdir.h>
void Tools::printTime()
{
qDebug() << QTime::currentTime().toString("hh:mm:ss");
}
QString Tools::getTime()
{
return QTime::currentTime().toString(("hh:mm:ss"));
}
QString Tools::createLocalPath(QString path)
{
qDebug() << "Full path: " << path;
qint8 pos = path.indexOf("Application");
QString localPath = path.remove(0,--pos);
qDebug() << "Local path: " << localPath;
return localPath;
}
QString Tools::createReceiveFullPath(QString path, StreamingVersionData *version)
{
QString fullPath;
QString localPath;
qint8 pos = path.indexOf("Application");
if(pos == -1)
{
pos = path.indexOf(version->getViewName());
localPath = path.remove(0,pos + version->getViewName().length());
localPath.prepend(streamingAssetsPath);
}
else
{
localPath = path.remove(0,--pos);
}
fullPath = QDir::currentPath() + localPath;
qDebug() << "CLIENT: localPath" << localPath;
return fullPath;
}
QString Tools::createSendFullPath(QString path)
{
QString fullPath;
qint8 pos = path.indexOf("Application");
QString localPath = path.remove(0,--pos);
qDebug() << "CLIENT: localPath" << localPath;
fullPath = QDir::currentPath() + localPath;
return fullPath;
}
QString Tools::convertFileSize(quint64 fileSize)
{
quint64 megaByte = fileSize / (1024 * 1024);
QString resultSize;
if (megaByte == 0)
{
auto kiloByte = fileSize / 1024;
resultSize = QString::number(kiloByte) + "кб. ";
}
else
{
resultSize = QString::number(megaByte) + "мб. ";
}
QString result = resultSize;
return result;
}