diff --git a/Telegram/SourceFiles/iv/markdown/iv_markdown_view_widget.cpp b/Telegram/SourceFiles/iv/markdown/iv_markdown_view_widget.cpp index 29e752c9a8..1994121e72 100644 --- a/Telegram/SourceFiles/iv/markdown/iv_markdown_view_widget.cpp +++ b/Telegram/SourceFiles/iv/markdown/iv_markdown_view_widget.cpp @@ -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(); } diff --git a/Telegram/SourceFiles/iv/markdown/iv_markdown_view_widget.h b/Telegram/SourceFiles/iv/markdown/iv_markdown_view_widget.h index fbb8716f5a..fb65637885 100644 --- a/Telegram/SourceFiles/iv/markdown/iv_markdown_view_widget.h +++ b/Telegram/SourceFiles/iv/markdown/iv_markdown_view_widget.h @@ -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 _selectionClickPreparedLink; PreparedPlaceholderBlockId _pressedPlaceholderId; bool _dragStartHadSelection = false;