Skip to content

Allow setting braille display specific settings in the GUI#8214

Merged
feerrenrut merged 39 commits into
nvaccess:masterfrom
BabbageCom:i7452
May 16, 2019
Merged

Allow setting braille display specific settings in the GUI#8214
feerrenrut merged 39 commits into
nvaccess:masterfrom
BabbageCom:i7452

Conversation

@LeonarddeR

@LeonarddeR LeonarddeR commented Apr 30, 2018

Copy link
Copy Markdown
Collaborator

Though this pr is a fully working implementation, I"m open for any feedback and am willing to change things drastically if desired.

Link to issue number:

Closes #7452

Summary of the issue:

Speech synthesizers support changing synth specific properties (such as volume, inflection, rate boost) in the graphical user interface. Braille display drivers currently don't have this ability. This means that braille display specific settings, such as dot firmness and whether to enable braille input, can't be changed from the GUI.

Description of how this pull request fixes the issue:

  1. Introduce a new driverHandler with a Driver class that contains all the functionality that has to be available both for synthesizer and braille display drivers. In the future, vision enhancement providers (such as magnifier, screen curtain and focus highlight) will also inherit from this class. Support for driver specific settings is now part of this class.
  2. Introduce a DriverSettingsMixin class for settings panels to support driver specific GUI settings. Most if not all of the synthesizer specific settings logic has been moved to this mixin.
  3. Added braille input and ATC toggles to the Handy Tech display driver as an example implementation. The eurobraille and ALVA drivers are not yet changed for this.
  4. Renamed the synthSettingsRing module to settingsRing. The global settings ring will still be a synthesizer settings ring. However, global plugins can now implement their own ring for custom drivers, such as future magnifiers.

Testing performed:

Tested changing handy tech driver parameters through the gui. Also changed several synth parameters through the synth settings ring and gui, and checked that the gui successfully updated itself accordingly.

Known issues with pull request:

None

Change log entry:

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

Just to be clear, I don't at all expect this to be reviewed before 2018.2. Furthermore, I don't expect this to conflict with braille display auto detection in a major way.

@bramd: As I recall that you were particularly interested in this idea, I'd also welcome a quick review from you, if you have the time.

@dkager

dkager commented Jun 15, 2018

Copy link
Copy Markdown
Contributor

I think a braille input toggle should be added to all drivers that potentially support this (and then I wonder if it should actually be driver-specific). You could also allow setting the braille input table to "No input".

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

The problem with your idea is that it requires some significant changes in all InputGesture derivatives, and I'm afraid it is currently not possible to test them all. I can do this for Hims, but than, we need to agree on what key names to use.

@dkager

dkager commented Jun 16, 2018

Copy link
Copy Markdown
Contributor

So we can't receive input and ignore it just before sending it to liblouis? I agree that this would be ugly, but it would be a universal setting that way.

The other solution for the HumanWare and ALVA displays is to just disable the 8 braille keys.

@LeonarddeR LeonarddeR closed this Jun 20, 2018
@LeonarddeR LeonarddeR deleted the i7452 branch June 20, 2018 05:00
@LeonarddeR LeonarddeR restored the i7452 branch June 20, 2018 05:00
@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

I closed this by accidentally removing the branch. Reopening.

@LeonarddeR LeonarddeR reopened this Jun 20, 2018
@feerrenrut

Copy link
Copy Markdown
Contributor

The PR comment mentions that this is not complete, could you elaborate on what is remaining?
Also, can you please update the changes.t2t file.

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@feerrenrut commented on 1 aug. 2018 03:39 CEST:

The PR comment mentions that this is not complete, could you elaborate on what is remaining?

THis is actually no longer true, I updated the comment accordingly.

Also, can you please update the changes.t2t file.

I don't think that we should aim to have this in 2018.3. Therefore if you agree, I'd rather wait until there's some more clarity about when this is ready to merge. Note that, though the amount of changes is really huge from a line count perspective, it is basically mainly moving things around, renaming synth to driver, etc.

@feerrenrut

Copy link
Copy Markdown
Contributor

Note that, though the amount of changes is really huge from a line count perspective, it is basically mainly moving things around.

Would you have time to rebase the changes so that moves and renames can be reviewed separately from the rest of the changes?

I don't think that we should aim to have this in 2018.3

I have started reviewing this, and will leave my comments. I'll probably need to review it again.

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@feerrenrut commented on 1 aug. 2018 08:00 CEST:

Would you have time to rebase the changes so that moves and renames can be reviewed separately from the rest of the changes?

I just rebased on master.

@feerrenrut

Copy link
Copy Markdown
Contributor

I just rebased on master.

Ah woops, not quite what I meant. I should have been more clear. I was hoping that when I do the final review of this, I can do it one commit at a time. First look at the moved code all in one commit, then a commit with the rename, then all other changes in final (or several other commits). They do not have to be in that order, but being able to isolate each of those groups really makes the process easier.

@feerrenrut feerrenrut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the settings ring limited to synth / braille driver settings? It might be a good moment to consider this, there have been issues in the past requesting that the options in the settings ring are configurable. I'm tempted to suggest that the settings ring changes be made separately from this PR. Being able to adjust braille driver settings from the NVDA braille settings dialog is a great start!

Comment thread source/braille.py Outdated
_BgThread.queueApc(_BgThread.executor)

@classmethod
def DotFirmnessSetting(cls,defaultVal,minVal,maxVal):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see this actually used (and tested) somewhere in this PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added and tested this functionality for the handy tech driver.

Í'm not sure what to do with models that don't support this functionality. Settings are defined on the driver class, and we don't know whether a model supports a setting when at the class level.

Comment thread source/driverHandler.py
continue

@classmethod
def _paramToPercent(cls, current, min, max):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it seems that these were not introduced here, I question whether this is where they belong. They are quite a bit more specific than the Driver class, perhaps in the NumericDriverSetting class instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that they are used within many synthesizer classes, moving them out of the SynthDriver or one of its parent classes would cause backwards incompatibility. Having said that, I can move them back to the SynthDriver class if you desire.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't you do the same as you already have done, import it for backwards compatibility?

Comment thread source/gui/nvdaControls.py Outdated

class EnhancedInputSlider(wx.Slider):
"""
A slider that supports additional key events, such as pageup/pageDown.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why pageup/pagedown support is desirable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that my assumptions where wrong. Page up and page down support is to move the slider in bigger steps, but this support was already there in wx.Slider. Honestly, I really don't know now what's the purpose of this class. 😖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems to have been removed, but the class is still there and still supports pageup/pagedown?

super(SynthesizerSelectionDialog, self).onOk(evt)

class SynthSettingChanger(object):
class DriverSettingChanger(object):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How hard would it be to pull out the DriverSettingChanger class and related sub-classes into a separate or submodule?

Comment thread source/gui/settingsDialogs.py Outdated
self.sizerDict={}
self.lastControl=None
super(DriverSettingsMixin,self).__init__(*args,**kwargs)
self._curDriverRef = weakref.ref(self.driver)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many spaces after the equals sign.

Comment thread source/settingsRing.py Outdated
self.step = setting.normalStep if isinstance(setting,synthDriverHandler.NumericSynthSetting) else 1
class DriverSetting(baseObject.AutoPropertyObject):
"""a numeric driver setting. Has functions to set, get, increase and decrease its value """
def __init__(self,driver,setting,min=0,max=100):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min, max only really make sense for numerical derivatives of this class. I'd prefer it was moved to the specialisation.

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@feerrenrut commented on 1 aug. 2018 09:46 CEST:

I was hoping that when I do the final review of this, I can do it one commit at a time. First look at the moved code all in one commit, then a commit with the rename, then all other changes in final (or several other commits). They do not have to be in that order, but being able to isolate each of those groups really makes the process easier.

I agree that this should have been handy, however I'm afraid that it will be very hard to accomplish this.

I have a backup of the old branch without the rebase on master, would it be helpful for you if I'd restore that? Probably not as it will create outdated review comments.

@feerrenrut feerrenrut self-requested a review August 6, 2018 08:56
Comment thread source/driverHandler.py Outdated
@rtype: l{bool}
"""
for s in self.supportedSettings:
if s.name==settingName: return True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work with translations? We shouldn't be comparing translated strings.
Oh, I see there is also displayName. I would have prefered name be ID I think.
But then StringParameterInfo has ID and name where name is the displayable string.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mm, yes, this is confusing. I'd be happy to change name to id, that's not a big deal. however, I want to use self.id, not self.ID. So I would like to propose making things uniform here. How about self.id and self.displayName for both settings and parameters?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about self.id and self.displayName for both settings and parameters?

Yes, that is fine with me.

Comment thread source/driverHandler.py
continue

@classmethod
def _paramToPercent(cls, current, min, max):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't you do the same as you already have done, import it for backwards compatibility?

Comment thread source/driverHandler.py
Comment thread source/braille.py Outdated

firstLoad = not config.conf["braille"].isSet(name)
if firstLoad:
config.conf["braille"][name] = {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this resolved?

Comment thread source/gui/nvdaControls.py Outdated

class EnhancedInputSlider(wx.Slider):
"""
A slider that supports additional key events, such as pageup/pageDown.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems to have been removed, but the class is still there and still supports pageup/pagedown?

Comment thread source/gui/settingsDialogs.py Outdated
return checkbox

def updateDriverSettings(self, changedSetting=None):
"""Creates, hides or updates existing GUI controls for all of supported settings."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be pulled out, right now it's hard to read. What about the driver provides a factory for constructing these. The common ones can be pulled out of here and provided for re-use.

For now, leave this as it is, in the interests of getting this merged.

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

I seem to be unable to reply on some of your inline comments, e.g. #8214 (comment). Do you have any idea why that could be the case?

As for #8214 (comment), I'm afraid I don't understand. What do you want me to import?

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@feerrenrut: I've had another look at this project ans stumbled upon some issues, which I've tried to solve. I'm sorry for the extra review work that causes this:

  1. A driver now saves its configuration when terminating. When exiting NVDA, the config is saved before terminating braille and speech, so that's where the pre_configSave action is used for. We actually would need a pre_configProfileSwitch action as well to make sure that settings are saved when profile switching. For speech, this has never been a problem because either the settings dialog or the settings ring automatically saves its configuration, but for braille drivers, this is currently not the case. I've not yet added such an action.
  2. The braille and synth handler loaded/saved their configuration based on whether the device was loaded for the first time. This is now still the case, but I abstracted this in a new initSettings method on drivers,. Now, the respective handler only has to call initSettings after the initialization has succeeded. Note that we can't call initSettings as part of Driver.init, as the settings system requires that the driver is fully initialized before loading/saving. initSetting also ensures that every driver has appropriate attributes for the settings system to work.
    A major drawback of the current code is that SynthDriver still needs overrides for initSettings and loadSettings. I really want to abstract this better, but I have no clue as how to do this most effectively.

@feerrenrut

Copy link
Copy Markdown
Contributor

seem to be unable to reply on some of your inline comments,

I think this is because they are on "outdated" lines. That's kind of annoying.

I'm afraid I don't understand. What do you want me to import?

I was trying to continue a thread that started in #8214 (comment) . These methods were moved from synthDriverHandler . Rather than put them in driverHandler it actually looks like they don't need to be class variables. I think I got confused when I referred to the import, ignore that part. Again, splitting this up might be work that could happen another time. Overall, I'm trying to reduce the size and complexity of modules in NVDA.

@feerrenrut

Copy link
Copy Markdown
Contributor

I've had another look at this project ans stumbled upon some issues

Could you first explain what these issues were?

@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

I've had another look at this project ans stumbled upon some issues

Could you first explain what these issues were?

Sure.

As for point 1, the issue popped up when using a handy tech display which supports the braille input setting. This driver contains a script to toggle braille input. However, when changing the state of the parameter using the script, the new state was never saved in the configuration. This is now solved by saving settings on terminating and on pre-saving configuration.

I also mentioned the issue related to config profile switches above. My second point wasn't strictly spoken because of an issue, but to avoid duplicated code, especially when the vision framework is also going to use the driverHandler.

@feerrenrut

Copy link
Copy Markdown
Contributor

If you are happy with the testing on this, can you merge in master? I'll look to merge this tomorrow.

@LeonarddeR

LeonarddeR commented May 13, 2019 via email

Copy link
Copy Markdown
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BabbageWork Pull requests filed on behalf of Babbage B.V. component/NVDA-GUI component/speech-synth-drivers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow braille display specific settings in the GUI

5 participants