Skip to content

Commit

Permalink
added clearing of the recent file list
Browse files Browse the repository at this point in the history
  • Loading branch information
matkuki committed Jan 28, 2023
1 parent f53e147 commit 538c7b9
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
13 changes: 7 additions & 6 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.


---------------------------------------------------------------------------------

Copyright (c) 2013-2018 Matic Kukovec. All rights reserved.

For complete licences of the dependencies, check the 'additional_licenses' directory.
5 changes: 2 additions & 3 deletions data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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") \
Expand Down
25 changes: 24 additions & 1 deletion gui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.")


"""
Expand Down
18 changes: 18 additions & 0 deletions settings/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 538c7b9

Please sign in to comment.