SettingsWindow.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2020, Idan Horowitz <idan.horowitz@serenityos.org>
  3. * Copyright (c) 2021, the SerenityOS developers.
  4. * Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #pragma once
  9. #include <LibGUI/Button.h>
  10. #include <LibGUI/TabWidget.h>
  11. #include <LibGUI/Window.h>
  12. namespace GUI {
  13. class SettingsWindow : public GUI::Window {
  14. C_OBJECT(SettingsWindow)
  15. public:
  16. class Tab : public GUI::Widget {
  17. public:
  18. virtual void apply_settings() = 0;
  19. virtual void reset_default_values() {};
  20. };
  21. enum class ShowDefaultsButton {
  22. Yes,
  23. No,
  24. };
  25. virtual ~SettingsWindow() override;
  26. template<class T, class... Args>
  27. T& add_tab(StringView const& title, Args&&... args)
  28. {
  29. auto& t = m_tab_widget->add_tab<T>(title, forward<Args>(args)...);
  30. m_tabs.append(t);
  31. return t;
  32. }
  33. private:
  34. SettingsWindow(StringView title, ShowDefaultsButton = ShowDefaultsButton::No);
  35. RefPtr<GUI::TabWidget> m_tab_widget;
  36. NonnullRefPtrVector<Tab> m_tabs;
  37. RefPtr<GUI::Button> m_ok_button;
  38. RefPtr<GUI::Button> m_cancel_button;
  39. RefPtr<GUI::Button> m_apply_button;
  40. RefPtr<GUI::Button> m_reset_button;
  41. };
  42. }