Clean up theme export

This commit is contained in:
Tim Bentley 2017-05-21 08:11:36 +01:00
parent 08a58844c6
commit fa89be414c
2 changed files with 7 additions and 9 deletions

View File

@ -698,7 +698,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'OpenLP Service Files (*.osz);; OpenLP Service Files - lite (*.oszl)')) 'OpenLP Service Files (*.osz);; OpenLP Service Files - lite (*.oszl)'))
else: else:
file_name, filter_uesd = QtWidgets.QFileDialog.getSaveFileName( file_name, filter_used = QtWidgets.QFileDialog.getSaveFileName(
self.main_window, UiStrings().SaveService, path, self.main_window, UiStrings().SaveService, path,
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz);;')) translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz);;'))
if not file_name: if not file_name:

View File

@ -379,11 +379,10 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ThemeManage
critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.')) critical_error_message_box(message=translate('OpenLP.ThemeManager', 'You have not selected a theme.'))
return return
theme = item.data(QtCore.Qt.UserRole) theme = item.data(QtCore.Qt.UserRole)
path = QtWidgets.QFileDialog.getExistingDirectory(self, path, filter_used = QtWidgets.QFileDialog.getSaveFileName(self.main_window,
translate('OpenLP.ThemeManager', translate('OpenLP.ThemeManager', 'Save Theme - ({name})').format(name=theme),
'Save Theme - ({name})').format(name=theme), Settings().value(self.settings_section + '/last directory export'),
Settings().value(self.settings_section + translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'))
'/last directory export'))
self.application.set_busy_cursor() self.application.set_busy_cursor()
if path: if path:
Settings().setValue(self.settings_section + '/last directory export', path) Settings().setValue(self.settings_section + '/last directory export', path)
@ -394,13 +393,12 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ThemeManage
'Your theme has been successfully exported.')) 'Your theme has been successfully exported.'))
self.application.set_normal_cursor() self.application.set_normal_cursor()
def _export_theme(self, path, theme): def _export_theme(self, theme_path, theme):
""" """
Create the zipfile with the theme contents. Create the zipfile with the theme contents.
:param path: Location where the zip file will be placed :param theme_path: Location where the zip file will be placed
:param theme: The name of the theme to be exported :param theme: The name of the theme to be exported
""" """
theme_path = os.path.join(path, theme + '.otz')
theme_zip = None theme_zip = None
try: try:
theme_zip = zipfile.ZipFile(theme_path, 'w') theme_zip = zipfile.ZipFile(theme_path, 'w')