Add new renderer code

This commit is contained in:
Tim Bentley 2010-07-11 06:40:56 +01:00
parent 9d77444ddf
commit 0bd6d297c7
4 changed files with 150 additions and 15 deletions

View File

@ -178,6 +178,11 @@ def resize_image(image, width, height):
QtCore.Qt.SmoothTransformation) QtCore.Qt.SmoothTransformation)
realw = preview.width() realw = preview.width()
realh = preview.height() realh = preview.height()
#Only resize if different size
print realw, realh, width, height
if realw == width and realh == height:
return image
print "different"
# and move it to the centre of the preview space # and move it to the centre of the preview space
new_image = QtGui.QImage(width, height, new_image = QtGui.QImage(width, height,
QtGui.QImage.Format_ARGB32_Premultiplied) QtGui.QImage.Format_ARGB32_Premultiplied)

View File

@ -145,6 +145,41 @@ class Renderer(object):
for line in lines: for line in lines:
text.append(line) text.append(line)
split_text = self.pre_render_text(text) split_text = self.pre_render_text(text)
doc = QtGui.QTextDocument()
doc.setPageSize(QtCore.QSizeF(self._rect.width(), self._rect.height()))
df = doc.defaultFont()
df.setPixelSize(self._theme.font_main_proportion)
df.setFamily(self._theme.font_main_name)
main_weight = 50
if self._theme.font_main_weight == u'Bold':
main_weight = 75
df.setWeight(main_weight)
doc.setDefaultFont(df)
myCursor = QtGui.QTextCursor(doc)
layout = doc.documentLayout()
formatted = []
if self._theme.display_horizontalAlign == 2:
shell = "<p align=center>%s</font></p>"
elif self._theme.display_horizontalAlign == 1:
shell = "<p align=right>%s</font></p>"
else:
shell = "<p>%s</p>"
temp_text = u''
old_html_text = u''
for line in text:
#do we need a <br> here?
temp_text = temp_text + line
html_text = shell % temp_text
doc.setHtml(html_text)
if layout.pageCount() != 1:
formatted.append(old_html_text)
temp_text = line
old_html_text = temp_text
formatted.append(old_html_text)
for f in formatted:
print "f", f
print "st", split_text
log.debug(u'format_slide - End') log.debug(u'format_slide - End')
return split_text return split_text

View File

@ -79,10 +79,28 @@ class DisplayManager(QtGui.QWidget):
QtCore.SIGNAL(u'videodisplay_start'), self.onStartVideo) QtCore.SIGNAL(u'videodisplay_start'), self.onStartVideo)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'videodisplay_stop'), self.onStopVideo) QtCore.SIGNAL(u'videodisplay_stop'), self.onStopVideo)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.setup)
def setup(self): def setup(self):
log.debug(u'mainDisplay - setup')
self.videoDisplay.setup() self.videoDisplay.setup()
self.mainDisplay.setup() self.mainDisplay.setup()
#Build the initial frame.
self.initialFrame = QtGui.QImage(
self.screens.current[u'size'].width(),
self.screens.current[u'size'].height(),
QtGui.QImage.Format_ARGB32_Premultiplied)
print self.screens.current
splash_image = QtGui.QImage(u':/graphics/openlp-splash-screen.png')
painter_image = QtGui.QPainter()
painter_image.begin(self.initialFrame)
painter_image.fillRect(self.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.mainDisplay.displayImage(self.initialFrame)
def hideDisplay(self, message): def hideDisplay(self, message):
""" """
@ -252,19 +270,6 @@ class MainDisplay(DisplayWidget):
self.webView.setGeometry(0, 0, self.size().width(), self.webView.setGeometry(0, 0, self.size().width(),
self.size().height()) self.size().height())
#Build a custom splash screen #Build a custom splash screen
self.initialFrame = QtGui.QImage(
self.screen[u'size'].width(),
self.screen[u'size'].height(),
QtGui.QImage.Format_ARGB32_Premultiplied)
splash_image = QtGui.QImage(u':/graphics/openlp-splash-screen.png')
painter_image = QtGui.QPainter()
painter_image.begin(self.initialFrame)
painter_image.fillRect(self.initialFrame.rect(), QtCore.Qt.white)
painter_image.drawImage(
(self.screen[u'size'].width() - splash_image.width()) / 2,
(self.screen[u'size'].height() - splash_image.height()) / 2,
splash_image)
self.displayImage(self.initialFrame)
self.repaint() self.repaint()
#Build a Black screen #Build a Black screen
painter = QtGui.QPainter() painter = QtGui.QPainter()
@ -498,8 +503,7 @@ class VideoDisplay(Phonon.VideoWidget):
QtCore.SIGNAL(u'videodisplay_pause'), self.onMediaPause) QtCore.SIGNAL(u'videodisplay_pause'), self.onMediaPause)
# QtCore.QObject.connect(Receiver.get_receiver(), # QtCore.QObject.connect(Receiver.get_receiver(),
# QtCore.SIGNAL(u'videodisplay_background'), self.onMediaBackground) # QtCore.SIGNAL(u'videodisplay_background'), self.onMediaBackground)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.setup)
QtCore.QObject.connect(self.mediaObject, QtCore.QObject.connect(self.mediaObject,
QtCore.SIGNAL(u'finished()'), self.onMediaStop) QtCore.SIGNAL(u'finished()'), self.onMediaStop)
self.setVisible(False) self.setVisible(False)

View File

@ -0,0 +1,91 @@
%{!?python_sitelib:%global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Summary: Open source Church presentation and lyrics projection application
Name: OpenLP
Version: 1.9.1.1
Release: 1%{?dist}
Source0: http://downloads.sourceforge.net/openlp/openlp/%{version}/%{name}-%{version}.tar.gz
License: GPLv2
Group: Applications/Multimedia
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
URL: http://openlp.org/
BuildRequires: desktop-file-utils
BuildRequires: python2-devel
BuildRequires: python-setuptools
Requires: PyQt4
Requires: phonon
Requires: python-BeautifulSoup
Requires: python-chardet
Requires: python-lxml
Requires: python-sqlalchemy
Requires: hicolor-icon-theme
%description
OpenLP is a church presentation software, for lyrics projection software,
used to display slides of Songs, Bible verses, videos, images, and
presentations (if OpenOffice.org is installed) using a computer and projector.
%prep
%setup -q
%build
python setup.py build
%install
rm -rf %{buildroot}
python setup.py install --skip-build -O1 --root %{buildroot}
install -m644 -p -D resources/images/openlp-logo-16x16.png \
%{buildroot}%{_datadir}/icons/hicolor/16x16/apps/openlp.png
install -m644 -p -D resources/images/openlp-logo-32x32.png \
%{buildroot}%{_datadir}/icons/hicolor/32x32/apps/openlp.png
install -m644 -p -D resources/images/openlp-logo-48x48.png \
%{buildroot}%{_datadir}/icons/hicolor/48x48/apps/openlp.png
install -m644 -p -D resources/images/openlp-logo.svg \
%{buildroot}%{_datadir}/icons/hicolor/scalable/apps/openlp.svg
desktop-file-install \
--dir %{buildroot}/%{_datadir}/applications \
resources/openlp.desktop
mv %{buildroot}%{_bindir}/bible-1to2-converter.py \
%{buildroot}%{_bindir}/bible-1to2-converter
mv %{buildroot}%{_bindir}/openlp-1to2-converter.py \
%{buildroot}%{_bindir}/openlp-1to2-converter
mv %{buildroot}%{_bindir}/openlp-remoteclient.py \
%{buildroot}%{_bindir}/openlp-remoteclient
mv %{buildroot}%{_bindir}/openlp.pyw %{buildroot}%{_bindir}/openlp
%post
touch --no-create %{_datadir}/icons/hicolor ||:
gtk-update-icon-cache -q %{_datadir}/icons/hicolor 2> /dev/null ||:
%postun
touch --no-create %{_datadir}/icons/hicolor ||:
gtk-update-icon-cache -q %{_datadir}/icons/hicolor 2> /dev/null ||:
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root)
%doc copyright.txt LICENSE
%{_bindir}/bible-1to2-converter
%{_bindir}/openlp-1to2-converter
%{_bindir}/openlp-remoteclient
%{_bindir}/openlp
%{_datadir}/applications/openlp.desktop
%{_datadir}/icons/hicolor/*/apps/openlp.*
%{python_sitelib}/openlp/
%{python_sitelib}/OpenLP-%{version}*.egg-info
%doc documentation/*.txt
%changelog
* Sun Mar 28 2010 Tim Bentley <timbentley@openlp.org> 1.9.1.1
- Initial build version - Alpha 1 Release