[FEATURE] Add 'open directory' action to right click menu for

folders in browser dock

Opens the folder in the OS' file explorer
This commit is contained in:
Nyall Dawson 2017-09-20 09:24:02 +10:00
parent dc72e140e9
commit 6ce3c6100d
3 changed files with 18 additions and 0 deletions

View File

@ -533,6 +533,9 @@ Check if the given path is hidden from the browser model
:rtype: bool
%End
virtual QList<QAction *> actions();
public slots:
virtual void childrenCreated();

View File

@ -27,6 +27,7 @@
#include <QTreeWidgetItem>
#include <QVector>
#include <QStyle>
#include <QDesktopServices>
#include "qgis.h"
#include "qgsdataitem.h"
@ -852,6 +853,18 @@ bool QgsDirectoryItem::hiddenPath( const QString &path )
return ( idx > -1 );
}
QList<QAction *> QgsDirectoryItem::actions()
{
QList<QAction *> result;
QAction *openFolder = new QAction( tr( "Open Directory…" ), this );
connect( openFolder, &QAction::triggered, this, [ = ]
{
QDesktopServices::openUrl( QUrl::fromLocalFile( mDirPath ) );
} );
result << openFolder;
return result;
}
void QgsDirectoryItem::childrenCreated()
{

View File

@ -476,6 +476,8 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
//! Check if the given path is hidden from the browser model
static bool hiddenPath( const QString &path );
QList<QAction *> actions() override;
public slots:
virtual void childrenCreated() override;