QGCApplication*app=new QGCApplication(argc,argv,runUnitTests);,
void QGCApplication::_initCommon(void) //将 C++类 注册为 QML可识别的类型
{
QSettings settings;
// Register our Qml objects
//qmlRegisterType 注册可实例化的对象类型
qmlRegisterType ("QGroundControl.Palette", 1, 0, "QGCPalette");
qmlRegisterType ("QGroundControl.Palette", 1, 0, "QGCMapPalette");
//qmlRegisterUncreatableType 注册不可被实例化的具有名称的C++类型,但是这样的类型依然可以作为QML类型系统可识别的一种类型。如果该类型的枚举或者附加特性需要在QML中使用,但是类型本身不应被实例化,就需要使用这种方式进行注册
qmlRegisterUncreatableType ("QGroundControl", 1, 0, "CoordinateVector", "Reference only");
qmlRegisterUncreatableType ("QGroundControl", 1, 0, "QmlObjectListModel", "Reference only");
qmlRegisterUncreatableType ("QGroundControl", 1, 0, "MissionCommandTree", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.AutoPilotPlugin", 1, 0, "AutoPilotPlugin", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.AutoPilotPlugin", 1, 0, "VehicleComponent", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.Vehicle", 1, 0, "Vehicle", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.Vehicle", 1, 0, "MissionItem", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.Vehicle", 1, 0, "MissionManager", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.Vehicle", 1, 0, "ParameterManager", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.JoystickManager", 1, 0, "JoystickManager", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.JoystickManager", 1, 0, "Joystick", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.QGCPositionManager", 1, 0, "QGCPositionManager", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.FlightMap", 1, 0, "QGCMapPolygon", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.Controllers", 1, 0, "MissionController", "Reference only");
qmlRegisterUncreatableType ("QGroundControl.Controllers", 1, 0, "GeoFenceController", "Reference only");
qmlRegisterUncreatableType("QGroundControl.Controllers", 1, 0, "RallyPointController", "Reference only");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "ESP8266ComponentController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "ScreenToolsController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "PlanElemementMasterController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "ValuesWidgetController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "QGCFileDialogController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "RCChannelMonitorController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "JoystickConfigController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "LogDownloadController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "SyslinkComponentController");
#ifndef __mobile__
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "FirmwareUpgradeController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "GeoTagController");
qmlRegisterType ("QGroundControl.Controllers", 1, 0, "MavlinkConsoleController");
#endif
// Register Qml Singletons
//注册不能从QML导入的单例类型
qmlRegisterSingletonType ("QGroundControl", 1, 0, "QGroundControl", qgroundcontrolQmlGlobalSingletonFactory);
qmlRegisterSingletonType ("QGroundControl.ScreenToolsController", 1, 0, "ScreenToolsController", screenToolsControllerSingletonFactory);
qmlRegisterSingletonType ("QGroundControl.Mavlink", 1, 0, "Mavlink", mavlinkQmlSingletonFactory);
}
_toolbox=new QGCToolbox(this);
void QGCToolbox::_scanAndLoadPlugins(QGCApplication* app)
{
//-- No plugins found, use default instance
_corePlugin = new QGCCorePlugin(app, app->toolbox());
}
QQmlApplicationEngine*QGCCorePlugin::createRootWindow(QObject*parent){
QQmlApplicationEngine* pEngine = new QQmlApplicationEngine(parent);
pEngine->addImportPath("qrc:/qml");
pEngine->rootContext()->setContextProperty("joystickManager", qgcApp()->toolbox()->joystickManager());
pEngine->rootContext()->setContextProperty("debugMessageModel", AppMessages::getModel());
pEngine->load(QUrl(QStringLiteral("qrc:/qml/MainWindowNative.qml")));
return pEngine;
}
Window{ //主窗体
Loader{
id: mainWindowInner
anchors.fill: parent
source: "MainWindowInner.qml"
Connections{
target:mainWindowInner.item
onReallyClose:{
_forceClose=true
_rootWindow.close()
}
}
}
MainToolBar{
id: toolBar
height: ScreenTools.toolbarHeight
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
opacity: planToolBar.visible?0:1
z: QGroundControl.zOrderTopMost
Component.onCompleted: ScreenTools.availableHeight= parent.height-toolBar.height
onShowSettingsView: mainWindow.showSettingsView()//设置
onShowSetupView: mainWindow.showSetupView()//设置
onShowPlanView: mainWindow.showPlanView()//任务规划
onShowFlyView: mainWindow.showFlyView()//飞行
onShowAnalyzeView: mainWindow.showAnalyzeView()//分析