Qt ForkAwesome: utils.cpp Source File

Qt ForkAwesome 0.3.4 Library that bundles ForkAwesome for use within Qt applications

Loading...
Searching...
No Matches
utils.cpp
Go to the documentation of this file.
1#include "./utils.h"
2#include "./icon.h"
3
4#include <QHash>
5#include <QString>
6
7namespace QtForkAwesome {
8
9#if (QT_VERSION >= QT_VERSION_CHECK(6, 8, 0))
10#define QT_HASH_HETEROGENEOUSLY_SEARCHABLE
11#endif
12
19#ifdef QT_HASH_HETEROGENEOUSLY_SEARCHABLE
20 Icon iconFromId(QStringView id)
21#else
22 Icon iconFromId(const QString &id)
23#endif
24{
25 static const auto mapping = QHash<QString, Icon>({
26#include "private/idmapping.h"
27 });
28 const auto icon = mapping.find(id);
29 return icon != mapping.cend() ? *icon : Icon::Invalid;
30}
31
38#ifdef QT_HASH_HETEROGENEOUSLY_SEARCHABLE
39 Icon iconFromId(const QString &id)
40{
41 return iconFromId(QStringView(id));
42}
43#else
44 Icon iconFromId(QStringView id)
45{
46 return iconFromId(id.toString());
47}
48#endif
49
50} // namespace QtForkAwesome
icon.h
QtForkAwesome
Contains classes provided by the QtForkAwesome library.
Definition renderer.h:20
QtForkAwesome::Icon
Icon
The Icon enum specifies a ForkAwesome icon for use with QtForkAwesome::Renderer::render().
Definition icon.h:11
QtForkAwesome::Icon::Invalid
@ Invalid
Definition icon.h:12
QtForkAwesome::iconFromId
QT_FORK_AWESOME_EXPORT Icon iconFromId(const QString &id)
Returns a QtForkAwesome::Icon for the specified icon id.
Definition utils.cpp:39
utils.h