ClockAlarm: a cross-platform alarm manager¶
ClockAlarm is a cross-platform (linux, Windows, macOS) alarm manager that will help you improve your life organization. Define alerts and never miss events again.
Features¶
- Simple / Periodic alerts
- Works on Windows, macOS and Linux
- Safe, corrupt-free and humanly readable database
- Fully customizable alerts (sound, color, font, etc)
Installation¶
You will need a working python environment.
Requirements¶
- python => 3.6
- pygame => 1.9.3
- PyQt5 => 5.8.2
- sip => 4.19.2
- tinydb => 3.2.2
You can install these packages using the following command:
$ pip3 install pygame pyqt5 sip tinydb
Clone the repository:
$ git clone https://github.com/BFH-BTI7301-project1/ClockAlarm.git
Launch ClockAlarm:
$ python3 bin/clockalarm&
Development¶
Requirements¶
- coverage >= 4.4.1
- pytest >= 3.0.7
- pytest-cov >= 2.5.1
- pytest-qt >= 2.1.0
- pytest-catchlog >= 1.2.2
- coveralls >= 1.1
You can install these packages using the following command:
$ pip3 install -r stable-req.txt
Run the tests:
$ py.test --cov-report term --cov=. _clockalarm/_tests --no-xvfb
Bugs/Requests¶
Please use the GitHub issue tracker to submit bugs or request features.
ClockAlarm API Documentation¶
_clockalarm¶
_clockalarm package¶
Subpackages¶
_clockalarm.UI package¶
-
class
_clockalarm.UI.AlertListWidget.
AlertListWidget
[source]¶ Bases:
PyQt5.QtWidgets.QTableWidget
Visual list displaying the Alerts from the database.
-
class
_clockalarm.UI.ColorSelectorWidget.
ColorSelectorWidget
(hex_color=None, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Custom widget to selected a color for the notification
Called when the color_select_button is clicked.
Choose a color from a palette.
-
class
_clockalarm.UI.MainWindow.
MainWindow
(application, *args)[source]¶ Bases:
PyQt5.QtWidgets.QMainWindow
Main window interface extending
PyQt5.QtWidgets.QMainWindow
.Shows a list of all the alerts retrieved from a JSON file.
-
application
¶ The main application
-
*args
The parent pointer or window flags
-
add_simple_alert
()[source]¶ Creates a
SimpleAlertEditWidget
and shows it to the user.
-
closeEvent
(event)[source]¶ Overrides
closeEvent()
method.Allows to intercept the window closing event.
-
edit_simple_alert
()[source]¶ Edits the selected alert and shows an SimpleAlertEditWidget to the user.
Mutes the alerts and updates the mute button.
-
-
class
_clockalarm.UI.NotificationWidget.
NotificationWidget
(geometry, notification, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Notification widget
-
geometry
¶ The position and size of the widget on the screen
-
notification
¶ The notification
-
init_ui
(geom)[source]¶ Helper method that sets the style of the NotificationWidget.
-
geom
¶ The position and size of the widget on the screen
-
-
popup_close
¶
-
-
class
_clockalarm.UI.SimpleAlertEditWidget.
SimpleAlertEditWidget
(alert: _clockalarm.SimpleAlert.SimpleAlert = None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Widget allowing to create or edit a
SimpleAlert
.-
alert
¶ A
SimpleAlert
to edit, default None
-
init_ui
(alert)[source]¶ Initialization helper method.
-
alert
The
SimpleAlert
to edit
-
-
-
class
_clockalarm.UI.SoundSelectorWidget.
SoundSelectorWidget
(sound_name: str = None, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Costum widget to selected a sound
Select a wave file and import it in the application sound folder.
Called when the sound_select_button is clicked. Get a wave sound file path from the file explorer.
-
load_sound
(sound_path: str)[source]¶ Load the given .wave sound file in the application folder
If the file already exist in the sound folder of the app, nothing append. If a file with the same name already exist in the sound folder, he is overwritten.
-
sound_path
¶ the full path of the sound file.
- Exceptions:
- ValueError: If the given sound_path isn’t a valid wave sound.
-
_clockalarm.utils package¶
-
_clockalarm.utils.importExportUtils.
export_alerts_file
(dest)[source]¶ Copy the file at ALERT_DB_PATH into the .json location specified the argument
If existing, the destination file is erased.
Parameters: dest (str) – full path of the destination location - Exceptions:
- FileNotFoundException: If the given destination file doesn’t exist or haven’t a json extension shutil.SameFileError: If the src and destination files are the same
-
_clockalarm.utils.importExportUtils.
get_default_config
(key, cmd=’str’)[source]¶ Read the configuration file and return the value for the given key
The cmd attribute defines the type of the value. Default is str.
-
_clockalarm.utils.importExportUtils.
key
¶ The key of the key-value pair in the config file
-
_clockalarm.utils.importExportUtils.
cmd
¶ Type of the desired value. Default is str.
- Exceptions:
- KeyError: Is the key doesn’t match any key in the config file. configparser.NoSectionError: If the config file or the section doesn’t exist.
-
-
_clockalarm.utils.importExportUtils.
import_alerts_file
(src)[source]¶ Copy the .json file given as argument into the location specified by ALERT_DB_PATH
If existing, the destination file is erased. All the application is restarted after an import.
Parameters: src (str) – full path of the source json database - Exceptions:
- FileNotFoundException: If the given source file doesn’t exist or isn’t a json file SameFileError: If the src and destination files are the same
-
_clockalarm.utils.importExportUtils.
set_default_config
(key, value)[source]¶ Set the given (key,value) pair in the config file.
Preserves the Caps
-
_clockalarm.utils.importExportUtils.
key
the key
-
_clockalarm.utils.importExportUtils.
value
¶ the value
- Exceptions:
- configparser.NoSectionError: If the config file or the section doesn’t exist.
-
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
-