From 1151037f968628cd659f06457f9ca7403f77f071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 11 Jan 2015 03:08:41 +0100 Subject: GH-719 Fix paste upload encoding and do not try to upload over limit --- gui/GuiUtil.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'gui') diff --git a/gui/GuiUtil.cpp b/gui/GuiUtil.cpp index 72c09ffe..fcbc8acd 100644 --- a/gui/GuiUtil.cpp +++ b/gui/GuiUtil.cpp @@ -11,12 +11,22 @@ void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget) { ProgressDialog dialog(parentWidget); - PasteUpload *paste = new PasteUpload(parentWidget, text); - dialog.exec(paste); + std::unique_ptr paste(new PasteUpload(parentWidget, text)); + + if (!paste->validateText()) + { + CustomMessageBox::selectable( + parentWidget, QObject::tr("Upload failed"), + QObject::tr("The log file is too big. You'll have to upload it manually."), + QMessageBox::Warning)->exec(); + return; + } + + dialog.exec(paste.get()); if (!paste->successful()) { - CustomMessageBox::selectable(parentWidget, "Upload failed", paste->failReason(), - QMessageBox::Critical)->exec(); + CustomMessageBox::selectable(parentWidget, QObject::tr("Upload failed"), + paste->failReason(), QMessageBox::Critical)->exec(); } else { @@ -25,11 +35,11 @@ void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget) QDesktopServices::openUrl(link); CustomMessageBox::selectable( parentWidget, QObject::tr("Upload finished"), - QObject::tr("The link to the uploaded log has been opened in the default " - "browser and placed in your clipboard.").arg(link), + QObject::tr("The link to the uploaded log has been opened in " + "the default " + "browser and placed in your clipboard.").arg(link), QMessageBox::Information)->exec(); } - delete paste; } void GuiUtil::setClipboardText(const QString &text) -- cgit v1.2.3