Compare commits

..

No commits in common. "277abe79d7d756e199118436e03f2c561d2bbe6c" and "8db7eae1e411dc4e0bd3b266ddf3a56318660121" have entirely different histories.

9 changed files with 73 additions and 225 deletions

Binary file not shown.

View File

@ -2,19 +2,20 @@ import sys
from PySide6 import QtWidgets, QtCore from PySide6 import QtWidgets, QtCore
from ui.window import LibraryWindow from ui.dashboard import LibraryDashboard
if __name__ == "__main__": if __name__ == "__main__":
app = QtWidgets.QApplication([]) app = QtWidgets.QApplication([])
window = LibraryWindow() window = LibraryDashboard()
window.show() window.show()
sys.exit(app.exec()) sys.exit(app.exec())
# from sqlalchemy import create_engine # from sqlalchemy import create_engine
# from sqlalchemy.orm import sessionmaker # from sqlalchemy.orm import sessionmaker
# from models.book_overview_view import BookOverviewView # from models.book import Book, BookStatusEnum
# from models.author import Author
# # Replace with your MySQL database credentials # # Replace with your MySQL database credentials
# DATABASE_URI = 'mysql+mysqlconnector://username:password@localhost:3306/library' # DATABASE_URI = 'mysql+mysqlconnector://username:password@localhost:3306/library'
@ -31,8 +32,8 @@ if __name__ == "__main__":
# # Create a session instance # # Create a session instance
# session = SessionLocal() # session = SessionLocal()
# books = session.query(BookOverviewView).all() # books = session.query(Book).all()
# for book in books: # for book in books:
# print(book.title, book.author_name, book.categories) # print(book.title, book.author.first_name)
# session.close() # session.close()

View File

@ -7,6 +7,4 @@ from .member import Member
from .librarian import Librarian from .librarian import Librarian
from .loan import Loan from .loan import Loan
from .book_overview_view import BookOverviewView __all__ = ["Author", "Book", "BookCategory", "BookCategoryLink", "Member", "Librarian", "Loan"]
__all__ = ["Author", "Book", "BookCategory", "BookCategoryLink", "Member", "Librarian", "Loan", "BookOverviewView"]

View File

@ -1,16 +0,0 @@
from sqlalchemy import Column, String, TIMESTAMP, Integer
from .base import Base
class BookOverviewView(Base):
__tablename__ = 'books_overview'
id = Column(Integer, primary_key=True, autoincrement=True)
title = Column(String())
author_name = Column(String())
categories = Column(String())
year_published = Column(String())
isbn = Column(String())
created_at = Column(TIMESTAMP())
borrower_name = Column(String())
librarian_name = Column(String())

View File

@ -1,19 +0,0 @@
from PySide6.QtGui import QGuiApplication, QAction
from PySide6.QtQml import QQmlApplicationEngine
from PySide6 import QtWidgets, QtCore
class BookEditor(QtWidgets.QWidget):
def __init__(self):
super().__init__()
# Central widget and layout
main_layout = QtWidgets.QVBoxLayout(self)
# Title label
title_label = QtWidgets.QLabel("Books", self)
title_label.setAlignment(QtCore.Qt.AlignCenter)
title_label.setStyleSheet("font-size: 20px; font-weight: bold; color: #0078D4;")
main_layout.addWidget(title_label)
self.setLayout(main_layout)

View File

@ -3,50 +3,37 @@ from PySide6.QtQml import QQmlApplicationEngine
from PySide6 import QtWidgets, QtCore from PySide6 import QtWidgets, QtCore
from ui.settings import SettingsDialog from ui.settings import SettingsDialog
class LibraryDashboard(QtWidgets.QWidget):
class LibraryDashboard(QtWidgets.QMainWindow):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
# Set up main window properties
self.setWindowTitle("Library Dashboard")
self.setGeometry(100, 100, 400, 400)
# Set up menu bar
self.create_menu_bar()
# Central widget and layout # Central widget and layout
main_layout = QtWidgets.QVBoxLayout(self) central_widget = QtWidgets.QWidget()
self.setCentralWidget(central_widget)
main_layout = QtWidgets.QVBoxLayout(central_widget)
# Title label # Title label
title_label = QtWidgets.QLabel("Dashboard", self) title_label = QtWidgets.QLabel("Library Dashboard", self)
title_label.setAlignment(QtCore.Qt.AlignCenter) title_label.setAlignment(QtCore.Qt.AlignCenter)
title_label.setStyleSheet("font-size: 20px; font-weight: bold; color: #0078D4;") title_label.setStyleSheet("font-size: 20px; font-weight: bold; color: #0078D4;")
main_layout.addWidget(title_label) main_layout.addWidget(title_label)
# Available books list # Available books list
available_label = QtWidgets.QLabel("Available Books") available_label = QtWidgets.QLabel("Available Books")
available_label.setStyleSheet("font-size: 16px;") available_label.setStyleSheet("font-size: 16px;")
main_layout.addWidget(available_label) main_layout.addWidget(available_label)
# Search bar
self.search_input = QtWidgets.QLineEdit()
self.search_input.setPlaceholderText("Type to search...")
self.search_input.textChanged.connect(self.filter_books)
main_layout.addWidget(self.search_input)
self.available_books_list = QtWidgets.QListWidget() self.available_books_list = QtWidgets.QListWidget()
self.books = ["Book One", "Book Two", "Book Three", "Book Four", self.available_books_list.addItems(["Book One", "Book Two", "Book Three", "Book Four","Book One", "Book Two", "Book Three", "Book Four","Book One", "Book Two", "Book Three", "Book Four"])
"Book Five", "Book Six", "Book Seven", "Book Eight"]
self.available_books_list.addItems(self.books)
self.available_books_list.itemClicked.connect(self.edit_book) self.available_books_list.itemClicked.connect(self.edit_book)
self.available_books_list.setStyleSheet("""
QListWidget {
font-size: 14px;
}
QListWidget::item {
padding: 5px;
}
QListWidget::item:hover {
background-color: palette(highlight);
color: palette(highlighted-text);
}
""")
main_layout.addWidget(self.available_books_list) main_layout.addWidget(self.available_books_list)
# Borrowed books list # Borrowed books list
@ -71,12 +58,6 @@ class LibraryDashboard(QtWidgets.QWidget):
main_layout.addLayout(button_layout) main_layout.addLayout(button_layout)
def filter_books(self, text):
"""Filter the available books list based on the search input."""
self.available_books_list.clear()
filtered_books = [book for book in self.books if text.lower() in book.lower()]
self.available_books_list.addItems(filtered_books)
# Slots for button actions # Slots for button actions
def edit_book(self, item): def edit_book(self, item):
QtWidgets.QMessageBox.information(self, "Edit Book", f"Edit details for '{item.text()}'.") QtWidgets.QMessageBox.information(self, "Edit Book", f"Edit details for '{item.text()}'.")
@ -90,3 +71,55 @@ class LibraryDashboard(QtWidgets.QWidget):
def add_borrow_record(self): def add_borrow_record(self):
QtWidgets.QMessageBox.information(self, "Add Borrow Record", "Open dialog to add a borrow record.") QtWidgets.QMessageBox.information(self, "Add Borrow Record", "Open dialog to add a borrow record.")
def create_menu_bar(self):
# Create the menu bar
menu_bar = self.menuBar()
# File menu
file_menu = menu_bar.addMenu("File")
import_action = QAction("Import", self)
import_action.triggered.connect(self.import_data)
file_menu.addAction(import_action)
export_action = QAction("Export", self)
export_action.triggered.connect(self.export_data)
file_menu.addAction(export_action)
file_menu.addSeparator()
exit_action = QAction("Exit", self)
exit_action.triggered.connect(self.close)
file_menu.addAction(exit_action)
# Edit menu
edit_menu = menu_bar.addMenu("Edit")
preferences = QAction("Preferences", self)
preferences.triggered.connect(self.edit_preferences)
edit_menu.addAction(preferences)
# Help menu
help_menu = menu_bar.addMenu("Help")
about_action = QAction("About", self)
about_action.triggered.connect(self.about)
help_menu.addAction(about_action)
# Menu action slots
def edit_preferences(self):
dialog = SettingsDialog(parent=self)
if dialog.exec() == QtWidgets.QDialog.Accepted:
print("Settings were saved.")
def open_file(self):
QtWidgets.QMessageBox.information(self, "Open File", "Open an existing file.")
def import_data(self):
pass
def export_data(self):
pass
def about(self):
QtWidgets.QMessageBox.information(self, "About", "Library Dashboard v1.0\nDeveloped by You.")

View File

@ -1,27 +0,0 @@
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)

View File

@ -1,19 +0,0 @@
from PySide6.QtGui import QGuiApplication, QAction
from PySide6.QtQml import QQmlApplicationEngine
from PySide6 import QtWidgets, QtCore
class MemberEditor(QtWidgets.QWidget):
def __init__(self):
super().__init__()
# Central widget and layout
main_layout = QtWidgets.QVBoxLayout(self)
# Title label
title_label = QtWidgets.QLabel("Members", self)
title_label.setAlignment(QtCore.Qt.AlignCenter)
title_label.setStyleSheet("font-size: 20px; font-weight: bold; color: #0078D4;")
main_layout.addWidget(title_label)
self.setLayout(main_layout)

View File

@ -1,103 +0,0 @@
from PySide6.QtGui import QGuiApplication, QAction, QIcon
from PySide6.QtQml import QQmlApplicationEngine
from PySide6 import QtWidgets, QtCore
from ui.dashboard.dashboard import LibraryDashboard
from ui.book_editor.book_editor import BookEditor
from ui.member_editor.member_editor import MemberEditor
from ui.settings import SettingsDialog
class LibraryWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
# Set up main window properties
self.setWindowTitle("Library App")
self.setGeometry(0, 0, 800, 600)
self.center_window()
# Set up menu bar
self.create_menu_bar()
# Central widget and layout
central_widget = QtWidgets.QTabWidget()
self.setCentralWidget(central_widget)
central_widget.addTab(LibraryDashboard(), "Dashboard")
central_widget.addTab(BookEditor(), "Books")
central_widget.addTab(MemberEditor(), "Members")
def center_window(self):
# Get the screen geometry
screen = QtWidgets.QApplication.primaryScreen()
screen_geometry = screen.geometry()
# Get the dimensions of the window
window_geometry = self.frameGeometry()
# Calculate the center point of the screen
center_point = screen_geometry.center()
# Move the window geometry to the center of the screen
window_geometry.moveCenter(center_point)
# Move the window to the calculated geometry
self.move(window_geometry.topLeft())
def create_menu_bar(self):
# Create the menu bar
menu_bar = self.menuBar()
# File menu
file_menu = menu_bar.addMenu("File")
import_action = QAction("Import", self)
import_action.triggered.connect(self.import_data)
file_menu.addAction(import_action)
export_action = QAction("Export", self)
export_action.triggered.connect(self.export_data)
file_menu.addAction(export_action)
file_menu.addSeparator()
exit_action = QAction("Exit", self)
exit_action.setShortcut("Ctrl+Q")
exit_action.triggered.connect(self.close)
file_menu.addAction(exit_action)
# Edit menu
edit_menu = menu_bar.addMenu("Edit")
preferences = QAction("Preferences", self)
preferences.triggered.connect(self.edit_preferences)
edit_menu.addAction(preferences)
# Help menu
help_menu = menu_bar.addMenu("Help")
about_action = QAction("About", self)
about_action.triggered.connect(self.about)
help_menu.addAction(about_action)
# Menu action slots
def edit_preferences(self):
dialog = SettingsDialog(parent=self)
if dialog.exec() == QtWidgets.QDialog.Accepted:
print("Settings were saved.")
def open_file(self):
QtWidgets.QMessageBox.information(self, "Open File", "Open an existing file.")
def import_data(self):
pass
def export_data(self):
pass
def about(self):
QtWidgets.QMessageBox.information(self, "About", "Library Dashboard v1.0\nDeveloped by You.")