File indexing completed on 2024-04-28 03:54:34

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2008 David Faure <faure@kde.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #include <kiconloader.h>
0009 #include <kiconthemes_version.h>
0010 
0011 #include <QCommandLineParser>
0012 #include <QGuiApplication>
0013 
0014 #include <stdio.h>
0015 
0016 int main(int argc, char *argv[])
0017 {
0018     QGuiApplication app(argc, argv);
0019     app.setApplicationName(QStringLiteral("kiconfinder"));
0020     app.setApplicationVersion(QStringLiteral(KICONTHEMES_VERSION_STRING));
0021     QCommandLineParser parser;
0022     parser.setApplicationDescription(app.translate("main", "Finds an icon based on its name"));
0023     parser.addPositionalArgument(QStringLiteral("iconname"), app.translate("main", "The icon name to look for"));
0024     parser.addHelpOption();
0025 
0026     parser.process(app);
0027     if (parser.positionalArguments().isEmpty()) {
0028         parser.showHelp();
0029     }
0030 
0031     for (const QString &iconName : parser.positionalArguments()) {
0032         const QString icon = KIconLoader::global()->iconPath(iconName, KIconLoader::Desktop /*TODO configurable*/, true);
0033         if (!icon.isEmpty()) {
0034             printf("%s\n", icon.toLocal8Bit().constData());
0035         } else {
0036             return 1; // error
0037         }
0038     }
0039 
0040     return 0;
0041 }