File indexing completed on 2024-05-19 12:54:43

0001 /* This file is part of the KDE project
0002    Copyright (C) 2012 Friedrich W. H. Kossebau <kossebau@kde.org>
0003    Copyright (C) 2015-2016 Jarosław Staniek <staniek@kde.org>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 
0010    This library is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this library; see the file COPYING.LIB.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef KEXIICON_H
0022 #define KEXIICON_H
0023 
0024 #include <kexiutils_export.h>
0025 
0026 #include <QApplication>
0027 #include <QIcon>
0028 #include <KIconLoader>
0029 
0030 /**
0031  * Macros to support collecting the icons in use.
0032  *
0033  * After any change to this list of macros the file /CheckIcons.sh needs to be
0034  * updated accordingly, to ensure that the icon names of the affected macros are
0035  * still considered in the extraction.
0036  *
0037  * The naming pattern of the macros is like this:
0038  * * koIcon* returns a QIcon object
0039  * * koIconName* returns a QString
0040  * * koIconNameCStr* returns a const char*
0041  */
0042 
0043 //! Use these macros for icons without any issues - global icons (breeze)
0044 #define koIcon(name) (QIcon::fromTheme(QStringLiteral(name)))
0045 #define koDarkIcon(name) (KexiStyle::darkIcon(QStringLiteral(name)))
0046 #define koDarkIcon2(name, context) (KexiStyle::darkIcon(QStringLiteral(name), context))
0047 #define koIconName(name) (QStringLiteral(name))
0048 #define koIconNameCStr(name) (name)
0049 #define koSmallIcon(name) (QIcon::fromTheme(QStringLiteral(name)).pixmap(KIconLoader::global()->currentSize(KIconLoader::Small)))
0050 #define koDesktopIcon(name) (QIcon::fromTheme(QStringLiteral(name)).pixmap(KIconLoader::global()->currentSize(KIconLoader::Desktop)))
0051 #define koSmallIconCStr(name) (QIcon::fromTheme(name).pixmap(KIconLoader::global()->currentSize(KIconLoader::Small)))
0052 #define koDesktopIconCStr(name) (QIcon::fromTheme(name).pixmap(KIconLoader::global()->currentSize(KIconLoader::Desktop)))
0053 
0054 //! Use these macros if there is a proper icon missing
0055 #define koIconNeeded(comment, neededName) (QIcon::fromTheme(QStringLiteral(neededName)))
0056 #define koIconNeededWithSubs(comment, neededName, substituteName) (QIcon::fromTheme(QStringLiteral(substituteName)))
0057 #define koIconNameNeeded(comment, neededName) (QStringLiteral(neededName))
0058 #define koIconNameNeededWithSubs(comment, neededName, substituteName) (QStringLiteral(substituteName))
0059 #define koIconNameCStrNeeded(comment, neededName) (neededName)
0060 #define koIconNameCStrNeededWithSubs(comment, neededName, substituteName) (substituteName)
0061 
0062 //! Use these macros if the UI is okay without any icon, but would be better with one.
0063 #define koIconWanted(comment, wantedName) (QIcon())
0064 #define koIconNameWanted(comment, wantedName) (QString())
0065 
0066 //! Use these macros for icons without any issues - Kexi icons
0067 #define KexiIcon(name) koIcon(name)
0068 #define KexiIconName(name) koIconName(name)
0069 #define KexiIconNameCStr(name) koIconNameCStr(name)
0070 #define KexiSmallIcon(name) koSmallIcon(name)
0071 #define KexiDesktopIcon(name) koDesktopIcon(name)
0072 
0073 //! Use this function to load an icon that fits the current color theme
0074 KEXIUTILS_EXPORT QIcon themedIcon(const QString &name);
0075 
0076 //! Use this function to find an icon name that fits the current color theme
0077 KEXIUTILS_EXPORT QString themedIconName(const QString &name);
0078 
0079 #endif