mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
parent
388325a496
commit
ac7b2e0da0
7 changed files with 39 additions and 8 deletions
|
@ -480,6 +480,11 @@ void Item::setupHistory() {
|
|||
using Type = Ui::ElasticScroll::OverscrollType;
|
||||
_scroll->setOverscrollTypes(Type::Real, Type::Real);
|
||||
|
||||
_inner->scrollKeyEvents(
|
||||
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
||||
_scroll->keyPressEvent(e);
|
||||
}, lifetime());
|
||||
|
||||
_scroll->events() | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||
if (e->type() == QEvent::MouseButtonDblClick) {
|
||||
const auto button = static_cast<QMouseEvent*>(e.get())->button();
|
||||
|
|
|
@ -2604,7 +2604,11 @@ auto ListWidget::countScrollState() const -> ScrollTopState {
|
|||
}
|
||||
|
||||
void ListWidget::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Back) {
|
||||
const auto key = e->key();
|
||||
const auto hasModifiers = (Qt::NoModifier !=
|
||||
(e->modifiers()
|
||||
& ~(Qt::KeypadModifier | Qt::GroupSwitchModifier)));
|
||||
if (key == Qt::Key_Escape || key == Qt::Key_Back) {
|
||||
if (hasSelectedText() || hasSelectedItems()) {
|
||||
cancelSelection();
|
||||
} else {
|
||||
|
@ -2616,22 +2620,33 @@ void ListWidget::keyPressEvent(QKeyEvent *e) {
|
|||
&& !hasCopyRestrictionForSelected()) {
|
||||
TextUtilities::SetClipboardText(getSelectedText());
|
||||
#ifdef Q_OS_MAC
|
||||
} else if (e->key() == Qt::Key_E
|
||||
} else if (key == Qt::Key_E
|
||||
&& e->modifiers().testFlag(Qt::ControlModifier)
|
||||
&& !showCopyRestriction()
|
||||
&& !hasCopyRestrictionForSelected()) {
|
||||
TextUtilities::SetClipboardText(getSelectedText(), QClipboard::FindBuffer);
|
||||
#endif // Q_OS_MAC
|
||||
} else if (e == QKeySequence::Delete || e->key() == Qt::Key_Backspace) {
|
||||
} else if (e == QKeySequence::Delete || key == Qt::Key_Backspace) {
|
||||
_delegate->listDeleteRequest();
|
||||
} else if (!hasModifiers
|
||||
&& ((key == Qt::Key_Up)
|
||||
|| (key == Qt::Key_Down)
|
||||
|| (key == Qt::Key_PageUp)
|
||||
|| (key == Qt::Key_PageDown))) {
|
||||
_scrollKeyEvents.fire(std::move(e));
|
||||
} else if (!(e->modifiers() & ~Qt::ShiftModifier)
|
||||
&& e->key() != Qt::Key_Shift) {
|
||||
&& key != Qt::Key_Shift) {
|
||||
_delegate->listTryProcessKeyInput(e);
|
||||
} else {
|
||||
e->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
auto ListWidget::scrollKeyEvents() const
|
||||
-> rpl::producer<not_null<QKeyEvent*>> {
|
||||
return _scrollKeyEvents.events();
|
||||
}
|
||||
|
||||
void ListWidget::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
mouseActionStart(e->globalPos(), e->button());
|
||||
trySwitchToWordSelection();
|
||||
|
|
|
@ -382,6 +382,10 @@ public:
|
|||
const TextState &reactionState) const;
|
||||
void toggleFavoriteReaction(not_null<Element*> view) const;
|
||||
|
||||
|
||||
[[nodiscard]] auto scrollKeyEvents() const
|
||||
-> rpl::producer<not_null<QKeyEvent*>>;
|
||||
|
||||
// ElementDelegate interface.
|
||||
Context elementContext() override;
|
||||
bool elementUnderCursor(not_null<const Element*> view) override;
|
||||
|
@ -851,6 +855,7 @@ private:
|
|||
rpl::event_stream<ReplyToMessageRequest> _requestedToReplyToMessage;
|
||||
rpl::event_stream<FullMsgId> _requestedToReadMessage;
|
||||
rpl::event_stream<FullMsgId> _requestedToShowMessage;
|
||||
rpl::event_stream<not_null<QKeyEvent*>> _scrollKeyEvents;
|
||||
|
||||
rpl::lifetime _viewerLifetime;
|
||||
|
||||
|
|
|
@ -797,7 +797,9 @@ void RepliesWidget::setupComposeControls() {
|
|||
}
|
||||
}, lifetime());
|
||||
|
||||
_composeControls->scrollKeyEvents(
|
||||
rpl::merge(
|
||||
_composeControls->scrollKeyEvents(),
|
||||
_inner->scrollKeyEvents()
|
||||
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
||||
_scroll->keyPressEvent(e);
|
||||
}, lifetime());
|
||||
|
|
|
@ -378,7 +378,9 @@ void ScheduledWidget::setupComposeControls() {
|
|||
}
|
||||
}, lifetime());
|
||||
|
||||
_composeControls->scrollKeyEvents(
|
||||
rpl::merge(
|
||||
_composeControls->scrollKeyEvents(),
|
||||
_inner->scrollKeyEvents()
|
||||
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
||||
_scroll->keyPressEvent(e);
|
||||
}, lifetime());
|
||||
|
|
|
@ -715,7 +715,9 @@ void ShortcutMessages::setupComposeControls() {
|
|||
}
|
||||
}, lifetime());
|
||||
|
||||
_composeControls->scrollKeyEvents(
|
||||
rpl::merge(
|
||||
_composeControls->scrollKeyEvents(),
|
||||
_inner->scrollKeyEvents()
|
||||
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
||||
_scroll->keyPressEvent(e);
|
||||
}, lifetime());
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6ce5ec6e43a28678ca89fd89b2fa90164e5bcef1
|
||||
Subproject commit 4ae0ffe56efb20f795062713780c79e79cd39879
|
Loading…
Add table
Reference in a new issue