Skip to content

Commit 218da5a

Browse files
committed
Add drag and drop for QLR files. Fix #10005
1 parent 317a509 commit 218da5a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/app/qgisapp.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -2462,10 +2462,10 @@ void QgisApp::addLayerDefinition()
24622462
if ( path.isEmpty() )
24632463
return;
24642464

2465-
QList<QgsMapLayer*> layers = QgsMapLayer::fromLayerDefinitionFile( path );
2466-
QgsMapLayerRegistry::instance()->addMapLayers( layers );
2465+
openLayerDefinition( path );
24672466
}
24682467

2468+
24692469
/**
24702470
This method prompts the user for a list of vector file names with a dialog.
24712471
*/
@@ -3806,6 +3806,12 @@ void QgisApp::dxfExport()
38063806
}
38073807
}
38083808

3809+
void QgisApp::openLayerDefinition( const QString & path )
3810+
{
3811+
QList<QgsMapLayer*> layers = QgsMapLayer::fromLayerDefinitionFile( path );
3812+
QgsMapLayerRegistry::instance()->addMapLayers( layers );
3813+
}
3814+
38093815
// Open the project file corresponding to the
38103816
// path at the given index in mRecentProjectPaths
38113817
void QgisApp::openProject( QAction *action )
@@ -3914,6 +3920,10 @@ void QgisApp::openFile( const QString & fileName )
39143920
QgsDebugMsg( "Opening project " + fileName );
39153921
openProject( fileName );
39163922
}
3923+
else if ( fi.completeSuffix() == "qlr" )
3924+
{
3925+
openLayerDefinition( fileName );
3926+
}
39173927
else
39183928
{
39193929
QgsDebugMsg( "Adding " + fileName + " to the map canvas" );

src/app/qgisapp.h

+2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
164164
Used to process a commandline argument, FileOpen or Drop event.
165165
*/
166166
void openProject( const QString & fileName );
167+
168+
void openLayerDefinition( const QString & filename );
167169
/** opens a qgis project file
168170
@returns false if unable to open the project
169171
*/

0 commit comments

Comments
 (0)