LibGUI: Add a cancel button callback to settings window tabs

Some settings tabs, like the ones on the upcoming terminal settings,
need to know when the cancel button is pressed to clean up things like
temporary live updates. Therefore, the SettingsWindow::Tab now features
a cancel_settings callback which does not need to be implemented.
This commit is contained in:
kleines Filmröllchen 2021-11-21 00:57:07 +01:00 committed by Andreas Kling
parent 72e9d024b9
commit 1e9554145e
2 changed files with 4 additions and 1 deletions

View file

@ -58,6 +58,8 @@ SettingsWindow::SettingsWindow(StringView title, ShowDefaultsButton show_default
m_cancel_button = button_container.add<GUI::Button>("Cancel");
m_cancel_button->set_fixed_width(75);
m_cancel_button->on_click = [&](auto) {
for (auto& tab : m_tabs)
tab.cancel_settings();
GUI::Application::the()->quit();
};

View file

@ -20,7 +20,8 @@ public:
class Tab : public GUI::Widget {
public:
virtual void apply_settings() = 0;
virtual void reset_default_values() {};
virtual void cancel_settings() { }
virtual void reset_default_values() { }
};
enum class ShowDefaultsButton {