Skip to content

Commit

Permalink
[processing] Fix annoying loss of matrix parameter table values
Browse files Browse the repository at this point in the history
if back button is pressed in table panel instead of "Ok"

The back button was treated as "cancel", but now the "cancel" only
happens if the user explicitly hits the Cancel button.
  • Loading branch information
nyalldawson committed Dec 8, 2022
1 parent 928689d commit 3a04bb5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/gui/processing/qgsprocessingmatrixparameterdialog.cpp
Expand Up @@ -43,14 +43,16 @@ QgsProcessingMatrixParameterPanelWidget::QgsProcessingMatrixParameterPanelWidget
mButtonRemoveAll = new QPushButton( tr( "Remove All" ) );
mButtonBox->addButton( mButtonRemoveAll, QDialogButtonBox::ActionRole );

connect( mButtonBox->button( QDialogButtonBox::Ok ), &QPushButton::clicked, this, [ = ]
connect( mButtonBox->button( QDialogButtonBox::Ok ), &QPushButton::clicked, this, &QgsPanelWidget::acceptPanel );
connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QPushButton::clicked, this, [ = ]
{
emit widgetChanged();
mWasCanceled = true;
acceptPanel();
} );
connect( mButtonBox->button( QDialogButtonBox::Cancel ), &QPushButton::clicked, this, [ = ]
connect( this, &QgsPanelWidget::panelAccepted, this, [ = ]()
{
acceptPanel();
if ( !mWasCanceled )
emit widgetChanged();
} );

connect( mButtonAdd, &QPushButton::clicked, this, &QgsProcessingMatrixParameterPanelWidget::addRow );
Expand Down
1 change: 1 addition & 0 deletions src/gui/processing/qgsprocessingmatrixparameterdialog.h
Expand Up @@ -64,6 +64,7 @@ class GUI_EXPORT QgsProcessingMatrixParameterPanelWidget : public QgsPanelWidget
QPushButton *mButtonRemoveAll = nullptr;
const QgsProcessingParameterMatrix *mParam = nullptr;
QStandardItemModel *mModel = nullptr;
bool mWasCanceled = false;

void populateTable( const QVariantList &contents );

Expand Down

0 comments on commit 3a04bb5

Please sign in to comment.