This commit is contained in:
2026-08-01 18:05:10 +03:00
parent 8e24f19a07
commit 7d050f3eb2
10 changed files with 1145 additions and 120 deletions
+862 -111
View File
File diff suppressed because it is too large Load Diff
+11 -1
View File
@@ -11,7 +11,7 @@ use std::rc::Rc;
use convert::{ConvField, ConvPanel, Converter, Endian, RatioWidth};
use crc::CrcTool;
use engine::{Calculator, Op};
use engine::{Calculator, Op, StdPanel};
use programmer::{Base, ProgOp, Programmer};
use slint::{ComponentHandle, ModelRc, VecModel};
@@ -55,6 +55,7 @@ fn main() -> Result<(), slint::PlatformError> {
let ui = AppWindow::new()?;
// Must match the .desktop basename (rcalc.desktop → "rcalc"), before show/run.
slint::set_xdg_app_id("rcalc")?;
ui.set_app_title(format!("Rcalc-{}", env!("APP_VERSION")).into());
let state = Rc::new(RefCell::new(State::default()));
@@ -170,6 +171,10 @@ fn refresh(ui: &AppWindow, state: &mut State) {
ui.set_display_text(state.std.display().into());
ui.set_expression_text(state.std.expression().into());
ui.set_has_memory(state.std.has_memory());
ui.set_std_panel(match state.std.panel() {
StdPanel::Standard => 0,
StdPanel::Formula => 1,
});
}
Mode::Programmer => {
ui.set_display_text(state.prog.display().into());
@@ -266,6 +271,8 @@ fn handle_key(state: &mut State, id: &str) {
fn handle_standard(calc: &mut Calculator, id: &str) {
match id {
"panel:std" => calc.set_panel(StdPanel::Standard),
"panel:formula" => calc.set_panel(StdPanel::Formula),
"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" => {
calc.input_digit(id.chars().next().unwrap());
}
@@ -276,9 +283,12 @@ fn handle_standard(calc: &mut Calculator, id: &str) {
"/" | "÷" => calc.set_op(Op::Div),
"=" => calc.equals(),
"%" => calc.percent(),
"(" => calc.paren_open(),
")" => calc.paren_close(),
"CE" => calc.clear_entry(),
"C" => calc.clear_all(),
"BS" => calc.backspace(),
"1/x" | "x2" | "sqrt" if calc.panel() == StdPanel::Formula => {}
"1/x" => calc.reciprocal(),
"x2" => calc.square(),
"sqrt" => calc.sqrt(),