Skip to content

Commit

Permalink
[browser] Do not show the file properties menu action for non-file items
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Sep 17, 2019
1 parent 0fcba4e commit 6fd7d4b
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/app/browser/qgsinbuiltdataitemproviders.cpp
Expand Up @@ -36,6 +36,8 @@
#include "qgsapplication.h"
#include "processing/qgsprojectstylealgorithms.h"
#include "qgsstylemanagerdialog.h"

#include <QFileInfo>
#include <QMenu>
#include <QInputDialog>
#include <QMessageBox>
Expand Down Expand Up @@ -429,11 +431,23 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men

if ( QgsGui::nativePlatformInterface()->capabilities() & QgsNative::NativeFilePropertiesDialog )
{
QAction *action = menu->addAction( tr( "File Properties…" ) );
connect( action, &QAction::triggered, this, [ = ]
bool isFile = false;
if ( layerItem )
{
QgsGui::nativePlatformInterface()->showFileProperties( item->path() );
} );
isFile = layerItem->providerKey() == QStringLiteral( "ogr" ) || layerItem->providerKey() == QStringLiteral( "gdal" );
}
else
{
isFile = QFileInfo::exists( item->path() );
}
if ( isFile )
{
QAction *action = menu->addAction( tr( "File Properties…" ) );
connect( action, &QAction::triggered, this, [ = ]
{
QgsGui::nativePlatformInterface()->showFileProperties( item->path() );
} );
}
}
}

Expand Down

0 comments on commit 6fd7d4b

Please sign in to comment.