mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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
|
@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
|
#include "base/options.h"
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
|
|
||||||
namespace ChatHelpers {
|
namespace ChatHelpers {
|
||||||
|
@ -22,8 +23,16 @@ namespace {
|
||||||
constexpr auto kHideTimeoutMs = 300;
|
constexpr auto kHideTimeoutMs = 300;
|
||||||
constexpr auto kDelayedHideTimeoutMs = 3000;
|
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
|
} // namespace
|
||||||
|
|
||||||
|
const char kOptionTabbedPanelShowOnClick[] = "tabbed-panel-show-on-click";
|
||||||
|
|
||||||
TabbedPanel::TabbedPanel(
|
TabbedPanel::TabbedPanel(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
|
@ -408,7 +417,9 @@ void TabbedPanel::showStarted() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TabbedPanel::eventFilter(QObject *obj, QEvent *e) {
|
bool TabbedPanel::eventFilter(QObject *obj, QEvent *e) {
|
||||||
if (e->type() == QEvent::Enter) {
|
if (TabbedPanelShowOnClick.value()) {
|
||||||
|
return false;
|
||||||
|
} else if (e->type() == QEvent::Enter) {
|
||||||
otherEnter();
|
otherEnter();
|
||||||
} else if (e->type() == QEvent::Leave) {
|
} else if (e->type() == QEvent::Leave) {
|
||||||
otherLeave();
|
otherLeave();
|
||||||
|
|
|
@ -24,6 +24,8 @@ namespace ChatHelpers {
|
||||||
|
|
||||||
class TabbedSelector;
|
class TabbedSelector;
|
||||||
|
|
||||||
|
extern const char kOptionTabbedPanelShowOnClick[];
|
||||||
|
|
||||||
class TabbedPanel : public Ui::RpWidget {
|
class TabbedPanel : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
TabbedPanel(
|
TabbedPanel(
|
||||||
|
|
|
@ -934,7 +934,11 @@ void HistoryWidget::initTabbedSelector() {
|
||||||
refreshTabbedPanel();
|
refreshTabbedPanel();
|
||||||
|
|
||||||
_tabbedSelectorToggle->addClickHandler([=] {
|
_tabbedSelectorToggle->addClickHandler([=] {
|
||||||
toggleTabbedSelectorMode();
|
if (_tabbedPanel && _tabbedPanel->isHidden()) {
|
||||||
|
_tabbedPanel->showAnimated();
|
||||||
|
} else {
|
||||||
|
toggleTabbedSelectorMode();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto selector = controller()->tabbedSelector();
|
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/wrap/vertical_layout.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
|
#include "base/options.h"
|
||||||
#include "chat_helpers/tabbed_panel.h"
|
#include "chat_helpers/tabbed_panel.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
|
@ -18,6 +19,26 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
namespace {
|
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(
|
void SetupExperimental(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container) {
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
|
@ -33,6 +54,14 @@ void SetupExperimental(
|
||||||
AddDivider(container);
|
AddDivider(container);
|
||||||
|
|
||||||
AddSkip(container, st::settingsCheckboxesSkip);
|
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
|
} // namespace
|
||||||
|
|
Loading…
Add table
Reference in a new issue