- 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: 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.
- fix: In split screen mode, editor on the right can't be correctly found by commands.
Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors.

View File

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

View File

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

View File

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