1 /* This file is part of the KDE project 2 Copyright (C) 2012 Friedrich W. H. Kossebau <kossebau@kde.org> 3 Copyright (C) 2015-2016 Jarosław Staniek <staniek@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public License 16 along with this library; see the file COPYING.LIB. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef KEXIICON_H 22 #define KEXIICON_H 23 24 #include <kexiutils_export.h> 25 26 #include <QApplication> 27 #include <QIcon> 28 #include <KIconLoader> 29 30 /** 31 * Macros to support collecting the icons in use. 32 * 33 * After any change to this list of macros the file /CheckIcons.sh needs to be 34 * updated accordingly, to ensure that the icon names of the affected macros are 35 * still considered in the extraction. 36 * 37 * The naming pattern of the macros is like this: 38 * * koIcon* returns a QIcon object 39 * * koIconName* returns a QLatin1String (aligned with usual API where "iconName" property is of type QString) 40 * * koIconNameCStr* returns a const char* 41 */ 42 43 //! Use these macros for icons without any issues - global icons (breeze) 44 #define koIcon(name) (QIcon::fromTheme(QLatin1String(name))) 45 #define koIconName(name) (QLatin1String(name)) 46 #define koIconNameCStr(name) (name) 47 #define koSmallIcon(name) (QIcon::fromTheme(QLatin1String(name)).pixmap(IconSize(KIconLoader::Small))) 48 #define koDesktopIcon(name) (QIcon::fromTheme(QLatin1String(name)).pixmap(IconSize(KIconLoader::Desktop))) 49 #define koSmallIconCStr(name) (QIcon::fromTheme(name).pixmap(IconSize(KIconLoader::Small))) 50 #define koDesktopIconCStr(name) (QIcon::fromTheme(name).pixmap(IconSize(KIconLoader::Desktop))) 51 52 //! Use these macros if there is a proper icon missing 53 #define koIconNeeded(comment, neededName) (QIcon::fromTheme(QLatin1String(neededName))) 54 #define koIconNeededWithSubs(comment, neededName, substituteName) (QIcon::fromTheme(QLatin1String(substituteName))) 55 #define koIconNameNeeded(comment, neededName) (QLatin1String(neededName)) 56 #define koIconNameNeededWithSubs(comment, neededName, substituteName) (QLatin1String(substituteName)) 57 #define koIconNameCStrNeeded(comment, neededName) (neededName) 58 #define koIconNameCStrNeededWithSubs(comment, neededName, substituteName) (substituteName) 59 60 //! Use these macros if the UI is okay without any icon, but would be better with one. 61 #define koIconWanted(comment, wantedName) (QIcon()) 62 #define koIconNameWanted(comment, wantedName) (QString()) 63 64 //! Use these macros for icons without any issues - Kexi icons 65 #define KexiIcon(name) koIcon(name) 66 #define KexiIconName(name) koIconName(name) 67 #define KexiIconNameCStr(name) koIconNameCStr(name) 68 #define KexiSmallIcon(name) koSmallIcon(name) 69 #define KexiDesktopIcon(name) koDesktopIcon(name) 70 71 //! Use this function to load an icon that fits the current color theme 72 KEXIUTILS_EXPORT QIcon themedIcon(const QString &name); 73 74 //! Use this function to find an icon name that fits the current color theme 75 KEXIUTILS_EXPORT QString themedIconName(const QString &name); 76 77 #endif 78