diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 35b62ddda..70517b34d 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -261,7 +261,7 @@ class ThemeXML(object): def add_font(self, name, color, size, override, fonttype=u'main', bold=u'False', italics=u'False', line_adjustment=0, xpos=0, ypos=0, width=0, height=0 , outline=u'False', - outline_color=u'#ffffff', outline_pixel=2, shadow=u'False', + outline_color=u'#ffffff', outline_pixel=2, shadow=u'False', shadow_color=u'#ffffff', shadow_pixel=5): """ Add a Font. diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index b0280f19b..cfad9cd91 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -138,11 +138,10 @@ class MainDisplay(DisplayWidget): painter_image.begin(initialFrame) painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white) painter_image.drawImage( - (self.screens.current[u'size'].width() \ - - splash_image.width()) / 2, - (self.screens.current[u'size'].height() \ - - splash_image.height()) / 2, - splash_image) + (self.screens.current[u'size'].width() - + splash_image.width()) / 2, + (self.screens.current[u'size'].height() + - splash_image.height()) / 2, splash_image) serviceItem = ServiceItem() serviceItem.bg_image_bytes = image_to_byte(initialFrame) self.webView.setHtml(build_html(serviceItem, self.screen, @@ -243,7 +242,10 @@ class MainDisplay(DisplayWidget): Used after Image plugin has changed the background """ log.debug(u'resetImage') - self.displayImage(self.serviceItem.bg_image_bytes) + if hasattr(self, u'serviceItem'): + self.displayImage(self.serviceItem.bg_image_bytes) + else: + self.displayImage(None) # Update the preview frame. Receiver.send_message(u'maindisplay_active') @@ -345,13 +347,11 @@ class MainDisplay(DisplayWidget): Generates a preview of the image displayed. """ log.debug(u'preview for %s', self.isLive) - # We must have a service item to preview - if not hasattr(self, u'serviceItem'): - return Receiver.send_message(u'openlp_process_events') - if self.isLive: + # We must have a service item to preview + if self.isLive and hasattr(self, u'serviceItem'): # Wait for the fade to finish before geting the preview. - # Important otherwise preview will have incorrect text if at all ! + # Important otherwise preview will have incorrect text if at all! if self.serviceItem.themedata and \ self.serviceItem.themedata.display_slide_transition: while self.frame.evaluateJavaScript(u'show_text_complete()') \ @@ -364,9 +364,8 @@ class MainDisplay(DisplayWidget): # if was hidden keep it hidden if self.isLive: self.setVisible(True) - # if was hidden keep it hidden - if self.hideMode and self.isLive: - self.hideDisplay(self.hideMode) + if self.hideMode: + self.hideDisplay(self.hideMode) preview = QtGui.QImage(self.screen[u'size'].width(), self.screen[u'size'].height(), QtGui.QImage.Format_ARGB32_Premultiplied) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 1941e97e8..7266d197c 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -783,6 +783,7 @@ class SlideController(QtGui.QWidget): QtCore.QSettings().remove( self.parent.generalSettingsSection + u'/screen blank') self.blankPlugin(checked) + self.updatePreview() def onThemeDisplay(self, checked): """ @@ -804,6 +805,7 @@ class SlideController(QtGui.QWidget): QtCore.QSettings().remove( self.parent.generalSettingsSection + u'/screen blank') self.blankPlugin(checked) + self.updatePreview() def onHideDisplay(self, checked): """ @@ -827,6 +829,7 @@ class SlideController(QtGui.QWidget): QtCore.QSettings().remove( self.parent.generalSettingsSection + u'/screen blank') self.hidePlugin(checked) + self.updatePreview() def blankPlugin(self, blank): """ @@ -896,7 +899,11 @@ class SlideController(QtGui.QWidget): row) def updatePreview(self): - log.debug(u'updatePreview %s ' %self.screens.current[u'primary']) + """ + This updates the preview frame, for example after changing a slide or + using *Blank to Theme*. + """ + log.debug(u'updatePreview %s ' % self.screens.current[u'primary']) if not self.screens.current[u'primary']: # Grab now, but try again in a couple of seconds if slide change # is slow @@ -907,6 +914,9 @@ class SlideController(QtGui.QWidget): QtGui.QPixmap.fromImage(self.display.preview())) def grabMainDisplay(self): + """ + Creates an image of the current screen and updates the preview frame. + """ winid = QtGui.QApplication.desktop().winId() rect = self.screens.current[u'size'] winimg = QtGui.QPixmap.grabWindow(winid, rect.x(), diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index be5b2813b..9dd133852 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -123,18 +123,6 @@ class AppLocation(object): return _get_frozen_path( os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0]) - elif dir_type == AppLocation.ConfigDir: - return _get_os_dir_path(u'openlp', - os.path.join(os.getenv(u'HOME'), u'Library', - u'Application Support', u'openlp'), - os.path.join(BaseDirectory.xdg_config_home, u'openlp'), - os.path.join(os.getenv(u'HOME'), u'.openlp')) - elif dir_type == AppLocation.DataDir: - return _get_os_dir_path(os.path.join(u'openlp', u'data'), - os.path.join(os.getenv(u'HOME'), u'Library', - u'Application Support', u'openlp', u'Data'), - os.path.join(BaseDirectory.xdg_data_home, u'openlp'), - os.path.join(os.getenv(u'HOME'), u'.openlp', u'data')) elif dir_type == AppLocation.PluginsDir: app_path = os.path.abspath(os.path.split(sys.argv[0])[0]) return _get_frozen_path(os.path.join(app_path, u'plugins'), @@ -143,17 +131,16 @@ class AppLocation(object): return _get_frozen_path( os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0]) - elif dir_type == AppLocation.CacheDir: - return _get_os_dir_path(u'openlp', - os.path.join(os.getenv(u'HOME'), u'Library', - u'Application Support', u'openlp'), - os.path.join(BaseDirectory.xdg_cache_home, u'openlp'), - os.path.join(os.getenv(u'HOME'), u'.openlp')) - if dir_type == AppLocation.LanguageDir: + elif dir_type == AppLocation.LanguageDir: app_path = _get_frozen_path( os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0]) return os.path.join(app_path, u'i18n') + else: + return _get_os_dir_path(u'openlp', + os.path.join(os.getenv(u'HOME'), u'Library', + u'Application Support', u'openlp'), + None, os.path.join(os.getenv(u'HOME'), u'.openlp'), dir_type) @staticmethod def get_data_path(): @@ -177,17 +164,24 @@ class AppLocation(object): return path def _get_os_dir_path(win_option, darwin_option, base_dir_option, - non_base_dir_option): + non_base_dir_option, dir_type=1): """ Return a path based on which OS and environment we are running in. """ if sys.platform == u'win32': return os.path.join(os.getenv(u'APPDATA'), win_option) elif sys.platform == u'darwin': + if dir_type == AppLocation.DataDir: + return os.path.join(darwin_option, u'Data') return darwin_option else: if XDG_BASE_AVAILABLE: - return base_dir_option + if dir_type == AppLocation.ConfigDir: + return os.path.join(BaseDirectory.xdg_config_home, u'openlp') + elif dir_type == AppLocation.DataDir: + return os.path.join(BaseDirectory.xdg_data_home, u'openlp') + elif dir_type == AppLocation.CacheDir: + return os.path.join(BaseDirectory.xdg_cache_home, u'openlp') else: return non_base_dir_option