DuxReiNummariae 1.0.0-alpha.23
Simple and powerful budgeting application
 
Loading...
Searching...
No Matches
drn::navigation::UserPreferences Class Reference

Manages user preferences related to budgeting, survey balance, work hours, and currency. More...

#include <UserPreferences.h>

Collaboration diagram for drn::navigation::UserPreferences:

Public Member Functions

CurrencyDisplayOptions currenciesDisplayAs () const noexcept
 Retrieves the user's preference for how currencies should be displayed.
 
std::chrono::days daysInWeek () const noexcept
 Retrieves the number of days in a standard work week based on user preferences.
 
bool doesExist () const noexcept
 Checks if any user preferences exist.
 
std::chrono::hours hoursInWeek () const noexcept
 Retrieves the number of hours in a standard work week, as defined in user preferences.
 
std::chrono::days notifyDueWithin () const noexcept
 Retrieves the notification period for due items from user preferences.
 
pecunia::Currency preferredCurrency () const noexcept
 Retrieves the user's preferred display currency for the application.
 
void setCurrenciesDisplayAs (const CurrencyDisplayOptions &displayAs)
 Sets the display format for currencies in the application.
 
void setDaysInWeek (const std::chrono::days &value)
 Sets the number of days in a typical user-defined work week.
 
void setHoursInWeek (const std::chrono::hours &value)
 Sets the number of hours in a week for user preferences.
 
void setNotifyDueWithin (const std::chrono::days &value)
 Sets the notification time period for due tasks.
 
void setPreferredCurrency (const pecunia::Currency &value)
 Sets the preferred display currency for the user.
 
void setSurveyWindow (const foundation::Percentage &window)
 Updates the user's preference for the survey window percentage.
 
void setUsableCurrencies (const std::set< pecunia::Currency > &values)
 Updates the list of usable currencies and stores them persistently.
 
foundation::Percentage surveyWindow () const noexcept
 Retrieves the survey window percentage preference for user settings.
 
std::set< pecunia::Currency > usableCurrencies () const noexcept
 Retrieves the list of usable currencies.
 

Detailed Description

Manages user preferences related to budgeting, survey balance, work hours, and currency.

This class is responsible for storing, retrieving, and managing various user preferences. It ensures user preferences are persisted across application sessions, allowing for consistent customization of the user experience in terms of financial and time-related settings.

Usage:

  • Use this class to set preferences such as survey balance windows, hours or days in a work week, notification windows, and currency-related configurations.
  • Retrieve these preferences to adjust application behavior and appearance to the user's needs.

This class interacts with a backing store and guarantees safe and consistent access to preference values. This enables the application to dynamically adapt its behavior to the user-defined settings.

Member Function Documentation

◆ currenciesDisplayAs()

CurrencyDisplayOptions drn::navigation::UserPreferences::currenciesDisplayAs ( ) const
nodiscardnoexcept

Retrieves the user's preference for how currencies should be displayed.

This method is used to determine how currency-related data should be presented in the application.

Returns
The preferred currency display option chosen by the user. If unavailable, it falls back to a default of the currency's symbol.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ daysInWeek()

std::chrono::days drn::navigation::UserPreferences::daysInWeek ( ) const
nodiscardnoexcept

Retrieves the number of days in a standard work week based on user preferences.

This function provides the ability to determine the number of days considered as part of the work week, as defined by stored user preferences. This ensures coherent behavior for operations depending on the work week settings.

Returns
The number of days in the user-configured work week or a default value if no valid configuration exists. If no custom preference is set or if the stored value is invalid, it falls back to a default value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ doesExist()

bool drn::navigation::UserPreferences::doesExist ( ) const
nodiscardnoexcept

Checks if any user preferences exist.

Returns
True if any user preferences have been stored; false otherwise.

◆ hoursInWeek()

std::chrono::hours drn::navigation::UserPreferences::hoursInWeek ( ) const
nodiscardnoexcept

Retrieves the number of hours in a standard work week, as defined in user preferences.

This method is used to obtain the configured or default value for the number of hours in a work week. It ensures the application can consistently use the preferred or default hours for time calculations.

Returns
The configured number of hours in a standard work week, or a default value if no valid preference was set. If no user preference is set, or if the value cannot be correctly converted, a default value is returned.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notifyDueWithin()

std::chrono::days drn::navigation::UserPreferences::notifyDueWithin ( ) const
nodiscardnoexcept

Retrieves the notification period for due items from user preferences.

This method is used to obtain the user's preferred number of days prior to a budgeting item becoming due, within which they wish to receive notifications.

Returns
The number of days prior to the due date for which notifications should be sent, or a default value if the preference is unset or invalid.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ preferredCurrency()

pecunia::Currency drn::navigation::UserPreferences::preferredCurrency ( ) const
nodiscardnoexcept

Retrieves the user's preferred display currency for the application.

This method allows the application to determine and use the currency that aligns with the user's preference. Use this function to obtain the preferred display currency value for any financial or currency-related operations.

Returns
The preferred currency of the user, or the default value if a preference is not set, or an error occurs. It falls back to either the system locale, or a default currency in case of missing or invalid data.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCurrenciesDisplayAs()

void drn::navigation::UserPreferences::setCurrenciesDisplayAs ( const CurrencyDisplayOptions & displayAs)

Sets the display format for currencies in the application.

This method updates the application's settings to define how currencies should be displayed. The updated preference is stored persistently and ensures that subsequent uses of the application adhere to the specified currency display format.

Parameters
displayAsThe desired format for currency display.
Postcondition
The preferences storage is updated with the new currency display format.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDaysInWeek()

void drn::navigation::UserPreferences::setDaysInWeek ( const std::chrono::days & value)

Sets the number of days in a typical user-defined work week.

This function updates the user's preference for the number of days they consider a work week. Changes to this preference impact how the application calculates and displays work-associated metrics and schedules. The value is stored persistently, ensuring that it is retained between sessions.

Parameters
valueThe number of days to set as the user's work week.
Postcondition
Updates the backing store used by the application to persistently save the days in the user-defined work week.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setHoursInWeek()

void drn::navigation::UserPreferences::setHoursInWeek ( const std::chrono::hours & value)

Sets the number of hours in a week for user preferences.

This function updates the stored value representing the number of hours in a week, allowing the application to adapt its budgeting and scheduling features accordingly.

Parameters
valueThe new number of hours to be stored as the weekly working hours.
Postcondition
Updates the internal store with the new hours value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setNotifyDueWithin()

void drn::navigation::UserPreferences::setNotifyDueWithin ( const std::chrono::days & value)

Sets the notification time period for due tasks.

This method specifies the time frame within which notifications about due tasks will be triggered. By setting this value, you can adjust when the application will alert the user about upcoming tasks, ensuring timely reminders for better task management.

Parameters
valueSpecifies the number of days before the due date to trigger task notifications.
Postcondition
Updates the internal settings storage to persist the provided notification time frame.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPreferredCurrency()

void drn::navigation::UserPreferences::setPreferredCurrency ( const pecunia::Currency & value)

Sets the preferred display currency for the user.

When called, this function updates the user's preferred display currency setting. It interacts with the underlying settings management system to ensure the update is stored persistently. Adjustments made are reflected in the application's behavior, such as displaying amounts in the selected currency format across relevant graphical elements.

Parameters
valueThe currency value to set as the user's preference.
Postcondition
The underlying settings system is updated with the new currency preference, ensuring future retrievals reflect this updated preference.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSurveyWindow()

void drn::navigation::UserPreferences::setSurveyWindow ( const foundation::Percentage & window)

Updates the user's preference for the survey window percentage.

This method sets a user-defined value indicating the percentage window for survey-related preferences. It ensures the value is stored in the application's settings for future reference. Use this method to customize survey-related calculations according to user-defined preference rates.

Parameters
windowA percentage value to define the survey window rate.
Postcondition
The user preferences are updated to reflect the given survey window percentage. The settings are saved persistently for use across application sessions.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUsableCurrencies()

void drn::navigation::UserPreferences::setUsableCurrencies ( const std::set< pecunia::Currency > & values)

Updates the list of usable currencies and stores them persistently.

This function allows the application to customize the list of currencies that are available for use. It ensures that the updated list is saved and persists across application sessions. Modifications made to the list of usable currencies will influence the behavior of any GUI items or processes that rely on available currency options.

Parameters
valuesA collection representing the updated set of usable currencies.
Postcondition
The updated list of usable currencies is persisted in the application's settings storage.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ surveyWindow()

foundation::Percentage drn::navigation::UserPreferences::surveyWindow ( ) const
nodiscardnoexcept

Retrieves the survey window percentage preference for user settings.

Use this method to get the user-defined survey window percentage rate. When the preference is not set, a default value is returned. This ensures a consistent fallback value in case of any undefined or corrupted settings.

Postcondition
If the stored preference cannot be converted to a valid percentage, a warning is logged to the standard error buffer.
Returns
The current survey window percentage rate if valid, or a pre-defined default percentage value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ usableCurrencies()

std::set< pecunia::Currency > drn::navigation::UserPreferences::usableCurrencies ( ) const
nodiscardnoexcept

Retrieves the list of usable currencies.

This method provides a set of currencies that are considered usable within the application, based on the user's settings.

Returns
A set of usable currencies configured by the user. If the conversion of stored currency data fails or the setting does not exist, it defaults to returning the user's preferred currency, ensuring the application continues to function without interruption.
Here is the call graph for this function:
Here is the caller graph for this function: