1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

filetransferinstance should use own pictures

This commit is contained in:
apprb 2014-09-07 15:04:42 +07:00
parent b3d6102a20
commit 0a1eaac9a4
12 changed files with 41 additions and 18 deletions

View File

@ -217,14 +217,16 @@ QString FileTransferInstance::getHtmlImage()
QString res; QString res;
if (state == tsPending || state == tsProcessing || state == tsPaused) if (state == tsPending || state == tsProcessing || state == tsPaused)
{ {
QImage rightUp(":ui/stopFileButton/default.png"); QImage leftBtnImg(":/ui/fileTransferInstance/stopFileButton.png");
QImage rightDown; QImage rightBtnImg;
if (state == tsProcessing) if (state == tsProcessing)
rightDown = QImage(":ui/pauseFileButton/default.png"); rightBtnImg = QImage(":/ui/fileTransferInstance/pauseFileButton.png");
else if (state == tsPaused)
rightBtnImg = QImage(":/ui/fileTransferInstance/resumeFileButton.png");
else else
rightDown = QImage(":ui/acceptFileButton/default.png"); rightBtnImg = QImage(":/ui/fileTransferInstance/acceptFileButton.png");
res = draw2ButtonsForm("green", rightUp, rightDown); res = draw2ButtonsForm("green", leftBtnImg, rightBtnImg);
} else if (state == tsCanceled) } else if (state == tsCanceled)
{ {
res = drawButtonlessForm("red"); res = drawButtonlessForm("red");
@ -262,16 +264,21 @@ void FileTransferInstance::pressFromHtml(QString code)
QString FileTransferInstance::drawButtonlessForm(const QString &type) QString FileTransferInstance::drawButtonlessForm(const QString &type)
{ {
QString res; QString imgAStr;
QString imgBStr;
res = "<table widht=100% cellspacing=\"1\">\n<tr>\n"; if (type == "red")
res += insertMiniature(); {
res += "<td width=100%>\n"; imgAStr = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/emptyLRedFileButton.png")) + "\">";
res += "<div class=" + type + "><p>" + filename + "</p><p>" + size + "</p></div>\n"; imgBStr = "<img src=\"data:placeholder/png;base64," + QImage2base64(QImage(":/ui/fileTransferInstance/emptyRRedFileButton.png")) + "\">";
res += "</td>\n</tr>\n"; } else {
res += "</table>\n"; 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")) + "\">";
}
return res; QString content = "<p>" + filename + "</p><p>" + size + "</p>";
return wrapIntoForm(content, type, imgAStr, imgBStr);
} }
QString FileTransferInstance::insertMiniature() QString FileTransferInstance::insertMiniature()
@ -290,12 +297,21 @@ QString FileTransferInstance::insertMiniature()
QString FileTransferInstance::draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB) QString FileTransferInstance::draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB)
{ {
QString res;
QString widgetId = QString::number(getId()); QString widgetId = QString::number(getId());
QString imgAstr = "<img src=\"data:ftrans." + widgetId + ".btnA/png;base64," + QImage2base64(imgA) + "\">"; 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 imgBstr = "<img src=\"data:ftrans." + widgetId + ".btnB/png;base64," + QImage2base64(imgB) + "\">";
QString content;
content += "<p>" + filename + "</p>";
content += "<p>" + getHumanReadableSize(lastBytesSent) + " / " + size; + "&nbsp;(" + speed + ")</p>\n";
return wrapIntoForm(content, type, imgAstr, imgBstr);
}
QString FileTransferInstance::wrapIntoForm(const QString& content, const QString &type, const QString &imgAstr, const QString &imgBstr)
{
QString res;
res = "<table widht=100% cellspacing=\"1\">\n"; res = "<table widht=100% cellspacing=\"1\">\n";
res += "<tr valign=middle>\n"; res += "<tr valign=middle>\n";
res += "<td>\n"; res += "<td>\n";
@ -304,8 +320,7 @@ QString FileTransferInstance::draw2ButtonsForm(const QString &type, const QImage
res += insertMiniature(); res += insertMiniature();
res += "<td width=100%>\n"; res += "<td width=100%>\n";
res += "<div class=" + type + ">"; res += "<div class=" + type + ">";
res += "<p>" + filename + "</p>"; res += content;
res += "<p>" + getHumanReadableSize(lastBytesSent) + " / " + size; + "&nbsp;(" + speed + ")</p>\n";
res += "</div>\n"; res += "</div>\n";
res += "</td>\n"; res += "</td>\n";
res += "<td>\n"; res += "<td>\n";

View File

@ -58,6 +58,7 @@ private:
QString drawButtonlessForm(const QString &type); QString drawButtonlessForm(const QString &type);
QString draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB); QString draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB);
QString insertMiniature(); QString insertMiniature();
QString wrapIntoForm(const QString &content, const QString &type, const QString &imgAstr, const QString &imgBstr);
private: private:
enum TransfState {tsPending, tsProcessing, tsPaused, tsFinished, tsCanceled}; enum TransfState {tsPending, tsProcessing, tsPaused, tsFinished, tsCanceled};

View File

@ -126,5 +126,13 @@
<file>ui/micButton/micButtonPressed.png</file> <file>ui/micButton/micButtonPressed.png</file>
<file>ui/micButton/micButton.css</file> <file>ui/micButton/micButton.css</file>
<file>ui/volButton/volButton.css</file> <file>ui/volButton/volButton.css</file>
<file>ui/fileTransferInstance/acceptFileButton.png</file>
<file>ui/fileTransferInstance/pauseFileButton.png</file>
<file>ui/fileTransferInstance/resumeFileButton.png</file>
<file>ui/fileTransferInstance/stopFileButton.png</file>
<file>ui/fileTransferInstance/emptyLGreenFileButton.png</file>
<file>ui/fileTransferInstance/emptyLRedFileButton.png</file>
<file>ui/fileTransferInstance/emptyRGreenFileButton.png</file>
<file>ui/fileTransferInstance/emptyRRedFileButton.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -50,7 +50,6 @@ div.button {
margin-bottom: 0px; margin-bottom: 0px;
margin-left: 0px; margin-left: 0px;
color: #ffffff; color: #ffffff;
background-color: #6bc260;
} }
div.red { div.red {

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B