From a3cb17299be357e3f13e4db7c1e2ef48f311cfac Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 28 Jul 2022 17:09:30 +0800 Subject: [PATCH] - fix: Drag&Drop no correctly disabled for readonly editors --- NEWS.md | 1 + RedPandaIDE/qsynedit/SynEdit.cpp | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index bcd3cb6e..25759888 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ Red Panda C++ Version 1.1.6 - fix: in #if, defined without () not correctly processed - enhancement: don't show cpp defines when editing c files - enhancement: choose default language when first run + - fix: Drag&Drop no correctly disabled for readonly editors Red Panda C++ Version 1.1.5 diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 44472ca0..c7779592 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -6277,7 +6277,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event) && (mSelectionMode == SynSelectionMode::Normal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { bStartDrag = true; } - if (bStartDrag) { + if (bStartDrag && !mReadOnly) { mStateFlags.setFlag(SynStateFlag::sfWaitForDragging); } else { if (event->modifiers() == Qt::ShiftModifier) { @@ -6285,7 +6285,8 @@ void SynEdit::mousePressEvent(QMouseEvent *event) //code from above and SetBlockEnd will take care of proper invalidation setBlockEnd(caretXY()); } else if (mOptions.testFlag(eoAltSetsColumnMode) && - (mActiveSelectionMode != SynSelectionMode::Line)) { + (mActiveSelectionMode != SynSelectionMode::Line) + && !mReadOnly) { if (event->modifiers() == Qt::AltModifier) setActiveSelectionMode(SynSelectionMode::Column); else @@ -6333,7 +6334,8 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event) QAbstractScrollArea::mouseMoveEvent(event); mMouseMoved = true; Qt::MouseButtons buttons = event->buttons(); - if ((mStateFlags.testFlag(SynStateFlag::sfWaitForDragging))) { + if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging) + && !mReadOnly) { if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) { mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false); QDrag *drag = new QDrag(this); @@ -6344,9 +6346,10 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event) drag->exec(Qt::CopyAction | Qt::MoveAction); } - } else if ((buttons == Qt::LeftButton)) { + } else if (buttons == Qt::LeftButton) { if (mOptions.testFlag(eoAltSetsColumnMode) && - (mActiveSelectionMode != SynSelectionMode::Line)) { + (mActiveSelectionMode != SynSelectionMode::Line) + && !mReadOnly) { if (event->modifiers() == Qt::AltModifier) setActiveSelectionMode(SynSelectionMode::Column); else