@@ -533,7 +533,9 @@ int main( int argc, char *argv[] )
533533 NotificationModel notificationModel;
534534
535535 ActiveLayer al;
536- ActiveProject activeProject ( *as, al, localProjectsManager );
536+ // ActiveProject activeProject( *as, al, localProjectsManager );
537+ ActiveProject *activeProject = engine.singletonInstance <ActiveProject *>( " MMInput" , " ActiveProject" );
538+ activeProject->setup ( *as, al, localProjectsManager );
537539 std::unique_ptr<VariablesManager> vm ( new VariablesManager ( ma.get () ) );
538540 vm->registerInputExpressionFunctions ();
539541
@@ -558,11 +560,11 @@ int main( int argc, char *argv[] )
558560
559561 // the automatic sync request on cold start will fail on MerginApiStatus not being initialized yet, so we call it again
560562 // after server ping is done
561- if ( activeProject. autosyncController () )
563+ if ( activeProject-> autosyncController () )
562564 {
563565 QObject::connect ( ma.get (), &MerginApi::pingMerginFinished, &lambdaContext, [&activeProject]
564566 {
565- activeProject. requestSync ( SyncOptions::AutomaticRequest );
567+ activeProject-> requestSync ( SyncOptions::AutomaticRequest );
566568 }, Qt::SingleShotConnection );
567569 }
568570
@@ -613,33 +615,33 @@ int main( int argc, char *argv[] )
613615 notificationModel.addError ( message );
614616 } );
615617
616- QObject::connect ( & activeProject, &ActiveProject::syncActiveProject, &syncManager, [&syncManager]( const LocalProject & project, const SyncOptions::RequestOrigin requestOrigin )
618+ QObject::connect ( activeProject, &ActiveProject::syncActiveProject, &syncManager, [&syncManager]( const LocalProject & project, const SyncOptions::RequestOrigin requestOrigin )
617619 {
618620 syncManager.syncProject ( project, SyncOptions::Authorized, SyncOptions::Retry, requestOrigin );
619621 } );
620622
621- QObject::connect ( & activeProject, &ActiveProject::projectReloaded, &lambdaContext, [merginApi = ma.get (), &activeProject]()
623+ QObject::connect ( activeProject, &ActiveProject::projectReloaded, &lambdaContext, [merginApi = ma.get (), &activeProject]()
622624 {
623- merginApi->reloadProjectRole ( activeProject. projectFullName () );
625+ merginApi->reloadProjectRole ( activeProject-> projectFullName () );
624626 } );
625627
626628 QObject::connect ( ma.get (), &MerginApi::authChanged, &lambdaContext, [merginApi = ma.get (), &activeProject]()
627629 {
628- if ( activeProject. isProjectLoaded () )
630+ if ( activeProject-> isProjectLoaded () )
629631 {
630632 // if you are logged in or if you just logged out
631633 if ( merginApi->userAuth ()->hasValidToken () || !merginApi->userAuth ()->hasAuthData () )
632634 {
633- merginApi->reloadProjectRole ( activeProject. projectFullName () );
635+ merginApi->reloadProjectRole ( activeProject-> projectFullName () );
634636 }
635637 }
636638 } );
637639
638- QObject::connect ( ma.get (), &MerginApi::projectRoleUpdated, & activeProject, [&activeProject]( const QString & projectFullName, const QString & role )
640+ QObject::connect ( ma.get (), &MerginApi::projectRoleUpdated, activeProject, [&activeProject]( const QString & projectFullName, const QString & role )
639641 {
640- if ( projectFullName == activeProject. projectFullName () )
642+ if ( projectFullName == activeProject-> projectFullName () )
641643 {
642- activeProject. setProjectRole ( role );
644+ activeProject-> setProjectRole ( role );
643645 }
644646 } );
645647
@@ -659,17 +661,17 @@ int main( int argc, char *argv[] )
659661 } );
660662 // Direct connections
661663 QObject::connect ( &app, &QGuiApplication::applicationStateChanged, &pk, &PositionKit::appStateChanged );
662- QObject::connect ( &app, &QGuiApplication::applicationStateChanged, & activeProject, &ActiveProject::appStateChanged );
664+ QObject::connect ( &app, &QGuiApplication::applicationStateChanged, activeProject, &ActiveProject::appStateChanged );
663665 QObject::connect ( &pw, &ProjectWizard::projectCreated, &localProjectsManager, &LocalProjectsManager::addLocalProject );
664- QObject::connect ( & activeProject, &ActiveProject::projectReloaded, vm.get (), &VariablesManager::merginProjectChanged );
665- QObject::connect ( & activeProject, &ActiveProject::projectWillBeReloaded, &inputProjUtils, &InputProjUtils::resetHandlers );
666- QObject::connect ( &syncManager, &SynchronizationManager::syncFinished, & activeProject, [&activeProject]( const QString & projectFullName, bool successfully, int version, bool reloadNeeded )
666+ QObject::connect ( activeProject, &ActiveProject::projectReloaded, vm.get (), &VariablesManager::merginProjectChanged );
667+ QObject::connect ( activeProject, &ActiveProject::projectWillBeReloaded, &inputProjUtils, &InputProjUtils::resetHandlers );
668+ QObject::connect ( &syncManager, &SynchronizationManager::syncFinished, activeProject, [&activeProject]( const QString & projectFullName, bool successfully, int version, bool reloadNeeded )
667669 {
668670 Q_UNUSED ( successfully );
669671 Q_UNUSED ( version );
670- if ( reloadNeeded && activeProject. projectFullName () == projectFullName )
672+ if ( reloadNeeded && activeProject-> projectFullName () == projectFullName )
671673 {
672- activeProject. reloadProject ( activeProject. qgsProject ()->homePath () );
674+ activeProject-> reloadProject ( activeProject-> qgsProject ()->homePath () );
673675 }
674676 } );
675677 QObject::connect ( QgsApplication::messageLog (),
@@ -725,7 +727,7 @@ int main( int argc, char *argv[] )
725727 engine.rootContext ()->setContextProperty ( " __inputUtils" , &iu );
726728 engine.rootContext ()->setContextProperty ( " __inputProjUtils" , &inputProjUtils );
727729 engine.rootContext ()->setContextProperty ( " __inputHelp" , &help );
728- engine.rootContext ()->setContextProperty ( " __activeProject" , &activeProject );
730+ // engine.rootContext()->setContextProperty( "__activeProject", &activeProject );
729731 engine.rootContext ()->setContextProperty ( " __syncManager" , &syncManager );
730732 engine.rootContext ()->setContextProperty ( " __merginApi" , ma.get () );
731733 engine.rootContext ()->setContextProperty ( " __merginProjectStatusModel" , &mpsm );
0 commit comments