本文整理汇总了Python中openlp.core.lib.ServiceItem.is_text方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceItem.is_text方法的具体用法?Python ServiceItem.is_text怎么用?Python ServiceItem.is_text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openlp.core.lib.ServiceItem
的用法示例。
在下文中一共展示了ServiceItem.is_text方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ListPreviewWidget
# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import is_text [as 别名]
class ListPreviewWidget(QtGui.QTableWidget):
def __init__(self, parent, screen_ratio):
"""
Initializes the widget to default state.
An empty ServiceItem is used per default.
One needs to call replace_service_manager_item() to make this widget display something.
"""
super(QtGui.QTableWidget, self).__init__(parent)
# Set up the widget.
self.setColumnCount(1)
self.horizontalHeader().setVisible(False)
self.setColumnWidth(0, parent.width())
self.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
self.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setAlternatingRowColors(True)
# Initialize variables.
self.service_item = ServiceItem()
self.screen_ratio = screen_ratio
def resizeEvent(self, QResizeEvent):
"""
Overloaded method from QTableWidget. Will recalculate the layout.
"""
self.__recalculate_layout()
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 on its own.
"""
self.setColumnWidth(0, self.viewport().width())
if self.service_item:
# Sort out songs, bibles, etc.
if self.service_item.is_text():
self.resizeRowsToContents()
else:
# Sort out image heights.
for framenumber in range(len(self.service_item.get_frames())):
height = self.viewport().width() // self.screen_ratio
self.setRowHeight(framenumber, height)
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.__recalculate_layout()
def replace_service_item(self, service_item, width, slideNumber):
"""
Replaces the current preview items with the ones in service_item.
Displays the given slide.
"""
self.service_item = service_item
self.clear()
self.setRowCount(0)
self.setColumnWidth(0, width)
row = 0
text = []
for framenumber, frame in enumerate(self.service_item.get_frames()):
self.setRowCount(self.slide_count() + 1)
item = QtGui.QTableWidgetItem()
slide_height = 0
if self.service_item.is_text():
if frame['verseTag']:
# These tags are already translated.
verse_def = frame['verseTag']
verse_def = '%s%s' % (verse_def[0], verse_def[1:])
two_line_def = '%s\n%s' % (verse_def[0], verse_def[1:])
row = two_line_def
else:
row += 1
item.setText(frame['text'])
else:
label = QtGui.QLabel()
label.setMargin(4)
if self.service_item.is_media():
label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
else:
label.setScaledContents(True)
if self.service_item.is_command():
label.setPixmap(QtGui.QPixmap(frame['image']))
else:
image = self.image_manager.get_image(frame['path'], ImageSource.ImagePlugin)
label.setPixmap(QtGui.QPixmap.fromImage(image))
self.setCellWidget(framenumber, 0, label)
slide_height = width // self.screen_ratio
row += 1
text.append(str(row))
self.setItem(framenumber, 0, item)
if slide_height:
self.setRowHeight(framenumber, slide_height)
self.setVerticalHeaderLabels(text)
if self.service_item.is_text():
self.resizeRowsToContents()
self.setColumnWidth(0, self.viewport().width())
self.setFocus()
#.........这里部分代码省略.........
示例2: ListPreviewWidget
# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import is_text [as 别名]
class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties):
"""
A special type of QTableWidget which lists the slides in the slide controller
:param parent:
:param screen_ratio:
"""
def __init__(self, parent, screen_ratio):
"""
Initializes the widget to default state.
An empty ``ServiceItem`` is used by default. replace_service_manager_item() needs to be called to make this
widget display something.
"""
super(QtWidgets.QTableWidget, self).__init__(parent)
self._setup(screen_ratio)
def _setup(self, screen_ratio):
"""
Set up the widget
"""
self.setColumnCount(1)
self.horizontalHeader().setVisible(False)
self.setColumnWidth(0, self.parent().width())
self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
self.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.setAlternatingRowColors(True)
# Initialize variables.
self.service_item = ServiceItem()
self.screen_ratio = screen_ratio
self.auto_row_height = 100
# Connect signals
self.verticalHeader().sectionResized.connect(self.row_resized)
def resizeEvent(self, event):
"""
Overloaded method from QTableWidget. Will recalculate the layout.
"""
self.__recalculate_layout()
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 on its own.
"""
self.setColumnWidth(0, self.viewport().width())
if self.service_item:
# Sort out songs, bibles, etc.
if self.service_item.is_text():
self.resizeRowsToContents()
# Sort out image heights.
else:
height = self.viewport().width() // self.screen_ratio
max_img_row_height = Settings().value('advanced/slide max height')
# Adjust for row height cap if in use.
if isinstance(max_img_row_height, int):
if max_img_row_height > 0 and height > max_img_row_height:
height = max_img_row_height
elif max_img_row_height < 0:
# If auto setting, show that number of slides, or if the resulting slides too small, 100px.
# E.g. If setting is -4, 4 slides will be visible, unless those slides are < 100px high.
self.auto_row_height = max(self.viewport().height() / (-1 * max_img_row_height), 100)
height = min(height, self.auto_row_height)
# Apply new height to slides
for frame_number in range(len(self.service_item.get_frames())):
self.setRowHeight(frame_number, height)
def row_resized(self, row, old_height, new_height):
"""
Will scale non-image slides.
"""
# Only for non-text slides when row height cap in use
max_img_row_height = Settings().value('advanced/slide max height')
if self.service_item.is_text() or not isinstance(max_img_row_height, int) or max_img_row_height == 0:
return
# Get and validate label widget containing slide & adjust max width
try:
self.cellWidget(row, 0).children()[1].setMaximumWidth(new_height * self.screen_ratio)
except:
return
def screen_size_changed(self, screen_ratio):
"""
This method is called whenever the live screen size changes, which then makes a layout recalculation necessary
:param screen_ratio: The new screen ratio
"""
self.screen_ratio = screen_ratio
self.__recalculate_layout()
def replace_service_item(self, service_item, width, slide_number):
"""
Replace the current preview items with the ones in service_item and display the given slide
:param service_item: The service item to insert
:param width: The width of the column
:param slide_number: The slide number to pre-select
#.........这里部分代码省略.........