ui to create new books in case of dupes
This commit is contained in:
38
src/ui/newBook.py
Normal file
38
src/ui/newBook.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
from .sources.Ui_dialog_addBook import Ui_Dialog
|
||||||
|
from src.schemas import Book
|
||||||
|
from src.utils import Icon
|
||||||
|
|
||||||
|
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
|
|
||||||
|
class NewBook(QtWidgets.QDialog, Ui_Dialog):
|
||||||
|
def __init__(self):
|
||||||
|
super(NewBook, self).__init__()
|
||||||
|
self.setupUi(self)
|
||||||
|
self.setWindowTitle("Buch hinzufügen")
|
||||||
|
self.setWindowIcon(Icon("addBook").icon)
|
||||||
|
self.btn_save.setEnabled(False)
|
||||||
|
self.btn_save.clicked.connect(self.saveBook)
|
||||||
|
self.btn_cancel.clicked.connect(self.reject)
|
||||||
|
self.book_title.setFocus()
|
||||||
|
self.book_title.textChanged.connect(self.checkFields)
|
||||||
|
self.book_signature.textChanged.connect(self.checkFields)
|
||||||
|
self.book = None
|
||||||
|
|
||||||
|
self.show()
|
||||||
|
|
||||||
|
def checkFields(self):
|
||||||
|
if (
|
||||||
|
self.book_title.hasAcceptableInput()
|
||||||
|
and self.book_signature.hasAcceptableInput
|
||||||
|
):
|
||||||
|
self.btn_save.setEnabled(True)
|
||||||
|
else:
|
||||||
|
self.btn_save.setEnabled(False)
|
||||||
|
|
||||||
|
def saveBook(self):
|
||||||
|
title = self.book_title.text()
|
||||||
|
signature = self.book_signature.text()
|
||||||
|
book = Book(title=title, signature=signature)
|
||||||
|
self.book = book
|
||||||
|
self.accept()
|
||||||
Reference in New Issue
Block a user