elisaqmlplugin.cpp 8.68 KB
Newer Older
1 2 3
/*
 * Copyright 2018 Matthieu Gallien <matthieu_gallien@yahoo.fr>
 *
4 5
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
6 7 8
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
9
 * This program is distributed in the hope that it will be useful,
10 11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14 15
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
 */

#include "elisaqmlplugin.h"

#if defined UPNPQT_FOUND && UPNPQT_FOUND
#include "upnp/upnpcontrolconnectionmanager.h"
#include "upnp/upnpcontrolmediaserver.h"
#include "upnp/upnpcontrolcontentdirectory.h"
#include "upnp/upnpcontentdirectorymodel.h"
#include "upnpdevicedescription.h"
#include "upnp/didlparser.h"
#include "upnp/upnpdiscoverallmusic.h"

#include "upnpssdpengine.h"
#include "upnpabstractservice.h"
#include "upnpcontrolabstractdevice.h"
#include "upnpcontrolabstractservice.h"
#include "upnpbasictypes.h"
#endif

36
#include "elisautils.h"
37 38 39 40 41 42 43
#include "elisaapplication.h"
#include "progressindicator.h"
#include "mediaplaylist.h"
#include "managemediaplayercontrol.h"
#include "manageheaderbar.h"
#include "manageaudioplayer.h"
#include "musiclistenersmanager.h"
44
#include "trackslistener.h"
Matthieu Gallien's avatar
toto  
Matthieu Gallien committed
45
#include "viewmanager.h"
46
#include "databaseinterface.h"
47
#include "datatypes.h"
48
#include "models/datamodel.h"
49
#include "models/trackmetadatamodel.h"
50
#include "models/trackcontextmetadatamodel.h"
51
#include "models/viewsmodel.h"
52
#include "models/gridviewproxymodel.h"
53 54
#include "models/alltracksproxymodel.h"
#include "models/singlealbumproxymodel.h"
55
#include "localFileConfiguration/elisaconfigurationdialog.h"
56 57

#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
58
#include "embeddedcoverageimageprovider.h"
59
#endif
60 61

#if defined KF5KIO_FOUND && KF5KIO_FOUND
62
#include "models/filebrowsermodel.h"
Alexander Stippich's avatar
Alexander Stippich committed
63
#include "models/filebrowserproxymodel.h"
64 65
#endif

66 67 68 69 70 71 72
#include "audiowrapper.h"

#if defined Qt5DBus_FOUND && Qt5DBus_FOUND
#include "mpris2/mpris2.h"
#include "mpris2/mediaplayer2player.h"
#endif

73

74 75 76 77 78 79
#include <QAction>
#include <QStandardPaths>

#include <QQmlExtensionPlugin>
#include <QQmlEngine>

Matthieu Gallien's avatar
Matthieu Gallien committed
80 81 82 83 84
ElisaQmlTestPlugin::ElisaQmlTestPlugin(QObject *aParent)
    : QQmlExtensionPlugin(aParent)
{
}

85 86 87
void ElisaQmlTestPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
    QQmlExtensionPlugin::initializeEngine(engine, uri);
88
#if defined KF5FileMetaData_FOUND && KF5FileMetaData_FOUND
89
    engine->addImageProvider(QStringLiteral("cover"), new EmbeddedCoverageImageProvider);
90
#endif
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
}

void ElisaQmlTestPlugin::registerTypes(const char *uri)
{
#if defined UPNPQT_FOUND && UPNPQT_FOUND
    qmlRegisterType<UpnpSsdpEngine>(uri, 1, 0, "UpnpSsdpEngine");
    qmlRegisterType<UpnpDiscoverAllMusic>(uri, 1, 0, "UpnpDiscoverAllMusic");

    qmlRegisterType<UpnpAbstractDevice>(uri, 1, 0, "UpnpAbstractDevice");
    qmlRegisterType<UpnpAbstractService>(uri, 1, 0, "UpnpAbstractService");
    qmlRegisterType<UpnpControlAbstractDevice>(uri, 1, 0, "UpnpControlAbstractDevice");
    qmlRegisterType<UpnpControlAbstractService>(uri, 1, 0, "UpnpControlAbstractService");
    qmlRegisterType<UpnpControlConnectionManager>(uri, 1, 0, "UpnpControlConnectionManager");
    qmlRegisterType<UpnpControlMediaServer>(uri, 1, 0, "UpnpControlMediaServer");
    qmlRegisterType<UpnpContentDirectoryModel>(uri, 1, 0, "UpnpContentDirectoryModel");
    qmlRegisterType<DidlParser>(uri, 1, 0, "DidlParser");
    qmlRegisterType<UpnpControlContentDirectory>(uri, 1, 0, "UpnpControlContentDirectory");
    qmlRegisterType<UpnpDeviceDescription>(uri, 1, 0, "UpnpDeviceDescription");

    qRegisterMetaType<A_ARG_TYPE_InstanceID>();
    qRegisterMetaType<QPointer<UpnpAbstractDevice> >();
    qRegisterMetaType<UpnpControlConnectionManager*>();
    qRegisterMetaType<UpnpContentDirectoryModel*>();
    qRegisterMetaType<UpnpDeviceDescription*>();
#endif

    qmlRegisterType<MediaPlayList>(uri, 1, 0, "MediaPlayList");
    qmlRegisterType<ManageMediaPlayerControl>(uri, 1, 0, "ManageMediaPlayerControl");
    qmlRegisterType<ManageHeaderBar>(uri, 1, 0, "ManageHeaderBar");
    qmlRegisterType<ManageAudioPlayer>(uri, 1, 0, "ManageAudioPlayer");
    qmlRegisterType<ProgressIndicator>(uri, 1, 0, "ProgressIndicator");
    qmlRegisterType<MusicListenersManager>(uri, 1, 0, "MusicListenersManager");
Matthieu Gallien's avatar
toto  
Matthieu Gallien committed
123
    qmlRegisterType<ViewManager>(uri, 1, 0, "ViewManager");
124
    qmlRegisterType<DataModel>(uri, 1, 0, "DataModel");
125
    qmlRegisterType<TrackMetadataModel>(uri, 1, 0, "TrackMetadataModel");
126
    qmlRegisterType<TrackContextMetaDataModel>(uri, 1, 0, "TrackContextMetaDataModel");
127
    qmlRegisterType<ViewsModel>(uri, 1, 0, "ViewsModel");
128
    qmlRegisterType<GridViewProxyModel>(uri, 1, 0, "GridViewProxyModel");
129 130
    qmlRegisterType<AllTracksProxyModel>(uri, 1, 0, "AllTracksProxyModel");
    qmlRegisterType<SingleAlbumProxyModel>(uri, 1, 0, "SingleAlbumProxyModel");
131 132

#if defined KF5KIO_FOUND && KF5KIO_FOUND
133
    qmlRegisterType<FileBrowserModel>(uri, 1, 0, "FileBrowserModel");
Alexander Stippich's avatar
Alexander Stippich committed
134
    qmlRegisterType<FileBrowserProxyModel>(uri, 1, 0, "FileBrowserProxyModel");
135 136
#endif

137
    qmlRegisterType<AudioWrapper>(uri, 1, 0, "AudioWrapper");
138
    qmlRegisterUncreatableType<DatabaseInterface>(uri, 1, 0, "DatabaseInterface", QStringLiteral("Only created in c++"));
139 140 141 142 143 144 145 146

#if defined Qt5DBus_FOUND && Qt5DBus_FOUND
    qmlRegisterType<Mpris2>(uri, 1, 0, "Mpris2");
    qRegisterMetaType<MediaPlayer2Player*>();
#endif

    qRegisterMetaType<AbstractMediaProxyModel*>();
    qRegisterMetaType<QHash<QString,QUrl>>("QHash<QString,QUrl>");
147
    qRegisterMetaType<QHash<QUrl,QDateTime>>("QHash<QUrl,QDateTime>");
148 149
    qRegisterMetaType<QVector<qulonglong>>("QVector<qulonglong>");
    qRegisterMetaType<QHash<qulonglong,int>>("QHash<qulonglong,int>");
150 151 152 153 154
    qRegisterMetaType<DataTypes::ListTrackDataType>("DataTypes::ListTrackDataType");
    qRegisterMetaType<DataTypes::ListRadioDataType>("DataTypes::ListRadioDataType");
    qRegisterMetaType<DataTypes::ListAlbumDataType>("DataTypes::ListAlbumDataType");
    qRegisterMetaType<DataTypes::ListArtistDataType>("DataTypes::ListArtistDataType");
    qRegisterMetaType<DataTypes::ListGenreDataType>("DataTypes::ListGenreDataType");
155
    qRegisterMetaType<ModelDataLoader::ListTrackDataType>("ModelDataLoader::ListTrackDataType");
Jerome Guidon's avatar
Jerome Guidon committed
156
    qRegisterMetaType<ModelDataLoader::ListRadioDataType>("ModelDataLoader::ListRadioDataType");
157 158 159
    qRegisterMetaType<ModelDataLoader::ListAlbumDataType>("ModelDataLoader::ListAlbumDataType");
    qRegisterMetaType<ModelDataLoader::ListArtistDataType>("ModelDataLoader::ListArtistDataType");
    qRegisterMetaType<ModelDataLoader::ListGenreDataType>("ModelDataLoader::ListGenreDataType");
160
    qRegisterMetaType<ModelDataLoader::AlbumDataType>("ModelDataLoader::AlbumDataType");
161
    qRegisterMetaType<TracksListener::ListTrackDataType>("TracksListener::ListTrackDataType");
162 163 164
    qRegisterMetaType<QMap<QString, int>>();
    qRegisterMetaType<QAction*>();
    qRegisterMetaType<QMap<QString,int>>("QMap<QString,int>");
165 166 167 168 169 170
    qRegisterMetaType<ElisaUtils::PlayListEnqueueMode>("ElisaUtils::PlayListEnqueueMode");
    qRegisterMetaType<ElisaUtils::PlayListEnqueueTriggerPlay>("ElisaUtils::PlayListEnqueueTriggerPlay");
    qRegisterMetaType<ElisaUtils::PlayListEntryType>("ElisaUtils::PlayListEntryType");
    qRegisterMetaType<ElisaUtils::EntryData>("ElisaUtils::EntryData");
    qRegisterMetaType<ElisaUtils::EntryDataList>("ElisaUtils::EntryDataList");
    qRegisterMetaType<ElisaUtils::FilterType>("ElisaUtils::FilterType");
171 172 173 174
    qRegisterMetaType<DataTypes::TrackDataType>("DataTypes::TrackDataType");
    qRegisterMetaType<DataTypes::AlbumDataType>("DataTypes::AlbumDataType");
    qRegisterMetaType<DataTypes::ArtistDataType>("DataTypes::ArtistDataType");
    qRegisterMetaType<DataTypes::GenreDataType>("DataTypes::GenreDataType");
175
    qRegisterMetaType<DataTypes::ColumnsRoles>("DataTypes::ColumnsRoles");
176 177
    qRegisterMetaType<ModelDataLoader::TrackDataType>("ModelDataLoader::TrackDataType");
    qRegisterMetaType<TracksListener::TrackDataType>("TracksListener::TrackDataType");
178
    qRegisterMetaType<ViewManager::ViewsType>("ViewManager::ViewsType");
179
    qRegisterMetaType<ViewManager::SortOrder>("ViewManager::SortOrder");
180
    qmlRegisterUncreatableType<ElisaConfigurationDialog>(uri, 1, 0, "ElisaConfigurationDialog", QStringLiteral("only one and done in c++"));
181 182

    qmlRegisterUncreatableType<ElisaApplication>(uri, 1, 0, "ElisaApplication", QStringLiteral("only one and done in c++"));
183
    qmlRegisterUncreatableMetaObject(ElisaUtils::staticMetaObject, uri, 1, 0, "ElisaUtils", QStringLiteral("Namespace ElisaUtils"));
184
}