mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibGUI: Store Statusbar text as String
This commit is contained in:
parent
e1e382152c
commit
2064f544c6
2 changed files with 20 additions and 17 deletions
|
@ -79,24 +79,24 @@ void Statusbar::update_segment(size_t index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (segment->override_text().is_null()) {
|
if (segment->override_text().has_value()) {
|
||||||
for (size_t i = 1; i < m_segments.size(); i++) {
|
|
||||||
if (!text(i).is_empty())
|
|
||||||
m_segments[i]->set_visible(true);
|
|
||||||
}
|
|
||||||
segment->set_text(String::from_deprecated_string(segment->restored_text()).release_value_but_fixme_should_propagate_errors());
|
|
||||||
segment->set_frame_style(Gfx::FrameStyle::SunkenPanel);
|
|
||||||
if (segment->mode() != Segment::Mode::Proportional)
|
|
||||||
segment->set_fixed_width(segment->restored_width());
|
|
||||||
} else {
|
|
||||||
for (size_t i = 1; i < m_segments.size(); i++) {
|
for (size_t i = 1; i < m_segments.size(); i++) {
|
||||||
if (!m_segments[i]->is_clickable())
|
if (!m_segments[i]->is_clickable())
|
||||||
m_segments[i]->set_visible(false);
|
m_segments[i]->set_visible(false);
|
||||||
}
|
}
|
||||||
segment->set_text(String::from_deprecated_string(segment->override_text()).release_value_but_fixme_should_propagate_errors());
|
segment->set_text(*segment->override_text());
|
||||||
segment->set_frame_style(Gfx::FrameStyle::NoFrame);
|
segment->set_frame_style(Gfx::FrameStyle::NoFrame);
|
||||||
if (segment->mode() != Segment::Mode::Proportional)
|
if (segment->mode() != Segment::Mode::Proportional)
|
||||||
segment->set_fixed_width(SpecialDimension::Grow);
|
segment->set_fixed_width(SpecialDimension::Grow);
|
||||||
|
} else {
|
||||||
|
for (size_t i = 1; i < m_segments.size(); i++) {
|
||||||
|
if (!text(i).is_empty())
|
||||||
|
m_segments[i]->set_visible(true);
|
||||||
|
}
|
||||||
|
segment->set_text(segment->restored_text());
|
||||||
|
segment->set_frame_style(Gfx::FrameStyle::SunkenPanel);
|
||||||
|
if (segment->mode() != Segment::Mode::Proportional)
|
||||||
|
segment->set_fixed_width(segment->restored_width());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,13 +112,16 @@ void Statusbar::set_text(DeprecatedString text)
|
||||||
|
|
||||||
void Statusbar::set_text(size_t index, DeprecatedString text)
|
void Statusbar::set_text(size_t index, DeprecatedString text)
|
||||||
{
|
{
|
||||||
m_segments[index]->m_restored_text = move(text);
|
m_segments[index]->m_restored_text = String::from_deprecated_string(text).release_value_but_fixme_should_propagate_errors();
|
||||||
update_segment(index);
|
update_segment(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Statusbar::set_override_text(DeprecatedString override_text)
|
void Statusbar::set_override_text(DeprecatedString override_text)
|
||||||
{
|
{
|
||||||
m_segments[0]->m_override_text = move(override_text);
|
if (override_text.is_null())
|
||||||
|
m_segments[0]->m_override_text = {};
|
||||||
|
else
|
||||||
|
m_segments[0]->m_override_text = String::from_deprecated_string(override_text).release_value_but_fixme_should_propagate_errors();
|
||||||
update_segment(0);
|
update_segment(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,11 +51,11 @@ public:
|
||||||
void set_frame_style(Gfx::FrameStyle style) { m_style = style; }
|
void set_frame_style(Gfx::FrameStyle style) { m_style = style; }
|
||||||
void set_restored_width(int width) { m_restored_width = width; }
|
void set_restored_width(int width) { m_restored_width = width; }
|
||||||
int restored_width() const { return m_restored_width; }
|
int restored_width() const { return m_restored_width; }
|
||||||
DeprecatedString const& override_text() const { return m_override_text; }
|
Optional<String> const& override_text() const { return m_override_text; }
|
||||||
DeprecatedString const& restored_text() const { return m_restored_text; }
|
String const& restored_text() const { return m_restored_text; }
|
||||||
|
|
||||||
DeprecatedString m_override_text;
|
Optional<String> m_override_text;
|
||||||
DeprecatedString m_restored_text;
|
String m_restored_text;
|
||||||
bool m_clickable { false };
|
bool m_clickable { false };
|
||||||
int m_restored_width { 0 };
|
int m_restored_width { 0 };
|
||||||
Mode m_mode { Mode::Proportional };
|
Mode m_mode { Mode::Proportional };
|
||||||
|
|
Loading…
Add table
Reference in a new issue