| 76 | } |
| 77 | |
| 78 | QString GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget) |
| 79 | { |
| 80 | ProgressDialog dialog(parentWidget); |
| 81 | auto pasteTypeSetting = static_cast<PasteUpload::PasteType>(APPLICATION->settings()->get("PastebinType").toInt()); |
| 82 | auto pasteCustomAPIBaseSetting = APPLICATION->settings()->get("PastebinCustomAPIBase").toString(); |
| 83 | std::unique_ptr<PasteUpload> paste(new PasteUpload(parentWidget, text, pasteCustomAPIBaseSetting, pasteTypeSetting)); |
| 84 | |
| 85 | dialog.execWithTask(paste.get()); |
| 86 | if (!paste->wasSuccessful()) |
| 87 | { |
| 88 | CustomMessageBox::selectable( |
| 89 | parentWidget, |
| 90 | QObject::tr("Upload failed"), |
| 91 | paste->failReason(), |
| 92 | QMessageBox::Critical |
| 93 | )->exec(); |
| 94 | return QString(); |
| 95 | } |
| 96 | else |
| 97 | { |
| 98 | const QString link = paste->pasteLink(); |
| 99 | setClipboardText(link); |
| 100 | CustomMessageBox::selectable( |
| 101 | parentWidget, QObject::tr("Upload finished"), |
| 102 | QObject::tr("The <a href=\"%1\">link to the uploaded log</a> has been placed in your clipboard.").arg(link), |
| 103 | QMessageBox::Information)->exec(); |
| 104 | return link; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | void GuiUtil::setClipboardText(const QString &text) |
| 109 | { |
nothing calls this directly
no test coverage detected