switching "set watching" and "set completed" to "set unwatched" if the status is watching or completed
This commit is contained in:
parent
de63ffc509
commit
307cd2fd43
39
frontend.py
39
frontend.py
@ -98,8 +98,8 @@ Global Shortcuts:
|
||||
Table-specific Shortcuts (apply to selected entry):
|
||||
- Delete: Delete an anime
|
||||
- E: Edit
|
||||
- W: Set to watching
|
||||
- C: Set to completed
|
||||
- W: Set to watching / Set to unwatched (toggle if watching)
|
||||
- C: Set to completed / Set to unwatched (toggle if completed)
|
||||
""")
|
||||
layout.addWidget(shortcuts_text)
|
||||
buttons = QDialogButtonBox(QDialogButtonBox.Ok)
|
||||
@ -119,6 +119,8 @@ class CustomTableWidget(QTableWidget):
|
||||
if selected_rows:
|
||||
row = selected_rows[0].row()
|
||||
anime_id = int(self.item(row, 0).text())
|
||||
status_col = 4 if self.is_pre else 3
|
||||
status = self.item(row, status_col).text()
|
||||
if key == Qt.Key_Delete:
|
||||
self.parent_window.delete_anime(anime_id)
|
||||
return
|
||||
@ -126,10 +128,12 @@ class CustomTableWidget(QTableWidget):
|
||||
self.parent_window.edit_anime(anime_id)
|
||||
return
|
||||
elif key == Qt.Key_W:
|
||||
self.parent_window.change_status(anime_id, 'watching')
|
||||
new_status = 'watching' if status == 'unwatched' else 'unwatched'
|
||||
self.parent_window.change_status(anime_id, new_status)
|
||||
return
|
||||
elif key == Qt.Key_C:
|
||||
self.parent_window.change_status(anime_id, 'completed')
|
||||
new_status = 'completed' if status == 'unwatched' else 'unwatched'
|
||||
self.parent_window.change_status(anime_id, new_status)
|
||||
return
|
||||
super().keyPressEvent(event)
|
||||
|
||||
@ -447,14 +451,25 @@ class AnimeTracker(QMainWindow):
|
||||
del_btn.clicked.connect(lambda: self.delete_anime(anime_id))
|
||||
layout.addWidget(del_btn)
|
||||
# Status buttons
|
||||
for st in ['unwatched', 'watching', 'completed']:
|
||||
btn = QToolButton()
|
||||
btn.setText(st[0].upper())
|
||||
btn.setToolTip(f"Set to {st}")
|
||||
if st == status:
|
||||
btn.setEnabled(False)
|
||||
btn.clicked.connect(lambda _, s=st: self.change_status(anime_id, s))
|
||||
layout.addWidget(btn)
|
||||
if status == 'unwatched':
|
||||
# Add W and C
|
||||
btn_w = QToolButton()
|
||||
btn_w.setText("W")
|
||||
btn_w.setToolTip("Set to watching")
|
||||
btn_w.clicked.connect(lambda: self.change_status(anime_id, 'watching'))
|
||||
layout.addWidget(btn_w)
|
||||
btn_c = QToolButton()
|
||||
btn_c.setText("C")
|
||||
btn_c.setToolTip("Set to completed")
|
||||
btn_c.clicked.connect(lambda: self.change_status(anime_id, 'completed'))
|
||||
layout.addWidget(btn_c)
|
||||
else:
|
||||
# Add U
|
||||
btn_u = QToolButton()
|
||||
btn_u.setText("U")
|
||||
btn_u.setToolTip("Set to unwatched")
|
||||
btn_u.clicked.connect(lambda: self.change_status(anime_id, 'unwatched'))
|
||||
layout.addWidget(btn_u)
|
||||
return widget
|
||||
|
||||
def add_anime(self):
|
||||
|
Loading…
Reference in New Issue
Block a user