not1mm 24.10.6__py3-none-any.whl → 24.10.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
not1mm/__main__.py CHANGED
@@ -37,7 +37,7 @@ except OSError as exception:
37
37
  from PyQt6 import QtCore, QtGui, QtWidgets, uic
38
38
  from PyQt6.QtCore import QDir, Qt, QThread, QSettings, QCoreApplication
39
39
  from PyQt6.QtGui import QFontDatabase, QColorConstants, QPalette, QColor, QPixmap
40
- from PyQt6.QtWidgets import QFileDialog, QSplashScreen
40
+ from PyQt6.QtWidgets import QFileDialog, QSplashScreen, QApplication
41
41
 
42
42
  from not1mm.lib.about import About
43
43
  from not1mm.lib.cwinterface import CW
@@ -162,6 +162,8 @@ class MainWindow(QtWidgets.QMainWindow):
162
162
  oldtext = ""
163
163
  text_color = QColorConstants.Black
164
164
  current_palette = None
165
+ use_esm = False
166
+ esm_dict = {}
165
167
 
166
168
  radio_thread = QThread()
167
169
  voice_thread = QThread()
@@ -176,6 +178,8 @@ class MainWindow(QtWidgets.QMainWindow):
176
178
  lookup_service = None
177
179
  fldigi_util = None
178
180
 
181
+ current_widget = None
182
+
179
183
  def __init__(self, splash):
180
184
  super().__init__()
181
185
  logger.info("MainWindow: __init__")
@@ -194,6 +198,7 @@ class MainWindow(QtWidgets.QMainWindow):
194
198
  self.setCorner(Qt.Corner.TopLeftCorner, Qt.DockWidgetArea.LeftDockWidgetArea)
195
199
  self.setCorner(Qt.Corner.BottomLeftCorner, Qt.DockWidgetArea.LeftDockWidgetArea)
196
200
  uic.loadUi(fsutils.APP_DATA_PATH / "main.ui", self)
201
+ QApplication.instance().focusObjectChanged.connect(self.on_focus_changed)
197
202
  self.cw_entry.hide()
198
203
  self.leftdot.hide()
199
204
  self.rightdot.hide()
@@ -246,13 +251,18 @@ class MainWindow(QtWidgets.QMainWindow):
246
251
  self.radioButton_sp.clicked.connect(self.run_sp_buttons_clicked)
247
252
  self.score.setText("0")
248
253
  self.callsign.textEdited.connect(self.callsign_changed)
249
- self.callsign.returnPressed.connect(self.save_contact)
250
- self.sent.returnPressed.connect(self.save_contact)
251
- self.receive.returnPressed.connect(self.save_contact)
252
- self.other_1.returnPressed.connect(self.save_contact)
254
+ self.callsign.returnPressed.connect(self.check_esm_with_enter)
255
+ self.callsign.cursorPositionChanged.connect(self.check_esm)
256
+ self.sent.returnPressed.connect(self.check_esm_with_enter)
257
+ self.sent.cursorPositionChanged.connect(self.check_esm)
258
+ self.receive.returnPressed.connect(self.check_esm_with_enter)
259
+ self.receive.cursorPositionChanged.connect(self.check_esm)
260
+ self.other_1.returnPressed.connect(self.check_esm_with_enter)
253
261
  self.other_1.textEdited.connect(self.other_1_changed)
254
- self.other_2.returnPressed.connect(self.save_contact)
262
+ self.other_1.cursorPositionChanged.connect(self.check_esm)
263
+ self.other_2.returnPressed.connect(self.check_esm_with_enter)
255
264
  self.other_2.textEdited.connect(self.other_2_changed)
265
+ self.other_2.cursorPositionChanged.connect(self.check_esm)
256
266
 
257
267
  self.sent.setText("59")
258
268
  self.receive.setText("59")
@@ -651,6 +661,47 @@ class MainWindow(QtWidgets.QMainWindow):
651
661
  "You can udate to the current version by using:\npip install -U not1mm"
652
662
  )
653
663
 
664
+ def on_focus_changed(self, new):
665
+ """"""
666
+ if self.use_esm:
667
+ if hasattr(self.contest, "process_esm"):
668
+ self.contest.process_esm(self, new_focused_widget=new)
669
+
670
+ def make_button_green(self, the_button: QtWidgets.QPushButton) -> None:
671
+ """Turn the_button green."""
672
+ if the_button is not None:
673
+ pal = QPalette()
674
+ pal.isCopyOf(self.current_palette)
675
+ greenColor = QColor(0, 128, 0)
676
+ pal.setBrush(QPalette.ColorRole.Button, greenColor)
677
+ the_button.setPalette(pal)
678
+
679
+ def restore_button_color(self, the_button: QtWidgets.QPushButton) -> None:
680
+ """Restores the color of the button"""
681
+ the_button.setPalette(self.current_palette)
682
+
683
+ def check_esm_with_enter(self):
684
+ """Check for ESM, otherwise save contact."""
685
+ if self.use_esm:
686
+ if hasattr(self.contest, "process_esm"):
687
+ self.contest.process_esm(self, with_enter=True)
688
+ else:
689
+ self.save_contact()
690
+ else:
691
+ self.save_contact()
692
+
693
+ def check_esm(self):
694
+ """Check for ESM, otherwise save contact."""
695
+ if self.use_esm:
696
+ if hasattr(self.contest, "process_esm"):
697
+ self.contest.process_esm(self)
698
+ else:
699
+ ...
700
+ # self.save_contact()
701
+ else:
702
+ ...
703
+ # self.save_contact()
704
+
654
705
  def show_splash_msg(self, msg: str) -> None:
655
706
  """Show text message in the splash window."""
656
707
  self.splash.showMessage(
@@ -1719,7 +1770,6 @@ class MainWindow(QtWidgets.QMainWindow):
1719
1770
  -------
1720
1771
  None
1721
1772
  """
1722
-
1723
1773
  modifier = event.modifiers()
1724
1774
  if event.key() == Qt.Key.Key_K:
1725
1775
  self.toggle_cw_entry()
@@ -2027,7 +2077,7 @@ class MainWindow(QtWidgets.QMainWindow):
2027
2077
 
2028
2078
  logger.debug("saving contact")
2029
2079
  if self.contest is None:
2030
- self.show_message_box("You have no contest defined.")
2080
+ self.show_message_box("You have no contest defined...")
2031
2081
  return
2032
2082
  if len(self.callsign.text()) < 3:
2033
2083
  return
@@ -2609,13 +2659,16 @@ class MainWindow(QtWidgets.QMainWindow):
2609
2659
  self.rig_control.poll_callback.connect(self.poll_radio)
2610
2660
  self.radio_thread.start()
2611
2661
 
2612
- if self.pref.get("cwtype", 0) == 0:
2613
- self.cw = None
2614
- else:
2662
+ self.cw = None
2663
+ if (
2664
+ self.pref.get("cwport")
2665
+ and self.pref.get("cwip")
2666
+ and self.pref.get("cwtype")
2667
+ ):
2615
2668
  self.cw = CW(
2616
2669
  int(self.pref.get("cwtype")),
2617
2670
  self.pref.get("cwip"),
2618
- int(self.pref.get("cwport", 6789)),
2671
+ int(self.pref.get("cwport")),
2619
2672
  )
2620
2673
  self.cw.speed = 20
2621
2674
  if self.cw.servertype == 2:
@@ -2646,13 +2699,9 @@ class MainWindow(QtWidgets.QMainWindow):
2646
2699
  self.pref["bands"] = [
2647
2700
  "160",
2648
2701
  "80",
2649
- "60",
2650
2702
  "40",
2651
- "30",
2652
2703
  "20",
2653
- "17",
2654
2704
  "15",
2655
- "12",
2656
2705
  "10",
2657
2706
  ]
2658
2707
 
@@ -2667,7 +2716,33 @@ class MainWindow(QtWidgets.QMainWindow):
2667
2716
  for band_to_show in self.pref.get("bands", []):
2668
2717
  if band_to_show in _indicator:
2669
2718
  _indicator[band_to_show].show()
2670
- # self.show_band_mode()
2719
+
2720
+ fkey_dict = {
2721
+ "F1": self.F1,
2722
+ "F2": self.F2,
2723
+ "F3": self.F3,
2724
+ "F4": self.F4,
2725
+ "F5": self.F5,
2726
+ "F6": self.F6,
2727
+ "F7": self.F7,
2728
+ "F8": self.F8,
2729
+ "F9": self.F9,
2730
+ "F10": self.F10,
2731
+ "F11": self.F11,
2732
+ "F12": self.F12,
2733
+ "DISABLED": None,
2734
+ }
2735
+
2736
+ self.use_esm = self.pref.get("use_esm", False)
2737
+ self.esm_dict["CQ"] = fkey_dict.get(self.pref.get("esm_cq", "DISABLED"))
2738
+ self.esm_dict["EXCH"] = fkey_dict.get(self.pref.get("esm_exch", "DISABLED"))
2739
+ self.esm_dict["QRZ"] = fkey_dict.get(self.pref.get("esm_qrz", "DISABLED"))
2740
+ self.esm_dict["AGN"] = fkey_dict.get(self.pref.get("esm_agn", "DISABLED"))
2741
+ self.esm_dict["HISCALL"] = fkey_dict.get(
2742
+ self.pref.get("esm_hiscall", "DISABLED")
2743
+ )
2744
+ self.esm_dict["MYCALL"] = fkey_dict.get(self.pref.get("esm_mycall", "DISABLED"))
2745
+ self.esm_dict["QSOB4"] = fkey_dict.get(self.pref.get("esm_qsob4", "DISABLED"))
2671
2746
 
2672
2747
  def watch_udp(self) -> None:
2673
2748
  """
@@ -2711,7 +2786,8 @@ class MainWindow(QtWidgets.QMainWindow):
2711
2786
  self.callsign_changed()
2712
2787
  self.callsign.setFocus()
2713
2788
  self.callsign.activateWindow()
2714
- window.raise_()
2789
+ # This broke somehow.
2790
+ # window.raise_()
2715
2791
  continue
2716
2792
 
2717
2793
  if (