2021-02-21 22:40:08 +11:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Nick Vella <nick@nxk.io>
|
2022-02-26 10:50:04 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2021-02-21 22:40:08 +11:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-21 22:40:08 +11:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibGUI/Dialog.h>
|
|
|
|
|
#include <LibGUI/Wizards/AbstractWizardPage.h>
|
|
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
|
|
class WizardDialog : public Dialog {
|
2023-06-08 07:46:11 -04:00
|
|
|
C_OBJECT_ABSTRACT(WizardDialog)
|
2021-02-21 22:40:08 +11:00
|
|
|
public:
|
2022-02-26 10:50:04 -07:00
|
|
|
virtual ~WizardDialog() override = default;
|
2021-02-21 22:40:08 +11:00
|
|
|
|
2023-06-08 07:46:11 -04:00
|
|
|
static ErrorOr<NonnullRefPtr<WizardDialog>> create(Window* parent_window);
|
2021-02-21 22:40:08 +11:00
|
|
|
|
|
|
|
|
Function<void()> on_cancel;
|
|
|
|
|
|
|
|
|
|
/// Push a page onto the page stack and display it, preserving the previous page on the stack.
|
|
|
|
|
void push_page(AbstractWizardPage& page);
|
|
|
|
|
/// Replace the current page on the stack with a new page, preventing the user from returning to the current page.
|
|
|
|
|
void replace_page(AbstractWizardPage& page);
|
|
|
|
|
void pop_page();
|
|
|
|
|
AbstractWizardPage& current_page();
|
|
|
|
|
|
|
|
|
|
inline bool has_pages() const { return !m_page_stack.is_empty(); }
|
|
|
|
|
|
|
|
|
|
protected:
|
2023-06-08 07:46:11 -04:00
|
|
|
explicit WizardDialog(Window* parent_window);
|
2021-02-21 22:40:08 +11:00
|
|
|
|
2023-06-08 07:46:11 -04:00
|
|
|
virtual ErrorOr<void> build();
|
2021-02-21 22:40:08 +11:00
|
|
|
virtual void handle_cancel();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void update_navigation();
|
|
|
|
|
|
|
|
|
|
RefPtr<Widget> m_page_container_widget;
|
|
|
|
|
RefPtr<Button> m_back_button;
|
|
|
|
|
RefPtr<Button> m_next_button;
|
|
|
|
|
RefPtr<Button> m_cancel_button;
|
|
|
|
|
|
2023-03-06 14:17:01 +01:00
|
|
|
Vector<NonnullRefPtr<AbstractWizardPage>> m_page_stack;
|
2021-02-21 22:40:08 +11:00
|
|
|
};
|
|
|
|
|
}
|