From 62d25244e0a4b7e52ddbe04281ae4b82e8fce2c9 Mon Sep 17 00:00:00 2001 From: alessandro90 Date: Sun, 18 Nov 2018 17:02:07 +0100 Subject: [PATCH] Add modulation filter screen plus minor modifications --- audio_player.py | 2 +- download_window.py | 1 + main.py | 6 +- main_window.ui | 31 +++++----- utilities.py | 137 ++++++++++++++++++++++++--------------------- 5 files changed, 97 insertions(+), 80 deletions(-) diff --git a/audio_player.py b/audio_player.py index d8b6b36..27754e7 100644 --- a/audio_player.py +++ b/audio_player.py @@ -8,7 +8,7 @@ import qtawesome as qta from utilities import Constants -class AudioPlayer(QObject): +class AudioPlayer(QObject): # Maybe useless inheriting from QObject """ This is the audio player widget. The only public methods are the __init__ method and set_audio_player, which loads the current file. Everything else diff --git a/download_window.py b/download_window.py index 9ba58e7..2291e34 100644 --- a/download_window.py +++ b/download_window.py @@ -2,6 +2,7 @@ from PyQt5 import uic from PyQt5.QtCore import Qt, pyqtSlot from PyQt5.QtWidgets import QWidget, QMessageBox from threads import DownloadThread, ThreadStatus + Ui_Download_window, _ = uic.loadUiType("download_db_window.ui") class DownloadWindow(QWidget, Ui_Download_window): diff --git a/main.py b/main.py index fee30cb..b43bef4 100644 --- a/main.py +++ b/main.py @@ -542,8 +542,8 @@ class MyApp(QMainWindow, Ui_MainWindow): @pyqtSlot() def display_signals(self): - for i in range(self.result_list.count()): - self.result_list.item(i).setHidden(True) + # for i in range(self.result_list.count()): + # self.result_list.item(i).setHidden(True) text = self.search_bar.text() available_signals = 0 for index, signal in enumerate(self.signal_names): @@ -555,6 +555,8 @@ class MyApp(QMainWindow, Ui_MainWindow): self.modulation_filters_ok(signal)]): self.result_list.item(index).setHidden(False) available_signals += 1 + else: + self.result_list.item(index).setHidden(True) self.update_status_tip(available_signals) def update_status_tip(self, available_signals): diff --git a/main_window.ui b/main_window.ui index c95046d..aeec5cf 100644 --- a/main_window.ui +++ b/main_window.ui @@ -134,6 +134,20 @@ QTextBrowser { QRadioButton { color: #ffffff; +} + +QListWidget { + background-color:rgb(52,52,52); + color: rgb(255, 255, 255); + border: 1px solid gray; + border-radius: 8px; +} + +QLineEdit { + background-color: #343434; + color: rgb(255, 255, 255); + border: 1px solid gray; + border-radius: 5px; } @@ -187,10 +201,7 @@ QRadioButton { - background-color: #343434; -color: rgb(255, 255, 255); -border: 1px solid gray; -border-radius: 5px; + @@ -244,13 +255,7 @@ border-radius: 5px; - QListWidget { - background-color:rgb(52,52,52); - color: rgb(255, 255, 255); - border: 1px solid gray; - border-radius: 8px; -} - + Qt::ScrollBarAsNeeded @@ -330,7 +335,7 @@ QPushButton:!enabled { QTabWidget::Rounded - 1 + 0 true @@ -1969,7 +1974,7 @@ QPushButton:checked { - 4 + 0 true diff --git a/utilities.py b/utilities.py index d36d054..7c38df4 100644 --- a/utilities.py +++ b/utilities.py @@ -4,77 +4,86 @@ from pandas import read_csv class _ReadOnlyProperty(object): def __init__(self, value): - self.value = value + self.__value = value def __get__(self, obj, objtype): - return self.value + return self.__value - def __Set__(self, obj, value): + def __set__(self, obj, value): return NotImplementedError("Cannot change a constant.") +def __make_read_only(cls): + for k, v in cls.__dict__.items(): + if not callable(getattr(cls, k)) and '__' not in k: + setattr(cls, k, _ReadOnlyProperty(v)) + # def raise_err(self, attr, value): + # raise NotImplementedError("Cannot add an attribute.") + # setattr(cls, '__setattr__', raise_err) + return cls -class Constants(object): - DB_LOCATION = _ReadOnlyProperty('https://aresvalley.com/Storage/Artemis/Database/data.zip') - REF_LOC = _ReadOnlyProperty('https://aresvalley.com/Storage/Artemis/Database/data.zip.log') - DATA_FOLDER = _ReadOnlyProperty('Data') - SPECTRA_FOLDER = _ReadOnlyProperty('Spectra') - AUDIO_FOLDER = _ReadOnlyProperty('Audio') - ICONS_FOLDER = _ReadOnlyProperty('icons_imgs') - __Band = namedtuple("Band", ["lower", "upper"]) - __ELF = __Band(0, 30) # Formally it is (3, 30) Hz. - __SLF = __Band(30, 300) - __ULF = __Band(300, 3000) - __VLF = __Band(3000, 30000) - __LF = __Band(30 * 10**3, 300 * 10**3) - __MF = __Band(300 * 10 ** 3, 3000 * 10**3) - __HF = __Band(3 * 10**6, 30 * 10**6) - __VHF = __Band(30 * 10**6, 300 * 10**6) - __UHF = __Band(300 * 10**6, 3000 * 10**6) - __SHF = __Band(3 * 10**9, 30 * 10**9) - __EHF = __Band(30 * 10**9, 300 * 10**9) - BANDS = _ReadOnlyProperty((__ELF, __SLF, __ULF, __VLF, __LF, __MF, __HF, __VHF, __UHF, __SHF, __EHF)) - ACTIVE_COLOR = _ReadOnlyProperty("#39eaff") - INACTIVE_COLOR = _ReadOnlyProperty("#9f9f9f") - CONVERSION_FACTORS = _ReadOnlyProperty({"Hz":1, "kHz":1000, "MHz":1000000, "GHz":1000000000}) - MODES = _ReadOnlyProperty({"FM": ["NFM", "WFM"], - "AM": [], - "CW": [], - "SK": ["FSK", "PSK", "MSK"], - "SB": ["LSB", "USB", "DSB"], - "Chirp Spread Spectrum": [], - "FHSS-TDM": [], - "RAW": [], - "SC-FDMA": [],} - ) - APPLY = _ReadOnlyProperty("Apply") - REMOVE = _ReadOnlyProperty("Remove") - UNKNOWN = _ReadOnlyProperty("N/A") - MODULATIONS = _ReadOnlyProperty(["8VSB", - "AFSK", - "AM", - "BFSK", - "C4FM", - "CDMA", - "COFDM", - "CW", - "FFSK", - "FM", - "FMCW", - "FMOP", - "FSK", - "GFSK", - "GMSK", - "IFK", - "MFSK", - "MSK", - "OFDM", - "OOK", - "PAM", - "PPM", - "PSK", - "QAM", - "TDMA",]) +@__make_read_only +class __Constants(object): + DB_LOCATION = 'https://aresvalley.com/Storage/Artemis/Database/data.zip' + REF_LOC = 'https://aresvalley.com/Storage/Artemis/Database/data.zip.log' + DATA_FOLDER = 'Data' + SPECTRA_FOLDER = 'Spectra' + AUDIO_FOLDER = 'Audio' + ICONS_FOLDER = 'icons_imgs' + __Band = namedtuple("Band", ["lower", "upper"]) + __ELF = __Band(0, 30) # Formally it is (3, 30) Hz. + __SLF = __Band(30, 300) + __ULF = __Band(300, 3000) + __VLF = __Band(3000, 30000) + __LF = __Band(30 * 10**3, 300 * 10**3) + __MF = __Band(300 * 10 ** 3, 3000 * 10**3) + __HF = __Band(3 * 10**6, 30 * 10**6) + __VHF = __Band(30 * 10**6, 300 * 10**6) + __UHF = __Band(300 * 10**6, 3000 * 10**6) + __SHF = __Band(3 * 10**9, 30 * 10**9) + __EHF = __Band(30 * 10**9, 300 * 10**9) + BANDS = (__ELF, __SLF, __ULF, __VLF, __LF, __MF, __HF, __VHF, __UHF, __SHF, __EHF) + ACTIVE_COLOR = "#39eaff" + INACTIVE_COLOR = "#9f9f9f" + CONVERSION_FACTORS = {"Hz":1, "kHz":1000, "MHz":1000000, "GHz":1000000000} + MODES = {"FM": ["NFM", "WFM"], + "AM": [], + "CW": [], + "SK": ["FSK", "PSK", "MSK"], + "SB": ["LSB", "USB", "DSB"], + "Chirp Spread Spectrum": [], + "FHSS-TDM": [], + "RAW": [], + "SC-FDMA": [],} + APPLY = "Apply" + REMOVE = "Remove" + UNKNOWN = "N/A" + MODULATIONS = ["8VSB", + "AFSK", + "AM", + "BFSK", + "C4FM", + "CDMA", + "COFDM", + "CW", + "FFSK", + "FM", + "FMCW", + "FMOP", + "FSK", + "GFSK", + "GMSK", + "IFK", + "MFSK", + "MSK", + "OFDM", + "OOK", + "PAM", + "PPM", + "PSK", + "QAM", + "TDMA",] +Constants = __Constants() def reset_apply_remove_btn(button): if button.isChecked():