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-05-13 13:10:27 +01:00
|
|
|
static ExecResult show(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder = {}, InputType input_type = InputType::Text);
|
2019-03-19 01:41:00 +01:00
|
|
|
|
|
|
|
|
private:
|
2021-11-11 00:55:02 +01:00
|
|
|
explicit InputBox(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type);
|
2020-07-16 07:54:42 -06:00
|
|
|
|
|
|
|
|
String text_value() const { return m_text_value; }
|
|
|
|
|
|
2021-07-24 22:59:39 -06:00
|
|
|
void build(InputType input_type);
|
2019-03-19 01:41:00 +01:00
|
|
|
String m_text_value;
|
2021-02-20 12:04:15 +01:00
|
|
|
String m_prompt;
|
2021-07-06 16:47:44 +02:00
|
|
|
String 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
|
|
|
|
|
|
|
|
}
|