mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 14:17:45 +00:00
Added network speed setting
This commit is contained in:
@@ -2259,6 +2259,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"ktg_settings_emoji_outline" = "Big emoji outline";
|
||||
"ktg_settings_always_show_scheduled" = "Always show scheduled";
|
||||
"ktg_settings_fonts" = "Change application fonts";
|
||||
"ktg_settings_network" = "Network";
|
||||
"ktg_settings_net_speed_boost" = "Speed boost";
|
||||
|
||||
"ktg_fonts_title" = "Fonts";
|
||||
"ktg_fonts_reset" = "Reset";
|
||||
@@ -2274,4 +2276,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
"ktg_fonts_restart" = "Restart";
|
||||
|
||||
"ktg_net_speed_boost_title" = "Network speed boost";
|
||||
"ktg_net_speed_boost_desc" = "Warning: changing this parameter to high values on slow networks can make even worse. Use at your own risk.\n\nYou'll need to restart app to save changes.";
|
||||
|
||||
"ktg_net_speed_boost_default" = "Disabled";
|
||||
"ktg_net_speed_boost_slight" = "Slight";
|
||||
"ktg_net_speed_boost_medium" = "Medium";
|
||||
"ktg_net_speed_boost_big" = "Big";
|
||||
|
||||
"ktg_net_boost_restart_desc" = "You'll need to restart app to change network boost.\n\nRestart now?";
|
||||
|
||||
// Keys finished
|
||||
|
@@ -33,6 +33,8 @@
|
||||
"ktg_settings_emoji_outline": "Обводка у больших эмодзи",
|
||||
"ktg_settings_always_show_scheduled": "Всегда показывать отложенные",
|
||||
"ktg_settings_fonts": "Изменить шрифты приложения",
|
||||
"ktg_settings_network": "Сеть",
|
||||
"ktg_settings_net_speed_boost": "Ускорение загрузки",
|
||||
"ktg_fonts_title": "Шрифты",
|
||||
"ktg_fonts_reset": "Сброс",
|
||||
"ktg_fonts_about": "Если вы хотите использовать жирное начертание для полужирного шрифта, не пишите «Bold» в названии, используйте настройку «Сделать полужирный жирным».\n\nДля применения и просмотра изменений требуется перезапуск.",
|
||||
@@ -42,5 +44,12 @@
|
||||
"ktg_fonts_monospaced": "Моноширинный шрифт",
|
||||
"ktg_fonts_restart_new_fonts": "Для применения новых шрифтов требуется перезапуск.\n\nПерезапустить сейчас?",
|
||||
"ktg_fonts_restart_reset": "Для сброса шрифтов к стандартным требуется перезапуск.\n\nПерезапустить сейчас?",
|
||||
"ktg_fonts_restart": "Перезапустить"
|
||||
"ktg_fonts_restart": "Перезапустить",
|
||||
"ktg_net_speed_boost_title": "Ускорение загрузки",
|
||||
"ktg_net_speed_boost_desc": "Внимание: высокие значения параметра при слабых сетях могут сделать ещё хуже. Используйте на свой страх и риск.\n\nДля сохранения изменений требуется перезапуск.",
|
||||
"ktg_net_speed_boost_default": "Отключено",
|
||||
"ktg_net_speed_boost_slight": "Небольшое",
|
||||
"ktg_net_speed_boost_medium": "Среднее",
|
||||
"ktg_net_speed_boost_big": "Высокое",
|
||||
"ktg_net_boost_restart_desc": "Для изменения ускорения загрузки требуется перезапуск.\n\nПерезапустить сейчас?"
|
||||
}
|
||||
|
88
Telegram/SourceFiles/boxes/net_boost_box.cpp
Normal file
88
Telegram/SourceFiles/boxes/net_boost_box.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "boxes/net_boost_box.h"
|
||||
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "core/kotato_settings.h"
|
||||
#include "app.h"
|
||||
|
||||
NetBoostBox::NetBoostBox(QWidget* parent)
|
||||
{
|
||||
}
|
||||
|
||||
void NetBoostBox::prepare() {
|
||||
setTitle(tr::ktg_net_speed_boost_title());
|
||||
|
||||
addButton(tr::lng_settings_save(), [=] { save(); });
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
|
||||
auto y = st::boxOptionListPadding.top();
|
||||
_description.create(
|
||||
this,
|
||||
tr::ktg_net_speed_boost_desc(tr::now),
|
||||
st::boxLabel);
|
||||
_description->moveToLeft(st::boxPadding.left(), y);
|
||||
|
||||
y += _description->height() + st::boxMediumSkip;
|
||||
|
||||
_boostGroup = std::make_shared<Ui::RadiobuttonGroup>(cNetSpeedBoost());
|
||||
|
||||
for (int i = 0; i <= 3; i++) {
|
||||
const auto button = Ui::CreateChild<Ui::Radiobutton>(
|
||||
this,
|
||||
_boostGroup,
|
||||
i,
|
||||
BoostLabel(i),
|
||||
st::autolockButton);
|
||||
button->moveToLeft(st::boxPadding.left(), y);
|
||||
y += button->heightNoMargins() + st::boxOptionListSkip;
|
||||
}
|
||||
showChildren();
|
||||
setDimensions(st::boxWidth, y);
|
||||
}
|
||||
|
||||
QString NetBoostBox::BoostLabel(int boost) {
|
||||
switch (boost) {
|
||||
case 0:
|
||||
return tr::ktg_net_speed_boost_default(tr::now);
|
||||
|
||||
case 1:
|
||||
return tr::ktg_net_speed_boost_slight(tr::now);
|
||||
|
||||
case 2:
|
||||
return tr::ktg_net_speed_boost_medium(tr::now);
|
||||
|
||||
case 3:
|
||||
return tr::ktg_net_speed_boost_big(tr::now);
|
||||
|
||||
default:
|
||||
Unexpected("Boost in NetBoostBox::BoostLabel.");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
void NetBoostBox::save() {
|
||||
const auto changeBoost = [=] {
|
||||
SetNetworkBoost(_boostGroup->value());
|
||||
KotatoSettings::Write();
|
||||
App::restart();
|
||||
};
|
||||
|
||||
const auto box = std::make_shared<QPointer<BoxContent>>();
|
||||
|
||||
*box = getDelegate()->show(
|
||||
Box<ConfirmBox>(
|
||||
tr::ktg_net_boost_restart_desc(tr::now),
|
||||
tr::ktg_fonts_restart(tr::now),
|
||||
tr::lng_cancel(tr::now),
|
||||
changeBoost));
|
||||
}
|
33
Telegram/SourceFiles/boxes/net_boost_box.h
Normal file
33
Telegram/SourceFiles/boxes/net_boost_box.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
This file is part of Kotatogram Desktop,
|
||||
the unofficial app based on Telegram Desktop.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "boxes/abstract_box.h"
|
||||
|
||||
namespace Ui {
|
||||
class RadiobuttonGroup;
|
||||
class Radiobutton;
|
||||
class FlatLabel;
|
||||
} // namespace Ui
|
||||
|
||||
class NetBoostBox : public BoxContent {
|
||||
public:
|
||||
NetBoostBox(QWidget* parent);
|
||||
|
||||
static QString BoostLabel(int boost);
|
||||
|
||||
protected:
|
||||
void prepare() override;
|
||||
|
||||
private:
|
||||
void save();
|
||||
|
||||
object_ptr<Ui::FlatLabel> _description = { nullptr };
|
||||
std::shared_ptr<Ui::RadiobuttonGroup> _boostGroup;
|
||||
|
||||
};
|
@@ -17,6 +17,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
|
||||
#include "ui/text/text_utilities.h" // Ui::Text::ToUpper
|
||||
#include "boxes/connection_box.h"
|
||||
#include "boxes/fonts_box.h"
|
||||
#include "boxes/net_boost_box.h"
|
||||
#include "boxes/about_box.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "info/profile/info_profile_button.h"
|
||||
@@ -104,6 +105,24 @@ void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
|
||||
st::settingsButton
|
||||
)->addClickHandler([=] {
|
||||
Ui::show(Box<FontsBox>());
|
||||
});
|
||||
|
||||
|
||||
AddSkip(container);
|
||||
}
|
||||
|
||||
void SetupKotatoNetwork(not_null<Ui::VerticalLayout*> container) {
|
||||
AddDivider(container);
|
||||
AddSkip(container);
|
||||
AddSubsectionTitle(container, tr::ktg_settings_network());
|
||||
|
||||
AddButtonWithLabel(
|
||||
container,
|
||||
tr::ktg_settings_net_speed_boost(),
|
||||
rpl::single(NetBoostBox::BoostLabel(cNetSpeedBoost())),
|
||||
st::settingsButton
|
||||
)->addClickHandler([=] {
|
||||
Ui::show(Box<NetBoostBox>());
|
||||
});
|
||||
|
||||
AddSkip(container);
|
||||
@@ -121,7 +140,7 @@ void Kotato::setupContent(not_null<Window::SessionController*> controller) {
|
||||
|
||||
SetupKotatoChats(content);
|
||||
//SetupKotatoFonts(content);
|
||||
//SetupKotatoNetwork(content);
|
||||
SetupKotatoNetwork(content);
|
||||
//SetupKotatoOther(content);
|
||||
|
||||
Ui::ResizeFitChild(this, content);
|
||||
|
@@ -15,7 +15,7 @@ namespace Settings {
|
||||
|
||||
void SetupKotatoChats(not_null<Ui::VerticalLayout*> container);
|
||||
//void SetupKotatoFonts(not_null<Ui::VerticalLayout*> container);
|
||||
//void SetupKotatoNetwork(not_null<Ui::VerticalLayout*> container);
|
||||
void SetupKotatoNetwork(not_null<Ui::VerticalLayout*> container);
|
||||
//void SetupKotatoOther(not_null<Ui::VerticalLayout*> container);
|
||||
|
||||
class Kotato : public Section {
|
||||
|
@@ -68,6 +68,8 @@
|
||||
<(src_loc)/boxes/local_storage_box.h
|
||||
<(src_loc)/boxes/mute_settings_box.cpp
|
||||
<(src_loc)/boxes/mute_settings_box.h
|
||||
<(src_loc)/boxes/net_boost_box.cpp
|
||||
<(src_loc)/boxes/net_boost_box.h
|
||||
<(src_loc)/boxes/peer_list_box.cpp
|
||||
<(src_loc)/boxes/peer_list_box.h
|
||||
<(src_loc)/boxes/peer_list_controllers.cpp
|
||||
|
Reference in New Issue
Block a user