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;
if(fileInfo.status == ToxFile::TRANSMITTING)
{
// update progress
qreal progress = static_cast<qreal>(file.bytesSent) / static_cast<qreal>(file.filesize);
ui->progressBar->setValue(static_cast<int>(progress * 100.0));
@ -106,7 +108,7 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
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"));
}
else
@ -119,10 +121,14 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
lastTick = now;
lastBytesSent = file.bytesSent;
}
}
else if(fileInfo.status == ToxFile::PAUSED)
{
ui->etaLabel->setText("--:--");
ui->progressLabel->setText(getHumanReadableSize(0) + "/s");
}
setupButtons();
repaint();
update();
}
void FileTransferWidget::onFileTransferAccepted(ToxFile file)
@ -161,6 +167,9 @@ void FileTransferWidget::onFileTransferPaused(ToxFile file)
fileInfo = file;
ui->etaLabel->setText("--:--");
ui->progressLabel->setText(getHumanReadableSize(0) + "/s");
setStyleSheet(Style::getStylesheet(":/ui/fileTransferInstance/grey.css"));
Style::repolish(this);
@ -254,20 +263,20 @@ void FileTransferWidget::handleButton(QPushButton *btn)
{
if(btn->objectName() == "cancel")
Core::getInstance()->cancelFileSend(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "pause")
else if(btn->objectName() == "pause")
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "resume")
else if(btn->objectName() == "resume")
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
}
else
{
if(btn->objectName() == "cancel")
Core::getInstance()->cancelFileRecv(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "pause")
else if(btn->objectName() == "pause")
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
if(btn->objectName() == "resume")
else if(btn->objectName() == "resume")
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));
acceptTransfer(path);

View File

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

View File

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

View File

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