Add tabbed-panel-show-on-click option.

This commit is contained in:
John Preston 2022-01-25 18:40:22 +03:00
parent 4aafcebef5
commit 2a99f1a1ef
4 changed files with 48 additions and 2 deletions

View file

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_session_controller.h"
#include "mainwindow.h"
#include "core/application.h"
#include "base/options.h"
#include "styles/style_chat_helpers.h"
namespace ChatHelpers {
@ -22,8 +23,16 @@ namespace {
constexpr auto kHideTimeoutMs = 300;
constexpr auto kDelayedHideTimeoutMs = 3000;
base::options::toggle TabbedPanelShowOnClick({
.id = kOptionTabbedPanelShowOnClick,
.name = "Show tabbed panel by click",
.description = "Show Emoji / Stickers / GIFs panel only after a click.",
});
} // namespace
const char kOptionTabbedPanelShowOnClick[] = "tabbed-panel-show-on-click";
TabbedPanel::TabbedPanel(
QWidget *parent,
not_null<Window::SessionController*> controller,
@ -408,7 +417,9 @@ void TabbedPanel::showStarted() {
}
bool TabbedPanel::eventFilter(QObject *obj, QEvent *e) {
if (e->type() == QEvent::Enter) {
if (TabbedPanelShowOnClick.value()) {
return false;
} else if (e->type() == QEvent::Enter) {
otherEnter();
} else if (e->type() == QEvent::Leave) {
otherLeave();

View file

@ -24,6 +24,8 @@ namespace ChatHelpers {
class TabbedSelector;
extern const char kOptionTabbedPanelShowOnClick[];
class TabbedPanel : public Ui::RpWidget {
public:
TabbedPanel(

View file

@ -934,7 +934,11 @@ void HistoryWidget::initTabbedSelector() {
refreshTabbedPanel();
_tabbedSelectorToggle->addClickHandler([=] {
toggleTabbedSelectorMode();
if (_tabbedPanel && _tabbedPanel->isHidden()) {
_tabbedPanel->showAnimated();
} else {
toggleTabbedSelectorMode();
}
});
const auto selector = controller()->tabbedSelector();

View file

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/vertical_layout.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
#include "base/options.h"
#include "chat_helpers/tabbed_panel.h"
#include "lang/lang_keys.h"
#include "styles/style_settings.h"
@ -18,6 +19,26 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Settings {
namespace {
void AddOption(
not_null<Ui::VerticalLayout*> container,
base::options::option<bool> &option) {
const auto name = option.name().isEmpty() ? option.id() : option.name();
AddButton(
container,
rpl::single(name),
st::settingsButton
)->toggleOn(rpl::single(option.value()))->toggledChanges(
) | rpl::start_with_next([=, &option](bool toggled) {
option.set(toggled);
}, container->lifetime());
const auto &description = option.description();
if (!description.isEmpty()) {
AddSkip(container, st::settingsCheckboxesSkip);
AddDividerText(container, rpl::single(description));
}
}
void SetupExperimental(
not_null<Window::SessionController*> controller,
not_null<Ui::VerticalLayout*> container) {
@ -33,6 +54,14 @@ void SetupExperimental(
AddDivider(container);
AddSkip(container, st::settingsCheckboxesSkip);
const auto addToggle = [&](const char name[]) {
AddOption(container, base::options::lookup<bool>(name));
};
addToggle(ChatHelpers::kOptionTabbedPanelShowOnClick);
AddSkip(container, st::settingsCheckboxesSkip);
}
} // namespace