Esempio n. 1
0
 def config_update(self):
     """
     Called when Config is changed to restart the server on new address or port
     """
     log.debug('remote config changed')
     self.main_window.information_message(translate('RemotePlugin', 'Configuration Change'),
         translate('RemotePlugin', 'OpenLP will need to be restarted for the Remote changes to become active.'))
 def retranslateUi(self, custom_slide_edit_dialog):
     custom_slide_edit_dialog.setWindowTitle(translate('CustomPlugin.EditVerseForm', 'Edit Slide'))
     self.split_button.setText(UiStrings().Split)
     self.split_button.setToolTip(UiStrings().SplitToolTip)
     self.insert_button.setText(translate('CustomPlugin.EditCustomForm', 'Insert Slide'))
     self.insert_button.setToolTip(translate('CustomPlugin.EditCustomForm',
         'Split a slide into two by inserting a slide splitter.'))
Esempio n. 3
0
 def load(self):
     """
     Load the plugin details into the screen
     """
     self.pluginListWidget.clear()
     self.programaticChange = True
     self._clearDetails()
     self.programaticChange = True
     pluginListWidth = 0
     for plugin in self.plugin_manager.plugins:
         item = QtGui.QListWidgetItem(self.pluginListWidget)
         # We do this just to make 100% sure the status is an integer as
         # sometimes when it's loaded from the config, it isn't cast to int.
         plugin.status = int(plugin.status)
         # Set the little status text in brackets next to the plugin name.
         if plugin.status == PluginStatus.Disabled:
             status_text = translate('OpenLP.PluginForm', '%s (Disabled)')
         elif plugin.status == PluginStatus.Active:
             status_text = translate('OpenLP.PluginForm', '%s (Active)')
         else:
             # PluginStatus.Inactive
             status_text = translate('OpenLP.PluginForm', '%s (Inactive)')
         item.setText(status_text % plugin.nameStrings[u'singular'])
         # If the plugin has an icon, set it!
         if plugin.icon:
             item.setIcon(plugin.icon)
         self.pluginListWidget.addItem(item)
         pluginListWidth = max(pluginListWidth, self.fontMetrics().width(
             translate('OpenLP.PluginForm', '%s (Inactive)') % plugin.nameStrings[u'singular']))
     self.pluginListWidget.setFixedWidth(pluginListWidth + self.pluginListWidget.iconSize().width() + 48)
Esempio n. 4
0
 def retranslateUi(self, media_files_dialog):
     """
     Translate the UI on the fly.
     """
     media_files_dialog.setWindowTitle(translate('SongsPlugin.MediaFilesForm', 'Select Media File(s)'))
     self.select_label.setText(translate('SongsPlugin.MediaFilesForm',
         'Select one or more audio files from the list below, and click OK to import them into this song.'))
Esempio n. 5
0
 def retranslateUi(self, language_dialog):
     language_dialog.setWindowTitle(translate('BiblesPlugin.LanguageDialog', 'Select Language'))
     self.bible_label.setText(translate('BiblesPlugin.LanguageDialog', ''))
     self.info_label.setText(translate('BiblesPlugin.LanguageDialog',
         'OpenLP is unable to determine the language of this translation of the Bible. Please select the language '
         'from the list below.'))
     self.language_label.setText(translate('BiblesPlugin.LanguageDialog', 'Language:'))
Esempio n. 6
0
 def accept(self):
     """
     Override the QDialog's accept() method to do some validation before the dialog can be closed.
     """
     if not self.first_name_edit.text():
         critical_error_message_box(
             message=translate('SongsPlugin.AuthorsForm', 'You need to type in the first name of the author.'))
         self.first_name_edit.setFocus()
         return False
     elif not self.last_name_edit.text():
         critical_error_message_box(
             message=translate('SongsPlugin.AuthorsForm', 'You need to type in the last name of the author.'))
         self.last_name_edit.setFocus()
         return False
     elif not self.display_edit.text():
         if critical_error_message_box(
             message=translate('SongsPlugin.AuthorsForm',
                               'You have not set a display name for the author, combine the first and last names?'),
                 parent=self, question=True) == QtWidgets.QMessageBox.Yes:
             self.display_edit.setText(self.first_name_edit.text() + ' ' + self.last_name_edit.text())
             return QtWidgets.QDialog.accept(self)
         else:
             self.display_edit.setFocus()
             return False
     else:
         return QtWidgets.QDialog.accept(self)
Esempio n. 7
0
 def retranslateUi(self, edit_verse_dialog):
     edit_verse_dialog.setWindowTitle(
         translate('SongsPlugin.EditVerseChordsForm',
                   'Edit Verse and Chords'))
     self.chord_hint_label.setText(
         translate(
             'SongsPlugin.EditVerseChordsForm',
             'Chord lines must finish with an @ and be put on the line above the corresponding lyrics.\nTo pad out lyrics to fit the chords use the # symbol.'
         ))
     self.verse_type_label.setText(
         translate('SongsPlugin.EditVerseChordsForm', '&Verse type:'))
     self.verse_type_combo_box.setItemText(
         VerseType.Verse, VerseType.translated_names[VerseType.Verse])
     self.verse_type_combo_box.setItemText(
         VerseType.Chorus, VerseType.translated_names[VerseType.Chorus])
     self.verse_type_combo_box.setItemText(
         VerseType.Bridge, VerseType.translated_names[VerseType.Bridge])
     self.verse_type_combo_box.setItemText(
         VerseType.PreChorus,
         VerseType.translated_names[VerseType.PreChorus])
     self.verse_type_combo_box.setItemText(
         VerseType.Intro, VerseType.translated_names[VerseType.Intro])
     self.verse_type_combo_box.setItemText(
         VerseType.Ending, VerseType.translated_names[VerseType.Ending])
     self.verse_type_combo_box.setItemText(
         VerseType.Other, VerseType.translated_names[VerseType.Other])
     self.split_button.setText(UiStrings().Split)
     self.split_button.setToolTip(UiStrings().SplitToolTip)
     self.force_split_button.setText(UiStrings().ForcedSplit)
     self.force_split_button.setToolTip(UiStrings().ForcedSplitToolTip)
     self.insert_button.setText(
         translate('SongsPlugin.EditVerseChordsForm', '&Insert'))
     self.insert_button.setToolTip(
         translate('SongsPlugin.EditVerseChordsForm',
                   'Split a slide into two by inserting a verse splitter.'))
Esempio n. 8
0
 def check_data_overwrite(self, data_path ):
     """
     Check if there's already data in the target directory.
     """
     test_path = os.path.join(data_path, 'songs')
     self.data_directory_copy_check_box.show()
     if os.path.exists(test_path):
         self.data_exists = True
         # Check is they want to replace existing data.
         answer = QtGui.QMessageBox.warning(self,
             translate('OpenLP.AdvancedTab', 'Overwrite Existing Data'),
             translate('OpenLP.AdvancedTab', 'WARNING: \n\nThe location you have selected \n\n%s\n\n'
             'appears to contain OpenLP data files. Do you wish to replace these files with the current data files?'
             ).replace('%s', os.path.abspath(data_path,)),
             QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No)
         if answer == QtGui.QMessageBox.Yes:
             self.data_directory_copy_check_box.setChecked(True)
             self.new_data_directory_has_files_label.show()
         else:
             self.data_directory_copy_check_box.setChecked(False)
             self.new_data_directory_has_files_label.hide()
     else:
         self.data_exists = False
         self.data_directory_copy_check_box.setChecked(True)
         self.new_data_directory_has_files_label.hide()
Esempio n. 9
0
 def retranslateUi(self):
     log.debug('retranslateUi')
     self.quickSearchLabel.setText(translate('BiblesPlugin.MediaItem', 'Find:'))
     self.quickVersionLabel.setText('%s:' % UiStrings().Version)
     self.quickSecondLabel.setText(translate('BiblesPlugin.MediaItem', 'Second:'))
     self.quickStyleLabel.setText(UiStrings().LayoutStyle)
     self.quickStyleComboBox.setItemText(LayoutStyle.VersePerSlide, UiStrings().VersePerSlide)
     self.quickStyleComboBox.setItemText(LayoutStyle.VersePerLine, UiStrings().VersePerLine)
     self.quickStyleComboBox.setItemText(LayoutStyle.Continuous, UiStrings().Continuous)
     self.quickLockButton.setToolTip(translate('BiblesPlugin.MediaItem',
         'Toggle to keep or clear the previous results.'))
     self.quickSearchButton.setText(UiStrings().Search)
     self.advancedBookLabel.setText(translate('BiblesPlugin.MediaItem', 'Book:'))
     self.advancedChapterLabel.setText(translate('BiblesPlugin.MediaItem', 'Chapter:'))
     self.advancedVerseLabel.setText(translate('BiblesPlugin.MediaItem', 'Verse:'))
     self.advancedFromLabel.setText(translate('BiblesPlugin.MediaItem', 'From:'))
     self.advancedToLabel.setText(translate('BiblesPlugin.MediaItem', 'To:'))
     self.advancedVersionLabel.setText('%s:' % UiStrings().Version)
     self.advancedSecondLabel.setText(translate('BiblesPlugin.MediaItem', 'Second:'))
     self.advancedStyleLabel.setText(UiStrings().LayoutStyle)
     self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerSlide, UiStrings().VersePerSlide)
     self.advancedStyleComboBox.setItemText(LayoutStyle.VersePerLine, UiStrings().VersePerLine)
     self.advancedStyleComboBox.setItemText(LayoutStyle.Continuous, UiStrings().Continuous)
     self.advancedLockButton.setToolTip(translate('BiblesPlugin.MediaItem',
         'Toggle to keep or clear the previous results.'))
     self.advancedSearchButton.setText(UiStrings().Search)
Esempio n. 10
0
 def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False,
         context=ServiceItemContext.Live):
     """
     Generate the slide data. Needs to be implemented by the plugin.
     """
     if item is None:
         item = self.list_view.currentItem()
         if item is None:
             return False
     filename = item.data(QtCore.Qt.UserRole)
     if not os.path.exists(filename):
         if not remote:
             # File is no longer present
             critical_error_message_box(
                 translate('MediaPlugin.MediaItem', 'Missing Media File'),
                 translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename)
         return False
     (path, name) = os.path.split(filename)
     service_item.title = name
     service_item.processor = self.display_type_combo_box.currentText()
     service_item.add_from_command(path, name, CLAPPERBOARD)
     # Only get start and end times if going to a service
     if context == ServiceItemContext.Service:
         # Start media and obtain the length
         if not self.media_controller.media_length(service_item):
             return False
     service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
     service_item.add_capability(ItemCapabilities.CanEditTitle)
     service_item.add_capability(ItemCapabilities.RequiresMedia)
     if Settings().value(self.settings_section + '/media auto start') == QtCore.Qt.Checked:
         service_item.will_auto_start = True
         # force a non-existent theme
     service_item.theme = -1
     return True
Esempio n. 11
0
 def on_topic_add_button_clicked(self):
     item = int(self.topicsComboBox.currentIndex())
     text = self.topicsComboBox.currentText()
     if item == 0 and text:
         if QtGui.QMessageBox.question(self, translate('SongsPlugin.EditSongForm', 'Add Topic'),
                 translate('SongsPlugin.EditSongForm', 'This topic does not exist, do you want to add it?'),
                 QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
             topic = Topic.populate(name=text)
             self.manager.save_object(topic)
             topic_item = QtGui.QListWidgetItem(str(topic.name))
             topic_item.setData(QtCore.Qt.UserRole, topic.id)
             self.topics_list_view.addItem(topic_item)
             self.load_topics()
             self.topicsComboBox.setCurrentIndex(0)
         else:
             return
     elif item > 0:
         item_id = (self.topicsComboBox.itemData(item))
         topic = self.manager.get_object(Topic, item_id)
         if self.topics_list_view.findItems(str(topic.name),
             QtCore.Qt.MatchExactly):
             critical_error_message_box(
                 message=translate('SongsPlugin.EditSongForm', 'This topic is already in the list.'))
         else:
             topic_item = QtGui.QListWidgetItem(str(topic.name))
             topic_item.setData(QtCore.Qt.UserRole, topic.id)
             self.topics_list_view.addItem(topic_item)
         self.topicsComboBox.setCurrentIndex(0)
     else:
         QtGui.QMessageBox.warning(self, UiStrings().NISs,
             translate('SongsPlugin.EditSongForm', 'You have not selected a valid topic. Either select a topic '
             'from the list, or type in a new topic and click the "Add Topic to Song" button to add the new topic.'))
Esempio n. 12
0
 def set_plugin_text_strings(self):
     """
     Called to define all translatable texts of the plugin
     """
     # Name PluginList
     self.text_strings[StringContent.Name] = {
         'singular': translate('BiblesPlugin', 'Bible', 'name singular'),
         'plural': translate('BiblesPlugin', 'Bibles', 'name plural')
     }
     # Name for MediaDockManager, SettingsManager
     self.text_strings[StringContent.VisibleName] = {
         'title': translate('BiblesPlugin', 'Bibles', 'container title')
     }
     # Middle Header Bar
     tooltips = {
         'load': '',
         'import': translate('BiblesPlugin', 'Import a Bible.'),
         'new': translate('BiblesPlugin', 'Add a new Bible.'),
         'edit': translate('BiblesPlugin', 'Edit the selected Bible.'),
         'delete': translate('BiblesPlugin', 'Delete the selected Bible.'),
         'preview': translate('BiblesPlugin', 'Preview the selected Bible.'),
         'live': translate('BiblesPlugin', 'Send the selected Bible live.'),
         'service': translate('BiblesPlugin', 'Add the selected Bible to the service.')
     }
     self.set_plugin_ui_text_strings(tooltips)
Esempio n. 13
0
 def retranslateUi(self, themeLayoutDialog):
     """
     Translate the UI on the fly
     """
     themeLayoutDialog.setWindowTitle(translate('OpenLP.StartTimeForm', 'Theme Layout'))
     self.mainColourLabel.setText(translate('OpenLP.StartTimeForm', 'The blue box shows the main area.'))
     self.footerColourLabel.setText(translate('OpenLP.StartTimeForm', 'The red box shows the footer.'))
Esempio n. 14
0
    def media_length(self, serviceItem):
        """
        Loads and starts a media item to obtain the media length

        ``serviceItem``
            The ServiceItem containing the details to be played.
        """
        controller = self.displayControllers[DisplayControllerType.Plugin]
        log.debug(u'media_length')
        # stop running videos
        self.media_reset(controller)
        controller.media_info = MediaInfo()
        controller.media_info.volume = 0
        controller.media_info.file_info = QtCore.QFileInfo(serviceItem.get_frame_path())
        display = controller.previewDisplay
        if not self._check_file_type(controller, display, serviceItem):
            # Media could not be loaded correctly
            critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
                translate('MediaPlugin.MediaItem', 'Unsupported File'))
            return False
        if not self.media_play(controller):
            critical_error_message_box(translate('MediaPlugin.MediaItem', 'Unsupported File'),
                translate('MediaPlugin.MediaItem', 'Unsupported File'))
            return False
        serviceItem.set_media_length(controller.media_info.length)
        self.media_stop(controller)
        log.debug(u'use %s controller' % self.currentMediaPlayer[controller.controllerType])
        return True
Esempio n. 15
0
 def retranslateUi(self, edit_verse_dialog):
     edit_verse_dialog.setWindowTitle(
         translate('SongsPlugin.EditVerseForm', 'Edit Verse'))
     self.verse_type_label.setText(
         translate('SongsPlugin.EditVerseForm', '&Verse type:'))
     self.verse_type_combo_box.setItemText(
         VerseType.Verse, VerseType.translated_names[VerseType.Verse])
     self.verse_type_combo_box.setItemText(
         VerseType.Chorus, VerseType.translated_names[VerseType.Chorus])
     self.verse_type_combo_box.setItemText(
         VerseType.Bridge, VerseType.translated_names[VerseType.Bridge])
     self.verse_type_combo_box.setItemText(
         VerseType.PreChorus,
         VerseType.translated_names[VerseType.PreChorus])
     self.verse_type_combo_box.setItemText(
         VerseType.Intro, VerseType.translated_names[VerseType.Intro])
     self.verse_type_combo_box.setItemText(
         VerseType.Ending, VerseType.translated_names[VerseType.Ending])
     self.verse_type_combo_box.setItemText(
         VerseType.Other, VerseType.translated_names[VerseType.Other])
     self.split_button.setText(UiStrings().Split)
     self.split_button.setToolTip(UiStrings().SplitToolTip)
     self.insert_button.setText(
         translate('SongsPlugin.EditVerseForm', '&Insert'))
     self.insert_button.setToolTip(
         translate('SongsPlugin.EditVerseForm',
                   'Split a slide into two by inserting a verse splitter.'))
Esempio n. 16
0
def update_reference_separators():
    """
    Updates separators and matches for parsing and formating scripture references.
    """
    default_separators = [
        '|'.join([
            translate('BiblesPlugin', ':', 'Verse identifier e.g. Genesis 1 : 1 = Genesis Chapter 1 Verse 1'),
            translate('BiblesPlugin', 'v', 'Verse identifier e.g. Genesis 1 v 1 = Genesis Chapter 1 Verse 1'),
            translate('BiblesPlugin', 'V', 'Verse identifier e.g. Genesis 1 V 1 = Genesis Chapter 1 Verse 1'),
            translate('BiblesPlugin', 'verse', 'Verse identifier e.g. Genesis 1 verse 1 = Genesis Chapter 1 Verse 1'),
            translate('BiblesPlugin', 'verses',
                      'Verse identifier e.g. Genesis 1 verses 1 - 2 = Genesis Chapter 1 Verses 1 to 2')]),
        '|'.join([
            translate('BiblesPlugin', '-',
                      'range identifier e.g. Genesis 1 verse 1 - 2 = Genesis Chapter 1 Verses 1 To 2'),
            translate('BiblesPlugin', 'to',
                      'range identifier e.g. Genesis 1 verse 1 - 2 = Genesis Chapter 1 Verses 1 To 2')]),
        '|'.join([
            translate('BiblesPlugin', ',', 'connecting identifier e.g. Genesis 1 verse 1 - 2, 4 - 5 = '
                                           'Genesis Chapter 1 Verses 1 To 2 And Verses 4 To 5'),
            translate('BiblesPlugin', 'and', 'connecting identifier e.g. Genesis 1 verse 1 - 2 and 4 - 5 = '
                                             'Genesis Chapter 1 Verses 1 To 2 And Verses 4 To 5')]),
        '|'.join([translate('BiblesPlugin', 'end', 'ending identifier e.g. Genesis 1 verse 1 - end = '
                                                   'Genesis Chapter 1 Verses 1 To The Last Verse')])]
    settings = Settings()
    settings.beginGroup('bibles')
    custom_separators = [
        settings.value('verse separator'),
        settings.value('range separator'),
        settings.value('list separator'),
        settings.value('end separator')]
    settings.endGroup()
    for index, role in enumerate(['v', 'r', 'l', 'e']):
        if custom_separators[index].strip('|') == '':
            source_string = default_separators[index].strip('|')
        else:
            source_string = custom_separators[index].strip('|')
        while '||' in source_string:
            source_string = source_string.replace('||', '|')
        if role != 'e':
            REFERENCE_SEPARATORS['sep_%s_display' % role] = source_string.split('|')[0]
        # escape reserved characters
        for character in '\\.^$*+?{}[]()':
            source_string = source_string.replace(character, '\\' + character)
        # add various unicode alternatives
        source_string = source_string.replace('-', '(?:[-\u00AD\u2010\u2011\u2012\u2014\u2014\u2212\uFE63\uFF0D])')
        source_string = source_string.replace(',', '(?:[,\u201A])')
        REFERENCE_SEPARATORS['sep_%s' % role] = '\s*(?:%s)\s*' % source_string
        REFERENCE_SEPARATORS['sep_%s_default' % role] = default_separators[index]
    # verse range match: (<chapter>:)?<verse>(-((<chapter>:)?<verse>|end)?)?
    range_regex = '(?:(?P<from_chapter>[0-9]+)%(sep_v)s)?' \
        '(?P<from_verse>[0-9]+)(?P<range_to>%(sep_r)s(?:(?:(?P<to_chapter>' \
        '[0-9]+)%(sep_v)s)?(?P<to_verse>[0-9]+)|%(sep_e)s)?)?' % REFERENCE_SEPARATORS
    REFERENCE_MATCHES['range'] = re.compile('^\s*%s\s*$' % range_regex, re.UNICODE)
    REFERENCE_MATCHES['range_separator'] = re.compile(REFERENCE_SEPARATORS['sep_l'], re.UNICODE)
    # full reference match: <book>(<range>(,(?!$)|(?=$)))+
    REFERENCE_MATCHES['full'] = \
        re.compile('^\s*(?!\s)(?P<book>[\d]*[^\d]+)(?<!\s)\s*'
                   '(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$'
                   % dict(list(REFERENCE_SEPARATORS.items()) + [('range_regex', range_regex)]), re.UNICODE)
Esempio n. 17
0
 def retranslateUi(self, song_book_dialog):
     """
     Translate the UI on the fly.
     """
     song_book_dialog.setWindowTitle(translate('SongsPlugin.SongBookForm', 'Song Book Maintenance'))
     self.name_label.setText(translate('SongsPlugin.SongBookForm', '&Name:'))
     self.publisher_label.setText(translate('SongsPlugin.SongBookForm', '&Publisher:'))
Esempio n. 18
0
 def do_import(self):
     if not isinstance(self.import_source, list):
         return
     try:
         self.start_ooo()
     except NoConnectException as exc:
         self.log_error(
             self.import_source[0],
             translate('SongsPlugin.SongImport', 'Cannot access OpenOffice or LibreOffice'))
         log.error(exc)
         return
     self.import_wizard.progress_bar.setMaximum(len(self.import_source))
     for filename in self.import_source:
         if self.stop_import_flag:
             break
         filename = str(filename)
         if os.path.isfile(filename):
             self.open_ooo_file(filename)
             if self.document:
                 self.process_ooo_document()
                 self.close_ooo_file()
             else:
                 self.log_error(self.file_path, translate('SongsPlugin.SongImport', 'Unable to open file'))
         else:
             self.log_error(self.file_path, translate('SongsPlugin.SongImport', 'File not found'))
     self.close_ooo()
Esempio n. 19
0
    def trigger_alert(self, text):
        """
        Prepares the alert text for displaying.

        ``text``
            The alert text (unicode).
        """
        if not text:
            return False
        # We found '<>' in the alert text, but the ParameterEdit field is empty.
        if text.find('<>') != -1 and not self.parameter_edit.text() and QtGui.QMessageBox.question(self,
                translate('AlertsPlugin.AlertForm', 'No Parameter Found'),
                translate('AlertsPlugin.AlertForm', 'You have not entered a parameter to be replaced.\n'
                    'Do you want to continue anyway?'),
                QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
            self.parameter_edit.setFocus()
            return False
        # The ParameterEdit field is not empty, but we have not found '<>'
        # in the alert text.
        elif text.find('<>') == -1 and self.parameter_edit.text() and QtGui.QMessageBox.question(self,
                translate('AlertsPlugin.AlertForm', 'No Placeholder Found'),
                translate('AlertsPlugin.AlertForm', 'The alert text does not contain \'<>\'.\n'
                    'Do you want to continue anyway?'),
                QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
            self.parameter_edit.setFocus()
            return False
        text = text.replace('<>', self.parameter_edit.text())
        self.plugin.alerts_manager.display_alert(text)
        return True
Esempio n. 20
0
 def do_import(self):
     if not isinstance(self.import_source, list):
         return
     try:
         self.start_ooo()
     except NoConnectException as exc:
         self.log_error(
             self.import_source[0],
             translate('SongsPlugin.SongImport',
                       'Cannot access OpenOffice or LibreOffice'))
         log.error(exc)
         return
     self.import_wizard.progress_bar.setMaximum(len(self.import_source))
     for filename in self.import_source:
         if self.stop_import_flag:
             break
         filename = str(filename)
         if os.path.isfile(filename):
             self.open_ooo_file(filename)
             if self.document:
                 self.process_ooo_document()
                 self.close_ooo_file()
             else:
                 self.log_error(
                     self.file_path,
                     translate('SongsPlugin.SongImport',
                               'Unable to open file'))
         else:
             self.log_error(
                 self.file_path,
                 translate('SongsPlugin.SongImport', 'File not found'))
     self.close_ooo()
Esempio n. 21
0
    def set_language(action, message=True):
        """
        Set the language to translate OpenLP into

        ``action``
            The language menu option

        ``message``
            Display the message option
        """
        language = 'en'
        if action:
            action_name = str(action.objectName())
            if action_name == 'autoLanguageItem':
                LanguageManager.auto_language = True
            else:
                LanguageManager.auto_language = False
                qm_list = LanguageManager.get_qm_list()
                language = str(qm_list[action_name])
        if LanguageManager.auto_language:
            language = '[%s]' % language
        Settings().setValue('core/language', language)
        log.info('Language file: \'%s\' written to conf file' % language)
        if message:
            QtGui.QMessageBox.information(None,
                translate('OpenLP.LanguageManager', 'Language'),
                translate('OpenLP.LanguageManager', 'Please restart OpenLP to use your new language setting.'))
Esempio n. 22
0
 def validateBook(self, new_book_name, abbreviation):
     """
     Validate a book.
     """
     book_regex = re.compile(u'[\d]*[^\d]+$')
     if not new_book_name:
         self.bookNameEdit[abbreviation].setFocus()
         critical_error_message_box(UiStrings().EmptyField,
             translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') %
                 self.book_names[abbreviation])
         return False
     elif not book_regex.match(new_book_name):
         self.bookNameEdit[abbreviation].setFocus()
         critical_error_message_box(UiStrings().EmptyField,
             translate('BiblesPlugin.BibleEditForm',
                 'The book name "%s" is not correct.\nNumbers can only be used at the beginning and must\nbe '
                 'followed by one or more non-numeric characters.') % new_book_name)
         return False
     for abbr, book in self.books.iteritems():
         if book:
             if abbr == abbreviation:
                 continue
             if self.bookNameEdit[abbr].text() == new_book_name:
                 self.bookNameEdit[abbreviation].setFocus()
                 critical_error_message_box(
                     translate('BiblesPlugin.BibleEditForm', 'Duplicate Book Name'),
                     translate('BiblesPlugin.BibleEditForm', 'The Book Name "%s" has been entered more than once.')
                         % new_book_name)
                 return False
     return True
Esempio n. 23
0
 def set_plugin_text_strings(self):
     """
     Called to define all translatable texts of the plugin
     """
     ## Name PluginList ##
     self.text_strings[StringContent.Name] = {
         'singular': translate('MediaPlugin', 'Media', 'name singular'),
         'plural': translate('MediaPlugin', 'Media', 'name plural')
     }
     ## Name for MediaDockManager, SettingsManager ##
     self.text_strings[StringContent.VisibleName] = {
         'title': translate('MediaPlugin', 'Media', 'container title')
     }
     # Middle Header Bar
     tooltips = {
         'load': translate('MediaPlugin', 'Load new media.'),
         'import': '',
         'new': translate('MediaPlugin', 'Add new media.'),
         'edit': translate('MediaPlugin', 'Edit the selected media.'),
         'delete': translate('MediaPlugin', 'Delete the selected media.'),
         'preview': translate('MediaPlugin', 'Preview the selected media.'),
         'live': translate('MediaPlugin', 'Send the selected media live.'),
         'service': translate('MediaPlugin', 'Add the selected media to the service.')
     }
     self.set_plugin_ui_text_strings(tooltips)
Esempio n. 24
0
 def retranslateUi(self):
     """
     The name of the plugin media displayed in UI
     """
     self.on_new_prompt = translate('PresentationPlugin.MediaItem', 'Select Presentation(s)')
     self.Automatic = translate('PresentationPlugin.MediaItem', 'Automatic')
     self.display_type_label.setText(translate('PresentationPlugin.MediaItem', 'Present using:'))
Esempio n. 25
0
 def post_wizard(self):
     """
     Clean up the UI after the import has finished.
     """
     successful_import = 0
     failed_import = 0
     for number, filename in enumerate(self.files):
         if self.success.get(number):
             successful_import += 1
         elif self.checkBox[number].checkState() == QtCore.Qt.Checked:
             failed_import += 1
             # Delete upgraded (but not complete, corrupted, ...) bible.
             delete_file(os.path.join(self.path, filename[0]))
             # Copy not upgraded bible back.
             shutil.move(os.path.join(self.temp_dir, filename[0]), self.path)
     if failed_import > 0:
         failed_import_text = translate('BiblesPlugin.UpgradeWizardForm', ', %s failed') % failed_import
     else:
         failed_import_text = ''
     if successful_import > 0:
         if self.includeWebBible:
             self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
                 'Upgrading Bible(s): %s successful%s\nPlease note that verses from Web Bibles will be downloaded '
                 'on demand and so an Internet connection is required.') % (successful_import, failed_import_text))
         else:
             self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
                 'Upgrading Bible(s): %s successful%s') % (successful_import, failed_import_text))
     else:
         self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade failed.'))
     # Remove temp directory.
     shutil.rmtree(self.temp_dir, True)
     super(BibleUpgradeForm, self).post_wizard()
Esempio n. 26
0
 def doImport(self):
     if not isinstance(self.importSource, list):
         return
     try:
         self.startOoo()
     except NoConnectException as exc:
         self.logError(
             self.importSource[0],
             translate('SongsPlugin.SongImport', 'Cannot access OpenOffice or LibreOffice'))
         log.error(exc)
         return
     self.importWizard.progressBar.setMaximum(len(self.importSource))
     for filename in self.importSource:
         if self.stopImportFlag:
             break
         filename = unicode(filename)
         if os.path.isfile(filename):
             self.openOooFile(filename)
             if self.document:
                 self.processOooDocument()
                 self.closeOooFile()
             else:
                 self.logError(self.filepath, translate('SongsPlugin.SongImport', 'Unable to open file'))
         else:
             self.logError(self.filepath, translate('SongsPlugin.SongImport', 'File not found'))
     self.closeOoo()
Esempio n. 27
0
 def validateCurrentPage(self):
     """
     Validate the current page before moving on to the next page.
     """
     if self.currentPage() == self.welcome_page:
         return True
     elif self.currentPage() == self.backup_page:
         if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked:
             backup_path = self.backupDirectoryEdit.text()
             if not backup_path:
                 critical_error_message_box(UiStrings().EmptyField,
                     translate('BiblesPlugin.UpgradeWizardForm',
                         'You need to specify a backup directory for your Bibles.'))
                 self.backupDirectoryEdit.setFocus()
                 return False
             else:
                 if not self.backupOldBibles(backup_path):
                     critical_error_message_box(UiStrings().Error,
                         translate('BiblesPlugin.UpgradeWizardForm', 'The backup was not successful.\nTo backup your '
                             'Bibles you need permission to write to the given directory.'))
                     return False
         return True
     elif self.currentPage() == self.selectPage:
         check_directory_exists(self.temp_dir)
         for number, filename in enumerate(self.files):
             if not self.checkBox[number].checkState() == QtCore.Qt.Checked:
                 continue
             # Move bibles to temp dir.
             if not os.path.exists(os.path.join(self.temp_dir, filename[0])):
                 shutil.move(os.path.join(self.path, filename[0]), self.temp_dir)
             else:
                 delete_file(os.path.join(self.path, filename[0]))
         return True
     if self.currentPage() == self.progress_page:
         return True
Esempio n. 28
0
 def accept(self):
     """
     Override the QDialog's accept() method to do some validation before the dialog can be closed.
     """
     if not self.first_name_edit.text():
         critical_error_message_box(message=translate(
             'SongsPlugin.AuthorsForm',
             'You need to type in the first name of the author.'))
         self.first_name_edit.setFocus()
         return False
     elif not self.last_name_edit.text():
         critical_error_message_box(message=translate(
             'SongsPlugin.AuthorsForm',
             'You need to type in the last name of the author.'))
         self.last_name_edit.setFocus()
         return False
     elif not self.display_edit.text():
         if critical_error_message_box(message=translate(
                 'SongsPlugin.AuthorsForm',
                 'You have not set a display name for the author, combine the first and last names?'
         ),
                                       parent=self,
                                       question=True
                                       ) == QtWidgets.QMessageBox.Yes:
             self.display_edit.setText(self.first_name_edit.text() + ' ' +
                                       self.last_name_edit.text())
             return QtWidgets.QDialog.accept(self)
         else:
             self.display_edit.setFocus()
             return False
     else:
         return QtWidgets.QDialog.accept(self)
Esempio n. 29
0
 def validateCurrentPage(self):
     """
     Validate the current page before moving on to the next page.
     """
     if self.currentPage() == self.welcomePage:
         return True
     elif self.currentPage() == self.availableSongsPage:
         items = [
             item for item in self._findListWidgetItems(
             self.availableListWidget) if item.checkState()
         ]
         if not items:
             critical_error_message_box(UiStrings().NISp,
                 translate('SongsPlugin.ExportWizardForm', 'You need to add at least one Song to export.'))
             return False
         self.selectedListWidget.clear()
         # Add the songs to the list of selected songs.
         for item in items:
             song = QtGui.QListWidgetItem(item.text())
             song.setData(QtCore.Qt.UserRole, item.data(QtCore.Qt.UserRole))
             song.setFlags(QtCore.Qt.ItemIsEnabled)
             self.selectedListWidget.addItem(song)
         return True
     elif self.currentPage() == self.exportSongPage:
         if not self.directoryLineEdit.text():
             critical_error_message_box(
                 translate('SongsPlugin.ExportWizardForm', 'No Save Location specified'),
                 translate('SongsPlugin.ExportWizardForm', 'You need to specify a directory.'))
             return False
         return True
     elif self.currentPage() == self.progressPage:
         self.availableListWidget.clear()
         self.selectedListWidget.clear()
         return True
Esempio n. 30
0
 def on_add_group_click(self):
     """
     Called to add a new group
     """
     # Find out if a group must be pre-selected
     preselect_group = 0
     selected_items = self.list_view.selectedItems()
     if selected_items:
         selected_item = selected_items[0]
         if isinstance(selected_item.data(0, QtCore.Qt.UserRole), ImageFilenames):
             selected_item = selected_item.parent()
         if isinstance(selected_item, QtGui.QTreeWidgetItem):
             if isinstance(selected_item.data(0, QtCore.Qt.UserRole), ImageGroups):
                 preselect_group = selected_item.data(0, QtCore.Qt.UserRole).id
     # Show 'add group' dialog
     if self.add_group_form.exec_(show_top_level_group=True, selected_group=preselect_group):
         new_group = ImageGroups.populate(parent_id=self.add_group_form.parent_group_combobox.itemData(
             self.add_group_form.parent_group_combobox.currentIndex(), QtCore.Qt.UserRole),
             group_name=self.add_group_form.name_edit.text())
         if not self.check_group_exists(new_group):
             if self.manager.save_object(new_group):
                 self.load_full_list(self.manager.get_all_objects(ImageFilenames,
                     order_by_ref=ImageFilenames.filename))
                 self.expand_group(new_group.id)
                 self.fill_groups_combobox(self.choose_group_form.group_combobox)
                 self.fill_groups_combobox(self.add_group_form.parent_group_combobox)
             else:
                 critical_error_message_box(
                     message=translate('ImagePlugin.AddGroupForm', 'Could not add the new group.'))
         else:
             critical_error_message_box(message=translate('ImagePlugin.AddGroupForm', 'This group already exists.'))
Esempio n. 31
0
 def onSaveReportButtonClicked(self):
     """
     Saving exception log and system information to a file.
     """
     report_text = translate('OpenLP.ExceptionForm',
         '**OpenLP Bug Report**\n'
         'Version: %s\n\n'
         '--- Details of the Exception. ---\n\n%s\n\n '
         '--- Exception Traceback ---\n%s\n'
         '--- System information ---\n%s\n'
         '--- Library Versions ---\n%s\n')
     filename = QtGui.QFileDialog.getSaveFileName(self,
         translate('OpenLP.ExceptionForm', 'Save Crash Report'),
         Settings().value(self.settingsSection + u'/last directory'),
         translate('OpenLP.ExceptionForm',
         'Text files (*.txt *.log *.text)'))
     if filename:
         filename = unicode(filename).replace(u'/', os.path.sep)
         Settings().setValue(self.settingsSection + u'/last directory', os.path.dirname(filename))
         report_text = report_text % self._createReport()
         try:
             report_file = open(filename, u'w')
             try:
                 report_file.write(report_text)
             except UnicodeError:
                 report_file.close()
                 report_file = open(filename, u'wb')
                 report_file.write(report_text.encode(u'utf-8'))
             finally:
                 report_file.close()
         except IOError:
             log.exception(u'Failed to write crash report')
         finally:
             report_file.close()
Esempio n. 32
0
 def on_data_directory_browse_button_clicked(self):
     """
     Browse for a new data directory location.
     """
     old_root_path = str(self.data_directory_label.text())
     # Get the new directory location.
     new_data_path = QtGui.QFileDialog.getExistingDirectory(
         self, translate('OpenLP.AdvancedTab', 'Select Data Directory Location'), old_root_path,
         options=QtGui.QFileDialog.ShowDirsOnly)
     # Set the new data path.
     if new_data_path:
         new_data_path = os.path.normpath(new_data_path)
         if self.current_data_path.lower() == new_data_path.lower():
             self.on_data_directory_cancel_button_clicked()
             return
     else:
         return
     # Make sure they want to change the data.
     answer = QtGui.QMessageBox.question(self,
         translate('OpenLP.AdvancedTab', 'Confirm Data Directory Change'),
         translate('OpenLP.AdvancedTab', 'Are you sure you want to change the location of the OpenLP '
             'data directory to:\n\n%s\n\n '
             'The data directory will be changed when OpenLP is closed.').replace('%s', new_data_path),
         QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No)
     if answer != QtGui.QMessageBox.Yes:
         return
     # Check if data already exists here.
     self.check_data_overwrite(new_data_path)
     # Save the new location.
     self.main_window.set_new_data_path(new_data_path)
     self.new_data_directory_edit.setText(new_data_path)
     self.data_directory_cancel_button.show()
Esempio n. 33
0
 def _validate_verse_list(self, verse_order, verse_count):
     verses = []
     invalid_verses = []
     verse_names = []
     order_names = str(verse_order).split()
     order = self._extract_verse_order(verse_order)
     for index in range(verse_count):
         verse = self.verse_list_widget.item(index, 0)
         verse = verse.data(QtCore.Qt.UserRole)
         if verse not in verse_names:
             verses.append(verse)
             verse_names.append('%s%s' % (VerseType.translated_tag(verse[0]), verse[1:]))
     for count, item in enumerate(order):
         if item not in verses:
             invalid_verses.append(order_names[count])
     if invalid_verses:
         valid = create_separated_list(verse_names)
         if len(invalid_verses) > 1:
             msg = translate('SongsPlugin.EditSongForm', 'There are no verses corresponding to "%(invalid)s".'
                 'Valid entries are %(valid)s.\nPlease enter the verses seperated by spaces.') \
                 % {'invalid' : ', '.join(invalid_verses), 'valid' : valid}
         else:
             msg = translate('SongsPlugin.EditSongForm', 'There is no verse corresponding to "%(invalid)s".'
                 'Valid entries are %(valid)s.\nPlease enter the verses seperated by spaces.') \
                 % {'invalid' : invalid_verses[0], 'valid' : valid}
         critical_error_message_box(title=translate('SongsPlugin.EditSongForm', 'Invalid Verse Order'),
                                    message=msg)
     return len(invalid_verses) == 0
Esempio n. 34
0
 def setPluginTextStrings(self):
     """
     Called to define all translatable texts of the plugin
     """
     ## Name PluginList ##
     self.textStrings[StringContent.Name] = {
         u'singular': translate('BiblesPlugin', 'Bible', 'name singular'),
         u'plural': translate('BiblesPlugin', 'Bibles', 'name plural')
     }
     ## Name for MediaDockManager, SettingsManager ##
     self.textStrings[StringContent.VisibleName] = {
         u'title': translate('BiblesPlugin', 'Bibles', 'container title')
     }
     # Middle Header Bar
     tooltips = {
         u'load': u'',
         u'import': translate('BiblesPlugin', 'Import a Bible.'),
         u'new': translate('BiblesPlugin', 'Add a new Bible.'),
         u'edit': translate('BiblesPlugin', 'Edit the selected Bible.'),
         u'delete': translate('BiblesPlugin', 'Delete the selected Bible.'),
         u'preview': translate('BiblesPlugin',
             'Preview the selected Bible.'),
         u'live': translate('BiblesPlugin', 'Send the selected Bible live.'),
         u'service': translate('BiblesPlugin', 'Add the selected Bible to the service.')
     }
     self.setPluginUiTextStrings(tooltips)
Esempio n. 35
0
 def retranslateUi(self, authors_dialog):
     """
     Translate the UI on the fly.
     """
     authors_dialog.setWindowTitle(translate('SongsPlugin.AuthorsForm', 'Author Maintenance'))
     self.display_label.setText(translate('SongsPlugin.AuthorsForm', 'Display name:'))
     self.first_name_label.setText(translate('SongsPlugin.AuthorsForm', 'First name:'))
     self.last_name_label.setText(translate('SongsPlugin.AuthorsForm', 'Last name:'))
Esempio n. 36
0
 def retranslateUi(self, topics_dialog):
     """
     Translate the UI on the fly.
     """
     topics_dialog.setWindowTitle(
         translate('SongsPlugin.TopicsForm', 'Topic Maintenance'))
     self.name_label.setText(
         translate('SongsPlugin.TopicsForm', 'Topic name:'))
Esempio n. 37
0
    def retranslateUi(self, media_files_dialog):
        """
        Translate the UI on the fly.

        :param media_files_dialog:
        """
        media_files_dialog.setWindowTitle(translate('SongsPlugin.MediaFilesForm', 'Select Media File(s)'))
        self.select_label.setText(translate('SongsPlugin.MediaFilesForm', 'Select one or more audio files from the '
                                                                          'list below, and click OK to import them '
                                                                          'into this song.'))
Esempio n. 38
0
 def retranslateUi(self, song_book_dialog):
     """
     Translate the UI on the fly.
     """
     song_book_dialog.setWindowTitle(
         translate('SongsPlugin.SongBookForm', 'Songbook Maintenance'))
     self.name_label.setText(translate('SongsPlugin.SongBookForm',
                                       '&Name:'))
     self.publisher_label.setText(
         translate('SongsPlugin.SongBookForm', '&Publisher:'))
Esempio n. 39
0
 def get_info(self):
     """
     Return some info about this player
     """
     return (translate(
         'Media.player', 'Phonon is a media player which '
         'interacts with the operating system to provide media capabilities.'
     ) + '<br/> <strong>' + translate('Media.player', 'Audio') +
             '</strong><br/>' + str(self.audio_extensions_list) +
             '<br/><strong>' + translate('Media.player', 'Video') +
             '</strong><br/>' + str(self.video_extensions_list) + '<br/>')
Esempio n. 40
0
 def get_info(self):
     """
     Return some info about this player
     """
     return (translate(
         'Media.player', 'This media player uses your operating system '
         'to provide media capabilities.') + '<br/> <strong>' +
             translate('Media.player', 'Audio') + '</strong><br/>' +
             str(self.audio_extensions_list) + '<br/><strong>' +
             translate('Media.player', 'Video') + '</strong><br/>' +
             str(self.video_extensions_list) + '<br/>')
Esempio n. 41
0
 def config_update(self):
     """
     Called when Config is changed to requests a restart with the server on new address or port
     """
     log.debug('remote config changed')
     QtWidgets.QMessageBox.information(self.main_window,
                                       translate('RemotePlugin', 'Server Config Change'),
                                       translate('RemotePlugin',
                                                 'Server configuration changes will require a restart '
                                                 'to take effect.'),
                                       QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
Esempio n. 42
0
 def get_info(self):
     """
     Return some information about this player
     """
     return (translate(
         'Media.player', 'VLC is an external player which '
         'supports a number of different formats.') + '<br/> <strong>' +
             translate('Media.player', 'Audio') + '</strong><br/>' +
             str(AUDIO_EXT) + '<br/><strong>' +
             translate('Media.player', 'Video') + '</strong><br/>' +
             str(VIDEO_EXT) + '<br/>')
Esempio n. 43
0
 def get_info(self):
     """
     Return some information about this player
     """
     part1 = translate(
         'Media.player',
         'Webkit is a media player which runs inside a web browser. This player '
         'allows text over video to be rendered.')
     part2 = translate('Media.player', 'Audio')
     part3 = translate('Media.player', 'Video')
     return part1 + '<br/> <strong>' + part2 + '</strong><br/>' + str(AUDIO_EXT) + '<br/><strong>' + part3 + \
         '</strong><br/>' + str(VIDEO_EXT) + '<br/>'
Esempio n. 44
0
 def retranslateUi(self, authors_dialog):
     """
     Translate the UI on the fly.
     """
     authors_dialog.setWindowTitle(
         translate('SongsPlugin.AuthorsForm', 'Author Maintenance'))
     self.display_label.setText(
         translate('SongsPlugin.AuthorsForm', 'Display name:'))
     self.first_name_label.setText(
         translate('SongsPlugin.AuthorsForm', 'First name:'))
     self.last_name_label.setText(
         translate('SongsPlugin.AuthorsForm', 'Last name:'))
Esempio n. 45
0
 def app_startup(self):
     """
     Perform tasks on application startup
     """
     super(BiblePlugin, self).app_startup()
     if self.manager.old_bible_databases:
         if QtWidgets.QMessageBox.information(
                 self.main_window, translate('OpenLP', 'Information'),
                 translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your '
                                     'existing Bibles.\nShould OpenLP upgrade now?'),
                 QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)) == \
                 QtWidgets.QMessageBox.Yes:
             self.on_tools_upgrade_item_triggered()
Esempio n. 46
0
 def start(self):
     """
     Run a search and then parse the results page of the search.
     """
     songs = self.importer.search(self.search_text, 1000, self._found_song_callback)
     if len(songs) >= 1000:
         self.show_info.emit(
             translate('SongsPlugin.SongSelectForm', 'More than 1000 results'),
             translate('SongsPlugin.SongSelectForm', 'Your search has returned more than 1000 results, it has '
                                                     'been stopped. Please refine your search to fetch better '
                                                     'results.'))
     self.finished.emit()
     self.quit.emit()
Esempio n. 47
0
 def set_plugin_text_strings(self):
     """
     Called to define all translatable texts of the plugin
     """
     # Name PluginList
     self.text_strings[StringContent.Name] = {
         'singular': translate('RemotePlugin', 'Remote', 'name singular'),
         'plural': translate('RemotePlugin', 'Remotes', 'name plural')
     }
     # Name for MediaDockManager, SettingsManager
     self.text_strings[StringContent.VisibleName] = {
         'title': translate('RemotePlugin', 'Remote', 'container title')
     }
Esempio n. 48
0
 def do_import(self):
     """
     Receive a single file to import.
     """
     try:
         conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s;PWD=6NOZ4eHK7k' %
                               self.import_source)
     except:
         # Unfortunately no specific exception type
         self.log_error(self.import_source, translate('SongsPlugin.MediaShoutImport',
                                                      'Unable to open the MediaShout database.'))
         return
     cursor = conn.cursor()
     cursor.execute('SELECT Record, Title, Author, Copyright, SongID, CCLI, Notes FROM Songs ORDER BY Title')
     songs = cursor.fetchall()
     self.import_wizard.progress_bar.setMaximum(len(songs))
     for song in songs:
         topics = []
         if self.stop_import_flag:
             break
         cursor.execute('SELECT Type, Number, Text FROM Verses WHERE Record = %s ORDER BY Type, Number'
                        % song.Record)
         verses = cursor.fetchall()
         cursor.execute('SELECT Type, Number, POrder FROM PlayOrder WHERE Record = %s ORDER BY POrder' % song.Record)
         verse_order = cursor.fetchall()
         if cursor.tables(table='TableName', tableType='TABLE').fetchone():
             cursor.execute('SELECT Name FROM Themes INNER JOIN SongThemes ON SongThemes.ThemeId = Themes.ThemeId '
                            'WHERE SongThemes.Record = %s' % song.Record)
             topics = cursor.fetchall()
         cursor.execute('SELECT Name FROM Groups INNER JOIN SongGroups ON SongGroups.GroupId = Groups.GroupId '
                        'WHERE SongGroups.Record = %s' % song.Record)
         topics += cursor.fetchall()
         self.process_song(song, verses, verse_order, topics)
Esempio n. 49
0
    def on_save_password_checkbox_toggled(self, checked):
        """
        Show a warning dialog when the user toggles the save checkbox on or off.

        :param checked: If the combobox is checked or not
        """
        if checked and self.login_page.isVisible():
            answer = QtWidgets.QMessageBox.question(
                self, translate('SongsPlugin.SongSelectForm', 'Save Username and Password'),
                translate('SongsPlugin.SongSelectForm', 'WARNING: Saving your username and password is INSECURE, your '
                                                        'password is stored in PLAIN TEXT. Click Yes to save your '
                                                        'password or No to cancel this.'),
                QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No),
                QtWidgets.QMessageBox.No)
            if answer == QtWidgets.QMessageBox.No:
                self.save_password_checkbox.setChecked(False)
Esempio n. 50
0
 def on_search_button_clicked(self):
     """
     Run a search on SongSelect.
     """
     # Set up UI components
     self.view_button.setEnabled(False)
     self.search_button.setEnabled(False)
     self.search_progress_bar.setMinimum(0)
     self.search_progress_bar.setMaximum(0)
     self.search_progress_bar.setValue(0)
     self.set_progress_visible(True)
     self.search_results_widget.clear()
     self.result_count_label.setText(translate('SongsPlugin.SongSelectForm', 'Found %s song(s)') % self.song_count)
     self.application.process_events()
     self.song_count = 0
     search_history = self.search_combobox.getItems()
     Settings().setValue(self.plugin.settings_section + '/songselect searches', '|'.join(search_history))
     # Create thread and run search
     self.thread = QtCore.QThread()
     self.worker = SearchWorker(self.song_select_importer, self.search_combobox.currentText())
     self.worker.moveToThread(self.thread)
     self.thread.started.connect(self.worker.start)
     self.worker.show_info.connect(self.on_search_show_info)
     self.worker.found_song.connect(self.on_search_found_song)
     self.worker.finished.connect(self.on_search_finished)
     self.worker.quit.connect(self.thread.quit)
     self.worker.quit.connect(self.worker.deleteLater)
     self.thread.finished.connect(self.thread.deleteLater)
     self.thread.start()
Esempio n. 51
0
 def on_import_button_clicked(self):
     """
     Import a song from SongSelect.
     """
     self.song_select_importer.save_song(self.song)
     self.song = None
     if QtWidgets.QMessageBox.question(self, translate('SongsPlugin.SongSelectForm', 'Song Imported'),
                                       translate('SongsPlugin.SongSelectForm',
                                                 'Your song has been imported, would you '
                                                 'like to import more songs?'),
                                       QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
                                       QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.Yes:
         self.on_back_button_clicked()
     else:
         self.application.process_events()
         self.done(QtWidgets.QDialog.Accepted)
Esempio n. 52
0
 def contextMenuEvent(self, event):
     """
     Provide the context menu for the text edit region.
     """
     popup_menu = self.createStandardContextMenu()
     # Select the word under the cursor.
     cursor = self.textCursor()
     # only select text if not already selected
     if not cursor.hasSelection():
         cursor.select(QtGui.QTextCursor.WordUnderCursor)
     self.setTextCursor(cursor)
     # Add menu with available languages.
     if ENCHANT_AVAILABLE:
         lang_menu = QtGui.QMenu(
             translate('OpenLP.SpellTextEdit', 'Language:'))
         for lang in enchant.list_languages():
             action = create_action(lang_menu,
                                    lang,
                                    text=lang,
                                    checked=lang == self.dictionary.tag)
             lang_menu.addAction(action)
         popup_menu.insertSeparator(popup_menu.actions()[0])
         popup_menu.insertMenu(popup_menu.actions()[0], lang_menu)
         lang_menu.triggered.connect(self.set_language)
     # Check if the selected word is misspelled and offer spelling suggestions if it is.
     if ENCHANT_AVAILABLE and self.textCursor().hasSelection():
         text = self.textCursor().selectedText()
         if not self.dictionary.check(text):
             spell_menu = QtGui.QMenu(
                 translate('OpenLP.SpellTextEdit', 'Spelling Suggestions'))
             for word in self.dictionary.suggest(text):
                 action = SpellAction(word, spell_menu)
                 action.correct.connect(self.correct_word)
                 spell_menu.addAction(action)
             # Only add the spelling suggests to the menu if there are suggestions.
             if spell_menu.actions():
                 popup_menu.insertMenu(popup_menu.actions()[0], spell_menu)
     tag_menu = QtGui.QMenu(
         translate('OpenLP.SpellTextEdit', 'Formatting Tags'))
     if self.formatting_tags_allowed:
         for html in FormattingTags.get_html_tags():
             action = SpellAction(html['desc'], tag_menu)
             action.correct.connect(self.html_tag)
             tag_menu.addAction(action)
         popup_menu.insertSeparator(popup_menu.actions()[0])
         popup_menu.insertMenu(popup_menu.actions()[0], tag_menu)
     popup_menu.exec_(event.globalPos())
Esempio n. 53
0
    def add_tools_menu_item(self, tools_menu):
        """
        Give the bible plugin the opportunity to add items to the **Tools** menu.

        :param tools_menu:  The actual **Tools** menu item, so that your actions can use it as their parent.
        """
        log.debug('add tools menu')
        self.tools_upgrade_item = create_action(
            tools_menu,
            'toolsUpgradeItem',
            text=translate('BiblesPlugin', '&Upgrade older Bibles'),
            statustip=translate(
                'BiblesPlugin',
                'Upgrade the Bible databases to the latest format.'),
            visible=False,
            triggers=self.on_tools_upgrade_item_triggered)
        tools_menu.addAction(self.tools_upgrade_item)
Esempio n. 54
0
 def on_login_button_clicked(self):
     """
     Log the user in to SongSelect.
     """
     self.username_edit.setEnabled(False)
     self.password_edit.setEnabled(False)
     self.save_password_checkbox.setEnabled(False)
     self.login_button.setEnabled(False)
     self.login_spacer.setVisible(False)
     self.login_progress_bar.setValue(0)
     self.login_progress_bar.setVisible(True)
     self.application.process_events()
     # Log the user in
     if not self.song_select_importer.login(self.username_edit.text(),
                                            self.password_edit.text(),
                                            self._update_login_progress):
         QtGui.QMessageBox.critical(
             self,
             translate('SongsPlugin.SongSelectForm', 'Error Logging In'),
             translate(
                 'SongsPlugin.SongSelectForm',
                 'There was a problem logging in, perhaps your username or password is incorrect?'
             ))
     else:
         if self.save_password_checkbox.isChecked():
             Settings().setValue(
                 self.plugin.settings_section + '/songselect username',
                 self.username_edit.text())
             Settings().setValue(
                 self.plugin.settings_section + '/songselect password',
                 self.password_edit.text())
         else:
             Settings().remove(self.plugin.settings_section +
                               '/songselect username')
             Settings().remove(self.plugin.settings_section +
                               '/songselect password')
         self.stacked_widget.setCurrentIndex(1)
     self.login_progress_bar.setVisible(False)
     self.login_progress_bar.setValue(0)
     self.login_spacer.setVisible(True)
     self.login_button.setEnabled(True)
     self.username_edit.setEnabled(True)
     self.password_edit.setEnabled(True)
     self.save_password_checkbox.setEnabled(True)
     self.search_combobox.setFocus()
     self.application.process_events()
Esempio n. 55
0
 def about():
     about_text = translate(
         'CustomPlugin',
         '<strong>Custom Slide Plugin </strong><br />The custom slide plugin '
         'provides the ability to set up custom text slides that can be displayed on the screen '
         'the same way songs are. This plugin provides greater freedom over the songs plugin.'
     )
     return about_text
Esempio n. 56
0
 def about():
     """
     Return the about text for the plugin manager
     """
     about_text = translate('BiblesPlugin', '<strong>Bible Plugin</strong>'
                            '<br />The Bible plugin provides the ability to display Bible '
                            'verses from different sources during the service.')
     return about_text
Esempio n. 57
0
    def retranslate_ui(self, planningcenter_dialog):
        """
        Translate the GUI.
        """
        planningcenter_dialog.setWindowTitle(
            translate('PlanningCenterPlugin.PlanningCenterAuthForm',
                      'Planning Center Service Importer Authentication'))
        self.notice_label.setText(
            translate(
                'PlanningCenterPlugin.PlanningCenterForm',
                '<strong>Note:</strong> '
                'An Internet connection and a Planning Center Online Account are required in order to import plans from Planning Center Online.'
            ))
        self.instructions_label.setText(
            translate('PlanningCenterPlugin.PlanningCenterAuthForm',\
"""Enter your <b>Planning Center Online</b> <i>Personal Access Token</i> details in the text boxes \
below.  Personal Access Tokens are created by doing the following:
<ol>
  <li>Log into your Planning Center Online account at<br>https://api.planningcenteronline.com/oauth/applications</li>
  <li>Click the "New Personal Access Token" button at the bottom of the screen.</li>
  <li>Enter a description of your use case (eg. "OpenLP Integration")</li>
  <li>Copy and paste the provided Application ID and Secret values below.</li>
</ol>"""))
        self.application_id_label.setText(
            translate('PlanningCenterPlugin.PlanningCenterAuthForm',
                      "Application ID"))
        self.secret_label.setText(
            translate('PlanningCenterPlugin.PlanningCenterAuthForm', "Secret"))
        self.test_credentials_button.setText(
            translate('PlanningCenterPlugin.PlanningCenterAuthForm',
                      'Test Credentials'))
        self.ok_button.setText(
            translate('PlanningCenterPlugin.PlanningCenterAuthForm', 'OK'))
Esempio n. 58
0
 def retranslateUi(self, exception_dialog):
     """
     Translate the widgets on the fly.
     """
     # Note that bugs mail is not clicable, but it adds the blue color and underlining and makes the test copyable.
     exception_dialog.setWindowTitle(
         translate('OpenLP.ExceptionDialog', 'Error Occurred'))
     # Explanation text, &nbsp; adds a small space before: If possible, write in English.
     self.description_explanation.setText(
         translate(
             'OpenLP.ExceptionDialog',
             '<strong>Please describe what you were trying to do.</strong> '
             '&nbsp;If possible, write in English.'))
     exception_part1 = (translate(
         'OpenLP.ExceptionDialog',
         '<strong>Oops, OpenLP hit a problem and couldn\'t recover!</strong> <br><br>'
         '<strong>You can help </strong> the OpenLP developers to <strong>fix this</strong>'
         ' by<br> sending them a <strong>bug report</strong> to {email}{newlines}'
     ).format(
         email='<a href = "mailto:[email protected]" > [email protected]</a>',
         newlines='<br><br>'))
     self.message_label.setText(
         translate(
             'OpenLP.ExceptionDialog', '{first_part}'
             '<strong>No email app? </strong> You can <strong>save</strong> this '
             'information to a <strong>file</strong> and<br>'
             'send it from your <strong>mail on browser</strong> via an <strong>attachment.</strong><br><br>'
             '<strong>Thank you<strong> for being part of making OpenLP better!<br>'
         ).format(first_part=exception_part1))
     self.send_report_button.setText(
         translate('OpenLP.ExceptionDialog', 'Send E-Mail'))
     self.save_report_button.setText(
         translate('OpenLP.ExceptionDialog', 'Save to File'))
     self.attach_tile_button.setText(
         translate('OpenLP.ExceptionDialog', 'Attach File'))
Esempio n. 59
0
File: db.py Progetto: jkunle/paul
class AuthorType(object):
    """
    Enumeration for Author types.
    They are defined by OpenLyrics: http://openlyrics.info/dataformat.html#authors

    The 'words+music' type is not an official type, but is provided for convenience.
    """
    NoType = ''
    Words = 'words'
    Music = 'music'
    WordsAndMusic = 'words+music'
    Translation = 'translation'
    Types = {
        NoType: '',
        Words: translate('SongsPlugin.AuthorType', 'Words', 'Author who wrote the lyrics of a song'),
        Music: translate('SongsPlugin.AuthorType', 'Music', 'Author who wrote the music of a song'),
        WordsAndMusic: translate('SongsPlugin.AuthorType', 'Words and Music',
                                 'Author who wrote both lyrics and music of a song'),
        Translation: translate('SongsPlugin.AuthorType', 'Translation', 'Author who translated the song')
    }
    SortedTypes = [
        NoType,
        Words,
        Music,
        WordsAndMusic,
        Translation
    ]
    TranslatedTypes = [
        Types[NoType],
        Types[Words],
        Types[Music],
        Types[WordsAndMusic],
        Types[Translation]
    ]

    @staticmethod
    def from_translated_text(translated_type):
        """
        Get the AuthorType from a translated string.
        :param translated_type: Translated Author type.
        """
        for key, value in AuthorType.Types.items():
            if value == translated_type:
                return key
        return AuthorType.NoType
Esempio n. 60
0
    def add_export_menu_item(self, export_menu):
        """
        Add an export menu item

        :param export_menu: The menu to insert the menu item into.
        """
        self.export_bible_item = create_action(export_menu, 'exportBibleItem',
                                               text=translate('BiblesPlugin', '&Bible'), visible=False)
        export_menu.addAction(self.export_bible_item)