some fixes about uploading, some error handling
This commit is contained in:
parent
166a7ac83a
commit
326eef864b
11 changed files with 200 additions and 56 deletions
|
@ -109,7 +109,7 @@ void Message::setSender(const QString& p_sender)
|
|||
sender->setText(p_sender);
|
||||
}
|
||||
|
||||
void Message::addButton(const QIcon& icon, const QString& buttonText)
|
||||
void Message::addButton(const QIcon& icon, const QString& buttonText, const QString& tooltip)
|
||||
{
|
||||
hideFile();
|
||||
hideProgress();
|
||||
|
@ -120,7 +120,7 @@ void Message::addButton(const QIcon& icon, const QString& buttonText)
|
|||
text->hide();
|
||||
}
|
||||
button = new QPushButton(icon, buttonText);
|
||||
button->setToolTip("<a href=\"" + msg.getOutOfBandUrl() + "\">" + msg.getOutOfBandUrl() + "</a>");
|
||||
button->setToolTip(tooltip);
|
||||
connect(button, &QPushButton::clicked, this, &Message::buttonClicked);
|
||||
bodyLayout->insertWidget(2, button);
|
||||
hasButton = true;
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
QString getFileUrl() const;
|
||||
const Shared::Message& getMessage() const;
|
||||
|
||||
void addButton(const QIcon& icon, const QString& buttonText);
|
||||
void addButton(const QIcon& icon, const QString& buttonText, const QString& tooltip = "");
|
||||
void showComment(const QString& comment, bool wordWrap = false);
|
||||
void hideComment();
|
||||
void showFile(const QString& path);
|
||||
|
|
|
@ -253,8 +253,9 @@ void MessageLine::responseLocalFile(const QString& messageId, const QString& pat
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (uItr != uploading.end()) {
|
||||
itr->second->addButton(QIcon::fromTheme("download"), tr("Download"));
|
||||
if (uItr == uploading.end()) {
|
||||
const Shared::Message& msg = itr->second->getMessage();
|
||||
itr->second->addButton(QIcon::fromTheme("download"), tr("Download"), "<a href=\"" + msg.getOutOfBandUrl() + "\">" + msg.getOutOfBandUrl() + "</a>");
|
||||
itr->second->showComment(tr("Push the button to daownload the file"));
|
||||
} else {
|
||||
qDebug() << "An unhandled state for file uploading - empty path";
|
||||
|
@ -319,7 +320,8 @@ void MessageLine::fileError(const QString& messageId, const QString& error)
|
|||
itr->second->addButton(QIcon::fromTheme("upload"), tr("Upload"));
|
||||
}
|
||||
} else {
|
||||
itr->second->addButton(QIcon::fromTheme("download"), tr("Download"));
|
||||
const Shared::Message& msg = itr->second->getMessage();
|
||||
itr->second->addButton(QIcon::fromTheme("download"), tr("Download"), "<a href=\"" + msg.getOutOfBandUrl() + "\">" + msg.getOutOfBandUrl() + "</a>");
|
||||
itr->second->showComment(tr("Error downloading file: %1\nYou can try again").arg(QCoreApplication::translate("NetworkErrors", error.toLatin1())), true);
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +333,7 @@ void MessageLine::appendMessageWithUpload(const Shared::Message& msg, const QStr
|
|||
Message* ui = messageIndex.find(id)->second;
|
||||
connect(ui, &Message::buttonClicked, this, &MessageLine::onUpload); //this is in case of retry;
|
||||
ui->setProgress(0);
|
||||
ui->showComment("Uploading...");
|
||||
ui->showComment(tr("Uploading..."));
|
||||
uploading.insert(std::make_pair(id, ui));
|
||||
uploadPaths.insert(std::make_pair(id, path));
|
||||
emit uploadFile(msg, path);
|
||||
|
|
|
@ -27,7 +27,8 @@ QObject(parent)
|
|||
bool Resizer::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::Resize) {
|
||||
emit resized();
|
||||
QResizeEvent* ev = static_cast<QResizeEvent*>(event);
|
||||
emit resized(ev->oldSize(), ev->size());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QEvent>
|
||||
#include <QResizeEvent>
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
|
@ -35,7 +36,7 @@ protected:
|
|||
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||
|
||||
signals:
|
||||
void resized();
|
||||
void resized(const QSize& oldSize, const QSize& newSize);
|
||||
};
|
||||
|
||||
#endif // RESIZER_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue