forked from openlp/openlp
now we can save the theme as new or overrite
This commit is contained in:
parent
d85a0ba293
commit
a3e2bce831
|
@ -261,8 +261,8 @@ class Renderer:
|
|||
bbox=self._render_lines_unaligned(lines, False, (x, y))
|
||||
|
||||
if lines1 is not None:
|
||||
x, y = self._correctAlignment(self._rect_footer, bbox1)
|
||||
bbox=self._render_lines_unaligned(lines1, True, (x, y) )
|
||||
#x, y = self._correctAlignment(self._rect_footer, bbox1)
|
||||
bbox=self._render_lines_unaligned(lines1, True, (self._rect_footer.left(), self._rect_footer.top()) )
|
||||
|
||||
log.debug(u'render lines DONE')
|
||||
|
||||
|
@ -337,7 +337,10 @@ class Renderer:
|
|||
starty=y
|
||||
rightextent=None
|
||||
t=self._theme
|
||||
align=t.display_horizontalAlign
|
||||
if footer: # dont allow alignment messing with footers
|
||||
align = 0
|
||||
else:
|
||||
align=t.display_horizontalAlign
|
||||
|
||||
wrapstyle=t.display_wrapStyle
|
||||
|
||||
|
|
|
@ -101,6 +101,23 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||
|
||||
|
||||
def accept(self):
|
||||
new_theme = ThemeXML()
|
||||
theme_name = str(self.ThemeNameEdit.displayText())
|
||||
new_theme.new_document(theme_name)
|
||||
if self.theme.background_type == u'solid':
|
||||
new_theme.add_background_solid(str(self.theme.background_color))
|
||||
elif self.theme.theme.background_type == u'gradient':
|
||||
new_theme.add_background_gradient(str(self.theme.background_startColor), str(self.theme.background_endColor), self.theme.background_direction)
|
||||
#else:
|
||||
#newtheme.add_background_image(str(self.theme.))
|
||||
|
||||
new_theme.add_font(str(self.theme.font_main_name), str(self.theme.font_main_color), str(self.theme.font_main_proportion), u'False')
|
||||
new_theme.add_font(str(self.theme.font_footer_name), str(self.theme.font_footer_color), str(self.theme.font_footer_proportion), u'False', u'footer')
|
||||
new_theme.add_display(str(self.theme.display_shadow), str(self.theme.display_shadow_color), str(self.theme.display_outline), str(self.theme.display_outline_color),
|
||||
str(self.theme.display_horizontalAlign), str(self.theme.display_verticalAlign), str(self.theme.display_wrapStyle))
|
||||
|
||||
theme = new_theme.extract_xml()
|
||||
self.thememanager.saveTheme(theme_name, theme)
|
||||
return QtGui.QDialog.accept(self)
|
||||
|
||||
def themePath(self, path):
|
||||
|
@ -140,6 +157,17 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||
self.theme.font_main_override = False
|
||||
else:
|
||||
self.theme.font_main_override = True
|
||||
|
||||
if int(self.theme.font_main_x) == 0 and int(self.theme.font_main_y) == 0 and \
|
||||
int(self.theme.font_main_width) == 0 and int(self.theme.font_main_height) == 0:
|
||||
self.theme.font_main_x = u'10'
|
||||
self.theme.font_main_y = u'10'
|
||||
self.theme.font_main_width = u'1024'
|
||||
self.theme.font_main_height = u'730'
|
||||
self.FontMainXSpinBox.setValue(int(self.theme.font_main_x))
|
||||
self.FontMainYSpinBox.setValue(int(self.theme.font_main_y))
|
||||
self.FontMainWidthSpinBox.setValue(int(self.theme.font_main_width))
|
||||
self.FontMainHeightSpinBox.setValue(int(self.theme.font_main_height))
|
||||
self.stateChanging(self.theme)
|
||||
self.previewTheme(self.theme)
|
||||
|
||||
|
@ -188,6 +216,19 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||
self.theme.font_footer_override = False
|
||||
else:
|
||||
self.theme.font_footer_override = True
|
||||
if int(self.theme.font_footer_x) == 0 and int(self.theme.font_footer_y) == 0 and \
|
||||
int(self.theme.font_footer_width) == 0 and int(self.theme.font_footer_height) == 0:
|
||||
self.theme.font_footer_x = u'10'
|
||||
self.theme.font_footer_y = u'730'
|
||||
self.theme.font_footer_width = u'1024'
|
||||
self.theme.font_footer_height = u'38'
|
||||
|
||||
self.FontFooterXSpinBox.setValue(int(self.theme.font_footer_x))
|
||||
self.FontFooterYSpinBox.setValue(int(self.theme.font_footer_y))
|
||||
self.FontFooterWidthSpinBox.setValue(int(self.theme.font_footer_width))
|
||||
self.FontFooterHeightSpinBox.setValue(int(self.theme.font_footer_height))
|
||||
|
||||
|
||||
self.stateChanging(self.theme)
|
||||
self.previewTheme(self.theme)
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ class ThemeManager(QWidget):
|
|||
if self.checkVersion1(xml_data):
|
||||
filexml = self.migrateVersion122(filename, fullpath, xml_data) # upgrade theme xml
|
||||
else:
|
||||
file_xml = xml_data
|
||||
filexml = xml_data
|
||||
outfile = open(fullpath, 'w')
|
||||
outfile.write(filexml)
|
||||
outfile.close()
|
||||
|
@ -322,6 +322,19 @@ class ThemeManager(QWidget):
|
|||
str(t.HorizontalAlign), str(t.VerticalAlign), str(t.WrapStyle))
|
||||
return newtheme.extract_xml()
|
||||
|
||||
def saveTheme(self, name, theme_xml) :
|
||||
self.generateAndSaveImage(self.path, name, theme_xml)
|
||||
theme_dir = os.path.join(self.path, name)
|
||||
if os.path.exists(theme_dir) == False:
|
||||
os.mkdir(os.path.join(self.path, name))
|
||||
|
||||
theme_file = os.path.join(theme_dir, name+u'.xml')
|
||||
outfile = open(theme_file, 'w')
|
||||
outfile.write(theme_xml)
|
||||
outfile.close()
|
||||
self.Theme_data.clearItems()
|
||||
self.loadThemes()
|
||||
|
||||
def generateAndSaveImage(self, dir, name, theme_xml):
|
||||
log.debug(u'generateImage %s %s %s', dir, name, theme_xml)
|
||||
theme = ThemeXML()
|
||||
|
@ -330,7 +343,7 @@ class ThemeManager(QWidget):
|
|||
frame = self.generateImage(theme)
|
||||
|
||||
im=frame.toImage()
|
||||
samplepathname=os.path.join(dir, name+u'.png')
|
||||
samplepathname=os.path.join(self.path, name+u'.png')
|
||||
if os.path.exists(samplepathname):
|
||||
os.unlink(samplepathname)
|
||||
im.save(samplepathname, u'png')
|
||||
|
|
Loading…
Reference in New Issue