File indexing completed on 2024-04-21 03:50:56
0001 /**************************************************************************** 0002 ** 0003 ** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org> 0004 ** 0005 ** This program is free software; you can redistribute it and/or 0006 ** modify it under the terms of the GNU General Public License as 0007 ** published by the Free Software Foundation; either version 2 of 0008 ** the License or (at your option) version 3 or any later version 0009 ** accepted by the membership of KDE e.V. (or its successor approved 0010 ** by the membership of KDE e.V.), which shall act as a proxy 0011 ** defined in Section 14 of version 3 of the license. 0012 ** 0013 ** This program is distributed in the hope that it will be useful, 0014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0016 ** GNU General Public License for more details. 0017 ** 0018 ** You should have received a copy of the GNU General Public License 0019 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 0020 ** 0021 ****************************************************************************/ 0022 0023 #include "core.h" 0024 0025 #include <qqml.h> 0026 0027 #include "exercisecontroller.h" 0028 #include "plugincontroller.h" 0029 #include "uicontroller.h" 0030 0031 #include <interfaces/isoundcontroller.h> 0032 0033 namespace Minuet 0034 { 0035 bool Core::initialize() 0036 { 0037 if (m_self) { 0038 return true; 0039 } 0040 0041 qRegisterMetaType<Minuet::ISoundController::State>("State"); 0042 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0043 qmlRegisterInterface<Minuet::ISoundController>("ISoundController"); 0044 #else 0045 qRegisterMetaType<Minuet::ISoundController>(); 0046 #endif 0047 qmlRegisterUncreatableType<Minuet::ISoundController>( 0048 "org.kde.minuet.isoundcontroller", 1, 0, "ISoundController", 0049 QStringLiteral("ISoundController cannot be instantiated")); 0050 0051 m_self = new Core; 0052 0053 return true; 0054 } 0055 0056 IPluginController *Core::pluginController() 0057 { 0058 return m_pluginController; 0059 } 0060 0061 ISoundController *Core::soundController() 0062 { 0063 return m_soundController; 0064 } 0065 0066 IExerciseController *Core::exerciseController() 0067 { 0068 return m_exerciseController; 0069 } 0070 0071 IUiController *Core::uiController() 0072 { 0073 return m_uiController; 0074 } 0075 0076 void Core::setSoundController(ISoundController *soundController) 0077 { 0078 if (m_soundController != soundController) { 0079 m_soundController = soundController; 0080 emit soundControllerChanged(m_soundController); 0081 } 0082 } 0083 0084 Core::Core(QObject *parent) : ICore(parent), m_soundController(nullptr) 0085 { 0086 m_pluginController = new PluginController(this); 0087 if (!((PluginController *)m_pluginController)->initialize(this)) { 0088 qCritical() << m_pluginController->errorString(); 0089 exit(-1); 0090 } 0091 0092 m_exerciseController = new ExerciseController(this); 0093 if (!((ExerciseController *)m_exerciseController)->initialize(this)) { 0094 qCritical() << m_exerciseController->errorString(); 0095 exit(-2); 0096 } 0097 0098 m_uiController = new UiController(this); 0099 if (!((UiController *)m_uiController)->initialize(this)) { 0100 qCritical() << m_uiController->errorString(); 0101 exit(-3); 0102 } 0103 } 0104 0105 } 0106 0107 #include "moc_core.cpp"