- enhancement: Auto adjust position of the suggestion popup window.

This commit is contained in:
Roy Qu 2023-10-21 10:14:12 +08:00
parent c1b5dd4b36
commit 5332ffee84
2 changed files with 18 additions and 6 deletions

View File

@ -1,6 +1,7 @@
Red Panda C++ Version 2.26 Red Panda C++ Version 2.26
- enhancment: Code suggestion for embedded std::vectors. - enhancement: Code suggestion for embedded std::vectors.
- change: Use ctrl+mouseMove event to highlight jumpable symbols (instead of ctrl+tooltip). - change: Use ctrl+mouseMove event to highlight jumpable symbols (instead of ctrl+tooltip).
- enhancement: Auto adjust position of the suggestion popup window.
Red Panda C++ Version 2.25 Red Panda C++ Version 2.25

View File

@ -48,6 +48,7 @@
#include <QTextDocument> #include <QTextDocument>
#include <QTextCodec> #include <QTextCodec>
#include <QScrollBar> #include <QScrollBar>
#include <QScreen>
#include "iconsmanager.h" #include "iconsmanager.h"
#include "debugger.h" #include "debugger.h"
#include "editorlist.h" #include "editorlist.h"
@ -3435,11 +3436,6 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple
} }
} }
// Position it at the top of the next line
QPoint p = rowColumnToPixels(displayXY());
p+=QPoint(0,textHeight()+2);
mCompletionPopup->move(mapToGlobal(p));
mCompletionPopup->setRecordUsage(pSettings->codeCompletion().recordUsage()); mCompletionPopup->setRecordUsage(pSettings->codeCompletion().recordUsage());
mCompletionPopup->setSortByScope(pSettings->codeCompletion().sortByScope()); mCompletionPopup->setSortByScope(pSettings->codeCompletion().sortByScope());
mCompletionPopup->setShowKeywords(pSettings->codeCompletion().showKeywords()); mCompletionPopup->setShowKeywords(pSettings->codeCompletion().showKeywords());
@ -3456,6 +3452,21 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple
mCompletionPopup->setIgnoreCase(pSettings->codeCompletion().ignoreCase()); mCompletionPopup->setIgnoreCase(pSettings->codeCompletion().ignoreCase());
mCompletionPopup->resize(pSettings->codeCompletion().width(), mCompletionPopup->resize(pSettings->codeCompletion().width(),
pSettings->codeCompletion().height()); pSettings->codeCompletion().height());
// Position it at the top of the next line
QPoint popupPos = mapToGlobal(rowColumnToPixels(displayXY()));
QSize desktopSize = screen()->virtualSize();
if (desktopSize.height() - popupPos.y() < mCompletionPopup->height() && popupPos.y() > mCompletionPopup->height())
popupPos-=QPoint(0, mCompletionPopup->height()+2);
else
popupPos+=QPoint(0,textHeight()+2);
if (desktopSize.width() - popupPos.x() < mCompletionPopup->width() ) {
popupPos.setX(std::max(0, desktopSize.width()-mCompletionPopup->width())-10);
}
mCompletionPopup->move(popupPos);
// fCompletionBox.CodeInsList := dmMain.CodeInserts.ItemList; // fCompletionBox.CodeInsList := dmMain.CodeInserts.ItemList;
// fCompletionBox.SymbolUsage := dmMain.SymbolUsage; // fCompletionBox.SymbolUsage := dmMain.SymbolUsage;
// fCompletionBox.ShowCount := devCodeCompletion.MaxCount; // fCompletionBox.ShowCount := devCodeCompletion.MaxCount;