1 | /* |
2 | This file is part of the KDE project |
3 | SPDX-FileCopyrightText: 2008 David Faure <faure@kde.org> |
4 | |
5 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL |
6 | */ |
7 | |
8 | #include <kiconloader.h> |
9 | #include <kiconthemes_version.h> |
10 | |
11 | #include <QCommandLineParser> |
12 | #include <QGuiApplication> |
13 | |
14 | #include <stdio.h> |
15 | |
16 | int main(int argc, char *argv[]) |
17 | { |
18 | QGuiApplication app(argc, argv); |
19 | app.setApplicationName(QStringLiteral("kiconfinder" )); |
20 | app.setApplicationVersion(QStringLiteral(KICONTHEMES_VERSION_STRING)); |
21 | QCommandLineParser parser; |
22 | parser.setApplicationDescription(app.translate(context: "main" , key: "Finds an icon based on its name" )); |
23 | parser.addPositionalArgument(QStringLiteral("iconname" ), description: app.translate(context: "main" , key: "The icon name to look for" )); |
24 | parser.addHelpOption(); |
25 | |
26 | parser.process(app); |
27 | if (parser.positionalArguments().isEmpty()) { |
28 | parser.showHelp(); |
29 | } |
30 | |
31 | for (const QString &iconName : parser.positionalArguments()) { |
32 | const QString icon = KIconLoader::global()->iconPath(name: iconName, group_or_size: KIconLoader::Desktop /*TODO configurable*/, canReturnNull: true); |
33 | if (!icon.isEmpty()) { |
34 | printf(format: "%s\n" , icon.toLocal8Bit().constData()); |
35 | } else { |
36 | return 1; // error |
37 | } |
38 | } |
39 | |
40 | return 0; |
41 | } |
42 | |