2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 00:55:12 +00:00
Files
kotatogram-desktop/Telegram/SourceFiles/boxes/net_boost_box.cpp
RadRussianRus b1b61fc9e0 Build fixes
2019-11-06 20:51:59 +03:00

89 lines
2.1 KiB
C++

/*
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_layers.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));
}