File indexing completed on 2024-05-12 16:39:56
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 QLatin1String (aligned with usual API where "iconName" property is of type 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(QLatin1String(name))) 0045 #define koIconName(name) (QLatin1String(name)) 0046 #define koIconNameCStr(name) (name) 0047 #define koSmallIcon(name) (QIcon::fromTheme(QLatin1String(name)).pixmap(KIconLoader::global()->currentSize(KIconLoader::Small))) 0048 #define koDesktopIcon(name) (QIcon::fromTheme(QLatin1String(name)).pixmap(KIconLoader::global()->currentSize(KIconLoader::Desktop))) 0049 #define koSmallIconCStr(name) (QIcon::fromTheme(name).pixmap(KIconLoader::global()->currentSize(KIconLoader::Small))) 0050 #define koDesktopIconCStr(name) (QIcon::fromTheme(name).pixmap(KIconLoader::global()->currentSize(KIconLoader::Desktop))) 0051 0052 //! Use these macros if there is a proper icon missing 0053 #define koIconNeeded(comment, neededName) (QIcon::fromTheme(QLatin1String(neededName))) 0054 #define koIconNeededWithSubs(comment, neededName, substituteName) (QIcon::fromTheme(QLatin1String(substituteName))) 0055 #define koIconNameNeeded(comment, neededName) (QLatin1String(neededName)) 0056 #define koIconNameNeededWithSubs(comment, neededName, substituteName) (QLatin1String(substituteName)) 0057 #define koIconNameCStrNeeded(comment, neededName) (neededName) 0058 #define koIconNameCStrNeededWithSubs(comment, neededName, substituteName) (substituteName) 0059 0060 //! Use these macros if the UI is okay without any icon, but would be better with one. 0061 #define koIconWanted(comment, wantedName) (QIcon()) 0062 #define koIconNameWanted(comment, wantedName) (QString()) 0063 0064 //! Use these macros for icons without any issues - Kexi icons 0065 #define KexiIcon(name) koIcon(name) 0066 #define KexiIconName(name) koIconName(name) 0067 #define KexiIconNameCStr(name) koIconNameCStr(name) 0068 #define KexiSmallIcon(name) koSmallIcon(name) 0069 #define KexiDesktopIcon(name) koDesktopIcon(name) 0070 0071 //! Use this function to load an icon that fits the current color theme 0072 KEXIUTILS_EXPORT QIcon themedIcon(const QString &name); 0073 0074 //! Use this function to find an icon name that fits the current color theme 0075 KEXIUTILS_EXPORT QString themedIconName(const QString &name); 0076 0077 #endif