blob: 72c09ffeb4958b43f1dffb2ce599b14fc964304f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include "GuiUtil.h"
#include <QClipboard>
#include <QDesktopServices>
#include <QApplication>
#include "dialogs/ProgressDialog.h"
#include "logic/net/PasteUpload.h"
#include "dialogs/CustomMessageBox.h"
void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
{
ProgressDialog dialog(parentWidget);
PasteUpload *paste = new PasteUpload(parentWidget, text);
dialog.exec(paste);
if (!paste->successful())
{
CustomMessageBox::selectable(parentWidget, "Upload failed", paste->failReason(),
QMessageBox::Critical)->exec();
}
else
{
const QString link = paste->pasteLink();
setClipboardText(link);
QDesktopServices::openUrl(link);
CustomMessageBox::selectable(
parentWidget, QObject::tr("Upload finished"),
QObject::tr("The <a href=\"%1\">link to the uploaded log</a> 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)
{
QApplication::clipboard()->setText(text);
}
|