taskbridgeapp.gui.viewmodel.taskbridgeapp.TaskBridgeApp

class taskbridgeapp.gui.viewmodel.taskbridgeapp.TaskBridgeApp(assets_path)

Bases: QMainWindow

View controller for the main window. The :py:att``SETTINGS`` dictionary accepts the following keys:

  • sync_notes - if ‘1’, notes are synchronised and corresponding configuration is enabled.

  • sync_reminders - if ‘1’, reminders are synchronised and corresponding configuration is enabled.

  • remote_notes_folder - path to the remote note folder.

  • associations - dictionary which contains list of notes to be synced bidirectionally in bi_directional and

others in local_to_remote and remote_to_local respectively. - prune_reminders - if ‘1’, completed reminders are deleted before synchronisation. - caldav_server - host of the CalDav server. - caldav_path - path to the calendar list for this user on the CalDav server. - caldav_url - automatically set by combining caldav_server and caldav_path. - caldav_username - username for the CalDav server. - caldav_type - stores either ‘NextCloud’ or ‘CalDav’ and enables appropriate settings in GUI. - reminder_sync - list of reminder contains to be synchronised. - log_level - the logging level. Can be ‘debug’, ‘info’, ‘warning’ or ‘critical’. - autosync - if ‘1’, automatic synchronisation is enabled. - autosync_interval - the interval for automatic synchronisation. - autosync_unit - determines the unit for autosync_interval. Either ‘Minutes’ or ‘Hours’.

Methods

apply_autosync_settings

Loads autosync settings and applies to UI.

apply_notes_settings

Applies settings to the notes view from configuration file.

apply_reminders_settings

Reads reminder settings from file and applies to reminders view.

bootstrap_notes

Initialises the notes table

bootstrap_reminders

Initialises the reminders view.

bootstrap_settings

Create configuration file if it doesn't exist.

bootstrap_sync

Prepare the Sync view.

bootstrap_ui

Bootstraps the TaskBridge UI.

check_changes

Checks for unsaved changes and prompts to save.

clear_logs

Clears the log view.

display_error

Displays an error message coming from a thread during synchronisation tasks.

display_log

Displays a log message.

display_notes_table

Displays the note folders in the table.

display_reminders_table

Displays the reminder contains in the reminder view table.

do_sync

Start the sync thread.

eventFilter

Handles various minor UI events.

get_table_icon

Gets an icon for inline-display in table.

handle_folder_browse

Shows the folder chooser dialog for selecting the remote note folder.

handle_login

Processes the login form.

handle_note_checkbox

Handles the UI logic for the checkboxes in the notes folder.

handle_notes_cancel

Prompts the user to save unsaved changes in the notes view.

handle_notes_sync

Triggered when the Synchronise Notes option is checked.

handle_prune_checkbox

Updates :py:att``SETTINGS`` when the Prune reminders checkbox is clicked.

handle_reminder_checkbox

Triggered when a checkbox in the reminders table is checked and updates :py:att`SETTINGS`.

handle_reminders_cancel

Prompts the user to save their reminder view changes.

handle_reminders_sync

Triggered when the Sync Reminders checkbox is enabled or disabled and sets the reminders UI state.

handle_sync_toggle

Triggers when the autosync checkbox is clicked and sets UI state.

load_note_folders

Starts the thread to load the note folders.

load_reminder_lists

Loads the reminder containers by starting a thread.

load_settings

Load settings from configuration file.

open_docs

Open TaskBridge documentation in browser.

quit_gracefully

Quits TaskBridge.

refresh_notes

Clears the notes table and reloads the notes folders.

refresh_reminders

Resets the reminders view and loads the reminder containers.

save_settings

Save settings to file.

set_autosync

Updates :py:att`SETTINGS` for autosync.

set_logging_level

Sets the logging level (and saves).

set_note_folder_association

Updates :py:att`SETTINGS` with the association setting for this folder

show_about

Show the About dialog.

start_autosync

Starts the autosync thread.

switch_sync_view

Switches between the two stacks in the Sync view (logo or debug).

switch_ui

Switches to the given tab.

sync_complete

Triggered when a sync is completed.

trigger_unsaved

Triggers an unsaved changes state and enables the form to save changes.

update_progress

Updates the progress bar.

update_status

Updates the status label.

validate_autosync_form

Validates the autosync form.

validate_login_form

Validates the login form.

Attributes

PENDING_CHANGES

If True, there are unsaved changes.

SETTINGS

Application settings

__display_name__

__name__

__orig_bases__

__sphinx_decorator_args__

__sphinx_mock__

PENDING_CHANGES: bool = False

If True, there are unsaved changes.

SETTINGS = {'associations': {'bi_directional': [], 'local_to_remote': [], 'remote_to_local': []}, 'autosync': '0', 'autosync_interval': 0, 'autosync_unit': 'Minutes', 'caldav_path': '', 'caldav_server': '', 'caldav_type': '', 'caldav_url': '', 'caldav_username': '', 'log_level': 'debug', 'prune_reminders': '0', 'reminder_sync': [], 'remote_notes_folder': '', 'sync_notes': '0', 'sync_reminders': '0'}

Application settings

__call__(*args, **kwargs)

Call self as a function.

Return type:

Any

__init__(assets_path)

Initialise the window and load settings.

Parameters:

assets_path (str) – Path to the GUI assets folder

static _ask_question(title, message)

Show a question dialog.

Parameters:
  • title (str) – the window title for the dialog.

  • message (str) – message to show.

Return type:

int

static _show_message(title, message, message_type='info')

Show an informational or error message.

Parameters:
  • title (str) – window title for the message dialog.

  • message (str) – message to show.

  • message_type (str) – the type of message. Either ‘info’ or ‘error’.

Return type:

None

apply_autosync_settings()

Loads autosync settings and applies to UI.

Return type:

None

apply_notes_settings()

Applies settings to the notes view from configuration file.

Return type:

None

apply_reminders_settings()

Reads reminder settings from file and applies to reminders view.

Return type:

None

bootstrap_notes()

Initialises the notes table

Return type:

None

bootstrap_reminders()

Initialises the reminders view.

static bootstrap_settings()

Create configuration file if it doesn’t exist.

Return type:

None

bootstrap_sync()

Prepare the Sync view.

Return type:

None

bootstrap_ui()

Bootstraps the TaskBridge UI.

Return type:

None

check_changes()

Checks for unsaved changes and prompts to save. If cancelled, resets changes.

Return type:

None

clear_logs()

Clears the log view.

Return type:

None

display_error(message)

Displays an error message coming from a thread during synchronisation tasks.

Parameters:

message (str) – the message to display.

Return type:

None

display_log(message)

Displays a log message.

Parameters:

message (str) – the message to display.

Return type:

None

display_notes_table(folder_list)

Displays the note folders in the table.

Parameters:

folder_list (List[NoteFolder]) – List of note folders to display.

Return type:

None

display_reminders_table(container_list)

Displays the reminder contains in the reminder view table.

Parameters:

container_list (List[ReminderContainer]) – the list of reminder containers.

Return type:

None

do_sync()

Start the sync thread.

Return type:

None

eventFilter(widget, event)

Handles various minor UI events.

Parameters:
  • widget (QWidget) – the widget which fired the event.

  • event (QEvent | QKeyEvent) – the event which was fired.

Return type:

bool

Returns:

False to allow further even handling to occur.

get_table_icon(image)

Gets an icon for inline-display in table. Returns correct icon depending on whether dark mode is set.

Parameters:

image (str) – the name of the image to display from the ‘taskbridge/gui/assets/table’ folder.

Return type:

str

Returns:

path to the correct image.

handle_folder_browse()

Shows the folder chooser dialog for selecting the remote note folder.

Return type:

None

handle_login()

Processes the login form.

Return type:

None

handle_note_checkbox(row, col)

Handles the UI logic for the checkboxes in the notes folder. Refer to the NoteCheckbox class.

Return type:

None

handle_notes_cancel()

Prompts the user to save unsaved changes in the notes view. If cancelled, changes are discarded.

handle_notes_sync()

Triggered when the Synchronise Notes option is checked.

Return type:

None

handle_prune_checkbox()

Updates :py:att``SETTINGS`` when the Prune reminders checkbox is clicked.

Return type:

None

handle_reminder_checkbox(row, col)

Triggered when a checkbox in the reminders table is checked and updates :py:att`SETTINGS`.

Parameters:
  • row (int) – the row in the table containing this checkbox.

  • col (int) – the column in the table containing this checkbox.

Return type:

None

handle_reminders_cancel()

Prompts the user to save their reminder view changes. If cancelled, changes are discarded and reminder lists are reloaded.

Return type:

None

handle_reminders_sync()

Triggered when the Sync Reminders checkbox is enabled or disabled and sets the reminders UI state.

Return type:

None

handle_sync_toggle()

Triggers when the autosync checkbox is clicked and sets UI state.

Return type:

None

load_note_folders()

Starts the thread to load the note folders.

Return type:

None

load_reminder_lists()

Loads the reminder containers by starting a thread.

Return type:

None

static load_settings()

Load settings from configuration file.

Return type:

None

static open_docs()

Open TaskBridge documentation in browser.

Return type:

None

quit_gracefully()

Quits TaskBridge. Terminates all threads and clears schedule before quitting.

Return type:

None

refresh_notes()

Clears the notes table and reloads the notes folders.

Return type:

None

refresh_reminders()

Resets the reminders view and loads the reminder containers.

Return type:

None

save_settings(what=None, silent=True)

Save settings to file.

Parameters:
  • what (str | None) – what was saved. Used when displaying confirmation dialog and to prompt for reminder pruning.

  • silent (bool) – if True, no confirmation dialog is shown.

Return type:

None

set_autosync()

Updates :py:att`SETTINGS` for autosync.

Return type:

None

set_logging_level()

Sets the logging level (and saves).

Return type:

None

static set_note_folder_association(folder_name, direction=None)

Updates :py:att`SETTINGS` with the association setting for this folder

Parameters:
  • folder_name (str) – the folder whose association was changed.

  • direction (str | None) – the sync direction as per keys in :py:att`SETTINGS`.

Return type:

None

static show_about()

Show the About dialog.

Return type:

None

start_autosync(interval, unit)

Starts the autosync thread.

Parameters:
  • interval (int) – the interval specified by the user.

  • unit (str) – the interval unit specified by the user. ‘Minutes’ or ‘Hours’.

Return type:

None

switch_sync_view()

Switches between the two stacks in the Sync view (logo or debug).

Return type:

None

switch_ui(index)

Switches to the given tab. Also updates the menu.

Parameters:

index (int) – the tab number to switch to.

Return type:

None

sync_complete()

Triggered when a sync is completed. Sets next UI state.

Return type:

None

trigger_unsaved(view)

Triggers an unsaved changes state and enables the form to save changes.

Parameters:

view (str) – the view for which to enable the save/cancel form.

Return type:

None

update_progress(progress)

Updates the progress bar.

Parameters:

progress (int) – the progress value to set.

Return type:

None

update_status(status='Currently idle.')

Updates the status label.

Parameters:

status (str) – the status to set.

Return type:

None

validate_autosync_form()

Validates the autosync form.

Valid sync intervals: 10-59 minutes, 1-12 hours.

Return type:

None

validate_login_form()

Validates the login form.

Return type:

tuple[bool, str]

Returns:

-success (bool) - true if form is valid.

-data (str) - error message(s) if invalid input, or full CalDav path if valid.