Skip to content

Commit

Permalink
Add notification handler
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreWohnsland committed Jul 3, 2024
1 parent b441c35 commit fe56d37
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/ui_controller.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
from PyQt6.QtWidgets import QDialog, QFileDialog, QInputDialog, QLayout, QMessageBox, QTableWidget, QTableWidgetItem
import sys

from plyer import notification
from PyQt6.QtWidgets import (
QDialog,
QFileDialog,
QInputDialog,
QLayout,
QMessageBox,
QSystemTrayIcon,
QTableWidget,
QTableWidgetItem,
)

from src import __version__
from src.config_handler import CONFIG_HANDLER
Expand All @@ -20,6 +32,13 @@ def show_message(self, message: str):
message_box.show()
message_box.exec()

def show_notification(self, tray_icon: QSystemTrayIcon, message: str, title: str, timeout: int = 3):
# QT notification are prettier, but does not work properly on other than windows
if sys.platform.startswith("win"):
tray_icon.showMessage(title, message, QSystemTrayIcon.MessageIcon.Information, timeout * 1000)
return
notification.notify(title=title, message=message, app_name="Time Tracker", timeout=timeout) # type: ignore

def report_choice(self):
message_box = QMessageBox()
message_box.setText(
Expand Down

0 comments on commit fe56d37

Please sign in to comment.