forked from openlp/openlp
r1242
This commit is contained in:
commit
e3a78c4d83
@ -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')
|
||||
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,8 +364,7 @@ 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:
|
||||
if self.hideMode:
|
||||
self.hideDisplay(self.hideMode)
|
||||
preview = QtGui.QImage(self.screen[u'size'].width(),
|
||||
self.screen[u'size'].height(),
|
||||
|
@ -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(),
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user