File indexing completed on 2024-04-28 04:45:36

0001 /*
0002  *   Copyright 2018 Camilo Higuita <milo.h@aol.com>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU Library General Public License as
0006  *   published by the Free Software Foundation; either version 2, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU General Public License for more details
0013  *
0014  *   You should have received a copy of the GNU Library General Public
0015  *   License along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018  */
0019 #pragma once
0020 
0021 #include <QQmlEngine>
0022 #include <QQmlExtensionPlugin>
0023 
0024 class MauiKit : public QQmlExtensionPlugin
0025 {
0026     Q_OBJECT
0027     Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
0028     
0029 public:
0030     MauiKit(QObject *parent =nullptr);
0031     void registerTypes(const char *uri) override;
0032     void initializeEngine(QQmlEngine *engine, const char *uri) override;
0033     
0034 private:
0035     QUrl componentUrl(const QString &fileName) const;
0036     
0037     QString resolveFileUrl(const QString &filePath) const
0038     {
0039         #if defined(Q_OS_ANDROID) && QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
0040         return QStringLiteral("qrc:/android_rcc_bundle/qml/org/mauikit/controls/") + filePath;
0041         #else
0042         #ifdef QUICK_COMPILER
0043         return QStringLiteral("qrc:/maui/kit/") + filePath;
0044         #else
0045         return baseUrl().toString() + QLatin1Char('/') + filePath;
0046         #endif
0047         #endif
0048     }
0049     
0050 Q_SIGNALS:
0051     void languageChangeEvent();
0052 };
0053