Commit 56ffdbbb authored by Tomaz  Canabrava's avatar Tomaz Canabrava Committed by Kurt Hindenburg
Browse files

Correctly handle selection and opening via clicks

Before we opened a link via mousePress but if we want to make a
selection that will open a file and drag.

Now we check if there is a selection before trying to open something.
So if you click and drag a url, it will not open. If you directly
click and release without dragging, it will open.

FIXED-IN: 20.08

!9
parent a6a726f1
......@@ -1113,6 +1113,11 @@ void Screen::clearSelection()
_selBegin = -1;
}
bool Screen::hasSelection() const
{
return _selBegin != -1;
}
void Screen::getSelectionStart(int& column , int& line) const
{
if (_selTopLeft != -1) {
......
......@@ -454,6 +454,9 @@ public:
/** Clears the current selection */
void clearSelection();
/** Return the selection state */
bool hasSelection() const;
/**
* Returns true if the character at (@p x, @p y) is part of the
* current selection.
......
......@@ -2231,15 +2231,6 @@ void TerminalDisplay::mousePressEvent(QMouseEvent* ev)
} else if (_usesMouseTracking && !_readOnly) {
emit mouseSignal(0, charColumn + 1, charLine + 1 + _scrollBar->value() - _scrollBar->maximum() , 0);
}
if ((_openLinksByDirectClick || ((ev->modifiers() & Qt::ControlModifier) != 0u))) {
auto spot = _filterChain->hotSpotAt(charLine, charColumn);
if ((spot != nullptr) && spot->type() == Filter::HotSpot::Link) {
QObject action;
action.setObjectName(QStringLiteral("open-action"));
spot->activate(&action);
}
}
}
} else if (ev->button() == Qt::MidButton) {
processMidButtonClick(ev);
......@@ -2598,6 +2589,13 @@ void TerminalDisplay::mouseReleaseEvent(QMouseEvent* ev)
charLine + 1 + _scrollBar->value() - _scrollBar->maximum() ,
2);
}
if (!_screenWindow->screen()->hasSelection() && (_openLinksByDirectClick || ((ev->modifiers() & Qt::ControlModifier) != 0u))) {
auto spot = _filterChain->hotSpotAt(charLine, charColumn);
if ((spot != nullptr) && spot->type() == Filter::HotSpot::Link) {
spot->activate();
}
}
}
void TerminalDisplay::getCharacterPosition(const QPoint& widgetPoint, int& line, int& column, bool edge) const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment