diff options
author | faxe1008 <fabianblatz@gmail.com> | 2022-05-07 17:14:09 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-05-08 16:36:53 +0200 |
commit | 86d5e5a90cfa691f76cc5b76c0f2b07ca5cf8c3d (patch) | |
tree | 4a06964f2cdc98137fe0717c6e0dcf65a4b85bf6 /Userland/Libraries/LibGUI/TextBox.h | |
parent | 448d6b9acc9f2596cf8c6f38c3a9dee801820e8e (diff) | |
download | serenity-86d5e5a90cfa691f76cc5b76c0f2b07ca5cf8c3d.zip |
LibGUI: Add button to PasswordBox to reveal the password
This patch adds an eye-like button to the PasswordBox
which allows the user to reveal the typed password.
Whether or not the button is shown is controllable via
an additional property within the PasswordBox.
Diffstat (limited to 'Userland/Libraries/LibGUI/TextBox.h')
-rw-r--r-- | Userland/Libraries/LibGUI/TextBox.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/TextBox.h b/Userland/Libraries/LibGUI/TextBox.h index fc73af4d74..3ac2fb8a26 100644 --- a/Userland/Libraries/LibGUI/TextBox.h +++ b/Userland/Libraries/LibGUI/TextBox.h @@ -42,8 +42,23 @@ private: class PasswordBox : public TextBox { C_OBJECT(PasswordBox) +public: + bool is_showing_reveal_button() const { return m_show_reveal_button; } + void set_show_reveal_button(bool show) + { + m_show_reveal_button = show; + update(); + } + private: PasswordBox(); + + virtual void paint_event(PaintEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; + + Gfx::IntRect reveal_password_button_rect() const; + + bool m_show_reveal_button { false }; }; class UrlBox : public TextBox { |