mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Add tabbed-panel-show-on-click option.
This commit is contained in:
parent
4aafcebef5
commit
2a99f1a1ef
4 changed files with 48 additions and 2 deletions
Telegram/SourceFiles
chat_helpers
history
settings
|
@ -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();
|
||||
|
|
|
@ -24,6 +24,8 @@ namespace ChatHelpers {
|
|||
|
||||
class TabbedSelector;
|
||||
|
||||
extern const char kOptionTabbedPanelShowOnClick[];
|
||||
|
||||
class TabbedPanel : public Ui::RpWidget {
|
||||
public:
|
||||
TabbedPanel(
|
||||
|
|
|
@ -934,7 +934,11 @@ void HistoryWidget::initTabbedSelector() {
|
|||
refreshTabbedPanel();
|
||||
|
||||
_tabbedSelectorToggle->addClickHandler([=] {
|
||||
toggleTabbedSelectorMode();
|
||||
if (_tabbedPanel && _tabbedPanel->isHidden()) {
|
||||
_tabbedPanel->showAnimated();
|
||||
} else {
|
||||
toggleTabbedSelectorMode();
|
||||
}
|
||||
});
|
||||
|
||||
const auto selector = controller()->tabbedSelector();
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue