- fix: Drag&Drop no correctly disabled for readonly editors

This commit is contained in:
Roy Qu 2022-07-28 17:09:30 +08:00
parent 8bd2802c99
commit a3cb17299b
2 changed files with 9 additions and 5 deletions

View File

@ -5,6 +5,7 @@ Red Panda C++ Version 1.1.6
- fix: in #if, defined without () not correctly processed - fix: in #if, defined without () not correctly processed
- enhancement: don't show cpp defines when editing c files - enhancement: don't show cpp defines when editing c files
- enhancement: choose default language when first run - enhancement: choose default language when first run
- fix: Drag&Drop no correctly disabled for readonly editors
Red Panda C++ Version 1.1.5 Red Panda C++ Version 1.1.5

View File

@ -6277,7 +6277,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event)
&& (mSelectionMode == SynSelectionMode::Normal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { && (mSelectionMode == SynSelectionMode::Normal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) {
bStartDrag = true; bStartDrag = true;
} }
if (bStartDrag) { if (bStartDrag && !mReadOnly) {
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging); mStateFlags.setFlag(SynStateFlag::sfWaitForDragging);
} else { } else {
if (event->modifiers() == Qt::ShiftModifier) { 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 //code from above and SetBlockEnd will take care of proper invalidation
setBlockEnd(caretXY()); setBlockEnd(caretXY());
} else if (mOptions.testFlag(eoAltSetsColumnMode) && } else if (mOptions.testFlag(eoAltSetsColumnMode) &&
(mActiveSelectionMode != SynSelectionMode::Line)) { (mActiveSelectionMode != SynSelectionMode::Line)
&& !mReadOnly) {
if (event->modifiers() == Qt::AltModifier) if (event->modifiers() == Qt::AltModifier)
setActiveSelectionMode(SynSelectionMode::Column); setActiveSelectionMode(SynSelectionMode::Column);
else else
@ -6333,7 +6334,8 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
QAbstractScrollArea::mouseMoveEvent(event); QAbstractScrollArea::mouseMoveEvent(event);
mMouseMoved = true; mMouseMoved = true;
Qt::MouseButtons buttons = event->buttons(); Qt::MouseButtons buttons = event->buttons();
if ((mStateFlags.testFlag(SynStateFlag::sfWaitForDragging))) { if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging)
&& !mReadOnly) {
if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) { if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) {
mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false); mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false);
QDrag *drag = new QDrag(this); QDrag *drag = new QDrag(this);
@ -6344,9 +6346,10 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event)
drag->exec(Qt::CopyAction | Qt::MoveAction); drag->exec(Qt::CopyAction | Qt::MoveAction);
} }
} else if ((buttons == Qt::LeftButton)) { } else if (buttons == Qt::LeftButton) {
if (mOptions.testFlag(eoAltSetsColumnMode) && if (mOptions.testFlag(eoAltSetsColumnMode) &&
(mActiveSelectionMode != SynSelectionMode::Line)) { (mActiveSelectionMode != SynSelectionMode::Line)
&& !mReadOnly) {
if (event->modifiers() == Qt::AltModifier) if (event->modifiers() == Qt::AltModifier)
setActiveSelectionMode(SynSelectionMode::Column); setActiveSelectionMode(SynSelectionMode::Column);
else else