QGC

15199 ワード

学習知識点の記録
QGCApplicationヘッダファイル
QGCApplication:public 
#ifdef __mobile__
    QGuiApplication
#else
    QApplication
#endif
{
    Q_OBJECT
public:
    QGCApplication(int &argc,char *argv[],bool unitTesting);
    ~QGCApplication();
    //     ,     QGC        
    void deleteAllSettingsNextBoot(void);
    //          
    void clearDeleteAllSettingsNextBoot(void);
    //  unittest  ,    true
    bool runningUnitTests(void){
        return _runningUnitTests;
    }
    //      (       )
    void reportMissingParameter(int componentId,const QString &name);
    //       
    void showMessage(const QString &mesage);
    //fake ui into showing mobile interface
    bool fakeMobile(void ){
        return _fakeMobile;
    }
...
    QGCToolbox * toolbox(void){
        return _toolbox;
    }
    //       
    bool isBluetoothAvailable(){
        return _bluetoothAvailable;
    }
    bool isInternetAvailable();



//slots  

public slots:
    //       connect to     information
    void informationMessageBoxOnMainThread(const QString &title,const QString &msg);

    //       connect to     warning
    void warningMessageBoxOnMainThread(const QString &title,const QString &msg);

    //       connect to     critical
    void criticalMessageBoxOnMainThread(const QString &title,const QString &msg);

    void showSetupView(void);

    void qmlAttemptWindow(void);

    //         
    void saveTelemetryLogOnMainThread(QString tempLogfile);
    //               
    void checkTelemetrySavePathOnMainThread(void);


signals:

    // mavlinkprotocol::checkForLostLogFiles,signal this to ourselves   mavlinkprotocol      
    void checkForLostLogFiles(void);



public:

    //    public,          ,    UnitTest    

    //               unit test
    //  public,      main    

    void _initCommon(void);


    //              ,      unit test
    //main  
    void _initForNormalAppBoot(void);

    //  unit test   ,                 (          )
    //main  

    void _initForUnitTests(void);

    void _loadCurrentStyleSheet(void)

    static QGCApplication * _app;  //  ,   gqcApp  directly   




public:

    //    UnitTest  
    //Shutdown application  
    void _shutdown();

    bool _checkTelemetrySavePath(bool useMessageBox);

private slots:
    void _missingParamDisplay(void);

private:
    QObject * _rootQmlObject(void);


#ifdef __mobile__
    QQmlApplicationEngine * _qmlAppEngine;
#endif

    bool _runningUnitTests;

    static const char * _darkStyleFile;
    static const char * _darkStyleFile;

    static const int _missingParamsDelayedDisplayTimerTimeout=1000;
    //  delay missing fact display
    QTimer _missingParamsDelayedDisplayTimerTimeout;
    QStringList _missingParams;
    //true:fake ui into displaying mobile interface
    bool _fakeMobile;
    //            
    bool _settingsUpgraded;

#ifdef QT_DEBUG
    //          dpi  
    bool __testHighDPI;
#endif


    QGCToolbox * _toolbox;

    bool _bluetoothAvailable;

    //
    static const char * _settingVersionKey;
    //         setting key,     setting key    
    static const char * _deleteAllSettingsKey;
    //   
    friend class UnitTest;
};

    //  QGCApplication  
    QGCApplication * qgcApp(void);
#endif;


QGCApplicationソースファイル
QGCMapEngineを含むh”
    QGCApplication *QGCApplication::_app=null;

    const char* QGCApplication::_deleteAllSettingsKey="DeleteAllSettingsKeyNextBoot";
    const char* QGCApplication::_settingsVersionKey="SettingsVersion";
    const char* QGCApplication::_darkStyleFile=":/res/styles/style-dark.css";
    const char* QGCApplication::_lightStyleFile=":/res/styles/style-light.css";

    //     mavlink    
    mavlink_status_t m_mavlink_status[MAVLINK_COMM_NUM_BUFFERS];
    //qml    
    static QObject* screenToolsControllerSingletonFactory(QQmlEngine *,QJSEngine*){
        ScreenToolsController *screenToolsController=new ScreenToolsController;
        return screenToolsController;
    }



    static QObject* mavlinkQmlSingletonFactory(QQmlEngine *,QJSEngine*){

        return new MavlinkQmlSingleton;
    }

    static QObject* qgroundcontrolQmlGlobalSingletonFactory(QQmlEngine *,QJSEngine*){
        //    QGCTool     toolbox 
        QGroundControlQmlGlobal * qmlGlobal=new QGroundControlQmlGlobal(qgcapp(),qgcApp()->toolbox());
        qmlGlobal->setToolbox(qgcApp()->toolbox());
        return qmlGlobal;
    }


//QGCApplication     
QGCApplication::QGCApplication(int &argc,char * argv[],bool unitTesting)
#ifdef __mobile__
    :QGuiApplication(argc,argv)
    ,_qmlAppEngine(NULL)
    #else
    :QApplication(argc,argv)
    #endif
    , _runningUnitTests(unitTesting)
    , _fakeMoile(false)
    ,_settingsUpgraded(false)
    #ifdef QT_DEBUG
    ,_testHighDPI(false)
    #endif
    ,_toolbox(NULL)
    ,_bluetoothAvailable(false)
{
    _app=this;
#ifndef __android__
    setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
#endif
    QNetworkProxyFactory::SetUserSystemConfiguration(true);







QGCApplicationの_initCommon
    QSettings settings;
    qmlRegisterType ("QGroundControl.Palette",1,0,"QGCPalette"); 

qmlRegisterType ("QGroundControl.Palette",1,0,"QGCMapPalette"); 

xxx

//     qml,     qmlsingletons

QGCApplicationの_initForNormalAppBoot
    //    Stylesheet
    connect(this,&QGCApplication::lastWindowClosed,this,QGCApplication::quit);
    MainWindow * mainwindow=MainWindow::_create();
    Q_CHECK_PTR(mainWindow);


//main window     log file
connect(this,&QGCApplication::checkForLostLogFiles,toolbox()->mavlinkProtocol(),&MAVLINKProtocol::checkForLostLogFiles);

emit checkForLostLogFiles();



//         
toolbox()->linkManager()->loadLinkConfiguratiinList();

//  joysticks
toolbox()->joystickManager()->init();

//if(_settingsUpgraded){
    showMmessage("         ,             ")。
}

//  links with flag AutoconnectLink
toolbox()->linkManager()->startAutoConnectedLinks();


//  getQGCMapEngine()->wasCacheReset()
    showmessage(         ,        );

settings.sync();
return true;

QGCApplication *gqcApp(void)
return QGCApplication::_app;

メインスレッドにリモートセンシングログを保存
saveTelemetryLgOnMainThread()
    if(_checkTelemetrySavePath(true)){
        //        、   

    //           ,       
    }

QGCApplication::_rootQmlObject()
MainWindow * mainWindow=MainWindow::instance();
QGCApplication::showSetupView(void)
QMetaObject::invokeMethod(__rootQmlObject(),”showSetupView”);