mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added initial implementation of search in section for comments.
This commit is contained in:
parent
0989a80a57
commit
a13ca95894
4 changed files with 68 additions and 7 deletions
|
@ -1035,13 +1035,15 @@ void ComposeControls::setAutocompleteBoundingRect(QRect rect) {
|
||||||
rpl::producer<int> ComposeControls::height() const {
|
rpl::producer<int> ComposeControls::height() const {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
return rpl::conditional(
|
return rpl::conditional(
|
||||||
_writeRestriction.value() | rpl::map(!_1),
|
rpl::combine(
|
||||||
|
_writeRestriction.value(),
|
||||||
|
_hidden.value()) | rpl::map(!_1 && !_2),
|
||||||
_wrap->heightValue(),
|
_wrap->heightValue(),
|
||||||
rpl::single(_st.attach.height));
|
rpl::single(_st.attach.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ComposeControls::heightCurrent() const {
|
int ComposeControls::heightCurrent() const {
|
||||||
return _writeRestriction.current()
|
return (_writeRestriction.current() || _hidden.current())
|
||||||
? _st.attach.height
|
? _st.attach.height
|
||||||
: _wrap->height();
|
: _wrap->height();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/history_view_replies_section.h"
|
#include "history/view/history_view_replies_section.h"
|
||||||
|
|
||||||
#include "history/view/controls/history_view_compose_controls.h"
|
#include "history/view/controls/history_view_compose_controls.h"
|
||||||
|
#include "history/view/controls/history_view_compose_search.h"
|
||||||
#include "history/view/controls/history_view_draft_options.h"
|
#include "history/view/controls/history_view_draft_options.h"
|
||||||
#include "history/view/history_view_top_bar_widget.h"
|
#include "history/view/history_view_top_bar_widget.h"
|
||||||
#include "history/view/history_view_schedule_box.h"
|
#include "history/view/history_view_schedule_box.h"
|
||||||
|
@ -291,7 +292,9 @@ RepliesWidget::RepliesWidget(
|
||||||
}, _topBar->lifetime());
|
}, _topBar->lifetime());
|
||||||
_topBar->searchRequest(
|
_topBar->searchRequest(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
searchInTopic();
|
if (!preventsClose(crl::guard(this, [=]{ searchInTopic(); }))) {
|
||||||
|
searchInTopic();
|
||||||
|
}
|
||||||
}, _topBar->lifetime());
|
}, _topBar->lifetime());
|
||||||
|
|
||||||
controller->adaptive().value(
|
controller->adaptive().value(
|
||||||
|
@ -338,6 +341,9 @@ RepliesWidget::RepliesWidget(
|
||||||
} else if (!_joinGroup && canSendReply) {
|
} else if (!_joinGroup && canSendReply) {
|
||||||
replyToMessage(to);
|
replyToMessage(to);
|
||||||
_composeControls->focus();
|
_composeControls->focus();
|
||||||
|
if (_composeSearch) {
|
||||||
|
_composeSearch->hideAnimated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, _inner->lifetime());
|
}, _inner->lifetime());
|
||||||
|
|
||||||
|
@ -2005,7 +2011,11 @@ void RepliesWidget::checkActivation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::doSetInnerFocus() {
|
void RepliesWidget::doSetInnerFocus() {
|
||||||
if (!_inner->getSelectedText().rich.text.isEmpty()
|
if (_composeSearch
|
||||||
|
&& _inner->getSelectedText().rich.text.isEmpty()
|
||||||
|
&& _inner->getSelectedItems().empty()) {
|
||||||
|
_composeSearch->setInnerFocus();
|
||||||
|
} else if (!_inner->getSelectedText().rich.text.isEmpty()
|
||||||
|| !_inner->getSelectedItems().empty()
|
|| !_inner->getSelectedItems().empty()
|
||||||
|| !_composeControls->focus()) {
|
|| !_composeControls->focus()) {
|
||||||
_inner->setFocus();
|
_inner->setFocus();
|
||||||
|
@ -2441,6 +2451,16 @@ bool RepliesWidget::listScrollTo(int top, bool syntetic) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::listCancelRequest() {
|
void RepliesWidget::listCancelRequest() {
|
||||||
|
if (_composeSearch) {
|
||||||
|
if (_inner &&
|
||||||
|
(!_inner->getSelectedItems().empty()
|
||||||
|
|| !_inner->getSelectedText().rich.text.isEmpty())) {
|
||||||
|
clearSelected();
|
||||||
|
} else {
|
||||||
|
_composeSearch->hideAnimated();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_inner && !_inner->getSelectedItems().empty()) {
|
if (_inner && !_inner->getSelectedItems().empty()) {
|
||||||
clearSelected();
|
clearSelected();
|
||||||
return;
|
return;
|
||||||
|
@ -2504,6 +2524,9 @@ void RepliesWidget::listSelectionChanged(SelectedItems &&items) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_topBar->showSelected(state);
|
_topBar->showSelected(state);
|
||||||
|
if ((state.count > 0) && _composeSearch) {
|
||||||
|
_composeSearch->hideAnimated();
|
||||||
|
}
|
||||||
if (items.empty()) {
|
if (items.empty()) {
|
||||||
doSetInnerFocus();
|
doSetInnerFocus();
|
||||||
}
|
}
|
||||||
|
@ -2788,7 +2811,9 @@ void RepliesWidget::setupShortcuts() {
|
||||||
}) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
}) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
||||||
using Command = Shortcuts::Command;
|
using Command = Shortcuts::Command;
|
||||||
request->check(Command::Search, 1) && request->handle([=] {
|
request->check(Command::Search, 1) && request->handle([=] {
|
||||||
searchInTopic();
|
if (!preventsClose(crl::guard(this, [=]{ searchInTopic(); }))) {
|
||||||
|
searchInTopic();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
@ -2797,6 +2822,39 @@ void RepliesWidget::setupShortcuts() {
|
||||||
void RepliesWidget::searchInTopic() {
|
void RepliesWidget::searchInTopic() {
|
||||||
if (_topic) {
|
if (_topic) {
|
||||||
controller()->searchInChat(_topic);
|
controller()->searchInChat(_topic);
|
||||||
|
} else {
|
||||||
|
const auto update = [=] {
|
||||||
|
if (_composeSearch) {
|
||||||
|
_composeControls->hide();
|
||||||
|
} else {
|
||||||
|
_composeControls->show();
|
||||||
|
}
|
||||||
|
updateControlsGeometry();
|
||||||
|
};
|
||||||
|
const auto from = (PeerData*)nullptr;
|
||||||
|
_composeSearch = std::make_unique<HistoryView::ComposeSearch>(
|
||||||
|
this,
|
||||||
|
controller(),
|
||||||
|
_history,
|
||||||
|
from);
|
||||||
|
_composeSearch->setTopMsgId(_rootId);
|
||||||
|
|
||||||
|
update();
|
||||||
|
doSetInnerFocus();
|
||||||
|
|
||||||
|
using Activation = HistoryView::ComposeSearch::Activation;
|
||||||
|
_composeSearch->activations(
|
||||||
|
) | rpl::start_with_next([=](Activation activation) {
|
||||||
|
showAtPosition(activation.item->position());
|
||||||
|
}, _composeSearch->lifetime());
|
||||||
|
|
||||||
|
_composeSearch->destroyRequests(
|
||||||
|
) | rpl::take(1) | rpl::start_with_next([=] {
|
||||||
|
_composeSearch = nullptr;
|
||||||
|
|
||||||
|
update();
|
||||||
|
doSetInnerFocus();
|
||||||
|
}, _composeSearch->lifetime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ class Element;
|
||||||
class TopBarWidget;
|
class TopBarWidget;
|
||||||
class RepliesMemento;
|
class RepliesMemento;
|
||||||
class ComposeControls;
|
class ComposeControls;
|
||||||
|
class ComposeSearch;
|
||||||
class SendActionPainter;
|
class SendActionPainter;
|
||||||
class StickerToast;
|
class StickerToast;
|
||||||
class TopicReopenBar;
|
class TopicReopenBar;
|
||||||
|
@ -345,6 +346,7 @@ private:
|
||||||
object_ptr<TopBarWidget> _topBar;
|
object_ptr<TopBarWidget> _topBar;
|
||||||
object_ptr<Ui::PlainShadow> _topBarShadow;
|
object_ptr<Ui::PlainShadow> _topBarShadow;
|
||||||
std::unique_ptr<ComposeControls> _composeControls;
|
std::unique_ptr<ComposeControls> _composeControls;
|
||||||
|
std::unique_ptr<ComposeSearch> _composeSearch;
|
||||||
std::unique_ptr<Ui::FlatButton> _joinGroup;
|
std::unique_ptr<Ui::FlatButton> _joinGroup;
|
||||||
std::unique_ptr<TopicReopenBar> _topicReopenBar;
|
std::unique_ptr<TopicReopenBar> _topicReopenBar;
|
||||||
std::unique_ptr<EmptyPainter> _emptyPainter;
|
std::unique_ptr<EmptyPainter> _emptyPainter;
|
||||||
|
|
|
@ -936,8 +936,7 @@ int TopBarWidget::countSelectedButtonsTop(float64 selectedShown) {
|
||||||
|
|
||||||
void TopBarWidget::updateSearchVisibility() {
|
void TopBarWidget::updateSearchVisibility() {
|
||||||
const auto searchAllowedMode = (_activeChat.section == Section::History)
|
const auto searchAllowedMode = (_activeChat.section == Section::History)
|
||||||
|| (_activeChat.section == Section::Replies
|
|| (_activeChat.section == Section::Replies)
|
||||||
&& _activeChat.key.topic())
|
|
||||||
|| (_activeChat.section == Section::SavedSublist
|
|| (_activeChat.section == Section::SavedSublist
|
||||||
&& _activeChat.key.sublist());
|
&& _activeChat.key.sublist());
|
||||||
_search->setVisible(searchAllowedMode && !_chooseForReportReason);
|
_search->setVisible(searchAllowedMode && !_chooseForReportReason);
|
||||||
|
|
Loading…
Add table
Reference in a new issue