KIconThemes

kiconfinder.cpp
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
16int 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("main", "Finds an icon based on its name"));
23 parser.addPositionalArgument(QStringLiteral("iconname"), app.translate("main", "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(iconName, KIconLoader::Desktop /*TODO configurable*/, true);
33 if (!icon.isEmpty()) {
34 printf("%s\n", icon.toLocal8Bit().constData());
35 } else {
36 return 1; // error
37 }
38 }
39
40 return 0;
41}
@ Desktop
Desktop icons.
static KIconLoader * global()
Returns the global icon loader initialized with the application name.
QString iconPath(const QString &name, int group_or_size, bool canReturnNull=false) const
Returns the path of an icon.
QCommandLineOption addHelpOption()
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax)
QStringList positionalArguments() const const
void process(const QCoreApplication &app)
void setApplicationDescription(const QString &description)
void showHelp(int exitCode)
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.