2021-03-11 13:30:45 -05:00
|
|
|
/*!
|
|
|
|
* Copyright (C) 2020 by Savoir-faire Linux
|
|
|
|
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, 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 General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qmlregister.h"
|
|
|
|
|
|
|
|
#include "accountlistmodel.h"
|
|
|
|
#include "accountstomigratelistmodel.h"
|
|
|
|
#include "mediacodeclistmodel.h"
|
|
|
|
#include "audiodevicemodel.h"
|
|
|
|
#include "audiomanagerlistmodel.h"
|
|
|
|
#include "bannedlistmodel.h"
|
|
|
|
#include "moderatorlistmodel.h"
|
|
|
|
#include "deviceitemlistmodel.h"
|
2021-03-30 15:15:36 -04:00
|
|
|
#include "smartlistmodel.h"
|
|
|
|
|
|
|
|
#include "appsettingsmanager.h"
|
2021-03-11 13:30:45 -05:00
|
|
|
#include "distantrenderer.h"
|
|
|
|
#include "namedirectory.h"
|
|
|
|
#include "updatemanager.h"
|
|
|
|
#include "pluginlistpreferencemodel.h"
|
|
|
|
#include "previewrenderer.h"
|
|
|
|
#include "version.h"
|
|
|
|
#include "videoformatfpsmodel.h"
|
|
|
|
#include "videoformatresolutionmodel.h"
|
|
|
|
#include "videoinputdevicemodel.h"
|
|
|
|
|
2021-04-08 16:03:25 -04:00
|
|
|
#include "api/peerdiscoverymodel.h"
|
|
|
|
#include "api/newcodecmodel.h"
|
|
|
|
#include "api/newdevicemodel.h"
|
|
|
|
#include "api/datatransfermodel.h"
|
|
|
|
#include "api/pluginmodel.h"
|
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
#include <QMetaType>
|
|
|
|
#include <QQmlEngine>
|
|
|
|
|
|
|
|
// clang-format off
|
2021-03-30 15:15:36 -04:00
|
|
|
// TODO: remove this
|
|
|
|
#define QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(T) \
|
|
|
|
qmlRegisterSingletonType<T>(NS_MODELS, VER_MAJ, VER_MIN, #T, \
|
2021-03-11 13:30:45 -05:00
|
|
|
[](QQmlEngine* e, QJSEngine* se) -> QObject* { \
|
|
|
|
Q_UNUSED(e); Q_UNUSED(se); \
|
|
|
|
return &(T::instance()); \
|
|
|
|
});
|
|
|
|
|
2021-03-30 15:15:36 -04:00
|
|
|
#define QML_REGISTERSINGLETONTYPE_URL(NS, URL, T) \
|
|
|
|
qmlRegisterSingletonType(QUrl(QStringLiteral(URL)), NS, VER_MAJ, VER_MIN, #T);
|
2021-03-11 13:30:45 -05:00
|
|
|
|
2021-03-30 15:15:36 -04:00
|
|
|
#define QML_REGISTERTYPE(NS, T) qmlRegisterType<T>(NS, VER_MAJ, VER_MIN, #T);
|
2021-03-11 13:30:45 -05:00
|
|
|
|
2021-03-30 15:15:36 -04:00
|
|
|
#define QML_REGISTERNAMESPACE(T, NAME) \
|
|
|
|
qmlRegisterUncreatableMetaObject(T, NS_MODELS, VER_MAJ, VER_MIN, NAME, "")
|
2021-03-11 13:30:45 -05:00
|
|
|
|
2021-03-30 15:15:36 -04:00
|
|
|
#define QML_REGISTERUNCREATABLE(N, T) \
|
|
|
|
qmlRegisterUncreatableType<T>(N, VER_MAJ, VER_MIN, #T, "Don't try to add to a qml definition of " #T);
|
2021-03-11 13:30:45 -05:00
|
|
|
|
2021-03-30 15:15:36 -04:00
|
|
|
#define QML_REGISTERUNCREATABLE_IN_NAMESPACE(T, NAMESPACE) \
|
|
|
|
qmlRegisterUncreatableType<NAMESPACE::T>(NS_MODELS, \
|
|
|
|
VER_MAJ, VER_MIN, #T, \
|
2021-03-11 13:30:45 -05:00
|
|
|
"Don't try to add to a qml definition of " #T);
|
|
|
|
|
2021-03-30 15:15:36 -04:00
|
|
|
namespace Utils {
|
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
/*!
|
|
|
|
* This function will expose custom types to the QML engine.
|
|
|
|
*/
|
|
|
|
void
|
2021-03-30 15:15:36 -04:00
|
|
|
registerTypes()
|
2021-03-11 13:30:45 -05:00
|
|
|
{
|
|
|
|
// QAbstractListModels
|
2021-03-30 15:15:36 -04:00
|
|
|
QML_REGISTERTYPE(NS_MODELS, AccountListModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, DeviceItemListModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, BannedListModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, ModeratorListModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, MediaCodecListModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, AccountsToMigrateListModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, AudioDeviceModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, AudioManagerListModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, VideoInputDeviceModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, VideoFormatResolutionModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, VideoFormatFpsModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, PluginListPreferenceModel);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, SmartListModel);
|
2021-03-11 13:30:45 -05:00
|
|
|
|
|
|
|
// QQuickItems
|
2021-03-30 15:15:36 -04:00
|
|
|
QML_REGISTERTYPE(NS_MODELS, PreviewRenderer);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, VideoCallPreviewRenderer);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, DistantRenderer);
|
|
|
|
QML_REGISTERTYPE(NS_MODELS, PhotoboothPreviewRender)
|
2021-03-11 13:30:45 -05:00
|
|
|
|
|
|
|
// Qml singleton components
|
2021-03-30 15:15:36 -04:00
|
|
|
QML_REGISTERSINGLETONTYPE_URL(NS_CONSTANTS, "qrc:/src/constant/JamiTheme.qml", JamiTheme);
|
|
|
|
QML_REGISTERSINGLETONTYPE_URL(NS_MODELS, "qrc:/src/constant/JamiQmlUtils.qml", JamiQmlUtils);
|
|
|
|
QML_REGISTERSINGLETONTYPE_URL(NS_CONSTANTS, "qrc:/src/constant/JamiStrings.qml", JamiStrings);
|
2021-03-11 13:30:45 -05:00
|
|
|
|
|
|
|
// C++ singletons
|
2021-03-30 15:15:36 -04:00
|
|
|
// TODO: remove this
|
|
|
|
QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(NameDirectory);
|
2021-03-11 13:30:45 -05:00
|
|
|
|
|
|
|
// Lrc namespaces, models, and singletons
|
2021-03-30 15:15:36 -04:00
|
|
|
QML_REGISTERNAMESPACE(lrc::api::staticMetaObject, "Lrc");
|
|
|
|
QML_REGISTERNAMESPACE(lrc::api::account::staticMetaObject, "Account");
|
|
|
|
QML_REGISTERNAMESPACE(lrc::api::call::staticMetaObject, "Call");
|
|
|
|
QML_REGISTERNAMESPACE(lrc::api::datatransfer::staticMetaObject, "Datatransfer");
|
|
|
|
QML_REGISTERNAMESPACE(lrc::api::interaction::staticMetaObject, "Interaction");
|
|
|
|
QML_REGISTERNAMESPACE(lrc::api::video::staticMetaObject, "Video");
|
|
|
|
QML_REGISTERNAMESPACE(lrc::api::profile::staticMetaObject, "Profile");
|
2021-03-11 13:30:45 -05:00
|
|
|
|
|
|
|
// Same as QML_REGISTERUNCREATABLE but omit the namespace in Qml
|
2021-03-30 15:15:36 -04:00
|
|
|
QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewAccountModel, lrc::api);
|
|
|
|
QML_REGISTERUNCREATABLE_IN_NAMESPACE(BehaviorController, lrc::api);
|
|
|
|
QML_REGISTERUNCREATABLE_IN_NAMESPACE(DataTransferModel, lrc::api);
|
|
|
|
QML_REGISTERUNCREATABLE_IN_NAMESPACE(ContactModel, lrc::api);
|
|
|
|
QML_REGISTERUNCREATABLE_IN_NAMESPACE(ConversationModel, lrc::api);
|
|
|
|
QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewCallModel, lrc::api);
|
|
|
|
QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewDeviceModel, lrc::api);
|
|
|
|
QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewCodecModel, lrc::api);
|
|
|
|
QML_REGISTERUNCREATABLE_IN_NAMESPACE(PeerDiscoveryModel, lrc::api);
|
2021-03-11 13:30:45 -05:00
|
|
|
|
|
|
|
// Enums
|
2021-03-30 15:15:36 -04:00
|
|
|
QML_REGISTERUNCREATABLE(NS_ENUMS, Settings);
|
|
|
|
QML_REGISTERUNCREATABLE(NS_ENUMS, NetWorkManager);
|
2021-03-11 13:30:45 -05:00
|
|
|
}
|
|
|
|
// clang-format on
|
2021-03-30 15:15:36 -04:00
|
|
|
} // namespace Utils
|