forked from openlp/openlp
Basic Theme copy and rename working
This commit is contained in:
parent
6351e65c1c
commit
cc42dc34d8
@ -217,7 +217,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.imageLineEdit.setText(filename)
|
self.imageLineEdit.setText(filename)
|
||||||
self.theme.background_filename = filename
|
self.theme.background_filename = filename
|
||||||
self.previewTheme()
|
self.previewTheme()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main Font Tab
|
# Main Font Tab
|
||||||
#
|
#
|
||||||
@ -301,7 +300,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
if self.theme.font_main_height != self.fontMainHeightSpinBox.value():
|
if self.theme.font_main_height != self.fontMainHeightSpinBox.value():
|
||||||
self.theme.font_main_height = self.fontMainHeightSpinBox.value()
|
self.theme.font_main_height = self.fontMainHeightSpinBox.value()
|
||||||
self.previewTheme()
|
self.previewTheme()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Footer Font Tab
|
# Footer Font Tab
|
||||||
#
|
#
|
||||||
@ -382,7 +380,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.theme.font_footer_height = \
|
self.theme.font_footer_height = \
|
||||||
self.fontFooterHeightSpinBox.value()
|
self.fontFooterHeightSpinBox.value()
|
||||||
self.previewTheme()
|
self.previewTheme()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Background Tab
|
# Background Tab
|
||||||
#
|
#
|
||||||
@ -442,7 +439,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.color2PushButton.setStyleSheet(u'background-color: %s' %
|
self.color2PushButton.setStyleSheet(u'background-color: %s' %
|
||||||
unicode(self.theme.background_end_color))
|
unicode(self.theme.background_end_color))
|
||||||
self.previewTheme()
|
self.previewTheme()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Other Tab
|
# Other Tab
|
||||||
#
|
#
|
||||||
@ -507,7 +503,6 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
|||||||
self.theme.display_vertical_align = currentIndex
|
self.theme.display_vertical_align = currentIndex
|
||||||
self.stateChanging(self.theme)
|
self.stateChanging(self.theme)
|
||||||
self.previewTheme()
|
self.previewTheme()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Local Methods
|
# Local Methods
|
||||||
#
|
#
|
||||||
|
@ -205,27 +205,86 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
Renames an existing theme to a new name
|
Renames an existing theme to a new name
|
||||||
"""
|
"""
|
||||||
item = self.themeListWidget.currentItem()
|
item = self.themeListWidget.currentItem()
|
||||||
oldThemeName = unicode(item.text())
|
oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||||
self.fileRenameForm.FileNameEdit.setText(oldThemeName)
|
self.fileRenameForm.FileNameEdit.setText(oldThemeName)
|
||||||
|
self.saveThemeName = u''
|
||||||
if self.fileRenameForm.exec_():
|
if self.fileRenameForm.exec_():
|
||||||
newThemeName = self.fileRenameForm.FileNameEdit.text()
|
newThemeName = unicode(self.fileRenameForm.FileNameEdit.text())
|
||||||
print oldThemeName, newThemeName
|
oldThemeData = self.getThemeData(oldThemeName)
|
||||||
|
self.deleteTheme(oldThemeName)
|
||||||
|
self.cloneThemeData(oldThemeData, newThemeName)
|
||||||
|
|
||||||
def onCopyTheme(self):
|
def onCopyTheme(self):
|
||||||
"""
|
"""
|
||||||
Copies an existing theme to a new name
|
Copies an existing theme to a new name
|
||||||
"""
|
"""
|
||||||
item = self.themeListWidget.currentItem()
|
item = self.themeListWidget.currentItem()
|
||||||
oldThemeName = unicode(item.text())
|
oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||||
self.fileRenameForm.FileNameEdit.setText(oldThemeName)
|
self.fileRenameForm.FileNameEdit.setText(oldThemeName)
|
||||||
|
self.saveThemeName = u''
|
||||||
if self.fileRenameForm.exec_():
|
if self.fileRenameForm.exec_():
|
||||||
newThemeName = self.fileRenameForm.FileNameEdit.text()
|
newThemeName = unicode(self.fileRenameForm.FileNameEdit.text())
|
||||||
print oldThemeName, newThemeName
|
oldThemeData = self.getThemeData(oldThemeName)
|
||||||
print self.path
|
self.cloneThemeData(oldThemeData, newThemeName)
|
||||||
source = os.path.join(self.path, oldThemeName)
|
self.loadThemes()
|
||||||
for files in os.walk(source):
|
|
||||||
for name in files[2]:
|
def cloneThemeData(self, oldThemeData, newThemeName):
|
||||||
print name
|
"""
|
||||||
|
"""
|
||||||
|
log.debug(u'cloneThemeData')
|
||||||
|
new_theme = ThemeXML()
|
||||||
|
new_theme.new_document(newThemeName)
|
||||||
|
save_from = None
|
||||||
|
save_to = None
|
||||||
|
if oldThemeData.background_type == u'solid':
|
||||||
|
new_theme.add_background_solid(
|
||||||
|
unicode(oldThemeData.background_color))
|
||||||
|
elif oldThemeData.background_type == u'gradient':
|
||||||
|
new_theme.add_background_gradient(
|
||||||
|
unicode(oldThemeData.background_start_color),
|
||||||
|
unicode(oldThemeData.background_end_color),
|
||||||
|
oldThemeData.background_direction)
|
||||||
|
else:
|
||||||
|
filename = \
|
||||||
|
os.path.split(unicode(oldThemeData.background_filename))[1]
|
||||||
|
new_theme.add_background_image(filename)
|
||||||
|
save_to = os.path.join(self.path, theme_name, filename)
|
||||||
|
save_from = oldThemeData.background_filename
|
||||||
|
new_theme.add_font(unicode(oldThemeData.font_main_name),
|
||||||
|
unicode(oldThemeData.font_main_color),
|
||||||
|
unicode(oldThemeData.font_main_proportion),
|
||||||
|
unicode(oldThemeData.font_main_override), u'main',
|
||||||
|
unicode(oldThemeData.font_main_weight),
|
||||||
|
unicode(oldThemeData.font_main_italics),
|
||||||
|
unicode(oldThemeData.font_main_line_adjustment),
|
||||||
|
unicode(oldThemeData.font_main_x),
|
||||||
|
unicode(oldThemeData.font_main_y),
|
||||||
|
unicode(oldThemeData.font_main_width),
|
||||||
|
unicode(oldThemeData.font_main_height))
|
||||||
|
new_theme.add_font(unicode(oldThemeData.font_footer_name),
|
||||||
|
unicode(oldThemeData.font_footer_color),
|
||||||
|
unicode(oldThemeData.font_footer_proportion),
|
||||||
|
unicode(oldThemeData.font_footer_override), u'footer',
|
||||||
|
unicode(oldThemeData.font_footer_weight),
|
||||||
|
unicode(oldThemeData.font_footer_italics),
|
||||||
|
0, # line adjustment
|
||||||
|
unicode(oldThemeData.font_footer_x),
|
||||||
|
unicode(oldThemeData.font_footer_y),
|
||||||
|
unicode(oldThemeData.font_footer_width),
|
||||||
|
unicode(oldThemeData.font_footer_height))
|
||||||
|
new_theme.add_display(unicode(oldThemeData.display_shadow),
|
||||||
|
unicode(oldThemeData.display_shadow_color),
|
||||||
|
unicode(oldThemeData.display_outline),
|
||||||
|
unicode(oldThemeData.display_outline_color),
|
||||||
|
unicode(oldThemeData.display_horizontal_align),
|
||||||
|
unicode(oldThemeData.display_vertical_align),
|
||||||
|
unicode(oldThemeData.display_wrap_style),
|
||||||
|
unicode(oldThemeData.display_slide_transition),
|
||||||
|
unicode(oldThemeData.display_shadow_size),
|
||||||
|
unicode(oldThemeData.display_outline_size))
|
||||||
|
theme = new_theme.extract_xml()
|
||||||
|
pretty_theme = new_theme.extract_formatted_xml()
|
||||||
|
self.saveTheme(newThemeName, theme, pretty_theme, save_from, save_to)
|
||||||
|
|
||||||
def onEditTheme(self):
|
def onEditTheme(self):
|
||||||
"""
|
"""
|
||||||
@ -248,7 +307,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
item.data(QtCore.Qt.UserRole).toString())
|
item.data(QtCore.Qt.UserRole).toString())
|
||||||
self.amendThemeForm.exec_()
|
self.amendThemeForm.exec_()
|
||||||
|
|
||||||
def onDeleteTheme(self):
|
def onDeleteTheme(self, onlyDelete=True):
|
||||||
"""
|
"""
|
||||||
Delete a theme
|
Delete a theme
|
||||||
"""
|
"""
|
||||||
|
@ -140,7 +140,7 @@ class SongsPlugin(Plugin):
|
|||||||
Song.theme_name == oldTheme)
|
Song.theme_name == oldTheme)
|
||||||
for song in songsUsingTheme:
|
for song in songsUsingTheme:
|
||||||
song.theme_name = newTheme
|
song.theme_name = newTheme
|
||||||
self.custommanager.save_object(song)
|
self.manager.save_object(song)
|
||||||
|
|
||||||
def importSongs(self, format, **kwargs):
|
def importSongs(self, format, **kwargs):
|
||||||
class_ = SongFormat.get_class(format)
|
class_ = SongFormat.get_class(format)
|
||||||
|
Loading…
Reference in New Issue
Block a user