Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show latest version on system tray #1667

Merged
merged 1 commit into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gui/systembridgegui/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(self) -> None:
)

self._system_tray_icon = SystemTray(
self._database,
self._icon,
self._application,
self._callback_exit_application,
Expand Down
47 changes: 19 additions & 28 deletions gui/systembridgegui/system_tray.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""System Bridge GUI: System Tray"""
from __future__ import annotations

import os
from collections.abc import Callable
import os
from webbrowser import open_new_tab

from PySide6.QtGui import QAction, QCursor, QIcon
from PySide6.QtWidgets import QMenu, QSystemTrayIcon, QWidget
from systembridgeshared.base import Base
from systembridgeshared.common import get_user_data_directory
from systembridgeshared.database import Database

PATH_BRIDGES_OPEN_ON = "/app/bridges/openon.html"
PATH_BRIDGES_SETUP = "/app/bridges/setup.html"
Expand All @@ -27,6 +28,7 @@ class SystemTray(Base, QSystemTrayIcon):
# pylint: disable=unsubscriptable-object
def __init__(
self,
database: Database,
icon: QIcon,
parent: QWidget,
callback_exit_application: Callable,
Expand All @@ -36,6 +38,8 @@ def __init__(
Base.__init__(self)
QSystemTrayIcon.__init__(self, icon, parent)

self._database = database

self._logger.info("Setup system tray")

self.callback_show_window = callback_show_window
Expand All @@ -61,33 +65,20 @@ def __init__(
menu.addSeparator()

latest_version_text = "Latest Version"
# if (
# information is not None
# and information.attributes is not None
# and information.updates is not None
# and information.updates.attributes is not None
# ):
# if (
# information.updates.available is not None
# and information.updates.available
# ):
# latest_version_text = f"""Version {
# information.updates.version.new
# } avaliable! ({
# information.updates.version.current
# } -> {
# information.updates.version.new
# })"""
# elif information.updates.newer:
# latest_version_text = f"""Version Newer ({
# information.updates.version.current
# } > {
# information.updates.version.new
# })"""
# else:
# latest_version_text = f"""Latest Version ({
# information.updates.version.current
# })"""
version_current = self._database.read_table_by_key("system", "version").to_dict(
orient="records"
)[0]["value"]
version_latest = self._database.read_table_by_key(
"system", "version_latest"
).to_dict(orient="records")[0]["value"]
version_newer_avaliable = self._database.read_table_by_key(
"system", "version_newer_avaliable"
).to_dict(orient="records")[0]["value"]

if version_newer_avaliable.lower() == "true":
latest_version_text = f"{version_latest} (New)"
else:
latest_version_text += f" ({version_current})"

action_latest_release: QAction = menu.addAction(latest_version_text)
action_latest_release.triggered.connect(self._open_latest_releases) # type: ignore
Expand Down