- enhancement: Function tip's width changes with editor width.
- fix: '<' / '>' not shown in function tips.
This commit is contained in:
parent
ffafcd4416
commit
57c4b4d646
2
NEWS.md
2
NEWS.md
|
@ -131,6 +131,8 @@ Red Panda C++ Version 2.27
|
|||
- fix: Can't find the correct type if current symbol is member of a class that has constructors.
|
||||
- fix: Alias a namespace to itself will create infinite loop.
|
||||
- fix: Can't find symbols indirectly included by other files.
|
||||
- enhancement: Function tip's width changes with editor width.
|
||||
- fix: '<' / '>' not shown in function tips.
|
||||
|
||||
Red Panda C++ Version 2.26
|
||||
- enhancement: Code suggestion for embedded std::vectors.
|
||||
|
|
|
@ -1640,6 +1640,7 @@ void Editor::hideEvent(QHideEvent */*event*/)
|
|||
void Editor::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QSynedit::QSynEdit::resizeEvent(event);
|
||||
pMainWindow->functionTip()->setMinWidth(width()*3/4);
|
||||
pMainWindow->functionTip()->hide();
|
||||
}
|
||||
|
||||
|
|
|
@ -1524,11 +1524,13 @@ PStatement CppParser::addStatement(const PStatement &parent,
|
|||
QChar ch=mTokenizer[i]->text[0];
|
||||
if (this->isIdentChar(ch)) {
|
||||
QString spaces=(i>argStart)?" ":"";
|
||||
if (args.length()>0 && isWordChar(args.back()))
|
||||
if (args.length()>0 && (isWordChar(args.back()) || args.back()=='>'))
|
||||
args+=spaces;
|
||||
word += mTokenizer[i]->text;
|
||||
if (!typeGetted) {
|
||||
noNameArgs+=spaces+word;
|
||||
if (noNameArgs.length()>0 && isWordChar(noNameArgs.back()))
|
||||
noNameArgs+=spaces;
|
||||
noNameArgs+=word;
|
||||
if (mCppTypeKeywords.contains(word) || !isCppKeyword(word))
|
||||
typeGetted = true;
|
||||
} else {
|
||||
|
@ -1541,6 +1543,7 @@ PStatement CppParser::addStatement(const PStatement &parent,
|
|||
} else if (mTokenizer[i]->text=="::") {
|
||||
if (braceLevel==0) {
|
||||
noNameArgs+= mTokenizer[i]->text;
|
||||
typeGetted = false;
|
||||
}
|
||||
} else {
|
||||
switch(ch.unicode()) {
|
||||
|
|
|
@ -18,9 +18,11 @@
|
|||
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QDebug>
|
||||
|
||||
FunctionTooltipWidget::FunctionTooltipWidget(QWidget *parent) :
|
||||
QFrame(parent, Qt::ToolTip | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus)
|
||||
QFrame{parent, Qt::ToolTip | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus},
|
||||
mMinWidth{410}
|
||||
{
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
mInfoLabel = new QLabel(this);
|
||||
|
@ -120,12 +122,19 @@ void FunctionTooltipWidget::updateTip()
|
|||
return;
|
||||
PFunctionInfo info = mInfos[mInfoIndex];
|
||||
QString text = info->returnType+ " " + info->name;
|
||||
QString originText = text;
|
||||
if (info->params.length()==0) {
|
||||
text += "()";
|
||||
originText += "()";
|
||||
} else {
|
||||
QStringList displayList;
|
||||
QStringList originList;
|
||||
for (int i=0;i<info->params.length();i++){
|
||||
const QString& param = info->params[i];
|
||||
QString param = info->params[i];
|
||||
originList.append(param);
|
||||
|
||||
param.replace("<","<");
|
||||
param.replace(">",">");
|
||||
if (mParamIndex == i) {
|
||||
displayList.append(QString("<b>%1</b>").arg(param));
|
||||
} else {
|
||||
|
@ -133,13 +142,14 @@ void FunctionTooltipWidget::updateTip()
|
|||
}
|
||||
}
|
||||
text += "( "+displayList.join(", ") + ") ";
|
||||
originText += "( "+originList.join(", ") + ") ";
|
||||
}
|
||||
if (mInfos.length()>1) {
|
||||
mTotalLabel->setText(QString("%1/%2").arg(mInfoIndex+1).arg(mInfos.length()));
|
||||
}
|
||||
int width = mInfoLabel->fontMetrics().horizontalAdvance(text);
|
||||
if (width > 400) {
|
||||
mInfoLabel->setMinimumWidth(410);
|
||||
int width = mInfoLabel->fontMetrics().horizontalAdvance(originText)+10;
|
||||
if (width > mMinWidth) {
|
||||
mInfoLabel->setMinimumWidth(mMinWidth);
|
||||
} else {
|
||||
mInfoLabel->setMinimumWidth(width);
|
||||
}
|
||||
|
@ -192,6 +202,16 @@ QStringList FunctionTooltipWidget::splitArgs(QString argStr)
|
|||
return result;
|
||||
}
|
||||
|
||||
int FunctionTooltipWidget::minWidth() const
|
||||
{
|
||||
return mMinWidth;
|
||||
}
|
||||
|
||||
void FunctionTooltipWidget::setMinWidth(int newMinWidth)
|
||||
{
|
||||
mMinWidth = newMinWidth;
|
||||
}
|
||||
|
||||
const QString &FunctionTooltipWidget::functionFullName() const
|
||||
{
|
||||
return mFunctioFullName;
|
||||
|
|
|
@ -54,6 +54,9 @@ public:
|
|||
const QString &functionFullName() const;
|
||||
void setFunctioFullName(const QString &newFunctioFullName);
|
||||
|
||||
int minWidth() const;
|
||||
void setMinWidth(int newMinWidth);
|
||||
|
||||
private:
|
||||
QStringList splitArgs(QString args);
|
||||
private:
|
||||
|
@ -67,6 +70,7 @@ private:
|
|||
QString mFunctioFullName;
|
||||
|
||||
QList<PFunctionInfo> mInfos;
|
||||
int mMinWidth;
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue