1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 03:27:44 +00:00

Calculator: Add a "Custom" entry to the rounding menu

This entry pop a dialog to ask the user to enter a value. The Calculator
will automatically put itself in this mode if you enter a number with
more digits in the fractional part than the actual maximum length.
This commit is contained in:
Lucas CHOLLET 2022-09-22 16:55:04 +02:00 committed by Tim Flynn
parent de568f87fd
commit e3b22c395d
8 changed files with 157 additions and 10 deletions

View file

@ -12,6 +12,7 @@
#include "Keypad.h"
#include <AK/Vector.h>
#include <LibCrypto/BigFraction/BigFraction.h>
#include <LibGUI/Action.h>
#include <LibGUI/Widget.h>
class CalculatorWidget final : public GUI::Widget {
@ -21,8 +22,11 @@ public:
String get_entry();
void set_entry(Crypto::BigFraction);
unsigned rounding_length() const;
void set_rounding_length(unsigned);
void set_rounding_custom(GUI::Action& action, StringView);
private:
CalculatorWidget();
void add_operation_button(GUI::Button&, Calculator::Operation);
@ -58,4 +62,7 @@ private:
RefPtr<GUI::Button> m_inverse_button;
RefPtr<GUI::Button> m_percent_button;
RefPtr<GUI::Button> m_equals_button;
StringView m_format;
RefPtr<GUI::Action> m_rounding_custom;
};