From 65a0320cea36f66b6c2fbb63eb4f69ea9ed0ad13 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 29 Mar 2020 19:52:56 +0200 Subject: [PATCH] refactor --- owrx/controllers/settings.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/owrx/controllers/settings.py b/owrx/controllers/settings.py index d4c50cd..831fbf3 100644 --- a/owrx/controllers/settings.py +++ b/owrx/controllers/settings.py @@ -110,6 +110,13 @@ class CheckboxInput(Input): return {self.id: self.id in data and data[self.id][0] == "on"} +class Option(object): + # used for both MultiCheckboxInput and DropdownInput + def __init__(self, value, text): + self.value = value + self.text = text + + class MultiCheckboxInput(Input): def __init__(self, id, label, options, infotext=None): super().__init__(id, label, infotext=infotext) @@ -148,16 +155,10 @@ class MultiCheckboxInput(Input): class ServicesCheckboxInput(MultiCheckboxInput): def __init__(self, id, label, infotext=None): - services = [DropdownOption(s, s.upper()) for s in ServiceDetector.getAvailableServices()] + services = [Option(s, s.upper()) for s in ServiceDetector.getAvailableServices()] super().__init__(id, label, services, infotext) -class DropdownOption(object): - def __init__(self, value, text): - self.value = value - self.text = text - - class DropdownInput(Input): def __init__(self, id, label, options, infotext = None): super().__init__(id, label, infotext=infotext) @@ -237,12 +238,12 @@ class SettingsController(AdminController): Section( "Compression", DropdownInput("audio_compression", "Audio compression", options=[ - DropdownOption("adpcm", "ADPCM"), - DropdownOption("none", "None"), + Option("adpcm", "ADPCM"), + Option("none", "None"), ]), DropdownInput("fft_compression", "Waterfall compression", options=[ - DropdownOption("adpcm", "ADPCM"), - DropdownOption("none", "None"), + Option("adpcm", "ADPCM"), + Option("none", "None"), ]), ), Section(