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

https://invent.kde.org/utilities/konsole/-/merge_requests/9
wilder-portage
Tomaz Canabrava 6 years ago committed by Kurt Hindenburg
parent a6a726f150
commit 56ffdbbb29
  1. 5
      src/Screen.cpp
  2. 3
      src/Screen.h
  3. 16
      src/TerminalDisplay.cpp

@ -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

Loading…
Cancel
Save