File indexing completed on 2024-05-12 05:39:34
0001 /*************************************************************************** 0002 * Copyright (C) 2022 by Renaud Guezennec * 0003 * renaud@rolisteam.org * 0004 * * 0005 * rmindmap is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 0021 #include <QAbstractItemModel> 0022 #include <QGuiApplication> 0023 #include <QOpenGLContext> 0024 #include <QQmlApplicationEngine> 0025 #include <QQmlContext> 0026 #include <QQmlEngine> 0027 #include <QQuickStyle> 0028 #include <QSurfaceFormat> 0029 0030 #include "common_qml/theme.h" 0031 #include "controller/view_controller/mindmapcontrollerbase.h" 0032 #include "controller/view_controller/sidemenucontroller.h" 0033 #include "maincontroller.h" 0034 #include "mindmap/controller/selectioncontroller.h" 0035 #include "mindmap/data/minditem.h" 0036 #include "mindmap/data/nodestyle.h" 0037 #include "mindmap/data/positioneditem.h" 0038 #include "mindmap/model/nodeimageprovider.h" 0039 #include "mindmap/qmlItems/linkitem.h" 0040 #include "utils/mappinghelper.h" 0041 0042 void registerMindmapType() 0043 { 0044 customization::Theme::setPath(":/resources/stylesheet/qml/theme.ini"); 0045 qRegisterMetaType<PlayerModel*>("PlayerModel*"); 0046 qRegisterMetaType<customization::Theme*>("customization::Theme*"); 0047 qRegisterMetaType<customization::StyleSheet*>("customization::StyleSheet*"); 0048 0049 qmlRegisterAnonymousType<PlayerModel>("PlayerModel", 1); 0050 0051 qmlRegisterSingletonType<customization::Theme>("Customization", 1, 0, "Theme", 0052 [](QQmlEngine* engine, QJSEngine*) -> QObject* 0053 { 0054 auto instead= customization::Theme::instance(); 0055 engine->setObjectOwnership(instead, QQmlEngine::CppOwnership); 0056 return instead; 0057 }); 0058 0059 qmlRegisterType<utils::MappingHelper>("utils", 1, 0, "MappingHelper"); 0060 qmlRegisterUncreatableType<mindmap::MindMapControllerBase>("mindmap", 1, 0, "MindMapController", 0061 "MindMapController can't be created in qml"); 0062 qmlRegisterUncreatableType<mindmap::MindItem>("mindmap", 1, 0, "MindItem", "Enum only"); 0063 qmlRegisterType<mindmap::SelectionController>("mindmap", 1, 0, "SelectionController"); 0064 qmlRegisterUncreatableType<RemotePlayerModel>("mindmap", 1, 0, "RemotePlayerModel", "property values"); 0065 qmlRegisterType<mindmap::LinkItem>("mindmap", 1, 0, "MindLink"); 0066 qmlRegisterType<mindmap::NodeStyle>("mindmap", 1, 0, "NodeStyle"); 0067 qmlRegisterUncreatableType<mindmap::PositionedItem>("mindmap", 1, 0, "PositionedItem", "Enum only"); 0068 qmlRegisterType<mindmap::SideMenuController>("mindmap", 1, 0, "SideMenuController"); 0069 qmlRegisterUncreatableType<mindmap::MindItemModel>("mindmap", 1, 0, "MindItemModel", 0070 "MindItemModel can't be created in qml"); 0071 } 0072 0073 int main(int argc, char** argv) 0074 { 0075 QGuiApplication app(argc, argv); 0076 0077 Q_INIT_RESOURCE(viewsqml); 0078 // Q_INIT_RESOURCE(textedit); 0079 Q_INIT_RESOURCE(rmindmap); 0080 // Q_INIT_RESOURCE(resources); 0081 // Q_INIT_RESOURCE(mindmap); 0082 0083 app.setApplicationName(QStringLiteral("RMindMap")); 0084 app.setOrganizationName(QStringLiteral("Rolisteam")); 0085 app.setOrganizationDomain(QStringLiteral("org.rolisteam")); 0086 auto format= QSurfaceFormat::defaultFormat(); 0087 if(QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) 0088 { 0089 format.setVersion(3, 2); 0090 format.setProfile(QSurfaceFormat::CoreProfile); 0091 } 0092 format.setDepthBufferSize(24); 0093 format.setStencilBufferSize(8); 0094 format.setSamples(8); 0095 QSurfaceFormat::setDefaultFormat(format); 0096 0097 0098 0099 QQuickStyle::setStyle("rolistyle"); 0100 QQuickStyle::setFallbackStyle("Fusion"); 0101 0102 MainController main; 0103 0104 registerMindmapType(); 0105 qmlRegisterSingletonInstance<MainController>("mindmap", 1, 0, "MindmapManager", &main); 0106 0107 QQmlApplicationEngine qmlEngine; 0108 qmlEngine.addImportPath(QStringLiteral("qrc:/qml")); 0109 qmlEngine.addImportPath(QStringLiteral("qrc:/qml/rolistyle")); 0110 auto provider= new mindmap::NodeImageProvider(main.imgModel()); 0111 qmlEngine.addImageProvider("nodeImages", provider); 0112 0113 qmlEngine.load(QLatin1String("qrc:/resources/qml/main.qml")); 0114 0115 return app.exec(); 0116 }