/* * Copyright (c) 2020, Idan Horowitz * Copyright (c) 2021, the SerenityOS developers. * Copyright (c) 2021, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace GUI { class SettingsWindow : public GUI::Window { C_OBJECT(SettingsWindow) public: class Tab : public GUI::Widget { public: virtual void apply_settings() = 0; virtual void cancel_settings() { } virtual void reset_default_values() { } }; enum class ShowDefaultsButton { Yes, No, }; static ErrorOr> create(String title, ShowDefaultsButton = ShowDefaultsButton::No); virtual ~SettingsWindow() override; template ErrorOr> add_tab(String title, Args&&... args) { auto tab = TRY(m_tab_widget->try_add_tab(move(title), forward(args)...)); TRY(m_tabs.try_append(tab)); return tab; } private: SettingsWindow(); RefPtr m_tab_widget; NonnullRefPtrVector m_tabs; RefPtr m_ok_button; RefPtr m_cancel_button; RefPtr m_apply_button; RefPtr m_reset_button; }; }