2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-06-24 16:05:19 +08:00
|
|
|
#ifndef ICONSMANAGER_H
|
|
|
|
#define ICONSMANAGER_H
|
|
|
|
|
2021-12-21 07:38:49 +08:00
|
|
|
#include <QMap>
|
2021-06-24 16:05:19 +08:00
|
|
|
#include <QObject>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <memory>
|
2022-01-27 20:31:44 +08:00
|
|
|
#include "parser/parserutils.h"
|
2021-06-24 16:05:19 +08:00
|
|
|
|
2021-12-23 00:24:52 +08:00
|
|
|
class QToolButton;
|
2021-12-23 09:11:58 +08:00
|
|
|
class QPushButton;
|
2021-06-24 16:05:19 +08:00
|
|
|
class IconsManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-12-23 00:24:52 +08:00
|
|
|
using PPixmap = std::shared_ptr<QPixmap>;
|
2021-12-21 07:38:49 +08:00
|
|
|
enum IconName {
|
|
|
|
GUTTER_SYNTAX_ERROR,
|
|
|
|
GUTTER_SYNTAX_WARNING,
|
|
|
|
GUTTER_BREAKPOINT,
|
|
|
|
GUTTER_ACTIVEBREAKPOINT,
|
|
|
|
GUTTER_BOOKMARK,
|
2021-12-21 11:57:23 +08:00
|
|
|
|
|
|
|
PARSER_TYPE,
|
|
|
|
PARSER_CLASS,
|
|
|
|
PARSER_NAMESPACE,
|
|
|
|
PARSER_DEFINE,
|
|
|
|
PARSER_ENUM,
|
|
|
|
PARSER_GLOBAL_METHOD,
|
|
|
|
PARSER_INHERITED_PROTECTED_METHOD,
|
|
|
|
PARSER_INHERITED_METHOD,
|
|
|
|
PARSER_PROTECTED_METHOD,
|
|
|
|
PARSER_PUBLIC_METHOD,
|
|
|
|
PARSER_PRIVATE_METHOD,
|
|
|
|
PARSER_GLOBAL_VAR,
|
|
|
|
PARSER_INHERITED_PROTECTD_VAR,
|
|
|
|
PARSER_INHERITED_VAR,
|
|
|
|
PARSER_PROTECTED_VAR,
|
|
|
|
PARSER_PUBLIC_VAR,
|
|
|
|
PARSER_PRIVATE_VAR,
|
2022-01-27 20:31:44 +08:00
|
|
|
PARSER_KEYWORD,
|
|
|
|
PARSER_CODE_SNIPPET,
|
2021-12-21 11:57:23 +08:00
|
|
|
|
2021-12-22 11:07:56 +08:00
|
|
|
ACTION_MISC_BACK,
|
|
|
|
ACTION_MISC_FORWARD,
|
|
|
|
ACTION_MISC_ADD,
|
|
|
|
ACTION_MISC_REMOVE,
|
|
|
|
ACTION_MISC_GEAR,
|
|
|
|
ACTION_MISC_CROSS,
|
|
|
|
ACTION_MISC_FOLDER,
|
|
|
|
ACTION_MISC_TERM,
|
|
|
|
ACTION_MISC_CLEAN,
|
2021-12-23 00:24:52 +08:00
|
|
|
ACTION_MISC_VALIDATE,
|
|
|
|
ACTION_MISC_RENAME,
|
2021-12-23 09:11:58 +08:00
|
|
|
ACTION_MISC_HELP,
|
2021-12-22 11:07:56 +08:00
|
|
|
|
2021-12-21 11:57:23 +08:00
|
|
|
ACTION_FILE_NEW,
|
|
|
|
ACTION_FILE_OPEN,
|
2021-12-21 19:13:47 +08:00
|
|
|
ACTION_FILE_OPEN_FOLDER,
|
2021-12-21 11:57:23 +08:00
|
|
|
ACTION_FILE_SAVE,
|
|
|
|
ACTION_FILE_SAVE_AS,
|
|
|
|
ACTION_FILE_SAVE_ALL,
|
|
|
|
ACTION_FILE_CLOSE,
|
|
|
|
ACTION_FILE_CLOSE_ALL,
|
|
|
|
ACTION_FILE_PRINT,
|
2021-12-22 11:07:56 +08:00
|
|
|
ACTION_FILE_PROPERTIES,
|
|
|
|
ACTION_FILE_LOCATE,
|
|
|
|
|
2021-12-21 11:57:23 +08:00
|
|
|
ACTION_PROJECT_NEW,
|
|
|
|
ACTION_PROJECT_SAVE,
|
|
|
|
ACTION_PROJECT_CLOSE,
|
2021-12-21 22:52:31 +08:00
|
|
|
ACTION_PROJECT_NEW_FILE,
|
|
|
|
ACTION_PROJECT_ADD_FILE,
|
|
|
|
ACTION_PROJECT_REMOVE_FILE,
|
|
|
|
ACTION_PROJECT_PROPERTIES,
|
2021-12-21 19:13:47 +08:00
|
|
|
|
2021-12-21 20:17:58 +08:00
|
|
|
ACTION_EDIT_UNDO,
|
|
|
|
ACTION_EDIT_REDO,
|
|
|
|
ACTION_EDIT_CUT,
|
|
|
|
ACTION_EDIT_COPY,
|
|
|
|
ACTION_EDIT_PASTE,
|
|
|
|
ACTION_EDIT_INDENT,
|
2021-12-21 22:52:31 +08:00
|
|
|
ACTION_EDIT_UNINDENT,
|
|
|
|
ACTION_EDIT_SEARCH,
|
|
|
|
ACTION_EDIT_REPLACE,
|
|
|
|
ACTION_EDIT_SEARCH_IN_FILES,
|
2021-12-22 18:55:36 +08:00
|
|
|
ACTION_EDIT_SORT_BY_NAME,
|
|
|
|
ACTION_EDIT_SORT_BY_TYPE,
|
|
|
|
ACTION_EDIT_SHOW_INHERITED,
|
2021-12-21 20:17:58 +08:00
|
|
|
|
2021-12-21 22:52:31 +08:00
|
|
|
ACTION_CODE_BACK,
|
|
|
|
ACTION_CODE_FORWARD,
|
|
|
|
ACTION_CODE_ADD_BOOKMARK,
|
|
|
|
ACTION_CODE_REMOVE_BOOKMARK,
|
|
|
|
ACTION_CODE_REFORMAT,
|
2021-12-22 11:07:56 +08:00
|
|
|
|
|
|
|
ACTION_RUN_COMPILE,
|
|
|
|
ACTION_RUN_COMPILE_RUN,
|
|
|
|
ACTION_RUN_RUN,
|
|
|
|
ACTION_RUN_REBUILD,
|
|
|
|
ACTION_RUN_OPTIONS,
|
|
|
|
ACTION_RUN_DEBUG,
|
|
|
|
ACTION_RUN_STEP_OVER,
|
|
|
|
ACTION_RUN_STEP_INTO,
|
|
|
|
ACTION_RUN_STEP_OUT,
|
|
|
|
ACTION_RUN_RUN_TO_CURSOR,
|
|
|
|
ACTION_RUN_CONTINUE,
|
|
|
|
ACTION_RUN_STOP,
|
|
|
|
ACTION_RUN_ADD_WATCH,
|
|
|
|
ACTION_RUN_REMOVE_WATCH,
|
2021-12-22 19:01:58 +08:00
|
|
|
ACTION_RUN_STEP_OVER_INSTRUCTION,
|
|
|
|
ACTION_RUN_STEP_INTO_INSTRUCTION,
|
2021-12-27 10:59:04 +08:00
|
|
|
ACTION_RUN_INTERRUPT,
|
2021-12-22 11:07:56 +08:00
|
|
|
|
|
|
|
ACTION_VIEW_MAXIMUM,
|
2021-12-22 18:55:36 +08:00
|
|
|
ACTION_VIEW_CLASSBROWSER,
|
|
|
|
ACTION_VIEW_FILES,
|
|
|
|
ACTION_VIEW_COMPILELOG,
|
|
|
|
ACTION_VIEW_BOOKMARK,
|
|
|
|
ACTION_VIEW_TODO,
|
2021-12-22 11:07:56 +08:00
|
|
|
|
|
|
|
ACTION_HELP_ABOUT,
|
2021-12-22 18:55:36 +08:00
|
|
|
|
|
|
|
ACTION_PROBLEM_PROBLEM,
|
|
|
|
ACTION_PROBLEM_SET,
|
|
|
|
ACTION_PROBLEM_PROPERTIES,
|
|
|
|
ACTION_PROBLEM_EDIT_SOURCE,
|
2022-01-01 17:24:18 +08:00
|
|
|
ACTION_PROBLEM_RUN_CASES,
|
|
|
|
ACTION_PROBLEM_PASSED,
|
|
|
|
ACTION_PROBLEM_FALIED,
|
|
|
|
ACTION_PROBLEM_TESTING
|
2021-12-21 07:38:49 +08:00
|
|
|
};
|
2021-06-24 16:05:19 +08:00
|
|
|
explicit IconsManager(QObject *parent = nullptr);
|
|
|
|
|
2021-12-21 07:38:49 +08:00
|
|
|
void updateEditorGuttorIcons(const QString& iconSet, int size);
|
|
|
|
void updateParserIcons(const QString& iconSet, int size);
|
2021-12-21 11:57:23 +08:00
|
|
|
void updateActionIcons(const QString iconSet, int size);
|
2021-12-20 09:36:18 +08:00
|
|
|
|
2021-12-23 00:24:52 +08:00
|
|
|
PPixmap getPixmap(IconName iconName) const;
|
2021-10-21 17:31:25 +08:00
|
|
|
|
2021-12-23 00:24:52 +08:00
|
|
|
QIcon getIcon(IconName iconName) const;
|
|
|
|
|
|
|
|
void setIcon(QToolButton* btn, IconName iconName) const;
|
2021-12-23 09:11:58 +08:00
|
|
|
void setIcon(QPushButton* btn, IconName iconName) const;
|
2021-12-23 00:24:52 +08:00
|
|
|
|
|
|
|
PPixmap createSVGIcon(const QString& filename, int width, int height);
|
2021-12-22 22:04:34 +08:00
|
|
|
const QSize &actionIconSize() const;
|
|
|
|
|
2022-01-27 12:08:57 +08:00
|
|
|
|
|
|
|
const QString &iconSetPathTemplate() const;
|
|
|
|
void setIconSetPathTemplate(const QString &newIconSetPathTemplate);
|
|
|
|
|
|
|
|
void prepareCustomIconSet(const QString &customIconSet);
|
|
|
|
|
2022-01-27 20:31:44 +08:00
|
|
|
QPixmap getPixmapForStatement(PStatement statement);
|
|
|
|
|
2021-12-22 22:04:34 +08:00
|
|
|
signals:
|
|
|
|
void actionIconsUpdated();
|
2021-06-24 16:05:19 +08:00
|
|
|
private:
|
2021-12-23 00:24:52 +08:00
|
|
|
QMap<IconName,PPixmap> mIconPixmaps;
|
|
|
|
PPixmap mDefaultIconPixmap;
|
2021-12-22 22:04:34 +08:00
|
|
|
QSize mActionIconSize;
|
2022-01-27 12:08:57 +08:00
|
|
|
QString mIconSetPathTemplate;
|
2021-06-24 16:05:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
extern IconsManager* pIconsManager;
|
|
|
|
#endif // ICONSMANAGER_H
|