@@ -74,6 +74,9 @@ void ImagePackEventContent::fillJson(QJsonObject *o) const
|
|||||||
}
|
}
|
||||||
imageJson["usage"_ls] = usageJson;
|
imageJson["usage"_ls] = usageJson;
|
||||||
}
|
}
|
||||||
|
if (image.info.has_value()) {
|
||||||
|
imageJson["info"_ls] = Quotient::EventContent::toInfoJson(*image.info);
|
||||||
|
}
|
||||||
imagesJson[image.shortcode] = imageJson;
|
imagesJson[image.shortcode] = imageJson;
|
||||||
}
|
}
|
||||||
(*o)["images"_ls] = imagesJson;
|
(*o)["images"_ls] = imagesJson;
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
|
|
||||||
#include "accountemoticonmodel.h"
|
#include "accountemoticonmodel.h"
|
||||||
|
|
||||||
|
#include <QImage>
|
||||||
|
#include <QMimeDatabase>
|
||||||
|
|
||||||
#include <Quotient/csapi/content-repo.h>
|
#include <Quotient/csapi/content-repo.h>
|
||||||
|
#include <Quotient/events/eventcontent.h>
|
||||||
#include <qcoro/qcorosignal.h>
|
#include <qcoro/qcorosignal.h>
|
||||||
|
|
||||||
using namespace Quotient;
|
using namespace Quotient;
|
||||||
@@ -162,7 +166,15 @@ QCoro::Task<void> AccountEmoticonModel::doSetEmoticonImage(int index, QUrl sourc
|
|||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
m_images->images[index].url = job->contentUri();
|
m_images->images[index].url = job->contentUri();
|
||||||
m_images->images[index].info = none;
|
auto mime = QMimeDatabase().mimeTypeForUrl(source);
|
||||||
|
source.setScheme("file"_ls);
|
||||||
|
QFileInfo fileInfo(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
||||||
|
EventContent::ImageInfo info;
|
||||||
|
if (mime.name().startsWith("image/"_ls)) {
|
||||||
|
QImage image(source.toLocalFile());
|
||||||
|
info = EventContent::ImageInfo(source, fileInfo.size(), mime, image.size(), fileInfo.fileName());
|
||||||
|
}
|
||||||
|
m_images->images[index].info = info;
|
||||||
QJsonObject data;
|
QJsonObject data;
|
||||||
m_images->fillJson(&data);
|
m_images->fillJson(&data);
|
||||||
m_connection->setAccountData("im.ponies.user_emotes"_ls, data);
|
m_connection->setAccountData("im.ponies.user_emotes"_ls, data);
|
||||||
@@ -175,11 +187,21 @@ QCoro::Task<void> AccountEmoticonModel::doAddEmoticon(QUrl source, QString short
|
|||||||
if (job->error() != BaseJob::NoError) {
|
if (job->error() != BaseJob::NoError) {
|
||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto mime = QMimeDatabase().mimeTypeForUrl(source);
|
||||||
|
source.setScheme("file"_ls);
|
||||||
|
QFileInfo fileInfo(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
||||||
|
EventContent::ImageInfo info;
|
||||||
|
if (mime.name().startsWith("image/"_ls)) {
|
||||||
|
QImage image(source.toLocalFile());
|
||||||
|
info = EventContent::ImageInfo(source, fileInfo.size(), mime, image.size(), fileInfo.fileName());
|
||||||
|
}
|
||||||
|
|
||||||
m_images->images.append(ImagePackEventContent::ImagePackImage{
|
m_images->images.append(ImagePackEventContent::ImagePackImage{
|
||||||
shortcode,
|
shortcode,
|
||||||
job->contentUri(),
|
job->contentUri(),
|
||||||
description,
|
description,
|
||||||
none,
|
info,
|
||||||
QStringList{type},
|
QStringList{type},
|
||||||
});
|
});
|
||||||
QJsonObject data;
|
QJsonObject data;
|
||||||
|
|||||||
Reference in New Issue
Block a user