File indexing completed on 2024-04-14 15:13:53

0001 /*  This file is part of the Calligra project, made within the KDE community.
0002 
0003     Copyright 2012 Friedrich W. H. Kossebau <kossebau@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 KOICON_H
0022 #define KOICON_H
0023 
0024 // Qt
0025 #include <QIcon>
0026 
0027 /**
0028  * Macros to support collecting the icons in use.
0029  *
0030  * After any change to this list of macros the file /CheckIcons.sh needs to be
0031  * updated accordingly, to ensure that the icon names of the affected macros are
0032  * still considered in the extraction.
0033  *
0034  * The naming pattern of the macros is like this:
0035  * * koIcon* returns a QIcon object
0036  * * koIconName* returns a QLatin1String (aligned with usual API where "iconName" property is of type QString)
0037  * * koIconNameCStr* returns a const char*
0038  */
0039 
0040 /// Use these macros for icons without any issues
0041 #define koIcon(name) (QIcon::fromTheme(QStringLiteral(name)))
0042 #define koIconName(name) (QStringLiteral(name))
0043 #define koIconNameCStr(name) (name)
0044 /// Use these definitions in files where needed:
0045 // #define koSmallIcon(name) (SmallIcon(QStringLiteral(name)))
0046 // #define koDesktopIcon(name) (DesktopIcon(QStringLiteral(name)))
0047 // Also #include <kiconloader.h>
0048 
0049 /// Use these macros if there is a proper icon missing
0050 #define koIconNeeded(comment, neededName) (QIcon::fromTheme(QStringLiteral(neededName)))
0051 #define koIconNeededWithSubs(comment, neededName, substituteName) (QIcon::fromTheme(QStringLiteral(substituteName)))
0052 #define koIconNameNeeded(comment, neededName) (QStringLiteral(neededName))
0053 #define koIconNameNeededWithSubs(comment, neededName, substituteName) (QStringLiteral(substituteName))
0054 #define koIconNameCStrNeeded(comment, neededName) (neededName)
0055 #define koIconNameCStrNeededWithSubs(comment, neededName, substituteName) (substituteName)
0056 
0057 /// Use these macros if the UI is okay without any icon, but would be better with one.
0058 #define koIconWanted(comment, wantedName) (QIcon())
0059 #define koIconNameWanted(comment, wantedName) (QString())
0060 
0061 #endif