download files error handling

This commit is contained in:
Blue 2019-09-18 16:27:47 +03:00
parent cc54c6393a
commit 2089d6af86
13 changed files with 199 additions and 9 deletions

View file

@ -38,10 +38,12 @@ Message::Message(const Shared::Message& source, bool outgoing, const QString& p_
file(0),
progress(0),
fileComment(new QLabel()),
errorText(""),
hasDownloadButton(false),
hasProgress(false),
hasFile(false),
commentAdded(false)
commentAdded(false),
errorDownloadingFile(false)
{
body->setBackgroundRole(QPalette::AlternateBase);
body->setAutoFillBackground(true);
@ -117,7 +119,12 @@ void Message::addDownloadDialog()
}
downloadButton = new QPushButton(QIcon::fromTheme("download"), "Download");
downloadButton->setToolTip("<a href=\"" + msg.getOutOfBandUrl() + "\">" + msg.getOutOfBandUrl() + "</a>");
fileComment->setText(sender->text() + " is offering you to download a file");
if (errorDownloadingFile) {
fileComment->setWordWrap(true);
fileComment->setText("Error downloading file: " + errorText + "\nYou can try again");
} else {
fileComment->setText(sender->text() + " is offering you to download a file");
}
fileComment->show();
connect(downloadButton, SIGNAL(clicked()), this, SLOT(onDownload()));
bodyLayout->insertWidget(2, fileComment);
@ -208,6 +215,7 @@ void Message::hideDownload()
downloadButton->deleteLater();
downloadButton = 0;
hasDownloadButton = false;
errorDownloadingFile = false;
}
}
@ -228,3 +236,10 @@ void Message::hideProgress()
hasProgress = false;;
}
}
void Message::showError(const QString& error)
{
errorDownloadingFile = true;
errorText = error;
addDownloadDialog();
}