Skip to content

Commit

Permalink
Fix cannot use browser dock to create new folders
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 3, 2018
1 parent e375d1d commit faa119f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/core/qgsdataitem.cpp
Expand Up @@ -29,6 +29,8 @@
#include <QStyle>
#include <QDesktopServices>
#include <QFileDialog>
#include <QInputDialog>
#include <QMessageBox>

#include "qgis.h"
#include "qgsdataitem.h"
Expand Down Expand Up @@ -913,6 +915,31 @@ bool QgsDirectoryItem::hiddenPath( const QString &path )
QList<QAction *> QgsDirectoryItem::actions( QWidget *parent )
{
QList<QAction *> result;

QAction *createFolder = new QAction( tr( "New Directory…" ), parent );
connect( createFolder, &QAction::triggered, this, [ = ]
{
bool ok = false;
const QString name = QInputDialog::getText( parent, tr( "Create Directory" ), tr( "Directory name" ), QLineEdit::Normal, QString(), &ok );
if ( ok && !name.isEmpty() )
{
QDir dir( mDirPath );
if ( !dir.mkdir( name ) )
{
QMessageBox::warning( parent, tr( "Create Directory" ), tr( "Could not create directory “%1”" ).arg( QDir::toNativeSeparators( dir.absoluteFilePath( name ) ) ) );
}
else
{
refresh();
}
}
} );
result << createFolder;

QAction *sep = new QAction();
sep->setSeparator( true );
result << sep;

QAction *openFolder = new QAction( tr( "Open Directory…" ), parent );
connect( openFolder, &QAction::triggered, this, [ = ]
{
Expand Down

0 comments on commit faa119f

Please sign in to comment.