Skip to content

Commit

Permalink
Open Last Item: Show an error message if no last item
Browse files Browse the repository at this point in the history
Also de-duplicate the code
  • Loading branch information
L3337 committed Dec 11, 2022
1 parent 4c7ee37 commit 8e3538b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 1 addition & 9 deletions src/sgui/daw/item_editor/notes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions src/sgui/daw/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 """
Expand Down

0 comments on commit 8e3538b

Please sign in to comment.