예제 #1
0
 def controller_text(self, var):
     """
     Perform an action on the slide controller.
     """
     log.debug("controller_text var = %s" % var)
     current_item = self.live_controller.service_item
     data = []
     if current_item:
         for index, frame in enumerate(current_item.get_frames()):
             item = {}
             # Handle text (songs, custom, bibles)
             if current_item.is_text():
                 if frame['verseTag']:
                     item['tag'] = str(frame['verseTag'])
                 else:
                     item['tag'] = str(index + 1)
                 item['text'] = str(frame['text'])
                 item['html'] = str(frame['html'])
             # Handle images, unless a custom thumbnail is given or if thumbnails is disabled
             elif current_item.is_image() and not frame.get(
                     'image',
                     '') and Settings().value('remotes/thumbnails'):
                 item['tag'] = str(index + 1)
                 thumbnail_path = os.path.join('images', 'thumbnails',
                                               frame['title'])
                 full_thumbnail_path = os.path.join(
                     AppLocation.get_data_path(), thumbnail_path)
                 # Create thumbnail if it doesn't exists
                 if not os.path.exists(full_thumbnail_path):
                     create_thumb(current_item.get_frame_path(index),
                                  full_thumbnail_path, False)
                 item['img'] = urllib.request.pathname2url(os.path.sep +
                                                           thumbnail_path)
                 item['text'] = str(frame['title'])
                 item['html'] = str(frame['title'])
             else:
                 # Handle presentation etc.
                 item['tag'] = str(index + 1)
                 if current_item.is_capable(
                         ItemCapabilities.HasDisplayTitle):
                     item['title'] = str(frame['display_title'])
                 if current_item.is_capable(ItemCapabilities.HasNotes):
                     item['slide_notes'] = str(frame['notes'])
                 if current_item.is_capable(ItemCapabilities.HasThumbnails) and \
                         Settings().value('remotes/thumbnails'):
                     # If the file is under our app directory tree send the portion after the match
                     data_path = AppLocation.get_data_path()
                     if frame['image'][0:len(data_path)] == data_path:
                         item['img'] = urllib.request.pathname2url(
                             frame['image'][len(data_path):])
                 item['text'] = str(frame['title'])
                 item['html'] = str(frame['title'])
             item['selected'] = (self.live_controller.selected_row == index)
             data.append(item)
     json_data = {'results': {'slides': data}}
     if current_item:
         json_data['results'][
             'item'] = self.live_controller.service_item.unique_identifier
     self.do_json_header()
     return json.dumps(json_data).encode()
예제 #2
0
    def controller_text(self, var):
        """
        Perform an action on the slide controller.

        :param var: variable - not used
        """
        log.debug("controller_text var = {var}".format(var=var))
        current_item = self.live_controller.service_item
        data = []
        if current_item:
            for index, frame in enumerate(current_item.get_frames()):
                item = {}
                # Handle text (songs, custom, bibles)
                if current_item.is_text():
                    if frame['verseTag']:
                        item['tag'] = str(frame['verseTag'])
                    else:
                        item['tag'] = str(index + 1)
                    item['text'] = str(frame['text'])
                    item['html'] = str(frame['html'])
                # Handle images, unless a custom thumbnail is given or if thumbnails is disabled
                elif current_item.is_image() and not frame.get('image', '') and Settings().value('remotes/thumbnails'):
                    item['tag'] = str(index + 1)
                    thumbnail_path = os.path.join('images', 'thumbnails', frame['title'])
                    full_thumbnail_path = os.path.join(AppLocation.get_data_path(), thumbnail_path)
                    # Create thumbnail if it doesn't exists
                    if not os.path.exists(full_thumbnail_path):
                        create_thumb(current_item.get_frame_path(index), full_thumbnail_path, False)
                    item['img'] = urllib.request.pathname2url(os.path.sep + thumbnail_path)
                    item['text'] = str(frame['title'])
                    item['html'] = str(frame['title'])
                else:
                    # Handle presentation etc.
                    item['tag'] = str(index + 1)
                    if current_item.is_capable(ItemCapabilities.HasDisplayTitle):
                        item['title'] = str(frame['display_title'])
                    if current_item.is_capable(ItemCapabilities.HasNotes):
                        item['slide_notes'] = str(frame['notes'])
                    if current_item.is_capable(ItemCapabilities.HasThumbnails) and \
                            Settings().value('remotes/thumbnails'):
                        # If the file is under our app directory tree send the portion after the match
                        data_path = AppLocation.get_data_path()
                        if frame['image'][0:len(data_path)] == data_path:
                            item['img'] = urllib.request.pathname2url(frame['image'][len(data_path):])
                    item['text'] = str(frame['title'])
                    item['html'] = str(frame['title'])
                item['selected'] = (self.live_controller.selected_row == index)
                data.append(item)
        json_data = {'results': {'slides': data}}
        if current_item:
            json_data['results']['item'] = self.live_controller.service_item.unique_identifier
        self.do_json_header()
        return json.dumps(json_data).encode()
예제 #3
0
 def is_data_path_missing(self):
     """
     Check if the data folder path exists.
     """
     data_folder_path = AppLocation.get_data_path()
     if not os.path.exists(data_folder_path):
         log.critical('Database was not found in: ' + data_folder_path)
         status = QtWidgets.QMessageBox.critical(
             None, translate('OpenLP', 'Data Directory Error'),
             translate(
                 'OpenLP', 'OpenLP data folder was not found in:\n\n{path}'
                 '\n\nThe location of the data folder was '
                 'previously changed from the OpenLP\'s '
                 'default location. If the data was stored on '
                 'removable device, that device needs to be '
                 'made available.\n\nYou may reset the data '
                 'location back to the default location, '
                 'or you can try to make the current location '
                 'available.\n\nDo you want to reset to the '
                 'default data location? If not, OpenLP will be '
                 'closed so you can try to fix the the problem.').format(
                     path=data_folder_path),
             QtWidgets.QMessageBox.StandardButtons(
                 QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No),
             QtWidgets.QMessageBox.No)
         if status == QtWidgets.QMessageBox.No:
             # If answer was "No", return "True", it will shutdown OpenLP in def main
             log.info('User requested termination')
             return True
         # If answer was "Yes", remove the custom data path thus resetting the default location.
         Settings().remove('advanced/data path')
         log.info(
             'Database location has been reset to the default settings.')
         return False
예제 #4
0
    def test_get_data_path(self):
        """
        Test the AppLocation.get_data_path() method
        """
        with patch('openlp.core.common.applocation.Settings') as mocked_class, \
                patch('openlp.core.common.AppLocation.get_directory') as mocked_get_directory, \
                patch('openlp.core.common.applocation.check_directory_exists') as mocked_check_directory_exists, \
                patch('openlp.core.common.applocation.os') as mocked_os:
            # GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
            mocked_settings = mocked_class.return_value
            mocked_settings.contains.return_value = False
            mocked_get_directory.return_value = os.path.join('test', 'dir')
            mocked_check_directory_exists.return_value = True
            mocked_os.path.normpath.return_value = os.path.join('test', 'dir')

            # WHEN: we call AppLocation.get_data_path()
            data_path = AppLocation.get_data_path()

            # THEN: check that all the correct methods were called, and the result is correct
            mocked_settings.contains.assert_called_with('advanced/data path')
            mocked_get_directory.assert_called_with(AppLocation.DataDir)
            mocked_check_directory_exists.assert_called_with(
                os.path.join('test', 'dir'))
            self.assertEqual(os.path.join('test', 'dir'), data_path,
                             'Result should be "test/dir"')
예제 #5
0
    def backup_on_upgrade(self, has_run_wizard):
        """
        Check if OpenLP has been upgraded, and ask if a backup of data should be made

        :param has_run_wizard: OpenLP has been run before
        """
        data_version = Settings().value('core/application version')
        openlp_version = get_application_version()['version']
        # New installation, no need to create backup
        if not has_run_wizard:
            Settings().setValue('core/application version', openlp_version)
        # If data_version is different from the current version ask if we should backup the data folder
        elif data_version != openlp_version:
            if QtGui.QMessageBox.question(None, translate('OpenLP', 'Backup'),
                                          translate('OpenLP', 'OpenLP has been upgraded, '
                                                              'do you want to create a backup of OpenLPs data folder?'),
                                          QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
                                          QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
                # Create copy of data folder
                data_folder_path = AppLocation.get_data_path()
                timestamp = time.strftime("%Y%m%d-%H%M%S")
                data_folder_backup_path = data_folder_path + '-' + timestamp
                try:
                    shutil.copytree(data_folder_path, data_folder_backup_path)
                except OSError:
                    QtGui.QMessageBox.warning(None, translate('OpenLP', 'Backup'),
                                              translate('OpenLP', 'Backup of the data folder failed!'))
                    return
                QtGui.QMessageBox.information(None, translate('OpenLP', 'Backup'),
                                              translate('OpenLP', 'A backup of the data folder has been created at %s')
                                              % data_folder_backup_path)
            # Update the version in the settings
            Settings().setValue('core/application version', openlp_version)
예제 #6
0
 def initialise(self):
     """
     Initialise the router stack and any other variables.
     """
     auth_code = "{user}:{password}".format(user=Settings().value('remotes/user id'),
                                            password=Settings().value('remotes/password'))
     try:
         self.auth = base64.b64encode(auth_code)
     except TypeError:
         self.auth = base64.b64encode(auth_code.encode()).decode()
     self.default_route = {'function': self.serve_file, 'secure': False}
     self.routes = [
         ('^/$', {'function': self.serve_file, 'secure': False}),
         ('^/(stage)$', {'function': self.serve_file, 'secure': False}),
         ('^/(stage)/(.*)$', {'function': self.stages, 'secure': False}),
         ('^/(main)$', {'function': self.serve_file, 'secure': False}),
         (r'^/(\w+)/thumbnails([^/]+)?/(.*)$', {'function': self.serve_thumbnail, 'secure': False}),
         (r'^/api/poll$', {'function': self.poll, 'secure': False}),
         (r'^/main/poll$', {'function': self.main_poll, 'secure': False}),
         (r'^/main/image$', {'function': self.main_image, 'secure': False}),
         (r'^/api/controller/(live|preview)/text$', {'function': self.controller_text, 'secure': False}),
         (r'^/api/controller/(live|preview)/(.*)$', {'function': self.controller, 'secure': True}),
         (r'^/api/service/list$', {'function': self.service_list, 'secure': False}),
         (r'^/api/service/(.*)$', {'function': self.service, 'secure': True}),
         (r'^/api/display/(hide|show|blank|theme|desktop)$', {'function': self.display, 'secure': True}),
         (r'^/api/alert$', {'function': self.alert, 'secure': True}),
         (r'^/api/plugin/(search)$', {'function': self.plugin_info, 'secure': False}),
         (r'^/api/(.*)/search$', {'function': self.search, 'secure': False}),
         (r'^/api/(.*)/live$', {'function': self.go_live, 'secure': True}),
         (r'^/api/(.*)/add$', {'function': self.add_to_service, 'secure': True})
     ]
     self.settings_section = 'remotes'
     self.translate()
     self.html_dir = os.path.join(AppLocation.get_directory(AppLocation.PluginsDir), 'remotes', 'html')
     self.config_dir = os.path.join(AppLocation.get_data_path(), 'stages')
예제 #7
0
 def load(self):
     """
     Load settings from disk.
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     # The max recent files value does not have an interface and so never
     # gets actually stored in the settings therefore the default value of
     # 20 will always be used.
     self.recent_spin_box.setMaximum(settings.value('max recent files'))
     self.recent_spin_box.setValue(settings.value('recent file count'))
     self.media_plugin_check_box.setChecked(settings.value('save current plugin'))
     self.double_click_live_check_box.setChecked(settings.value('double click live'))
     self.single_click_preview_check_box.setChecked(settings.value('single click preview'))
     self.single_click_service_preview_check_box.setChecked(settings.value('single click service preview'))
     self.expand_service_item_check_box.setChecked(settings.value('expand service item'))
     slide_max_height_value = settings.value('slide max height')
     for i in range(0, self.slide_max_height_combo_box.count()):
         if self.slide_max_height_combo_box.itemData(i) == slide_max_height_value:
             self.slide_max_height_combo_box.setCurrentIndex(i)
     autoscroll_value = settings.value('autoscrolling')
     for i in range(0, len(self.autoscroll_map)):
         if self.autoscroll_map[i] == autoscroll_value and i < self.autoscroll_combo_box.count():
             self.autoscroll_combo_box.setCurrentIndex(i)
     self.enable_auto_close_check_box.setChecked(settings.value('enable exit confirmation'))
     self.hide_mouse_check_box.setChecked(settings.value('hide mouse'))
     self.service_name_day.setCurrentIndex(settings.value('default service day'))
     self.service_name_time.setTime(QtCore.QTime(settings.value('default service hour'),
                                                 settings.value('default service minute')))
     self.should_update_service_name_example = True
     self.service_name_edit.setText(settings.value('default service name'))
     default_service_enabled = settings.value('default service enabled')
     self.service_name_check_box.setChecked(default_service_enabled)
     self.service_name_check_box_toggled(default_service_enabled)
     self.x11_bypass_check_box.setChecked(settings.value('x11 bypass wm'))
     self.slide_limits = settings.value('slide limits')
     self.is_search_as_you_type_enabled = settings.value('search as type')
     self.search_as_type_check_box.setChecked(self.is_search_as_you_type_enabled)
     # Prevent the dialog displayed by the alternate_rows_check_box to display.
     self.alternate_rows_check_box.blockSignals(True)
     self.alternate_rows_check_box.setChecked(settings.value('alternate rows'))
     self.alternate_rows_check_box.blockSignals(False)
     if self.slide_limits == SlideLimits.End:
         self.end_slide_radio_button.setChecked(True)
     elif self.slide_limits == SlideLimits.Wrap:
         self.wrap_slide_radio_button.setChecked(True)
     else:
         self.next_item_radio_button.setChecked(True)
     settings.endGroup()
     self.data_directory_copy_check_box.hide()
     self.new_data_directory_has_files_label.hide()
     self.data_directory_cancel_button.hide()
     # Since data location can be changed, make sure the path is present.
     self.current_data_path = AppLocation.get_data_path()
     self.data_directory_label.setText(os.path.abspath(self.current_data_path))
     # Don't allow data directory move if running portable.
     if settings.value('advanced/is portable'):
         self.data_directory_group_box.hide()
예제 #8
0
    def backup_on_upgrade(self, has_run_wizard, can_show_splash):
        """
        Check if OpenLP has been upgraded, and ask if a backup of data should be made

        :param has_run_wizard: OpenLP has been run before
        """
        data_version = Settings().value('core/application version')
        openlp_version = get_application_version()['version']
        # New installation, no need to create backup
        if not has_run_wizard:
            Settings().setValue('core/application version', openlp_version)
        # If data_version is different from the current version ask if we should backup the data folder
        elif data_version != openlp_version:
            if can_show_splash and self.splash.isVisible():
                self.splash.hide()
            if QtWidgets.QMessageBox.question(
                    None, translate('OpenLP', 'Backup'),
                    translate(
                        'OpenLP',
                        'OpenLP has been upgraded, do you want to create '
                        'a backup of OpenLPs data folder?'),
                    QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,
                    QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.Yes:
                # Create copy of data folder
                data_folder_path = AppLocation.get_data_path()
                timestamp = time.strftime("%Y%m%d-%H%M%S")
                data_folder_backup_path = data_folder_path + '-' + timestamp
                try:
                    shutil.copytree(data_folder_path, data_folder_backup_path)
                except OSError:
                    QtWidgets.QMessageBox.warning(
                        None, translate('OpenLP', 'Backup'),
                        translate('OpenLP',
                                  'Backup of the data folder failed!'))
                    return
                QtWidgets.QMessageBox.information(
                    None, translate('OpenLP', 'Backup'),
                    translate(
                        'OpenLP',
                        'A backup of the data folder has been created at %s') %
                    data_folder_backup_path)
            # Update the version in the settings
            Settings().setValue('core/application version', openlp_version)
            if can_show_splash:
                self.splash.show()
예제 #9
0
    def get_data_path_with_custom_location_test(self):
        """
        Test the AppLocation.get_data_path() method when a custom location is set in the settings
        """
        with patch('openlp.core.common.applocation.Settings') as mocked_class,\
                patch('openlp.core.common.applocation.os') as mocked_os:
            # GIVEN: A mocked out Settings class which returns a custom data location
            mocked_settings = mocked_class.return_value
            mocked_settings.contains.return_value = True
            mocked_settings.value.return_value.toString.return_value = 'custom/dir'
            mocked_os.path.normpath.return_value = 'custom/dir'

            # WHEN: we call AppLocation.get_data_path()
            data_path = AppLocation.get_data_path()

            # THEN: the mocked Settings methods were called and the value returned was our set up value
            mocked_settings.contains.assert_called_with('advanced/data path')
            mocked_settings.value.assert_called_with('advanced/data path')
            self.assertEqual('custom/dir', data_path, 'Result should be "custom/dir"')
예제 #10
0
    def test_get_data_path_with_custom_location(self):
        """
        Test the AppLocation.get_data_path() method when a custom location is set in the settings
        """
        with patch('openlp.core.common.applocation.Settings') as mocked_class,\
                patch('openlp.core.common.applocation.os') as mocked_os:
            # GIVEN: A mocked out Settings class which returns a custom data location
            mocked_settings = mocked_class.return_value
            mocked_settings.contains.return_value = True
            mocked_settings.value.return_value.toString.return_value = 'custom/dir'
            mocked_os.path.normpath.return_value = 'custom/dir'

            # WHEN: we call AppLocation.get_data_path()
            data_path = AppLocation.get_data_path()

            # THEN: the mocked Settings methods were called and the value returned was our set up value
            mocked_settings.contains.assert_called_with('advanced/data path')
            mocked_settings.value.assert_called_with('advanced/data path')
            self.assertEqual('custom/dir', data_path,
                             'Result should be "custom/dir"')
예제 #11
0
 def update_preview_text(self):
     """
     Creates the html text and updates the html of *self.document*.
     """
     html_data = self._add_element('html')
     self._add_element('head', parent=html_data)
     self._add_element('title', self.title_line_edit.text(), html_data.head)
     css_path = os.path.join(AppLocation.get_data_path(),
                             'service_print.css')
     custom_css = get_text_file_string(css_path)
     if not custom_css:
         custom_css = DEFAULT_CSS
     self._add_element('style',
                       custom_css,
                       html_data.head,
                       attribute=('type', 'text/css'))
     self._add_element('body', parent=html_data)
     self._add_element('h1',
                       html.escape(self.title_line_edit.text()),
                       html_data.body,
                       classId='serviceTitle')
     for index, item in enumerate(self.service_manager.service_items):
         self._add_preview_item(html_data.body, item['service_item'], index)
     # Add the custom service notes:
     if self.footer_text_edit.toPlainText():
         div = self._add_element('div',
                                 parent=html_data.body,
                                 classId='customNotes')
         self._add_element('span',
                           translate('OpenLP.ServiceManager',
                                     'Custom Service Notes: '),
                           div,
                           classId='customNotesTitle')
         self._add_element('span',
                           html.escape(self.footer_text_edit.toPlainText()),
                           div,
                           classId='customNotesText')
     self.document.setHtml(lxml.html.tostring(html_data).decode())
     self.preview_widget.updatePreview()
예제 #12
0
    def get_data_path_test(self):
        """
        Test the AppLocation.get_data_path() method
        """
        with patch('openlp.core.common.applocation.Settings') as mocked_class, \
                patch('openlp.core.common.AppLocation.get_directory') as mocked_get_directory, \
                patch('openlp.core.common.applocation.check_directory_exists') as mocked_check_directory_exists, \
                patch('openlp.core.common.applocation.os') as mocked_os:
            # GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
            mocked_settings = mocked_class.return_value
            mocked_settings.contains.return_value = False
            mocked_get_directory.return_value = os.path.join('test', 'dir')
            mocked_check_directory_exists.return_value = True
            mocked_os.path.normpath.return_value = os.path.join('test', 'dir')

            # WHEN: we call AppLocation.get_data_path()
            data_path = AppLocation.get_data_path()

            # THEN: check that all the correct methods were called, and the result is correct
            mocked_settings.contains.assert_called_with('advanced/data path')
            mocked_get_directory.assert_called_with(AppLocation.DataDir)
            mocked_check_directory_exists.assert_called_with(os.path.join('test', 'dir'))
            self.assertEqual(os.path.join('test', 'dir'), data_path, 'Result should be "test/dir"')
예제 #13
0
 def update_preview_text(self):
     """
     Creates the html text and updates the html of *self.document*.
     """
     html_data = self._add_element('html')
     self._add_element('head', parent=html_data)
     self._add_element('title', self.title_line_edit.text(), html_data.head)
     css_path = os.path.join(AppLocation.get_data_path(), 'service_print.css')
     custom_css = get_text_file_string(css_path)
     if not custom_css:
         custom_css = DEFAULT_CSS
     self._add_element('style', custom_css, html_data.head, attribute=('type', 'text/css'))
     self._add_element('body', parent=html_data)
     self._add_element('h1', html.escape(self.title_line_edit.text()), html_data.body, classId='serviceTitle')
     for index, item in enumerate(self.service_manager.service_items):
         self._add_preview_item(html_data.body, item['service_item'], index)
     # Add the custom service notes:
     if self.footer_text_edit.toPlainText():
         div = self._add_element('div', parent=html_data.body, classId='customNotes')
         self._add_element(
             'span', translate('OpenLP.ServiceManager', 'Custom Service Notes: '), div, classId='customNotesTitle')
         self._add_element('span', html.escape(self.footer_text_edit.toPlainText()), div, classId='customNotesText')
     self.document.setHtml(lxml.html.tostring(html_data).decode())
     self.preview_widget.updatePreview()
예제 #14
0
 def initialise(self):
     """
     Initialise the router stack and any other variables.
     """
     auth_code = "%s:%s" % (Settings().value('remotes/user id'),
                            Settings().value('remotes/password'))
     try:
         self.auth = base64.b64encode(auth_code)
     except TypeError:
         self.auth = base64.b64encode(auth_code.encode()).decode()
     self.routes = [('^/$', {
         'function': self.serve_file,
         'secure': False
     }), ('^/(stage)$', {
         'function': self.serve_file,
         'secure': False
     }), ('^/(stage)/(.*)$', {
         'function': self.stages,
         'secure': False
     }), ('^/(main)$', {
         'function': self.serve_file,
         'secure': False
     }), (r'^/files/(.*)$', {
         'function': self.serve_file,
         'secure': False
     }),
                    (r'^/(\w+)/thumbnails([^/]+)?/(.*)$', {
                        'function': self.serve_thumbnail,
                        'secure': False
                    }),
                    (r'^/api/poll$', {
                        'function': self.poll,
                        'secure': False
                    }),
                    (r'^/main/poll$', {
                        'function': self.main_poll,
                        'secure': False
                    }),
                    (r'^/main/image$', {
                        'function': self.main_image,
                        'secure': False
                    }),
                    (r'^/api/controller/(live|preview)/text$', {
                        'function': self.controller_text,
                        'secure': False
                    }),
                    (r'^/api/controller/(live|preview)/(.*)$', {
                        'function': self.controller,
                        'secure': True
                    }),
                    (r'^/api/service/list$', {
                        'function': self.service_list,
                        'secure': False
                    }),
                    (r'^/api/service/(.*)$', {
                        'function': self.service,
                        'secure': True
                    }),
                    (r'^/api/display/(hide|show|blank|theme|desktop)$', {
                        'function': self.display,
                        'secure': True
                    }),
                    (r'^/api/alert$', {
                        'function': self.alert,
                        'secure': True
                    }),
                    (r'^/api/plugin/(search)$', {
                        'function': self.plugin_info,
                        'secure': False
                    }),
                    (r'^/api/(.*)/search$', {
                        'function': self.search,
                        'secure': False
                    }),
                    (r'^/api/(.*)/live$', {
                        'function': self.go_live,
                        'secure': True
                    }),
                    (r'^/api/(.*)/add$', {
                        'function': self.add_to_service,
                        'secure': True
                    })]
     self.settings_section = 'remotes'
     self.translate()
     self.html_dir = os.path.join(
         AppLocation.get_directory(AppLocation.PluginsDir), 'remotes',
         'html')
     self.config_dir = os.path.join(AppLocation.get_data_path(), 'stages')
예제 #15
0
 def load(self):
     """
     Load settings from disk.
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     # The max recent files value does not have an interface and so never
     # gets actually stored in the settings therefore the default value of
     # 20 will always be used.
     self.recent_spin_box.setMaximum(settings.value('max recent files'))
     self.recent_spin_box.setValue(settings.value('recent file count'))
     self.media_plugin_check_box.setChecked(settings.value('save current plugin'))
     self.double_click_live_check_box.setChecked(settings.value('double click live'))
     self.single_click_preview_check_box.setChecked(settings.value('single click preview'))
     self.expand_service_item_check_box.setChecked(settings.value('expand service item'))
     self.enable_auto_close_check_box.setChecked(settings.value('enable exit confirmation'))
     self.hide_mouse_check_box.setChecked(settings.value('hide mouse'))
     self.service_name_day.setCurrentIndex(settings.value('default service day'))
     self.service_name_time.setTime(QtCore.QTime(settings.value('default service hour'),
                                                 settings.value('default service minute')))
     self.should_update_service_name_example = True
     self.service_name_edit.setText(settings.value('default service name'))
     default_service_enabled = settings.value('default service enabled')
     self.service_name_check_box.setChecked(default_service_enabled)
     self.service_name_check_box_toggled(default_service_enabled)
     self.x11_bypass_check_box.setChecked(settings.value('x11 bypass wm'))
     self.default_color = settings.value('default color')
     self.default_file_edit.setText(settings.value('default image'))
     self.slide_limits = settings.value('slide limits')
     self.is_search_as_you_type_enabled = settings.value('search as type')
     self.search_as_type_check_box.setChecked(self.is_search_as_you_type_enabled)
     # Prevent the dialog displayed by the alternate_rows_check_box to display.
     self.alternate_rows_check_box.blockSignals(True)
     self.alternate_rows_check_box.setChecked(settings.value('alternate rows'))
     self.alternate_rows_check_box.blockSignals(False)
     if self.slide_limits == SlideLimits.End:
         self.end_slide_radio_button.setChecked(True)
     elif self.slide_limits == SlideLimits.Wrap:
         self.wrap_slide_radio_button.setChecked(True)
     else:
         self.next_item_radio_button.setChecked(True)
     settings.endGroup()
     self.data_directory_copy_check_box.hide()
     self.new_data_directory_has_files_label.hide()
     self.data_directory_cancel_button.hide()
     # Since data location can be changed, make sure the path is present.
     self.current_data_path = AppLocation.get_data_path()
     if not os.path.exists(self.current_data_path):
         log.error('Data path not found %s' % self.current_data_path)
         answer = QtWidgets.QMessageBox.critical(
             self, translate('OpenLP.AdvancedTab', 'Data Directory Error'),
             translate('OpenLP.AdvancedTab', 'OpenLP data directory was not found\n\n%s\n\n'
                       'This data directory was previously changed from the OpenLP '
                       'default location.  If the new location was on removable '
                       'media, that media needs to be made available.\n\n'
                       'Click "No" to stop loading OpenLP. allowing you to fix the the problem.\n\n'
                       'Click "Yes" to reset the data directory to the default '
                       'location.').replace('%s', self.current_data_path),
             QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No),
             QtWidgets.QMessageBox.No)
         if answer == QtWidgets.QMessageBox.No:
             log.info('User requested termination')
             self.main_window.clean_up()
             sys.exit()
         # Set data location to default.
         settings.remove('advanced/data path')
         self.current_data_path = AppLocation.get_data_path()
         log.warning('User requested data path set to default %s' % self.current_data_path)
     self.data_directory_label.setText(os.path.abspath(self.current_data_path))
     self.default_color_button.color = self.default_color
     # Don't allow data directory move if running portable.
     if settings.value('advanced/is portable'):
         self.data_directory_group_box.hide()
예제 #16
0
 def load(self):
     """
     Load settings from disk.
     """
     settings = Settings()
     settings.beginGroup(self.settings_section)
     # The max recent files value does not have an interface and so never
     # gets actually stored in the settings therefore the default value of
     # 20 will always be used.
     self.recent_spin_box.setMaximum(settings.value('max recent files'))
     self.recent_spin_box.setValue(settings.value('recent file count'))
     self.media_plugin_check_box.setChecked(settings.value('save current plugin'))
     self.double_click_live_check_box.setChecked(settings.value('double click live'))
     self.single_click_preview_check_box.setChecked(settings.value('single click preview'))
     self.expand_service_item_check_box.setChecked(settings.value('expand service item'))
     self.enable_auto_close_check_box.setChecked(settings.value('enable exit confirmation'))
     self.hide_mouse_check_box.setChecked(settings.value('hide mouse'))
     self.service_name_day.setCurrentIndex(settings.value('default service day'))
     self.service_name_time.setTime(QtCore.QTime(settings.value('default service hour'),
                                                 settings.value('default service minute')))
     self.should_update_service_name_example = True
     self.service_name_edit.setText(settings.value('default service name'))
     default_service_enabled = settings.value('default service enabled')
     self.service_name_check_box.setChecked(default_service_enabled)
     self.service_name_check_box_toggled(default_service_enabled)
     self.x11_bypass_check_box.setChecked(settings.value('x11 bypass wm'))
     self.default_color = settings.value('default color')
     self.default_file_edit.setText(settings.value('default image'))
     self.slide_limits = settings.value('slide limits')
     # Prevent the dialog displayed by the alternate_rows_check_box to display.
     self.alternate_rows_check_box.blockSignals(True)
     self.alternate_rows_check_box.setChecked(settings.value('alternate rows'))
     self.alternate_rows_check_box.blockSignals(False)
     if self.slide_limits == SlideLimits.End:
         self.end_slide_radio_button.setChecked(True)
     elif self.slide_limits == SlideLimits.Wrap:
         self.wrap_slide_radio_button.setChecked(True)
     else:
         self.next_item_radio_button.setChecked(True)
     settings.endGroup()
     self.data_directory_copy_check_box.hide()
     self.new_data_directory_has_files_label.hide()
     self.data_directory_cancel_button.hide()
     # Since data location can be changed, make sure the path is present.
     self.current_data_path = AppLocation.get_data_path()
     if not os.path.exists(self.current_data_path):
         log.error('Data path not found %s' % self.current_data_path)
         answer = QtGui.QMessageBox.critical(
             self, translate('OpenLP.AdvancedTab', 'Data Directory Error'),
             translate('OpenLP.AdvancedTab', 'OpenLP data directory was not found\n\n%s\n\n'
                       'This data directory was previously changed from the OpenLP '
                       'default location.  If the new location was on removable '
                       'media, that media needs to be made available.\n\n'
                       'Click "No" to stop loading OpenLP. allowing you to fix the the problem.\n\n'
                       'Click "Yes" to reset the data directory to the default '
                       'location.').replace('%s', self.current_data_path),
             QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
             QtGui.QMessageBox.No)
         if answer == QtGui.QMessageBox.No:
             log.info('User requested termination')
             self.main_window.clean_up()
             sys.exit()
         # Set data location to default.
         settings.remove('advanced/data path')
         self.current_data_path = AppLocation.get_data_path()
         log.warning('User requested data path set to default %s' % self.current_data_path)
     self.data_directory_label.setText(os.path.abspath(self.current_data_path))
     self.default_color_button.color = self.default_color
     # Don't allow data directory move if running portable.
     if settings.value('advanced/is portable'):
         self.data_directory_group_box.hide()