@@ -1745,6 +1745,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers
1745
1745
1746
1746
setupLayoutManagerConnections();
1747
1747
1748
+ #ifdef HAVE_3D
1749
+ connect( QgsProject::instance()->views3DManager(), &Qgs3DViewsManager::viewsListChanged, this, &QgisApp::views3DMenuAboutToShow );
1750
+ #endif
1751
+
1748
1752
setupDuplicateFeaturesAction();
1749
1753
1750
1754
// support for project storage
@@ -9909,6 +9913,7 @@ Qgs3DMapCanvasDockWidget *QgisApp::open3DMapView( const QString &mapName )
9909
9913
return nullptr;
9910
9914
9911
9915
read3DMapViewSettings( mapCanvasDock3D, elem3DMap );
9916
+ mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );
9912
9917
9913
9918
QgsProject::instance()->views3DManager()->viewOpened( mapName );
9914
9919
@@ -9973,6 +9978,8 @@ Qgs3DMapCanvasDockWidget *QgisApp::duplicate3DMapView( const QString &existingVi
9973
9978
QgsProject::instance()->views3DManager()->register3DViewSettings( newViewName, elem3DMap );
9974
9979
QgsProject::instance()->views3DManager()->viewOpened( newViewName );
9975
9980
9981
+ mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );
9982
+
9976
9983
return mapCanvasDock3D;
9977
9984
#else
9978
9985
Q_UNUSED( existingViewName )
@@ -10072,14 +10079,28 @@ void QgisApp::populate3DMapviewsMenu( QMenu *menu )
10072
10079
#ifdef HAVE_3D
10073
10080
menu->clear();
10074
10081
QList<QAction *> acts;
10075
- const QList< QString > views = QgsProject::instance()->views3DManager()->get3DViewsNames ();
10082
+ QList< QDomElement > views = QgsProject::instance()->views3DManager()->get3DViews ();
10076
10083
acts.reserve( views.size() );
10077
- for ( QString viewName : views )
10084
+ for ( const QDomElement &viewConfig : views )
10078
10085
{
10086
+ QString viewName = viewConfig.attribute( QStringLiteral( "name" ) );
10087
+ bool isOpen = viewConfig.attribute( QStringLiteral( "isOpen" ), QStringLiteral( "1" ) ).toInt() == 1;
10079
10088
QAction *a = new QAction( viewName, menu );
10080
- connect( a, &QAction::triggered, this, [this, viewName]
10089
+ a->setCheckable( true );
10090
+ a->setChecked( isOpen );
10091
+ connect( a, &QAction::triggered, this, [viewName]( bool isChecked )
10081
10092
{
10082
- open3DMapView( viewName );
10093
+ if ( isChecked )
10094
+ {
10095
+ QgisApp::instance()->open3DMapView( viewName );
10096
+ }
10097
+ else
10098
+ {
10099
+ if ( Qgs3DMapCanvasDockWidget *w = QgisApp::instance()->findChild<Qgs3DMapCanvasDockWidget *>( viewName + QStringLiteral( "ViewObject" ) ) )
10100
+ {
10101
+ w->close();
10102
+ }
10103
+ }
10083
10104
} );
10084
10105
acts << a;
10085
10106
}
@@ -10097,6 +10118,7 @@ void QgisApp::populate3DMapviewsMenu( QMenu *menu )
10097
10118
10098
10119
void QgisApp::views3DMenuAboutToShow()
10099
10120
{
10121
+ qDebug() << __PRETTY_FUNCTION__;
10100
10122
populate3DMapviewsMenu( m3DMapViewsMenu );
10101
10123
}
10102
10124
@@ -14059,6 +14081,8 @@ void QgisApp::new3DMapCanvas()
14059
14081
{
14060
14082
QgsProject::instance()->views3DManager()->viewClosed( name );
14061
14083
} );
14084
+
14085
+ mPanelMenu->removeAction( dock->toggleViewAction() );
14062
14086
}
14063
14087
#endif
14064
14088
}
@@ -16761,8 +16785,6 @@ void QgisApp::writeProject( QDomDocument &doc )
16761
16785
write3DMapViewSettings( widget, doc, elem3DMap );
16762
16786
QgsProject::instance()->views3DManager()->register3DViewSettings( viewName, elem3DMap );
16763
16787
}
16764
- // QDomElement elem3DMaps = QgsProject::instance()->views3DManager()->writeXml( doc );
16765
- // qgisNode.appendChild( elem3DMaps );
16766
16788
#endif
16767
16789
projectChanged( doc );
16768
16790
}
@@ -16885,6 +16907,8 @@ void QgisApp::readProject( const QDomDocument &doc )
16885
16907
{
16886
16908
QgsProject::instance()->views3DManager()->viewClosed( viewName );
16887
16909
} );
16910
+
16911
+ mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );
16888
16912
}
16889
16913
#endif
16890
16914
0 commit comments