diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index 8c0727db0bcb6b..aa81f01fa12286 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -36,6 +36,12 @@ const auto AutoRepeatCommands = base::flat_set{ Command::ChatNext, Command::ChatFirst, Command::ChatLast, + Command::ChatScrollDown, + Command::ChatScrollUp, + Command::ChatScrollScreenDown, + Command::ChatScrollScreenUp, + Command::ChatScrollHalfScreenDown, + Command::ChatScrollHalfScreenUp, }; const auto MediaCommands = base::flat_set{ @@ -73,6 +79,14 @@ const auto CommandByName = base::flat_map{ { u"previous_chat"_q , Command::ChatPrevious }, { u"next_chat"_q , Command::ChatNext }, { u"first_chat"_q , Command::ChatFirst }, + { u"chat_scroll_down"_q , Command::ChatScrollDown }, + { u"chat_scroll_up"_q , Command::ChatScrollUp }, + { u"chat_scroll_screen_down"_q, Command::ChatScrollScreenDown }, + { u"chat_scroll_screen_up"_q , Command::ChatScrollScreenUp }, + { u"chat_scroll_half_screen_down"_q, Command::ChatScrollHalfScreenDown }, + { u"chat_scroll_half_screen_up"_q , Command::ChatScrollHalfScreenUp }, + { u"chat_scroll_top"_q , Command::ChatScrollTop }, + { u"chat_scroll_bottom"_q, Command::ChatScrollBottom }, { u"last_chat"_q , Command::ChatLast }, { u"self_chat"_q , Command::ChatSelf }, @@ -130,6 +144,14 @@ const auto CommandNames = base::flat_map{ { Command::ChatFirst , u"first_chat"_q }, { Command::ChatLast , u"last_chat"_q }, { Command::ChatSelf , u"self_chat"_q }, + { Command::ChatScrollDown , u"chat_scroll_down"_q }, + { Command::ChatScrollUp , u"chat_scroll_up"_q }, + { Command::ChatScrollScreenDown, u"chat_scroll_screen_down"_q }, + { Command::ChatScrollScreenUp , u"chat_scroll_screen_up"_q }, + { Command::ChatScrollHalfScreenDown, u"chat_scroll_half_screen_down"_q }, + { Command::ChatScrollHalfScreenUp , u"chat_scroll_half_screen_up"_q }, + { Command::ChatScrollTop , u"chat_scroll_top"_q }, + { Command::ChatScrollBottom, u"chat_scroll_bottom"_q }, { Command::FolderPrevious , u"previous_folder"_q }, { Command::FolderNext , u"next_folder"_q }, @@ -396,6 +418,9 @@ void Manager::fillDefaults() { set(u"ctrl+pgup"_q, Command::ChatPrevious); set(u"alt+up"_q, Command::ChatPrevious); + set(u"pgup"_q, Command::ChatScrollScreenUp); + set(u"pgdown"_q, Command::ChatScrollScreenDown); + set(u"%1+tab"_q.arg(ctrl), Command::ChatNext); set(u"%1+shift+tab"_q.arg(ctrl), Command::ChatPrevious); set(u"%1+backtab"_q.arg(ctrl), Command::ChatPrevious); diff --git a/Telegram/SourceFiles/core/shortcuts.h b/Telegram/SourceFiles/core/shortcuts.h index 562c54e441b3b2..57ef746c9544bf 100644 --- a/Telegram/SourceFiles/core/shortcuts.h +++ b/Telegram/SourceFiles/core/shortcuts.h @@ -22,6 +22,15 @@ enum class Command { MediaPrevious, MediaNext, + ChatScrollDown, + ChatScrollUp, + ChatScrollScreenDown, + ChatScrollScreenUp, + ChatScrollHalfScreenDown, + ChatScrollHalfScreenUp, + ChatScrollTop, + ChatScrollBottom, + Search, ChatPrevious, diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 2b3696f3519dc8..fdfcffc01826cc 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1963,6 +1963,30 @@ void HistoryWidget::setupShortcuts() { controller()->searchInChat(_history); return true; }); + request->check(Command::ChatScrollUp) && request->handle([=] { + return touchScroll({ 0, _scroll->height() / 10 }); + }); + request->check(Command::ChatScrollDown) && request->handle([=] { + return touchScroll({ 0, -_scroll->height() / 10 }); + }); + request->check(Command::ChatScrollScreenUp) && request->handle([=] { + return touchScroll({ 0, _scroll->height() }); + }); + request->check(Command::ChatScrollScreenDown) && request->handle([=] { + return touchScroll({ 0, -_scroll->height() }); + }); + request->check(Command::ChatScrollHalfScreenUp) && request->handle([=] { + return touchScroll({ 0, _scroll->height() / 2 }); + }); + request->check(Command::ChatScrollHalfScreenDown) && request->handle([=] { + return touchScroll({ 0, -_scroll->height() / 2 }); + }); + request->check(Command::ChatScrollTop) && request->handle([=] { + return touchScroll({ 0, _scroll->scrollTopMax() }); + }); + request->check(Command::ChatScrollBottom) && request->handle([=] { + return touchScroll({ 0, -_scroll->scrollTopMax() }); + }); _canSendMessages && request->check(Command::ShowScheduled, 1) && request->handle([=] { @@ -6742,10 +6766,6 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) { } } else if (e->key() == Qt::Key_Back) { _cancelRequests.fire({}); - } else if (e->key() == Qt::Key_PageDown) { - _scroll->keyPressEvent(e); - } else if (e->key() == Qt::Key_PageUp) { - _scroll->keyPressEvent(e); } else if (e->key() == Qt::Key_Down && !commonModifiers) { _scroll->keyPressEvent(e); } else if (e->key() == Qt::Key_Up && !commonModifiers) {