Calculator: Convert DeprecatedString to String

This commit is contained in:
sSt3lla 2023-10-29 20:06:32 +13:00 committed by Sam Atkins
parent 9677d8eeac
commit 6b72fc0924
4 changed files with 10 additions and 10 deletions

View file

@ -28,7 +28,7 @@ CalculatorWidget::CalculatorWidget()
m_label->set_frame_style(Gfx::FrameStyle::SunkenContainer);
for (int i = 0; i < 10; i++) {
m_digit_button[i] = *find_descendant_of_type_named<GUI::Button>(DeprecatedString::formatted("{}_button", i));
m_digit_button[i] = *find_descendant_of_type_named<GUI::Button>(String::formatted("{}_button", i).release_value_but_fixme_should_propagate_errors());
add_digit_button(*m_digit_button[i], i);
}
@ -128,9 +128,9 @@ void CalculatorWidget::add_digit_button(GUI::Button& button, int digit)
};
}
DeprecatedString CalculatorWidget::get_entry()
String CalculatorWidget::get_entry()
{
return m_entry->text();
return String::from_deprecated_string(m_entry->text()).release_value_but_fixme_should_propagate_errors();
}
void CalculatorWidget::set_entry(Crypto::BigFraction value)
@ -147,7 +147,7 @@ void CalculatorWidget::set_typed_entry(Crypto::BigFraction value)
void CalculatorWidget::update_display()
{
m_entry->set_text(m_keypad.to_deprecated_string());
m_entry->set_text(m_keypad.to_string().release_value_but_fixme_should_propagate_errors());
if (m_calculator.has_error())
m_label->set_text("E"_string);
else

View file

@ -19,7 +19,7 @@ class CalculatorWidget final : public GUI::Widget {
C_OBJECT(CalculatorWidget)
public:
virtual ~CalculatorWidget() override = default;
DeprecatedString get_entry();
String get_entry();
void set_entry(Crypto::BigFraction);
void set_typed_entry(Crypto::BigFraction);

View file

@ -121,10 +121,10 @@ void Keypad::set_to_0()
m_state = State::External;
}
DeprecatedString Keypad::to_deprecated_string() const
ErrorOr<String> Keypad::to_string() const
{
if (m_state == State::External || m_state == State::TypedExternal)
return m_internal_value.to_deprecated_string(m_displayed_fraction_length);
return String::from_deprecated_string(m_internal_value.to_deprecated_string(m_displayed_fraction_length));
StringBuilder builder;
@ -142,7 +142,7 @@ DeprecatedString Keypad::to_deprecated_string() const
builder.append(frac_value);
}
return builder.to_deprecated_string();
return builder.to_string();
}
bool Keypad::in_typing_state() const

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/String.h>
#include <LibCrypto/BigFraction/BigFraction.h>
#include <LibCrypto/BigInt/UnsignedBigInteger.h>
@ -34,7 +34,7 @@ public:
void set_rounding_length(unsigned);
unsigned rounding_length() const;
DeprecatedString to_deprecated_string() const;
ErrorOr<String> to_string() const;
bool in_typing_state() const;