From 24bd8f51e1cdf51eb8a288e36f4ad3ba0d1c1a56 Mon Sep 17 00:00:00 2001 From: Rob <5183487+Rexeh@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:25:25 +0000 Subject: [PATCH] Added version pill to main window --- joystick_diagrams/ui/main_window.py | 26 +++++++++++++++++++++++++- theme/custom.css | 6 ++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/joystick_diagrams/ui/main_window.py b/joystick_diagrams/ui/main_window.py index 1fa73e7..512b35f 100644 --- a/joystick_diagrams/ui/main_window.py +++ b/joystick_diagrams/ui/main_window.py @@ -4,7 +4,13 @@ import qtawesome as qta # type: ignore from PySide6.QtCore import QCoreApplication, QSize from PySide6.QtGui import QDesktopServices, QIcon -from PySide6.QtWidgets import QCheckBox, QLabel, QMainWindow, QProgressBar, QPushButton +from PySide6.QtWidgets import ( + QCheckBox, + QLabel, + QMainWindow, + QProgressBar, + QPushButton, +) from joystick_diagrams import version from joystick_diagrams.app_state import AppState @@ -68,8 +74,15 @@ def __init__(self, *args, **kwargs): self.website_pill.setIcon(QIcon(ui_consts.JD_ICON)) self.website_pill.setProperty("class", "pill-button web") + self.update_pill = QPushButton() + self.update_pill.setText("An update is available!") + self.update_pill.setHidden(True) + self.update_pill.setIcon(QIcon(ui_consts.JD_ICON)) + self.update_pill.setProperty("class", "pill-button update") + self.discord_pill.clicked.connect(self.open_discord_link) self.website_pill.clicked.connect(self.open_website_link) + self.update_pill.clicked.connect(self.open_website_link) self.topnav_additional_layout.addStretch(1) @@ -83,6 +96,7 @@ def __init__(self, *args, **kwargs): # self.styleTimer.start() # self.topnav_additional_layout.addWidget(self.styleButton) + self.topnav_additional_layout.addWidget(self.update_pill) self.topnav_additional_layout.addWidget(self.discord_pill) self.topnav_additional_layout.addWidget(self.website_pill) @@ -131,6 +145,16 @@ def __init__(self, *args, **kwargs): # Window Setup self.setWindowTitle(f"Joystick Diagrams - {version.get_current_version()}") + self.check_for_new_version() + + def check_for_new_version(self): + _logger.info("Checking version...") + version_check = version.perform_version_check() + _logger.info(f"Version check was {version_check}") + + if version_check is False: + self.update_pill.setHidden(False) + def handle_debug_mode_switch(self, state): if state == 2: _logger.root.setLevel(logging.DEBUG) diff --git a/theme/custom.css b/theme/custom.css index dd9db24..4b63e61 100644 --- a/theme/custom.css +++ b/theme/custom.css @@ -12,6 +12,12 @@ QWidget {{ /* Main Navigation */ +.pill-button.update {{ + background: #d80e902a; + color:white; + max-width: 150px; +}} + .pill-button.discord {{ background: #7289da; color:white