File indexing completed on 2024-04-28 12:31:22

0001 /*
0002  * Copyright 2021 Aditya Mehra <aix.m@outlook.com>
0003  *
0004  * Licensed under the Apache License, Version 2.0 (the "License");
0005  * you may not use this file except in compliance with the License.
0006  * You may obtain a copy of the License at
0007  *
0008  *    http://www.apache.org/licenses/LICENSE-2.0
0009  *
0010  * Unless required by applicable law or agreed to in writing, software
0011  * distributed under the License is distributed on an "AS IS" BASIS,
0012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013  * See the License for the specific language governing permissions and
0014  * limitations under the License.
0015  *
0016  */
0017 
0018 #include "qmycroftplugin.h"
0019 #include "controller.h"
0020 #include "skillmanager.h"
0021 #include "audiotranscribe.h"
0022 #include "skillentry.h"
0023 #include <QQmlContext>
0024 #include <QQmlEngine>
0025 
0026 static QObject *controllerSingletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
0027 {
0028     Q_UNUSED(scriptEngine);
0029 
0030     //singleton managed internally, qml should never delete it
0031     engine->setObjectOwnership(Controller::instance(), QQmlEngine::CppOwnership);
0032     return Controller::instance();
0033 }
0034 
0035 void QmycroftPlugin::registerTypes(const char *uri)
0036 {
0037     qmlRegisterSingletonType<Controller>(uri, 1, 0, "Controller", controllerSingletonProvider);
0038     qmlRegisterType<SkillManager>(uri, 1, 0, "SkillManager");
0039     qmlRegisterType<SkillEntry>(uri, 1,0, "SkillEntry");
0040     qmlRegisterType<AudioTranscribe>(uri, 1, 0, "AudioTranscribe");
0041     qmlRegisterType(QUrl(QStringLiteral("qrc:/qml/TranscribeButton.qml")), uri, 1, 0, "TranscribeButton");
0042 }