Skip to content

Commit

Permalink
Add ability to restore add-on settings to defaults (#42)
Browse files Browse the repository at this point in the history
* Add ability to restore add-on settings to defaults

* Fix linter errors
  • Loading branch information
nvdaes authored May 19, 2023
1 parent c7ea4b4 commit a19cdae
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
23 changes: 21 additions & 2 deletions addon/globalPlugins/clipContentsDesigner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ class AddonSettingsPanel(SettingsPanel):
def makeSettings(self, settingsSizer):
sHelper = guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
# Translators: label of a dialog.
self.restoreDefaultsButton = sHelper.addItem(wx.Button(self, label=_("Restore defaults")))
self.restoreDefaultsButton.Bind(wx.EVT_BUTTON, self.onRestoreDefaults)
# Translators: label of a dialog.
setSeparatorLabel = _("Type the string to be used as a &separator between contents added to the clipboard.")
self.setSeparatorEdit = sHelper.addLabeledControl(setSeparatorLabel, wx.TextCtrl)
self.setSeparatorEdit.SetValue(config.conf["clipContentsDesigner"]["separator"])
Expand Down Expand Up @@ -472,10 +475,26 @@ def makeSettings(self, settingsSizer):
max=1000000,
initial=config.conf["clipContentsDesigner"]["maxLengthForBrowseableText"]
)

def postInit(self):
self.setSeparatorEdit.SetFocus()

def onRestoreDefaults(self, evt):
self.setSeparatorEdit.SetValue(
config.conf.getConfigValidation(['clipContentsDesigner', 'separator']).default
)
self.addTextBeforeCheckBox.SetValue(
config.conf.getConfigValidation(['clipContentsDesigner', 'addTextBefore']).default
)
self.confirmList.CheckedItems = []
self.confirmRequirementChoices.SetSelection(
config.conf.getConfigValidation(['clipContentsDesigner', 'confirmationRequirement']).default
)
self.formatChoices.SetSelection(
config.conf.getConfigValidation(['clipContentsDesigner', 'browseableTextFormat']).default
)
self.maxLengthEdit.SetValue(
config.conf.getConfigValidation(['clipContentsDesigner', 'maxLengthForBrowseableText']).default
)

def onSave(self):
config.conf["clipContentsDesigner"]["separator"] = self.setSeparatorEdit.GetValue()
config.conf["clipContentsDesigner"]["addTextBefore"] = self.addTextBeforeCheckBox.GetValue()
Expand Down
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This panel is available from NVDA's menu, Preferences submenu, Settings dialog.

It contains the following controls:

* Restore defaults: Press shift+tab after opening the panel to press this button.
* Type the string to be used as a separator between contents added to the clipboard: Allows to set a separator which can be used to find the text segments once the entire added text is pasted.
* Add text before clip data: It's also possible to choose if the added text will be appended or prepended.
* Select the actions which require previous confirmation: You can choose, for each action available, if it should be performed inmediately or after confirmation. Available actions are: add text, clear clipboard, emulate copy and emulate cut.
Expand All @@ -31,6 +32,9 @@ Notes:
* Confirmations won't be requested when a message box of NVDA is still opened. In those cases, actions will be inmediately performed.
* Emulate copy and emulate cut commands mean that, when these features are enabled, the add-on will take control of control+c and control+x. This will allow to select if a confirmation should be requested before performing the actions corresponding to these keystrokes.

## Changes for 22.0.0
* Added a button to restore defaults in the add-on settings panel.

## Changes for 17.0
* Compatible with NVDA 2023.1.

Expand Down

0 comments on commit a19cdae

Please sign in to comment.