Skip to content

Commit f455b9e

Browse files
committedNov 4, 2018
[needs-docs] Add right click context actions to Project files
in browser With options to - load project - open project file properties (operating system file properties dialog that is, on supported platforms only)
1 parent fa3a08e commit f455b9e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed
 

‎src/app/browser/qgsinbuiltdataitemproviders.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,29 @@ QString QgsProjectItemGuiProvider::name()
453453
return QStringLiteral( "project_items" );
454454
}
455455

456-
void QgsProjectItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &selectedItems, QgsDataItemGuiContext context )
456+
void QgsProjectItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &, QgsDataItemGuiContext )
457457
{
458458
if ( !item || item->type() != QgsDataItem::Project )
459459
return;
460460

461461
if ( QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item ) )
462462
{
463-
// TODO add actions
463+
QAction *openAction = new QAction( tr( "Open Project" ), menu );
464+
const QString projectPath = projectItem->path();
465+
connect( openAction, &QAction::triggered, this, [projectPath]
466+
{
467+
QgisApp::instance()->openProject( projectPath );
468+
} );
469+
menu->addAction( openAction );
470+
471+
if ( QgsGui::nativePlatformInterface()->capabilities() & QgsNative::NativeFilePropertiesDialog )
472+
{
473+
QAction *action = menu->addAction( tr( "File Properties…" ) );
474+
connect( action, &QAction::triggered, this, [projectPath]
475+
{
476+
QgsGui::nativePlatformInterface()->showFileProperties( projectPath );
477+
} );
478+
}
464479
}
465480
}
466481

0 commit comments

Comments
 (0)
Please sign in to comment.