From 0131d83256c203c83be291b8f27c29b5fff323ba Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 9 Mar 2020 19:56:10 +1100 Subject: [PATCH] footageproperties: allow for sanity checks before accepting/making changes --- .../footageproperties/footageproperties.cpp | 15 +++++++++++++-- .../streamproperties/streamproperties.h | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/dialog/footageproperties/footageproperties.cpp b/app/dialog/footageproperties/footageproperties.cpp index fa5063540..ea543b811 100644 --- a/app/dialog/footageproperties/footageproperties.cpp +++ b/app/dialog/footageproperties/footageproperties.cpp @@ -91,11 +91,22 @@ FootagePropertiesDialog::FootagePropertiesDialog(QWidget *parent, Footage *foota buttons->setCenterButtons(true); layout->addWidget(buttons, row, 0, 1, 2); - connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttons, &QDialogButtonBox::rejected, this, &QDialog::reject); } void FootagePropertiesDialog::accept() { + // Perform sanity check on all pages + for (int i=0;icount();i++) { + if (!static_cast(stacked_widget_->widget(i))->SanityCheck()) { + // Switch to the failed panel in question + stacked_widget_->setCurrentIndex(i); + + // Do nothing (it's up to the property panel itself to throw the error message) + return; + } + } + QUndoCommand* command = new QUndoCommand(); if (footage_->name() != footage_name_field_->text()) { diff --git a/app/dialog/footageproperties/streamproperties/streamproperties.h b/app/dialog/footageproperties/streamproperties/streamproperties.h index 72840f010..30f8d7aa5 100644 --- a/app/dialog/footageproperties/streamproperties/streamproperties.h +++ b/app/dialog/footageproperties/streamproperties/streamproperties.h @@ -30,6 +30,9 @@ public: StreamProperties(QWidget* parent = nullptr); virtual void Accept(QUndoCommand*){} + + virtual bool SanityCheck(){return true;} + }; #endif // STREAMPROPERTIES_H