- fix: In split screen mode, editor on the right can't be correctly found by commands.

This commit is contained in:
Roy Qu 2024-03-26 13:58:14 +08:00
parent 477f7f1d7d
commit 5976ef95ea
4 changed files with 22 additions and 3 deletions

View File

@ -92,6 +92,7 @@ Red Panda C++ Version 2.27
- enhancement: Auto define macro "_DEBUG" for "Debug" compiler set(like visual studio). - enhancement: Auto define macro "_DEBUG" for "Debug" compiler set(like visual studio).
- enhancement: Suggest macro names after "#ifdef"/"#ifndef". - enhancement: Suggest macro names after "#ifdef"/"#ifndef".
- enhancement: Info contents from stderr are logged into "Tools Output" panel, add problem case name info to the log. - enhancement: Info contents from stderr are logged into "Tools Output" panel, add problem case name info to the log.
- fix: In split screen mode, editor on the right can't be correctly found by commands.
Red Panda C++ Version 2.26 Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors. - enhancement: Code suggestion for embedded std::vectors.

View File

@ -95,6 +95,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
mHoverModifiedLine{-1}, mHoverModifiedLine{-1},
mWheelAccumulatedDelta{0} mWheelAccumulatedDelta{0}
{ {
mLastFocusOutTime = 0;
mInited=false; mInited=false;
mBackupFile=nullptr; mBackupFile=nullptr;
mHighlightCharPos1 = QSynedit::BufferCoord{0,0}; mHighlightCharPos1 = QSynedit::BufferCoord{0,0};
@ -704,6 +705,7 @@ void Editor::focusOutEvent(QFocusEvent *event)
if (!pMainWindow->isQuitting()) { if (!pMainWindow->isQuitting()) {
pMainWindow->functionTip()->hide(); pMainWindow->functionTip()->hide();
} }
mLastFocusOutTime = QDateTime::currentMSecsSinceEpoch();
} }
void Editor::keyPressEvent(QKeyEvent *event) void Editor::keyPressEvent(QKeyEvent *event)
@ -4546,6 +4548,11 @@ void Editor::cancelHoverLink()
} }
} }
quint64 Editor::lastFocusOutTime() const
{
return mLastFocusOutTime;
}
PCppParser Editor::sharedParser(ParserLanguage language) PCppParser Editor::sharedParser(ParserLanguage language)
{ {
PCppParser parser; PCppParser parser;

View File

@ -356,6 +356,7 @@ private:
int mHoverModifiedLine; int mHoverModifiedLine;
int mWheelAccumulatedDelta; int mWheelAccumulatedDelta;
QMap<QString,StatementKind> mIdentCache; QMap<QString,StatementKind> mIdentCache;
qint64 mLastFocusOutTime;
static QHash<ParserLanguage,std::weak_ptr<CppParser>> mSharedParsers; static QHash<ParserLanguage,std::weak_ptr<CppParser>> mSharedParsers;
@ -400,6 +401,8 @@ public:
bool canAutoSave() const; bool canAutoSave() const;
void setCanAutoSave(bool newCanAutoSave); void setCanAutoSave(bool newCanAutoSave);
quint64 lastFocusOutTime() const;
protected: protected:
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override;

View File

@ -68,15 +68,23 @@ QTabWidget* EditorList::getNewEditorPageControl() const {
} }
QTabWidget* EditorList::getFocusedPageControl() const { QTabWidget* EditorList::getFocusedPageControl() const {
//todo:
switch(mLayout) { switch(mLayout) {
case LayoutShowType::lstLeft: case LayoutShowType::lstLeft:
return mLeftPageWidget; return mLeftPageWidget;
case LayoutShowType::lstRight: case LayoutShowType::lstRight:
return mRightPageWidget; return mRightPageWidget;
case LayoutShowType::lstBoth: { case LayoutShowType::lstBoth: {
Editor* editor = dynamic_cast<Editor*>(mRightPageWidget->currentWidget()); Editor* rightEditor = dynamic_cast<Editor*>(mRightPageWidget->currentWidget());
if (editor && editor->hasFocus()) if (!rightEditor)
return mLeftPageWidget;
if (rightEditor->hasFocus())
return mRightPageWidget;
Editor *leftEditor = dynamic_cast<Editor*>(mLeftPageWidget->currentWidget());
if (!leftEditor)
return mRightPageWidget;
if (leftEditor->hasFocus())
return mLeftPageWidget;
if (rightEditor->lastFocusOutTime() > leftEditor->lastFocusOutTime())
return mRightPageWidget; return mRightPageWidget;
return mLeftPageWidget; return mLeftPageWidget;
} }