not1mm 24.10.27.1__py3-none-any.whl → 24.11.2__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,6 +37,7 @@ from PyQt6 import QtCore, QtGui, QtWidgets, uic
37
37
  from PyQt6.QtCore import QDir, Qt, QThread, QSettings, QCoreApplication
38
38
  from PyQt6.QtGui import QFontDatabase, QColorConstants, QPalette, QColor, QPixmap
39
39
  from PyQt6.QtWidgets import QFileDialog, QSplashScreen, QApplication
40
+ from PyQt6.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
40
41
 
41
42
  from not1mm.lib.about import About
42
43
  from not1mm.lib.cwinterface import CW
@@ -163,6 +164,7 @@ class MainWindow(QtWidgets.QMainWindow):
163
164
  text_color = QColorConstants.Black
164
165
  current_palette = None
165
166
  use_esm = False
167
+ use_call_history = False
166
168
  esm_dict = {}
167
169
 
168
170
  radio_thread = QThread()
@@ -198,6 +200,7 @@ class MainWindow(QtWidgets.QMainWindow):
198
200
  self.setCorner(Qt.Corner.TopLeftCorner, Qt.DockWidgetArea.LeftDockWidgetArea)
199
201
  self.setCorner(Qt.Corner.BottomLeftCorner, Qt.DockWidgetArea.LeftDockWidgetArea)
200
202
  uic.loadUi(fsutils.APP_DATA_PATH / "main.ui", self)
203
+ self.history_info.hide()
201
204
  QApplication.instance().focusObjectChanged.connect(self.on_focus_changed)
202
205
  self.inputs_dict = {
203
206
  self.callsign: "callsign",
@@ -223,12 +226,15 @@ class MainWindow(QtWidgets.QMainWindow):
223
226
 
224
227
  self.actionCW_Macros.triggered.connect(self.cw_macros_state_changed)
225
228
  self.actionDark_Mode_2.triggered.connect(self.dark_mode_state_changed)
226
- self.actionCommand_Buttons.triggered.connect(self.command_buttons_state_change)
229
+ self.actionCommand_Buttons_2.triggered.connect(
230
+ self.command_buttons_state_change
231
+ )
227
232
  self.actionLog_Window.triggered.connect(self.launch_log_window)
228
233
  self.actionBandmap.triggered.connect(self.launch_bandmap_window)
229
234
  self.actionCheck_Window.triggered.connect(self.launch_check_window)
230
235
  self.actionVFO.triggered.connect(self.launch_vfo)
231
236
  self.actionRecalculate_Mults.triggered.connect(self.recalculate_mults)
237
+ self.actionLoad_Call_History_File.triggered.connect(self.load_call_history)
232
238
 
233
239
  self.actionGenerate_Cabrillo_ASCII.triggered.connect(
234
240
  lambda x: self.generate_cabrillo("ascii")
@@ -289,6 +295,12 @@ class MainWindow(QtWidgets.QMainWindow):
289
295
  self.radio_green = QtGui.QPixmap(str(icon_path / "radio_green.png"))
290
296
  self.radio_icon.setPixmap(self.radio_grey)
291
297
 
298
+ self.log_it.clicked.connect(self.save_contact)
299
+ self.wipe.clicked.connect(self.clearinputs)
300
+ self.esc_stop.clicked.connect(self.stop_cw)
301
+ self.mark.clicked.connect(self.mark_spot)
302
+ self.spot_it.clicked.connect(self.spot_dx)
303
+
292
304
  self.F1.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.CustomContextMenu)
293
305
  self.F1.customContextMenuRequested.connect(lambda x: self.edit_macro(self.F1))
294
306
  self.F1.clicked.connect(lambda x: self.process_function_key(self.F1))
@@ -589,7 +601,21 @@ class MainWindow(QtWidgets.QMainWindow):
589
601
  self.voice_process.current_op = self.current_op
590
602
  self.make_op_dir()
591
603
 
592
- # Featureset for wayland
604
+ logger.debug(f"{QT_VERSION_STR=} {PYQT_VERSION_STR=}")
605
+ x = PYQT_VERSION_STR.split(".")
606
+ old_Qt = True
607
+ # test if pyqt version is at least 6.7.1
608
+ if len(x) == 1:
609
+ if int(x[0]) > 6:
610
+ old_Qt = False
611
+ elif len(x) == 2:
612
+ if int(x[0]) >= 6 and int(x[1]) > 8:
613
+ old_Qt = False
614
+ elif len(x) == 3:
615
+ if int(x[0]) >= 6 and int(x[1]) >= 7 and int(x[2]) >= 2:
616
+ old_Qt = False
617
+
618
+ # Featureset for wayland if pyqt is older that 6.7.1
593
619
  dockfeatures = (
594
620
  QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetClosable
595
621
  | QtWidgets.QDockWidget.DockWidgetFeature.DockWidgetMovable
@@ -598,7 +624,7 @@ class MainWindow(QtWidgets.QMainWindow):
598
624
  self.show_splash_msg("Setting up BandMapWindow.")
599
625
  self.bandmap_window = BandMapWindow()
600
626
  self.bandmap_window.setObjectName("bandmap-window")
601
- if os.environ.get("WAYLAND_DISPLAY"):
627
+ if os.environ.get("WAYLAND_DISPLAY") and old_Qt is True:
602
628
  self.bandmap_window.setFeatures(dockfeatures)
603
629
  self.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, self.bandmap_window)
604
630
  self.bandmap_window.hide()
@@ -609,7 +635,7 @@ class MainWindow(QtWidgets.QMainWindow):
609
635
  self.show_splash_msg("Setting up CheckWindow.")
610
636
  self.check_window = CheckWindow()
611
637
  self.check_window.setObjectName("check-window")
612
- if os.environ.get("WAYLAND_DISPLAY"):
638
+ if os.environ.get("WAYLAND_DISPLAY") and old_Qt is True:
613
639
  self.check_window.setFeatures(dockfeatures)
614
640
  self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.check_window)
615
641
  self.check_window.hide()
@@ -618,7 +644,7 @@ class MainWindow(QtWidgets.QMainWindow):
618
644
  self.show_splash_msg("Setting up VFOWindow.")
619
645
  self.vfo_window = VfoWindow()
620
646
  self.vfo_window.setObjectName("vfo-window")
621
- if os.environ.get("WAYLAND_DISPLAY"):
647
+ if os.environ.get("WAYLAND_DISPLAY") and old_Qt is True:
622
648
  self.vfo_window.setFeatures(dockfeatures)
623
649
  self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.vfo_window)
624
650
  self.vfo_window.hide()
@@ -626,7 +652,7 @@ class MainWindow(QtWidgets.QMainWindow):
626
652
  self.show_splash_msg("Setting up LogWindow.")
627
653
  self.log_window = LogWindow()
628
654
  self.log_window.setObjectName("log-window")
629
- if os.environ.get("WAYLAND_DISPLAY"):
655
+ if os.environ.get("WAYLAND_DISPLAY") and old_Qt is True:
630
656
  self.log_window.setFeatures(dockfeatures)
631
657
  self.addDockWidget(Qt.DockWidgetArea.TopDockWidgetArea, self.log_window)
632
658
  self.log_window.hide()
@@ -688,6 +714,45 @@ class MainWindow(QtWidgets.QMainWindow):
688
714
  "You can udate to the current version by using:\npip install -U not1mm"
689
715
  )
690
716
 
717
+ def load_call_history(self) -> None:
718
+ """"""
719
+ filename = self.filepicker("other")
720
+ if filename:
721
+ self.database.create_callhistory_table()
722
+ self.database.delete_callhistory()
723
+
724
+ try:
725
+ with open(filename, "rt", encoding="utf-8") as file_descriptor:
726
+ lines = file_descriptor.readlines()
727
+ if "!!Order!!" in lines[0]:
728
+ item_names = lines[0].strip().split(",")
729
+ # ['!!Order!!', 'Call', 'Sect', 'State', 'CK', 'UserText', '']
730
+ item_names = item_names[1:-1]
731
+ # ['Call', 'Sect', 'State', 'CK', 'UserText']
732
+ lines = lines[1:]
733
+ group_list = []
734
+ for line in lines:
735
+ if line.startswith("#"):
736
+ continue
737
+ group = {}
738
+ fields = line.strip().split(",")
739
+ # ['4U1WB','MDC','DC','89','']
740
+ count = 0
741
+ try:
742
+ for item in item_names:
743
+ if item == "":
744
+ continue
745
+ group[item] = fields[count]
746
+ count += 1
747
+ group_list.append(group)
748
+ # database.add_callhistory_item(group)
749
+ # print(f"{group=}")
750
+ except IndexError:
751
+ ...
752
+ self.database.add_callhistory_items(group_list)
753
+ except FileNotFoundError as err:
754
+ self.show_message_box(f"{err}")
755
+
691
756
  def on_focus_changed(self, new):
692
757
  """"""
693
758
  if self.use_esm:
@@ -1713,6 +1778,14 @@ class MainWindow(QtWidgets.QMainWindow):
1713
1778
  "Database (*.db)",
1714
1779
  options=options,
1715
1780
  )
1781
+ if action == "other":
1782
+ file, _ = QFileDialog.getOpenFileName(
1783
+ self,
1784
+ "Choose a File",
1785
+ "~/",
1786
+ "Any (*.*)",
1787
+ options=options,
1788
+ )
1716
1789
  return file
1717
1790
 
1718
1791
  def recalculate_mults(self) -> None:
@@ -1892,6 +1965,43 @@ class MainWindow(QtWidgets.QMainWindow):
1892
1965
  if self.rig_control.interface == "flrig":
1893
1966
  self.rig_control.cat.set_flrig_cw_speed(self.cw_speed.value())
1894
1967
 
1968
+ def stop_cw(self):
1969
+ """"""
1970
+ if self.cw is not None:
1971
+ if self.cw.servertype == 1:
1972
+ self.cw.sendcw("\x1b4")
1973
+ return
1974
+ if self.rig_control:
1975
+ if self.rig_control.online:
1976
+ if self.pref.get("cwtype") == 3 and self.rig_control is not None:
1977
+ if self.rig_control.interface == "flrig":
1978
+ self.rig_control.cat.set_flrig_cw_send(False)
1979
+ self.rig_control.cat.set_flrig_cw_send(True)
1980
+
1981
+ def mark_spot(self):
1982
+ """"""
1983
+ freq = self.radio_state.get("vfoa")
1984
+ dx = self.callsign.text()
1985
+ if freq and dx:
1986
+ cmd = {}
1987
+ cmd["cmd"] = "MARKDX"
1988
+ cmd["dx"] = dx
1989
+ cmd["freq"] = float(int(freq) / 1000)
1990
+ if self.bandmap_window:
1991
+ self.bandmap_window.msg_from_main(cmd)
1992
+
1993
+ def spot_dx(self):
1994
+ """"""
1995
+ freq = self.radio_state.get("vfoa")
1996
+ dx = self.callsign.text()
1997
+ if freq and dx:
1998
+ cmd = {}
1999
+ cmd["cmd"] = "SPOTDX"
2000
+ cmd["dx"] = dx
2001
+ cmd["freq"] = float(int(freq) / 1000)
2002
+ if self.bandmap_window:
2003
+ self.bandmap_window.msg_from_main(cmd)
2004
+
1895
2005
  def keyPressEvent(self, event) -> None: # pylint: disable=invalid-name
1896
2006
  """
1897
2007
  This overrides Qt key event.
@@ -1906,6 +2016,12 @@ class MainWindow(QtWidgets.QMainWindow):
1906
2016
  None
1907
2017
  """
1908
2018
  modifier = event.modifiers()
2019
+ if (
2020
+ event.key() == Qt.Key.Key_Equal
2021
+ and modifier == Qt.KeyboardModifier.ControlModifier
2022
+ ):
2023
+ self.save_contact()
2024
+ return
1909
2025
  if event.key() == Qt.Key.Key_K:
1910
2026
  self.toggle_cw_entry()
1911
2027
  return
@@ -2886,6 +3002,9 @@ class MainWindow(QtWidgets.QMainWindow):
2886
3002
  "DISABLED": None,
2887
3003
  }
2888
3004
 
3005
+ self.use_call_history = self.pref.get("use_call_history", False)
3006
+ if self.use_call_history:
3007
+ self.history_info.show()
2889
3008
  self.use_esm = self.pref.get("use_esm", False)
2890
3009
  self.esm_dict["CQ"] = fkey_dict.get(self.pref.get("esm_cq", "DISABLED"))
2891
3010
  self.esm_dict["EXCH"] = fkey_dict.get(self.pref.get("esm_exch", "DISABLED"))
@@ -2953,7 +3072,7 @@ class MainWindow(QtWidgets.QMainWindow):
2953
3072
  None
2954
3073
  """
2955
3074
 
2956
- self.pref["command_buttons"] = self.actionCommand_Buttons.isChecked()
3075
+ self.pref["command_buttons"] = self.actionCommand_Buttons_2.isChecked()
2957
3076
  self.write_preference()
2958
3077
  self.show_command_buttons()
2959
3078
 
@@ -3109,6 +3228,13 @@ class MainWindow(QtWidgets.QMainWindow):
3109
3228
  if self.lookup_service:
3110
3229
  self.lookup_service.msg_from_main(cmd)
3111
3230
  self.next_field.setFocus()
3231
+ if self.contest:
3232
+ if self.use_call_history and hasattr(
3233
+ self.contest, "check_call_history"
3234
+ ):
3235
+ self.contest.check_call_history(self)
3236
+ if "CQ WW" in self.contest.name or "IARU HF" in self.contest.name:
3237
+ self.contest.prefill(self)
3112
3238
  return
3113
3239
  cmd = {}
3114
3240
  cmd["cmd"] = "CALLCHANGED"
@@ -3278,7 +3404,11 @@ class MainWindow(QtWidgets.QMainWindow):
3278
3404
  )
3279
3405
  if len(callsign) > 2:
3280
3406
  if self.contest:
3281
- self.contest.prefill(self)
3407
+ if (
3408
+ "CQ WW" not in self.contest.name
3409
+ and "IARU HF" not in self.contest.name
3410
+ ):
3411
+ self.contest.prefill(self)
3282
3412
 
3283
3413
  def check_dupe(self, call: str) -> bool:
3284
3414
  """Checks if a callsign is a dupe on current band/mode."""