[main] Updated design for tab view, prepared for other tabs and general tweaks to design
This commit is contained in:
parent
8db7eae1e4
commit
6a1c76798d
19
src/ui/book_editor/book_editor.py
Normal file
19
src/ui/book_editor/book_editor.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
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)
|
||||||
|
|
27
src/ui/dashboard/book_list_entry.py
Normal file
27
src/ui/dashboard/book_list_entry.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
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)
|
@ -3,37 +3,50 @@ 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
|
||||||
central_widget = QtWidgets.QWidget()
|
main_layout = QtWidgets.QVBoxLayout(self)
|
||||||
self.setCentralWidget(central_widget)
|
|
||||||
main_layout = QtWidgets.QVBoxLayout(central_widget)
|
|
||||||
|
|
||||||
# Title label
|
# Title label
|
||||||
title_label = QtWidgets.QLabel("Library Dashboard", self)
|
title_label = QtWidgets.QLabel("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.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"])
|
self.books = ["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
|
||||||
@ -58,6 +71,12 @@ class LibraryDashboard(QtWidgets.QMainWindow):
|
|||||||
|
|
||||||
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()}'.")
|
||||||
@ -71,55 +90,3 @@ class LibraryDashboard(QtWidgets.QMainWindow):
|
|||||||
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.")
|
|
19
src/ui/member_editor/member_editor.py
Normal file
19
src/ui/member_editor/member_editor.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
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)
|
||||||
|
|
103
src/ui/window.py
Normal file
103
src/ui/window.py
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
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.")
|
Loading…
x
Reference in New Issue
Block a user