From e158fa081c4cc623f008ba3cdd4830b66514a905 Mon Sep 17 00:00:00 2001 From: mbridak Date: Sun, 24 Nov 2024 11:52:06 -0800 Subject: [PATCH] @mbridak Add ESM and call History to ARRL 10m --- README.md | 2 +- not1mm/plugins/arrl_10m.py | 110 +++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ac55798..86a1c62 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,7 @@ generated, 'cause I'm lazy, list of those who've submitted PR's. - 10 10 Spring CW - 10 10 Summer Phone - 10 10 Winter Phone -- ARRL 10M +- **ARRL 10M** - **ARRL DX CW, SSB** - **ARRL Field Day** - **ARRL Sweepstakes CW, SSB** diff --git a/not1mm/plugins/arrl_10m.py b/not1mm/plugins/arrl_10m.py index 5d3a215..b70336c 100644 --- a/not1mm/plugins/arrl_10m.py +++ b/not1mm/plugins/arrl_10m.py @@ -441,3 +441,113 @@ def cabrillo(self, file_encoding): def recalculate_mults(self): """Recalculates multipliers after change in logged qso.""" + + +def process_esm(self, new_focused_widget=None, with_enter=False): + """ESM State Machine""" + + # self.pref["run_state"] + + # -----===== Assigned F-Keys =====----- + # self.esm_dict["CQ"] + # self.esm_dict["EXCH"] + # self.esm_dict["QRZ"] + # self.esm_dict["AGN"] + # self.esm_dict["HISCALL"] + # self.esm_dict["MYCALL"] + # self.esm_dict["QSOB4"] + + # ----==== text fields ====---- + # self.callsign + # self.sent + # self.receive + # self.other_1 + # self.other_2 + + if new_focused_widget is not None: + self.current_widget = self.inputs_dict.get(new_focused_widget) + + # print(f"checking esm {self.current_widget=} {with_enter=} {self.pref.get("run_state")=}") + + for a_button in [ + self.esm_dict["CQ"], + self.esm_dict["EXCH"], + self.esm_dict["QRZ"], + self.esm_dict["AGN"], + self.esm_dict["HISCALL"], + self.esm_dict["MYCALL"], + self.esm_dict["QSOB4"], + ]: + if a_button is not None: + self.restore_button_color(a_button) + + buttons_to_send = [] + + if self.pref.get("run_state"): + if self.current_widget == "callsign": + if len(self.callsign.text()) < 3: + self.make_button_green(self.esm_dict["CQ"]) + buttons_to_send.append(self.esm_dict["CQ"]) + elif len(self.callsign.text()) > 2: + self.make_button_green(self.esm_dict["HISCALL"]) + self.make_button_green(self.esm_dict["EXCH"]) + buttons_to_send.append(self.esm_dict["HISCALL"]) + buttons_to_send.append(self.esm_dict["EXCH"]) + + elif self.current_widget in ["other_2"]: + if self.other_2.text() == "": + self.make_button_green(self.esm_dict["AGN"]) + buttons_to_send.append(self.esm_dict["AGN"]) + else: + self.make_button_green(self.esm_dict["QRZ"]) + buttons_to_send.append(self.esm_dict["QRZ"]) + buttons_to_send.append("LOGIT") + + if with_enter is True and bool(len(buttons_to_send)): + for button in buttons_to_send: + if button: + if button == "LOGIT": + self.save_contact() + continue + self.process_function_key(button) + else: + if self.current_widget == "callsign": + if len(self.callsign.text()) > 2: + self.make_button_green(self.esm_dict["MYCALL"]) + buttons_to_send.append(self.esm_dict["MYCALL"]) + + elif self.current_widget in ["other_2"]: + if self.other_2.text() == "": + self.make_button_green(self.esm_dict["AGN"]) + buttons_to_send.append(self.esm_dict["AGN"]) + else: + self.make_button_green(self.esm_dict["EXCH"]) + buttons_to_send.append(self.esm_dict["EXCH"]) + buttons_to_send.append("LOGIT") + + if with_enter is True and bool(len(buttons_to_send)): + for button in buttons_to_send: + if button: + if button == "LOGIT": + self.save_contact() + continue + self.process_function_key(button) + + +def populate_history_info_line(self): + result = self.database.fetch_call_history(self.callsign.text()) + if result: + self.history_info.setText( + f"{result.get('Call', '')}, {result.get('Name', '')}, {result.get('State', '')}, {result.get('UserText','...')}" + ) + else: + self.history_info.setText("") + + +def check_call_history(self): + """""" + result = self.database.fetch_call_history(self.callsign.text()) + if result: + self.history_info.setText(f"{result.get('UserText','')}") + if self.other_2.text() == "": + self.other_2.setText(f"{result.get('State', '')}")