mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Enter selects from-row in reply-in-another-chat.
This commit is contained in:
parent
0045eb4598
commit
d157eb0b6e
3 changed files with 33 additions and 4 deletions
|
@ -474,7 +474,7 @@ void PeerListBox::addSelectItem(
|
|||
void PeerListBox::addSelectItem(
|
||||
uint64 itemId,
|
||||
const QString &text,
|
||||
Ui::MultiSelect::PaintRoundImage paintUserpic,
|
||||
PaintRoundImageCallback paintUserpic,
|
||||
anim::type animated) {
|
||||
if (!_select) {
|
||||
createMultiSelect();
|
||||
|
@ -549,6 +549,10 @@ rpl::producer<int> PeerListBox::multiSelectHeightValue() const {
|
|||
return _select ? _select->heightValue() : rpl::single(0);
|
||||
}
|
||||
|
||||
rpl::producer<> PeerListBox::noSearchSubmits() const {
|
||||
return content()->noSearchSubmits();
|
||||
}
|
||||
|
||||
PeerListRow::PeerListRow(not_null<PeerData*> peer)
|
||||
: PeerListRow(peer, peer->id.value) {
|
||||
}
|
||||
|
@ -2189,6 +2193,9 @@ bool PeerListContent::submitted() {
|
|||
_controller->rowClicked(row);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
_noSearchSubmits.fire({});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -712,7 +712,7 @@ public:
|
|||
update();
|
||||
}
|
||||
|
||||
std::unique_ptr<PeerListState> saveState() const;
|
||||
[[nodiscard]] std::unique_ptr<PeerListState> saveState() const;
|
||||
void restoreState(std::unique_ptr<PeerListState> state);
|
||||
|
||||
void showRowMenu(
|
||||
|
@ -720,10 +720,14 @@ public:
|
|||
bool highlightRow,
|
||||
Fn<void(not_null<Ui::PopupMenu*>)> destroyed);
|
||||
|
||||
auto scrollToRequests() const {
|
||||
[[nodiscard]] auto scrollToRequests() const {
|
||||
return _scrollToRequests.events();
|
||||
}
|
||||
|
||||
[[nodiscard]] auto noSearchSubmits() const {
|
||||
return _noSearchSubmits.events();
|
||||
}
|
||||
|
||||
~PeerListContent();
|
||||
|
||||
protected:
|
||||
|
@ -890,6 +894,8 @@ private:
|
|||
object_ptr<Ui::FlatLabel> _searchLoading = { nullptr };
|
||||
object_ptr<Ui::RpWidget> _loadingAnimation = { nullptr };
|
||||
|
||||
rpl::event_stream<> _noSearchSubmits;
|
||||
|
||||
std::vector<std::unique_ptr<PeerListRow>> _searchRows;
|
||||
base::Timer _repaintByStatus;
|
||||
base::unique_qptr<Ui::PopupMenu> _contextMenu;
|
||||
|
@ -1106,6 +1112,7 @@ public:
|
|||
[[nodiscard]] std::vector<PeerListRowId> collectSelectedIds();
|
||||
[[nodiscard]] std::vector<not_null<PeerData*>> collectSelectedRows();
|
||||
[[nodiscard]] rpl::producer<int> multiSelectHeightValue() const;
|
||||
[[nodiscard]] rpl::producer<> noSearchSubmits() const;
|
||||
|
||||
void peerListSetTitle(rpl::producer<QString> title) override {
|
||||
setTitle(std::move(title));
|
||||
|
|
|
@ -917,6 +917,7 @@ void DraftOptionsBox(
|
|||
struct AuthorSelector {
|
||||
object_ptr<Ui::RpWidget> content = { nullptr };
|
||||
Fn<bool(int, int, int)> overrideKey;
|
||||
Fn<void()> activate;
|
||||
};
|
||||
[[nodiscard]] AuthorSelector AuthorRowSelector(
|
||||
not_null<Main::Session*> session,
|
||||
|
@ -975,12 +976,15 @@ struct AuthorSelector {
|
|||
tr::lng_reply_in_author()));
|
||||
Ui::AddSkip(container);
|
||||
|
||||
const auto activate = [=] {
|
||||
chosen(from->owner().history(from));
|
||||
};
|
||||
const auto delegate = container->lifetime().make_state<
|
||||
PeerListContentDelegateSimple
|
||||
>();
|
||||
const auto controller = container->lifetime().make_state<
|
||||
AuthorController
|
||||
>(from, [=] { chosen(from->owner().history(from)); });
|
||||
>(from, activate);
|
||||
controller->setStyleOverrides(&st::peerListSingleRow);
|
||||
const auto content = container->add(object_ptr<PeerListContent>(
|
||||
container,
|
||||
|
@ -1021,6 +1025,7 @@ struct AuthorSelector {
|
|||
return {
|
||||
.content = std::move(result),
|
||||
.overrideKey = overrideKey,
|
||||
.activate = activate,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1051,6 +1056,12 @@ void ShowReplyToChatBox(
|
|||
}
|
||||
}
|
||||
|
||||
void noSearchSubmit() {
|
||||
if (const auto onstack = _authorRow.activate) {
|
||||
onstack();
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] rpl::producer<Chosen> singleChosen() const {
|
||||
return _singleChosen.events();
|
||||
}
|
||||
|
@ -1094,6 +1105,10 @@ void ShowReplyToChatBox(
|
|||
auto box = Box<PeerListBox>(std::move(controller), [=](
|
||||
not_null<PeerListBox*> box) {
|
||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||
|
||||
box->noSearchSubmits() | rpl::start_with_next([=] {
|
||||
controllerRaw->noSearchSubmit();
|
||||
}, box->lifetime());
|
||||
});
|
||||
const auto boxRaw = box.data();
|
||||
show->show(std::move(box));
|
||||
|
|
Loading…
Add table
Reference in a new issue