From a1080e726ad005fc85e516d237069e282ebf1260 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 18 Jul 2022 11:30:19 -0700 Subject: [PATCH] app: reset data panel when a file is replaced --- app/mainwindow.cpp | 4 +++- app/panel.cpp | 5 +++++ app/panel.h | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index 58a7b43..a3f30dc 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -146,13 +146,15 @@ void MainWindow::ReplaceObject(si::Object *obj) { QString s = QFileDialog::getOpenFileName(this, tr("Replace Object")); if (!s.isEmpty()) { - if (!obj->ReplaceWithFile( + if (obj->ReplaceWithFile( #ifdef Q_OS_WINDOWS s.toStdWString().c_str() #else s.toUtf8() #endif )) { + static_cast(config_stack_->currentWidget())->ResetData(); + } else { QMessageBox::critical(this, QString(), tr("Failed to open to file \"%1\".").arg(s)); } } diff --git a/app/panel.cpp b/app/panel.cpp index a0d5c92..1659efa 100644 --- a/app/panel.cpp +++ b/app/panel.cpp @@ -23,6 +23,11 @@ void Panel::SetData(void *data) } } +void Panel::ResetData() +{ + SetData(data_); +} + void Panel::FinishLayout() { outer_layout_->addStretch(); diff --git a/app/panel.h b/app/panel.h index 1c60694..944fe9c 100644 --- a/app/panel.h +++ b/app/panel.h @@ -13,6 +13,8 @@ public: void *GetData() const { return data_; } void SetData(void *data); + void ResetData(); + signals: protected: