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

filetransferwidget: fixed pause button, ETA, font size, resource usage

This commit is contained in:
krepa098 2015-01-04 12:04:30 +01:00
parent f630583e59
commit ea467152aa
4 changed files with 42 additions and 30 deletions

View File

@ -91,6 +91,8 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
fileInfo = file; fileInfo = file;
if(fileInfo.status == ToxFile::TRANSMITTING)
{
// update progress // update progress
qreal progress = static_cast<qreal>(file.bytesSent) / static_cast<qreal>(file.filesize); qreal progress = static_cast<qreal>(file.bytesSent) / static_cast<qreal>(file.filesize);
ui->progressBar->setValue(static_cast<int>(progress * 100.0)); ui->progressBar->setValue(static_cast<int>(progress * 100.0));
@ -106,7 +108,7 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
if(bytesPerSec > 0) if(bytesPerSec > 0)
{ {
QTime toGo(0,0,file.filesize / bytesPerSec); QTime toGo = QTime(0,0).addSecs(file.filesize / bytesPerSec);
ui->etaLabel->setText(toGo.toString("mm:ss")); ui->etaLabel->setText(toGo.toString("mm:ss"));
} }
else else
@ -119,10 +121,14 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
lastTick = now; lastTick = now;
lastBytesSent = file.bytesSent; lastBytesSent = file.bytesSent;
} }
}
else if(fileInfo.status == ToxFile::PAUSED)
{
ui->etaLabel->setText("--:--");
ui->progressLabel->setText(getHumanReadableSize(0) + "/s");
}
setupButtons(); update();
repaint();
} }
void FileTransferWidget::onFileTransferAccepted(ToxFile file) void FileTransferWidget::onFileTransferAccepted(ToxFile file)
@ -161,6 +167,9 @@ void FileTransferWidget::onFileTransferPaused(ToxFile file)
fileInfo = file; fileInfo = file;
ui->etaLabel->setText("--:--");
ui->progressLabel->setText(getHumanReadableSize(0) + "/s");
setStyleSheet(Style::getStylesheet(":/ui/fileTransferInstance/grey.css")); setStyleSheet(Style::getStylesheet(":/ui/fileTransferInstance/grey.css"));
Style::repolish(this); Style::repolish(this);
@ -254,20 +263,20 @@ void FileTransferWidget::handleButton(QPushButton *btn)
{ {
if(btn->objectName() == "cancel") if(btn->objectName() == "cancel")
Core::getInstance()->cancelFileSend(fileInfo.friendId, fileInfo.fileNum); Core::getInstance()->cancelFileSend(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "pause") else if(btn->objectName() == "pause")
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum); Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "resume") else if(btn->objectName() == "resume")
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum); Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
} }
else else
{ {
if(btn->objectName() == "cancel") if(btn->objectName() == "cancel")
Core::getInstance()->cancelFileRecv(fileInfo.friendId, fileInfo.fileNum); Core::getInstance()->cancelFileRecv(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "pause") else if(btn->objectName() == "pause")
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum); Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "resume") else if(btn->objectName() == "resume")
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum); Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "accept") else if(btn->objectName() == "accept")
{ {
QString path = QFileDialog::getSaveFileName(0, tr("Save a file","Title of the file saving dialog"), QDir::home().filePath(fileInfo.fileName)); QString path = QFileDialog::getSaveFileName(0, tr("Save a file","Title of the file saving dialog"), QDir::home().filePath(fileInfo.fileName));
acceptTransfer(path); acceptTransfer(path);

View File

@ -8,6 +8,7 @@ QFrame {
QLabel { QLabel {
color:white; color:white;
font:@medium;
} }
QPushButton { QPushButton {

View File

@ -8,6 +8,7 @@ QFrame {
QLabel { QLabel {
color:white; color:white;
font:@medium;
} }
QPushButton { QPushButton {

View File

@ -8,6 +8,7 @@ QFrame {
QLabel { QLabel {
color:black; color:black;
font:@medium;
} }
QPushButton { QPushButton {