forked from openlp/openlp
Clean up PreviewWidget interface a little more.
This commit is contained in:
parent
25db18d34c
commit
2b9a13ff97
@ -51,9 +51,16 @@ class ListPreviewWidget(QtGui.QTableWidget):
|
|||||||
self.setAlternatingRowColors(True)
|
self.setAlternatingRowColors(True)
|
||||||
|
|
||||||
def resizeEvent(self, QResizeEvent):
|
def resizeEvent(self, QResizeEvent):
|
||||||
|
"""
|
||||||
|
Overloaded method from QTableWidget. Will recalculate the layout.
|
||||||
|
"""
|
||||||
self.__recalculate_layout()
|
self.__recalculate_layout()
|
||||||
|
|
||||||
def __recalculate_layout(self):
|
def __recalculate_layout(self):
|
||||||
|
"""
|
||||||
|
Recalculates the layout of the table widget. It will set height and width
|
||||||
|
of the table cells. QTableWidget does not adapt the cells to the widget size at all.
|
||||||
|
"""
|
||||||
self.setColumnWidth(0, self.viewport().width())
|
self.setColumnWidth(0, self.viewport().width())
|
||||||
if self.service_item:
|
if self.service_item:
|
||||||
# Sort out songs, bibles, etc.
|
# Sort out songs, bibles, etc.
|
||||||
@ -66,21 +73,18 @@ class ListPreviewWidget(QtGui.QTableWidget):
|
|||||||
height = self.viewport().width() / self.screen_ratio
|
height = self.viewport().width() / self.screen_ratio
|
||||||
self.setRowHeight(framenumber, height)
|
self.setRowHeight(framenumber, height)
|
||||||
|
|
||||||
#width = self.main_window.controlSplitter.sizes()[self.split]
|
|
||||||
def screen_size_changed(self, screen_ratio):
|
def screen_size_changed(self, screen_ratio):
|
||||||
|
"""
|
||||||
|
To be called whenever the live screen size changes.
|
||||||
|
Because this makes a layout recalculation necessary.
|
||||||
|
"""
|
||||||
self.screen_ratio = screen_ratio
|
self.screen_ratio = screen_ratio
|
||||||
self.__recalculate_layout()
|
self.__recalculate_layout()
|
||||||
|
|
||||||
def set_active(self, active):
|
def replace_service_manager_item(self, service_item, width, slide):
|
||||||
if active:
|
|
||||||
self.show()
|
|
||||||
else:
|
|
||||||
self.hide()
|
|
||||||
|
|
||||||
def replace_service_manager_item(self, service_item, width, slideno):
|
|
||||||
"""
|
"""
|
||||||
Loads a ServiceItem into the system from ServiceManager
|
Replaces the current preview items with the ones in service_item.
|
||||||
Display the slide number passed
|
Displays the given slide.
|
||||||
"""
|
"""
|
||||||
self.service_item = service_item
|
self.service_item = service_item
|
||||||
self.clear()
|
self.clear()
|
||||||
@ -112,10 +116,6 @@ class ListPreviewWidget(QtGui.QTableWidget):
|
|||||||
if self.service_item.is_command():
|
if self.service_item.is_command():
|
||||||
label.setPixmap(QtGui.QPixmap(frame[u'image']))
|
label.setPixmap(QtGui.QPixmap(frame[u'image']))
|
||||||
else:
|
else:
|
||||||
# If current slide set background to image
|
|
||||||
if framenumber == slideno:
|
|
||||||
self.service_item.bg_image_bytes = self.image_manager.get_image_bytes(frame[u'path'],
|
|
||||||
ImageSource.ImagePlugin)
|
|
||||||
image = self.image_manager.get_image(frame[u'path'], ImageSource.ImagePlugin)
|
image = self.image_manager.get_image(frame[u'path'], ImageSource.ImagePlugin)
|
||||||
label.setPixmap(QtGui.QPixmap.fromImage(image))
|
label.setPixmap(QtGui.QPixmap.fromImage(image))
|
||||||
self.setCellWidget(framenumber, 0, label)
|
self.setCellWidget(framenumber, 0, label)
|
||||||
@ -129,25 +129,19 @@ class ListPreviewWidget(QtGui.QTableWidget):
|
|||||||
if self.service_item.is_text():
|
if self.service_item.is_text():
|
||||||
self.resizeRowsToContents()
|
self.resizeRowsToContents()
|
||||||
self.setColumnWidth(0, self.viewport().width())
|
self.setColumnWidth(0, self.viewport().width())
|
||||||
#stuff happens here, perhaps the setFocus() has to happen later...
|
|
||||||
self.setFocus()
|
self.setFocus()
|
||||||
|
self.change_slide(slide)
|
||||||
|
|
||||||
def update_preview_selection(self, row):
|
def change_slide(self, slide):
|
||||||
"""
|
"""
|
||||||
Utility method to update the selected slide in the list.
|
Switches to the given row.
|
||||||
"""
|
"""
|
||||||
if row >= self.rowCount():
|
if slide >= self.rowCount():
|
||||||
self.selectRow(self.rowCount() - 1)
|
slide = self.rowCount() - 1
|
||||||
else:
|
#Scroll to next item if possible.
|
||||||
self.check_update_selected_slide(row)
|
if slide + 1 < self.rowCount():
|
||||||
|
self.scrollToItem(self.item(slide + 1, 0))
|
||||||
def check_update_selected_slide(self, row):
|
self.selectRow(slide)
|
||||||
"""
|
|
||||||
Check if this slide has been updated
|
|
||||||
"""
|
|
||||||
if row + 1 < self.rowCount():
|
|
||||||
self.scrollToItem(self.item(row + 1, 0))
|
|
||||||
self.selectRow(row)
|
|
||||||
|
|
||||||
def currentRow(self):
|
def currentRow(self):
|
||||||
return super(ListPreviewWidget, self).currentRow()
|
return super(ListPreviewWidget, self).currentRow()
|
||||||
|
@ -36,7 +36,7 @@ from collections import deque
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import OpenLPToolbar, ItemCapabilities, ServiceItem, SlideLimits, \
|
from openlp.core.lib import OpenLPToolbar, ImageSource, ItemCapabilities, ServiceItem, SlideLimits, \
|
||||||
ServiceItemAction, Settings, Registry, UiStrings, ScreenList, build_icon, build_html, translate
|
ServiceItemAction, Settings, Registry, UiStrings, ScreenList, build_icon, build_html, translate
|
||||||
from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
|
from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
|
||||||
from openlp.core.lib.ui import create_action
|
from openlp.core.lib.ui import create_action
|
||||||
@ -418,7 +418,7 @@ class SlideController(DisplayController):
|
|||||||
if len(matches) == 1:
|
if len(matches) == 1:
|
||||||
self.shortcutTimer.stop()
|
self.shortcutTimer.stop()
|
||||||
self.current_shortcut = u''
|
self.current_shortcut = u''
|
||||||
self.preview_widget.check_update_selected_slide(self.slideList[matches[0]])
|
self.preview_widget.change_slide(self.slideList[matches[0]])
|
||||||
self.slideSelected()
|
self.slideSelected()
|
||||||
elif sender_name != u'shortcutTimer':
|
elif sender_name != u'shortcutTimer':
|
||||||
# Start the time as we did not have any match.
|
# Start the time as we did not have any match.
|
||||||
@ -428,7 +428,7 @@ class SlideController(DisplayController):
|
|||||||
if self.current_shortcut in keys:
|
if self.current_shortcut in keys:
|
||||||
# We had more than one match for example "V1" and "V10", but
|
# We had more than one match for example "V1" and "V10", but
|
||||||
# "V1" was the slide we wanted to go.
|
# "V1" was the slide we wanted to go.
|
||||||
self.preview_widget.check_update_selected_slide(self.slideList[self.current_shortcut])
|
self.preview_widget.change_slide(self.slideList[self.current_shortcut])
|
||||||
self.slideSelected()
|
self.slideSelected()
|
||||||
# Reset the shortcut.
|
# Reset the shortcut.
|
||||||
self.current_shortcut = u''
|
self.current_shortcut = u''
|
||||||
@ -704,7 +704,7 @@ class SlideController(DisplayController):
|
|||||||
slidenum = 0
|
slidenum = 0
|
||||||
# If service item is the same as the current one, only change slide
|
# If service item is the same as the current one, only change slide
|
||||||
if slideno >= 0 and item == self.service_item:
|
if slideno >= 0 and item == self.service_item:
|
||||||
self.preview_widget.check_update_selected_slide(slidenum)
|
self.preview_widget.change_slide(slidenum)
|
||||||
self.slideSelected()
|
self.slideSelected()
|
||||||
else:
|
else:
|
||||||
self._processItem(item, slidenum)
|
self._processItem(item, slidenum)
|
||||||
@ -776,8 +776,11 @@ class SlideController(DisplayController):
|
|||||||
slideHeight = width * (1 / self.ratio)
|
slideHeight = width * (1 / self.ratio)
|
||||||
row += 1
|
row += 1
|
||||||
self.slideList[unicode(row)] = row - 1
|
self.slideList[unicode(row)] = row - 1
|
||||||
|
# If current slide set background to image
|
||||||
|
if not self.service_item.is_command() and framenumber == slideno:
|
||||||
|
self.service_item.bg_image_bytes = self.image_manager.get_image_bytes(frame[u'path'],
|
||||||
|
ImageSource.ImagePlugin)
|
||||||
self.preview_widget.replace_service_manager_item(self.service_item, width, slideno)
|
self.preview_widget.replace_service_manager_item(self.service_item, width, slideno)
|
||||||
self.preview_widget.update_preview_selection(slideno)
|
|
||||||
self.enableToolBar(service_item)
|
self.enableToolBar(service_item)
|
||||||
# Pass to display for viewing.
|
# Pass to display for viewing.
|
||||||
# Postpone image build, we need to do this later to avoid the theme
|
# Postpone image build, we need to do this later to avoid the theme
|
||||||
@ -810,7 +813,7 @@ class SlideController(DisplayController):
|
|||||||
Registry().execute(u'%s_slide' % self.service_item.name.lower(), [self.service_item, self.is_live, index])
|
Registry().execute(u'%s_slide' % self.service_item.name.lower(), [self.service_item, self.is_live, index])
|
||||||
self.updatePreview()
|
self.updatePreview()
|
||||||
else:
|
else:
|
||||||
self.preview_widget.check_update_selected_slide(index)
|
self.preview_widget.change_slide(index)
|
||||||
self.slideSelected()
|
self.slideSelected()
|
||||||
|
|
||||||
def mainDisplaySetBackground(self):
|
def mainDisplaySetBackground(self):
|
||||||
@ -973,7 +976,7 @@ class SlideController(DisplayController):
|
|||||||
self.service_item.bg_image_bytes = None
|
self.service_item.bg_image_bytes = None
|
||||||
self.updatePreview()
|
self.updatePreview()
|
||||||
self.selected_row = row
|
self.selected_row = row
|
||||||
self.preview_widget.check_update_selected_slide(row)
|
self.preview_widget.change_slide(row)
|
||||||
Registry().execute(u'slidecontroller_%s_changed' % self.type_prefix, row)
|
Registry().execute(u'slidecontroller_%s_changed' % self.type_prefix, row)
|
||||||
self.display.setFocus()
|
self.display.setFocus()
|
||||||
|
|
||||||
@ -981,7 +984,7 @@ class SlideController(DisplayController):
|
|||||||
"""
|
"""
|
||||||
The slide has been changed. Update the slidecontroller accordingly
|
The slide has been changed. Update the slidecontroller accordingly
|
||||||
"""
|
"""
|
||||||
self.preview_widget.check_update_selected_slide(row)
|
self.preview_widget.change_slide(row)
|
||||||
self.updatePreview()
|
self.updatePreview()
|
||||||
Registry().execute(u'slidecontroller_%s_changed' % self.type_prefix, row)
|
Registry().execute(u'slidecontroller_%s_changed' % self.type_prefix, row)
|
||||||
|
|
||||||
@ -1040,7 +1043,7 @@ class SlideController(DisplayController):
|
|||||||
row = 0
|
row = 0
|
||||||
else:
|
else:
|
||||||
row = self.preview_widget.rowCount() - 1
|
row = self.preview_widget.rowCount() - 1
|
||||||
self.preview_widget.check_update_selected_slide(row)
|
self.preview_widget.change_slide(row)
|
||||||
self.slideSelected()
|
self.slideSelected()
|
||||||
|
|
||||||
def on_slide_selected_previous(self):
|
def on_slide_selected_previous(self):
|
||||||
@ -1063,7 +1066,7 @@ class SlideController(DisplayController):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
row = 0
|
row = 0
|
||||||
self.preview_widget.check_update_selected_slide(row)
|
self.preview_widget.change_slide(row)
|
||||||
self.slideSelected()
|
self.slideSelected()
|
||||||
|
|
||||||
def onToggleLoop(self):
|
def onToggleLoop(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user