more fixes

This commit is contained in:
Philip Ridout 2017-09-24 21:26:39 +01:00
parent 047a1b3808
commit 2c52059275
2 changed files with 6 additions and 12 deletions

View File

@ -511,7 +511,7 @@ class AdvancedTab(SettingsTab):
# Check if data already exists here.
self.check_data_overwrite(new_path)
# Save the new location.
self.main_window.set_new_data_path(path_to_str(new_data_path))
self.main_window.new_data_path = new_path
self.data_directory_cancel_button.show()
def on_data_directory_copy_check_box_toggled(self):
@ -562,7 +562,7 @@ class AdvancedTab(SettingsTab):
"""
self.data_directory_path_edit.path = AppLocation.get_data_path()
self.data_directory_copy_check_box.setChecked(False)
self.main_window.set_new_data_path(None)
self.main_window.new_data_path = None
self.main_window.set_copy_data(False)
self.data_directory_copy_check_box.hide()
self.data_directory_cancel_button.hide()

View File

@ -1332,12 +1332,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
if self.application:
self.application.process_events()
def set_new_data_path(self, new_data_path):
"""
Set the new data path
"""
self.new_data_path = new_data_path
def set_copy_data(self, copy_data):
"""
Set the flag to copy the data
@ -1349,7 +1343,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
Change the data directory.
"""
log.info('Changing data path to {newpath}'.format(newpath=self.new_data_path))
old_data_path = str(AppLocation.get_data_path())
old_data_path = AppLocation.get_data_path()
# Copy OpenLP data to new location if requested.
self.application.set_busy_cursor()
if self.copy_data:
@ -1358,7 +1352,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
self.show_status_message(
translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - {path} '
'- Please wait for copy to finish').format(path=self.new_data_path))
dir_util.copy_tree(old_data_path, self.new_data_path)
dir_util.copy_tree(str(old_data_path), str(self.new_data_path))
log.info('Copy successful')
except (IOError, os.error, DistutilsFileError) as why:
self.application.set_normal_cursor()
@ -1373,9 +1367,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, RegistryProperties):
log.info('No data copy requested')
# Change the location of data directory in config file.
settings = QtCore.QSettings()
settings.setValue('advanced/data path', Path(self.new_data_path))
settings.setValue('advanced/data path', self.new_data_path)
# Check if the new data path is our default.
if self.new_data_path == str(AppLocation.get_directory(AppLocation.DataDir)):
if self.new_data_path == AppLocation.get_directory(AppLocation.DataDir):
settings.remove('advanced/data path')
self.application.set_normal_cursor()