Fixed double clicking sometimes turning into unwanted triple-clicking.

This commit is contained in:
Cranken 2018-10-06 17:15:38 +02:00 committed by pajlada
parent 39ee6efffc
commit f13f99bb42

View file

@ -1018,7 +1018,6 @@ void ChannelView::mousePressEvent(QMouseEvent *event)
if (!tryGetMessageAt(event->pos(), layout, relativePos, messageIndex)) {
setCursor(Qt::ArrowCursor);
auto messagesSnapshot = this->getMessagesSnapshot();
if (messagesSnapshot.getLength() == 0) {
return;
@ -1072,18 +1071,19 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
if (event->button() == Qt::LeftButton) {
this->dCSelection_.selectingLeft = this->dCSelection_.selectingRight =
false;
if (this->isMouseDown_) {
this->isMouseDown_ = false;
if (fabsf(distanceBetweenPoints(this->lastPressPosition_,
event->screenPos())) > 15.f) {
return;
}
} else if (this->isDoubleClick_) {
if (this->isDoubleClick_) {
this->isDoubleClick_ = false;
// Was actually not a wanted triple-click
if (fabsf(distanceBetweenPoints(this->lastDClickPosition_,
event->screenPos())) > 10.f) {
this->clickTimer_->stop();
return;
}
} else if (this->isMouseDown_) {
this->isMouseDown_ = false;
if (fabsf(distanceBetweenPoints(this->lastPressPosition_,
event->screenPos())) > 15.f) {
return;
}
} else {
@ -1104,7 +1104,6 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
// not left or right button
return;
}
// find message
this->layoutMessages();
@ -1129,11 +1128,13 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
const MessageLayoutElement *hoverLayoutElement =
layout->getElementAt(relativePos);
// Triple-clicking a message selects the whole message
if (this->clickTimer_->isActive() && this->selecting_) {
if (fabsf(distanceBetweenPoints(this->lastDClickPosition_,
event->screenPos())) < 10.f) {
this->selectWholeMessage(layout.get(), messageIndex);
}
}
if (hoverLayoutElement == nullptr) {
return;