From 6d3597db29c7d2d653d11362e7ce9825a5ec9f66 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 12 Sep 2024 22:13:41 +0800 Subject: [PATCH] - fix: While Control is pressed, can't start Drag&Drop by mouse. --- NEWS.md | 3 +- RedPandaIDE/editor.cpp | 47 +++++++++++------------------ RedPandaIDE/editor.h | 29 +++++------------- libs/qsynedit/qsynedit/qsynedit.cpp | 1 - 4 files changed, 26 insertions(+), 54 deletions(-) diff --git a/NEWS.md b/NEWS.md index 26762df1..36cc3693 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,12 +1,13 @@ Red Panda C++ Version 3.2 - - Change: The way to calcuate astyle path. + - change: The way to calcuate astyle path. - fix: Scroll bar arrow size not correct in the dark themes. - fix: Don't auto scroll to the caret after undo/redo. - fix: "bits/stdc++" is not openned in readonly mode. - fix: astyle path error when reformat. - fix: Slow when paste/replace bulk contents. - fix: Crash in windows 7. + - fix: While Control is pressed, can't start Drag&Drop by mouse. Red Panda C++ Version 3.1 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 0421bd9e..1478f72a 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1169,7 +1169,7 @@ void Editor::keyReleaseEvent(QKeyEvent *event) void Editor::mouseMoveEvent(QMouseEvent *event) { - if(event->modifiers() == Qt::ControlModifier) { + if(event->modifiers() == Qt::ControlModifier && !selAvail()) { cancelHint(); QSynedit::BufferCoord p; @@ -1185,7 +1185,6 @@ void Editor::mouseMoveEvent(QMouseEvent *event) } return; } - QSynedit::QSynEdit::mouseMoveEvent(event); } @@ -1486,24 +1485,22 @@ void Editor::mouseReleaseEvent(QMouseEvent *event) { // if ctrl+clicked if ((event->modifiers() == Qt::ControlModifier) - && (event->button() == Qt::LeftButton)) { - if (!selAvail() ) { - QSynedit::BufferCoord p; - if (mParser && pointToCharLine(event->pos(),p)) { - cancelHoverLink(); - QString sLine = lineText(p.line); - if (mParser->isIncludeNextLine(sLine)) { - QString filename = mParser->getHeaderFileName(mFilename,sLine, true); - pMainWindow->openFile(filename); - return; - } if (mParser->isIncludeLine(sLine)) { - QString filename = mParser->getHeaderFileName(mFilename,sLine); - pMainWindow->openFile(filename); - return; - } else if (mParser->enabled()) { - gotoDefinition(p); - return; - } + && (event->button() == Qt::LeftButton) && !selAvail()) { + QSynedit::BufferCoord p; + if (mParser && pointToCharLine(event->pos(),p)) { + cancelHoverLink(); + QString sLine = lineText(p.line); + if (mParser->isIncludeNextLine(sLine)) { + QString filename = mParser->getHeaderFileName(mFilename,sLine, true); + pMainWindow->openFile(filename); + return; + } if (mParser->isIncludeLine(sLine)) { + QString filename = mParser->getHeaderFileName(mFilename,sLine); + pMainWindow->openFile(filename); + return; + } else if (mParser->enabled()) { + gotoDefinition(p); + return; } } } @@ -4618,16 +4615,6 @@ void Editor::setCanAutoSave(bool newCanAutoSave) mCanAutoSave = newCanAutoSave; } -void Editor::mousePressEvent(QMouseEvent *event) -{ - if ((event->modifiers() == Qt::ControlModifier) - && (event->button() == Qt::LeftButton)) { - event->accept(); - return; - } - QSynedit::QSynEdit::mousePressEvent(event); -} - const QDateTime &Editor::hideTime() const { return mHideTime; diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index 33608c75..4ac05111 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -387,26 +387,11 @@ private: static QHash> mSharedParsers; - // QWidget interface -protected: - void wheelEvent(QWheelEvent *event) override; - void focusInEvent(QFocusEvent *event) override; - void focusOutEvent(QFocusEvent *event) override; - void keyPressEvent(QKeyEvent *event) override; - void keyReleaseEvent(QKeyEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; - // SynEdit interface protected: void onGutterPaint(QPainter &painter, int aLine, int X, int Y) override; void onGetEditingAreas(int Line, QSynedit::EditingAreaList &areaList) override; - - // SynEdit interface -protected: bool onGetSpecialLineColors(int Line, QColor &foreground, QColor &backgroundColor) override; - - // SynEdit interface -protected: void onPreparePaintHighlightToken(int line, int aChar, const QString &token, QSynedit::PTokenAttribute attr, QSynedit::FontStyles &style, QColor &foreground, QColor &background) override; // QObject interface @@ -431,18 +416,18 @@ public: quint64 lastFocusOutTime() const; protected: - void mousePressEvent(QMouseEvent *event) override; + // QWidget interface + void wheelEvent(QWheelEvent *event) override; + void focusInEvent(QFocusEvent *event) override; + void focusOutEvent(QFocusEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; + void keyReleaseEvent(QKeyEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void inputMethodEvent(QInputMethodEvent *) override; void closeEvent(QCloseEvent *event) override; - - // QWidget interface -protected: void showEvent(QShowEvent *event) override; void hideEvent(QHideEvent *event) override; - - // QWidget interface -protected: void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; }; diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 5cda9e4f..1515e1eb 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -6051,7 +6051,6 @@ void QSynEdit::mousePressEvent(QMouseEvent *event) QAbstractScrollArea::mousePressEvent(event); - BufferCoord oldCaret=caretXY(); if (button == Qt::RightButton) { if (mOptions.testFlag(EditorOption::RightMouseMovesCursor) &&