_clockalarm package¶
Submodules¶
_clockalarm.Alert module¶
-
class
_clockalarm.Alert.
Alert
(trigger_time)[source]¶ Bases:
PyQt5.QtCore.QObject
Abstract Alert class representing alerts.
-
trigger_time
¶ The trigger time of the alert.
-
id
¶ The identification number of the alert in the alert.
-
Set up when added to the database.
-
get_trigger_time
()[source]¶ Get the Alert trigger time in seconds since epoch.
Returns: The trigger time
-
timeout
¶
-
_clockalarm.AlertCollection module¶
-
class
_clockalarm.AlertCollection.
AlertCollection
(parent=None)[source]¶ Bases:
object
Collection of all the Alert objects running on the program.
This class contains utilities to load, update and save the alerts in a TinyDB database, and maintain the correct state of all the alerts
-
add
(alert: _clockalarm.SimpleAlert.SimpleAlert)[source]¶ Add the Alert given in argument to the collection of alerts
If parent is set, the new Alert is connected to the notification center and the list of displayed alerts is updated.
-
alert
¶ SimpleAlert – The alert to add to the collection
- Exceptions:
- ValueError: If the alert argument is None or incorrect.
-
-
check_timers
(trig_time)[source]¶ Check all the alerts to see if on should be triggered
This function is triggered periodically by the clock.
-
trig_time
¶ Actual time, in seconds.
-
-
clean_db
()[source]¶ Make the TinyDB database consistent
All the outdated alerts without periodicity are removed. New trigger time is calculated for outdated alerts with periodicity.
If the db is corrupted, nothing append.
-
delete
(id_alert: int)[source]¶ Remove an alert from the collection
-
id_alert
¶ The id number of the alert to remove.
- Exceptions:
- KeyError: If the alert to delete doesn’t exist in the database.
-
-
display
()[source]¶ Actualize the UI alert list display
If parent is unset, the AlertCollection object isn’t link to any QWindow and nothing append
-
edit
(id_alert: int, notification: _clockalarm.Notification.Notification = None, trigger_time: int = None, periodicity: int = None)[source]¶ Update an alert with the given modifications
If the trigger_time is in the past, he won’t re updated.
-
id_alert
int – The id number of the alert to modify
-
notification
¶ Notification, optional – Default is None. The new notification
-
trigger_time
¶ int,optional – Default is None. The new trigger time
-
periodicity(int,optional
Default is None. The new periodicity
- Exceptions:
- KeyError: If the alert to edit doesn’t exist in the database. ValueError: If the periodicity argument is under zero.
-
-
_clockalarm.Clock module¶
_clockalarm.Notification module¶
-
class
_clockalarm.Notification.
Notification
(message: str, color_hex: str = None, font_family: str = None, font_size: int = None, sound: str = None)[source]¶ Bases:
object
Encapsulate the parameters of a Notification in order to pass it to the NotificationCenter
-
get_color
()[source]¶ Build a QColor from color_hex parameter
If color_hex parameter is missing, replace it with de default configuration.
Returns: The QColor of the notification
-
_clockalarm.NotificationCenter module¶
-
class
_clockalarm.NotificationCenter.
NotificationCenter
(screen_geometry, parent=None)[source]¶ Bases:
object
Class handling the display of the Notification Widgets
Receives the notifications to display and add it to a queue. If there is free slot on the UI display area, pop the queue and display the notification. If the user clicks on the widget, closes it and compacts the remaining widgets.
-
add_to_queue
(notification)[source]¶ Add a new notification to the queue
The notification will wait till there is a free spot in the display zone
-
notification
¶ Notification – The notification to add to enqueue
- Exceptions:
- ValueError: If the user try to add None or incorrect Notification object to the queue
-
-
close_popup
(popup: _clockalarm.UI.NotificationWidget.NotificationWidget)[source]¶ Triggered by a NotificationWidget when closed
Remove the popup from the list and refresh the display zone.
-
popup
¶ The NotificationWidget to remove from the display zone
- Exceptions:
- ValueError: If the user pass a None or incorrect popup object as argument. KeyError: If the popup isn’t in the list and can’t be removed
-
-
display_popup
(geom: PyQt5.QtCore.QRect, notification)[source]¶ Display a QWidget popup
Play a sound if the program isn’t muted
-
geom
¶ QRect – position and size of the widget on the screen
-
notification
Notification – the notification to display
- Exceptions:
- ValueError: In case of None or invalid QRect object as geom argument ValueError: In case of None or invalid Notification object as notification argument IndexError: If the number of displayed popups is greater or equal to the max number of displayed popups
-
-
_clockalarm.SimpleAlert module¶
-
class
_clockalarm.SimpleAlert.
SimpleAlert
(trigger_time, notification, periodicity=None)[source]¶ Bases:
_clockalarm.Alert.Alert
Simple Alert implementation with text message
-
trigger_time
¶ The time at which the alert is triggered.
-
notification
¶ The notification to display when the alert is triggered.
-
periodicity
¶ frequency in which the alert is displayed, in seconds.
-
_clockalarm.main module¶
-
class
_clockalarm.main.
App
(default_config_path, alert_db_path, *argv)[source]¶ Bases:
PyQt5.QtWidgets.QApplication
Main Application extending QApplication
-
CLOCK_FREQUENCY
= None¶
-
MUTE
= None¶
-
init_alert_collection
()[source]¶ Init AlertCollection object and connect the clock to it
Note
The alerts will be loaded from the default database
-