diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index 33ba25046..80d677386 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -37,6 +37,7 @@ class HideMode(object): Theme = 2 Screen = 3 +from filerenameform import FileRenameForm from maindisplay import MainDisplay from slidecontroller import HideMode from servicenoteform import ServiceNoteForm diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index d181ad0d1..8c344e662 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -27,7 +27,6 @@ from PyQt4 import QtCore, QtGui from exceptiondialog import Ui_ExceptionDialog -from openlp.core.lib import translate class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): """ diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index cd2cfefad..7f20e661c 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -32,7 +32,7 @@ import logging from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtCore, QtGui -from openlp.core.ui import AmendThemeForm +from openlp.core.ui import AmendThemeForm, FileRenameForm from openlp.core.theme import Theme from openlp.core.lib import OpenLPToolbar, context_menu_action, \ ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \ @@ -54,6 +54,7 @@ class ThemeManager(QtGui.QWidget): self.layout.setSpacing(0) self.layout.setMargin(0) self.amendThemeForm = AmendThemeForm(self) + self.fileRenameForm = FileRenameForm(self) self.toolbar = OpenLPToolbar(self) self.toolbar.addToolbarButton( translate('OpenLP.ThemeManager', 'New Theme'), @@ -93,6 +94,16 @@ class ThemeManager(QtGui.QWidget): u':/themes/theme_edit.png', translate('OpenLP.ThemeManager', '&Edit Theme'), self.onEditTheme)) + self.themeListWidget.addAction( + context_menu_action(self.themeListWidget, + u':/themes/theme_edit.png', + translate('OpenLP.ThemeManager', '&Rename Theme'), + self.onRenameTheme)) + self.themeListWidget.addAction( + context_menu_action(self.themeListWidget, + u':/themes/theme_edit.png', + translate('OpenLP.ThemeManager', '&Copy Theme'), + self.onCopyTheme)) self.themeListWidget.addAction( context_menu_separator(self.themeListWidget)) self.themeListWidget.addAction( @@ -189,6 +200,33 @@ class ThemeManager(QtGui.QWidget): self.saveThemeName = u'' self.amendThemeForm.exec_() + def onRenameTheme(self): + """ + Renames an existing theme to a new name + """ + item = self.themeListWidget.currentItem() + oldThemeName = unicode(item.text()) + self.fileRenameForm.FileNameEdit.setText(oldThemeName) + if self.fileRenameForm.exec_(): + newThemeName = self.fileRenameForm.FileNameEdit.text() + print oldThemeName, newThemeName + + def onCopyTheme(self): + """ + Copies an existing theme to a new name + """ + item = self.themeListWidget.currentItem() + oldThemeName = unicode(item.text()) + self.fileRenameForm.FileNameEdit.setText(oldThemeName) + if self.fileRenameForm.exec_(): + newThemeName = self.fileRenameForm.FileNameEdit.text() + print oldThemeName, newThemeName + print self.path + source = os.path.join(self.path, oldThemeName) + for files in os.walk(source): + for name in files[2]: + print name + def onEditTheme(self): """ Loads the settings for the theme that is to be edited and launches the