Skip to content

Commit

Permalink
Closing the 3d settings dialog should also apply unapplied changes
Browse files Browse the repository at this point in the history
Make this dialog more standard, with Apply / Cancel / Ok buttons
so that it works just like other QGIS apply-able dialogs.
  • Loading branch information
nyalldawson committed Nov 10, 2022
1 parent 090cc94 commit f307c0f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/3d/qgs3dmapcanvaswidget.cpp
Expand Up @@ -412,7 +412,7 @@ void Qgs3DMapCanvasWidget::configure()

Qgs3DMapSettings *map = mCanvas->map();
Qgs3DMapConfigWidget *w = new Qgs3DMapConfigWidget( map, mMainCanvas, mCanvas, mConfigureDialog );
QDialogButtonBox *buttons = new QDialogButtonBox( QDialogButtonBox::Apply | QDialogButtonBox::Close | QDialogButtonBox::Help, mConfigureDialog );
QDialogButtonBox *buttons = new QDialogButtonBox( QDialogButtonBox::Apply | QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, mConfigureDialog );

auto applyConfig = [ = ]()
{
Expand Down Expand Up @@ -446,14 +446,17 @@ void Qgs3DMapCanvasWidget::configure()
connect( buttons, &QDialogButtonBox::rejected, mConfigureDialog, &QDialog::reject );
connect( buttons, &QDialogButtonBox::clicked, mConfigureDialog, [ = ]( QAbstractButton * button )
{
if ( buttons->buttonRole( button ) == QDialogButtonBox::ApplyRole )
if ( button == buttons->button( QDialogButtonBox::Apply ) || button == buttons->button( QDialogButtonBox::Ok ) )
applyConfig();
if ( button == buttons->button( QDialogButtonBox::Ok ) )
mConfigureDialog->accept();
} );
connect( buttons, &QDialogButtonBox::helpRequested, w, []() { QgsHelp::openHelp( QStringLiteral( "introduction/qgis_gui.html#scene-configuration" ) ); } );

connect( w, &Qgs3DMapConfigWidget::isValidChanged, this, [ = ]( bool valid )
{
buttons->button( QDialogButtonBox::Apply )->setEnabled( valid );
buttons->button( QDialogButtonBox::Ok )->setEnabled( valid );
} );

QVBoxLayout *layout = new QVBoxLayout( mConfigureDialog );
Expand Down

0 comments on commit f307c0f

Please sign in to comment.