Skip to content
Permalink
Browse files

Correctly parent actions

  • Loading branch information
nyalldawson committed Oct 3, 2018
1 parent faa119f commit 5774b9a85bb45900ae901cd1f25ecae34b554a04
Showing with 14 additions and 5 deletions.
  1. +14 −5 src/core/qgsdataitem.cpp
@@ -920,13 +920,22 @@ QList<QAction *> QgsDirectoryItem::actions( QWidget *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 );

QWidget *parentWindow = parent;
while ( parentWindow->parentWidget() )
parentWindow = parentWindow->parentWidget();

const QString name = QInputDialog::getText( parentWindow, tr( "Create Directory" ), tr( "Directory name" ), QLineEdit::Normal, QString(), &ok );
if ( ok && !name.isEmpty() )
{
QDir dir( mDirPath );
if ( !dir.mkdir( name ) )
if ( QFileInfo::exists( dir.absoluteFilePath( name ) ) )
{
QMessageBox::critical( parentWindow, tr( "Create Directory" ), tr( "The path “%1” already exists." ).arg( QDir::toNativeSeparators( dir.absoluteFilePath( name ) ) ) );
}
else if ( !dir.mkdir( name ) )
{
QMessageBox::warning( parent, tr( "Create Directory" ), tr( "Could not create directory “%1”" ).arg( QDir::toNativeSeparators( dir.absoluteFilePath( name ) ) ) );
QMessageBox::critical( parentWindow, tr( "Create Directory" ), tr( "Could not create directory “%1”." ).arg( QDir::toNativeSeparators( dir.absoluteFilePath( name ) ) ) );
}
else
{
@@ -936,7 +945,7 @@ QList<QAction *> QgsDirectoryItem::actions( QWidget *parent )
} );
result << createFolder;

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

@@ -1522,7 +1531,7 @@ QList<QAction *> QgsProjectHomeItem::actions( QWidget *parent )
connect( setHome, &QAction::triggered, this, [ = ]
{
QString oldHome = QgsProject::instance()->homePath();
QString newPath = QFileDialog::getExistingDirectory( parent, tr( "Select Project Home Directory" ), oldHome );
QString newPath = QFileDialog::getExistingDirectory( parent->window(), tr( "Select Project Home Directory" ), oldHome );
if ( !newPath.isEmpty() )
{
QgsProject::instance()->setPresetHomePath( newPath );

0 comments on commit 5774b9a

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