mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-07 04:05:17 +00:00
Allowed cancelling query and search in profile tabs with Escape.
This commit is contained in:
@@ -536,6 +536,14 @@ void InnerWidget::showFinished() {
|
||||
_showFinished.fire({});
|
||||
}
|
||||
|
||||
void InnerWidget::checkBeforeCloseByEscape(Fn<void()> close) {
|
||||
if (const auto top = _topBar.get()) {
|
||||
top->checkBeforeCloseByEscape(std::move(close));
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
bool InnerWidget::hasFlexibleTopBar() const {
|
||||
return true;
|
||||
}
|
||||
@@ -571,6 +579,7 @@ base::weak_qptr<Ui::RpWidget> InnerWidget::createPinnedToTop(
|
||||
}));
|
||||
}
|
||||
_topBarColor = content->edgeColor();
|
||||
_topBar = content;
|
||||
return base::make_weak(not_null<Ui::RpWidget*>{ content });
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace Profile {
|
||||
class Memento;
|
||||
class Members;
|
||||
class TabsHost;
|
||||
class TopBar;
|
||||
struct Origin;
|
||||
|
||||
class InnerWidget final : public Ui::RpWidget {
|
||||
@@ -64,6 +65,7 @@ public:
|
||||
|
||||
void enableBackButton();
|
||||
void showFinished();
|
||||
void checkBeforeCloseByEscape(Fn<void()> close);
|
||||
|
||||
[[nodiscard]] TabsHost *tabsHost() const {
|
||||
return _tabsHost;
|
||||
@@ -116,6 +118,7 @@ private:
|
||||
rpl::variable<std::optional<QColor>> _topBarColor;
|
||||
|
||||
Members *_members = nullptr;
|
||||
base::weak_qptr<TopBar> _topBar;
|
||||
Ui::SlideWrap<RpWidget> *_sharedMediaWrap = nullptr;
|
||||
TabsHost *_tabsHost = nullptr;
|
||||
rpl::variable<bool> _tabsDocked = false;
|
||||
|
||||
@@ -2339,12 +2339,7 @@ void TopBar::showTabSearch() {
|
||||
cancel->setAccessibleName(tr::lng_sr_cancel_search(tr::now));
|
||||
cancel->show();
|
||||
cancel->addClickHandler([=] {
|
||||
if (_tabSearchField->getLastText().isEmpty()) {
|
||||
hideTabSearch();
|
||||
updateTabSwapVisibility();
|
||||
} else {
|
||||
_tabSearchField->setText(QString());
|
||||
}
|
||||
cancelTabSearch();
|
||||
});
|
||||
inner->widthValue(
|
||||
) | rpl::on_next([=](int newWidth) {
|
||||
@@ -2377,6 +2372,24 @@ void TopBar::hideTabSearch() {
|
||||
_tabSearchBar->toggle(false, anim::type::normal);
|
||||
}
|
||||
|
||||
bool TopBar::cancelTabSearch() {
|
||||
if (!_tabSearchShown) {
|
||||
return false;
|
||||
} else if (!_tabSearchField->getLastText().isEmpty()) {
|
||||
_tabSearchField->setText(QString());
|
||||
} else {
|
||||
hideTabSearch();
|
||||
updateTabSwapVisibility();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopBar::checkBeforeCloseByEscape(Fn<void()> close) {
|
||||
if (!cancelTabSearch()) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
void TopBar::raiseTabSearchOverlay() {
|
||||
if (!_tabSearchBar || !_tabSearchShown) {
|
||||
return;
|
||||
|
||||
@@ -131,6 +131,8 @@ public:
|
||||
rpl::producer<bool> available,
|
||||
Fn<void(bool)> toggle);
|
||||
|
||||
void checkBeforeCloseByEscape(Fn<void()> close);
|
||||
|
||||
void setRoundEdges(bool value);
|
||||
void setLottieSingleLoop(bool value);
|
||||
void setColorProfileIndex(std::optional<uint8> index);
|
||||
@@ -219,6 +221,7 @@ private:
|
||||
[[nodiscard]] bool tabSelectionMode() const;
|
||||
void showTabSearch();
|
||||
void hideTabSearch();
|
||||
bool cancelTabSearch();
|
||||
void raiseTabSearchOverlay();
|
||||
void updateTabSearchGeometry();
|
||||
[[nodiscard]] int calculateRightButtonsWidth() const;
|
||||
|
||||
@@ -305,6 +305,12 @@ void Widget::showFinished() {
|
||||
_inner->showFinished();
|
||||
}
|
||||
|
||||
void Widget::checkBeforeCloseByEscape(Fn<void()> close) {
|
||||
_inner->checkBeforeCloseByEscape([=] {
|
||||
ContentWidget::checkBeforeCloseByEscape(close);
|
||||
});
|
||||
}
|
||||
|
||||
rpl::producer<QString> Widget::title() {
|
||||
if (const auto topic = controller()->key().topic()) {
|
||||
return topic->peer()->isBot()
|
||||
|
||||
@@ -90,6 +90,7 @@ public:
|
||||
void setInnerFocus() override;
|
||||
void enableBackButton() override;
|
||||
void showFinished() override;
|
||||
void checkBeforeCloseByEscape(Fn<void()> close) override;
|
||||
|
||||
rpl::producer<QString> title() override;
|
||||
rpl::producer<Dialogs::Stories::Content> titleStories() override;
|
||||
|
||||
Reference in New Issue
Block a user