2019-10-10 19:57:03 +03:00
|
|
|
/*
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
#include "settings/settings_kotato.h"
|
|
|
|
|
|
|
|
#include "settings/settings_common.h"
|
|
|
|
#include "settings/settings_chat.h"
|
|
|
|
#include "ui/wrap/vertical_layout.h"
|
|
|
|
#include "ui/wrap/slide_wrap.h"
|
2019-11-06 16:22:25 +03:00
|
|
|
#include "ui/widgets/buttons.h"
|
2019-10-10 19:57:03 +03:00
|
|
|
#include "ui/widgets/labels.h"
|
|
|
|
#include "ui/widgets/checkbox.h"
|
|
|
|
#include "ui/widgets/continuous_sliders.h"
|
|
|
|
#include "ui/text/text_utilities.h" // Ui::Text::ToUpper
|
|
|
|
#include "boxes/connection_box.h"
|
2019-10-14 02:17:53 +03:00
|
|
|
#include "boxes/fonts_box.h"
|
2019-10-18 20:32:18 +03:00
|
|
|
#include "boxes/net_boost_box.h"
|
2019-10-10 19:57:03 +03:00
|
|
|
#include "boxes/about_box.h"
|
|
|
|
#include "boxes/confirm_box.h"
|
|
|
|
#include "platform/platform_specific.h"
|
|
|
|
#include "window/window_session_controller.h"
|
|
|
|
#include "lang/lang_keys.h"
|
|
|
|
#include "core/update_checker.h"
|
2019-10-11 06:54:49 +03:00
|
|
|
#include "core/kotato_settings.h"
|
2019-10-10 19:57:03 +03:00
|
|
|
#include "core/application.h"
|
|
|
|
#include "storage/localstorage.h"
|
|
|
|
#include "data/data_session.h"
|
|
|
|
#include "main/main_session.h"
|
|
|
|
#include "layout.h"
|
2020-03-30 19:36:59 +03:00
|
|
|
#include "mainwindow.h"
|
2019-10-10 19:57:03 +03:00
|
|
|
#include "facades.h"
|
|
|
|
#include "app.h"
|
|
|
|
#include "styles/style_settings.h"
|
|
|
|
|
|
|
|
namespace Settings {
|
|
|
|
|
|
|
|
void SetupKotatoChats(not_null<Ui::VerticalLayout*> container) {
|
|
|
|
AddSkip(container);
|
|
|
|
AddSubsectionTitle(container, tr::ktg_settings_chats());
|
|
|
|
|
|
|
|
const auto stickerHeightLabel = container->add(
|
|
|
|
object_ptr<Ui::LabelSimple>(
|
|
|
|
container,
|
|
|
|
st::settingsAudioVolumeLabel),
|
|
|
|
st::settingsAudioVolumeLabelPadding);
|
|
|
|
const auto stickerHeightSlider = container->add(
|
|
|
|
object_ptr<Ui::MediaSlider>(
|
|
|
|
container,
|
|
|
|
st::settingsAudioVolumeSlider),
|
|
|
|
st::settingsAudioVolumeSliderPadding);
|
|
|
|
const auto updateStickerHeightLabel = [=](int value) {
|
|
|
|
const auto pixels = QString::number(value);
|
|
|
|
stickerHeightLabel->setText(
|
|
|
|
tr::ktg_settings_sticker_height(tr::now, lt_pixels, pixels));
|
|
|
|
};
|
|
|
|
const auto updateStickerHeight = [=](int value) {
|
|
|
|
updateStickerHeightLabel(value);
|
2019-10-11 02:39:38 +03:00
|
|
|
SetStickerHeight(value);
|
2019-10-11 06:54:49 +03:00
|
|
|
KotatoSettings::Write();
|
2019-10-10 19:57:03 +03:00
|
|
|
};
|
|
|
|
stickerHeightSlider->resize(st::settingsAudioVolumeSlider.seekSize);
|
|
|
|
stickerHeightSlider->setPseudoDiscrete(
|
2020-02-02 08:09:45 +03:00
|
|
|
193,
|
|
|
|
[](int val) { return val + 64; },
|
2019-10-11 02:39:38 +03:00
|
|
|
StickerHeight(),
|
2019-10-10 19:57:03 +03:00
|
|
|
updateStickerHeight);
|
2019-10-11 02:39:38 +03:00
|
|
|
updateStickerHeightLabel(StickerHeight());
|
2019-10-10 19:57:03 +03:00
|
|
|
|
2020-02-23 04:53:24 +03:00
|
|
|
const auto recentStickersLimitLabel = container->add(
|
|
|
|
object_ptr<Ui::LabelSimple>(
|
|
|
|
container,
|
|
|
|
st::settingsAudioVolumeLabel),
|
|
|
|
st::settingsAudioVolumeLabelPadding);
|
|
|
|
const auto recentStickersLimitSlider = container->add(
|
|
|
|
object_ptr<Ui::MediaSlider>(
|
|
|
|
container,
|
|
|
|
st::settingsAudioVolumeSlider),
|
|
|
|
st::settingsAudioVolumeSliderPadding);
|
|
|
|
const auto updateRecentStickersLimitLabel = [=](int value) {
|
|
|
|
if (value == 0) {
|
|
|
|
recentStickersLimitLabel->setText(
|
|
|
|
tr::ktg_settings_recent_stickers_limit_none(tr::now));
|
|
|
|
} else {
|
|
|
|
recentStickersLimitLabel->setText(
|
|
|
|
tr::ktg_settings_recent_stickers_limit(tr::now, lt_count_decimal, value));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const auto updateRecentStickersLimitHeight = [=](int value) {
|
|
|
|
updateRecentStickersLimitLabel(value);
|
|
|
|
SetRecentStickersLimit(value);
|
|
|
|
KotatoSettings::Write();
|
|
|
|
};
|
|
|
|
recentStickersLimitSlider->resize(st::settingsAudioVolumeSlider.seekSize);
|
|
|
|
recentStickersLimitSlider->setPseudoDiscrete(
|
|
|
|
201,
|
|
|
|
[](int val) { return val; },
|
|
|
|
RecentStickersLimit(),
|
|
|
|
updateRecentStickersLimitHeight);
|
|
|
|
updateRecentStickersLimitLabel(RecentStickersLimit());
|
|
|
|
|
2019-12-19 22:26:39 +04:00
|
|
|
AddButton(
|
|
|
|
container,
|
2020-01-18 18:51:07 +03:00
|
|
|
tr::ktg_settings_adaptive_bubbles(),
|
2019-12-19 22:26:39 +04:00
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
2020-01-26 07:03:18 +03:00
|
|
|
rpl::single(AdaptiveBubbles())
|
2019-12-19 22:26:39 +04:00
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
2020-01-26 07:03:18 +03:00
|
|
|
return (enabled != AdaptiveBubbles());
|
|
|
|
}) | rpl::start_with_next([](bool enabled) {
|
|
|
|
SetAdaptiveBubbles(enabled);
|
|
|
|
KotatoSettings::Write();
|
2019-12-19 22:26:39 +04:00
|
|
|
}, container->lifetime());
|
|
|
|
|
2019-10-10 19:57:03 +03:00
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_emoji_outline(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
2019-10-11 00:54:02 +03:00
|
|
|
rpl::single(BigEmojiOutline())
|
2019-10-10 19:57:03 +03:00
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
2019-10-11 00:54:02 +03:00
|
|
|
return (enabled != BigEmojiOutline());
|
2019-10-10 19:57:03 +03:00
|
|
|
}) | rpl::start_with_next([](bool enabled) {
|
2019-10-11 00:54:02 +03:00
|
|
|
SetBigEmojiOutline(enabled);
|
2019-10-11 06:54:49 +03:00
|
|
|
KotatoSettings::Write();
|
2019-10-10 19:57:03 +03:00
|
|
|
}, container->lifetime());
|
|
|
|
|
2019-11-13 19:14:03 +03:00
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_chat_list_compact(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(DialogListLines() == 1)
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled != (DialogListLines() == 1));
|
|
|
|
}) | rpl::start_with_next([](bool enabled) {
|
|
|
|
SetDialogListLines(enabled ? 1 : 2);
|
|
|
|
KotatoSettings::Write();
|
|
|
|
}, container->lifetime());
|
|
|
|
|
2019-10-10 19:57:03 +03:00
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_always_show_scheduled(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(cAlwaysShowScheduled())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled != cAlwaysShowScheduled());
|
|
|
|
}) | rpl::start_with_next([](bool enabled) {
|
|
|
|
cSetAlwaysShowScheduled(enabled);
|
2019-10-10 23:51:46 +03:00
|
|
|
Notify::showScheduledButtonChanged();
|
2019-10-11 06:54:49 +03:00
|
|
|
KotatoSettings::Write();
|
2019-10-14 02:17:53 +03:00
|
|
|
}, container->lifetime());
|
|
|
|
|
2020-02-03 08:12:47 +03:00
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_disable_up_edit(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(cDisableUpEdit())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled != cDisableUpEdit());
|
|
|
|
}) | rpl::start_with_next([](bool enabled) {
|
|
|
|
cSetDisableUpEdit(enabled);
|
|
|
|
KotatoSettings::Write();
|
|
|
|
}, container->lifetime());
|
|
|
|
|
2019-10-14 02:17:53 +03:00
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_fonts(),
|
|
|
|
st::settingsButton
|
|
|
|
)->addClickHandler([=] {
|
|
|
|
Ui::show(Box<FontsBox>());
|
2019-10-18 20:32:18 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
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>());
|
2020-01-20 22:34:01 +00:00
|
|
|
});
|
2019-10-10 19:57:03 +03:00
|
|
|
|
|
|
|
AddSkip(container);
|
|
|
|
}
|
|
|
|
|
2020-03-30 19:36:59 +03:00
|
|
|
void SetupKotatoFolders(
|
|
|
|
not_null<Window::SessionController*> controller,
|
|
|
|
not_null<Ui::VerticalLayout*> container) {
|
|
|
|
AddDivider(container);
|
|
|
|
AddSkip(container);
|
|
|
|
AddSubsectionTitle(container, tr::ktg_settings_filters());
|
|
|
|
|
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_filters_only_unmuted_counter(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(cUnmutedFilterCounterOnly())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled != cUnmutedFilterCounterOnly());
|
|
|
|
}) | rpl::start_with_next([=](bool enabled) {
|
|
|
|
cSetUnmutedFilterCounterOnly(enabled);
|
|
|
|
KotatoSettings::Write();
|
|
|
|
controller->reloadFiltersMenu();
|
|
|
|
App::wnd()->fixOrder();
|
|
|
|
}, container->lifetime());
|
|
|
|
|
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_filters_hide_edit(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(cHideFilterEditButton())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled != cHideFilterEditButton());
|
|
|
|
}) | rpl::start_with_next([=](bool enabled) {
|
|
|
|
cSetHideFilterEditButton(enabled);
|
|
|
|
KotatoSettings::Write();
|
|
|
|
controller->reloadFiltersMenu();
|
|
|
|
App::wnd()->fixOrder();
|
|
|
|
}, container->lifetime());
|
|
|
|
|
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_filters_hide_folder_names(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(cHideFilterNames())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled != cHideFilterNames());
|
|
|
|
}) | rpl::start_with_next([=](bool enabled) {
|
|
|
|
cSetHideFilterNames(enabled);
|
|
|
|
KotatoSettings::Write();
|
|
|
|
controller->reloadFiltersMenu();
|
|
|
|
App::wnd()->fixOrder();
|
|
|
|
}, container->lifetime());
|
|
|
|
|
|
|
|
AddSkip(container);
|
|
|
|
}
|
|
|
|
|
2020-02-23 05:30:39 +03:00
|
|
|
void SetupKotatoSystem(not_null<Ui::VerticalLayout*> container) {
|
|
|
|
AddDivider(container);
|
|
|
|
AddSkip(container);
|
|
|
|
AddSubsectionTitle(container, tr::ktg_settings_system());
|
|
|
|
|
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_no_taskbar_flash(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(cNoTaskbarFlashing())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled != cNoTaskbarFlashing());
|
|
|
|
}) | rpl::start_with_next([](bool enabled) {
|
|
|
|
cSetNoTaskbarFlashing(enabled);
|
|
|
|
KotatoSettings::Write();
|
|
|
|
}, container->lifetime());
|
|
|
|
|
|
|
|
AddSkip(container);
|
|
|
|
}
|
|
|
|
|
2019-10-18 22:29:21 +03:00
|
|
|
void SetupKotatoOther(not_null<Ui::VerticalLayout*> container) {
|
|
|
|
AddDivider(container);
|
|
|
|
AddSkip(container);
|
|
|
|
AddSubsectionTitle(container, tr::ktg_settings_other());
|
|
|
|
|
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_show_phone_number(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(cShowPhoneInDrawer())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled != cShowPhoneInDrawer());
|
|
|
|
}) | rpl::start_with_next([](bool enabled) {
|
|
|
|
cSetShowPhoneInDrawer(enabled);
|
|
|
|
KotatoSettings::Write();
|
|
|
|
}, container->lifetime());
|
|
|
|
|
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_show_chat_id(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(cShowChatId())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled != cShowChatId());
|
|
|
|
}) | rpl::start_with_next([](bool enabled) {
|
|
|
|
cSetShowChatId(enabled);
|
|
|
|
KotatoSettings::Write();
|
|
|
|
}, container->lifetime());
|
|
|
|
|
2020-02-03 05:51:15 +03:00
|
|
|
AddButton(
|
|
|
|
container,
|
|
|
|
tr::ktg_settings_call_confirm(),
|
|
|
|
st::settingsButton
|
|
|
|
)->toggleOn(
|
|
|
|
rpl::single(cConfirmBeforeCall())
|
|
|
|
)->toggledValue(
|
|
|
|
) | rpl::filter([](bool enabled) {
|
|
|
|
return (enabled != cConfirmBeforeCall());
|
|
|
|
}) | rpl::start_with_next([](bool enabled) {
|
|
|
|
cSetConfirmBeforeCall(enabled);
|
|
|
|
KotatoSettings::Write();
|
|
|
|
}, container->lifetime());
|
|
|
|
|
2019-10-18 22:29:21 +03:00
|
|
|
AddSkip(container);
|
|
|
|
}
|
|
|
|
|
2019-10-10 19:57:03 +03:00
|
|
|
Kotato::Kotato(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<Window::SessionController*> controller)
|
|
|
|
: Section(parent) {
|
|
|
|
setupContent(controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Kotato::setupContent(not_null<Window::SessionController*> controller) {
|
|
|
|
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
|
|
|
|
|
|
|
SetupKotatoChats(content);
|
2019-10-18 20:32:18 +03:00
|
|
|
SetupKotatoNetwork(content);
|
2020-03-30 19:36:59 +03:00
|
|
|
SetupKotatoFolders(controller, content);
|
2020-02-23 05:30:39 +03:00
|
|
|
SetupKotatoSystem(content);
|
2019-10-18 22:29:21 +03:00
|
|
|
SetupKotatoOther(content);
|
2019-10-10 19:57:03 +03:00
|
|
|
|
|
|
|
Ui::ResizeFitChild(this, content);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Settings
|
2019-10-14 02:17:53 +03:00
|
|
|
|