forked from openlp/openlp
r1242
This commit is contained in:
commit
e3a78c4d83
@ -261,7 +261,7 @@ class ThemeXML(object):
|
|||||||
def add_font(self, name, color, size, override, fonttype=u'main',
|
def add_font(self, name, color, size, override, fonttype=u'main',
|
||||||
bold=u'False', italics=u'False', line_adjustment=0,
|
bold=u'False', italics=u'False', line_adjustment=0,
|
||||||
xpos=0, ypos=0, width=0, height=0 , outline=u'False',
|
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):
|
shadow_color=u'#ffffff', shadow_pixel=5):
|
||||||
"""
|
"""
|
||||||
Add a Font.
|
Add a Font.
|
||||||
|
@ -138,11 +138,10 @@ class MainDisplay(DisplayWidget):
|
|||||||
painter_image.begin(initialFrame)
|
painter_image.begin(initialFrame)
|
||||||
painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white)
|
painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white)
|
||||||
painter_image.drawImage(
|
painter_image.drawImage(
|
||||||
(self.screens.current[u'size'].width() \
|
(self.screens.current[u'size'].width() -
|
||||||
- splash_image.width()) / 2,
|
splash_image.width()) / 2,
|
||||||
(self.screens.current[u'size'].height() \
|
(self.screens.current[u'size'].height()
|
||||||
- splash_image.height()) / 2,
|
- splash_image.height()) / 2, splash_image)
|
||||||
splash_image)
|
|
||||||
serviceItem = ServiceItem()
|
serviceItem = ServiceItem()
|
||||||
serviceItem.bg_image_bytes = image_to_byte(initialFrame)
|
serviceItem.bg_image_bytes = image_to_byte(initialFrame)
|
||||||
self.webView.setHtml(build_html(serviceItem, self.screen,
|
self.webView.setHtml(build_html(serviceItem, self.screen,
|
||||||
@ -243,7 +242,10 @@ class MainDisplay(DisplayWidget):
|
|||||||
Used after Image plugin has changed the background
|
Used after Image plugin has changed the background
|
||||||
"""
|
"""
|
||||||
log.debug(u'resetImage')
|
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.
|
# Update the preview frame.
|
||||||
Receiver.send_message(u'maindisplay_active')
|
Receiver.send_message(u'maindisplay_active')
|
||||||
|
|
||||||
@ -345,13 +347,11 @@ class MainDisplay(DisplayWidget):
|
|||||||
Generates a preview of the image displayed.
|
Generates a preview of the image displayed.
|
||||||
"""
|
"""
|
||||||
log.debug(u'preview for %s', self.isLive)
|
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')
|
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.
|
# 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 \
|
if self.serviceItem.themedata and \
|
||||||
self.serviceItem.themedata.display_slide_transition:
|
self.serviceItem.themedata.display_slide_transition:
|
||||||
while self.frame.evaluateJavaScript(u'show_text_complete()') \
|
while self.frame.evaluateJavaScript(u'show_text_complete()') \
|
||||||
@ -364,9 +364,8 @@ class MainDisplay(DisplayWidget):
|
|||||||
# if was hidden keep it hidden
|
# if was hidden keep it hidden
|
||||||
if self.isLive:
|
if self.isLive:
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
# if was hidden keep it hidden
|
if self.hideMode:
|
||||||
if self.hideMode and self.isLive:
|
self.hideDisplay(self.hideMode)
|
||||||
self.hideDisplay(self.hideMode)
|
|
||||||
preview = QtGui.QImage(self.screen[u'size'].width(),
|
preview = QtGui.QImage(self.screen[u'size'].width(),
|
||||||
self.screen[u'size'].height(),
|
self.screen[u'size'].height(),
|
||||||
QtGui.QImage.Format_ARGB32_Premultiplied)
|
QtGui.QImage.Format_ARGB32_Premultiplied)
|
||||||
|
@ -783,6 +783,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
QtCore.QSettings().remove(
|
QtCore.QSettings().remove(
|
||||||
self.parent.generalSettingsSection + u'/screen blank')
|
self.parent.generalSettingsSection + u'/screen blank')
|
||||||
self.blankPlugin(checked)
|
self.blankPlugin(checked)
|
||||||
|
self.updatePreview()
|
||||||
|
|
||||||
def onThemeDisplay(self, checked):
|
def onThemeDisplay(self, checked):
|
||||||
"""
|
"""
|
||||||
@ -804,6 +805,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
QtCore.QSettings().remove(
|
QtCore.QSettings().remove(
|
||||||
self.parent.generalSettingsSection + u'/screen blank')
|
self.parent.generalSettingsSection + u'/screen blank')
|
||||||
self.blankPlugin(checked)
|
self.blankPlugin(checked)
|
||||||
|
self.updatePreview()
|
||||||
|
|
||||||
def onHideDisplay(self, checked):
|
def onHideDisplay(self, checked):
|
||||||
"""
|
"""
|
||||||
@ -827,6 +829,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
QtCore.QSettings().remove(
|
QtCore.QSettings().remove(
|
||||||
self.parent.generalSettingsSection + u'/screen blank')
|
self.parent.generalSettingsSection + u'/screen blank')
|
||||||
self.hidePlugin(checked)
|
self.hidePlugin(checked)
|
||||||
|
self.updatePreview()
|
||||||
|
|
||||||
def blankPlugin(self, blank):
|
def blankPlugin(self, blank):
|
||||||
"""
|
"""
|
||||||
@ -896,7 +899,11 @@ class SlideController(QtGui.QWidget):
|
|||||||
row)
|
row)
|
||||||
|
|
||||||
def updatePreview(self):
|
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']:
|
if not self.screens.current[u'primary']:
|
||||||
# Grab now, but try again in a couple of seconds if slide change
|
# Grab now, but try again in a couple of seconds if slide change
|
||||||
# is slow
|
# is slow
|
||||||
@ -907,6 +914,9 @@ class SlideController(QtGui.QWidget):
|
|||||||
QtGui.QPixmap.fromImage(self.display.preview()))
|
QtGui.QPixmap.fromImage(self.display.preview()))
|
||||||
|
|
||||||
def grabMainDisplay(self):
|
def grabMainDisplay(self):
|
||||||
|
"""
|
||||||
|
Creates an image of the current screen and updates the preview frame.
|
||||||
|
"""
|
||||||
winid = QtGui.QApplication.desktop().winId()
|
winid = QtGui.QApplication.desktop().winId()
|
||||||
rect = self.screens.current[u'size']
|
rect = self.screens.current[u'size']
|
||||||
winimg = QtGui.QPixmap.grabWindow(winid, rect.x(),
|
winimg = QtGui.QPixmap.grabWindow(winid, rect.x(),
|
||||||
|
@ -123,18 +123,6 @@ class AppLocation(object):
|
|||||||
return _get_frozen_path(
|
return _get_frozen_path(
|
||||||
os.path.abspath(os.path.split(sys.argv[0])[0]),
|
os.path.abspath(os.path.split(sys.argv[0])[0]),
|
||||||
os.path.split(openlp.__file__)[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:
|
elif dir_type == AppLocation.PluginsDir:
|
||||||
app_path = os.path.abspath(os.path.split(sys.argv[0])[0])
|
app_path = os.path.abspath(os.path.split(sys.argv[0])[0])
|
||||||
return _get_frozen_path(os.path.join(app_path, u'plugins'),
|
return _get_frozen_path(os.path.join(app_path, u'plugins'),
|
||||||
@ -143,17 +131,16 @@ class AppLocation(object):
|
|||||||
return _get_frozen_path(
|
return _get_frozen_path(
|
||||||
os.path.abspath(os.path.split(sys.argv[0])[0]),
|
os.path.abspath(os.path.split(sys.argv[0])[0]),
|
||||||
os.path.split(openlp.__file__)[0])
|
os.path.split(openlp.__file__)[0])
|
||||||
elif dir_type == AppLocation.CacheDir:
|
elif dir_type == AppLocation.LanguageDir:
|
||||||
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:
|
|
||||||
app_path = _get_frozen_path(
|
app_path = _get_frozen_path(
|
||||||
os.path.abspath(os.path.split(sys.argv[0])[0]),
|
os.path.abspath(os.path.split(sys.argv[0])[0]),
|
||||||
os.path.split(openlp.__file__)[0])
|
os.path.split(openlp.__file__)[0])
|
||||||
return os.path.join(app_path, u'i18n')
|
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
|
@staticmethod
|
||||||
def get_data_path():
|
def get_data_path():
|
||||||
@ -177,17 +164,24 @@ class AppLocation(object):
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
def _get_os_dir_path(win_option, darwin_option, base_dir_option,
|
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.
|
Return a path based on which OS and environment we are running in.
|
||||||
"""
|
"""
|
||||||
if sys.platform == u'win32':
|
if sys.platform == u'win32':
|
||||||
return os.path.join(os.getenv(u'APPDATA'), win_option)
|
return os.path.join(os.getenv(u'APPDATA'), win_option)
|
||||||
elif sys.platform == u'darwin':
|
elif sys.platform == u'darwin':
|
||||||
|
if dir_type == AppLocation.DataDir:
|
||||||
|
return os.path.join(darwin_option, u'Data')
|
||||||
return darwin_option
|
return darwin_option
|
||||||
else:
|
else:
|
||||||
if XDG_BASE_AVAILABLE:
|
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:
|
else:
|
||||||
return non_base_dir_option
|
return non_base_dir_option
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user