mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 06:04:57 +00:00
LibGUI: Add a MessageBox type to reveal a file
This will be used by Ladybird to open a screenshot's containing folder.
This commit is contained in:
parent
cc88a2657d
commit
9218b2f3ce
3 changed files with 12 additions and 1 deletions
|
@ -21,6 +21,7 @@ public:
|
|||
Aborted = 2,
|
||||
Yes = 3,
|
||||
No = 4,
|
||||
Reveal = 5,
|
||||
};
|
||||
|
||||
enum class ScreenPosition {
|
||||
|
|
|
@ -130,7 +130,7 @@ ErrorOr<RefPtr<Gfx::Bitmap>> MessageBox::icon() const
|
|||
|
||||
bool MessageBox::should_include_ok_button() const
|
||||
{
|
||||
return m_input_type == InputType::OK || m_input_type == InputType::OKCancel;
|
||||
return m_input_type == InputType::OK || m_input_type == InputType::OKCancel || m_input_type == InputType::OKReveal;
|
||||
}
|
||||
|
||||
bool MessageBox::should_include_cancel_button() const
|
||||
|
@ -148,6 +148,11 @@ bool MessageBox::should_include_no_button() const
|
|||
return should_include_yes_button();
|
||||
}
|
||||
|
||||
bool MessageBox::should_include_reveal_button() const
|
||||
{
|
||||
return m_input_type == InputType::OKReveal;
|
||||
}
|
||||
|
||||
ErrorOr<void> MessageBox::build()
|
||||
{
|
||||
auto main_widget = set_main_widget<Widget>();
|
||||
|
@ -188,6 +193,8 @@ ErrorOr<void> MessageBox::build()
|
|||
m_no_button = add_button("No"_string, ExecResult::No);
|
||||
if (should_include_cancel_button())
|
||||
m_cancel_button = add_button("Cancel"_string, ExecResult::Cancel);
|
||||
if (should_include_reveal_button())
|
||||
m_reveal_button = add_button("Open folder"_string, ExecResult::Reveal);
|
||||
button_container.add_spacer();
|
||||
|
||||
return {};
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
enum class InputType {
|
||||
OK,
|
||||
OKCancel,
|
||||
OKReveal,
|
||||
YesNo,
|
||||
YesNoCancel,
|
||||
};
|
||||
|
@ -58,6 +59,7 @@ private:
|
|||
bool should_include_cancel_button() const;
|
||||
bool should_include_yes_button() const;
|
||||
bool should_include_no_button() const;
|
||||
bool should_include_reveal_button() const;
|
||||
|
||||
ErrorOr<void> build();
|
||||
ErrorOr<RefPtr<Gfx::Bitmap>> icon() const;
|
||||
|
@ -69,6 +71,7 @@ private:
|
|||
RefPtr<GUI::Button> m_yes_button;
|
||||
RefPtr<GUI::Button> m_no_button;
|
||||
RefPtr<GUI::Button> m_cancel_button;
|
||||
RefPtr<GUI::Button> m_reveal_button;
|
||||
RefPtr<Label> m_text_label;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue