- fix: failed to show function tip, when there are parameters having '[' and ']'

- refactor iconmanager
This commit is contained in:
Roy Qu 2022-01-28 19:30:50 +08:00
parent 458b87ea64
commit e58ca80282
5 changed files with 33 additions and 39 deletions

View File

@ -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)

View File

@ -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++;
}
}
}

View File

@ -25,19 +25,19 @@
#include <QFile>
#include <QDir>
#include "utils.h"
#include "settings.h"
IconsManager* pIconsManager;
IconsManager::IconsManager(QObject *parent) : QObject(parent)
{
mDefaultIconPixmap = std::make_shared<QPixmap>();
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;
}

View File

@ -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<IconName,PPixmap> mIconPixmaps;
PPixmap mDefaultIconPixmap;
QSize mActionIconSize;
QString mIconSetPathTemplate;
QString mIconSetTemplate;
QString mIconSetsFolder;
};
extern IconsManager* pIconsManager;

View File

@ -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()));