2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2022-09-12 16:06:24 +02:00
|
|
|
* Copyright (c) 2021, networkException <networkexception@serenityos.org>
|
2022-02-26 10:50:04 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2019-03-19 01:41:00 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/Dialog.h>
|
2019-03-19 01:41:00 +01:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
namespace GUI {
|
2019-03-19 02:20:00 +01:00
|
|
|
|
2021-07-24 22:59:39 -06:00
|
|
|
enum class InputType {
|
|
|
|
|
Text,
|
|
|
|
|
Password
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class InputBox : public Dialog {
|
|
|
|
|
C_OBJECT(InputBox)
|
2019-03-19 01:41:00 +01:00
|
|
|
public:
|
2022-02-26 10:50:04 -07:00
|
|
|
virtual ~InputBox() override = default;
|
2019-03-19 01:41:00 +01:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
static ExecResult show(Window* parent_window, DeprecatedString& text_value, StringView prompt, StringView title, StringView placeholder = {}, InputType input_type = InputType::Text);
|
2019-03-19 01:41:00 +01:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString const& text_value() const { return m_text_value; }
|
|
|
|
|
void set_text_value(DeprecatedString text_value);
|
2020-07-16 07:54:42 -06:00
|
|
|
|
2022-11-16 07:35:02 -05:00
|
|
|
private:
|
2022-12-04 18:02:33 +00:00
|
|
|
explicit InputBox(Window* parent_window, DeprecatedString text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type);
|
2020-07-16 07:54:42 -06:00
|
|
|
|
2022-11-16 07:35:02 -05:00
|
|
|
virtual void on_done(ExecResult) override;
|
2021-07-24 22:59:39 -06:00
|
|
|
void build(InputType input_type);
|
2022-11-16 07:35:02 -05:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString m_text_value;
|
|
|
|
|
DeprecatedString m_prompt;
|
|
|
|
|
DeprecatedString m_placeholder;
|
2019-03-19 02:20:00 +01:00
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
RefPtr<Button> m_ok_button;
|
|
|
|
|
RefPtr<Button> m_cancel_button;
|
|
|
|
|
RefPtr<TextEditor> m_text_editor;
|
2019-03-19 01:41:00 +01:00
|
|
|
};
|
2020-02-02 15:07:41 +01:00
|
|
|
|
|
|
|
|
}
|