mauikit.h 2.11 KB
Newer Older
Camilo higuita's avatar
Camilo higuita committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 *   Copyright 2018 Camilo Higuita <milo.h@aol.com>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2, or
 *   (at your option) any later version.
 *
 *   This program 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 General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

Camilo Higuita's avatar
Camilo Higuita committed
20 21 22
#ifndef MAUIKIT_H
#define MAUIKIT_H

Camilo higuita's avatar
Camilo higuita committed
23 24
#define MAUIKIT_VERSION "1.0.2"

Camilo Higuita's avatar
Camilo Higuita committed
25 26 27
#include <QQmlEngine>
#include <QQmlExtensionPlugin>

camilo higuita's avatar
camilo higuita committed
28 29 30 31 32 33
#ifndef STATIC_MAUIKIT
#include "mauikit_export.h"
#endif

class MauiAccounts;
#ifdef STATIC_MAUIKIT
Camilo Higuita's avatar
Camilo Higuita committed
34
class MauiKit : public QQmlExtensionPlugin
camilo higuita's avatar
camilo higuita committed
35
        #else
camilo higuita's avatar
camilo higuita committed
36
class MAUIKIT_EXPORT MauiKit : public QQmlExtensionPlugin
camilo higuita's avatar
camilo higuita committed
37
        #endif
Camilo Higuita's avatar
Camilo Higuita committed
38 39
{
    Q_OBJECT
40 41

#ifndef STATIC_MAUIKIT
Camilo Higuita's avatar
Camilo Higuita committed
42
    Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
43 44
#endif

Camilo Higuita's avatar
Camilo Higuita committed
45 46 47 48 49
public:    
    void registerTypes(const char *uri) Q_DECL_OVERRIDE;

    static MauiKit& getInstance()
    {
50 51
        static MauiKit instance;
        return instance;
Camilo Higuita's avatar
Camilo Higuita committed
52 53 54 55 56 57
    }

    static void registerTypes()
    {
        static MauiKit instance;
        instance.registerTypes("org.kde.mauikit");
camilo higuita's avatar
camilo higuita committed
58
    }
59 60
    
    void initResources();
Camilo Higuita's avatar
Camilo Higuita committed
61 62 63 64 65

private:
    QUrl componentUrl(const QString &fileName) const;
    QString resolveFilePath(const QString &path) const
    {
Camilo higuita's avatar
Camilo higuita committed
66
#ifdef STATIC_MAUIKIT
Camilo Higuita's avatar
Camilo Higuita committed
67 68 69 70 71 72 73 74
        return QStringLiteral(":/org/kde/mauikit/") + path;
#else
        return baseUrl().toLocalFile() + QLatin1Char('/') + path;
#endif
    }
    
    QString resolveFileUrl(const QString &filePath) const
    {
Camilo higuita's avatar
Camilo higuita committed
75
#ifdef STATIC_MAUIKIT
Camilo Higuita's avatar
Camilo Higuita committed
76 77 78 79 80
        return filePath;
#else
        return baseUrl().toString() + QLatin1Char('/') + filePath;
#endif
    }
81

Camilo Higuita's avatar
Camilo Higuita committed
82 83 84 85 86 87
signals:

public slots:
};

#endif // MAUIKIT_H