diff --git a/gui/__main__.py b/gui/__main__.py index 2b23078..66319fc 100644 --- a/gui/__main__.py +++ b/gui/__main__.py @@ -106,7 +106,7 @@ if is_compatable: # If the user lacks a database, we want to force them to sync the new data, to avoid NoneType errors when enabling existing profiles, if reason == "no_database": logger.info(f"[DB MANAGEMENT] User had no database to begin with, so now we're entering GUI with sync on..") - force_sync = False + force_sync = True else: logger.info(f"[DB MANAGEMENT] Launcher is now passing it off to launch the main GUI window WITHOUT force sync..") force_sync = False diff --git a/gui/__pycache__/__main__.cpython-312.pyc b/gui/__pycache__/__main__.cpython-312.pyc new file mode 100644 index 0000000..2398983 Binary files /dev/null and b/gui/__pycache__/__main__.cpython-312.pyc differ diff --git a/gui/__pycache__/main_ui.cpython-312.pyc b/gui/__pycache__/main_ui.cpython-312.pyc new file mode 100644 index 0000000..55972e6 Binary files /dev/null and b/gui/__pycache__/main_ui.cpython-312.pyc differ diff --git a/gui/main_ui.py b/gui/main_ui.py index 34bedc6..a12679d 100755 --- a/gui/main_ui.py +++ b/gui/main_ui.py @@ -12,7 +12,7 @@ from PyQt6.QtWidgets import ( QApplication, QMainWindow, QStackedWidget, QLabel, QPushButton, QDialog, QVBoxLayout, QHBoxLayout, QMessageBox ) -from PyQt6.QtGui import QPixmap, QFont, QFontDatabase +from PyQt6.QtGui import QPixmap, QFont, QFontDatabase, QIcon from PyQt6 import QtGui from PyQt6.QtCore import Qt, QTimer, QEvent @@ -196,21 +196,40 @@ class CustomWindow(QMainWindow): if self.force_sync: QTimer.singleShot(0, self._prompt_force_sync) + def _prompt_force_sync(self): + """ + Popup to encourage remote database sync + + Context: + Database loader in __main__ passes in the 'forced_sync' variable, + If true, this popup encourages sync to avoid NoneType errors. + """ connection = ConfigurationController.get_connection() box = QMessageBox(self) box.setWindowTitle("Data Update Needed") box.setText( "Please download the new data to avoid errors. You have profiles that need the data to function.\n\n" f"Connection type: {connection}") - style_message_box(box) - sync_button = box.addButton("Sync", QMessageBox.ButtonRole.AcceptRole) - mark_confirm_button(sync_button) - box.addButton("Cancel", QMessageBox.ButtonRole.RejectRole) + + # Apply styling + # import it inside the function to reduce load on non-display flows. + from gui.v2.ui.styles.css.main_ui_css import forced_sync_popup_style + stylesheet = forced_sync_popup_style + box.setStyleSheet(stylesheet) + + # Add styled buttons + sync_button = box.addButton("Ok Fetch", QMessageBox.ButtonRole.AcceptRole) + sync_button.setCursor(Qt.CursorShape.PointingHandCursor) + cancel_button = box.addButton("Cancel", QMessageBox.ButtonRole.RejectRole) + cancel_button.setCursor(Qt.CursorShape.PointingHandCursor) + box.setMinimumWidth(450) # button size box.exec() + if box.clickedButton() == sync_button: self.sync() + def perform_update_check(self): from core.controllers.ClientController import ClientController update_available = ClientController.can_be_updated() diff --git a/gui/v2/ui/pages/menu_page.py b/gui/v2/ui/pages/menu_page.py index 5904cea..2bca999 100755 --- a/gui/v2/ui/pages/menu_page.py +++ b/gui/v2/ui/pages/menu_page.py @@ -219,7 +219,7 @@ class MenuPage(Page): protocol = profile.connection.code - # print(f"DEBUG: the type is = {type(profile.location)}, value = {profile.location}") + print(f"DEBUG: the type is = {type(profile.location)}, value = {profile.location}") if isinstance(profile.location, dict): # Fake/missing data — show placeholders from data, diff --git a/gui/v2/ui/styles/css/main_ui_css.py b/gui/v2/ui/styles/css/main_ui_css.py new file mode 100644 index 0000000..c2b4fab --- /dev/null +++ b/gui/v2/ui/styles/css/main_ui_css.py @@ -0,0 +1,22 @@ + + +forced_sync_popup_style = """ + QPushButton { + background-color: #3498db; + color: white; + border: none; + border-radius: 5px; + padding: 8px 20px; + font-weight: bold; + min-width: 80px; + } + QPushButton:hover { + background-color: #2980b9; + } + QPushButton[text="Cancel"] { + background-color: #e74c3c; + } + QPushButton[text="Cancel"]:hover { + background-color: #c0392b; + } +"""