feat: add exteraGram plugins basic info box

This commit is contained in:
AlexeyZavar
2026-01-28 00:27:28 +03:00
parent 92bb0910c0
commit c91baa5179
6 changed files with 584 additions and 1 deletions
@@ -36,6 +36,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtCore/QMimeType>
#include <QtCore/QMimeDatabase>
// AyuGram includes
#include "ayu/ui/boxes/plugin_info_box.h"
#include <QtCore/QFile>
namespace Data {
namespace {
@@ -239,6 +244,34 @@ void ResolveDocument(
}
return false;
};
const auto openPluginInfo = [&] {
// image size limit is fine too ig (64MB)
if (document->size >= Images::kReadBytesLimit) {
return false;
}
if (controller
&& document->filename().endsWith(
u".plugin"_q,
Qt::CaseInsensitive)
&& !document->filepath(true).isEmpty()) {
const auto path = document->location(true).name();
auto file = QFile(path);
if (file.open(QIODevice::ReadOnly)) {
const auto data = file.readAll();
file.close();
auto metadata = Ui::ParsePluginMetadata(data);
if (!metadata.id.isEmpty()
&& !metadata.name.isEmpty()) {
Ui::ShowPluginInfoBox(
controller,
path,
std::move(metadata));
return true;
}
}
}
return false;
};
const auto &location = document->location(true);
if (document->isTheme() && media->loaded(true)) {
showDocument();
@@ -259,7 +292,7 @@ void ResolveDocument(
}
} else {
document->saveFromDataSilent();
if (!openImageInApp()) {
if (!openPluginInfo() && !openImageInApp()) {
if (!document->filepath(true).isEmpty()) {
LaunchWithWarning(location.name(), item);
} else if (document->status == FileReady