def onOk(self, evt):
     if self.skipEmptyParagraphBox.IsChecked(
     ) != _addonConfigManager.toggleSkipEmptyParagraphsOption(False):
         _addonConfigManager.toggleSkipEmptyParagraphsOption()
     if self.playSoundOnSkippedParagraphBox.IsChecked(
     ) != _addonConfigManager.togglePlaySoundOnSkippedParagraphOption(
             False):
         _addonConfigManager.togglePlaySoundOnSkippedParagraphOption()
     super(WordAddonSettingsDialog, self).onOk(evt)
Пример #2
0
 def saveSettingChanges(self):
     if self.skipEmptyParagraphBox.IsChecked(
     ) != _addonConfigManager.toggleSkipEmptyParagraphsOption(False):
         _addonConfigManager.toggleSkipEmptyParagraphsOption()
     if self.playSoundOnSkippedParagraphBox.IsChecked(
     ) != _addonConfigManager.togglePlaySoundOnSkippedParagraphOption(
             False):
         _addonConfigManager.togglePlaySoundOnSkippedParagraphOption()
     if self.autoCheckForUpdatesCheckBox.IsChecked(
     ) != _addonConfigManager.toggleAutoUpdateCheck(False):
         _addonConfigManager.toggleAutoUpdateCheck(True)
     if self.updateReleaseVersionsToDevVersionsCheckBox.IsChecked(
     ) != _addonConfigManager.toggleUpdateReleaseVersionsToDevVersions(
             False):
         _addonConfigManager.toggleUpdateReleaseVersionsToDevVersions(True)
 def script_toggleSkipEmptyParagraphsOption(self, gesture):
     if _addonConfigManager.toggleSkipEmptyParagraphsOption():
         # Translators: message to report skipping of empty paragraph when moving by paragraph.
         speech.speakMessage(_("Skip empty paragraphs"))
     else:
         # Translators: message to report no skipping empty paragraph when moving by paragraph.
         speech.speakMessage(_("Don't skip empty paragraphs"))
Пример #4
0
 def saveSettingChanges(self):
     if self.skipEmptyParagraphBox.IsChecked(
     ) != _addonConfigManager.toggleSkipEmptyParagraphsOption(
             False):  # noqa:E501
         _addonConfigManager.toggleSkipEmptyParagraphsOption()
     if self.playSoundOnSkippedParagraphBox.IsChecked(
     ) != _addonConfigManager.togglePlaySoundOnSkippedParagraphOption(
             False):  # noqa:E501
         _addonConfigManager.togglePlaySoundOnSkippedParagraphOption()
     if self.automaticReadingCheckBox.IsChecked(
     ) != _addonConfigManager.toggleAutomaticReadingOption(
             False):  # noqa:E501
         _addonConfigManager.toggleAutomaticReadingOption()
     if self.objectsToReadCheckListBox.IsChecked(
             self.objectsToRead.index("comment")
     ) != _addonConfigManager.toggleAutoCommentReadingOption(
             False):  # noqa:E501
         _addonConfigManager.toggleAutoCommentReadingOption()
     if self.objectsToReadCheckListBox.IsChecked(
             self.objectsToRead.index("footnote")
     ) != _addonConfigManager.toggleAutoFootnoteReadingOption(
             False):  # noqa:E501
         _addonConfigManager.toggleAutoFootnoteReadingOption()
     if self.objectsToReadCheckListBox.IsChecked(
             self.objectsToRead.index("endnote")
     ) != _addonConfigManager.toggleAutoEndnoteReadingOption(
             False):  # noqa:E501
         _addonConfigManager.toggleAutoEndnoteReadingOption()
     _addonConfigManager.setAutoReadingWithOption(
         self.autoReadingWithChoiceBox.GetSelection())
     elementsSearchMaxTime = int(
         self.elementsSearchMaxTimeListBox.GetString(
             self.elementsSearchMaxTimeListBox.GetSelection()))
     if self.objectsToReadCheckListBox.IsChecked(
             self.objectsToRead.index("endnote")
     ) != _addonConfigManager.toggleAutoEndnoteReadingOption(
             False):  # noqa:E501
         _addonConfigManager.setElementsSearchMaxTime(elementsSearchMaxTime)
     if self.loopInNavigationModeOptionBox.IsChecked(
     ) != _addonConfigManager.toggleLoopInNavigationModeOption(False):
         _addonConfigManager.toggleLoopInNavigationModeOption()
    def makeSettings(self, settingsSizer):

        sHelper = gui.guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
        self.skipEmptyParagraphBox = sHelper.addItem(
            wx.CheckBox(self, wx.ID_ANY, label=_("&Skip empty paragraph")))
        self.skipEmptyParagraphBox.SetValue(
            _addonConfigManager.toggleSkipEmptyParagraphsOption(False))
        self.playSoundOnSkippedParagraphBox = sHelper.addItem(
            wx.CheckBox(self,
                        wx.ID_ANY,
                        label=_("&Play sound when paragraph is skipped")))
        self.playSoundOnSkippedParagraphBox.SetValue(
            _addonConfigManager.togglePlaySoundOnSkippedParagraphOption(False))
    def _moveToNextOrPriorElement(self, direction, type="paragraph"):
        def move(wdUnit, direction):
            info = self.makeTextInfo(textInfos.POSITION_CARET)
            if not info:
                return
            # #4375: can't use self.move here as it may check document.chracters.count which can take for ever on large documents.
            info._rangeObj.move(wdUnit, direction)
            info.updateCaret()

        stopScriptTimer()
        res = self._getPageAndLineNumber()
        if not res:
            # no document or not in text
            return
        if res == (1, 1) and direction == -1:
            # top of document
            return
        if type == "paragraph":
            unit = textInfos.UNIT_PARAGRAPH
            wdUnit = wdParagraph
        else:
            unit = textInfos.UNIT_SENTENCE
            wdUnit = wdSentence
        move(wdUnit, direction)
        option = _addonConfigManager.toggleSkipEmptyParagraphsOption(False)
        if type != "paragraph" or not option:
            return
        # we skip a maximum  of empty paragraph
        i = 100
        playSound = False
        while i:
            i = i - 1
            res = self._getPageAndLineNumber()
            if not res:
                return
            if res == (1, 1):
                return
            try:
                info = self.makeTextInfo(textInfos.POSITION_CARET)
            except:
                return
            info.expand(unit)
            text = info.text.strip()
            info.collapse()
            if len(text) != 0:
                if playSound:
                    self.playSoundOnSkippedParagraph()
                return
            move(wdUnit, direction)
            playSound = True
Пример #7
0
    def makeSettings(self, settingsSizer):

        sHelper = gui.guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
        # Translators: This is the label for a checkbox in the settings panel.
        self.skipEmptyParagraphBox = sHelper.addItem(
            wx.CheckBox(self, wx.ID_ANY, label=_("&Skip empty paragraph")))
        self.skipEmptyParagraphBox.SetValue(
            _addonConfigManager.toggleSkipEmptyParagraphsOption(False))
        # Translators: This is the label for a checkbox in the settings panel.
        self.playSoundOnSkippedParagraphBox = sHelper.addItem(
            wx.CheckBox(self,
                        wx.ID_ANY,
                        label=_("&Play sound when paragraph is skipped")))
        self.playSoundOnSkippedParagraphBox.SetValue(
            _addonConfigManager.togglePlaySoundOnSkippedParagraphOption(False))
        # Translators: This is the label for a group of editing options in the settings panel.
        groupText = _("Update")
        group = gui.guiHelper.BoxSizerHelper(self,
                                             sizer=wx.StaticBoxSizer(
                                                 wx.StaticBox(self,
                                                              label=groupText),
                                                 wx.VERTICAL))
        sHelper.addItem(group)
        # Translators: This is the label for a checkbox in the settings panel.
        labelText = _("Automatically check for &updates ")
        self.autoCheckForUpdatesCheckBox = group.addItem(
            wx.CheckBox(self, wx.ID_ANY, label=labelText))
        self.autoCheckForUpdatesCheckBox.SetValue(
            _addonConfigManager.toggleAutoUpdateCheck(False))
        # Translators: This is the label for a checkbox in the settings panel.
        labelText = _(
            "Update also release versions to &developpement versions")
        self.updateReleaseVersionsToDevVersionsCheckBox = group.addItem(
            wx.CheckBox(self, wx.ID_ANY, label=labelText))
        self.updateReleaseVersionsToDevVersionsCheckBox.SetValue(
            _addonConfigManager.toggleUpdateReleaseVersionsToDevVersions(
                False))
        # Translators: This is the label for a button in the settings panel.
        labelText = _("&Check for update")
        checkForUpdateButton = wx.Button(self, label=labelText)
        group.addItem(checkForUpdateButton)
        checkForUpdateButton.Bind(wx.EVT_BUTTON, self.onCheckForUpdate)
Пример #8
0
    def makeSettings(self, settingsSizer):

        sHelper = gui.guiHelper.BoxSizerHelper(self, sizer=settingsSizer)
        # Translators: This is the label for a group of editing options
        # in the settings panel.
        groupText = _("Paragraph")
        group = gui.guiHelper.BoxSizerHelper(self,
                                             sizer=wx.StaticBoxSizer(
                                                 wx.StaticBox(self,
                                                              label=groupText),
                                                 wx.VERTICAL))
        sHelper.addItem(group)
        # Translators: This is the label for a checkbox in the settings panel.
        labelText = _("&Skip empty paragraphs")
        self.skipEmptyParagraphBox = group.addItem(
            wx.CheckBox(self, wx.ID_ANY, label=labelText))
        self.skipEmptyParagraphBox.SetValue(
            _addonConfigManager.toggleSkipEmptyParagraphsOption(False))
        # Translators: This is the label for a checkbox in the settings panel.
        labelText = _("&Play sound when paragraph is skipped")
        self.playSoundOnSkippedParagraphBox = group.addItem(
            wx.CheckBox(self, wx.ID_ANY, label=labelText))
        self.playSoundOnSkippedParagraphBox.SetValue(
            _addonConfigManager.togglePlaySoundOnSkippedParagraphOption(False))
        # Translators: This is the label for a group of editing options
        # in the settings panel.
        groupText = _("Automatic reading")
        group = gui.guiHelper.BoxSizerHelper(self,
                                             sizer=wx.StaticBoxSizer(
                                                 wx.StaticBox(self,
                                                              label=groupText),
                                                 wx.VERTICAL))
        sHelper.addItem(group)
        # Translators: This is the label for a checkbox in the settings panel.
        labelText = _("&Activate automatic reading")
        self.automaticReadingCheckBox = group.addItem(
            wx.CheckBox(self, wx.ID_ANY, label=labelText))
        self.automaticReadingCheckBox.SetValue(
            _addonConfigManager.toggleAutomaticReadingOption(False))
        #Translators: This is the label for a list of checkboxes
        # controlling which  object are automatically reading.
        labelText = _("Concerned elements:")
        choice = [self.objectsToReadLabels[x] for x in self.objectsToRead]
        self.objectsToReadCheckListBox = sHelper.addLabeledControl(
            labelText, nvdaControls.CustomCheckListBox, choices=choice)
        checkedItems = []
        if _addonConfigManager.toggleAutoCommentReadingOption(False):
            checkedItems.append(self.objectsToRead.index("comment"))
        if _addonConfigManager.toggleAutoFootnoteReadingOption(False):
            checkedItems.append(self.objectsToRead.index("footnote"))
        if _addonConfigManager.toggleAutoEndnoteReadingOption(False):
            checkedItems.append(self.objectsToRead.index("endnote"))
        self.objectsToReadCheckListBox.CheckedItems = checkedItems
        self.objectsToReadCheckListBox.Select(0)
        """
		# Translators: This is the label for a checkbox in the settings panel.
		labelText = _("&Comments")
		self.autoCommentReadingCheckBox = group.addItem(
			wx.CheckBox(self, wx.ID_ANY, label=labelText))
		self.autoCommentReadingCheckBox.SetValue(
			_addonConfigManager.toggleAutoCommentReadingOption(False))
		# Translators: This is the label for a checkbox in the settings panel.
		labelText = _("&Footnotes")
		self.automaticNoteReadingCheckBox = group.addItem(
			wx.CheckBox(self, wx.ID_ANY, label=labelText))
		self.automaticNoteReadingCheckBox.SetValue(
			_addonConfigManager.toggleAutoFootnoteReadingOption(False))
		"""
        # Translators: This is the label for a checkbox in the settings panel.
        labelText = _("Read &with:")
        # Translators: choice labelsfor automatic reading.
        choice = [
            _("nothing"),
            _("a beep at start and end"),
            _("another voice")
        ]
        self.autoReadingWithChoiceBox = group.addLabeledControl(labelText,
                                                                wx.Choice,
                                                                choices=choice)
        self.autoReadingWithChoiceBox.SetSelection(
            _addonConfigManager.getAutoReadingWithOption())
        # translators: label for a button in Options settings panel.
        labelText = _("&Display voice's recorded setting")
        voiceInformationsButton = wx.Button(self, label=labelText)
        group.addItem(voiceInformationsButton)
        voiceInformationsButton.Bind(wx.EVT_BUTTON,
                                     self.onVoiceInformationButton)
        from versionInfo import version_year, version_major
        if [version_year, version_major] < [2019, 3]:
            # automatic reading is not available for nvda version less than nvda 2019.3
            for item in range(0, group.sizer.GetItemCount()):
                group.sizer.Hide(item)
        choice = [x for x in range(5, 125, 5)]
        choice = list(reversed(choice))
        # translators: label for a list box in Options settings panel.
        labelText = _("Maximum time of elements's search (in seconds:)")
        self.elementsSearchMaxTimeListBox = sHelper.addLabeledControl(
            labelText, wx.Choice, choices=[str(x) for x in choice])
        self.elementsSearchMaxTimeListBox.SetSelection(
            choice.index(_addonConfigManager.getElementsSearchMaxTime()))
        # Translators: This is the label for a checkbox in the options settings panel.
        labelText = _("Na&vigate in loop")
        self.loopInNavigationModeOptionBox = sHelper.addItem(
            wx.CheckBox(self, wx.ID_ANY, label=labelText))
        self.loopInNavigationModeOptionBox.SetValue(
            _addonConfigManager.toggleLoopInNavigationModeOption(False))
    def _moveToNextOrPriorElement(self, direction, type="paragraph"):
        def move(wdUnit, direction, curPosition):
            info = self.makeTextInfo(textInfos.POSITION_CARET)
            if not info:
                return
            # #4375: can't use self.move here as it may check document.
            # chracters.count which can take for ever on large documents.
            info._rangeObj.move(wdUnit, direction)
            info.updateCaret()
            position = self._getPosition()
            return position

        stopScriptTimer()
        position = self._getPosition()
        if not position:
            # no document or not in text
            return False
        if type == "paragraph":
            unit = textInfos.UNIT_PARAGRAPH
            wdUnit = wdParagraph
            msgNoOther = _("No other paragraph")
        else:
            unit = textInfos.UNIT_SENTENCE
            wdUnit = wdSentence
            msgNoOther = _("No other sentence")
            doc = self.WinwordDocumentObject
            selection = self.WinwordSelectionObject
            start = selection.Start
            end = doc.storyRanges[1].End
            r = doc.range(start, end)
            sentences = r.Sentences
            if direction == 1 and sentences.Count == 1:
                speech.speakMessage(_("No other sentence"))
                return False
        oldPosition = position
        position = move(wdUnit, direction, position)
        if position == oldPosition:
            speech.speakMessage(msgNoOther)
            return False
        option = _addonConfigManager.toggleSkipEmptyParagraphsOption(False)
        if type != "paragraph" or not option:
            return True
        # we skip a maximum of empty paragraph
        i = 100
        playSound = False
        while i:
            i = i - 1
            try:
                info = self.makeTextInfo(textInfos.POSITION_CARET)
            except:  # noqa:E722
                return False
            info.expand(unit)
            text = info.text.strip()
            info.collapse()
            if len(text) != 0:
                if playSound:
                    self.playSoundOnSkippedParagraph()
                return True
# move to next paragraph
            oldPosition = position
            position = move(wdUnit, direction, position)
            if not position or position == oldPosition:
                speech.speakMessage(msgNoOther)
                if playSound:
                    self.playSoundOnSkippedParagraph()
                return False
            playSound = True