diff --git a/filetransferinstance.cpp b/filetransferinstance.cpp index 9bcc7b6e1..6167bfac3 100644 --- a/filetransferinstance.cpp +++ b/filetransferinstance.cpp @@ -21,6 +21,7 @@ #include #include #include +#include uint FileTransferInstance::Idconter = 0; @@ -76,6 +77,7 @@ void FileTransferInstance::onFileTransferInfo(int FriendId, int FileNum, int64_t long rawspeed = diff / timediff; speed = getHumanReadableSize(rawspeed)+"/s"; size = getHumanReadableSize(Filesize); + totalBytes = Filesize; if (!rawspeed) return; int etaSecs = (Filesize - BytesSent) / rawspeed; @@ -352,8 +354,16 @@ QString FileTransferInstance::draw2ButtonsForm(const QString &type, const QImage QString imgBstr = ""; QString content; - content += "

" + filename + "

"; - content += "

" + getHumanReadableSize(lastBytesSent) + " / " + size + " (" + speed + " ETA: " + eta + ")

\n"; + QString progrBar = ""; + + content = "

" + filename + "

"; + content += ""; + content += ""; + content += ""; + content += ""; + content += "
" + size + "" + speed + "ETA: " + eta + "
"; + content += progrBar; + content += "
"; return wrapIntoForm(content, type, imgAstr, imgBstr); } @@ -362,10 +372,10 @@ QString FileTransferInstance::wrapIntoForm(const QString& content, const QString { QString res; - res = "\n"; + res = "
\n"; res += "\n"; res += insertMiniature(type); - res += "
\n"; + res += "\n"; res += "
"; res += content; res += "
\n"; @@ -378,3 +388,19 @@ QString FileTransferInstance::wrapIntoForm(const QString& content, const QString return res; } + +QImage FileTransferInstance::drawProgressBarImg(const double &part, int w, int h) +{ + QImage progressBar(w, h, QImage::Format_Mono); + + QPainter qPainter(&progressBar); + qPainter.setBrush(Qt::NoBrush); + qPainter.setPen(Qt::black); + qPainter.drawRect(0, 0, w - 1, h - 1); + + qPainter.setBrush(Qt::SolidPattern); + qPainter.setPen(Qt::black); + qPainter.drawRect(1, 0, (w - 2) * (part), h - 1); + + return progressBar; +} diff --git a/filetransferinstance.h b/filetransferinstance.h index b81b03102..d1c9062d9 100644 --- a/filetransferinstance.h +++ b/filetransferinstance.h @@ -62,6 +62,7 @@ private: QString draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB); QString insertMiniature(const QString &type); QString wrapIntoForm(const QString &content, const QString &type, const QString &imgAstr, const QString &imgBstr); + QImage drawProgressBarImg(const double &part, int w, int h); private: static uint Idconter; @@ -72,7 +73,7 @@ private: QImage pic; QString filename, size, speed, eta; QDateTime lastUpdate; - long long lastBytesSent; + long long lastBytesSent, totalBytes; int fileNum; int friendId; QString savePath;