Skip to content

Commit

Permalink
[needs-docs] Add right click context actions to Project files
Browse files Browse the repository at this point in the history
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 4, 2018
1 parent fa3a08e commit f455b9e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/app/browser/qgsinbuiltdataitemproviders.cpp
Expand Up @@ -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 );
} );
}
}
}

Expand Down

0 comments on commit f455b9e

Please sign in to comment.