Skip to content
Permalink
Browse files

[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)
  • Loading branch information
nyalldawson committed Nov 1, 2018
1 parent fa3a08e commit f455b9ed34e9bd64779993a49a9b43fa4b4147f0
Showing with 17 additions and 2 deletions.
  1. +17 −2 src/app/browser/qgsinbuiltdataitemproviders.cpp
@@ -453,14 +453,29 @@ QString QgsProjectItemGuiProvider::name()
return QStringLiteral( "project_items" );
}

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

if ( QgsProjectItem *projectItem = qobject_cast<QgsProjectItem *>( item ) )
{
// TODO add actions
QAction *openAction = new QAction( tr( "Open Project" ), menu );
const QString projectPath = projectItem->path();
connect( openAction, &QAction::triggered, this, [projectPath]
{
QgisApp::instance()->openProject( projectPath );
} );
menu->addAction( openAction );

if ( QgsGui::nativePlatformInterface()->capabilities() & QgsNative::NativeFilePropertiesDialog )
{
QAction *action = menu->addAction( tr( "File Properties…" ) );
connect( action, &QAction::triggered, this, [projectPath]
{
QgsGui::nativePlatformInterface()->showFileProperties( projectPath );
} );
}
}
}

0 comments on commit f455b9e

Please sign in to comment.
You can’t perform that action at this time.