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