2021-06-24 16:05:19 +08:00
|
|
|
#include "iconsmanager.h"
|
|
|
|
|
2021-12-20 09:36:18 +08:00
|
|
|
#include <QPainter>
|
|
|
|
#include <QSvgRenderer>
|
2021-12-21 11:57:23 +08:00
|
|
|
#include <QDebug>
|
2021-12-20 09:36:18 +08:00
|
|
|
|
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 11:57:23 +08:00
|
|
|
void IconsManager::updateActionIcons(const QString iconSet, int size)
|
|
|
|
{
|
|
|
|
QString iconFolder = QString(":/icons/images/%1/").arg(iconSet);
|
|
|
|
mIcons.insert(ACTION_FILE_NEW, createSVGIcon(iconFolder+"01File-01New.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_FILE_OPEN, createSVGIcon(iconFolder+"01File-02Open.svg",size,size));
|
2021-12-21 19:13:47 +08:00
|
|
|
mIcons.insert(ACTION_FILE_OPEN_FOLDER, createSVGIcon(iconFolder+"01File-09Open_Folder.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_FILE_SAVE, createSVGIcon(iconFolder+"01File-03Save.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_FILE_SAVE_AS, createSVGIcon(iconFolder+"01File-04SaveAs.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_FILE_SAVE_ALL, createSVGIcon(iconFolder+"01File-05SaveAll.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_FILE_CLOSE, createSVGIcon(iconFolder+"01File-06Close.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_FILE_CLOSE_ALL, createSVGIcon(iconFolder+"01File-07CloseAll.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_FILE_PRINT, createSVGIcon(iconFolder+"01File-08Print.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_PROJECT_NEW, createSVGIcon(iconFolder+"02Project_01New.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_PROJECT_SAVE, createSVGIcon(iconFolder+"02Project_02Save.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_PROJECT_CLOSE, createSVGIcon(iconFolder+"02Project_03Close.svg",size,size));
|
2021-12-21 22:52:31 +08:00
|
|
|
mIcons.insert(ACTION_PROJECT_NEW_FILE, createSVGIcon(iconFolder+"02Project_04NewFile.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_PROJECT_ADD_FILE, createSVGIcon(iconFolder+"02Project_05AddFile.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_PROJECT_REMOVE_FILE, createSVGIcon(iconFolder+"02Project_06RemoveFile.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_PROJECT_PROPERTIES, createSVGIcon(iconFolder+"02Project_07Properties.svg",size,size));
|
2021-12-21 20:17:58 +08:00
|
|
|
mIcons.insert(ACTION_EDIT_UNDO, createSVGIcon(iconFolder+"03Edit_01Undo.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_EDIT_REDO, createSVGIcon(iconFolder+"03Edit_02Redo.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_EDIT_CUT, createSVGIcon(iconFolder+"03Edit_03Cut.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_EDIT_COPY, createSVGIcon(iconFolder+"03Edit_04Copy.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_EDIT_PASTE, createSVGIcon(iconFolder+"03Edit_05Paste.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_EDIT_INDENT, createSVGIcon(iconFolder+"03Edit_06Indent.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_EDIT_UNINDENT, createSVGIcon(iconFolder+"03Edit_07Unindent.svg",size,size));
|
2021-12-21 22:52:31 +08:00
|
|
|
mIcons.insert(ACTION_EDIT_SEARCH, createSVGIcon(iconFolder+"03Edit_08Search.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_EDIT_REPLACE, createSVGIcon(iconFolder+"03Edit_09Replace.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_EDIT_SEARCH_IN_FILES, createSVGIcon(iconFolder+"03Edit_10SearchInFiles.svg",size,size));
|
|
|
|
|
|
|
|
mIcons.insert(ACTION_CODE_BACK, createSVGIcon(iconFolder+"04Code-01Back.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_CODE_FORWARD, createSVGIcon(iconFolder+"04Code-02Forward.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_CODE_ADD_BOOKMARK, createSVGIcon(iconFolder+"04Code-03AddBookmark.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_CODE_REMOVE_BOOKMARK, createSVGIcon(iconFolder+"04Code-04RemoveBookmark.svg",size,size));
|
|
|
|
mIcons.insert(ACTION_CODE_REFORMAT, createSVGIcon(iconFolder+"04Code-05Reformat.svg",size,size));
|
2021-12-21 11:57:23 +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;
|
|
|
|
}
|