diff --git a/main.py b/main.py index 25823c5..2eda037 100755 --- a/main.py +++ b/main.py @@ -20,7 +20,8 @@ from PyQt6.QtCore import ( pyqtSlot, ) from PyQt6.QtSql import QSqlDatabase, QSqlQuery, QSqlQueryModel -from PyQt6.QtWidgets import QApplication, QFileDialog, QMainWindow +from PyQt6.QtWidgets import QApplication, QFileDialog, QMainWindow, QMenu +from PyQt6.QtGui import QContextMenuEvent from lib import Book, PersonDialog, ReadDialog, SessionDialog, query_error from lib.preferences import Preferences @@ -59,6 +60,20 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.show() return + def contextMenuEvent(self, event: QContextMenuEvent) -> None: + localPos = self.peopleView.mapFromGlobal(event.globalPos()) + if not self.peopleView.rect().contains(localPos): + return + index = self.peopleView.indexAt(localPos) + if index.row() < 0: + return + menu = QMenu(self) + menu.addAction(self.actionRead) + self.actionEditPerson.setEnabled(True) + menu.addAction(self.actionEditPerson) + menu.exec(event.globalPos()) + return + @pyqtSlot() def editPreferences(self) -> None: dlg = Preferences()