Kitlist
1.1.0
|
Maintains the application's configuration parameters in a YAML formatted file. More...
#include <yamlconfig.hpp>
Public Member Functions | |
YamlConfig () | |
~YamlConfig () | |
Also saves the configuration on program exit. More... | |
void | load () |
Loads the configuration file. More... | |
void | save () |
Saves the current configuration. More... | |
Glib::ustring | get_current_filename () |
The current filename. More... | |
void | set_current_filename (Glib::ustring filename) |
Sets the current filename. More... | |
Glib::ustring | get_page_title () |
The page title to use for printing or creating a PDF. More... | |
void | set_page_title (Glib::ustring title) |
Set the page title. More... | |
void | add_recent_filename (Glib::ustring filename) |
Adds a filename to the list of recently used filenames. More... | |
std::deque< Glib::ustring > | get_recent_filenames () |
The history list of recent filenames. More... | |
Glib::ustring | get_debug_log_filename () |
the name of the debug log file. More... | |
Private Member Functions | |
Glib::ustring | get_config_filename () |
Private Attributes | |
gint | m_max_recent_files |
The list of recently used files for the recent files menu. More... | |
Glib::ustring | m_current_filename |
The current filename. More... | |
Glib::ustring | m_debug_log_filename |
The name of the log file to write debug information to. More... | |
Glib::ustring | m_page_title |
The title to use when printing a page or creating a PDF. More... | |
std::deque< Glib::ustring > | m_mru_file_history |
The history list of most recently used filenames. More... | |
Maintains the application's configuration parameters in a YAML formatted file.
See https://yaml.org/ for information on the YAML file format.
The application uses the C++ implementation of a YAML parser from https://github.com/jbeder/yaml-cpp/
The location of the configuration file follows the XDG Base Directory Specification. By default this is ~/.config/kitlist
but can be overridden by specifying the name of the configuration directory by defining the XDG_CONFIG_HOME
environment variable.
See: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
Definition at line 55 of file yamlconfig.hpp.
YamlConfig::YamlConfig | ( | ) |
Definition at line 51 of file yamlconfig.cpp.
References load().
|
inline |
Also saves the configuration on program exit.
Definition at line 85 of file yamlconfig.hpp.
void YamlConfig::add_recent_filename | ( | Glib::ustring | filename | ) |
Adds a filename to the list of recently used filenames.
filename | the filename to set. |
Definition at line 141 of file yamlconfig.cpp.
References m_max_recent_files, and m_mru_file_history.
Referenced by set_page_title(), and KitListGui::update_recent_files().
|
private |
Returns the path to the user's configuration file for this application. e.g. "/home/user/.config/kitlist"
Definition at line 129 of file yamlconfig.cpp.
References CONFIG_FILENAME.
|
inline |
The current filename.
Definition at line 93 of file yamlconfig.hpp.
References m_current_filename.
Referenced by KitListGui::init().
|
inline |
the name of the debug log file.
Definition at line 120 of file yamlconfig.hpp.
References m_debug_log_filename.
Referenced by KitListGui::init().
|
inline |
The page title to use for printing or creating a PDF.
Definition at line 102 of file yamlconfig.hpp.
References m_page_title.
Referenced by KitListGui::init().
|
inline |
The history list of recent filenames.
Definition at line 116 of file yamlconfig.hpp.
References m_mru_file_history.
Referenced by KitListGui::update_recent_files_menu().
void YamlConfig::load | ( | ) |
Loads the configuration file.
Definition at line 60 of file yamlconfig.cpp.
References CURRENT_FILENAME_CONFIG_KEY, DEBUG_LOG_FILENAME_CONFIG_KEY, DEFAULT_PAGE_TITLE, get_config_filename(), m_current_filename, m_debug_log_filename, m_max_recent_files, m_mru_file_history, m_page_title, MAX_RECENT_FILES_CONFIG_KEY, PAGE_TITLE_CONFIG_KEY, and RECENT_FILES_CONFIG_KEY.
Referenced by YamlConfig(), and ~YamlConfig().
void YamlConfig::save | ( | ) |
Saves the current configuration.
Definition at line 104 of file yamlconfig.cpp.
References CURRENT_FILENAME_CONFIG_KEY, DEBUG_LOG_FILENAME_CONFIG_KEY, get_config_filename(), m_current_filename, m_debug_log_filename, m_max_recent_files, m_mru_file_history, m_page_title, MAX_RECENT_FILES_CONFIG_KEY, PAGE_TITLE_CONFIG_KEY, and RECENT_FILES_CONFIG_KEY.
Referenced by ~YamlConfig().
|
inline |
Sets the current filename.
filename | the name of the file to set. |
Definition at line 98 of file yamlconfig.hpp.
Referenced by KitListGui::on_menu_file_new(), KitListGui::on_menu_recent_file(), KitListGui::on_menu_save(), KitListGui::on_menu_save_as(), and KitListGui::open_file().
|
inline |
Set the page title.
Sets the page title used for printing or creating a PDF.
title | the page title to set. |
Definition at line 109 of file yamlconfig.hpp.
References add_recent_filename().
Referenced by KitListGui::set_page_title().
|
private |
The current filename.
Used to reload the same file on the next occasion the application is launched.
Definition at line 65 of file yamlconfig.hpp.
Referenced by get_current_filename(), load(), and save().
|
private |
The name of the log file to write debug information to.
Note: This is only used if the application is compiled with KITLIST_DEBUG. See the distribution README for more information.
Definition at line 72 of file yamlconfig.hpp.
Referenced by get_debug_log_filename(), load(), and save().
|
private |
The list of recently used files for the recent files menu.
Definition at line 59 of file yamlconfig.hpp.
Referenced by add_recent_filename(), load(), and save().
|
private |
The history list of most recently used filenames.
Definition at line 80 of file yamlconfig.hpp.
Referenced by add_recent_filename(), get_recent_filenames(), load(), and save().
|
private |
The title to use when printing a page or creating a PDF.
Definition at line 75 of file yamlconfig.hpp.
Referenced by get_page_title(), load(), and save().