Skip to content

Commit b43d0a4

Browse files
NEDJIMAbelgacemnyalldawson
authored andcommittedJan 12, 2022
remove 3D views from view->panels and make checkable in view->3d views
1 parent 05824dc commit b43d0a4

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers
17451745

17461746
setupLayoutManagerConnections();
17471747

1748+
#ifdef HAVE_3D
1749+
connect( QgsProject::instance()->views3DManager(), &Qgs3DViewsManager::viewsListChanged, this, &QgisApp::views3DMenuAboutToShow );
1750+
#endif
1751+
17481752
setupDuplicateFeaturesAction();
17491753

17501754
// support for project storage
@@ -9909,6 +9913,7 @@ Qgs3DMapCanvasDockWidget *QgisApp::open3DMapView( const QString &mapName )
99099913
return nullptr;
99109914

99119915
read3DMapViewSettings( mapCanvasDock3D, elem3DMap );
9916+
mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );
99129917

99139918
QgsProject::instance()->views3DManager()->viewOpened( mapName );
99149919

@@ -9973,6 +9978,8 @@ Qgs3DMapCanvasDockWidget *QgisApp::duplicate3DMapView( const QString &existingVi
99739978
QgsProject::instance()->views3DManager()->register3DViewSettings( newViewName, elem3DMap );
99749979
QgsProject::instance()->views3DManager()->viewOpened( newViewName );
99759980

9981+
mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );
9982+
99769983
return mapCanvasDock3D;
99779984
#else
99789985
Q_UNUSED( existingViewName )
@@ -10072,14 +10079,28 @@ void QgisApp::populate3DMapviewsMenu( QMenu *menu )
1007210079
#ifdef HAVE_3D
1007310080
menu->clear();
1007410081
QList<QAction *> acts;
10075-
const QList< QString > views = QgsProject::instance()->views3DManager()->get3DViewsNames();
10082+
QList< QDomElement > views = QgsProject::instance()->views3DManager()->get3DViews();
1007610083
acts.reserve( views.size() );
10077-
for ( QString viewName : views )
10084+
for ( const QDomElement &viewConfig : views )
1007810085
{
10086+
QString viewName = viewConfig.attribute( QStringLiteral( "name" ) );
10087+
bool isOpen = viewConfig.attribute( QStringLiteral( "isOpen" ), QStringLiteral( "1" ) ).toInt() == 1;
1007910088
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 )
1008110092
{
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+
}
1008310104
} );
1008410105
acts << a;
1008510106
}
@@ -10097,6 +10118,7 @@ void QgisApp::populate3DMapviewsMenu( QMenu *menu )
1009710118

1009810119
void QgisApp::views3DMenuAboutToShow()
1009910120
{
10121+
qDebug() << __PRETTY_FUNCTION__;
1010010122
populate3DMapviewsMenu( m3DMapViewsMenu );
1010110123
}
1010210124

@@ -14059,6 +14081,8 @@ void QgisApp::new3DMapCanvas()
1405914081
{
1406014082
QgsProject::instance()->views3DManager()->viewClosed( name );
1406114083
} );
14084+
14085+
mPanelMenu->removeAction( dock->toggleViewAction() );
1406214086
}
1406314087
#endif
1406414088
}
@@ -16761,8 +16785,6 @@ void QgisApp::writeProject( QDomDocument &doc )
1676116785
write3DMapViewSettings( widget, doc, elem3DMap );
1676216786
QgsProject::instance()->views3DManager()->register3DViewSettings( viewName, elem3DMap );
1676316787
}
16764-
// QDomElement elem3DMaps = QgsProject::instance()->views3DManager()->writeXml( doc );
16765-
// qgisNode.appendChild( elem3DMaps );
1676616788
#endif
1676716789
projectChanged( doc );
1676816790
}
@@ -16885,6 +16907,8 @@ void QgisApp::readProject( const QDomDocument &doc )
1688516907
{
1688616908
QgsProject::instance()->views3DManager()->viewClosed( viewName );
1688716909
} );
16910+
16911+
mPanelMenu->removeAction( mapCanvasDock3D->toggleViewAction() );
1688816912
}
1688916913
#endif
1689016914

‎src/core/3d/qgs3dviewsmanager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ void Qgs3DViewsManager::rename3DView( const QString &oldTitle, const QString &ne
9292
QDomElement elem = m3DMapViewsDom.value( oldTitle );
9393
m3DMapViewsDom.remove( oldTitle );
9494
m3DMapViewsDom[ newTitle ] = elem;
95+
m3DMapViewsDom[ newTitle ].setAttribute( QStringLiteral( "name" ), newTitle );
9596
emit viewsListChanged();
9697
}
9798

0 commit comments

Comments
 (0)
Please sign in to comment.