From f377a8af53463daec0d373f5e87b613a5c525af6 Mon Sep 17 00:00:00 2001
From: Pete Peterson <petersonpf@ornl.gov>
Date: Wed, 15 Aug 2018 16:48:33 -0400
Subject: [PATCH] Add method to remove a key

---
 .../workbench/workbench/config/test/test_user.py           | 6 ++++++
 qt/applications/workbench/workbench/config/user.py         | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/qt/applications/workbench/workbench/config/test/test_user.py b/qt/applications/workbench/workbench/config/test/test_user.py
index 44cbe84769b..a9bdc3cdb46 100644
--- a/qt/applications/workbench/workbench/config/test/test_user.py
+++ b/qt/applications/workbench/workbench/config/test/test_user.py
@@ -68,6 +68,12 @@ class ConfigUserTest(TestCase):
         self.assertFalse(self.cfg.has('main', 'missing-key'))
         self.assertFalse(self.cfg.has('main/missing-key'))
 
+    def test_remove_key(self):
+        self.cfg.set('main', 'key1', 1)
+        self.assertTrue(self.cfg.has('main/key1'))
+        self.cfg.remove('main/key1')
+        self.assertFalse(self.cfg.has('main/key1'))
+
     # ----------------------------------------------
     # Failure tests
     # ----------------------------------------------
diff --git a/qt/applications/workbench/workbench/config/user.py b/qt/applications/workbench/workbench/config/user.py
index f7658e2db61..cfce377d88d 100644
--- a/qt/applications/workbench/workbench/config/user.py
+++ b/qt/applications/workbench/workbench/config/user.py
@@ -114,6 +114,13 @@ class UserConfig(object):
             value = extra
         self.qsettings.setValue(option, value)
 
+    def remove(self, option, second=None):
+        """Removes a key from the settings. Key not existing returns without effect.
+        """
+        option = self._check_section_option_is_valid(option, second)
+        if self.has(option):
+            self.qsettings.remove(option)
+
     # -------------------------------------------------------------------------
     # "Private" methods
     # -------------------------------------------------------------------------
-- 
GitLab