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

somehow working example

This commit is contained in:
apprb 2014-09-06 20:13:06 +07:00
parent 25ee6a24d9
commit 0fe14953c8
3 changed files with 27 additions and 52 deletions

View File

@ -217,7 +217,11 @@ QString FileTransferInstance::getHtmlImage()
if (state == tsPending || state == tsProcessing || state == tsPaused)
{
QImage rightUp(":ui/stopFileButton/default.png");
QImage rightDown(":ui/acceptFileButton/default.png");
QImage rightDown;
if (state == tsProcessing)
rightDown = QImage(":ui/pauseFileButton/default.png");
else
rightDown = QImage(":ui/acceptFileButton/default.png");
QString widgetId = QString::number(getId());
QString strUp = "<img src=\"data:ftrans." + widgetId + ".top/png;base64," + QImage2base64(rightUp) + "\">";
@ -225,7 +229,8 @@ QString FileTransferInstance::getHtmlImage()
res = "<table widht=100% cellspacing=\"2\">\n";
res += "<tr>\n<td width=100%>\n";
res += "<div class=quote><p>PROCESSING</p><p>" + filename + "</p><p>" + size + "</p></div>\n";
res += "<div class=green><p>" + filename + "</p><p>" + getHumanReadableSize(lastBytesSent) + "/" + size;
res += "&nbsp;(" + speed + ")</p></div>\n";
res += "</td>\n<td>\n";
res += "<table cellspacing=\"0\"><tr valign=top><td>" + strUp + "</td></tr><tr valign=bottom><td>" + strDown + "</td></tr></table>\n";
res += "</td>\n</tr>\n";
@ -234,14 +239,14 @@ QString FileTransferInstance::getHtmlImage()
{
res = "<table widht=100% cellspacing=\"2\">\n";
res += "<tr>\n<td width=100%>\n";
res += "<div class=quote><p>CANCELED</p><p>" + filename + "</p><p>" + size + "</p></div>\n";
res += "<div class=red><p>" + filename + "</p><p>" + size + "</p></div>\n";
res += "</td>\n</tr>\n";
res += "</table>\n";
} else if (state == tsFinished)
{
res = "<table widht=100% cellspacing=\"2\">\n";
res += "<tr>\n<td width=100%>\n";
res += "<div class=quote><p>FINISHED</p><p>" + filename + "</p><p>" + size + "</p></div>\n";
res += "<div class=green><p>" + filename + "</p><p>" + size + "</p></div>\n";
res += "</td>\n</tr>\n";
res += "</table>\n";
}

View File

@ -35,3 +35,21 @@ div.date {
color: #000000;
padding-left: 3px;
}
div.green {
margin-top: 12px;
margin-bottom: 12px;
margin-left: 12px;
color: #ffffff;
background-color: #6bc260;
font-size: 10px;
}
div.red {
margin-top: 12px;
margin-bottom: 12px;
margin-left: 12px;
color: #ffffff;
background-color: rgb(200,78,78);
font-size: 10px;
}

View File

@ -95,34 +95,8 @@ void ChatForm::startFileSend(ToxFile file)
if (file.friendId != f->friendId)
return;
// QLabel *author = new QLabel(Widget::getInstance()->getUsername());
// QLabel *date = new QLabel(QTime::currentTime().toString("hh:mm"));
// QScrollBar* scroll = chatArea->verticalScrollBar();
// lockSliderToBottom = scroll && scroll->value() == scroll->maximum();
// author->setAlignment(Qt::AlignTop | Qt::AlignRight);
// date->setAlignment(Qt::AlignTop);
// QPalette pal;
// pal.setColor(QPalette::WindowText, Qt::gray);
// author->setPalette(pal);
// if (previousName.isEmpty() || previousName != author->text())
// {
// if (curRow)
// {
// mainChatLayout->setRowStretch(curRow, 0);
// mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3);
// curRow++;
// }
// mainChatLayout->addWidget(author, curRow, 0);
// }
FileTransferInstance* fileTrans = new FileTransferInstance(file);
ftransWidgets.insert(fileTrans->getId(), fileTrans);
// previousName = author->text();
// mainChatLayout->addWidget(fileTrans, curRow, 1);
// mainChatLayout->addWidget(date, curRow, 3);
// mainChatLayout->setRowStretch(curRow+1, 1);
// mainChatLayout->setRowStretch(curRow, 0);
// curRow++;
connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo);
connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled);
@ -138,30 +112,8 @@ void ChatForm::onFileRecvRequest(ToxFile file)
if (file.friendId != f->friendId)
return;
// QLabel *author = new QLabel(f->getName());
// QLabel *date = new QLabel(QTime::currentTime().toString("hh:mm"));
// QScrollBar* scroll = chatArea->verticalScrollBar();
// lockSliderToBottom = scroll && scroll->value() == scroll->maximum();
// author->setAlignment(Qt::AlignTop | Qt::AlignRight);
// date->setAlignment(Qt::AlignTop);
// if (previousName.isEmpty() || previousName != author->text())
// {
// if (curRow)
// {
// mainChatLayout->setRowStretch(curRow, 0);
// mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3);
// curRow++;
// }
// mainChatLayout->addWidget(author, curRow, 0);
// }
FileTransferInstance* fileTrans = new FileTransferInstance(file);
ftransWidgets.insert(fileTrans->getId(), fileTrans);
// previousName = author->text();
// mainChatLayout->addWidget(fileTrans, curRow, 1);
// mainChatLayout->addWidget(date, curRow, 3);
// mainChatLayout->setRowStretch(curRow+1, 1);
// mainChatLayout->setRowStretch(curRow, 0);
// curRow++;
connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo);
connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled);