More audit changes and dynamic image backgrounds

This commit is contained in:
Tim Bentley 2009-09-26 07:46:26 +01:00
parent 14277fdbfd
commit 9f04b6f478
6 changed files with 439 additions and 15 deletions

View File

@ -51,7 +51,6 @@ class Renderer(object):
self._frame = None self._frame = None
self.bg_frame = None self.bg_frame = None
self.bg_image = None self.bg_image = None
#self.bg_frame_small = None
def set_debug(self, debug): def set_debug(self, debug):
""" """

View File

@ -64,6 +64,9 @@ class RenderManager(object):
self.theme = u'' self.theme = u''
self.service_theme = u'' self.service_theme = u''
self.global_style = u'' self.global_style = u''
self.override_background = None
self.save_bg_frame = None
self.override_background_changed = False
def update_display(self, screen_number): def update_display(self, screen_number):
""" """
@ -134,6 +137,20 @@ class RenderManager(object):
self.screen_list[self.current_display][u'size']) self.screen_list[self.current_display][u'size'])
self.renderer.set_theme(self.themedata) self.renderer.set_theme(self.themedata)
self.build_text_rectangle(self.themedata) self.build_text_rectangle(self.themedata)
#Replace the backgrount image from renderer with one from image
if self.override_background is not None:
if self.save_bg_frame is None:
self.save_bg_frame = self.renderer.bg_frame
if self.override_background_changed:
self.renderer.bg_frame = self.resize_image(self.override_background)
self.override_background_changed = False
else:
if self.override_background_changed:
self.renderer.bg_frame = self.resize_image(self.override_background)
self.override_background_changed = False
if self.save_bg_frame is not None:
self.renderer.bg_frame = self.save_bg_frame
self.save_bg_frame = None
def build_text_rectangle(self, theme): def build_text_rectangle(self, theme):
""" """

View File

@ -107,18 +107,26 @@ class AuditManager():
def delete_all(self): def delete_all(self):
""" """
Delete a audit record Delete all audit records
""" """
id = 0 try:
if id !=0: self.session.query(AuditItem).delete(synchronize_session=False)
audititem = self.get_audit(id) self.session.commit()
try:
self.session.delete(audititem)
self.session.commit()
return True
except:
self.session.rollback()
log.excertion(u'Audit Item failed to delete')
return False
else:
return True return True
except:
self.session.rollback()
log.excertion(u'Failed to delete all audit items')
return False
def delete_to_date(self, date):
"""
Delete audit records before given date
"""
try:
self.session.query(AuditItem).filter(AuditItem.auditdate <= date).delete(synchronize_session=False)
self.session.commit()
return True
except:
self.session.rollback()
log.excertion(u'Failed to delete all audit items to %s' % date)
return False

View File

@ -26,7 +26,7 @@ import logging
import os import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, buildIcon from openlp.core.lib import MediaManagerItem, BaseListWithDnD, buildIcon, translate
# We have to explicitly create separate classes for each plugin # We have to explicitly create separate classes for each plugin
# in order for DnD to the Service manager to work correctly. # in order for DnD to the Service manager to work correctly.
@ -59,6 +59,7 @@ class ImageMediaItem(MediaManagerItem):
self.ServiceItemIconName = u':/media/media_image.png' self.ServiceItemIconName = u':/media/media_image.png'
self.servicePath = None self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
self.overrideActive = False
def initialise(self): def initialise(self):
self.ListView.setSelectionMode( self.ListView.setSelectionMode(
@ -70,6 +71,37 @@ class ImageMediaItem(MediaManagerItem):
os.mkdir(self.servicePath) os.mkdir(self.servicePath)
self.loadList(self.parent.config.load_list(self.ConfigSection)) self.loadList(self.parent.config.load_list(self.ConfigSection))
def addEndHeaderBar(self):
self.ImageWidget = QtGui.QWidget(self)
sizePolicy = QtGui.QSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.ImageWidget.sizePolicy().hasHeightForWidth())
self.ImageWidget.setSizePolicy(sizePolicy)
self.ImageWidget.setObjectName(u'ImageWidget')
self.OverrideLayout = QtGui.QVBoxLayout(self.ImageWidget)
self.OverrideLayout.setMargin(5)
self.OverrideLayout.setSpacing(4)
self.OverrideLayout.setObjectName(u'OverrideLayout')
self.OverrideCheckBox = QtGui.QCheckBox(self.ImageWidget)
self.OverrideCheckBox.setObjectName(u'OverrideCheckBox')
self.OverrideCheckBox.setCheckable(True)
self.OverrideCheckBox.setChecked(False)
self.OverrideCheckBox.setText(translate(u'ImagePlugin', u'Override background'))
self.OverrideCheckBox.setStatusTip(
translate(u'ImageMedia', u'Allow background of live slide to be overridden'))
self.OverrideLayout.addWidget(self.OverrideCheckBox)
self.OverrideLabel = QtGui.QLabel(self.ImageWidget)
self.OverrideLabel.setObjectName(u'OverrideLabel')
self.OverrideLayout.addWidget(self.OverrideLabel)
# Add the song widget to the page layout
self.PageLayout.addWidget(self.ImageWidget)
QtCore.QObject.connect(self.OverrideCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.toggleOverrideState)
def onDeleteClick(self): def onDeleteClick(self):
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item is not None: if item is not None:
@ -111,3 +143,24 @@ class ImageMediaItem(MediaManagerItem):
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
service_item.add_from_image(path, name, frame) service_item.add_from_image(path, name, frame)
return True return True
def toggleOverrideState(self):
self.overrideActive = not self.overrideActive
if not self.overrideActive:
self.OverrideLabel.setText(u'')
self.parent.render_manager.override_background = None
def onPreviewClick(self):
if self.overrideActive:
items = self.ListView.selectedIndexes()
if len(items) == 0:
return False
for item in items:
bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
self.OverrideLabel.setText(bitem.text())
frame = QtGui.QImage(unicode(filename))
self.parent.render_manager.override_background = frame
self.parent.render_manager.override_background_changed = True
else:
MediaManagerItem.onPreviewClick(self)

View File

@ -93,6 +93,8 @@ class SongMediaItem(MediaManagerItem):
':/songs/song_maintenance.png', self.onSongMaintenanceClick, ':/songs/song_maintenance.png', self.onSongMaintenanceClick,
'SongMaintenanceItem') 'SongMaintenanceItem')
## Add the SongListView widget ## ## Add the SongListView widget ##
# Create the tab widget # Create the tab widget
self.SongWidget = QtGui.QWidget(self) self.SongWidget = QtGui.QWidget(self)
sizePolicy = QtGui.QSizePolicy( sizePolicy = QtGui.QSizePolicy(
@ -127,6 +129,8 @@ class SongMediaItem(MediaManagerItem):
self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1) self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)
# Add the song widget to the page layout # Add the song widget to the page layout
self.PageLayout.addWidget(self.SongWidget) self.PageLayout.addWidget(self.SongWidget)
self.ListView = SongListView() self.ListView = SongListView()
self.ListView.setAlternatingRowColors(True) self.ListView.setAlternatingRowColors(True)
self.ListView.setDragEnabled(True) self.ListView.setDragEnabled(True)

View File

@ -0,0 +1,343 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AuditDetailDialog</class>
<widget class="QWidget" name="AuditDetailDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>593</width>
<height>501</height>
</rect>
</property>
<property name="windowTitle">
<string>Audit Detail Extraction</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>420</x>
<y>470</y>
<width>170</width>
<height>25</height>
</rect>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QGroupBox" name="FileGroupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>370</y>
<width>571</width>
<height>70</height>
</rect>
</property>
<property name="title">
<string>Report Location</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="FileLineEdit"/>
</item>
<item>
<widget class="QPushButton" name="SaveFilePushButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images/openlp-2.qrc">
<normaloff>:/exports/export_load.png</normaloff>:/exports/export_load.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>561</width>
<height>361</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="ReportTypeGroup">
<property name="title">
<string>Report Type</string>
</property>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>50</x>
<y>40</y>
<width>481</width>
<height>23</height>
</rect>
</property>
<layout class="QHBoxLayout" name="ReportHorizontalLayout">
<item>
<widget class="QRadioButton" name="SummaryReport">
<property name="text">
<string>Summary</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="DetailedReport">
<property name="text">
<string>Detailed</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="DateRangeGroupBox">
<property name="title">
<string>Date Range</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="DateHorizontalLayout">
<item>
<widget class="QDateEdit" name="FromDateEdit">
<property name="displayFormat">
<string>dd/MM/yyyy</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="To">
<property name="text">
<string>to</string>
</property>
</widget>
</item>
<item>
<widget class="QDateEdit" name="ToDateEdit">
<property name="displayFormat">
<string>dd/MM/yyyy</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="TimePeriodGroupBox">
<property name="title">
<string>Time Periods</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="FirstHorizontalLayout">
<item>
<widget class="QCheckBox" name="FirstCheckBox">
<property name="text">
<string>First Service</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="FirstFromTimeEdit">
<property name="displayFormat">
<string>hh:mm AP</string>
</property>
<property name="time">
<time>
<hour>9</hour>
<minute>0</minute>
<second>0</second>
</time>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="FirstTo">
<property name="text">
<string>to</string>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="FirstToTimeEdit">
<property name="displayFormat">
<string>hh:mm AP</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
<property name="time">
<time>
<hour>10</hour>
<minute>0</minute>
<second>0</second>
</time>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="SecondHorizontalLayout">
<item>
<widget class="QCheckBox" name="SecondCheckBox">
<property name="text">
<string>Second Service</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="SecondFromTimeEdit">
<property name="displayFormat">
<string>hh:mm AP</string>
</property>
<property name="time">
<time>
<hour>10</hour>
<minute>45</minute>
<second>0</second>
</time>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="SecondTo">
<property name="text">
<string>to</string>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="SecondToTimeEdit">
<property name="displayFormat">
<string>hh:mm AP</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="ThirdHorizontalLayout">
<item>
<widget class="QCheckBox" name="ThirdCheckBox">
<property name="text">
<string>Third Service</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="ThirdFromTimeEdit">
<property name="displayFormat">
<string>hh:mm AP</string>
</property>
<property name="time">
<time>
<hour>18</hour>
<minute>30</minute>
<second>0</second>
</time>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="ThirdTo">
<property name="text">
<string>to</string>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="ThirdToTimeEdit">
<property name="displayFormat">
<string>hh:mm AP</string>
</property>
<property name="time">
<time>
<hour>19</hour>
<minute>30</minute>
<second>0</second>
</time>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<resources>
<include location="../images/openlp-2.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AuditDetailDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>455</x>
<y>483</y>
</hint>
<hint type="destinationlabel">
<x>445</x>
<y>575</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AuditDetailDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>528</x>
<y>484</y>
</hint>
<hint type="destinationlabel">
<x>526</x>
<y>531</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>accept()</slot>
</slots>
</ui>