diff --git a/images/images.qrc b/images/images.qrc index b76ca481c0f..51f3d20b8c1 100644 --- a/images/images.qrc +++ b/images/images.qrc @@ -744,6 +744,7 @@ themes/default/mIconFieldBool.svg themes/default/mIconDataDefineColor.svg themes/default/mIconDataDefineColorOn.svg + themes/default/mActionNewVirtualLayer.svg qgis_tips/symbol_levels.png diff --git a/images/themes/default/mActionNewVirtualLayer.svg b/images/themes/default/mActionNewVirtualLayer.svg new file mode 100644 index 00000000000..9455657a2f8 --- /dev/null +++ b/images/themes/default/mActionNewVirtualLayer.svg @@ -0,0 +1,152 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index a9675c0623f..a1b04f58099 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -2203,6 +2203,7 @@ void QgisApp::createActions() connect( mActionNewSpatiaLiteLayer, &QAction::triggered, this, &QgisApp::newSpatialiteLayer ); connect( mActionNewGeoPackageLayer, &QAction::triggered, this, &QgisApp::newGeoPackageLayer ); connect( mActionNewMemoryLayer, &QAction::triggered, this, &QgisApp::newMemoryLayer ); + connect( mActionNewVirtualLayer, &QAction::triggered, this, &QgisApp::addVirtualLayer ); connect( mActionShowRasterCalculator, &QAction::triggered, this, &QgisApp::showRasterCalculator ); connect( mActionShowMeshCalculator, &QAction::triggered, this, &QgisApp::showMeshCalculator ); connect( mActionShowAlignRasterTool, &QAction::triggered, this, &QgisApp::showAlignRasterTool ); @@ -5316,7 +5317,7 @@ void QgisApp::addDatabaseLayers( QStringList const &layerPathList, QString const void QgisApp::addVirtualLayer() { - // show the Delimited text dialog + // show the virtual layer dialog QDialog *dts = dynamic_cast( QgsProviderRegistry::instance()->createSelectionWidget( QStringLiteral( "virtual" ), this ) ); if ( !dts ) { @@ -5324,7 +5325,7 @@ void QgisApp::addVirtualLayer() return; } connect( dts, SIGNAL( addVectorLayer( QString, QString, QString ) ), - this, SLOT( addSelectedVectorLayer( QString, QString, QString ) ) ); + this, SLOT( onVirtualLayerAdded( QString, QString ) ) ); connect( dts, SIGNAL( replaceVectorLayer( QString, QString, QString, QString ) ), this, SLOT( replaceSelectedVectorLayer( QString, QString, QString, QString ) ) ); dts->exec(); @@ -12137,6 +12138,11 @@ int QgisApp::addDatabaseToolBarIcon( QAction *qAction ) return 0; } +void QgisApp::onVirtualLayerAdded( const QString &uri, const QString &layerName ) +{ + addVectorLayer( uri, layerName, QStringLiteral( "virtual" ) ); +} + QAction *QgisApp::addDatabaseToolBarWidget( QWidget *widget ) { return mDatabaseToolBar->addWidget( widget ); diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index c8a6e50896f..788b36515e1 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -1244,6 +1244,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow //! Add an icon to the Database toolbar int addDatabaseToolBarIcon( QAction *qAction ); + void onVirtualLayerAdded( const QString &uri, const QString &layerName ); + /** * Add a widget to the database toolbar. * To remove this widget again, call removeDatabaseToolBarIcon() diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index 818599b46e3..26eb95b0dff 100644 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -164,6 +164,8 @@ + + @@ -683,6 +685,8 @@ + + @@ -3171,6 +3175,18 @@ Acts on currently active editable layer Add Mesh Layer... + + + + :/images/themes/default/mActionNewVirtualLayer.svg:/images/themes/default/mActionNewVirtualLayer.svg + + + New Virtual Layer… + + + New Virtual Layer + +