Follow show-panel-on-click for attach menu.

This commit is contained in:
John Preston 2024-11-06 17:52:54 +04:00
parent da8a4ba8ab
commit 53abd2fe38
4 changed files with 27 additions and 8 deletions

View file

@ -33,6 +33,10 @@ base::options::toggle TabbedPanelShowOnClick({
const char kOptionTabbedPanelShowOnClick[] = "tabbed-panel-show-on-click";
bool ShowPanelOnClick() {
return TabbedPanelShowOnClick.value();
}
TabbedPanel::TabbedPanel(
QWidget *parent,
not_null<Window::SessionController*> controller,

View file

@ -25,6 +25,7 @@ namespace ChatHelpers {
class TabbedSelector;
extern const char kOptionTabbedPanelShowOnClick[];
[[nodiscard]] bool ShowPanelOnClick();
struct TabbedPanelDescriptor {
Window::SessionController *regularWindow = nullptr;

View file

@ -421,8 +421,16 @@ HistoryWidget::HistoryWidget(
initTabbedSelector();
_attachToggle->setClickedCallback([=] {
const auto toggle = _attachBotsMenu && _attachBotsMenu->isHidden();
base::call_delayed(st::historyAttach.ripple.hideDuration, this, [=] {
chooseAttach();
if (_attachBotsMenu && toggle) {
_attachBotsMenu->showAnimated();
} else {
chooseAttach();
if (_attachBotsMenu) {
_attachBotsMenu->hideAnimated();
}
}
});
});
@ -2611,7 +2619,7 @@ void HistoryWidget::setHistory(History *history) {
if (was && !now) {
_attachToggle->removeEventFilter(_attachBotsMenu.get());
_attachBotsMenu->hideFast();
} else if (now && !was) {
} else if (now && !was && !ChatHelpers::ShowPanelOnClick()) {
_attachToggle->installEventFilter(_attachBotsMenu.get());
}
@ -2699,7 +2707,9 @@ void HistoryWidget::refreshAttachBotsMenu() {
}
_attachBotsMenu->setOrigin(
Ui::PanelAnimation::Origin::BottomLeft);
_attachToggle->installEventFilter(_attachBotsMenu.get());
if (!ChatHelpers::ShowPanelOnClick()) {
_attachToggle->installEventFilter(_attachBotsMenu.get());
}
_attachBotsMenu->heightValue(
) | rpl::start_with_next([=] {
moveFieldControls();

View file

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/timer_rpl.h"
#include "boxes/peer_list_controllers.h"
#include "boxes/share_box.h"
#include "chat_helpers/tabbed_panel.h"
#include "core/application.h"
#include "core/click_handler_types.h"
#include "core/local_url_handlers.h"
@ -2039,9 +2040,6 @@ std::unique_ptr<Ui::DropdownMenu> MakeAttachBotsMenu(
not_null<PeerData*> peer,
Fn<Api::SendAction()> actionFactory,
Fn<void(bool)> attach) {
if (!Data::CanSend(peer, ChatRestriction::SendInline)) {
return nullptr;
}
auto result = std::make_unique<Ui::DropdownMenu>(
parent,
st::dropdownMenuWithIcons);
@ -2096,8 +2094,10 @@ std::unique_ptr<Ui::DropdownMenu> MakeAttachBotsMenu(
ChooseAndSendLocation(controller, config, actionFactory());
}, &st::menuIconAddress);
}
const auto addBots = Data::CanSend(peer, ChatRestriction::SendInline);
for (const auto &bot : bots->attachBots()) {
if (!bot.inAttachMenu
if (!addBots
|| !bot.inAttachMenu
|| !PeerMatchesTypes(peer, bot.user, bot.types)) {
continue;
}
@ -2128,7 +2128,11 @@ std::unique_ptr<Ui::DropdownMenu> MakeAttachBotsMenu(
}, action->lifetime());
raw->addAction(std::move(action));
}
if (raw->actions().size() <= minimal) {
const auto actions = raw->actions().size();
const auto onclick = ChatHelpers::ShowPanelOnClick();
if (!actions) {
return nullptr;
} else if (actions <= minimal && !onclick) {
return nullptr;
}
return result;