mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 22:46:10 +00:00
Show preview on Force-Click on macOS.
This commit is contained in:
@@ -332,6 +332,11 @@ InnerWidget::InnerWidget(
|
||||
switchToFilter(filterId);
|
||||
}, lifetime());
|
||||
|
||||
_controller->window().widget()->globalForceClicks(
|
||||
) | rpl::start_with_next([=](QPoint globalPosition) {
|
||||
processGlobalForceClick(globalPosition);
|
||||
}, lifetime());
|
||||
|
||||
session().data().stories().incrementPreloadingMainSources();
|
||||
|
||||
handleChatListEntryRefreshes();
|
||||
@@ -1424,6 +1429,16 @@ void InnerWidget::selectByMouse(QPoint globalPosition) {
|
||||
}
|
||||
}
|
||||
|
||||
void InnerWidget::processGlobalForceClick(QPoint globalPosition) {
|
||||
const auto parent = parentWidget();
|
||||
if (_pressButton == Qt::LeftButton
|
||||
&& parent->rect().contains(parent->mapFromGlobal(globalPosition))
|
||||
&& pressShowsPreview(false)) {
|
||||
_chatPreviewWillBeFor = computeChosenRow().key;
|
||||
showChatPreview(false);
|
||||
}
|
||||
}
|
||||
|
||||
void InnerWidget::mousePressEvent(QMouseEvent *e) {
|
||||
selectByMouse(e->globalPos());
|
||||
|
||||
@@ -1761,6 +1776,7 @@ void InnerWidget::mousePressReleased(
|
||||
Qt::MouseButton button,
|
||||
Qt::KeyboardModifiers modifiers) {
|
||||
_chatPreviewTimer.cancel();
|
||||
_pressButton = Qt::NoButton;
|
||||
|
||||
auto wasDragging = (_dragging != nullptr);
|
||||
if (wasDragging) {
|
||||
@@ -3598,8 +3614,11 @@ ChosenRow InnerWidget::computeChosenRow() const {
|
||||
|
||||
bool InnerWidget::isUserpicPress() const {
|
||||
return (_lastRowLocalMouseX >= 0)
|
||||
&& (_lastRowLocalMouseX < _st->nameLeft)
|
||||
&& (width() > _narrowWidth);
|
||||
&& (_lastRowLocalMouseX < _st->nameLeft);
|
||||
}
|
||||
|
||||
bool InnerWidget::isUserpicPressOnWide() const {
|
||||
return isUserpicPress() && (width() > _narrowWidth);
|
||||
}
|
||||
|
||||
bool InnerWidget::pressShowsPreview(bool onlyUserpic) const {
|
||||
@@ -3625,7 +3644,7 @@ bool InnerWidget::chooseRow(
|
||||
ChosenRow row,
|
||||
Qt::KeyboardModifiers modifiers) {
|
||||
row.newWindow = (modifiers & Qt::ControlModifier);
|
||||
row.userpicClick = isUserpicPress();
|
||||
row.userpicClick = isUserpicPressOnWide();
|
||||
return row;
|
||||
};
|
||||
auto chosen = modifyChosenRow(computeChosenRow(), modifiers);
|
||||
|
Reference in New Issue
Block a user