From 9acd628dd0d91ddf24eaf435f9f8e9c2533ba6dc Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Sat, 10 Sep 2022 20:03:06 +0300 Subject: [PATCH] [Option][GUI] Emoji panel options --- Telegram/Resources/langs/rewrites/en.json | 2 ++ .../SourceFiles/chat_helpers/tabbed_panel.h | 6 ++++++ .../SourceFiles/history/history_widget.cpp | 20 ++++++++++++++++--- .../history_view_compose_controls.cpp | 20 ++++++++++++++++--- .../SourceFiles/kotato/kotato_settings.cpp | 6 ++++++ .../kotato/kotato_settings_menu.cpp | 2 ++ 6 files changed, 50 insertions(+), 6 deletions(-) diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index be1cd87ca..d2b471270 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -150,5 +150,7 @@ "ktg_in_app_update_disabled": "In-app updater is disabled.", "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.", + "ktg_settings_emoji_sidebar": "Enable emoji sidebar", + "ktg_settings_emoji_sidebar_right_click": "Emoji sidebar on right click", "dummy_last_string": "" } diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_panel.h b/Telegram/SourceFiles/chat_helpers/tabbed_panel.h index fcedb5efc..dfbcf45ea 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_panel.h +++ b/Telegram/SourceFiles/chat_helpers/tabbed_panel.h @@ -67,6 +67,10 @@ public: void hideAnimated(); void toggleAnimated(); + void setPreventHover(bool value) { + _preventHover = value; + } + ~TabbedPanel(); protected: @@ -127,6 +131,8 @@ private: Ui::Animations::Simple _a_opacity; base::Timer _hideTimer; + bool _preventHover = false; + }; } // namespace ChatHelpers diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index f769dc735..f4e2cce5d 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1176,13 +1176,26 @@ void HistoryWidget::initTabbedSelector() { refreshTabbedPanel(); _tabbedSelectorToggle->addClickHandler([=] { - if (_tabbedPanel && _tabbedPanel->isHidden()) { - _tabbedPanel->showAnimated(); + if (_tabbedPanel && (_tabbedPanel->isHidden() + || ::Kotato::JsonSettings::GetBool("emoji_sidebar_right_click"))) { + _tabbedPanel->toggleAnimated(); } else { toggleTabbedSelectorMode(); } }); + base::install_event_filter(_tabbedSelectorToggle, [=](not_null e) { + if (e->type() == QEvent::ContextMenu) { + if (::Kotato::JsonSettings::GetBool("emoji_sidebar_right_click")) { + toggleTabbedSelectorMode(); + } else if (_tabbedPanel) { + _tabbedPanel->toggleAnimated(); + } + return base::EventFilterResult::Cancel; + } + return base::EventFilterResult::Continue; + }); + const auto selector = controller()->tabbedSelector(); base::install_event_filter(this, selector, [=](not_null e) { @@ -5273,7 +5286,8 @@ void HistoryWidget::toggleTabbedSelectorMode() { } if (_tabbedPanel) { if (controller()->canShowThirdSection() - && !controller()->adaptive().isOneColumn()) { + && !controller()->adaptive().isOneColumn() + && ::Kotato::JsonSettings::GetBool("emoji_sidebar")) { Core::App().settings().setTabbedSelectorSectionEnabled(true); Core::App().saveSettingsDelayed(); pushTabbedSelectorToThirdSection( diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index d71f80099..d4fc2485f 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -2111,9 +2111,22 @@ void ComposeControls::initTabbedSelector() { setTabbedPanel(nullptr); } + base::install_event_filter(_tabbedSelectorToggle, [=](not_null e) { + if (e->type() == QEvent::ContextMenu) { + if (::Kotato::JsonSettings::GetBool("emoji_sidebar_right_click")) { + toggleTabbedSelectorMode(); + } else if (_tabbedPanel) { + _tabbedPanel->toggleAnimated(); + } + return base::EventFilterResult::Cancel; + } + return base::EventFilterResult::Continue; + }); + _tabbedSelectorToggle->addClickHandler([=] { - if (_tabbedPanel && _tabbedPanel->isHidden()) { - _tabbedPanel->showAnimated(); + if (_tabbedPanel && (_tabbedPanel->isHidden() + || ::Kotato::JsonSettings::GetBool("emoji_sidebar_right_click"))) { + _tabbedPanel->toggleAnimated(); } else { toggleTabbedSelectorMode(); } @@ -2853,7 +2866,8 @@ void ComposeControls::toggleTabbedSelectorMode() { } if (_tabbedPanel) { if (_regularWindow->canShowThirdSection() - && !_regularWindow->adaptive().isOneColumn()) { + && !_regularWindow->adaptive().isOneColumn() + && ::Kotato::JsonSettings::GetBool("emoji_sidebar")) { Core::App().settings().setTabbedSelectorSectionEnabled(true); Core::App().saveSettingsDelayed(); const auto topic = _history->peer->forumTopicFor(_topicRootId); diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index f25a1c7f5..4df75d98c 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -361,6 +361,12 @@ const std::map> DefinitionMap { { "view_profile_on_top", { .type = SettingType::BoolSetting, .defaultValue = false, }}, + { "emoji_sidebar", { + .type = SettingType::BoolSetting, + .defaultValue = true, }}, + { "emoji_sidebar_right_click", { + .type = SettingType::BoolSetting, + .defaultValue = false, }}, }; using OldOptionKey = QString; diff --git a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp index 72bdbdc05..e3293ba38 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -258,6 +258,8 @@ void SetupKotatoChats( Ui::AddDividerText(container, rktr("ktg_settings_view_profile_on_top_about")); Ui::AddSkip(container); + SettingsMenuJsonSwitch(ktg_settings_emoji_sidebar, emoji_sidebar); + SettingsMenuJsonSwitch(ktg_settings_emoji_sidebar_right_click, emoji_sidebar_right_click); Ui::AddSkip(container); Ui::AddDivider(container);