(parent, name_field, password_field)
| 376 | |
| 377 | |
| 378 | def on_login_button_clicked(parent, name_field, password_field): |
| 379 | name = name_field.text().strip() |
| 380 | password = password_field.text().strip() |
| 381 | |
| 382 | if not name or not password: |
| 383 | show_popup_message(parent, "Please enter your name and password.", HOME_PAGE) |
| 384 | else: |
| 385 | try: |
| 386 | # Ideally, here you'd call a backend authentication check |
| 387 | success = backend.check_admin(name, password) |
| 388 | if success: |
| 389 | QtWidgets.QMessageBox.information( |
| 390 | parent, "Login Successful", f"Welcome, {name}!" |
| 391 | ) |
| 392 | else: |
| 393 | QtWidgets.QMessageBox.warning( |
| 394 | parent, "Login Failed", "Incorrect name or password." |
| 395 | ) |
| 396 | except Exception as e: |
| 397 | QtWidgets.QMessageBox.critical( |
| 398 | parent, "Error", f"An error occurred during login: {str(e)}" |
| 399 | ) |
| 400 | |
| 401 | |
| 402 | def create_home_page(parent, on_admin_clicked, on_employee_clicked, on_exit_clicked): |
nothing calls this directly
no test coverage detected