mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +00:00
Calculator: Convert DeprecatedString to String
This commit is contained in:
parent
9677d8eeac
commit
6b72fc0924
|
@ -28,7 +28,7 @@ CalculatorWidget::CalculatorWidget()
|
||||||
m_label->set_frame_style(Gfx::FrameStyle::SunkenContainer);
|
m_label->set_frame_style(Gfx::FrameStyle::SunkenContainer);
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
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);
|
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)
|
void CalculatorWidget::set_entry(Crypto::BigFraction value)
|
||||||
|
@ -147,7 +147,7 @@ void CalculatorWidget::set_typed_entry(Crypto::BigFraction value)
|
||||||
|
|
||||||
void CalculatorWidget::update_display()
|
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())
|
if (m_calculator.has_error())
|
||||||
m_label->set_text("E"_string);
|
m_label->set_text("E"_string);
|
||||||
else
|
else
|
||||||
|
|
|
@ -19,7 +19,7 @@ class CalculatorWidget final : public GUI::Widget {
|
||||||
C_OBJECT(CalculatorWidget)
|
C_OBJECT(CalculatorWidget)
|
||||||
public:
|
public:
|
||||||
virtual ~CalculatorWidget() override = default;
|
virtual ~CalculatorWidget() override = default;
|
||||||
DeprecatedString get_entry();
|
String get_entry();
|
||||||
void set_entry(Crypto::BigFraction);
|
void set_entry(Crypto::BigFraction);
|
||||||
void set_typed_entry(Crypto::BigFraction);
|
void set_typed_entry(Crypto::BigFraction);
|
||||||
|
|
||||||
|
|
|
@ -121,10 +121,10 @@ void Keypad::set_to_0()
|
||||||
m_state = State::External;
|
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)
|
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;
|
StringBuilder builder;
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ DeprecatedString Keypad::to_deprecated_string() const
|
||||||
builder.append(frac_value);
|
builder.append(frac_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.to_deprecated_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Keypad::in_typing_state() const
|
bool Keypad::in_typing_state() const
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/DeprecatedString.h>
|
#include <AK/String.h>
|
||||||
#include <LibCrypto/BigFraction/BigFraction.h>
|
#include <LibCrypto/BigFraction/BigFraction.h>
|
||||||
#include <LibCrypto/BigInt/UnsignedBigInteger.h>
|
#include <LibCrypto/BigInt/UnsignedBigInteger.h>
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public:
|
||||||
void set_rounding_length(unsigned);
|
void set_rounding_length(unsigned);
|
||||||
unsigned rounding_length() const;
|
unsigned rounding_length() const;
|
||||||
|
|
||||||
DeprecatedString to_deprecated_string() const;
|
ErrorOr<String> to_string() const;
|
||||||
|
|
||||||
bool in_typing_state() const;
|
bool in_typing_state() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue