mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Replaced confirmation box for proxy links with generic box.
This commit is contained in:
parent
233e80d22d
commit
d9572949f6
3 changed files with 53 additions and 26 deletions
|
@ -304,6 +304,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_sure_ban_admin" = "This user is an admin. Are you sure you want to go ahead and restrict them?";
|
"lng_sure_ban_admin" = "This user is an admin. Are you sure you want to go ahead and restrict them?";
|
||||||
"lng_sure_enable_socks" = "Are you sure you want to enable this proxy?\n\nServer: {server}\nPort: {port}\n\nYou can change your proxy server later in the Settings (Connection Type).";
|
"lng_sure_enable_socks" = "Are you sure you want to enable this proxy?\n\nServer: {server}\nPort: {port}\n\nYou can change your proxy server later in the Settings (Connection Type).";
|
||||||
"lng_sure_enable" = "Enable";
|
"lng_sure_enable" = "Enable";
|
||||||
|
"lng_proxy_box_title" = "Enable proxy";
|
||||||
|
"lng_proxy_box_server" = "Server";
|
||||||
|
"lng_proxy_box_port" = "Port";
|
||||||
|
"lng_proxy_box_secret" = "Secret";
|
||||||
|
"lng_proxy_box_status" = "Status";
|
||||||
|
"lng_proxy_box_username" = "Username";
|
||||||
|
"lng_proxy_box_password" = "Password";
|
||||||
"lng_proxy_invalid" = "The proxy link is invalid.";
|
"lng_proxy_invalid" = "The proxy link is invalid.";
|
||||||
"lng_proxy_unsupported" = "Your Telegram Desktop version doesn't support this proxy type or the proxy link is invalid. Please update Telegram Desktop to the latest version.";
|
"lng_proxy_unsupported" = "Your Telegram Desktop version doesn't support this proxy type or the proxy link is invalid. Please update Telegram Desktop to the latest version.";
|
||||||
|
|
||||||
|
|
|
@ -642,6 +642,10 @@ proxyDropdownUpPosition: point(-2px, 20px);
|
||||||
proxyAboutPadding: margins(22px, 7px, 22px, 14px);
|
proxyAboutPadding: margins(22px, 7px, 22px, 14px);
|
||||||
proxyAboutSponsorPadding: margins(22px, 7px, 22px, 0px);
|
proxyAboutSponsorPadding: margins(22px, 7px, 22px, 0px);
|
||||||
|
|
||||||
|
proxyApplyBoxLabel : FlatLabel(defaultFlatLabel) {
|
||||||
|
maxHeight: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
markdownLinkFieldPadding: margins(22px, 0px, 22px, 10px);
|
markdownLinkFieldPadding: margins(22px, 0px, 22px, 10px);
|
||||||
|
|
||||||
termsContent: FlatLabel(defaultFlatLabel) {
|
termsContent: FlatLabel(defaultFlatLabel) {
|
||||||
|
|
|
@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/qthelp_regex.h"
|
#include "base/qthelp_regex.h"
|
||||||
#include "base/qthelp_url.h"
|
#include "base/qthelp_url.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/click_handler_types.h"
|
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
#include "core/local_url_handlers.h"
|
#include "core/local_url_handlers.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -36,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
#include "ui/vertical_list.h"
|
||||||
#include "boxes/abstract_box.h" // Ui::show().
|
#include "boxes/abstract_box.h" // Ui::show().
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
|
@ -1220,35 +1220,51 @@ void ProxiesBoxController::ShowApplyConfirmation(
|
||||||
UrlStartRegExp,
|
UrlStartRegExp,
|
||||||
QString()
|
QString()
|
||||||
).replace(UrlEndRegExp, QString());
|
).replace(UrlEndRegExp, QString());
|
||||||
const auto text = tr::lng_sure_enable_socks(
|
const auto box = [=](not_null<Ui::GenericBox*> box) {
|
||||||
tr::now,
|
box->setTitle(tr::lng_proxy_box_title());
|
||||||
lt_server,
|
if (type == Type::Mtproto) {
|
||||||
displayServer,
|
box->addRow(object_ptr<Ui::FlatLabel>(
|
||||||
lt_port,
|
box,
|
||||||
QString::number(proxy.port))
|
tr::lng_proxy_sponsor_warning(),
|
||||||
+ (proxy.type == Type::Mtproto
|
st::boxDividerLabel));
|
||||||
? "\n\n" + tr::lng_proxy_sponsor_warning(tr::now)
|
Ui::AddSkip(box->verticalLayout());
|
||||||
: QString());
|
Ui::AddSkip(box->verticalLayout());
|
||||||
auto callback = [=](Fn<void()> &&close) {
|
|
||||||
auto &proxies = Core::App().settings().proxy().list();
|
|
||||||
if (!ranges::contains(proxies, proxy)) {
|
|
||||||
proxies.push_back(proxy);
|
|
||||||
}
|
}
|
||||||
Core::App().setCurrentProxy(
|
const auto &stL = st::proxyApplyBoxLabel;
|
||||||
proxy,
|
const auto &stSubL = st::boxDividerLabel;
|
||||||
ProxyData::Settings::Enabled);
|
const auto add = [&](const QString &s, tr::phrase<> phrase) {
|
||||||
Local::writeSettings();
|
if (!s.isEmpty()) {
|
||||||
close();
|
box->addRow(object_ptr<Ui::FlatLabel>(box, s, stL));
|
||||||
|
box->addRow(object_ptr<Ui::FlatLabel>(box, phrase(), stSubL));
|
||||||
|
Ui::AddSkip(box->verticalLayout());
|
||||||
|
Ui::AddSkip(box->verticalLayout());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (!displayServer.isEmpty()) {
|
||||||
|
add(displayServer, tr::lng_proxy_box_server);
|
||||||
|
}
|
||||||
|
add(QString::number(proxy.port), tr::lng_proxy_box_port);
|
||||||
|
if (type == Type::Socks5) {
|
||||||
|
add(proxy.user, tr::lng_proxy_box_username);
|
||||||
|
add(proxy.password, tr::lng_proxy_box_password);
|
||||||
|
} else if (type == Type::Mtproto) {
|
||||||
|
add(proxy.password, tr::lng_proxy_box_secret);
|
||||||
|
}
|
||||||
|
box->addButton(tr::lng_sure_enable(), [=] {
|
||||||
|
auto &proxies = Core::App().settings().proxy().list();
|
||||||
|
if (!ranges::contains(proxies, proxy)) {
|
||||||
|
proxies.push_back(proxy);
|
||||||
|
}
|
||||||
|
Core::App().setCurrentProxy(proxy, ProxyData::Settings::Enabled);
|
||||||
|
Local::writeSettings();
|
||||||
|
box->closeBox();
|
||||||
|
});
|
||||||
|
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||||
};
|
};
|
||||||
auto box = Ui::MakeConfirmBox({
|
|
||||||
.text = text,
|
|
||||||
.confirmed = std::move(callback),
|
|
||||||
.confirmText = tr::lng_sure_enable(),
|
|
||||||
});
|
|
||||||
if (controller) {
|
if (controller) {
|
||||||
controller->uiShow()->showBox(std::move(box));
|
controller->uiShow()->showBox(Box(box));
|
||||||
} else {
|
} else {
|
||||||
Ui::show(std::move(box));
|
Ui::show(Box(box));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue