mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Proof-of-concept custom scheme in WKWebView.
This commit is contained in:
parent
125f856e67
commit
6d733bb566
4 changed files with 8 additions and 10 deletions
|
@ -3509,10 +3509,10 @@ void Session::webpageApplyFields(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (const auto page = data.vcached_page()) {
|
if (const auto page = data.vcached_page()) {
|
||||||
for (const auto photo : page->data().vphotos().v) {
|
for (const auto &photo : page->data().vphotos().v) {
|
||||||
processPhoto(photo);
|
processPhoto(photo);
|
||||||
}
|
}
|
||||||
for (const auto document : page->data().vdocuments().v) {
|
for (const auto &document : page->data().vdocuments().v) {
|
||||||
processDocument(document);
|
processDocument(document);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/history_item_helpers.h"
|
#include "history/history_item_helpers.h"
|
||||||
#include "history/history_unread_things.h"
|
#include "history/history_unread_things.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
|
#include "iv/iv_data.h"
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/text/text_isolated_emoji.h"
|
#include "ui/text/text_isolated_emoji.h"
|
||||||
|
@ -668,6 +669,7 @@ HistoryItem::HistoryItem(
|
||||||
: nullptr),
|
: nullptr),
|
||||||
nullptr,
|
nullptr,
|
||||||
WebPageCollage(),
|
WebPageCollage(),
|
||||||
|
nullptr,
|
||||||
0,
|
0,
|
||||||
QString(),
|
QString(),
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -29,7 +29,7 @@ void Controller::show(const QString &dataPath, Prepared page) {
|
||||||
_window = std::make_unique<Ui::RpWindow>();
|
_window = std::make_unique<Ui::RpWindow>();
|
||||||
const auto window = _window.get();
|
const auto window = _window.get();
|
||||||
|
|
||||||
window->setGeometry({ 200, 200, 800, 600 });
|
window->setGeometry({ 200, 200, 600, 800 });
|
||||||
|
|
||||||
const auto container = Ui::CreateChild<Ui::RpWidget>(
|
const auto container = Ui::CreateChild<Ui::RpWidget>(
|
||||||
window->body().get());
|
window->body().get());
|
||||||
|
|
|
@ -132,13 +132,11 @@ private:
|
||||||
|
|
||||||
const Options _options;
|
const Options _options;
|
||||||
|
|
||||||
const QByteArray _resourcePrefix;
|
|
||||||
base::flat_set<QByteArray> _resources;
|
base::flat_set<QByteArray> _resources;
|
||||||
|
|
||||||
Prepared _result;
|
Prepared _result;
|
||||||
|
|
||||||
bool _rtl = false;
|
bool _rtl = false;
|
||||||
bool _imageAsBackground = false;
|
|
||||||
bool _captionAsTitle = false;
|
bool _captionAsTitle = false;
|
||||||
bool _captionWrapped = false;
|
bool _captionWrapped = false;
|
||||||
base::flat_map<uint64, Photo> _photosById;
|
base::flat_map<uint64, Photo> _photosById;
|
||||||
|
@ -171,9 +169,6 @@ private:
|
||||||
|
|
||||||
Parser::Parser(const Source &source, const Options &options)
|
Parser::Parser(const Source &source, const Options &options)
|
||||||
: _options(options)
|
: _options(options)
|
||||||
, _resourcePrefix(options.saveToFolder.isEmpty()
|
|
||||||
? "http://desktop-app-resource/"
|
|
||||||
: QByteArray())
|
|
||||||
, _rtl(source.page.data().is_rtl()) {
|
, _rtl(source.page.data().is_rtl()) {
|
||||||
process(source);
|
process(source);
|
||||||
_result.html = prepare(page(source.page.data()));
|
_result.html = prepare(page(source.page.data()));
|
||||||
|
@ -968,10 +963,11 @@ QByteArray Parser::mapUrl(const Geo &geo, int width, int height, int zoom) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Parser::resource(QByteArray id) {
|
QByteArray Parser::resource(QByteArray id) {
|
||||||
if (!_options.saveToFolder.isEmpty() && _resources.emplace(id).second) {
|
const auto toFolder = !_options.saveToFolder.isEmpty();
|
||||||
|
if (toFolder && _resources.emplace(id).second) {
|
||||||
_result.resources.push_back(id);
|
_result.resources.push_back(id);
|
||||||
}
|
}
|
||||||
return _resourcePrefix + id;
|
return toFolder ? id : ('/' + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Parser::page(const MTPDpage &data) {
|
QByteArray Parser::page(const MTPDpage &data) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue