Kitlist  1.1.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
YamlConfig Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ YamlConfig()

YamlConfig::YamlConfig ( )

Definition at line 51 of file yamlconfig.cpp.

References load().

◆ ~YamlConfig()

YamlConfig::~YamlConfig ( )
inline

Also saves the configuration on program exit.

Definition at line 85 of file yamlconfig.hpp.

References load(), and save().

Member Function Documentation

◆ add_recent_filename()

void YamlConfig::add_recent_filename ( Glib::ustring  filename)

Adds a filename to the list of recently used filenames.

Parameters
filenamethe 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().

◆ get_config_filename()

Glib::ustring YamlConfig::get_config_filename ( )
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.

Referenced by load(), and save().

◆ get_current_filename()

Glib::ustring YamlConfig::get_current_filename ( )
inline

The current filename.

Returns
the current filename

Definition at line 93 of file yamlconfig.hpp.

References m_current_filename.

Referenced by KitListGui::init().

◆ get_debug_log_filename()

Glib::ustring YamlConfig::get_debug_log_filename ( )
inline

the name of the debug log file.

Returns
the filename.

Definition at line 120 of file yamlconfig.hpp.

References m_debug_log_filename.

Referenced by KitListGui::init().

◆ get_page_title()

Glib::ustring YamlConfig::get_page_title ( )
inline

The page title to use for printing or creating a PDF.

Returns
the page title.

Definition at line 102 of file yamlconfig.hpp.

References m_page_title.

Referenced by KitListGui::init().

◆ get_recent_filenames()

std::deque<Glib::ustring> YamlConfig::get_recent_filenames ( )
inline

The history list of recent filenames.

Returns
a list of the most recently used filenames.

Definition at line 116 of file yamlconfig.hpp.

References m_mru_file_history.

Referenced by KitListGui::update_recent_files_menu().

◆ load()

void YamlConfig::load ( )

◆ save()

void YamlConfig::save ( )

◆ set_current_filename()

void YamlConfig::set_current_filename ( Glib::ustring  filename)
inline

Sets the current filename.

Parameters
filenamethe 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().

◆ set_page_title()

void YamlConfig::set_page_title ( Glib::ustring  title)
inline

Set the page title.

Sets the page title used for printing or creating a PDF.

Parameters
titlethe page title to set.

Definition at line 109 of file yamlconfig.hpp.

References add_recent_filename().

Referenced by KitListGui::set_page_title().

Member Data Documentation

◆ m_current_filename

Glib::ustring YamlConfig::m_current_filename
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().

◆ m_debug_log_filename

Glib::ustring YamlConfig::m_debug_log_filename
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().

◆ m_max_recent_files

gint YamlConfig::m_max_recent_files
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().

◆ m_mru_file_history

std::deque<Glib::ustring> YamlConfig::m_mru_file_history
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().

◆ m_page_title

Glib::ustring YamlConfig::m_page_title
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().


The documentation for this class was generated from the following files:

Copyright 2008-2021 Frank Dean