mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
feat: add exteraGram plugins basic info box
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user