Fix issues pointed out in reviews :)
Fixed PR BabyRage
This commit is contained in:
+3
-2
@@ -27,7 +27,7 @@ Arguments:
|
||||
- None
|
||||
|
||||
Notes:
|
||||
- If you want to host the images yourself. You need [Nuuls' filehost software](https://github.com/nuuls/fiehost)
|
||||
- If you want to host the images yourself. You need [Nuuls' filehost software](https://github.com/nuuls/filehost)
|
||||
- Other image hosting software is currently not supported.
|
||||
|
||||
### CHATTERINO2_TWITCH_SERVER_HOST
|
||||
@@ -42,4 +42,5 @@ Default value: `443`
|
||||
|
||||
### CHATTERINO2_TWITCH_SERVER_SECURE
|
||||
Bool value used to tell Chatterino whether to try to connect securely (secure irc) to the Twitch chat server.
|
||||
Default value: `true`
|
||||
Default value: `true`
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
QString getImageFileFormat(QString path)
|
||||
QString getImageFileFormat(const QString &path)
|
||||
{
|
||||
static QStringList listOfImageFormats = {".png", ".jpg", ".jpeg"};
|
||||
for (const QString &format : listOfImageFormats)
|
||||
@@ -49,8 +49,8 @@ std::queue<RawImageData> uploadQueue;
|
||||
void uploadImageToNuuls(RawImageData imageData, ChannelPtr channel,
|
||||
ResizingTextEdit &textEdit)
|
||||
{
|
||||
const char *boundary = "thisistheboudaryasd";
|
||||
QString contentType =
|
||||
const static char *boundary = "thisistheboudaryasd";
|
||||
const static QString contentType =
|
||||
QString("multipart/form-data; boundary=%1").arg(boundary);
|
||||
static QUrl url(Env::get().imageUploaderUrl);
|
||||
|
||||
@@ -86,12 +86,8 @@ void uploadImageToNuuls(RawImageData imageData, ChannelPtr channel,
|
||||
"wait until all of them are uploaded. About %2 "
|
||||
"seconds left.")
|
||||
.arg(uploadQueue.size(),
|
||||
uploadQueue.size() *
|
||||
(UPLOAD_DELAY / 1000 +
|
||||
1) // convert UPLOAD_DELAY to seconds
|
||||
)));
|
||||
// Argument number 2 is the ETA.
|
||||
// 2 seconds for the timer that's there not to spam Nuuls' server
|
||||
uploadQueue.size() * (UPLOAD_DELAY / 1000 + 1))));
|
||||
// 2 seconds for the timer that's there not to spam the remote server
|
||||
// and 1 second of actual uploading.
|
||||
|
||||
QTimer::singleShot(UPLOAD_DELAY, [channel, &textEdit]() {
|
||||
@@ -156,6 +152,7 @@ void upload(const QMimeData *source, ChannelPtr channel,
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage(QString("Couldn't load image :(")));
|
||||
isUploading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -183,6 +180,7 @@ void upload(const QMimeData *source, ChannelPtr channel,
|
||||
{
|
||||
channel->addMessage(
|
||||
makeSystemMessage(QString("Failed to open file. :(")));
|
||||
isUploading = false;
|
||||
return;
|
||||
}
|
||||
RawImageData data = {file.readAll(), "gif"};
|
||||
@@ -217,6 +215,7 @@ void upload(const QMimeData *source, ChannelPtr channel,
|
||||
{
|
||||
channel->addMessage(makeSystemMessage(
|
||||
QString("Cannot upload file, failed to convert to png.")));
|
||||
isUploading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ struct RawImageData {
|
||||
QByteArray data;
|
||||
QString format;
|
||||
};
|
||||
|
||||
void upload(QByteArray imageData, ChannelPtr channel,
|
||||
ResizingTextEdit &textEdit, std::string format);
|
||||
void upload(RawImageData imageData, ChannelPtr channel,
|
||||
|
||||
@@ -301,7 +301,7 @@ void ResizingTextEdit::dropEvent(QDropEvent *event)
|
||||
{
|
||||
this->imagePasted.invoke(event->mimeData());
|
||||
}
|
||||
else // allow for previous functionality of dropping text.
|
||||
else
|
||||
{
|
||||
QTextEdit::dropEvent(event);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user