Skip to content

Commit

Permalink
[FEATURE] Add 'open directory' action to right click menu for
Browse files Browse the repository at this point in the history
folders in browser dock

Opens the folder in the OS' file explorer
  • Loading branch information
nyalldawson committed Sep 19, 2017
1 parent dc72e14 commit 6ce3c61
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/core/qgsdataitem.sip
Expand Up @@ -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();
Expand Down
13 changes: 13 additions & 0 deletions src/core/qgsdataitem.cpp
Expand Up @@ -27,6 +27,7 @@
#include <QTreeWidgetItem>
#include <QVector>
#include <QStyle>
#include <QDesktopServices>

#include "qgis.h"
#include "qgsdataitem.h"
Expand Down Expand Up @@ -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()
{
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsdataitem.h
Expand Up @@ -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;
Expand Down

0 comments on commit 6ce3c61

Please sign in to comment.