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