-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
KoIcon.h
50 lines (41 loc) · 2.13 KB
/
KoIcon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* This file is part of the Calligra project, made within the KDE community.
SPDX-FileCopyrightText: 2012 Friedrich W. H. Kossebau <[email protected]>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef KOICON_H
#define KOICON_H
// Qt
#include <QIcon>
/**
* Macros to support collecting the icons in use.
*
* After any change to this list of macros the file /CheckIcons.sh needs to be
* updated accordingly, to ensure that the icon names of the affected macros are
* still considered in the extraction.
*
* The naming pattern of the macros is like this:
* * koIcon* returns a QIcon object
* * koIconFallback* returns a QIcon object for given name or fallback name
* * koIconName* returns a QLatin1String (aligned with usual API where "iconName" property is of type QString)
* * koIconNameCStr* returns a const char*
*/
/// Use these macros for icons without any issues
#define koIcon(name) (QIcon::fromTheme(QStringLiteral(name)))
#define koIconFallback(name, fallbackName) (QIcon::fromTheme(QStringLiteral(name), QIcon::fromTheme(QStringLiteral(fallbackName))))
#define koIconName(name) (QStringLiteral(name))
#define koIconNameCStr(name) (name)
/// Use these definitions in files where needed:
// #define koSmallIcon(name) (SmallIcon(QStringLiteral(name)))
// #define koDesktopIcon(name) (DesktopIcon(QStringLiteral(name)))
// Also #include <KIconLoader>
/// Use these macros if there is a proper icon missing
#define koIconNeeded(comment, neededName) (QIcon::fromTheme(QStringLiteral(neededName)))
#define koIconNeededWithSubs(comment, neededName, substituteName) (QIcon::fromTheme(QStringLiteral(substituteName)))
#define koIconNameNeeded(comment, neededName) (QStringLiteral(neededName))
#define koIconNameNeededWithSubs(comment, neededName, substituteName) (QStringLiteral(substituteName))
#define koIconNameCStrNeeded(comment, neededName) (neededName)
#define koIconNameCStrNeededWithSubs(comment, neededName, substituteName) (substituteName)
/// Use these macros if the UI is okay without any icon, but would be better with one.
#define koIconWanted(comment, wantedName) (QIcon())
#define koIconNameWanted(comment, wantedName) (QString())
#endif