mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 11:28:49 +03:00
Merge 50cdcc0376
into 1a00d91316
This commit is contained in:
commit
e6153b03d4
2 changed files with 48 additions and 11 deletions
|
@ -391,6 +391,9 @@ InputBar::send()
|
||||||
{
|
{
|
||||||
QInputMethod *im = QGuiApplication::inputMethod();
|
QInputMethod *im = QGuiApplication::inputMethod();
|
||||||
im->commit();
|
im->commit();
|
||||||
|
// If the input from the UI is only blanks or no text, this trigger should
|
||||||
|
// be used to confirm media upload. If that is not the case however, but
|
||||||
|
// but there are pending uploads, we fall into one of the cases seen later.
|
||||||
if (text().trimmed().isEmpty()) {
|
if (text().trimmed().isEmpty()) {
|
||||||
acceptUploads();
|
acceptUploads();
|
||||||
return;
|
return;
|
||||||
|
@ -404,8 +407,18 @@ InputBar::send()
|
||||||
updateTextContentProperties(text());
|
updateTextContentProperties(text());
|
||||||
if (containsIncompleteCommand_)
|
if (containsIncompleteCommand_)
|
||||||
return;
|
return;
|
||||||
if (commandName.isEmpty() || !command(commandName, args))
|
if (unconfirmedUploads.empty()) {
|
||||||
message(text());
|
if (commandName.isEmpty() || !command(commandName, args)) {
|
||||||
|
message(text());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (commandName.isEmpty()) {
|
||||||
|
// This is a set of uploads with text
|
||||||
|
acceptUploadsWithCaption(text());
|
||||||
|
} else if (!command(commandName, args)) {
|
||||||
|
message(text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!wasEdit) {
|
if (!wasEdit) {
|
||||||
history_.push_front(QLatin1String(""));
|
history_.push_front(QLatin1String(""));
|
||||||
|
@ -718,6 +731,7 @@ void
|
||||||
InputBar::image(const QString &filename,
|
InputBar::image(const QString &filename,
|
||||||
const std::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
|
const std::optional<QString> &caption,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize,
|
uint64_t dsize,
|
||||||
const QSize &dimensions,
|
const QSize &dimensions,
|
||||||
|
@ -731,9 +745,10 @@ InputBar::image(const QString &filename,
|
||||||
image.info.mimetype = mime.toStdString();
|
image.info.mimetype = mime.toStdString();
|
||||||
image.info.size = dsize;
|
image.info.size = dsize;
|
||||||
image.info.blurhash = blurhash.toStdString();
|
image.info.blurhash = blurhash.toStdString();
|
||||||
image.body = filename.toStdString();
|
// Depending on the input bar's situation, retrieve the text
|
||||||
image.info.h = dimensions.height();
|
image.body = caption.has_value() ? caption.value().toStdString() : filename.toStdString();
|
||||||
image.info.w = dimensions.width();
|
image.info.h = dimensions.height();
|
||||||
|
image.info.w = dimensions.width();
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
image.file = file;
|
image.file = file;
|
||||||
|
@ -762,13 +777,14 @@ void
|
||||||
InputBar::file(const QString &filename,
|
InputBar::file(const QString &filename,
|
||||||
const std::optional<mtx::crypto::EncryptedFile> &encryptedFile,
|
const std::optional<mtx::crypto::EncryptedFile> &encryptedFile,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
|
const std::optional<QString> &caption,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize)
|
uint64_t dsize)
|
||||||
{
|
{
|
||||||
mtx::events::msg::File file;
|
mtx::events::msg::File file;
|
||||||
file.info.mimetype = mime.toStdString();
|
file.info.mimetype = mime.toStdString();
|
||||||
file.info.size = dsize;
|
file.info.size = dsize;
|
||||||
file.body = filename.toStdString();
|
file.body = caption.has_value() ? caption.value().toStdString() : filename.toStdString();
|
||||||
|
|
||||||
if (encryptedFile)
|
if (encryptedFile)
|
||||||
file.file = encryptedFile;
|
file.file = encryptedFile;
|
||||||
|
@ -785,6 +801,7 @@ void
|
||||||
InputBar::audio(const QString &filename,
|
InputBar::audio(const QString &filename,
|
||||||
const std::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
|
const std::optional<QString> &caption,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize,
|
uint64_t dsize,
|
||||||
uint64_t duration)
|
uint64_t duration)
|
||||||
|
@ -792,8 +809,8 @@ InputBar::audio(const QString &filename,
|
||||||
mtx::events::msg::Audio audio;
|
mtx::events::msg::Audio audio;
|
||||||
audio.info.mimetype = mime.toStdString();
|
audio.info.mimetype = mime.toStdString();
|
||||||
audio.info.size = dsize;
|
audio.info.size = dsize;
|
||||||
audio.body = filename.toStdString();
|
audio.body = caption.has_value() ? caption.value().toStdString() : filename.toStdString();
|
||||||
audio.url = url.toStdString();
|
audio.url = url.toStdString();
|
||||||
|
|
||||||
if (duration > 0)
|
if (duration > 0)
|
||||||
audio.info.duration = duration;
|
audio.info.duration = duration;
|
||||||
|
@ -813,6 +830,7 @@ void
|
||||||
InputBar::video(const QString &filename,
|
InputBar::video(const QString &filename,
|
||||||
const std::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
|
const std::optional<QString> &caption,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize,
|
uint64_t dsize,
|
||||||
uint64_t duration,
|
uint64_t duration,
|
||||||
|
@ -827,7 +845,7 @@ InputBar::video(const QString &filename,
|
||||||
video.info.mimetype = mime.toStdString();
|
video.info.mimetype = mime.toStdString();
|
||||||
video.info.size = dsize;
|
video.info.size = dsize;
|
||||||
video.info.blurhash = blurhash.toStdString();
|
video.info.blurhash = blurhash.toStdString();
|
||||||
video.body = filename.toStdString();
|
video.body = caption.has_value() ? caption.value().toStdString() : filename.toStdString();
|
||||||
|
|
||||||
if (duration > 0)
|
if (duration > 0)
|
||||||
video.info.duration = duration;
|
video.info.duration = duration;
|
||||||
|
@ -1299,10 +1317,12 @@ InputBar::finalizeUpload(MediaUpload *upload, const QString &url)
|
||||||
auto mimeClass = upload->mimeClass();
|
auto mimeClass = upload->mimeClass();
|
||||||
auto size = upload->size();
|
auto size = upload->size();
|
||||||
auto encryptedFile = upload->encryptedFile_();
|
auto encryptedFile = upload->encryptedFile_();
|
||||||
|
auto caption = upload->caption();
|
||||||
if (mimeClass == u"image")
|
if (mimeClass == u"image")
|
||||||
image(filename,
|
image(filename,
|
||||||
encryptedFile,
|
encryptedFile,
|
||||||
url,
|
url,
|
||||||
|
caption,
|
||||||
mime,
|
mime,
|
||||||
size,
|
size,
|
||||||
upload->dimensions(),
|
upload->dimensions(),
|
||||||
|
@ -1312,11 +1332,12 @@ InputBar::finalizeUpload(MediaUpload *upload, const QString &url)
|
||||||
upload->thumbnailImg().size(),
|
upload->thumbnailImg().size(),
|
||||||
upload->blurhash());
|
upload->blurhash());
|
||||||
else if (mimeClass == u"audio")
|
else if (mimeClass == u"audio")
|
||||||
audio(filename, encryptedFile, url, mime, size, upload->duration());
|
audio(filename, encryptedFile, url, caption, mime, size, upload->duration());
|
||||||
else if (mimeClass == u"video")
|
else if (mimeClass == u"video")
|
||||||
video(filename,
|
video(filename,
|
||||||
encryptedFile,
|
encryptedFile,
|
||||||
url,
|
url,
|
||||||
|
caption,
|
||||||
mime,
|
mime,
|
||||||
size,
|
size,
|
||||||
upload->duration(),
|
upload->duration(),
|
||||||
|
@ -1327,7 +1348,7 @@ InputBar::finalizeUpload(MediaUpload *upload, const QString &url)
|
||||||
upload->thumbnailImg().size(),
|
upload->thumbnailImg().size(),
|
||||||
upload->blurhash());
|
upload->blurhash());
|
||||||
else
|
else
|
||||||
file(filename, encryptedFile, url, mime, size);
|
file(filename, encryptedFile, url, caption, mime, size);
|
||||||
|
|
||||||
removeRunUpload(upload);
|
removeRunUpload(upload);
|
||||||
}
|
}
|
||||||
|
@ -1422,6 +1443,15 @@ InputBar::acceptUploads()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
InputBar::acceptUploadsWithCaption(QString caption)
|
||||||
|
{
|
||||||
|
for (UploadHandle &upload : unconfirmedUploads) {
|
||||||
|
upload->caption_ = std::optional(caption);
|
||||||
|
}
|
||||||
|
acceptUploads();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
InputBar::declineUploads()
|
InputBar::declineUploads()
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
return MediaType::File;
|
return MediaType::File;
|
||||||
}
|
}
|
||||||
[[nodiscard]] QString url() const { return url_; }
|
[[nodiscard]] QString url() const { return url_; }
|
||||||
|
[[nodiscard]] std::optional<QString> caption() const { return caption_; }
|
||||||
[[nodiscard]] QString mimetype() const { return mimetype_; }
|
[[nodiscard]] QString mimetype() const { return mimetype_; }
|
||||||
[[nodiscard]] QString mimeClass() const { return mimeClass_; }
|
[[nodiscard]] QString mimeClass() const { return mimeClass_; }
|
||||||
[[nodiscard]] QString filename() const { return originalFilename_; }
|
[[nodiscard]] QString filename() const { return originalFilename_; }
|
||||||
|
@ -143,6 +144,7 @@ public:
|
||||||
QString blurhash_;
|
QString blurhash_;
|
||||||
QString thumbnailUrl_;
|
QString thumbnailUrl_;
|
||||||
QString url_;
|
QString url_;
|
||||||
|
std::optional<QString> caption_;
|
||||||
std::optional<mtx::crypto::EncryptedFile> encryptedFile, thumbnailEncryptedFile;
|
std::optional<mtx::crypto::EncryptedFile> encryptedFile, thumbnailEncryptedFile;
|
||||||
|
|
||||||
QImage thumbnail_;
|
QImage thumbnail_;
|
||||||
|
@ -241,6 +243,7 @@ public slots:
|
||||||
void sticker(QStringList descriptor);
|
void sticker(QStringList descriptor);
|
||||||
|
|
||||||
void acceptUploads();
|
void acceptUploads();
|
||||||
|
void acceptUploadsWithCaption(QString);
|
||||||
void declineUploads();
|
void declineUploads();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -269,6 +272,7 @@ private:
|
||||||
void image(const QString &filename,
|
void image(const QString &filename,
|
||||||
const std::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
|
const std::optional<QString> &caption,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize,
|
uint64_t dsize,
|
||||||
const QSize &dimensions,
|
const QSize &dimensions,
|
||||||
|
@ -280,17 +284,20 @@ private:
|
||||||
void file(const QString &filename,
|
void file(const QString &filename,
|
||||||
const std::optional<mtx::crypto::EncryptedFile> &encryptedFile,
|
const std::optional<mtx::crypto::EncryptedFile> &encryptedFile,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
|
const std::optional<QString> &caption,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize);
|
uint64_t dsize);
|
||||||
void audio(const QString &filename,
|
void audio(const QString &filename,
|
||||||
const std::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
|
const std::optional<QString> &caption,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize,
|
uint64_t dsize,
|
||||||
uint64_t duration);
|
uint64_t duration);
|
||||||
void video(const QString &filename,
|
void video(const QString &filename,
|
||||||
const std::optional<mtx::crypto::EncryptedFile> &file,
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
|
const std::optional<QString> &caption,
|
||||||
const QString &mime,
|
const QString &mime,
|
||||||
uint64_t dsize,
|
uint64_t dsize,
|
||||||
uint64_t duration,
|
uint64_t duration,
|
||||||
|
|
Loading…
Reference in a new issue