From 8e3538ba1a0ca05d95dd570b3dcb86b656c095da Mon Sep 17 00:00:00 2001 From: Anon McHacker Date: Sat, 10 Dec 2022 20:21:11 -0800 Subject: [PATCH] Open Last Item: Show an error message if no last item Also de-duplicate the code --- src/sgui/daw/item_editor/notes/__init__.py | 10 +--------- src/sgui/daw/shared.py | 9 +++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/sgui/daw/item_editor/notes/__init__.py b/src/sgui/daw/item_editor/notes/__init__.py index 8a6e27ff..168de741 100644 --- a/src/sgui/daw/item_editor/notes/__init__.py +++ b/src/sgui/daw/item_editor/notes/__init__.py @@ -398,7 +398,7 @@ def __init__(self): 'Open the previously opened item. Use this to rapidly switch ' 'between 2 items you are editing' ) - self.open_last_action.triggered.connect(self.open_last) + self.open_last_action.triggered.connect(shared.open_last) self.open_last_action.setShortcut( QKeySequence.fromString("ALT+F"), ) @@ -465,14 +465,6 @@ def select_all(self): for f_note in shared.PIANO_ROLL_EDITOR.note_items: f_note.setSelected(True) - def open_last(self): - if shared.LAST_ITEM_NAME: - global_open_items( - shared.LAST_ITEM_NAME, - a_new_ref=shared.LAST_ITEM_REF, - ) - shared.PIANO_ROLL_EDITOR.draw_item() - def draw_last(self): shared.DRAW_LAST_ITEMS = not shared.DRAW_LAST_ITEMS self.draw_last_action.setChecked(shared.DRAW_LAST_ITEMS) diff --git a/src/sgui/daw/shared.py b/src/sgui/daw/shared.py index 78692aba..cba8180b 100644 --- a/src/sgui/daw/shared.py +++ b/src/sgui/daw/shared.py @@ -253,6 +253,15 @@ def open_last(): if LAST_ITEM_NAME: global_open_items(LAST_ITEM_NAME, a_new_ref=LAST_ITEM_REF) MAIN_WINDOW.tab_changed() + else: + QMessageBox.warning( + None, + "Error", + ( + "You musst open at least 2 items from the sequencer to use " + "this feature" + ), + ) def global_open_project(a_project_file): """ Opens or creates a new project """