Skip to content

Commit

Permalink
Added version pill to main window
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexeh committed Feb 29, 2024
1 parent b3295dc commit 24bd8f5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
26 changes: 25 additions & 1 deletion joystick_diagrams/ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ QWidget {{

/* Main Navigation */

.pill-button.update {{
background: #d80e902a;
color:white;
max-width: 150px;
}}

.pill-button.discord {{
background: #7289da;
color:white
Expand Down

0 comments on commit 24bd8f5

Please sign in to comment.