QString FileTransferInstance::draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB) { QString widgetId = QString::number(getId()); QString imgAstr = "<img src=\"data:ftrans." + widgetId + ".btnA/png;base64," + QImage2base64(imgA) + "\">"; QString imgBstr = "<img src=\"data:ftrans." + widgetId + ".btnB/png;base64," + QImage2base64(imgB) + "\">"; QString content; content += "<p>" + filename + "</p>"; content += "<p>" + getHumanReadableSize(lastBytesSent) + " / " + size + " (" + speed + " ETA: " + eta + ")</p>\n"; return wrapIntoForm(content, type, imgAstr, imgBstr); }
QString FileTransferInstance::drawButtonlessForm(const QString &type) { QString imgAStr; QString imgBStr; if (type == "red") { imgAStr = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/emptyLRedFileButton.png")) + "\">"; imgBStr = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/emptyRRedFileButton.png")) + "\">"; } else { imgAStr = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/emptyLGreenFileButton.png")) + "\">"; imgBStr = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/emptyRGreenFileButton.png")) + "\">"; } QString content = "<p>" + filenameElided + "</p><p>" + size + "</p>"; return wrapIntoForm(content, type, imgAStr, imgBStr); }
QString FileTransferInstance::draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB) { QString widgetId = QString::number(getId()); QString imgAstr = "<img src=\"data:ftrans." + widgetId + ".btnA/png;base64," + QImage2base64(imgA) + "\">"; QString imgBstr = "<img src=\"data:ftrans." + widgetId + ".btnB/png;base64," + QImage2base64(imgB) + "\">"; QString content; QString progrBar = "<img src=\"data:progressbar." + widgetId + "/png;base64," + QImage2base64(drawProgressBarImg(double(lastBytesSent)/totalBytes, CONTENT_WIDTH, 9)) + "\">"; content = "<p>" + filenameElided + "</p>"; content += "<table cellspacing=\"0\"><tr>"; content += "<td>" + size + "</td>"; content += "<td align=center>" + speed + "</td>"; content += "<td align=right>ETA: " + eta + "</td>"; content += "</tr><tr><td colspan=3>"; content += progrBar; content += "</td></tr></table>"; return wrapIntoForm(content, type, imgAstr, imgBstr); }
QString FileTransferInstance::insertMiniature(const QString &type) { if (pic == QImage()) return QString(); QString widgetId = QString::number(getId()); QString res; res = "<td><div class=" + type + ">\n"; res += "<img src=\"data:mini." + widgetId + "/png;base64," + QImage2base64(pic) + "\">"; res += "</div></td>\n"; return res; }
QString FileTransferInstance::wrapIntoForm(const QString& content, const QString &type, const QString &imgAstr, const QString &imgBstr) { QString w = QString::number(QImage(":/ui/fileTransferInstance/emptyLRedFileButton.png").size().width()); QString imgLeftA, imgLeftB; if (type == "green") { imgLeftA = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/emptyLGreenFileButton.png").mirrored(true,false)) + "\">"; imgLeftB = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/emptyLGreenFileButton.png").mirrored(true,true)) + "\">"; } if (type == "silver") { imgLeftA = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/sliverRTEdge.png").mirrored(true,false)) + "\">"; imgLeftB = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/sliverRTEdge.png").mirrored(true,true)) + "\">"; } if (type == "red") { imgLeftA = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/emptyLRedFileButton.png").mirrored(true,false)) + "\">"; imgLeftB = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/emptyLRedFileButton.png").mirrored(true,true)) + "\">"; } QString res; res = "<table cellspacing=\"0\">\n"; res += "<tr valign=middle>\n"; res += "<td width=" + w + ">\n"; res += "<div class=button>" + imgLeftA + "<br>" + imgLeftB + "</div>\n"; res += "</td>\n"; res += insertMiniature(type); res += "<td width=" + QString::number(contentPrefWidth) + ">\n"; res += "<div class=" + type + ">"; res += content; res += "</div>\n"; res += "</td>\n"; res += "<td width=3>\n"; res += "<div class=" + type + "></div>\n"; res += "</td>\n"; res += "<td>\n"; res += "<div class=button>" + imgAstr + "<br>" + imgBstr + "</div>\n"; res += "</td>\n"; res += "</tr>\n"; res += "</table>\n"; return res; }