Change ThemeManager to use new XML format and renderer API's

Put in Propper logging for Screen resolution detection.
This commit is contained in:
Tim Bentley 2009-04-10 06:59:40 +01:00
parent b581fcab8f
commit 9b29d2b668
3 changed files with 23 additions and 19 deletions

View File

@ -26,23 +26,26 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver from openlp.core.lib import Receiver
logging.basicConfig(level=logging.DEBUG, logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', format=u'%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M', datefmt=u'%m-%d %H:%M',
filename='openlp.log', filename=u'openlp.log',
filemode='w') filemode=u'w')
from openlp.core.resources import * from openlp.core.resources import *
from openlp.core.ui import MainWindow, SplashScreen from openlp.core.ui import MainWindow, SplashScreen
class OpenLP(QtGui.QApplication): class OpenLP(QtGui.QApplication):
global log
log=logging.getLogger(u'OpenLP Application')
log.info(u'Application Loaded')
def run(self): def run(self):
#provide a listener for widgets to reqest a screen update. #provide a listener for widgets to reqest a screen update.
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL('openlpprocessevents'), self.processEvents) QtCore.SIGNAL(u'openlpprocessevents'), self.processEvents)
self.setApplicationName('openlp.org') self.setApplicationName(u'openlp.org')
self.setApplicationVersion('1.9.0') self.setApplicationVersion(u'1.9.0')
self.splash = SplashScreen() self.splash = SplashScreen()
self.splash.show() self.splash.show()
# make sure Qt really display the splash screen # make sure Qt really display the splash screen
@ -51,6 +54,7 @@ class OpenLP(QtGui.QApplication):
# Decide how many screens we have and their size # Decide how many screens we have and their size
for i in range (0 , self.desktop().numScreens()): for i in range (0 , self.desktop().numScreens()):
screens.insert(i, (i+1, self.desktop().availableGeometry(i+1))) screens.insert(i, (i+1, self.desktop().availableGeometry(i+1)))
log.info(u'Screen %d found with resolution %s', i+1, self.desktop().availableGeometry(i+1))
# start the main app window # start the main app window
self.main_window = MainWindow(screens) self.main_window = MainWindow(screens)
self.main_window.show() self.main_window.show()

View File

@ -31,7 +31,6 @@ class GeneralTab(SettingsTab):
def __init__(self, screen_list): def __init__(self, screen_list):
SettingsTab.__init__(self, translate(u'GeneralTab', u'General')) SettingsTab.__init__(self, translate(u'GeneralTab', u'General'))
self.screen_list = screen_list self.screen_list = screen_list
print screen_list
def setupUi(self): def setupUi(self):
self.setObjectName(u'GeneralTab') self.setObjectName(u'GeneralTab')

View File

@ -276,8 +276,8 @@ class ThemeManager(QWidget):
else: else:
newtheme.add_background_image(str(t.BackgroundParameter1)) newtheme.add_background_image(str(t.BackgroundParameter1))
newtheme.add_font(str(t.FontName), str(t.FontColor.name()), str(t.FontProportion * 2)) newtheme.add_font(str(t.FontName), str(t.FontColor.name()), str(t.FontProportion * 2), u'False')
newtheme.add_font(str(t.FontName), str(t.FontColor.name()), str(12), u'footer') newtheme.add_font(str(t.FontName), str(t.FontColor.name()), str(12), u'False', u'footer')
outline = False outline = False
shadow = False shadow = False
if t.Shadow == 1: if t.Shadow == 1:
@ -302,7 +302,7 @@ class ThemeManager(QWidget):
r.set_theme(theme) # set default theme r.set_theme(theme) # set default theme
r._render_background() r._render_background()
r.set_text_rectangle(QtCore.QRect(0,0, size.width()-1, size.height()-1)) r.set_text_rectangle(QtCore.QRect(0,0, size.width()-1, size.height()-1), QtCore.QRect(10,560, size.width()-1, size.height()-1))
lines=[] lines=[]
lines.append(u'Amazing Grace!') lines.append(u'Amazing Grace!')
@ -310,17 +310,18 @@ class ThemeManager(QWidget):
lines.append(u'To save a wretch like me;') lines.append(u'To save a wretch like me;')
lines.append(u'I once was lost but now am found,') lines.append(u'I once was lost but now am found,')
lines.append(u'Was blind, but now I see.') lines.append(u'Was blind, but now I see.')
lines1=[]
lines1.append(u'Amazing Grace (John Newton)' )
lines1.append(u'CCLI xxx (c)Openlp.org')
answer=r._render_lines(lines) answer=r._render_lines(lines, lines1)
r._get_extent_and_render(u'Amazing Grace (John Newton) ', (10, 560), True, None, True)
r._get_extent_and_render(u'CCLI xxx (c)Openlp.org', (10, 580), True, None, True)
im=frame.GetPixmap().toImage() im=frame.GetPixmap().toImage()
testpathname=os.path.join(dir, name+u'.png') samplepathname=os.path.join(dir, name+u'.png')
if os.path.exists(testpathname): if os.path.exists(samplepathname):
os.unlink(testpathname) os.unlink(samplepathname)
im.save(testpathname, u'png') im.save(samplepathname, u'png')
log.debug(u'Theme image written to %s',testpathname) log.debug(u'Theme image written to %s',samplepathname)
class TstFrame: class TstFrame: