-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
67 lines (48 loc) · 1.36 KB
/
utils.h
File metadata and controls
67 lines (48 loc) · 1.36 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef UTILS_H
#define UTILS_H
#include <iostream>
#include <QDebug>
#include <QObject>
#include <QClipboard>
#include <QtNetwork>
#include <QCoreApplication>
#include <QApplication>
class DumpzService: public QObject
{
Q_OBJECT
private:
QNetworkAccessManager *manager;
QNetworkReply *reply;
public:
DumpzService()
{
manager = new QNetworkAccessManager();
}
QString postDump(QString text)
{
QString url;
QByteArray data;
QUrl params;
QNetworkRequest request(QUrl("http://dumpz.org/"));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
params.addQueryItem("lexer", "text");
params.addQueryItem("code", QUrl::toPercentEncoding(text));
data.append(params.toString());
data.remove(0, 1);
reply = manager->post(request, data);
connect(reply, SIGNAL(finished()), this, SLOT(responseReceived()));
return url;
};
public slots:
void responseReceived()
{
QByteArray location = reply->rawHeader("Location");
// put url to terminal
std::cout << ((QString) location).toStdString();
// put url to clipboard
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText((QString) location);
QApplication::quit();
}
};
#endif