New option: "Show "View Profile" first"

This commit is contained in:
Eric Kotato 2022-02-17 06:02:58 +03:00
parent a197245574
commit 1186494b91
5 changed files with 35 additions and 5 deletions

View file

@ -270,5 +270,7 @@
"ktg_experimental_view_profile_context_menu_description": "Add \"View Profile\" to context menu in chats list",
"ktg_experimental_linux_nvidia_opengl": "Allow OpenGL on the NVIDIA drivers (Linux)",
"ktg_experimental_linux_nvidia_opengl_description": "Qt+OpenGL have problems on Linux with NVIDIA drivers.",
"ktg_settings_view_profile_on_top": "Show \"View Profile\" first",
"ktg_settings_view_profile_on_top_about": "This option also enables \"Add \"View Profile\"\" from TDesktop's experimental settings.",
"dummy_last_string": ""
}

View file

@ -270,5 +270,7 @@
"ktg_experimental_view_profile_context_menu_description": "Добавить пункт \"Показать профиль\" в контекстное меню списка чатов.",
"ktg_experimental_linux_nvidia_opengl": "OpenGL на драйверах NVIDIA (Linux)",
"ktg_experimental_linux_nvidia_opengl_description": "У Qt+OpenGL есть проблемы на Linux с драйверами NVIDIA.",
"ktg_settings_view_profile_on_top": "\"Показать профиль\" первым пунктом меню",
"ktg_settings_view_profile_on_top_about": "Эта настройка также включает \"Добавить \"Показать профиль\"\" из экспериментальных настроек TDesktop.",
"dummy_last_string": ""
}

View file

@ -460,6 +460,9 @@ const std::map<QString, Definition, std::greater<QString>> DefinitionMap {
{ "remember_compress_images", {
.type = SettingType::BoolSetting,
.defaultValue = false, }},
{ "view_profile_on_top", {
.type = SettingType::BoolSetting,
.defaultValue = false, }},
};
using OldOptionKey = QString;

View file

@ -9,6 +9,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
#include "kotato/kotato_lang.h"
#include "kotato/kotato_settings.h"
#include "base/options.h"
#include "base/platform/base_platform_info.h"
#include "settings/settings_common.h"
#include "settings/settings_chat.h"
@ -26,6 +27,7 @@ https://github.com/kotatogram/kotatogram-desktop/blob/dev/LEGAL
#include "ui/boxes/confirm_box.h"
#include "platform/platform_specific.h"
#include "platform/platform_file_utilities.h"
#include "window/window_peer_menu.h"
#include "window/window_session_controller.h"
#include "lang/lang_keys.h"
#include "core/update_checker.h"
@ -336,12 +338,30 @@ void SetupKotatoChats(
::Kotato::JsonSettings::Write();
}, container->lifetime());
AddButton(
container,
rktr("ktg_settings_view_profile_on_top"),
st::settingsButton
)->toggleOn(
rpl::single(::Kotato::JsonSettings::GetBool("view_profile_on_top"))
)->toggledValue(
) | rpl::filter([](bool enabled) {
return (enabled != ::Kotato::JsonSettings::GetBool("view_profile_on_top"));
}) | rpl::start_with_next([](bool enabled) {
::Kotato::JsonSettings::Set("view_profile_on_top", enabled);
if (enabled) {
auto &option = ::base::options::lookup<bool>(Window::kOptionViewProfileInChatsListContextMenu);
option.set(true);
}
::Kotato::JsonSettings::Write();
}, container->lifetime());
AddSkip(container);
AddDividerText(container, rktr("ktg_settings_view_profile_on_top_about"));
AddSkip(container);
}
void SetupKotatoMessages(not_null<Ui::VerticalLayout*> container) {
AddDivider(container);
AddSkip(container);
AddSubsectionTitle(container, rktr("ktg_settings_messages"));
const auto stickerHeightLabel = container->add(

View file

@ -773,11 +773,15 @@ void Filler::fill() {
}
void Filler::fillChatsListActions() {
const auto profileEnabled = ViewProfileInChatsListContextMenu.value();
const auto profileOnTop = ::Kotato::JsonSettings::GetBool("view_profile_on_top");
addHidePromotion();
addInfo();
if (profileEnabled && profileOnTop) {
addInfo();
}
addToggleArchive();
addTogglePin();
if (ViewProfileInChatsListContextMenu.value()) {
if (profileEnabled && !profileOnTop) {
addInfo();
}
addToggleMute();
@ -794,7 +798,6 @@ void Filler::fillChatsListActions() {
}
void Filler::fillHistoryActions() {
addInfo();
addToggleMute();
addSupportInfo();
addHidePin();