ui changes, loan quit with hotkey q if no lineedit in focus

This commit is contained in:
WorldTeacher
2024-07-31 10:02:27 +02:00
parent a0fce94298
commit 6d4b274b30
5 changed files with 102 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
import omegaconf
import sys
# import argparse
__version__ = "0.0.1"
__author__ = "Alexander Kirchner"
@@ -9,5 +9,55 @@ config = omegaconf.OmegaConf.load("config/settings.yaml")
# if programm launched with argument --debug, set debug to True
if "--debug" in sys.argv:
config.debug = True
# if programm launched with argument --log, set log_debug
if "--log" in sys.argv:
config.log_debug = True
# arguments = argparse.ArgumentParser(
# prog="Ausleihsystem",
# description="Ein Ausleihsystem für Handbibliotheken",
# epilog="Version: {}".format(__version__),
# )
# arguments.add_argument(
# "-d",
# "--debug",
# action="store_true",
# help="Display debug messages in terminal",
# default=False,
# required=False,
# )
# arguments.add_argument(
# "-v",
# "--version",
# action="store_true",
# help="Display version number",
# default=False,
# required=False,
# )
# arguments.add_argument(
# "-l",
# "--log",
# action="store_true",
# help="Log debug messages to logfile",
# default=False,
# required=False,
# )
# arguments.add_argument(
# "--no-backup",
# action="store_true",
# help="Disable backup",
# default=False,
# required=False,
# )
# args = arguments.parse_args()
# # based on the arguments, set the config values
# if args.debug:
# config.debug = True
# if args.version:
# print(f"Version: {__version__}")
# sys.exit()
# if args.log:
# config.log_debug = True
# if args.no_backup:
# config.database.do_backup = False

View File

@@ -374,7 +374,6 @@ class MainUI(QtWidgets.QMainWindow, Ui_MainWindow):
self.btn_show_lentmedia.setText(
self.db.getActiveLoans(self.activeUser.id)
)
#
else:
# print("Book not loaned")
self.setStatusTipMessage("Buch nicht entliehen")

View File

@@ -70,9 +70,16 @@ class Ui_MainWindow(object):
self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 899, 22))
self.menubar.setObjectName("menubar")
self.menuDatei = QtWidgets.QMenu(parent=self.menubar)
self.menuDatei.setObjectName("menuDatei")
MainWindow.setMenuBar(self.menubar)
self.actionBeenden = QtGui.QAction(parent=MainWindow)
self.actionBeenden.setObjectName("actionBeenden")
self.menuDatei.addAction(self.actionBeenden)
self.menubar.addAction(self.menuDatei.menuAction())
self.retranslateUi(MainWindow)
self.actionBeenden.triggered.connect(MainWindow.close) # type: ignore
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
@@ -98,3 +105,6 @@ class Ui_MainWindow(object):
item.setText(_translate("MainWindow", "entliehen bis"))
item = self.loanTable.horizontalHeaderItem(6)
item.setText(_translate("MainWindow", "Zurückgegeben am"))
self.menuDatei.setTitle(_translate("MainWindow", "Datei"))
self.actionBeenden.setText(_translate("MainWindow", "Beenden"))
self.actionBeenden.setShortcut(_translate("MainWindow", "Q"))

View File

@@ -141,8 +141,40 @@
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuDatei">
<property name="title">
<string>Datei</string>
</property>
<addaction name="actionBeenden"/>
</widget>
<addaction name="menuDatei"/>
</widget>
<action name="actionBeenden">
<property name="text">
<string>Beenden</string>
</property>
<property name="shortcut">
<string>Q</string>
</property>
</action>
</widget>
<resources/>
<connections/>
<connections>
<connection>
<sender>actionBeenden</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>449</x>
<y>328</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -4,6 +4,7 @@ from src.logic import Database
from src.schemas import User
from .extendLoan import ExtendLoan
from src.utils import stringToDate, Icon
from src.utils import debugMessage as dbg
TABLETOFIELDTRANSLATE = {
"Titel": "title",
@@ -128,7 +129,7 @@ class UserUI(QtWidgets.QMainWindow, Ui_MainWindow):
if self.radio_currentlyLoaned.isChecked()
else "overdue"
)
# print(mode)
print(mode)
if self.userMedia == []:
books = self.db.getAllMedia(self.userno)
for book in books:
@@ -145,12 +146,15 @@ class UserUI(QtWidgets.QMainWindow, Ui_MainWindow):
continue
elif mode == "overdue":
# book not returned and todays date is greater than todate
if book.returned_date != "":
dbg(book=book)
if book.returned_date is not None:
continue
# if todate is greater than current date, continue
if todate > QtCore.QDate.currentDate():
continue
self.addBookToTable(book)
self.addBookToTable(book)
print(book.title)
def addBookToTable(self, book):
self.UserMediaTable.insertRow(0)
# item0 = isbn