Skip to content

Commit

Permalink
Add an iface.mapCanvas() to get to the main map canvas easily
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Apr 15, 2024
1 parent bc43828 commit d3f2fea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/appinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ void AppInterface::addItemToCanvasActionsToolbar( QQuickItem *item ) const
}
}

QObject *AppInterface::mapCanvas() const
{
if ( !mApp->rootObjects().isEmpty() )
{
return mApp->rootObjects().at( 0 )->findChild<QObject *>( "mapCanvas" );
}
return nullptr;
}

void AppInterface::removeRecentProject( const QString &path )
{
return mApp->removeRecentProject( path );
Expand Down
5 changes: 5 additions & 0 deletions src/core/appinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class AppInterface : public QObject
*/
Q_INVOKABLE void addItemToCanvasActionsToolbar( QQuickItem *item ) const;

/**
* Returns the main map canvas.
*/
Q_INVOKABLE QObject *mapCanvas() const;

static void setInstance( AppInterface *instance ) { sAppInterface = instance; }
static AppInterface *instance() { return sAppInterface; }

Expand Down

0 comments on commit d3f2fea

Please sign in to comment.