[UI] Update default for "Hide Unused Fields"
Set "Hide Unused Fields" to be enabled by default
#1779
diff -r 832afc1a783c -r a49282e62688 chirpui/mainapp.py --- a/chirpui/mainapp.py Tue Jul 22 19:31:33 2014 -0400 +++ b/chirpui/mainapp.py Tue Jul 22 20:53:05 2014 -0400 @@ -1555,7 +1555,7 @@
conf = config.get() re = not conf.get_bool("no_report");
hu = conf.get_bool("hide_unused", "memedit")
hu = not conf.get_bool("hide_unused", "memedit")
I think this will flip it for everyone that currently has it set, right? And, I would think that this would mean that if you enable it, then close and re-open chirp, it will be disabled (and vice versa) right? If we store hide_unused=True because they have it set, then when we load the config next time, we will assume (not True)== False for that run. Then when we save it, we'll save False, which next time will be (not False)==True, causing it to flap on and off.
I think we need something like this:
diff -r 312bfc5cab57 chirpui/config.py --- a/chirpui/config.py Mon Jul 21 16:48:35 2014 +0200 +++ b/chirpui/config.py Wed Jul 23 09:02:28 2014 -0700 @@ -96,8 +96,12 @@
self.set(key, "%i" % value, section)
- def get_bool(self, key, section=None): - return self.get(key, section) == "True" + def get_bool(self, key, section=None, default=False): + val = self.get(key, section) + if val is None: + return default + else: + return val == "True"
def set_bool(self, key, value, section=None): self.set(key, str(bool(value)), section) diff -r 312bfc5cab57 chirpui/mainapp.py --- a/chirpui/mainapp.py Mon Jul 21 16:48:35 2014 +0200 +++ b/chirpui/mainapp.py Wed Jul 23 09:02:28 2014 -0700 @@ -1555,7 +1555,7 @@
conf = config.get() re = not conf.get_bool("no_report"); - hu = conf.get_bool("hide_unused", "memedit") + hu = conf.get_bool("hide_unused", "memedit", default=True) dv = conf.get_bool("developer", "state") st = not conf.get_bool("no_smart_tmode", "memedit")
The first hunk lets you pass a default value to get_bool(), which says "if it's not set in the config, assume this default instead of False". Normally, we assume False if not set, but in the case of hide_unused, we want to assume True if not set.
This way, existing users that have it already set won't see it magically change on them. Anyone who has never toggled the value shouldn't have it set in their config, which means they'll get the new value of enabled-by-default.
What do you think?
Thanks Jim!
--Dan