mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-13 04:37:11 +02:00
feat: webview settings
This commit is contained in:
parent
dbb234097c
commit
27d3721646
7 changed files with 119 additions and 9 deletions
|
@ -5472,6 +5472,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ayu_ContextMenuElementsHeader" = "Context Menu Elements";
|
||||
"ayu_DrawerElementsHeader" = "Drawer Elements";
|
||||
"ayu_TrayElementsHeader" = "Tray Elements";
|
||||
"ayu_SettingsSpoofWebviewAsAndroid" = "Spoof Client as Android";
|
||||
"ayu_SettingsBiggerWindow" = "Bigger Window";
|
||||
"ayu_SettingsIncreaseWebviewHeight" = "Increase Content Height";
|
||||
"ayu_SettingsIncreaseWebviewWidth" = "Increase Content Width";
|
||||
"ayu_ExportDataTitle" = "Export AyuGram Database?";
|
||||
"ayu_ExportDataDescription" = "It will be exported to the public folder, to Saved Attachments.";
|
||||
"ayu_ExportDataConfirm" = "Yes, export";
|
||||
|
@ -5667,10 +5671,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"ayu_MessageShotShowReactions" = "Show reactions";
|
||||
"ayu_MessageShotShowColorfulReplies" = "Show colorful replies";
|
||||
"ayu_SendAsSticker" = "Send as Sticker";
|
||||
"ayu_AyuForwardStatusForwarding" = "Forwarding messages…";
|
||||
"ayu_AyuForwardStatusLoadingMedia" = "Loading media…";
|
||||
"ayu_AyuForwardForwardingDescription" = "Please keep this window open while AyuGram is forwarding your messages.";
|
||||
"ayu_AyuForwardLoadingMediaDescription" = "Please keep this window open while AyuGram is downloading media from your messages.";
|
||||
"ayu_AyuForwardStatusPreparing" = "Forwarding messages";
|
||||
"ayu_AyuForwardStatusLoadingMedia" = "Loading media";
|
||||
"ayu_AyuForwardStatusForwarding" = "Forwarding messages";
|
||||
"ayu_AyuForwardStatusFinished" = "Done";
|
||||
"ayu_AyuForwardStatusSentCount" = "sent %1$d of %2$d";
|
||||
"ayu_AyuForwardStatusChunkCount" = "chunk %1$d of %2$d";
|
||||
"ayu_ExpireMediaContextMenuText" = "Burn";
|
||||
"ayu_ExpiringVoiceMessageNote" = "This voice message can be played as many times as you want.";
|
||||
"ayu_ExpiringVideoMessageNote" = "This video message can be played as many times as you want.";
|
||||
|
|
|
@ -214,6 +214,10 @@ AyuGramSettings::AyuGramSettings() {
|
|||
collapseSimilarChannels = true;
|
||||
hideSimilarChannels = false;
|
||||
|
||||
spoofWebviewAsAndroid = false;
|
||||
increaseWebviewHeight = false;
|
||||
increaseWebviewWidth = false;
|
||||
|
||||
disableNotificationsDelay = false;
|
||||
localPremium = false;
|
||||
|
||||
|
@ -341,6 +345,18 @@ void AyuGramSettings::set_hideSimilarChannels(bool val) {
|
|||
hideSimilarChannels = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_spoofWebviewAsAndroid(bool val) {
|
||||
spoofWebviewAsAndroid = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_increaseWebviewHeight(bool val) {
|
||||
increaseWebviewHeight = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_increaseWebviewWidth(bool val) {
|
||||
increaseWebviewWidth = val;
|
||||
}
|
||||
|
||||
void AyuGramSettings::set_disableNotificationsDelay(bool val) {
|
||||
disableNotificationsDelay = val;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,10 @@ public:
|
|||
bool collapseSimilarChannels;
|
||||
bool hideSimilarChannels;
|
||||
|
||||
bool spoofWebviewAsAndroid;
|
||||
bool increaseWebviewHeight;
|
||||
bool increaseWebviewWidth;
|
||||
|
||||
bool disableNotificationsDelay;
|
||||
bool localPremium;
|
||||
|
||||
|
@ -95,6 +99,10 @@ public:
|
|||
void set_collapseSimilarChannels(bool val);
|
||||
void set_hideSimilarChannels(bool val);
|
||||
|
||||
void set_spoofWebviewAsAndroid(bool val);
|
||||
void set_increaseWebviewHeight(bool val);
|
||||
void set_increaseWebviewWidth(bool val);
|
||||
|
||||
void set_disableNotificationsDelay(bool val);
|
||||
void set_localPremium(bool val);
|
||||
|
||||
|
@ -149,6 +157,9 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
|
|||
disableCustomBackgrounds,
|
||||
collapseSimilarChannels,
|
||||
hideSimilarChannels,
|
||||
spoofWebviewAsAndroid,
|
||||
increaseWebviewHeight,
|
||||
increaseWebviewWidth,
|
||||
disableNotificationsDelay,
|
||||
localPremium,
|
||||
appIcon,
|
||||
|
|
|
@ -27,6 +27,9 @@ recentStickersLimitPadding: margins(22px, 4px, 22px, 8px);
|
|||
imageViewPadding: margins(22px, 10px, 22px, 10px);
|
||||
imageViewInnerPadding: margins(16px, 16px, 16px, 16px);
|
||||
|
||||
botWebViewPanelHeightIncreased: 782px;
|
||||
botWebViewPanelWidthIncreased: 512px;
|
||||
|
||||
stickerRoundingSize: 5px;
|
||||
|
||||
messageShotPadding: 4px;
|
||||
|
|
|
@ -1249,6 +1249,50 @@ void SetupNerdSettings(not_null<Ui::VerticalLayout*> container, not_null<Window:
|
|||
container->lifetime());
|
||||
}
|
||||
|
||||
void SetupWebviewSettings(not_null<Ui::VerticalLayout*> container) {
|
||||
auto settings = &AyuSettings::getInstance();
|
||||
|
||||
AddSubsectionTitle(container, rpl::single(QString("Webview")));
|
||||
|
||||
AddButtonWithIcon(
|
||||
container,
|
||||
tr::ayu_SettingsSpoofWebviewAsAndroid(),
|
||||
st::settingsButtonNoIcon
|
||||
)->toggleOn(
|
||||
rpl::single(settings->spoofWebviewAsAndroid)
|
||||
)->toggledValue(
|
||||
) | rpl::filter(
|
||||
[=](bool enabled)
|
||||
{
|
||||
return (enabled != settings->spoofWebviewAsAndroid);
|
||||
}) | start_with_next(
|
||||
[=](bool enabled)
|
||||
{
|
||||
settings->set_spoofWebviewAsAndroid(enabled);
|
||||
AyuSettings::save();
|
||||
},
|
||||
container->lifetime());
|
||||
|
||||
std::vector checkboxes = {
|
||||
NestedEntry{
|
||||
tr::ayu_SettingsIncreaseWebviewHeight(tr::now), settings->increaseWebviewHeight, [=](bool enabled)
|
||||
{
|
||||
settings->set_increaseWebviewHeight(enabled);
|
||||
AyuSettings::save();
|
||||
}
|
||||
},
|
||||
NestedEntry{
|
||||
tr::ayu_SettingsIncreaseWebviewWidth(tr::now), settings->increaseWebviewWidth, [=](bool enabled)
|
||||
{
|
||||
settings->set_increaseWebviewWidth(enabled);
|
||||
AyuSettings::save();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AddCollapsibleToggle(container, tr::ayu_SettingsBiggerWindow(), checkboxes, false);
|
||||
}
|
||||
|
||||
void SetupCustomization(not_null<Ui::VerticalLayout*> container,
|
||||
not_null<Window::SessionController*> controller) {
|
||||
AddSubsectionTitle(container, tr::ayu_CustomizationHeader());
|
||||
|
@ -1318,6 +1362,12 @@ void SetupAyuGramSettings(not_null<Ui::VerticalLayout*> container,
|
|||
AddSkip(container);
|
||||
AddDividerText(container, tr::ayu_SettingsCustomizationHint());
|
||||
|
||||
AddSkip(container);
|
||||
SetupWebviewSettings(container);
|
||||
AddSkip(container);
|
||||
|
||||
AddDivider(container);
|
||||
|
||||
AddSkip(container);
|
||||
SetupSendConfirmations(container);
|
||||
AddSkip(container);
|
||||
|
|
|
@ -59,6 +59,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <QSvgRenderer>
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
|
||||
|
||||
namespace InlineBots {
|
||||
namespace {
|
||||
|
||||
|
@ -431,6 +435,11 @@ void BotAction::handleKeyPress(not_null<QKeyEvent*> e) {
|
|||
}
|
||||
}
|
||||
|
||||
QString WebviewPlatform() {
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
return settings->spoofWebviewAsAndroid ? "android" : "tdesktop";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
MenuBotIcon::MenuBotIcon(
|
||||
|
@ -901,7 +910,7 @@ void AttachWebView::request(const WebViewButton &button) {
|
|||
MTP_bytes(button.url),
|
||||
MTP_string(_startCommand),
|
||||
MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams().json)),
|
||||
MTP_string("tdesktop"),
|
||||
MTP_string(WebviewPlatform()),
|
||||
action.mtpReplyTo(),
|
||||
(action.options.sendAs
|
||||
? action.options.sendAs->input
|
||||
|
@ -1222,7 +1231,7 @@ void AttachWebView::requestSimple(const WebViewButton &button) {
|
|||
MTP_bytes(button.url),
|
||||
MTP_string(button.startCommand),
|
||||
MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams().json)),
|
||||
MTP_string("tdesktop")
|
||||
MTP_string(WebviewPlatform())
|
||||
)).done([=](const MTPWebViewResult &result) {
|
||||
_requestId = 0;
|
||||
const auto &data = result.data();
|
||||
|
@ -1300,7 +1309,7 @@ void AttachWebView::requestMenu(
|
|||
MTP_string(url),
|
||||
MTPstring(), // start_param
|
||||
MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams().json)),
|
||||
MTP_string("tdesktop"),
|
||||
MTP_string(WebviewPlatform()),
|
||||
action.mtpReplyTo(),
|
||||
(action.options.sendAs
|
||||
? action.options.sendAs->input
|
||||
|
@ -1430,7 +1439,7 @@ void AttachWebView::requestAppView(bool allowWrite) {
|
|||
MTP_inputBotAppID(MTP_long(app->id), MTP_long(app->accessHash)),
|
||||
MTP_string(_startCommand),
|
||||
MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams().json)),
|
||||
MTP_string("tdesktop")
|
||||
MTP_string(WebviewPlatform())
|
||||
)).done([=](const MTPWebViewResult &result) {
|
||||
_requestId = 0;
|
||||
const auto &data = result.data();
|
||||
|
|
|
@ -35,6 +35,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QClipboard>
|
||||
|
||||
// AyuGram includes
|
||||
#include "ayu/ayu_settings.h"
|
||||
#include "styles/style_ayu_styles.h"
|
||||
|
||||
|
||||
namespace Ui::BotWebView {
|
||||
namespace {
|
||||
|
||||
|
@ -324,7 +329,17 @@ Panel::Panel(
|
|||
, _widget(std::make_unique<SeparatePanel>())
|
||||
, _allowClipboardRead(allowClipboardRead) {
|
||||
_widget->setWindowFlag(Qt::WindowStaysOnTopHint, false);
|
||||
_widget->setInnerSize(st::botWebViewPanelSize);
|
||||
|
||||
const auto settings = &AyuSettings::getInstance();
|
||||
auto size = QSize(st::botWebViewPanelSize);
|
||||
if (settings->increaseWebviewHeight) {
|
||||
size.setHeight(st::botWebViewPanelHeightIncreased);
|
||||
}
|
||||
if (settings->increaseWebviewWidth) {
|
||||
size.setWidth(st::botWebViewPanelWidthIncreased);
|
||||
}
|
||||
|
||||
_widget->setInnerSize(size);
|
||||
|
||||
_widget->closeRequests(
|
||||
) | rpl::start_with_next([=] {
|
||||
|
|
Loading…
Add table
Reference in a new issue