From e58ca802826dcfd246720fe4b5c87be67cd64e86 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 28 Jan 2022 19:30:50 +0800 Subject: [PATCH] - fix: failed to show function tip, when there are parameters having '[' and ']' - refactor iconmanager --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 8 +++---- RedPandaIDE/iconsmanager.cpp | 42 ++++++++++++++++-------------------- RedPandaIDE/iconsmanager.h | 12 +++++------ RedPandaIDE/mainwindow.cpp | 9 +++----- 5 files changed, 33 insertions(+), 39 deletions(-) diff --git a/NEWS.md b/NEWS.md index 60d437b3..b1d9b1ee 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ Red Panda C++ Version 0.14.1 - enhancement: custom theme + - fix: failed to show function tip, when there are parameters having '[' and ']' Red Panda C++ Version 0.14.0 - enhancement: custom icon set ( in the configuration folder) diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index a08b3384..1cc7ebf8 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -3313,9 +3313,9 @@ void Editor::updateFunctionTip() } } else if (bracketLevel>0) { if (tokens[i]=="[") { - braceLevel--; + bracketLevel--; } else if (tokens[i]=="]") { - braceLevel++; + bracketLevel++; } }else if (parenthesisLevel>0){ if (tokens[i]==")") { @@ -3345,10 +3345,10 @@ void Editor::updateFunctionTip() parenthesisLevel++; } else if (tokens[i]=="}") { braceLevel++; - } else if (tokens[i]=="}") { + } else if (tokens[i]=="]") { bracketLevel++; } else if (tokens[i]==",") { - paramsCount++; + paramsCount++; } } } diff --git a/RedPandaIDE/iconsmanager.cpp b/RedPandaIDE/iconsmanager.cpp index 7c9180e9..3cec43cf 100644 --- a/RedPandaIDE/iconsmanager.cpp +++ b/RedPandaIDE/iconsmanager.cpp @@ -25,19 +25,19 @@ #include #include #include "utils.h" +#include "settings.h" IconsManager* pIconsManager; IconsManager::IconsManager(QObject *parent) : QObject(parent) { mDefaultIconPixmap = std::make_shared(); + mIconSetTemplate = "%1/%2/%3/"; } void IconsManager::updateEditorGuttorIcons(const QString& iconSet,int size) { - QString iconFolder = QString(":/resources/iconsets/%1/editor/").arg(iconSet); - if (!mIconSetPathTemplate.isEmpty()) - iconFolder = mIconSetPathTemplate.arg(iconSet,"editor"); + QString iconFolder = mIconSetTemplate.arg( iconSetsFolder(),iconSet,"editor"); mIconPixmaps.insert(GUTTER_BREAKPOINT, createSVGIcon(iconFolder+"breakpoint.svg",size,size)); mIconPixmaps.insert(GUTTER_SYNTAX_ERROR, createSVGIcon(iconFolder+"syntaxerror.svg",size,size)); mIconPixmaps.insert(GUTTER_SYNTAX_WARNING,createSVGIcon(iconFolder+"syntaxwarning.svg",size,size)); @@ -47,9 +47,7 @@ void IconsManager::updateEditorGuttorIcons(const QString& iconSet,int size) void IconsManager::updateParserIcons(const QString &iconSet, int size) { - QString iconFolder = QString(":/resources/iconsets/%1/classparser/").arg(iconSet); - if (!mIconSetPathTemplate.isEmpty()) - iconFolder = mIconSetPathTemplate.arg(iconSet,"classparser"); + QString iconFolder = mIconSetTemplate.arg( iconSetsFolder(),iconSet,"classparser"); 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)); @@ -73,11 +71,9 @@ void IconsManager::updateParserIcons(const QString &iconSet, int size) } -void IconsManager::updateActionIcons(const QString iconSet, int size) +void IconsManager::updateActionIcons(const QString& iconSet, int size) { - QString iconFolder = QString(":/resources/iconsets/%1/actions/").arg(iconSet); - if (!mIconSetPathTemplate.isEmpty()) - iconFolder = mIconSetPathTemplate.arg(iconSet,"actions"); + QString iconFolder = mIconSetTemplate.arg( iconSetsFolder(),iconSet,"actions"); mActionIconSize = QSize(size,size); mIconPixmaps.insert(ACTION_MISC_BACK, createSVGIcon(iconFolder+"00Misc-01Back.svg",size,size)); mIconPixmaps.insert(ACTION_MISC_FORWARD, createSVGIcon(iconFolder+"00Misc-02Forward.svg",size,size)); @@ -208,21 +204,11 @@ const QSize &IconsManager::actionIconSize() const return mActionIconSize; } -const QString &IconsManager::iconSetPathTemplate() const -{ - return mIconSetPathTemplate; -} - -void IconsManager::setIconSetPathTemplate(const QString &newIconSetPathTemplate) -{ - mIconSetPathTemplate = newIconSetPathTemplate; -} - void IconsManager::prepareCustomIconSet(const QString &customIconSet) { if (QFile(customIconSet).exists()) return; - copyFolder(":/resources/iconsets",customIconSet); + copyFolder(pSettings->dirs().data(Settings::Dirs::DataType::IconSet),customIconSet); } QPixmap IconsManager::getPixmapForStatement(PStatement statement) @@ -270,8 +256,6 @@ QPixmap IconsManager::getPixmapForStatement(PStatement statement) case StatementKind::skLocalVariable: return *(pIconsManager->getPixmap(IconsManager::PARSER_LOCAL_VAR)); case StatementKind::skVariable: -// if (statement->scope == StatementScope::ssGlobal) -// return QIcon(":/icons/images/classparser/global.ico"); if (statement->isInherited) { if (statement->classScope == StatementClassScope::scsProtected) { return *(pIconsManager->getPixmap(IconsManager::PARSER_INHERITED_PROTECTD_VAR)); @@ -297,3 +281,15 @@ QPixmap IconsManager::getPixmapForStatement(PStatement statement) } return QPixmap(); } + +const QString IconsManager::iconSetsFolder() const +{ + if (mIconSetsFolder.isEmpty()) + return pSettings->dirs().data(Settings::Dirs::DataType::IconSet); + return mIconSetsFolder; +} + +void IconsManager::setIconSetsFolder(const QString &newIconSetsFolder) +{ + mIconSetsFolder = newIconSetsFolder; +} diff --git a/RedPandaIDE/iconsmanager.h b/RedPandaIDE/iconsmanager.h index 941c99c2..f3e137c2 100644 --- a/RedPandaIDE/iconsmanager.h +++ b/RedPandaIDE/iconsmanager.h @@ -151,7 +151,7 @@ public: void updateEditorGuttorIcons(const QString& iconSet, int size); void updateParserIcons(const QString& iconSet, int size); - void updateActionIcons(const QString iconSet, int size); + void updateActionIcons(const QString& iconSet, int size); PPixmap getPixmap(IconName iconName) const; @@ -163,21 +163,21 @@ public: PPixmap createSVGIcon(const QString& filename, int width, int height); const QSize &actionIconSize() const; - - const QString &iconSetPathTemplate() const; - void setIconSetPathTemplate(const QString &newIconSetPathTemplate); - void prepareCustomIconSet(const QString &customIconSet); QPixmap getPixmapForStatement(PStatement statement); + const QString iconSetsFolder() const; + void setIconSetsFolder(const QString &newIconSetsFolder); + signals: void actionIconsUpdated(); private: QMap mIconPixmaps; PPixmap mDefaultIconPixmap; QSize mActionIconSize; - QString mIconSetPathTemplate; + QString mIconSetTemplate; + QString mIconSetsFolder; }; extern IconsManager* pIconsManager; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 8c06ff03..bd7f81de 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -599,12 +599,9 @@ void MainWindow::applySettings() p->setFont(font); } if (pSettings->environment().useCustomIconSet()) { - QString customIconSetPath = pSettings->dirs().config(Settings::Dirs::DataType::IconSet); - pIconsManager->prepareCustomIconSet(customIconSetPath); - pIconsManager->setIconSetPathTemplate( - includeTrailingPathDelimiter(customIconSetPath) - +"%1/%2/" - ); + QString customIconSetFolder = pSettings->dirs().config(Settings::Dirs::DataType::IconSet); + pIconsManager->prepareCustomIconSet(customIconSetFolder); + pIconsManager->setIconSetsFolder(customIconSetFolder); } pIconsManager->updateParserIcons(pSettings->environment().iconSet(),pointToPixel(pSettings->environment().interfaceFontSize()));