Skip to content

Commit c20d083

Browse files
committedMar 21, 2023
Make Execute SQL dialog non-modal
Allows running mutiple sql concurrently, and checking layer properties etc while the dialog is open
1 parent 1a29880 commit c20d083

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed
 

‎src/app/browser/qgsinbuiltdataitemproviders.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,9 +1711,11 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *
17111711
// Create the SQL dialog: this might become an independent class dialog in the future, for now
17121712
// we are still prototyping the features that this dialog will have.
17131713

1714-
QgsDialog dialog;
1715-
dialog.setObjectName( QStringLiteral( "SQLCommandsDialog" ) );
1716-
dialog.setWindowTitle( tr( "%1 — Execute SQL" ).arg( item->name() ) );
1714+
QMainWindow *dialog = new QMainWindow();
1715+
dialog->setObjectName( QStringLiteral( "SQLCommandsDialog" ) );
1716+
dialog->setWindowTitle( tr( "%1 — Execute SQL" ).arg( item->name() ) );
1717+
QgsGui::enableAutoGeometryRestore( dialog );
1718+
dialog->setAttribute( Qt::WA_DeleteOnClose );
17171719

17181720
// If this is a layer item (or below the hierarchy) we can pre-set the query to something
17191721
// meaningful
@@ -1737,11 +1739,9 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *
17371739
tableName, 10 );
17381740
}
17391741

1740-
QgsGui::enableAutoGeometryRestore( &dialog );
1741-
QgsQueryResultWidget *widget { new QgsQueryResultWidget( &dialog, conn2.release() ) };
1742+
QgsQueryResultWidget *widget { new QgsQueryResultWidget( nullptr, conn2.release() ) };
17421743
widget->setQuery( sql );
1743-
widget->layout()->setContentsMargins( 0, 0, 0, 0 );
1744-
dialog.layout()->addWidget( widget );
1744+
dialog->setCentralWidget( widget );
17451745

17461746
connect( widget, &QgsQueryResultWidget::createSqlVectorLayer, widget, [ item, context ]( const QString &, const QString &, const QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions & options )
17471747
{
@@ -1757,9 +1757,7 @@ void QgsDatabaseItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *
17571757
}
17581758

17591759
} );
1760-
dialog.exec();
1761-
1762-
1760+
dialog->show();
17631761
} );
17641762
menu->addAction( sqlAction );
17651763
}

0 commit comments

Comments
 (0)
Please sign in to comment.