app: reset data panel when a file is replaced

This commit is contained in:
itsmattkc 2022-07-18 11:30:19 -07:00
parent bc4ddfd7ac
commit a1080e726a
3 changed files with 10 additions and 1 deletions

View file

@ -146,13 +146,15 @@ void MainWindow::ReplaceObject(si::Object *obj)
{ {
QString s = QFileDialog::getOpenFileName(this, tr("Replace Object")); QString s = QFileDialog::getOpenFileName(this, tr("Replace Object"));
if (!s.isEmpty()) { if (!s.isEmpty()) {
if (!obj->ReplaceWithFile( if (obj->ReplaceWithFile(
#ifdef Q_OS_WINDOWS #ifdef Q_OS_WINDOWS
s.toStdWString().c_str() s.toStdWString().c_str()
#else #else
s.toUtf8() s.toUtf8()
#endif #endif
)) { )) {
static_cast<Panel*>(config_stack_->currentWidget())->ResetData();
} else {
QMessageBox::critical(this, QString(), tr("Failed to open to file \"%1\".").arg(s)); QMessageBox::critical(this, QString(), tr("Failed to open to file \"%1\".").arg(s));
} }
} }

View file

@ -23,6 +23,11 @@ void Panel::SetData(void *data)
} }
} }
void Panel::ResetData()
{
SetData(data_);
}
void Panel::FinishLayout() void Panel::FinishLayout()
{ {
outer_layout_->addStretch(); outer_layout_->addStretch();

View file

@ -13,6 +13,8 @@ public:
void *GetData() const { return data_; } void *GetData() const { return data_; }
void SetData(void *data); void SetData(void *data);
void ResetData();
signals: signals:
protected: protected: