diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index c7e0a279..7e01f1dd 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -116,6 +116,12 @@ KEY_FENRIR,KEY_CTRL,KEY_SHIFT,KEY_X=remove_marks KEY_FENRIR,KEY_X=set_mark KEY_FENRIR,KEY_SHIFT,KEY_X=marked_text KEY_FENRIR,KEY_F10=toggle_vmenu_mode +#=current_quick_menu_entry +#=current_quick_menu_value +#=next_quick_menu_entry +#=next_quick_menu_value +#=prev_quick_menu_entry +#=prev_quick_menu_value # linux specific KEY_FENRIR,KEY_F7=import_clipboard_from_x KEY_FENRIR,KEY_F8=export_clipboard_to_x diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 57bc2210..772a098b 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -116,6 +116,12 @@ KEY_FENRIR,KEY_CTRL,KEY_SHIFT,KEY_X=remove_marks KEY_FENRIR,KEY_X=set_mark KEY_FENRIR,KEY_SHIFT,KEY_X=marked_text KEY_FENRIR,KEY_F10=toggle_vmenu_mode +#=current_quick_menu_entry +#=current_quick_menu_value +#=next_quick_menu_entry +#=next_quick_menu_value +#=prev_quick_menu_entry +#=prev_quick_menu_value # linux specific KEY_FENRIR,KEY_F7=import_clipboard_from_x KEY_FENRIR,KEY_F8=export_clipboard_to_x diff --git a/config/keyboard/nvda-desktop.conf b/config/keyboard/nvda-desktop.conf index 38b4fad3..d30cf5f0 100644 --- a/config/keyboard/nvda-desktop.conf +++ b/config/keyboard/nvda-desktop.conf @@ -120,6 +120,12 @@ KEY_FENRIR,KEY_CTRL,KEY_SHIFT,KEY_X=remove_marks KEY_FENRIR,KEY_F9=set_mark KEY_FENRIR,KEY_F10=marked_text KEY_FENRIR,KEY_F10=toggle_vmenu_mode +#=current_quick_menu_entry +#=current_quick_menu_value +#=next_quick_menu_entry +#=next_quick_menu_value +#=prev_quick_menu_entry +#=prev_quick_menu_value # linux specific #=import_clipboard_from_x KEY_FENRIR,KEY_F8=export_clipboard_to_x diff --git a/config/keyboard/nvda-laptop.conf b/config/keyboard/nvda-laptop.conf index 515d4133..fb76c318 100644 --- a/config/keyboard/nvda-laptop.conf +++ b/config/keyboard/nvda-laptop.conf @@ -120,6 +120,12 @@ KEY_FENRIR,KEY_CTRL,KEY_SHIFT,KEY_X=remove_marks KEY_FENRIR,KEY_F9=set_mark KEY_FENRIR,KEY_F10=marked_text KEY_FENRIR,KEY_SHIFT,KEY_F10=toggle_vmenu_mode +#=current_quick_menu_entry +#=current_quick_menu_value +#=next_quick_menu_entry +#=next_quick_menu_value +#=prev_quick_menu_entry +#=prev_quick_menu_value # linux specific #=import_clipboard_from_x KEY_FENRIR,KEY_F8=export_clipboard_to_x diff --git a/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_entry.py b/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_entry.py new file mode 100644 index 00000000..19a264f8 --- /dev/null +++ b/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_entry.py @@ -0,0 +1,26 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from fenrirscreenreader.core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return _('get current quick menu entry') + def run(self): + menu = '' + value = '' + menu = self.env['runtime']['quickMenuManager'].getCurrentEntry() + if menu != '': + value = self.env['runtime']['quickMenuManager'].getCurrentValue() + self.env['runtime']['outputManager'].presentText(menu + ' ' + value, interrupt=True) + def setCallback(self, callback): + pass diff --git a/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_value.py b/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_value.py new file mode 100644 index 00000000..440d76fb --- /dev/null +++ b/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_value.py @@ -0,0 +1,22 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from fenrirscreenreader.core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return _('get current quick menu value') + def run(self): + value = self.env['runtime']['quickMenuManager'].getCurrentValue() + self.env['runtime']['outputManager'].presentText(value, interrupt=True) + def setCallback(self, callback): + pass diff --git a/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_entry.py b/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_entry.py new file mode 100644 index 00000000..bd5490b0 --- /dev/null +++ b/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_entry.py @@ -0,0 +1,29 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from fenrirscreenreader.core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return _('get next quick menu entry') + def run(self): + menu = '' + value = '' + if self.env['runtime']['quickMenuManager'].nextEntry(): + menu = self.env['runtime']['quickMenuManager'].getCurrentEntry() + if menu != '': + value = self.env['runtime']['quickMenuManager'].getCurrentValue() + self.env['runtime']['outputManager'].presentText(menu + ' ' + value, interrupt=True) + else: + self.env['runtime']['outputManager'].presentText(_('Quick menu not available'), interrupt=True) + def setCallback(self, callback): + pass diff --git a/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_value.py b/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_value.py new file mode 100644 index 00000000..152eb675 --- /dev/null +++ b/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_value.py @@ -0,0 +1,25 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from fenrirscreenreader.core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return _('get next quick menu value') + def run(self): + if self.env['runtime']['quickMenuManager'].nextValue(): + value = self.env['runtime']['quickMenuManager'].getCurrentValue() + self.env['runtime']['outputManager'].presentText(value, interrupt=True) + def setCallback(self, callback): + pass + def setCallback(self, callback): + pass diff --git a/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_entry.py b/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_entry.py new file mode 100644 index 00000000..fa93d8b0 --- /dev/null +++ b/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_entry.py @@ -0,0 +1,29 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from fenrirscreenreader.core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return _('get previous quick menu entry') + def run(self): + menu = '' + value = '' + if self.env['runtime']['quickMenuManager'].prevEntry(): + menu = self.env['runtime']['quickMenuManager'].getCurrentEntry() + if menu != '': + value = self.env['runtime']['quickMenuManager'].getCurrentValue() + self.env['runtime']['outputManager'].presentText(menu + ' ' + value, interrupt=True) + else: + self.env['runtime']['outputManager'].presentText(_('Quick menu not available'), interrupt=True) + def setCallback(self, callback): + pass diff --git a/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_value.py b/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_value.py new file mode 100644 index 00000000..6546cf20 --- /dev/null +++ b/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_value.py @@ -0,0 +1,23 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from fenrirscreenreader.core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return _('get previous quick menu value') + def run(self): + if self.env['runtime']['quickMenuManager'].prevValue(): + value = self.env['runtime']['quickMenuManager'].getCurrentValue() + self.env['runtime']['outputManager'].presentText(value, interrupt=True) + def setCallback(self, callback): + pass diff --git a/src/fenrirscreenreader/core/quickMenuManager.py b/src/fenrirscreenreader/core/quickMenuManager.py index c29dac3f..d8d29683 100644 --- a/src/fenrirscreenreader/core/quickMenuManager.py +++ b/src/fenrirscreenreader/core/quickMenuManager.py @@ -8,9 +8,98 @@ from fenrirscreenreader.core import debug class quickMenuManager(): def __init__(self): - pass + self.position = 0 + self.quickMenu = [] def initialize(self, environment): - self.env = environment + self.env = environment + self.loadMenu(self.env['runtime']['settingsManager'].getSetting('menu', 'quickMenu')) def shutdown(self): - pass + pass + def loadMenu(self, menuString): + self.position = 0 + self.quickMenu = [] + if menuString == '': + return + entrys = menuString.split(';') + for e in entrys: + entry = e.split('#') + if len(entry) != 2: + continue + self.quickMenu.append({'section': entry[0], 'setting': entry[1]}) + def nextEntry(self): + if len(self.quickMenu) == 0: + return False + self.position += 1 + if self.position >= len(self.quickMenu): + self.position = 0 + return True + def prevEntry(self): + if len(self.quickMenu) == 0: + return False + self.position -= 1 + if self.position < 0: + self.position = len(self.quickMenu) - 1 + return True + def nextValue(self): + if len(self.quickMenu) == 0: + return False + try: + valueString = self.env['runtime']['settingsManager'].getSetting(self.quickMenu[self.position]['section'], self.quickMenu[self.position]['setting']) + except: + return False + # bool + if valueString.upper() in ['TRUE', 'FALSE']: + value = valueString.upper() == 'TRUE' + value = not value + self.env['runtime']['settingsManager'].setSettingAsBool(self.quickMenu[self.position]['section'], self.quickMenu[self.position]['setting'], value) + return True + # float + try: + value = float(valueString) + value += 0.05 + if value > 1.0: + value = 1.0 + self.env['runtime']['settingsManager'].setSettingAsFloat(self.quickMenu[self.position]['section'], self.quickMenu[self.position]['setting'], value) + return True + except: + pass + return True + def prevValue(self): + if len(self.quickMenu) == 0: + return False + try: + valueString = self.env['runtime']['settingsManager'].getSetting(self.quickMenu[self.position]['section'], self.quickMenu[self.position]['setting']) + except: + return False + # bool + if valueString.upper() in ['TRUE', 'FALSE']: + value = valueString.upper() == 'TRUE' + value = not value + self.env['runtime']['settingsManager'].setSettingAsBool(self.quickMenu[self.position]['section'], self.quickMenu[self.position]['setting'], value) + return True + # float + try: + value = float(valueString) + value -= 0.05 + if value < 0.0: + value = 0 + self.env['runtime']['settingsManager'].setSettingAsFloat(self.quickMenu[self.position]['section'], self.quickMenu[self.position]['setting'], value) + return True + except: + pass + return True + def getCurrentEntry(self): + if len(self.quickMenu) == 0: + return '' + try: + return _(self.quickMenu[self.position]['section']) + ' ' + _(self.quickMenu[self.position]['setting']) + except: + return _('setting invalid') + def getCurrentValue(self): + if len(self.quickMenu) == 0: + return '' + try: + return self.env['runtime']['settingsManager'].getSetting(self.quickMenu[self.position]['section'], self.quickMenu[self.position]['setting']) + except: + return _('setting value invalid')