From 538c7b9178d6e83f1c66f47e72924dab61c2d432 Mon Sep 17 00:00:00 2001 From: Matic Kukovec Date: Sat, 28 Jan 2023 10:55:43 +0100 Subject: [PATCH] added clearing of the recent file list --- LICENSE.txt | 13 +++++++------ data.py | 5 ++--- gui/mainwindow.py | 25 ++++++++++++++++++++++++- settings/settings.py | 18 ++++++++++++++++++ 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 973c230..d9ff909 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,10 +1,4 @@ -Copyright (c) 2013-2018 Matic Kukovec. All rights reserved. - -For complete licences of the dependencies, check the 'additional_licenses' directory. - ------------------------------------------------------------ - GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -679,3 +673,10 @@ may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . + + +--------------------------------------------------------------------------------- + +Copyright (c) 2013-2018 Matic Kukovec. All rights reserved. + +For complete licences of the dependencies, check the 'additional_licenses' directory. diff --git a/data.py b/data.py index 52f8253..9040106 100644 --- a/data.py +++ b/data.py @@ -118,7 +118,7 @@ ## Built-in special function escape sequence: "lit#" ## (prepend it to escape built-ins like: cmain, set_all_text, lines, ...) -""" +\'\'\' # These imports are optional as they are already imported # by the REPL, I added them here for clarity. import data @@ -195,8 +195,7 @@ def delete_files_in_dir(extension=None, directory=None): print(" - deleted file: {:s}".format(file)) print("DONE") delete_files_in_dir.autocompletion = "delete_files_in_dir(extension=\"\", directory=None)" -""" - +\'\'\' ''' # Application icon image that will be displayed on all Qt widgets application_icon = os.path.join(resources_directory, "exco-icon.png") \ diff --git a/gui/mainwindow.py b/gui/mainwindow.py index 1c9f5c0..d2a5f22 100644 --- a/gui/mainwindow.py +++ b/gui/mainwindow.py @@ -818,6 +818,13 @@ def open_user_func_file(): reload_functions_action = create_action('Reload User Definitions', None, 'Reload the {} file to refresh user defined definitions and functions'.format(data.config_file), 'tango_icons/file-user-funcs-reload.png', self.import_user_functions) #Add recent file list in the file menu recent_file_list_menu = self.view.create_recent_file_list_menu() + clear_recent_file_list_action = create_action( + 'Clear recent files', + None, + 'Clear the recent files list', + 'tango_icons/edit-clear.png', + self.view.clear_recent_file_list, + ) #Add the actions to the File menu file_menu.addAction(new_file_action) file_menu.addAction(open_file_action) @@ -836,6 +843,7 @@ def open_user_func_file(): file_menu.addAction(reload_functions_action) file_menu.addSeparator() file_menu.addMenu(recent_file_list_menu) + file_menu.addAction(clear_recent_file_list_action) file_menu.addSeparator() file_menu.addAction(exit_action) #Edit Menus @@ -2853,7 +2861,10 @@ def new_file_function(file): temp_function = functools.partial(new_file_function, recent_file) new_file_action.triggered.connect(temp_function) recent_files_menu.addAction(new_file_action) - + + def clear_recent_list(self): + self.manipulator.clear_recent_files() + def restore(self): """Restore the previously stored settings""" # Load the settings from the initialization file @@ -3685,6 +3696,18 @@ def create_recent_file_list_menu(self): def delete_recent_file_list_menu(self): self._parent.recent_files_menu.setParent(None) self._parent.recent_files_menu = None + + def clear_recent_file_list(self): + warning = ( + "Are you sure you wish to delete\n" + + "the recent files list?" + ) + reply = YesNoDialog.warning(warning) + if reply == data.DialogResult.No.value: + return + self._parent.settings.clear_recent_list() + self._parent.settings.update_recent_list() + self._parent.display.repl_display_success("Recent file list cleared.") """ diff --git a/settings/settings.py b/settings/settings.py index 4c3fea7..59f4d36 100644 --- a/settings/settings.py +++ b/settings/settings.py @@ -244,6 +244,24 @@ def update_recent_files(self): self.context_menu_functions ) + def clear_recent_files(self): + if self.error_lock == True: + return + settings_data = functions.load_json_file( + self.settings_filename_with_path + ) + # Clear the recent file list + self.recent_files = [] + # Load the sessions + stored_sessions = settings_data["stored_sessions"] + # Save the updated settings + self.write_settings_file( + data.theme, + self.recent_files, + stored_sessions, + self.context_menu_functions + ) + def load_settings(self): """ Load all setting from the settings file