mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
fe3b846ac8
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
57 lines
1.4 KiB
C++
57 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2020, Idan Horowitz <idan.horowitz@serenityos.org>
|
|
* Copyright (c) 2021-2022, 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,
|
|
};
|
|
|
|
static ErrorOr<NonnullRefPtr<SettingsWindow>> create(String title, ShowDefaultsButton = ShowDefaultsButton::No);
|
|
|
|
virtual ~SettingsWindow() override = default;
|
|
|
|
template<class T, class... Args>
|
|
ErrorOr<NonnullRefPtr<T>> add_tab(String title, Args&&... args)
|
|
{
|
|
auto tab = TRY(m_tab_widget->try_add_tab<T>(move(title), forward<Args>(args)...));
|
|
TRY(m_tabs.try_append(tab));
|
|
return tab;
|
|
}
|
|
|
|
private:
|
|
SettingsWindow() = default;
|
|
|
|
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;
|
|
};
|
|
|
|
}
|