mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Renamed TypedBytes to RawImageData, type to format.
FeelsGoodMan Clap
This commit is contained in:
parent
736df48788
commit
6c261459cf
|
@ -44,10 +44,9 @@ boost::optional<QByteArray> convertToPng(QImage image)
|
|||
namespace chatterino {
|
||||
// These variables are only used from the main thread.
|
||||
bool isUploading = false;
|
||||
std::queue<RawImageData> uploadQueue;
|
||||
|
||||
std::queue<TypedBytes> uploadQueue;
|
||||
|
||||
void uploadImageToNuuls(TypedBytes imageData, ChannelPtr channel,
|
||||
void uploadImageToNuuls(RawImageData imageData, ChannelPtr channel,
|
||||
ResizingTextEdit &textEdit)
|
||||
{
|
||||
const char *boundary = "thisistheboudaryasd";
|
||||
|
@ -59,13 +58,13 @@ void uploadImageToNuuls(TypedBytes imageData, ChannelPtr channel,
|
|||
QHttpPart part = QHttpPart();
|
||||
part.setBody(imageData.data);
|
||||
part.setHeader(QNetworkRequest::ContentTypeHeader,
|
||||
QString("image/%1").arg(imageData.type));
|
||||
QString("image/%1").arg(imageData.format));
|
||||
part.setHeader(QNetworkRequest::ContentLengthHeader,
|
||||
QVariant(imageData.data.length()));
|
||||
part.setHeader(
|
||||
QNetworkRequest::ContentDispositionHeader,
|
||||
QString("form-data; name=\"attachment\"; filename=\"control_v.%1\"")
|
||||
.arg(imageData.type));
|
||||
.arg(imageData.format));
|
||||
payload->setBoundary(boundary);
|
||||
payload->append(part);
|
||||
NetworkRequest(url, NetworkRequestType::Post)
|
||||
|
@ -163,7 +162,7 @@ void upload(const QMimeData *source, ChannelPtr channel,
|
|||
boost::optional<QByteArray> imageData = convertToPng(img);
|
||||
if (imageData)
|
||||
{
|
||||
TypedBytes data = {imageData.get(), "png"};
|
||||
RawImageData data = {imageData.get(), "png"};
|
||||
uploadQueue.push(data);
|
||||
}
|
||||
else
|
||||
|
@ -186,7 +185,7 @@ void upload(const QMimeData *source, ChannelPtr channel,
|
|||
makeSystemMessage(QString("Failed to open file. :(")));
|
||||
return;
|
||||
}
|
||||
TypedBytes data = {file.readAll(), "gif"};
|
||||
RawImageData data = {file.readAll(), "gif"};
|
||||
uploadQueue.push(data);
|
||||
file.close();
|
||||
// file.readAll() => might be a bit big but it /should/ work
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
#include <QString>
|
||||
|
||||
namespace chatterino {
|
||||
struct TypedBytes {
|
||||
struct RawImageData {
|
||||
QByteArray data;
|
||||
QString type;
|
||||
QString format;
|
||||
};
|
||||
void upload(QByteArray imageData, ChannelPtr channel,
|
||||
ResizingTextEdit &textEdit, std::string format);
|
||||
void upload(TypedBytes imageData, ChannelPtr channel,
|
||||
void upload(RawImageData imageData, ChannelPtr channel,
|
||||
ResizingTextEdit &textEdit);
|
||||
void upload(const QMimeData *source, ChannelPtr channel,
|
||||
ResizingTextEdit &outputTextEdit);
|
||||
|
|
Loading…
Reference in a new issue