diff --git a/src/prefs/PrefsDialog.cpp b/src/prefs/PrefsDialog.cpp index de3c28539..6e4b9abb8 100644 --- a/src/prefs/PrefsDialog.cpp +++ b/src/prefs/PrefsDialog.cpp @@ -280,6 +280,10 @@ PrefsDialog::PrefsDialog S.EndHorizontalLay(); } else { + // TODO: Look into getting rid of mUniquePage and instead + // adding into mCategories, so there is just one page in mCategories. + // And then hiding the trrebook. + // Unique page, don't show the factory const PrefsNode &node = factories[0]; PrefsPanelFactory &factory = *node.pFactory; @@ -386,18 +390,25 @@ void PrefsDialog::OnCancel(wxCommandEvent & WXUNUSED(event)) EndModal(false); } +PrefsPanel * PrefsDialog::GetCurrentPanel() +{ + if( mCategories) + return static_cast(mCategories->GetCurrentPage()); + else + { + wxASSERT( mUniquePage ); + return mUniquePage; + } +} + void PrefsDialog::OnApply(wxCommandEvent & WXUNUSED(event)) { - if (mCategories) - static_cast(mCategories->GetCurrentPage())->Apply(); - else - mUniquePage->Apply(); + GetCurrentPanel()->Apply(); } void PrefsDialog::OnHelp(wxCommandEvent & WXUNUSED(event)) { - PrefsPanel* panel = static_cast(mCategories->GetCurrentPage()); - HelpSystem::ShowHelpDialog(this, panel->HelpPageName(), true); + HelpSystem::ShowHelpDialog(this, GetCurrentPanel()->HelpPageName(), true); } void PrefsDialog::OnTreeKeyDown(wxTreeEvent & event) diff --git a/src/prefs/PrefsDialog.h b/src/prefs/PrefsDialog.h index b545d985e..893e2d6d6 100644 --- a/src/prefs/PrefsDialog.h +++ b/src/prefs/PrefsDialog.h @@ -78,6 +78,7 @@ class PrefsDialog /* not final */ : public wxDialogWrapper private: void RecordExpansionState(); + PrefsPanel * GetCurrentPanel(); wxTreebook *mCategories{}; PrefsPanel *mUniquePage{}; Factories &mFactories;