File indexing completed on 2024-05-12 16:02:27

0001 /*
0002  *  SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef __KIS_ICON_UTILS_H
0008 #define __KIS_ICON_UTILS_H
0009 
0010 #include "kritawidgetutils_export.h"
0011 
0012 class QAbstractButton;
0013 class QComboBox;
0014 class QAction;
0015 class QObject;
0016 class QTabBar;
0017 class QTabWidget;
0018 
0019 #include <QIcon>
0020 #include <QString>
0021 
0022 namespace KisIconUtils
0023 {
0024 
0025     enum StdSizes {
0026         SizeSmall = 16, SizeSmallMedium = 22, SizeMedium = 32, SizeLarge = 48,
0027         SizeHuge = 64, SizeEnormous = 128
0028     };
0029 
0030     enum class Group {
0031         NoGroup = -1,
0032         Desktop = 0,
0033         FirstGroup = 0,
0034         Toolbar,
0035         MainToolbar,
0036         Small,
0037         Panel,
0038         Dialog,
0039         LastGroup,
0040         User
0041     };
0042 
0043 
0044     /**
0045      * Load a themed icon using its base name. Use it in
0046      * Krita instead of previous KisIconUtils::loadIcon()
0047      */
0048     KRITAWIDGETUTILS_EXPORT QIcon loadIcon(const QString &name);
0049 
0050     /**
0051      * Should we use a dark or light themeed icon? Useful for images that are loaded
0052      * dynamically like document templates instead of being in static resource files
0053      */
0054     KRITAWIDGETUTILS_EXPORT bool useDarkIcons();
0055 
0056     /**
0057      * This function updates an icon of \p object depending on its
0058      * type. See updateIcon() overrides to see the supported types
0059      */
0060     KRITAWIDGETUTILS_EXPORT void updateIconCommon(QObject *object);
0061 
0062     /**
0063      * Update an icon of \p button according to the current theme
0064      */
0065     KRITAWIDGETUTILS_EXPORT void updateIcon(QAbstractButton *button);
0066 
0067 
0068     KRITAWIDGETUTILS_EXPORT void clearIconCache();
0069 
0070     /**
0071      * Update an icon of \p comboBox according to the current theme
0072      */
0073     KRITAWIDGETUTILS_EXPORT void updateIcon(QComboBox *comboBox);
0074 
0075     /**
0076      * Update an icon of \p action according to the current theme
0077      */
0078     KRITAWIDGETUTILS_EXPORT void updateIcon(QAction *action);
0079 
0080     /**
0081      * Update the iconst of the \p tabBar according to the current theme
0082      */
0083     KRITAWIDGETUTILS_EXPORT void updateIcon(QTabBar *tabBar);
0084 }
0085 
0086 #endif /* __KIS_ICON_UTILS_H */