def setup(self): """ Set up and build the output screen """ self.log_debug('Start MainDisplay setup (live = %s)' % self.is_live) self.screen = self.screens.current self.setVisible(False) Display.setup(self) if self.is_live: # Build the initial frame. background_color = QtGui.QColor() background_color.setNamedColor(Settings().value('advanced/default color')) if not background_color.isValid(): background_color = QtCore.Qt.white image_file = Settings().value('advanced/default image') splash_image = QtGui.QImage(image_file) self.initial_fame = QtGui.QImage( self.screen['size'].width(), self.screen['size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied) painter_image = QtGui.QPainter() painter_image.begin(self.initial_fame) painter_image.fillRect(self.initial_fame.rect(), background_color) painter_image.drawImage( (self.screen['size'].width() - splash_image.width()) // 2, (self.screen['size'].height() - splash_image.height()) // 2, splash_image) service_item = ServiceItem() service_item.bg_image_bytes = image_to_byte(self.initial_fame) self.web_view.setHtml(build_html(service_item, self.screen, self.is_live, None, plugins=self.plugin_manager.plugins)) 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)) 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_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 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()