File indexing completed on 2024-05-12 04:55:39

0001 /**
0002  * \file kid3qmlplugin.h
0003  * QML plugin for Kid3 application.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 19 Sep 2014
0008  *
0009  * Copyright (C) 2014-2024  Urs Fleisch
0010  *
0011  * This file is part of Kid3.
0012  *
0013  * Kid3 is free software; you can redistribute it and/or modify
0014  * it under the terms of the GNU General Public License as published by
0015  * the Free Software Foundation; either version 2 of the License, or
0016  * (at your option) any later version.
0017  *
0018  * Kid3 is distributed in the hope that it will be useful,
0019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0021  * GNU General Public License for more details.
0022  *
0023  * You should have received a copy of the GNU General Public License
0024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0025  */
0026 
0027 #pragma once
0028 
0029 #include <QtGlobal>
0030 #include <QScopedPointer>
0031 #include "kid3api.h"
0032 
0033 class ICorePlatformTools;
0034 class Kid3Application;
0035 class QmlImageProvider;
0036 
0037 #include <QQmlExtensionPlugin>
0038 
0039 /**
0040  * QML plugin for Kid3 application.
0041  */
0042 class KID3_PLUGIN_EXPORT Kid3QmlPlugin : public QQmlExtensionPlugin {
0043   Q_OBJECT
0044   Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
0045 public:
0046   /**
0047    * Constructor.
0048    * @param parent parent object
0049    */
0050   explicit Kid3QmlPlugin(QObject* parent = nullptr);
0051 
0052   /**
0053    * Destructor.
0054    */
0055   ~Kid3QmlPlugin() override;
0056 
0057   /**
0058    * Register the types used by the QML plugin.
0059    * @param uri URI of imported module, must be "Kid3"
0060    */
0061   void registerTypes(const char* uri) override;
0062 
0063   /**
0064    * Initialize the QML engine when the plugin is imported.
0065    * @param engine QML engine
0066    * @param uri URI of imported module, must be "Kid3"
0067    */
0068   void initializeEngine(QQmlEngine* engine, const char* uri) override;
0069 
0070 private:
0071   ICorePlatformTools* m_platformTools;
0072   Kid3Application* m_kid3App;
0073   QmlImageProvider* m_imageProvider;
0074   bool m_ownsKid3App;
0075 };