mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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;
|
using Type = Ui::ElasticScroll::OverscrollType;
|
||||||
_scroll->setOverscrollTypes(Type::Real, Type::Real);
|
_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) {
|
_scroll->events() | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||||
if (e->type() == QEvent::MouseButtonDblClick) {
|
if (e->type() == QEvent::MouseButtonDblClick) {
|
||||||
const auto button = static_cast<QMouseEvent*>(e.get())->button();
|
const auto button = static_cast<QMouseEvent*>(e.get())->button();
|
||||||
|
|
|
@ -2604,7 +2604,11 @@ auto ListWidget::countScrollState() const -> ScrollTopState {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListWidget::keyPressEvent(QKeyEvent *e) {
|
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()) {
|
if (hasSelectedText() || hasSelectedItems()) {
|
||||||
cancelSelection();
|
cancelSelection();
|
||||||
} else {
|
} else {
|
||||||
|
@ -2616,22 +2620,33 @@ void ListWidget::keyPressEvent(QKeyEvent *e) {
|
||||||
&& !hasCopyRestrictionForSelected()) {
|
&& !hasCopyRestrictionForSelected()) {
|
||||||
TextUtilities::SetClipboardText(getSelectedText());
|
TextUtilities::SetClipboardText(getSelectedText());
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
} else if (e->key() == Qt::Key_E
|
} else if (key == Qt::Key_E
|
||||||
&& e->modifiers().testFlag(Qt::ControlModifier)
|
&& e->modifiers().testFlag(Qt::ControlModifier)
|
||||||
&& !showCopyRestriction()
|
&& !showCopyRestriction()
|
||||||
&& !hasCopyRestrictionForSelected()) {
|
&& !hasCopyRestrictionForSelected()) {
|
||||||
TextUtilities::SetClipboardText(getSelectedText(), QClipboard::FindBuffer);
|
TextUtilities::SetClipboardText(getSelectedText(), QClipboard::FindBuffer);
|
||||||
#endif // Q_OS_MAC
|
#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();
|
_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)
|
} else if (!(e->modifiers() & ~Qt::ShiftModifier)
|
||||||
&& e->key() != Qt::Key_Shift) {
|
&& key != Qt::Key_Shift) {
|
||||||
_delegate->listTryProcessKeyInput(e);
|
_delegate->listTryProcessKeyInput(e);
|
||||||
} else {
|
} else {
|
||||||
e->ignore();
|
e->ignore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto ListWidget::scrollKeyEvents() const
|
||||||
|
-> rpl::producer<not_null<QKeyEvent*>> {
|
||||||
|
return _scrollKeyEvents.events();
|
||||||
|
}
|
||||||
|
|
||||||
void ListWidget::mouseDoubleClickEvent(QMouseEvent *e) {
|
void ListWidget::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||||
mouseActionStart(e->globalPos(), e->button());
|
mouseActionStart(e->globalPos(), e->button());
|
||||||
trySwitchToWordSelection();
|
trySwitchToWordSelection();
|
||||||
|
|
|
@ -382,6 +382,10 @@ public:
|
||||||
const TextState &reactionState) const;
|
const TextState &reactionState) const;
|
||||||
void toggleFavoriteReaction(not_null<Element*> view) const;
|
void toggleFavoriteReaction(not_null<Element*> view) const;
|
||||||
|
|
||||||
|
|
||||||
|
[[nodiscard]] auto scrollKeyEvents() const
|
||||||
|
-> rpl::producer<not_null<QKeyEvent*>>;
|
||||||
|
|
||||||
// ElementDelegate interface.
|
// ElementDelegate interface.
|
||||||
Context elementContext() override;
|
Context elementContext() override;
|
||||||
bool elementUnderCursor(not_null<const Element*> view) override;
|
bool elementUnderCursor(not_null<const Element*> view) override;
|
||||||
|
@ -851,6 +855,7 @@ private:
|
||||||
rpl::event_stream<ReplyToMessageRequest> _requestedToReplyToMessage;
|
rpl::event_stream<ReplyToMessageRequest> _requestedToReplyToMessage;
|
||||||
rpl::event_stream<FullMsgId> _requestedToReadMessage;
|
rpl::event_stream<FullMsgId> _requestedToReadMessage;
|
||||||
rpl::event_stream<FullMsgId> _requestedToShowMessage;
|
rpl::event_stream<FullMsgId> _requestedToShowMessage;
|
||||||
|
rpl::event_stream<not_null<QKeyEvent*>> _scrollKeyEvents;
|
||||||
|
|
||||||
rpl::lifetime _viewerLifetime;
|
rpl::lifetime _viewerLifetime;
|
||||||
|
|
||||||
|
|
|
@ -797,7 +797,9 @@ void RepliesWidget::setupComposeControls() {
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_composeControls->scrollKeyEvents(
|
rpl::merge(
|
||||||
|
_composeControls->scrollKeyEvents(),
|
||||||
|
_inner->scrollKeyEvents()
|
||||||
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
||||||
_scroll->keyPressEvent(e);
|
_scroll->keyPressEvent(e);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
|
@ -378,7 +378,9 @@ void ScheduledWidget::setupComposeControls() {
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_composeControls->scrollKeyEvents(
|
rpl::merge(
|
||||||
|
_composeControls->scrollKeyEvents(),
|
||||||
|
_inner->scrollKeyEvents()
|
||||||
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
||||||
_scroll->keyPressEvent(e);
|
_scroll->keyPressEvent(e);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
|
@ -715,7 +715,9 @@ void ShortcutMessages::setupComposeControls() {
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
_composeControls->scrollKeyEvents(
|
rpl::merge(
|
||||||
|
_composeControls->scrollKeyEvents(),
|
||||||
|
_inner->scrollKeyEvents()
|
||||||
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
) | rpl::start_with_next([=](not_null<QKeyEvent*> e) {
|
||||||
_scroll->keyPressEvent(e);
|
_scroll->keyPressEvent(e);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6ce5ec6e43a28678ca89fd89b2fa90164e5bcef1
|
Subproject commit 4ae0ffe56efb20f795062713780c79e79cd39879
|
Loading…
Add table
Reference in a new issue