diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,3 +87,13 @@ include(ECMGeneratePriFile) ecm_generate_pri_file(BASE_NAME KIconThemes LIB_NAME KF5IconThemes DEPS "widgets" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KIconThemes) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) + +add_library(KIconEnginePlugin MODULE kiconengineplugin.cpp) + +target_link_libraries(KIconEnginePlugin + PRIVATE + Qt5::Gui + KF5::IconThemes +) + +install(TARGETS KIconEnginePlugin DESTINATION ${KDE_INSTALL_QTPLUGINDIR}/iconengines) diff --git a/src/kiconengineplugin.cpp b/src/kiconengineplugin.cpp new file mode 100644 --- /dev/null +++ b/src/kiconengineplugin.cpp @@ -0,0 +1,43 @@ +/* + * kiconengineplugin.cpp: Qt plugin providing the ability to create a KIconEngine + * + * This file is part of the KDE project, module kdeui. + * Copyright (C) 2018 Fabian Vogt + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class KIconEnginePlugin : public QIconEnginePlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QIconEngineFactoryInterface" FILE "kiconengineplugin.json") + +public: + QIconEngine *create(const QString &file) override + { + return new KIconEngine(file, KIconLoader::global()); + } +}; + +QT_END_NAMESPACE + +#include "kiconengineplugin.moc" diff --git a/src/kiconengineplugin.json b/src/kiconengineplugin.json new file mode 100644 --- /dev/null +++ b/src/kiconengineplugin.json @@ -0,0 +1,4 @@ +{ + "Keys": [ "KIconEngine" ] +} +