2021-06-24 16:05:19 +08:00
|
|
|
#include "iconsmanager.h"
|
|
|
|
|
2021-12-20 09:36:18 +08:00
|
|
|
#include <QPainter>
|
|
|
|
#include <QSvgRenderer>
|
|
|
|
|
2021-06-24 16:05:19 +08:00
|
|
|
IconsManager* pIconsManager;
|
|
|
|
|
|
|
|
IconsManager::IconsManager(QObject *parent) : QObject(parent)
|
|
|
|
{
|
2021-12-21 07:38:49 +08:00
|
|
|
mDefaultIcon = PIcon();
|
|
|
|
//updateEditorGuttorIcons(24);
|
2021-12-20 12:53:35 +08:00
|
|
|
mFolder = std::make_shared<QPixmap>(":/icons/images/newlook24/090-explorer.png");
|
2021-12-20 09:36:18 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-12-21 07:38:49 +08:00
|
|
|
void IconsManager::updateEditorGuttorIcons(const QString& iconSet,int size)
|
2021-12-20 09:36:18 +08:00
|
|
|
{
|
2021-12-21 07:38:49 +08:00
|
|
|
QString iconFolder = QString(":/icons/images/%1/").arg(iconSet);
|
|
|
|
mIcons.insert(GUTTER_BREAKPOINT, createSVGIcon(iconFolder+"breakpoint.svg",size,size));
|
|
|
|
mIcons.insert(GUTTER_SYNTAX_ERROR, createSVGIcon(iconFolder+"syntaxerror.svg",size,size));
|
|
|
|
mIcons.insert(GUTTER_SYNTAX_WARNING,createSVGIcon(iconFolder+"syntaxwarning.svg",size,size));
|
|
|
|
mIcons.insert(GUTTER_ACTIVEBREAKPOINT,createSVGIcon(iconFolder+"currentline.svg",size,size));
|
|
|
|
mIcons.insert(GUTTER_BOOKMARK, createSVGIcon(iconFolder+"bookmark.svg",size,size));
|
2021-06-24 16:05:19 +08:00
|
|
|
}
|
|
|
|
|
2021-12-21 07:38:49 +08:00
|
|
|
void IconsManager::updateParserIcons(const QString &iconSet, int size)
|
2021-06-24 16:05:19 +08:00
|
|
|
{
|
2021-12-21 07:38:49 +08:00
|
|
|
QString iconFolder = QString(":/icons/images/%1/").arg(iconSet);
|
|
|
|
mIcons.insert(PARSER_TYPE, createSVGIcon(iconFolder+"type.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_CLASS, createSVGIcon(iconFolder+"class.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_NAMESPACE, createSVGIcon(iconFolder+"namespace.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_DEFINE, createSVGIcon(iconFolder+"define.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_ENUM, createSVGIcon(iconFolder+"enum.svg",size,size));;
|
|
|
|
mIcons.insert(PARSER_GLOBAL_METHOD, createSVGIcon(iconFolder+"global_method.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_INHERITED_PROTECTED_METHOD, createSVGIcon(iconFolder+"method_inherited_protected.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_INHERITED_METHOD, createSVGIcon(iconFolder+"method_inherited.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_PROTECTED_METHOD, createSVGIcon(iconFolder+"method_protected.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_PUBLIC_METHOD, createSVGIcon(iconFolder+"method_public.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_PRIVATE_METHOD, createSVGIcon(iconFolder+"method_private.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_GLOBAL_VAR, createSVGIcon(iconFolder+"global.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_INHERITED_PROTECTD_VAR, createSVGIcon(iconFolder+"var_inherited_protected.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_INHERITED_VAR, createSVGIcon(iconFolder+"var_inherited.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_PROTECTED_VAR, createSVGIcon(iconFolder+"var_protected.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_PUBLIC_VAR, createSVGIcon(iconFolder+"var_public.svg",size,size));
|
|
|
|
mIcons.insert(PARSER_PRIVATE_VAR, createSVGIcon(iconFolder+"var_private.svg",size,size));
|
2021-06-24 16:05:19 +08:00
|
|
|
|
|
|
|
}
|
2021-10-21 17:31:25 +08:00
|
|
|
|
2021-12-21 07:38:49 +08:00
|
|
|
IconsManager::PIcon IconsManager::getIcon(IconName iconName) const
|
2021-10-21 17:31:25 +08:00
|
|
|
{
|
2021-12-21 07:38:49 +08:00
|
|
|
return mIcons.value(iconName, mDefaultIcon);
|
2021-10-21 17:31:25 +08:00
|
|
|
}
|
2021-10-23 23:10:34 +08:00
|
|
|
|
2021-12-21 07:38:49 +08:00
|
|
|
const IconsManager::PIcon &IconsManager::folder() const
|
2021-10-23 23:10:34 +08:00
|
|
|
{
|
|
|
|
return mFolder;
|
|
|
|
}
|
2021-12-20 12:53:35 +08:00
|
|
|
|
2021-12-21 07:38:49 +08:00
|
|
|
IconsManager::PIcon IconsManager::createSVGIcon(const QString &filename, int width, int height)
|
2021-12-20 12:53:35 +08:00
|
|
|
{
|
|
|
|
QSvgRenderer renderer(filename);
|
|
|
|
PIcon icon = std::make_shared<QPixmap>(width,height);
|
|
|
|
icon->fill(Qt::transparent);
|
|
|
|
QPainter painter(icon.get());
|
|
|
|
renderer.render(&painter,icon->rect());
|
|
|
|
return icon;
|
|
|
|
}
|