ui: Set move and select cursors for drag interactions in code view
This commit is contained in:
@@ -471,12 +471,15 @@ void QtCodeArea::mousePressEvent(QMouseEvent* event)
|
||||
if (Qt::KeyboardModifier::ShiftModifier & QApplication::keyboardModifiers())
|
||||
{
|
||||
m_isPanning = true;
|
||||
viewport()->setCursor(Qt::ClosedHandCursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isSelecting = true;
|
||||
QTextCursor cursor = this->cursorForPosition(event->pos());
|
||||
setCursor(cursor);
|
||||
setNewTextCursor(cursor);
|
||||
|
||||
viewport()->setCursor(Qt::IBeamCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -489,6 +492,8 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
||||
m_isSelecting = false;
|
||||
m_isPanning = false;
|
||||
|
||||
viewport()->setCursor(Qt::ArrowCursor);
|
||||
|
||||
if (m_panningDistance < panningThreshold) // dont do anything if mouse is release to end some real panning action.
|
||||
{
|
||||
if (Qt::KeyboardModifier::ControlModifier & QApplication::keyboardModifiers())
|
||||
@@ -527,7 +532,7 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
cursor.setPosition(this->cursorForPosition(event->pos()).position(), QTextCursor::KeepAnchor);
|
||||
setCursor(cursor);
|
||||
setNewTextCursor(cursor);
|
||||
}
|
||||
else if (m_isPanning)
|
||||
{
|
||||
@@ -612,10 +617,10 @@ void QtCodeArea::clearSelection()
|
||||
QTextCursor cursor = textCursor();
|
||||
cursor.clearSelection();
|
||||
|
||||
setCursor(cursor);
|
||||
setNewTextCursor(cursor);
|
||||
}
|
||||
|
||||
void QtCodeArea::setCursor(const QTextCursor& cursor)
|
||||
void QtCodeArea::setNewTextCursor(const QTextCursor& cursor)
|
||||
{
|
||||
int horizontalValue = horizontalScrollBar()->value();
|
||||
int verticalValue = verticalScrollBar()->value();
|
||||
|
||||
@@ -109,7 +109,7 @@ private slots:
|
||||
void updateLineNumberAreaWidth(int newBlockCount = 0);
|
||||
void updateLineNumberArea(const QRect&, int);
|
||||
void clearSelection();
|
||||
void setCursor(const QTextCursor& cursor);
|
||||
void setNewTextCursor(const QTextCursor& cursor);
|
||||
void setIDECursorPosition();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user