lambda/src/ui/dashboard/book_list_entry.py

28 lines
775 B
Python

from PySide6.QtGui import QGuiApplication, QAction
from PySide6.QtQml import QQmlApplicationEngine
from PySide6 import QtWidgets, QtCore
from models.book import BookStatusEnum
STATUS_TO_COLOR_MAP = {
BookStatusEnum.available: "highlight",
BookStatusEnum.borrowed: "highlighted-text",
BookStatusEnum.reserved: "base"
}
class BookListEntry(QtWidgets.QWidget):
def __init__(self, title, status):
super().__init__()
layout = QtWidgets.QHBoxLayout(self)
book_label = QtWidgets.QLabel(title)
layout.addWidget(book_label)
status_label = QtWidgets.QLabel(status)
status_label.setStyleSheet(f"color: palette({STATUS_TO_COLOR_MAP[status]});")
layout.addWidget(status_label)
self.setLayout(layout)