1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 12:15:09 +00:00
serenity/Userland/Libraries/LibGUI/SettingsWindow.h
kleines Filmröllchen 1e9554145e 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.
2021-11-27 12:45:44 +01:00

54 lines
1.3 KiB
C++

/*
* Copyright (c) 2020, Idan Horowitz <idan.horowitz@serenityos.org>
* Copyright (c) 2021, the SerenityOS developers.
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Button.h>
#include <LibGUI/TabWidget.h>
#include <LibGUI/Window.h>
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,
};
virtual ~SettingsWindow() override;
template<class T, class... Args>
T& add_tab(StringView const& title, Args&&... args)
{
auto& t = m_tab_widget->add_tab<T>(title, forward<Args>(args)...);
m_tabs.append(t);
return t;
}
private:
SettingsWindow(StringView title, ShowDefaultsButton = ShowDefaultsButton::No);
RefPtr<GUI::TabWidget> m_tab_widget;
NonnullRefPtrVector<Tab> m_tabs;
RefPtr<GUI::Button> m_ok_button;
RefPtr<GUI::Button> m_cancel_button;
RefPtr<GUI::Button> m_apply_button;
RefPtr<GUI::Button> m_reset_button;
};
}