def accept(self): """ Lets save the theme as Finish has been triggered """ # Save the theme name self.theme.theme_name = self.field('name') if not self.theme.theme_name: critical_error_message_box( translate('OpenLP.ThemeWizard', 'Theme Name Missing'), translate('OpenLP.ThemeWizard', 'There is no name for this theme. Please enter one.')) return if self.theme.theme_name == '-1' or self.theme.theme_name == 'None': critical_error_message_box( translate('OpenLP.ThemeWizard', 'Theme Name Invalid'), translate('OpenLP.ThemeWizard', 'Invalid theme name. Please enter one.')) return save_from = None save_to = None if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) or \ self.theme.background_type == BackgroundType.to_string(BackgroundType.Video): filename = os.path.split(str(self.theme.background_filename))[1] save_to = os.path.join(self.path, self.theme.theme_name, filename) save_from = self.theme.background_filename if not self.edit_mode and not self.theme_manager.check_if_theme_exists(self.theme.theme_name): return self.theme_manager.save_theme(self.theme, save_from, save_to) return QtWidgets.QDialog.accept(self)
def build_background_css(item, width, height): """ Build the background css ``item`` Service Item containing theme and location information """ width = int(width) / 2 theme = item.themedata background = u'background-color: black' if theme: if theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): background = u'' elif theme.background_type == BackgroundType.to_string(BackgroundType.Solid): background = u'background-color: %s' % theme.background_color else: if theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): background = u'background: -webkit-gradient(linear, left top, left bottom, from(%s), to(%s)) fixed' \ % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftTop): background = u'background: -webkit-gradient(linear, left top, right bottom, from(%s), to(%s)) fixed' \ % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftBottom): background = u'background: -webkit-gradient(linear, left bottom, right top, from(%s), to(%s)) fixed' \ % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Vertical): background = u'background: -webkit-gradient(linear, left top, right top, from(%s), to(%s)) fixed' % \ (theme.background_start_color, theme.background_end_color) else: background = u'background: -webkit-gradient(radial, %s 50%%, 100, %s 50%%, %s, from(%s), to(%s)) fixed'\ % (width, width, width, theme.background_start_color, theme.background_end_color) return background
def get_theme_data(self, theme_level=None): """ Get the theme appropriate for this item :param theme_level: The theme_level to use, the value in Settings is used when this value is missinig """ if theme_level is None: theme_level = self.settings.value('themes/theme level') theme_manager = Registry().get('theme_manager') # Just assume we use the global theme. theme = theme_manager.global_theme if theme_level != ThemeLevel.Global: service_theme = self.settings.value('servicemanager/service theme') # Service or Song level, so assume service theme (if it exists and item in service) # but use song theme if level is song (and it exists) if service_theme and self.from_service: theme = service_theme if theme_level == ThemeLevel.Song and self.theme: theme = self.theme theme = theme_manager.get_theme_data(theme) # Clean up capabilities and reload from the theme. if self.is_text(): if self.is_capable(ItemCapabilities.CanStream): self.remove_capability(ItemCapabilities.CanStream) if self.is_capable(ItemCapabilities.HasBackgroundVideo): self.remove_capability(ItemCapabilities.HasBackgroundVideo) if theme.background_type == BackgroundType.to_string(BackgroundType.Stream): self.add_capability(ItemCapabilities.CanStream) if theme.background_type == BackgroundType.to_string(BackgroundType.Video): self.video_file_name = theme.background_filename self.add_capability(ItemCapabilities.HasBackgroundVideo) return theme
def set_background_page_values(self): """ Handle the display and state of the Background page. """ if self.theme.background_type == BackgroundType.to_string( BackgroundType.Solid): self.color_button.color = self.theme.background_color self.setField('background_type', 0) elif self.theme.background_type == BackgroundType.to_string( BackgroundType.Gradient): self.gradient_start_button.color = self.theme.background_start_color self.gradient_end_button.color = self.theme.background_end_color self.setField('background_type', 1) elif self.theme.background_type == BackgroundType.to_string( BackgroundType.Image): self.image_color_button.color = self.theme.background_border_color self.image_file_edit.setText(self.theme.background_filename) self.setField('background_type', 2) elif self.theme.background_type == BackgroundType.to_string( BackgroundType.Transparent): self.setField('background_type', 3) if self.theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.Horizontal): self.setField('gradient', 0) elif self.theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.Vertical): self.setField('gradient', 1) elif self.theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.Circular): self.setField('gradient', 2) elif self.theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.LeftTop): self.setField('gradient', 3) else: self.setField('gradient', 4)
def build_background_css(item, width): """ Build the background css :param item: Service Item containing theme and location information :param width: """ width = int(width) // 2 theme = item.theme_data background = 'background-color: black' if theme: if theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): background = '' elif theme.background_type == BackgroundType.to_string(BackgroundType.Solid): background = 'background-color: {theme}'.format(theme=theme.background_color) else: if theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): background = 'background: -webkit-gradient(linear, left top, left bottom, from({start}), to({end})) ' \ 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftTop): background = 'background: -webkit-gradient(linear, left top, right bottom, from({start}), to({end})) ' \ 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftBottom): background = 'background: -webkit-gradient(linear, left bottom, right top, from({start}), to({end})) ' \ 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Vertical): background = 'background: -webkit-gradient(linear, left top, right top, from({start}), to({end})) ' \ 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) else: background = 'background: -webkit-gradient(radial, {width} 50%, 100, {width} 50%, {width}, ' \ 'from({start}), to({end})) fixed'.format(width=width, start=theme.background_start_color, end=theme.background_end_color) return background
def set_background_page_values(self): """ Handle the display and state of the Background page. """ if self.theme.background_type == BackgroundType.to_string(BackgroundType.Solid): self.color_button.color = self.theme.background_color self.setField('background_type', 0) elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Gradient): self.gradient_start_button.color = self.theme.background_start_color self.gradient_end_button.color = self.theme.background_end_color self.setField('background_type', 1) elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Image): self.image_color_button.color = self.theme.background_border_color self.image_file_edit.setText(self.theme.background_filename) self.setField('background_type', 2) elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Video): self.video_color_button.color = self.theme.background_border_color self.video_file_edit.setText(self.theme.background_filename) self.setField('background_type', 4) elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): self.setField('background_type', 3) if self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): self.setField('gradient', 0) elif self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Vertical): self.setField('gradient', 1) elif self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Circular): self.setField('gradient', 2) elif self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.LeftTop): self.setField('gradient', 3) else: self.setField('gradient', 4)
def accept(self): """ Lets save the theme as Finish has been triggered """ # Save the theme name self.theme.theme_name = self.theme_name_edit.text() if not self.theme.theme_name: critical_error_message_box( translate('OpenLP.ThemeWizard', 'Theme Name Missing'), translate( 'OpenLP.ThemeWizard', 'There is no name for this theme. Please enter one.')) return if self.theme.theme_name == '-1' or self.theme.theme_name == 'None': critical_error_message_box( translate('OpenLP.ThemeWizard', 'Theme Name Invalid'), translate('OpenLP.ThemeWizard', 'Invalid theme name. Please enter one.')) return destination_path = None if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) or \ self.theme.background_type == BackgroundType.to_string(BackgroundType.Video): file_name = self.theme.background_filename.name destination_path = self.path / self.theme.theme_name / file_name if not self.edit_mode and not self.theme_manager.check_if_theme_exists( self.theme.theme_name): return # Set the theme background to the cache location self.theme.background_filename = destination_path self.theme_manager.save_theme(self.theme, self.preview_box.save_screenshot()) return QtWidgets.QDialog.accept(self)
def set_background_page_values(self): """ Handle the display and state of the Background page. """ self.background_page.background_type = self.theme.background_type if self.theme.background_type == BackgroundType.to_string( BackgroundType.Solid): self.background_page.color = self.theme.background_color elif self.theme.background_type == BackgroundType.to_string( BackgroundType.Gradient): self.background_page.gradient_start = self.theme.background_start_color self.background_page.gradient_end = self.theme.background_end_color self.background_page.gradient_type = self.theme.background_direction elif self.theme.background_type == BackgroundType.to_string( BackgroundType.Image): self.background_page.image_color = self.theme.background_border_color if self.theme.background_source and self.theme.background_source.exists( ): self.background_page.image_path = self.theme.background_source else: self.background_page.image_path = self.theme.background_filename elif self.theme.background_type == BackgroundType.to_string( BackgroundType.Video): self.background_page.video_color = self.theme.background_border_color if self.theme.background_source and self.theme.background_source.exists( ): self.background_page.video_path = self.theme.background_source else: self.background_page.video_path = self.theme.background_filename
def on_background_combo_box_current_index_changed(self, index): """ Background style Combo box has changed. """ # do not allow updates when screen is building for the first time. if self.update_theme_allowed: self.theme.background_type = BackgroundType.to_string(index) if self.theme.background_type != BackgroundType.to_string(BackgroundType.Image) and \ self.temp_background_filename == '': self.temp_background_filename = self.theme.background_filename self.theme.background_filename = '' if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) and \ self.temp_background_filename != '': self.theme.background_filename = self.temp_background_filename self.temp_background_filename = '' self.set_background_page_values()
def background_type(self, value): if isinstance(value, str): self.background_combo_box.setCurrentIndex( BackgroundType.from_string(value)) elif isinstance(value, int): self.background_combo_box.setCurrentIndex(value) else: raise TypeError( 'background_type must either be a string or an int')
def build_html(self, service_item, image_path=''): """ Store the service_item and build the new HTML from it. Add the HTML to the display :param service_item: The Service item to be used :param image_path: Where the image resides. """ self.web_loaded = False self.initial_fame = None self.service_item = service_item background = None # We have an image override so keep the image till the theme changes. if self.override: # We have an video override so allow it to be stopped. if 'video' in self.override: Registry().execute('video_background_replaced') self.override = {} # We have a different theme. elif self.override['theme'] != service_item.theme_data.background_filename: Registry().execute('live_theme_changed') self.override = {} else: # replace the background background = self.image_manager.get_image_bytes(self.override['image'], ImageSource.ImagePlugin) self.set_transparency(self.service_item.theme_data.background_type == BackgroundType.to_string(BackgroundType.Transparent)) image_bytes = None if self.service_item.theme_data.background_type == 'image': if self.service_item.theme_data.background_filename: self.service_item.bg_image_bytes = self.image_manager.get_image_bytes( self.service_item.theme_data.background_filename, ImageSource.Theme) if image_path: image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin) created_html = build_html(self.service_item, self.screen, self.is_live, background, image_bytes, plugins=self.plugin_manager.plugins) self.web_view.setHtml(created_html) if service_item.foot_text: self.footer(service_item.foot_text) # if was hidden keep it hidden if self.hide_mode and self.is_live and not service_item.is_media(): if Settings().value('core/auto unblank'): Registry().execute('slidecontroller_live_unblank') else: self.hide_display(self.hide_mode) if self.service_item.theme_data.background_type == 'video' and self.is_live: if self.service_item.theme_data.background_filename: service_item = ServiceItem() service_item.title = 'webkit' service_item.processor = 'webkit' path = os.path.join(AppLocation.get_section_data_path('themes'), self.service_item.theme_data.theme_name) service_item.add_from_command(path, self.service_item.theme_data.background_filename, ':/media/slidecontroller_multimedia.png') self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True) self._hide_mouse()
def build_html(self, service_item, image_path=''): """ Store the service_item and build the new HTML from it. Add the HTML to the display :param service_item: The Service item to be used :param image_path: Where the image resides. """ self.web_loaded = False self.initial_fame = None self.service_item = service_item background = None # We have an image override so keep the image till the theme changes. if self.override: # We have an video override so allow it to be stopped. if 'video' in self.override: Registry().execute('video_background_replaced') self.override = {} # We have a different theme. elif self.override[ 'theme'] != service_item.theme_data.background_filename: Registry().execute('live_theme_changed') self.override = {} else: # replace the background background = self.image_manager.get_image_bytes( self.override['image'], ImageSource.ImagePlugin) self.set_transparency( self.service_item.theme_data.background_type == BackgroundType.to_string(BackgroundType.Transparent)) if self.service_item.theme_data.background_filename: self.service_item.bg_image_bytes = self.image_manager.get_image_bytes( self.service_item.theme_data.background_filename, ImageSource.Theme) if image_path: image_bytes = self.image_manager.get_image_bytes( image_path, ImageSource.ImagePlugin) else: image_bytes = None html = build_html(self.service_item, self.screen, self.is_live, background, image_bytes, plugins=self.plugin_manager.plugins) self.web_view.setHtml(html) if service_item.foot_text: self.footer(service_item.foot_text) # if was hidden keep it hidden if self.hide_mode and self.is_live and not service_item.is_media(): if Settings().value('core/auto unblank'): Registry().execute('slidecontroller_live_unblank') else: self.hide_display(self.hide_mode) self._hide_mouse()
def build_background_css(item, width): """ Build the background css :param item: Service Item containing theme and location information :param width: """ width = int(width) // 2 theme = item.theme_data background = 'background-color: black' if theme: if theme.background_type == BackgroundType.to_string( BackgroundType.Transparent): background = '' elif theme.background_type == BackgroundType.to_string( BackgroundType.Solid): background = 'background-color: {theme}'.format( theme=theme.background_color) else: if theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.Horizontal): background = 'background: -webkit-gradient(linear, left top, left bottom, from({start}), to({end})) ' \ 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.LeftTop): background = 'background: -webkit-gradient(linear, left top, right bottom, from({start}), to({end})) ' \ 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.LeftBottom): background = 'background: -webkit-gradient(linear, left bottom, right top, from({start}), to({end})) ' \ 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.Vertical): background = 'background: -webkit-gradient(linear, left top, right top, from({start}), to({end})) ' \ 'fixed'.format(start=theme.background_start_color, end=theme.background_end_color) else: background = 'background: -webkit-gradient(radial, {width} 50%, 100, {width} 50%, {width}, ' \ 'from({start}), to({end})) fixed'.format(width=width, start=theme.background_start_color, end=theme.background_end_color) return background
def test_background_type_from_string(self): """ Test the from_string method of :class:`BackgroundType` """ # GIVEN: The BackgroundType strings background_type_solid = 'solid' background_type_gradient = 'gradient' background_type_image = 'image' background_type_transparent = 'transparent' background_type_video = 'video' background_type_stream = 'stream' # WHEN: Calling BackgroundType.from_string # THEN: The enum equivalents should be returned assert BackgroundType.from_string( background_type_solid) == BackgroundType.Solid assert BackgroundType.from_string( background_type_gradient) == BackgroundType.Gradient assert BackgroundType.from_string( background_type_image) == BackgroundType.Image assert BackgroundType.from_string( background_type_transparent) == BackgroundType.Transparent assert BackgroundType.from_string( background_type_video) == BackgroundType.Video assert BackgroundType.from_string( background_type_stream) == BackgroundType.Stream
def validateCurrentPage(self): """ Validate the current page """ background_image = BackgroundType.to_string(BackgroundType.Image) if self.page(self.currentId()) == self.background_page and \ self.theme.background_type == background_image and is_not_image_file(self.theme.background_filename): QtWidgets.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'), translate('OpenLP.ThemeWizard', 'You have not selected a ' 'background image. Please select one before continuing.')) return False else: return True
def test_set_background_type_str(self): """ Test the background_type setter with a str """ # GIVEN: A BackgroundPage instance page = BackgroundPage() # WHEN: The property is set page.background_type = BackgroundType.to_string( BackgroundType.Gradient) # THEN: The combobox should be correct assert page.background_combo_box.currentIndex() == 1
def build_background_css(item, width): """ Build the background css :param item: Service Item containing theme and location information :param width: """ width = int(width) // 2 theme = item.theme_data background = 'background-color: black' if theme: if theme.background_type == BackgroundType.to_string( BackgroundType.Transparent): background = '' elif theme.background_type == BackgroundType.to_string( BackgroundType.Solid): background = 'background-color: %s' % theme.background_color else: if theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.Horizontal): background = 'background: -webkit-gradient(linear, left top, left bottom, from(%s), to(%s)) fixed' \ % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.LeftTop): background = 'background: -webkit-gradient(linear, left top, right bottom, from(%s), to(%s)) fixed' \ % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.LeftBottom): background = 'background: -webkit-gradient(linear, left bottom, right top, from(%s), to(%s)) fixed' \ % (theme.background_start_color, theme.background_end_color) elif theme.background_direction == BackgroundGradientType.to_string( BackgroundGradientType.Vertical): background = 'background: -webkit-gradient(linear, left top, right top, from(%s), to(%s)) fixed' % \ (theme.background_start_color, theme.background_end_color) else: background = 'background: -webkit-gradient(radial, %s 50%%, 100, %s 50%%, %s, from(%s), to(%s)) fixed'\ % (width, width, width, theme.background_start_color, theme.background_end_color) return background
def save_theme(self, theme, image_from, image_to): """ Called by theme maintenance Dialog to save the theme and to trigger the reload of the theme list :param theme: The theme data object. :param image_from: Where the theme image is currently located. :param image_to: Where the Theme Image is to be saved to """ self._write_theme(theme, image_from, image_to) if theme.background_type == BackgroundType.to_string(BackgroundType.Image): self.image_manager.update_image_border(theme.background_filename, ImageSource.Theme, QtGui.QColor(theme.background_border_color)) self.image_manager.process_updates()
def save_theme(self, theme, image_source_path, image_destination_path): """ Called by theme maintenance Dialog to save the theme and to trigger the reload of the theme list :param Theme theme: The theme data object. :param openlp.core.common.path.Path image_source_path: Where the theme image is currently located. :param openlp.core.common.path.Path image_destination_path: Where the Theme Image is to be saved to :rtype: None """ self._write_theme(theme, image_source_path, image_destination_path) if theme.background_type == BackgroundType.to_string(BackgroundType.Image): self.image_manager.update_image_border(path_to_str(theme.background_filename), ImageSource.Theme, QtGui.QColor(theme.background_border_color)) self.image_manager.process_updates()
def save_theme(self, theme, image_from, image_to): """ Called by theme maintenance Dialog to save the theme and to trigger the reload of the theme list :param theme: The theme data object. :param image_from: Where the theme image is currently located. :param image_to: Where the Theme Image is to be saved to """ self._write_theme(theme, image_from, image_to) if theme.background_type == BackgroundType.to_string( BackgroundType.Image): self.image_manager.update_image_border( theme.background_filename, ImageSource.Theme, QtGui.QColor(theme.background_border_color)) self.image_manager.process_updates()
def build_html(self, service_item, image_path=''): """ Store the service_item and build the new HTML from it. Add the HTML to the display """ log.debug('build_html') self.web_loaded = False self.initial_fame = None self.service_item = service_item background = None # We have an image override so keep the image till the theme changes. if self.override: # We have an video override so allow it to be stopped. if 'video' in self.override: Registry().execute('video_background_replaced') self.override = {} # We have a different theme. elif self.override['theme'] != service_item.themedata.background_filename: Registry().execute('live_theme_changed') self.override = {} else: # replace the background background = self.image_manager.get_image_bytes(self.override['image'], ImageSource.ImagePlugin) self.set_transparency(self.service_item.themedata.background_type == BackgroundType.to_string(BackgroundType.Transparent)) if self.service_item.themedata.background_filename: self.service_item.bg_image_bytes = self.image_manager.get_image_bytes( self.service_item.themedata.background_filename, ImageSource.Theme ) if image_path: image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin) else: image_bytes = None html = build_html(self.service_item, self.screen, self.is_live, background, image_bytes, plugins=self.plugin_manager.plugins) log.debug('buildHtml - pre setHtml') self.web_view.setHtml(html) log.debug('buildHtml - post setHtml') if service_item.foot_text: self.footer(service_item.foot_text) # if was hidden keep it hidden if self.hide_mode and self.is_live and not service_item.is_media(): if Settings().value('core/auto unblank'): Registry().execute('slidecontroller_live_unblank') else: self.hide_display(self.hide_mode) self.__hideMouse()
def test_validate_current_page_with_image(self, mocked_setup, mocked_is_not_image_file, mocked_critical): """ Test the validateCurrentPage() method """ # GIVEN: An instance of ThemeForm with some mocks theme_form = ThemeForm(None) theme_form.background_page = MagicMock( background_type=BackgroundType.to_string(BackgroundType.Image), image_path=Path('picture.jpg')) theme_form.page = MagicMock(return_value=theme_form.background_page) mocked_is_not_image_file.return_value = True # WHEN: validateCurrentPage() is called result = theme_form.validateCurrentPage() # THEN: The right methods were called, and the result is False mocked_critical.assert_called_once_with( theme_form, 'Background Image Empty', 'You have not selected a background image. ' 'Please select one before continuing.') assert result is False
def test_background_type_to_string(self): """ Test the to_string method of :class:`BackgroundType` """ # GIVEN: The BackgroundType members background_type_solid = BackgroundType.Solid background_type_gradient = BackgroundType.Gradient background_type_image = BackgroundType.Image background_type_transparent = BackgroundType.Transparent background_type_video = BackgroundType.Video background_type_stream = BackgroundType.Stream # WHEN: Calling BackgroundType.to_string # THEN: The string equivalents should be returned assert BackgroundType.to_string(background_type_solid) == 'solid' assert BackgroundType.to_string(background_type_gradient) == 'gradient' assert BackgroundType.to_string(background_type_image) == 'image' assert BackgroundType.to_string( background_type_transparent) == 'transparent' assert BackgroundType.to_string(background_type_video) == 'video' assert BackgroundType.to_string(background_type_stream) == 'stream'
def update_theme(self): """ Update the theme object from the UI for fields not already updated when the are changed. """ if not self.can_update_theme: return log.debug('update_theme') # background page self.theme.background_type = self.background_page.background_type if self.theme.background_type == BackgroundType.to_string( BackgroundType.Solid): self.theme.background_color = self.background_page.color elif self.theme.background_type == BackgroundType.to_string( BackgroundType.Gradient): self.theme.background_direction = self.background_page.gradient_type self.theme.background_start_color = self.background_page.gradient_start self.theme.background_end_color = self.background_page.gradient_end elif self.theme.background_type == BackgroundType.to_string( BackgroundType.Image): self.theme.background_border_color = self.background_page.image_color self.theme.background_source = self.background_page.image_path self.theme.background_filename = self.background_page.image_path elif self.theme.background_type == BackgroundType.to_string( BackgroundType.Video): self.theme.background_border_color = self.background_page.video_color self.theme.background_source = self.background_page.video_path self.theme.background_filename = self.background_page.video_path # main page self.theme.font_main_name = self.main_area_page.font_name self.theme.font_main_size = self.main_area_page.font_size self.theme.font_main_line_adjustment = self.main_area_page.line_spacing self.theme.font_main_outline_size = self.main_area_page.outline_size self.theme.font_main_shadow_size = self.main_area_page.shadow_size self.theme.font_main_bold = self.main_area_page.is_bold self.theme.font_main_italics = self.main_area_page.is_italic # footer page self.theme.font_footer_name = self.footer_area_page.font_name self.theme.font_footer_size = self.footer_area_page.font_size # position page (main) self.theme.font_main_override = not self.area_position_page.use_main_default_location if self.theme.font_main_override: self.theme.font_main_x = self.area_position_page.main_x self.theme.font_main_y = self.area_position_page.main_y self.theme.font_main_height = self.area_position_page.main_height self.theme.font_main_width = self.area_position_page.main_width else: self.theme.set_default_header() # position page (footer) self.theme.font_footer_override = not self.area_position_page.use_footer_default_location if self.theme.font_footer_override: self.theme.font_footer_x = self.area_position_page.footer_x self.theme.font_footer_y = self.area_position_page.footer_y self.theme.font_footer_height = self.area_position_page.footer_height self.theme.font_footer_width = self.area_position_page.footer_width else: self.theme.set_default_footer() # alignment page self.theme.display_horizontal_align = self.alignment_page.horizontal_align self.theme.display_vertical_align = self.alignment_page.vertical_align self.theme.display_slide_transition = self.alignment_page.is_transition_enabled self.theme.display_slide_transition_type = self.alignment_page.transition_type self.theme.display_slide_transition_speed = self.alignment_page.transition_speed self.theme.display_slide_transition_direction = self.alignment_page.transition_direction self.theme.display_slide_transition_reverse = self.alignment_page.is_transition_reverse_enabled
def build_html(self, service_item, image_path=''): """ Store the service_item and build the new HTML from it. Add the HTML to the display :param service_item: The Service item to be used :param image_path: Where the image resides. """ self.web_loaded = False self.initial_fame = None self.service_item = service_item background = None # We have an image override so keep the image till the theme changes. if self.override: # We have an video override so allow it to be stopped. if 'video' in self.override: Registry().execute('video_background_replaced') self.override = {} # We have a different theme. elif self.override['theme'] != path_to_str( service_item.theme_data.background_filename): Registry().execute('live_theme_changed') self.override = {} else: # replace the background background = self.image_manager.get_image_bytes( self.override['image'], ImageSource.ImagePlugin) self.set_transparency( self.service_item.theme_data.background_type == BackgroundType.to_string(BackgroundType.Transparent)) image_bytes = None if self.service_item.theme_data.background_type == 'image': if self.service_item.theme_data.background_filename: self.service_item.bg_image_bytes = self.image_manager.get_image_bytes( path_to_str( self.service_item.theme_data.background_filename), ImageSource.Theme) if image_path: image_bytes = self.image_manager.get_image_bytes( image_path, ImageSource.ImagePlugin) created_html = build_html(self.service_item, self.screen, self.is_live, background, image_bytes, plugins=self.plugin_manager.plugins) self.web_view.setHtml(created_html) if service_item.foot_text: self.footer(service_item.foot_text) # if was hidden keep it hidden if self.hide_mode and self.is_live and not service_item.is_media(): if Settings().value('core/auto unblank'): Registry().execute('slidecontroller_live_unblank') else: self.hide_display(self.hide_mode) if self.service_item.theme_data.background_type == 'video' and self.is_live: if self.service_item.theme_data.background_filename: service_item = ServiceItem() service_item.title = 'webkit' service_item.processor = 'webkit' path = str( AppLocation.get_section_data_path('themes') / self.service_item.theme_data.theme_name) service_item.add_from_command( path, path_to_str( self.service_item.theme_data.background_filename), UiIcons().media) self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True) self._hide_mouse()
def background_type(self): return BackgroundType.to_string( self.background_combo_box.currentIndex())