diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2020-12-15 00:17:44 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2020-12-15 00:17:56 +0100 |
commit | b8ce9d543d730b912245015591cfa2cb892af657 (patch) | |
tree | 5cf860a56376f26eb17e491e26d663c47be2ba1e /src | |
parent | Background color for code and don't collapse space in timeline (diff) | |
download | nheko-b8ce9d543d730b912245015591cfa2cb892af657.tar.xz |
Fix scrolling the room list using touch
Diffstat (limited to 'src')
-rw-r--r-- | src/RoomInfoListItem.cpp | 44 | ||||
-rw-r--r-- | src/RoomList.cpp | 2 |
2 files changed, 24 insertions, 22 deletions
diff --git a/src/RoomInfoListItem.cpp b/src/RoomInfoListItem.cpp index 985ab1b9..0acfcc90 100644 --- a/src/RoomInfoListItem.cpp +++ b/src/RoomInfoListItem.cpp @@ -484,37 +484,37 @@ RoomInfoListItem::mousePressEvent(QMouseEvent *event) if (event->buttons() == Qt::RightButton) { QWidget::mousePressEvent(event); return; - } - - if (roomType_ == RoomType::Invited) { - const auto point = event->pos(); + } else if (event->buttons() == Qt::LeftButton) { + if (roomType_ == RoomType::Invited) { + const auto point = event->pos(); - if (acceptBtnRegion_.contains(point)) - emit acceptInvite(roomId_); + if (acceptBtnRegion_.contains(point)) + emit acceptInvite(roomId_); - if (declineBtnRegion_.contains(point)) - emit declineInvite(roomId_); + if (declineBtnRegion_.contains(point)) + emit declineInvite(roomId_); - return; - } + return; + } - emit clicked(roomId_); + emit clicked(roomId_); - setPressedState(true); + setPressedState(true); - // Ripple on mouse position by default. - QPoint pos = event->pos(); - qreal radiusEndValue = static_cast<qreal>(width()) / 3; + // Ripple on mouse position by default. + QPoint pos = event->pos(); + qreal radiusEndValue = static_cast<qreal>(width()) / 3; - Ripple *ripple = new Ripple(pos); + Ripple *ripple = new Ripple(pos); - ripple->setRadiusEndValue(radiusEndValue); - ripple->setOpacityStartValue(0.15); - ripple->setColor(QColor("white")); - ripple->radiusAnimation()->setDuration(200); - ripple->opacityAnimation()->setDuration(400); + ripple->setRadiusEndValue(radiusEndValue); + ripple->setOpacityStartValue(0.15); + ripple->setColor(QColor("white")); + ripple->radiusAnimation()->setDuration(200); + ripple->opacityAnimation()->setDuration(400); - ripple_overlay_->addRipple(ripple); + ripple_overlay_->addRipple(ripple); + } } void diff --git a/src/RoomList.cpp b/src/RoomList.cpp index 8c9e296f..aab89491 100644 --- a/src/RoomList.cpp +++ b/src/RoomList.cpp @@ -45,8 +45,10 @@ RoomList::RoomList(QSharedPointer<UserSettings> userSettings, QWidget *parent) scrollArea_->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); scrollArea_->setWidgetResizable(true); scrollArea_->setAlignment(Qt::AlignLeading | Qt::AlignTop | Qt::AlignVCenter); + scrollArea_->setAttribute(Qt::WA_AcceptTouchEvents); QScroller::grabGesture(scrollArea_, QScroller::TouchGesture); + QScroller::grabGesture(scrollArea_, QScroller::LeftMouseButtonGesture); // The scrollbar on macOS will hide itself when not active so it won't interfere // with the content. |