Merge branch 'develop' into coretk-enhance/error-dialog
This commit is contained in:
commit
80f47a5d4c
22 changed files with 599 additions and 343 deletions
|
@ -24,6 +24,8 @@ from core.gui.dialogs.sessions import SessionsDialog
|
|||
from core.gui.dialogs.throughput import ThroughputDialog
|
||||
from core.gui.task import BackgroundTask
|
||||
|
||||
MAX_FILES = 3
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.gui.app import Application
|
||||
|
||||
|
@ -86,6 +88,7 @@ class MenuAction:
|
|||
defaultextension=".xml",
|
||||
)
|
||||
if file_path:
|
||||
self.add_recent_file_to_gui_config(file_path)
|
||||
self.app.core.save_xml(file_path)
|
||||
|
||||
def file_open_xml(self, event: tk.Event = None):
|
||||
|
@ -101,6 +104,7 @@ class MenuAction:
|
|||
|
||||
def open_xml_task(self, filename):
|
||||
if filename:
|
||||
self.add_recent_file_to_gui_config(filename)
|
||||
self.app.core.xml_file = filename
|
||||
self.app.core.xml_dir = str(os.path.dirname(filename))
|
||||
self.prompt_save_running_session()
|
||||
|
@ -170,3 +174,21 @@ class MenuAction:
|
|||
def config_throughput(self):
|
||||
dialog = ThroughputDialog(self.app, self.app)
|
||||
dialog.show()
|
||||
|
||||
def add_recent_file_to_gui_config(self, file_path):
|
||||
recent_files = self.app.guiconfig["recentfiles"]
|
||||
num_files = len(recent_files)
|
||||
if num_files == 0:
|
||||
recent_files.insert(0, file_path)
|
||||
elif 0 < num_files <= MAX_FILES:
|
||||
if file_path in recent_files:
|
||||
recent_files.remove(file_path)
|
||||
recent_files.insert(0, file_path)
|
||||
else:
|
||||
if num_files == MAX_FILES:
|
||||
recent_files.pop()
|
||||
recent_files.insert(0, file_path)
|
||||
else:
|
||||
logging.error("unexpected number of recent files")
|
||||
self.app.save_config()
|
||||
self.app.menubar.update_recent_files()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue