Merge branch 'master' of github.com:royqh1979/RedPanda-CPP
This commit is contained in:
commit
c5bdecca17
2
NEWS.md
2
NEWS.md
|
@ -125,6 +125,8 @@ Red Panda C++ Version 2.27
|
|||
- fix: can't jump to definition/declaration for symbols in using alias statement like "using ::printf".
|
||||
- fix: Don't show completion suggestion for members of variable which type name has namespace alias;
|
||||
- fix: Theme manager not correctly inited in options dialog / environment / appearance.
|
||||
- enhancement: Size of icons in the completion popup changes with the editor font size.
|
||||
- change: Completion popup size settings are based on editor's char width/line height.
|
||||
|
||||
Red Panda C++ Version 2.26
|
||||
- enhancement: Code suggestion for embedded std::vectors.
|
||||
|
|
|
@ -3577,8 +3577,8 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple
|
|||
mCompletionPopup->setHideSymbolsStartWithUnderline(pSettings->codeCompletion().hideSymbolsStartsWithUnderLine());
|
||||
mCompletionPopup->setHideSymbolsStartWithTwoUnderline(pSettings->codeCompletion().hideSymbolsStartsWithTwoUnderLine());
|
||||
mCompletionPopup->setIgnoreCase(pSettings->codeCompletion().ignoreCase());
|
||||
mCompletionPopup->resize(pSettings->codeCompletion().width(),
|
||||
pSettings->codeCompletion().height());
|
||||
QSize popSize = calcCompletionPopupSize();
|
||||
mCompletionPopup->resize(popSize);
|
||||
|
||||
// Position it at the top of the next line
|
||||
QPoint popupPos = mapToGlobal(displayCoordToPixels(displayXY()));
|
||||
|
@ -3675,10 +3675,10 @@ void Editor::showHeaderCompletion(bool autoComplete, bool forceShow)
|
|||
p.setY(p.y() + textHeight() + 2);
|
||||
mHeaderCompletionPopup->move(mapToGlobal(p));
|
||||
|
||||
|
||||
mHeaderCompletionPopup->setIgnoreCase(pSettings->codeCompletion().ignoreCase());
|
||||
mHeaderCompletionPopup->resize(pSettings->codeCompletion().width(),
|
||||
pSettings->codeCompletion().height());
|
||||
|
||||
QSize popSize = calcCompletionPopupSize();
|
||||
mHeaderCompletionPopup->resize(popSize);
|
||||
//Set Font size;
|
||||
mHeaderCompletionPopup->setFont(font());
|
||||
mHeaderCompletionPopup->setLineHeightFactor(pSettings->editor().lineSpacing());
|
||||
|
@ -4576,6 +4576,22 @@ void Editor::cancelHoverLink()
|
|||
}
|
||||
}
|
||||
|
||||
QSize Editor::calcCompletionPopupSize()
|
||||
{
|
||||
#if QT_VERSION_MAJOR==5 && QT_VERSION_MINOR < 15
|
||||
int screenHeight = qApp->primaryScreen()->size().height();
|
||||
int screenWidht = qApp->primaryScreen()->size().width;
|
||||
#else
|
||||
int screenHeight = screen()->size().height();
|
||||
int screenWidth = screen()->size().width();
|
||||
#endif
|
||||
int popWidth = std::min(pSettings->codeCompletion().widthInColumns() * charWidth(),
|
||||
screenWidth / 2) + 4;
|
||||
int popHeight = std::min(pSettings->codeCompletion().heightInLines() * textHeight(),
|
||||
(screenHeight / 2 - textHeight() * 2)) + 4;
|
||||
return QSize{popWidth, popHeight};
|
||||
}
|
||||
|
||||
quint64 Editor::lastFocusOutTime() const
|
||||
{
|
||||
return mLastFocusOutTime;
|
||||
|
|
|
@ -303,6 +303,8 @@ private:
|
|||
void updateHoverLink(int line);
|
||||
void cancelHoverLink();
|
||||
|
||||
QSize calcCompletionPopupSize();
|
||||
|
||||
private:
|
||||
bool mInited;
|
||||
QDateTime mBackupTime;
|
||||
|
|
|
@ -41,7 +41,7 @@ IconsManager::IconsManager(QObject *parent) : QObject(parent)
|
|||
mMakeDisabledIconDarker = false;
|
||||
}
|
||||
|
||||
void IconsManager::updateEditorGuttorIcons(const QString& iconSet,int size)
|
||||
void IconsManager::updateEditorGutterIcons(const QString& iconSet,int size)
|
||||
{
|
||||
QString iconFolder = mIconSetTemplate.arg( iconSetsFolder(),iconSet,"editor");
|
||||
updateMakeDisabledIconDarker(iconSet);
|
||||
|
@ -54,29 +54,12 @@ void IconsManager::updateEditorGuttorIcons(const QString& iconSet,int size)
|
|||
|
||||
void IconsManager::updateParserIcons(const QString &iconSet, int size)
|
||||
{
|
||||
QString iconFolder = mIconSetTemplate.arg( iconSetsFolder(),iconSet,"classparser");
|
||||
updateMakeDisabledIconDarker(iconSet);
|
||||
mIconPixmaps.insert(PARSER_TYPE, createSVGIcon(iconFolder+"type.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_CLASS, createSVGIcon(iconFolder+"class.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_NAMESPACE, createSVGIcon(iconFolder+"namespace.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_DEFINE, createSVGIcon(iconFolder+"define.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_ENUM, createSVGIcon(iconFolder+"enum.svg",size,size));;
|
||||
mIconPixmaps.insert(PARSER_GLOBAL_METHOD, createSVGIcon(iconFolder+"global_method.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_INHERITED_PROTECTED_METHOD, createSVGIcon(iconFolder+"method_inherited_protected.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_INHERITED_METHOD, createSVGIcon(iconFolder+"method_inherited.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_PROTECTED_METHOD, createSVGIcon(iconFolder+"method_protected.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_PUBLIC_METHOD, createSVGIcon(iconFolder+"method_public.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_PRIVATE_METHOD, createSVGIcon(iconFolder+"method_private.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_GLOBAL_VAR, createSVGIcon(iconFolder+"global.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_INHERITED_PROTECTD_VAR, createSVGIcon(iconFolder+"var_inherited_protected.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_INHERITED_VAR, createSVGIcon(iconFolder+"var_inherited.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_PROTECTED_VAR, createSVGIcon(iconFolder+"var_protected.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_PUBLIC_VAR, createSVGIcon(iconFolder+"var_public.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_PRIVATE_VAR, createSVGIcon(iconFolder+"var_private.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_KEYWORD, createSVGIcon(iconFolder+"keyword.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_CODE_SNIPPET, createSVGIcon(iconFolder+"code_snippet.svg",size,size));
|
||||
mIconPixmaps.insert(PARSER_LOCAL_VAR, createSVGIcon(iconFolder+"var.svg",size,size));
|
||||
|
||||
mParserIconSize = size;
|
||||
mParserIconSet = iconSet;
|
||||
mCachedParserIconSet = "";
|
||||
mCachedParserIconSize = -1;
|
||||
mCachedParserIconPixmaps.clear();
|
||||
updateParserIcons(mIconPixmaps,iconSet,size);
|
||||
}
|
||||
|
||||
void IconsManager::updateActionIcons(const QString& iconSet, int size)
|
||||
|
@ -281,79 +264,26 @@ void IconsManager::prepareCustomIconSet(const QString &customIconSet)
|
|||
|
||||
QPixmap IconsManager::getPixmapForStatement(PStatement statement)
|
||||
{
|
||||
if (!statement)
|
||||
return QPixmap();
|
||||
StatementKind kind = getKindOfStatement(statement);
|
||||
switch (kind) {
|
||||
case StatementKind::Typedef:
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_TYPE));
|
||||
case StatementKind::Class:
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_CLASS));
|
||||
case StatementKind::Namespace:
|
||||
case StatementKind::NamespaceAlias:
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_NAMESPACE));
|
||||
case StatementKind::Preprocessor:
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_DEFINE));
|
||||
case StatementKind::EnumClassType:
|
||||
case StatementKind::EnumType:
|
||||
case StatementKind::Enum:
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_ENUM));
|
||||
case StatementKind::Function:
|
||||
case StatementKind::Constructor:
|
||||
case StatementKind::Destructor:
|
||||
if (statement->scope == StatementScope::Global)
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_GLOBAL_METHOD));
|
||||
if (statement->isInherited()) {
|
||||
if (statement->accessibility == StatementAccessibility::Protected) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_INHERITED_PROTECTED_METHOD));
|
||||
} else if (statement->accessibility == StatementAccessibility::Public) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_INHERITED_METHOD));
|
||||
} else {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PRIVATE_METHOD));
|
||||
}
|
||||
} else {
|
||||
if (statement->accessibility == StatementAccessibility::Protected) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PROTECTED_METHOD));
|
||||
} else if (statement->accessibility == StatementAccessibility::Public) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PUBLIC_METHOD));
|
||||
} else {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PRIVATE_METHOD));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case StatementKind::GlobalVariable:
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_GLOBAL_VAR));
|
||||
case StatementKind::LocalVariable:
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_LOCAL_VAR));
|
||||
case StatementKind::Variable:
|
||||
if (statement->isInherited()) {
|
||||
if (statement->accessibility == StatementAccessibility::Protected) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_INHERITED_PROTECTD_VAR));
|
||||
} else if (statement->accessibility == StatementAccessibility::Public) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_INHERITED_VAR));
|
||||
} else {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PRIVATE_VAR));
|
||||
}
|
||||
} else {
|
||||
if (statement->accessibility == StatementAccessibility::Protected) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PROTECTED_VAR));
|
||||
} else if (statement->accessibility == StatementAccessibility::Public) {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PUBLIC_VAR));
|
||||
} else {
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_PRIVATE_VAR));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case StatementKind::Keyword:
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_KEYWORD));
|
||||
case StatementKind::UserCodeSnippet:
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_CODE_SNIPPET));
|
||||
case StatementKind::Alias:
|
||||
return *(pIconsManager->getPixmap(IconsManager::PARSER_TYPE));
|
||||
default:
|
||||
break;
|
||||
return getPixmapForStatement(mIconPixmaps, statement);
|
||||
}
|
||||
|
||||
QPixmap IconsManager::getPixmapForStatement(PStatement statement, int size)
|
||||
{
|
||||
if (size == mParserIconSize)
|
||||
return getPixmapForStatement(statement);
|
||||
if (mParserIconSet != mCachedParserIconSet
|
||||
|| size != mCachedParserIconSize) {
|
||||
mCachedParserIconSet.clear();
|
||||
mCachedParserIconSet = mParserIconSet;
|
||||
mCachedParserIconSize = size;
|
||||
updateParserIcons(mCachedParserIconPixmaps,mParserIconSet,size);
|
||||
}
|
||||
return QPixmap();
|
||||
return getPixmapForStatement(mCachedParserIconPixmaps, statement);
|
||||
}
|
||||
|
||||
IconsManager::PPixmap IconsManager::getPixmap(const QMap<IconName, PPixmap> &iconPixmaps, IconName iconName) const
|
||||
{
|
||||
return iconPixmaps.value(iconName, mDefaultIconPixmap);
|
||||
}
|
||||
|
||||
const QString IconsManager::iconSetsFolder() const
|
||||
|
@ -404,3 +334,106 @@ void IconsManager::updateMakeDisabledIconDarker(const QString& iconset )
|
|||
{
|
||||
mMakeDisabledIconDarker = (iconset == "contrast");
|
||||
}
|
||||
|
||||
void IconsManager::updateParserIcons(QMap<IconName, PPixmap> &iconPixmaps, const QString &iconSet, int size)
|
||||
{
|
||||
QString iconFolder = mIconSetTemplate.arg( iconSetsFolder(),iconSet,"classparser");
|
||||
updateMakeDisabledIconDarker(iconSet);
|
||||
iconPixmaps.insert(PARSER_TYPE, createSVGIcon(iconFolder+"type.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_CLASS, createSVGIcon(iconFolder+"class.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_NAMESPACE, createSVGIcon(iconFolder+"namespace.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_DEFINE, createSVGIcon(iconFolder+"define.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_ENUM, createSVGIcon(iconFolder+"enum.svg",size,size));;
|
||||
iconPixmaps.insert(PARSER_GLOBAL_METHOD, createSVGIcon(iconFolder+"global_method.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_INHERITED_PROTECTED_METHOD, createSVGIcon(iconFolder+"method_inherited_protected.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_INHERITED_METHOD, createSVGIcon(iconFolder+"method_inherited.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_PROTECTED_METHOD, createSVGIcon(iconFolder+"method_protected.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_PUBLIC_METHOD, createSVGIcon(iconFolder+"method_public.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_PRIVATE_METHOD, createSVGIcon(iconFolder+"method_private.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_GLOBAL_VAR, createSVGIcon(iconFolder+"global.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_INHERITED_PROTECTD_VAR, createSVGIcon(iconFolder+"var_inherited_protected.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_INHERITED_VAR, createSVGIcon(iconFolder+"var_inherited.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_PROTECTED_VAR, createSVGIcon(iconFolder+"var_protected.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_PUBLIC_VAR, createSVGIcon(iconFolder+"var_public.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_PRIVATE_VAR, createSVGIcon(iconFolder+"var_private.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_KEYWORD, createSVGIcon(iconFolder+"keyword.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_CODE_SNIPPET, createSVGIcon(iconFolder+"code_snippet.svg",size,size));
|
||||
iconPixmaps.insert(PARSER_LOCAL_VAR, createSVGIcon(iconFolder+"var.svg",size,size));
|
||||
}
|
||||
|
||||
QPixmap IconsManager::getPixmapForStatement(const QMap<IconName, PPixmap> &iconPixmaps, PStatement statement)
|
||||
{
|
||||
if (!statement)
|
||||
return QPixmap();
|
||||
StatementKind kind = getKindOfStatement(statement);
|
||||
switch (kind) {
|
||||
case StatementKind::Typedef:
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_TYPE));
|
||||
case StatementKind::Class:
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_CLASS));
|
||||
case StatementKind::Namespace:
|
||||
case StatementKind::NamespaceAlias:
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_NAMESPACE));
|
||||
case StatementKind::Preprocessor:
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_DEFINE));
|
||||
case StatementKind::EnumClassType:
|
||||
case StatementKind::EnumType:
|
||||
case StatementKind::Enum:
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_ENUM));
|
||||
case StatementKind::Function:
|
||||
case StatementKind::Constructor:
|
||||
case StatementKind::Destructor:
|
||||
if (statement->scope == StatementScope::Global)
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_GLOBAL_METHOD));
|
||||
if (statement->isInherited()) {
|
||||
if (statement->accessibility == StatementAccessibility::Protected) {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_INHERITED_PROTECTED_METHOD));
|
||||
} else if (statement->accessibility == StatementAccessibility::Public) {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_INHERITED_METHOD));
|
||||
} else {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_PRIVATE_METHOD));
|
||||
}
|
||||
} else {
|
||||
if (statement->accessibility == StatementAccessibility::Protected) {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_PROTECTED_METHOD));
|
||||
} else if (statement->accessibility == StatementAccessibility::Public) {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_PUBLIC_METHOD));
|
||||
} else {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_PRIVATE_METHOD));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case StatementKind::GlobalVariable:
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_GLOBAL_VAR));
|
||||
case StatementKind::LocalVariable:
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_LOCAL_VAR));
|
||||
case StatementKind::Variable:
|
||||
if (statement->isInherited()) {
|
||||
if (statement->accessibility == StatementAccessibility::Protected) {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_INHERITED_PROTECTD_VAR));
|
||||
} else if (statement->accessibility == StatementAccessibility::Public) {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_INHERITED_VAR));
|
||||
} else {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_PRIVATE_VAR));
|
||||
}
|
||||
} else {
|
||||
if (statement->accessibility == StatementAccessibility::Protected) {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_PROTECTED_VAR));
|
||||
} else if (statement->accessibility == StatementAccessibility::Public) {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_PUBLIC_VAR));
|
||||
} else {
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_PRIVATE_VAR));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case StatementKind::Keyword:
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_KEYWORD));
|
||||
case StatementKind::UserCodeSnippet:
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_CODE_SNIPPET));
|
||||
case StatementKind::Alias:
|
||||
return *(getPixmap(iconPixmaps, IconsManager::PARSER_TYPE));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QPixmap();
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ public:
|
|||
};
|
||||
explicit IconsManager(QObject *parent = nullptr);
|
||||
|
||||
void updateEditorGuttorIcons(const QString& iconSet, int size);
|
||||
void updateEditorGutterIcons(const QString& iconSet, int size);
|
||||
void updateParserIcons(const QString& iconSet, int size);
|
||||
void updateActionIcons(const QString& iconSet, int size);
|
||||
void updateFileSystemIcons(const QString& iconSet, int size);
|
||||
|
@ -216,13 +216,20 @@ public:
|
|||
void prepareCustomIconSet(const QString &customIconSet);
|
||||
|
||||
QPixmap getPixmapForStatement(PStatement statement);
|
||||
QPixmap getPixmapForStatement(PStatement statement, int size);
|
||||
|
||||
const QString iconSetsFolder() const;
|
||||
void setIconSetsFolder(const QString &newIconSetsFolder);
|
||||
|
||||
QList<PIconSet> listIconSets();
|
||||
QString iconSet() const;
|
||||
void setIconSet(const QString &newIconSet);
|
||||
|
||||
private:
|
||||
void updateMakeDisabledIconDarker(const QString& iconset);
|
||||
void updateParserIcons(QMap<IconName,PPixmap> &iconPixmaps, const QString& iconSet, int size);
|
||||
QPixmap getPixmapForStatement(const QMap<IconName,PPixmap> &iconPixmaps, PStatement statement);
|
||||
PPixmap getPixmap(const QMap<IconName,PPixmap> &iconPixmaps, IconName iconName) const;
|
||||
signals:
|
||||
void actionIconsUpdated();
|
||||
private:
|
||||
|
@ -231,6 +238,11 @@ private:
|
|||
QSize mActionIconSize;
|
||||
QString mIconSetTemplate;
|
||||
QString mIconSetsFolder;
|
||||
QString mParserIconSet;
|
||||
int mParserIconSize;
|
||||
QString mCachedParserIconSet;
|
||||
int mCachedParserIconSize;
|
||||
QMap<IconName,PPixmap> mCachedParserIconPixmaps;
|
||||
|
||||
bool mMakeDisabledIconDarker;
|
||||
};
|
||||
|
|
|
@ -547,7 +547,7 @@ void MainWindow::updateStatusbarForLineCol(bool clear)
|
|||
|
||||
void MainWindow::updateEditorSettings()
|
||||
{
|
||||
pIconsManager->updateEditorGuttorIcons(
|
||||
pIconsManager->updateEditorGutterIcons(
|
||||
pSettings->environment().iconSet(),
|
||||
calIconSize(pSettings->editor().fontName(),pSettings->editor().fontSize())
|
||||
);
|
||||
|
|
|
@ -4843,30 +4843,30 @@ void Settings::CodeCompletion::setEnabled(bool newEnabled)
|
|||
mEnabled = newEnabled;
|
||||
}
|
||||
|
||||
int Settings::CodeCompletion::height() const
|
||||
int Settings::CodeCompletion::heightInLines() const
|
||||
{
|
||||
return mHeight;
|
||||
return mHeightInLines;
|
||||
}
|
||||
|
||||
void Settings::CodeCompletion::setHeight(int newHeight)
|
||||
void Settings::CodeCompletion::setHeightInLines(int newHeight)
|
||||
{
|
||||
mHeight = newHeight;
|
||||
mHeightInLines = newHeight;
|
||||
}
|
||||
|
||||
int Settings::CodeCompletion::width() const
|
||||
int Settings::CodeCompletion::widthInColumns() const
|
||||
{
|
||||
return mWidth;
|
||||
return mWidthInColumns;
|
||||
}
|
||||
|
||||
void Settings::CodeCompletion::setWidth(int newWidth)
|
||||
void Settings::CodeCompletion::setWidthInColumns(int newWidth)
|
||||
{
|
||||
mWidth = newWidth;
|
||||
mWidthInColumns = newWidth;
|
||||
}
|
||||
|
||||
void Settings::CodeCompletion::doSave()
|
||||
{
|
||||
saveValue("width",mWidth);
|
||||
saveValue("height",mHeight);
|
||||
saveValue("widthInColumns",mWidthInColumns);
|
||||
saveValue("heightInLines",mHeightInLines);
|
||||
saveValue("enabled",mEnabled);
|
||||
saveValue("parse_local_headers",mParseLocalHeaders);
|
||||
saveValue("parse_global_headers",mParseGlobalHeaders);
|
||||
|
@ -4888,8 +4888,8 @@ void Settings::CodeCompletion::doSave()
|
|||
void Settings::CodeCompletion::doLoad()
|
||||
{
|
||||
//Appearance
|
||||
mWidth = intValue("width",700);
|
||||
mHeight = intValue("height",400);
|
||||
mWidthInColumns = intValue("widthInColumns",30);
|
||||
mHeightInLines = intValue("heightInLines",8);
|
||||
mEnabled = boolValue("enabled",true);
|
||||
mParseLocalHeaders = boolValue("parse_local_headers",true);
|
||||
mParseGlobalHeaders = boolValue("parse_global_headers",true);
|
||||
|
|
|
@ -643,11 +643,11 @@ public:
|
|||
class CodeCompletion: public _Base {
|
||||
public:
|
||||
explicit CodeCompletion(Settings *settings);
|
||||
int width() const;
|
||||
void setWidth(int newWidth);
|
||||
int widthInColumns() const;
|
||||
void setWidthInColumns(int newWidth);
|
||||
|
||||
int height() const;
|
||||
void setHeight(int newHeight);
|
||||
int heightInLines() const;
|
||||
void setHeightInLines(int newHeight);
|
||||
|
||||
bool enabled() const;
|
||||
void setEnabled(bool newEnabled);
|
||||
|
@ -695,8 +695,8 @@ public:
|
|||
void setShareParser(bool newShareParser);
|
||||
|
||||
private:
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
int mWidthInColumns;
|
||||
int mHeightInLines;
|
||||
bool mEnabled;
|
||||
bool mParseLocalHeaders;
|
||||
bool mParseGlobalHeaders;
|
||||
|
|
|
@ -41,8 +41,8 @@ void EditorCodeCompletionWidget::doLoad()
|
|||
ui->chkParseLocalFiles->setChecked(pSettings->codeCompletion().parseLocalHeaders());
|
||||
ui->chkParseSystemFiles->setChecked(pSettings->codeCompletion().parseGlobalHeaders());
|
||||
|
||||
ui->spinWidth->setValue(pSettings->codeCompletion().width());
|
||||
ui->spinHeight->setValue(pSettings->codeCompletion().height());
|
||||
ui->spinWidth->setValue(pSettings->codeCompletion().widthInColumns());
|
||||
ui->spinHeight->setValue(pSettings->codeCompletion().heightInLines());
|
||||
|
||||
ui->chkShowSuggestionWhileTyping->setChecked(pSettings->codeCompletion().showCompletionWhileInput());
|
||||
ui->chkRecordUsage->setChecked(pSettings->codeCompletion().recordUsage());
|
||||
|
@ -67,8 +67,8 @@ void EditorCodeCompletionWidget::doSave()
|
|||
pSettings->codeCompletion().setParseLocalHeaders(ui->chkParseLocalFiles->isChecked());
|
||||
pSettings->codeCompletion().setParseGlobalHeaders(ui->chkParseSystemFiles->isChecked());
|
||||
|
||||
pSettings->codeCompletion().setWidth(ui->spinWidth->value());
|
||||
pSettings->codeCompletion().setHeight(ui->spinHeight->value());
|
||||
pSettings->codeCompletion().setWidthInColumns(ui->spinWidth->value());
|
||||
pSettings->codeCompletion().setHeightInLines(ui->spinHeight->value());
|
||||
|
||||
pSettings->codeCompletion().setShowCompletionWhileInput(ui->chkShowSuggestionWhileTyping->isChecked());
|
||||
pSettings->codeCompletion().setRecordUsage(ui->chkRecordUsage->isChecked());
|
||||
|
|
|
@ -250,10 +250,10 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinWidth">
|
||||
<property name="minimum">
|
||||
<number>100</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
<number>999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -267,10 +267,10 @@
|
|||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinHeight">
|
||||
<property name="minimum">
|
||||
<number>100</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
<number>999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -1300,10 +1300,6 @@ QVariant CodeCompletionListModel::data(const QModelIndex &index, int role) const
|
|||
PStatement statement = mStatements->at(index.row());
|
||||
return statement->command;
|
||||
}
|
||||
case Qt::DecorationRole:{
|
||||
PStatement statement = mStatements->at(index.row());
|
||||
return pIconsManager->getPixmapForStatement(statement);
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -1317,14 +1313,14 @@ PStatement CodeCompletionListModel::statement(const QModelIndex &index) const
|
|||
return mStatements->at(index.row());
|
||||
}
|
||||
|
||||
QPixmap CodeCompletionListModel::statementIcon(const QModelIndex &index) const
|
||||
QPixmap CodeCompletionListModel::statementIcon(const QModelIndex &index, int size) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QPixmap();
|
||||
if (index.row()>=mStatements->count())
|
||||
return QPixmap();
|
||||
PStatement statement = mStatements->at(index.row());
|
||||
return pIconsManager->getPixmapForStatement(statement);
|
||||
return pIconsManager->getPixmapForStatement(statement, size);
|
||||
}
|
||||
|
||||
void CodeCompletionListModel::notifyUpdated()
|
||||
|
@ -1348,7 +1344,9 @@ void CodeCompletionListItemDelegate::paint(QPainter *painter, const QStyleOption
|
|||
if (option.state & QStyle::State_Selected) {
|
||||
painter->fillRect(option.rect, mCurrentSelectionColor);
|
||||
}
|
||||
QPixmap icon = mModel->statementIcon(index);
|
||||
QFontMetrics fm{font()};
|
||||
int iconSize = fm.height()*0.8;
|
||||
QPixmap icon = mModel->statementIcon(index, iconSize);
|
||||
int x=option.rect.left();
|
||||
if (!icon.isNull()) {
|
||||
qreal dpr=icon.devicePixelRatioF();
|
||||
|
@ -1422,7 +1420,7 @@ void CodeCompletionListItemDelegate::setFont(const QFont &newFont)
|
|||
QSize CodeCompletionListItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QSize size = QStyledItemDelegate::sizeHint(option, index);
|
||||
size.setHeight(size.height()*mLineHeightFactor);
|
||||
size.setHeight(QFontMetrics(mFont).height()*mLineHeightFactor);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
int rowCount(const QModelIndex &parent) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
PStatement statement(const QModelIndex &index) const;
|
||||
QPixmap statementIcon(const QModelIndex &index) const;
|
||||
QPixmap statementIcon(const QModelIndex &index, int size) const;
|
||||
void notifyUpdated();
|
||||
|
||||
private:
|
||||
|
|
|
@ -454,7 +454,7 @@ void HeaderCompletionListItemDelegate::paint(QPainter *painter, const QStyleOpti
|
|||
QSize HeaderCompletionListItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QSize size = QStyledItemDelegate::sizeHint(option, index);
|
||||
size.setHeight(size.height()*mLineHeightFactor);
|
||||
size.setHeight(QFontMetrics(mFont).height()*mLineHeightFactor);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue