Added ability to attach file with shortcut in sections.

This commit is contained in:
23rd 2021-01-31 07:33:24 +03:00 committed by John Preston
parent 062c451c27
commit 0b98cfbfec
2 changed files with 10 additions and 2 deletions

View file

@ -768,8 +768,10 @@ rpl::producer<MessageToEdit> ComposeControls::editRequests() const {
}
rpl::producer<> ComposeControls::attachRequests() const {
return _attachToggle->clicks(
) | rpl::to_empty | rpl::filter([=] {
return rpl::merge(
_attachToggle->clicks() | rpl::to_empty,
_attachRequests.events()
) | rpl::filter([=] {
if (isEditingMessage()) {
Ui::show(Box<InformBox>(tr::lng_edit_caption_attach(tr::now)));
return false;
@ -1057,6 +1059,11 @@ void ComposeControls::initKeyHandler() {
}) | rpl::start_with_next([=](not_null<QEvent*> e) {
auto keyEvent = static_cast<QKeyEvent*>(e.get());
const auto key = keyEvent->key();
const auto isCtrl = keyEvent->modifiers() == Qt::ControlModifier;
if (key == Qt::Key_O && isCtrl) {
_attachRequests.fire({});
return;
}
if (key == Qt::Key_Up) {
if (!isEditingMessage()) {
_editLastMessageRequests.fire(std::move(keyEvent));

View file

@ -296,6 +296,7 @@ private:
rpl::event_stream<QString> _sendCommandRequests;
rpl::event_stream<not_null<QKeyEvent*>> _scrollKeyEvents;
rpl::event_stream<not_null<QKeyEvent*>> _editLastMessageRequests;
rpl::event_stream<> _attachRequests;
TextUpdateEvents _textUpdateEvents = TextUpdateEvents()
| TextUpdateEvent::SaveDraft