Skip to content
Permalink
Browse files

Fix cannot use browser dock to create new folders

  • Loading branch information
nyalldawson committed Oct 3, 2018
1 parent e375d1d commit faa119fef5cadaf6c230c1f43123f7d88d61d4c7
Showing with 27 additions and 0 deletions.
  1. +27 −0 src/core/qgsdataitem.cpp
@@ -29,6 +29,8 @@
#include <QStyle>
#include <QDesktopServices>
#include <QFileDialog>
#include <QInputDialog>
#include <QMessageBox>

#include "qgis.h"
#include "qgsdataitem.h"
@@ -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, [ = ]
{

0 comments on commit faa119f

Please sign in to comment.
You can’t perform that action at this time.