Add IV triple-click paragraph selection

This commit is contained in:
John Preston
2026-07-01 17:58:15 +04:00
parent 86b9b426e5
commit 13b61fc5c8
2 changed files with 23 additions and 0 deletions
@@ -724,6 +724,8 @@ void MarkdownDocumentWidget::mouseDoubleClickEvent(QMouseEvent *e) {
uint16(_selection.from.offset),
uint16(_selection.to.offset));
}
_tripleClickPoint = e->pos();
_tripleClickTimer.callOnce(QApplication::doubleClickInterval());
setFocus();
updateHover(state);
update();
@@ -1058,6 +1060,7 @@ void MarkdownDocumentWidget::resetSelection() {
_dragExpandedSelection = {};
_selectionClickPreparedLink = std::nullopt;
_dragStartHadSelection = false;
_tripleClickTimer.cancel();
}
void MarkdownDocumentWidget::clearSelection() {
@@ -1211,6 +1214,23 @@ void MarkdownDocumentWidget::dragActionStart(
};
_savedSelectionEndpoints = {};
_dragAction = Selecting;
if (_tripleClickTimer.isActive()
&& (point - _tripleClickPoint).manhattanLength()
< QApplication::startDragDistance()
&& _article->segmentIsText(state.segmentIndex)
&& state.direct
&& state.state.uponSymbol) {
_selectionType = TextSelectType::Paragraphs;
_selection = selectionFromHit(state);
if (_selection.from.segment == _dragSegment
&& _selection.to.segment == _dragSegment) {
_dragExpandedSelection = TextSelection(
uint16(_selection.from.offset),
uint16(_selection.to.offset));
}
_tripleClickPoint = point;
_tripleClickTimer.callOnce(QApplication::doubleClickInterval());
}
update();
}
@@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "iv/markdown/iv_markdown_article.h"
#include "iv/markdown/iv_markdown_view.h"
#include "base/timer.h"
#include "base/unique_qptr.h"
#include "rpl/lifetime.h"
#include "ui/click_handler.h"
@@ -161,6 +162,8 @@ private:
int _dragSegment = -1;
int _dragSymbol = 0;
TextSelection _dragExpandedSelection;
QPoint _tripleClickPoint;
base::Timer _tripleClickTimer;
std::optional<PreparedLink> _selectionClickPreparedLink;
PreparedPlaceholderBlockId _pressedPlaceholderId;
bool _dragStartHadSelection = false;