BibleTime
|
#include <btconfig.h>
Public Types | |
using | FontSettingsPair = QPair< bool, QFont > |
using | ShortcutsMap = QHash< QString, QList< QKeySequence > > |
using | StringMap = QMap< QString, QString > |
Public Member Functions | |
QString | addSession (const QString &name) |
Creates a new session with the given name. More... | |
QString | booknameLanguage () |
QString const & | currentSessionKey () const |
QString | currentSessionName () const |
void | deleteSearchScopesWithCurrentLocale () |
void | deleteSession (const QString &key) |
Deletes the session with the given key. More... | |
QFont const & | getDefaultFont () const |
CSwordModuleInfo * | getDefaultSwordModuleByType (const QString &moduleType) |
Returns default sword module info class for a given module type. More... | |
DisplayOptions | getDisplayOptions () const |
FilterOptions | getFilterOptions () const |
FontSettingsPair | getFontForLanguage (Language const &language) |
Get font for a language. More... | |
QString | getModuleEncryptionKey (const QString &name) |
Function to get a module decryption key. More... | |
StringMap | getSearchScopesForCurrentLocale (const QStringList &scopeModules) |
ShortcutsMap | getShortcuts (QString const &shortcutGroup) |
Gets the shortcuts for the given group. More... | |
BtConfigCore | session () const |
QHash< QString, QString > | sessionNames () const |
void | setCurrentSession (const QString &key) |
Notifies the configuration system that the session settings should be read from and saved to the given session. More... | |
void | setDefaultSwordModuleByType (const QString &moduleType, const CSwordModuleInfo *const module) |
Sets the default sword module for a module type. More... | |
void | setFontForLanguage (Language const &language, FontSettingsPair const &fontSettings) |
Set font for a language. More... | |
void | setModuleEncryptionKey (const QString &name, const QString &key) |
Function to set a module decryption key. More... | |
void | setSearchScopesWithCurrentLocale (const QStringList &scopeModules, StringMap searchScopes) |
void | setShortcuts (QString const &shortcutGroup, ShortcutsMap const &shortcuts) |
Sets the shortcuts for the given group. More... | |
Public Member Functions inherited from BtConfigCore | |
BtConfigCore (BtConfigCore &&)=default | |
BtConfigCore (BtConfigCore const &)=default | |
QStringList | childGroups () const |
QStringList | childKeys () const |
template<typename Prefix > | |
BtConfigCore | group (Prefix &&prefix) && |
template<typename Prefix > | |
BtConfigCore | group (Prefix &&prefix) const & |
BtConfigCore & | operator= (BtConfigCore &&)=default |
BtConfigCore & | operator= (BtConfigCore const &)=default |
QVariant | qVariantValue (QString const &key, QVariant const &defaultValue=QVariant()) const |
Returns the settings value for the given global key as a QVariant. More... | |
void | remove (QString const &key) |
removes a key (and its children) from the current group. More... | |
template<typename T > | |
void | setValue (QString const &key, T const &value) |
Sets a value for a key. More... | |
void | sync () |
Synchronizes the configuration to disk. More... | |
template<typename T > | |
T | value (QString const &key, T const &defaultValue=T()) const |
Returns the settings value for the given global key. More... | |
~BtConfigCore () | |
Static Public Member Functions | |
static BtConfig & | getInstance () |
static DisplayOptions | loadDisplayOptionsFromGroup (BtConfigCore const &group) |
static FilterOptions | loadFilterOptionsFromGroup (BtConfigCore const &group) |
static sword::ListKey | parseVerseListWithModules (const QString &data, const QStringList &scopeModules) |
static void | storeDisplayOptionsToGroup (DisplayOptions const &options, BtConfigCore &group) |
Saves the current display options. More... | |
static void | storeFilterOptionsToGroup (FilterOptions const &options, BtConfigCore &group) |
Saves the current filter options. More... | |
Private Types | |
enum | InitState { INIT_NEED_UNIMPLEMENTED_BACKWARD_MIGRATE = -2 , INIT_OK = 0 , INIT_NEED_UNIMPLEMENTED_FORWARD_MIGRATE = 2 } |
Private Member Functions | |
BtConfig (const QString &settingsFile) | |
Static Private Member Functions | |
static void | destroyInstance () |
static void | forceMigrate () |
static InitState | initBtConfig () |
Private Attributes | |
QString | m_currentSessionKey |
QFont | m_defaultFont |
default font used when no special one is set More... | |
QHash< Language const *, FontSettingsPair > | m_fontCache |
a cache for the fonts saved in the configuration file for speed More... | |
QHash< QString, QString > | m_sessionNames |
Static Private Attributes | |
static StringMap | m_defaultSearchScopes |
static BtConfig * | m_instance = nullptr |
singleton instance More... | |
Friends | |
class | BibleTimeApp |
Definition at line 35 of file btconfig.h.
using BtConfig::FontSettingsPair = QPair<bool, QFont> |
The first parameter indicates whether the custom font should be used or not. The second parameter is the custom font that has been set.
Definition at line 47 of file btconfig.h.
using BtConfig::ShortcutsMap = QHash<QString, QList<QKeySequence> > |
Definition at line 49 of file btconfig.h.
using BtConfig::StringMap = QMap<QString, QString> |
Definition at line 48 of file btconfig.h.
|
private |
Enumerator | |
---|---|
INIT_NEED_UNIMPLEMENTED_BACKWARD_MIGRATE | |
INIT_OK | |
INIT_NEED_UNIMPLEMENTED_FORWARD_MIGRATE |
Definition at line 53 of file btconfig.h.
|
explicitprivate |
Definition at line 72 of file btconfig.cpp.
References BT_ASSERT, BtConfigCore::group(), anonymous_namespace{btconfig.cpp}::GROUP_SESSIONS, anonymous_namespace{btconfig.cpp}::KEY_CURRENT_SESSION, anonymous_namespace{btconfig.cpp}::KEY_SESSION_NAME, m_currentSessionKey, m_defaultFont, m_defaultSearchScopes, m_instance, m_sessionNames, and BtConfigCore::setValue().
QString BtConfig::addSession | ( | const QString & | name | ) |
Creates a new session with the given name.
[in] | name | the name of the session |
Definition at line 177 of file btconfig.cpp.
References BT_ASSERT, anonymous_namespace{btconfig.cpp}::KEY_SESSION_NAME, m_sessionNames, and BtConfigCore::setValue().
Referenced by BibleTime::saveToNewProfile().
QString BtConfig::booknameLanguage | ( | ) |
Definition at line 473 of file btconfig.cpp.
References r(), and BtConfigCore::setValue().
Referenced by CDisplaySettingsPage::bookNameAbbreviationsTryVector().
|
inline |
Definition at line 66 of file btconfig.h.
References m_currentSessionKey.
Referenced by BibleTime::refreshProfileMenus().
|
inline |
Definition at line 71 of file btconfig.h.
References BT_ASSERT, m_currentSessionKey, and m_sessionNames.
void BtConfig::deleteSearchScopesWithCurrentLocale | ( | ) |
Deletes the searchScopes given in the current locale.
Definition at line 499 of file btconfig.cpp.
References BtConfigCore::remove().
Referenced by Search::CRangeChooserDialog::initConnections().
void BtConfig::deleteSession | ( | const QString & | key | ) |
Deletes the session with the given key.
[in] | key | the key of the session to delete. |
Definition at line 205 of file btconfig.cpp.
References BT_ASSERT, anonymous_namespace{btconfig.cpp}::GROUP_SESSIONS_PREFIX, m_currentSessionKey, m_sessionNames, and BtConfigCore::remove().
Referenced by BibleTime::deleteProfile().
|
staticprivate |
Definition at line 216 of file btconfig.cpp.
References m_instance.
Referenced by BibleTimeApp::~BibleTimeApp().
|
staticprivate |
Definition at line 161 of file btconfig.cpp.
References BTCONFIG_API_VERSION, anonymous_namespace{btconfig.cpp}::BTCONFIG_API_VERSION_KEY, m_instance, and BtConfigCore::setValue().
Referenced by BibleTimeApp::initBtConfig().
|
inline |
Returns a default font that is suitable for the current language.
Definition at line 192 of file btconfig.h.
References m_defaultFont.
Referenced by CDisplayTemplateMgr::fillTemplate(), and getFontForLanguage().
CSwordModuleInfo * BtConfig::getDefaultSwordModuleByType | ( | const QString & | moduleType | ) |
Returns default sword module info class for a given module type.
This is basically a convenience function for getting the respective "settings/defaults/ *" variable and searching that module manually. If module is not installed 0 will be returned.
[in] | moduleType | module type to return the default sword module info for |
Definition at line 503 of file btconfig.cpp.
References CSwordBackend::findModuleByName(), and CSwordBackend::instance().
Referenced by anonymous_namespace{btinforendering.cpp}::decodeCrossReference(), ReferenceManager::decodeHyperlink(), anonymous_namespace{btinforendering.cpp}::decodeMorph(), anonymous_namespace{btinforendering.cpp}::getStrongsModule(), Filters::ThmlToHtml::handleToken(), BibleTime::processCommandline(), anonymous_namespace{osistohtml.cpp}::renderReference(), Filters::TeiToHtml::renderReference(), and CDisplayWindow::setBibleReference().
|
inline |
Definition at line 176 of file btconfig.h.
References BtConfigCore::group(), loadDisplayOptionsFromGroup(), and session().
Referenced by CBookmarkIndex::CBookmarkIndex().
|
inline |
Definition at line 160 of file btconfig.h.
References BtConfigCore::group(), loadFilterOptionsFromGroup(), and session().
Referenced by CBookmarkIndex::CBookmarkIndex(), and anonymous_namespace{btbookmarksmodel.cpp}::BookmarkItem::toolTip().
BtConfig::FontSettingsPair BtConfig::getFontForLanguage | ( | Language const & | language | ) |
Get font for a language.
Gets a FontSettingsPair for the language given. If no font has been saved a default font is returned.
[in] | language | pointer to a language to get the font for. |
Definition at line 364 of file btconfig.cpp.
References Language::abbrev(), BT_ASSERT, Language::englishName(), getDefaultFont(), m_fontCache, and BtConfigCore::qVariantValue().
Referenced by CBookKeyChooser::adjustFont(), BtFontSettingsPage::BtFontSettingsPage(), CDisplayTemplateMgr::fillTemplate(), and BtQmlInterface::getFontsFromSettings().
|
static |
Definition at line 164 of file btconfig.cpp.
References BT_ASSERT, and m_instance.
Referenced by btConfig().
QString BtConfig::getModuleEncryptionKey | ( | const QString & | name | ) |
Function to get a module decryption key.
This helper function will retrieve a previously set module decryption key from the configuration. If the key is not set it will return a null string.
[in] | name | Name of module to retrieve the key for |
Definition at line 228 of file btconfig.cpp.
References BT_ASSERT.
Referenced by CSwordModuleInfo::config().
BtConfig::StringMap BtConfig::getSearchScopesForCurrentLocale | ( | const QStringList & | scopeModules | ) |
Returns the searchScopes for the current locale.
This function retrieves the search scopes of the "properties/searchScopes" property and converts them to the current locale.
Definition at line 412 of file btconfig.cpp.
References m_defaultSearchScopes, and parseVerseListWithModules().
Referenced by Search::CRangeChooserDialog::CRangeChooserDialog(), and Search::BtSearchOptionsArea::searchScope().
BtConfig::ShortcutsMap BtConfig::getShortcuts | ( | QString const & | shortcutGroup | ) |
Gets the shortcuts for the given group.
Returns a hash of shortcuts for strings for the respective shortcut group.
[in] | shortcutGroup | The group to retrieve shortcuts for. |
Definition at line 233 of file btconfig.cpp.
References BtConfigCore::group().
Referenced by BtActionCollection::readShortcuts().
|
staticprivate |
Definition at line 141 of file btconfig.cpp.
References BT_ASSERT, BtConfigCore::BtConfig, BTCONFIG_API_VERSION, anonymous_namespace{btconfig.cpp}::BTCONFIG_API_VERSION_KEY, util::directory::getUserBaseDir(), INIT_NEED_UNIMPLEMENTED_BACKWARD_MIGRATE, INIT_NEED_UNIMPLEMENTED_FORWARD_MIGRATE, INIT_OK, m_instance, BtConfigCore::setValue(), and BtConfigCore::value().
Referenced by BibleTimeApp::initBtConfig().
|
static |
Definition at line 320 of file btconfig.cpp.
References BtConfigCore::group(), DisplayOptions::lineBreaks, and DisplayOptions::verseNumbers.
Referenced by CBibleReadWindow::applyProfileSettings(), and getDisplayOptions().
|
static |
Definition at line 283 of file btconfig.cpp.
References FilterOptions::footnotes, FilterOptions::greekAccents, BtConfigCore::group(), FilterOptions::headings, FilterOptions::hebrewCantillation, FilterOptions::hebrewPoints, FilterOptions::lemmas, FilterOptions::morphSegmentation, FilterOptions::morphTags, FilterOptions::redLetterWords, FilterOptions::scriptureReferences, FilterOptions::strongNumbers, and FilterOptions::textualVariants.
Referenced by CBibleReadWindow::applyProfileSettings(), and getFilterOptions().
|
static |
Definition at line 486 of file btconfig.cpp.
References CSwordBackend::findModuleByName(), CSwordBackend::instance(), and CSwordModuleInfo::swordModule().
Referenced by getSearchScopesForCurrentLocale(), Search::BtSearchOptionsArea::searchScope(), and setSearchScopesWithCurrentLocale().
BtConfigCore BtConfig::session | ( | ) | const |
Definition at line 213 of file btconfig.cpp.
References BtConfigCore::group(), anonymous_namespace{btconfig.cpp}::GROUP_SESSIONS_PREFIX, and m_currentSessionKey.
Referenced by BtEditTextPage::BtEditTextPage(), BtTextFiltersTab::BtTextFiltersTab(), BibleTime::createMenuAndToolBar(), getDisplayOptions(), getFilterOptions(), BibleTime::initActions(), BtEditTextPage::initHtmlFont(), BibleTime::reloadProfile(), BtTextFiltersTab::save(), BibleTime::saveProfile(), BibleTime::showOrHideToolBars(), BibleTime::slotToggleMainToolbar(), BibleTime::slotToggleNavigatorToolbar(), BibleTime::slotToggleTextWindowHeader(), BibleTime::slotToggleToolBarsInEachWindow(), BibleTime::slotToggleToolsToolbar(), BibleTime::slotToggleWorksToolbar(), and BibleTime::slotUpdateWindowArrangementActions().
|
inline |
Definition at line 78 of file btconfig.h.
References m_sessionNames.
Referenced by BibleTime::refreshProfileMenus(), and BibleTime::saveToNewProfile().
void BtConfig::setCurrentSession | ( | const QString & | key | ) |
Notifies the configuration system that the session settings should be read from and saved to the given session.
[in] | key | the key of the session to switch to. |
Definition at line 169 of file btconfig.cpp.
References BT_ASSERT, anonymous_namespace{btconfig.cpp}::KEY_CURRENT_SESSION, m_currentSessionKey, m_sessionNames, and BtConfigCore::setValue().
Referenced by BibleTime::saveToNewProfile().
void BtConfig::setDefaultSwordModuleByType | ( | const QString & | moduleType, |
const CSwordModuleInfo *const | module | ||
) |
Sets the default sword module for a module type.
This is basically a convenience function for setting the "settings/defaults/ *" variables to the module->name() string manually. 0 is allowed as the module, then the default module will be unset.
[in] | moduleType | module type to set |
[in] | module | the sword module info to set as default module |
Definition at line 512 of file btconfig.cpp.
References CSwordModuleInfo::name(), and BtConfigCore::setValue().
void BtConfig::setFontForLanguage | ( | Language const & | language, |
FontSettingsPair const & | fontSettings | ||
) |
Set font for a language.
Sets a FontSettingsPair for the language given.
[in] | language | pointer to a language to set the font for |
[in] | fontSettings | FontSettingsPair to set |
Definition at line 338 of file btconfig.cpp.
References Language::abbrev(), BT_ASSERT, Language::englishName(), m_fontCache, and BtConfigCore::setValue().
Referenced by BtFontSettingsPage::save().
void BtConfig::setModuleEncryptionKey | ( | const QString & | name, |
const QString & | key | ||
) |
Function to set a module decryption key.
This helper function will set a module decryption key in the configuration. Any previous key will be overwritten.
[in] | name | Name of module to set the key for |
[in] | key | Decryption key to set as string |
Definition at line 221 of file btconfig.cpp.
References BT_ASSERT, and BtConfigCore::setValue().
Referenced by CSwordModuleInfo::unlock().
void BtConfig::setSearchScopesWithCurrentLocale | ( | const QStringList & | scopeModules, |
StringMap | searchScopes | ||
) |
Sets the searchScopes given in the current locale.
This function sets the search scopes of the "properties/searchScopes" property, the scopes are converted to the english locale before saving them.
[in] | searchScopes | Search scopes in any locale. |
We want to make sure that the search scopes are saved with english key names so loading them will always work with each locale set.
Definition at line 441 of file btconfig.cpp.
References parseVerseListWithModules(), and BtConfigCore::setValue().
Referenced by Search::CRangeChooserDialog::accept().
void BtConfig::setShortcuts | ( | QString const & | shortcutGroup, |
ShortcutsMap const & | shortcuts | ||
) |
Sets the shortcuts for the given group.
Writes a hash of shortcuts for strings for the respective shortcut group.
[in] | shortcutGroup | The group to retrieve shortcuts for. |
[in] | Hash | of strings and lists of shortcuts to write. |
Definition at line 267 of file btconfig.cpp.
References BtConfigCore::group().
Referenced by BtActionCollection::writeShortcuts().
|
static |
Saves the current display options.
[in] | options | The display options to save. |
Definition at line 328 of file btconfig.cpp.
References BtConfigCore::group(), DisplayOptions::lineBreaks, BtConfigCore::setValue(), and DisplayOptions::verseNumbers.
Referenced by CBibleReadWindow::storeProfileSettings().
|
static |
Saves the current filter options.
[in] | options | The filter options to save. |
Definition at line 301 of file btconfig.cpp.
References FilterOptions::footnotes, FilterOptions::greekAccents, BtConfigCore::group(), FilterOptions::headings, FilterOptions::hebrewCantillation, FilterOptions::hebrewPoints, FilterOptions::lemmas, FilterOptions::morphSegmentation, FilterOptions::morphTags, FilterOptions::redLetterWords, FilterOptions::scriptureReferences, BtConfigCore::setValue(), FilterOptions::strongNumbers, and FilterOptions::textualVariants.
Referenced by CBibleReadWindow::storeProfileSettings().
|
friend |
Definition at line 39 of file btconfig.h.
|
private |
Definition at line 293 of file btconfig.h.
Referenced by BtConfig(), currentSessionKey(), currentSessionName(), deleteSession(), session(), and setCurrentSession().
|
private |
default font used when no special one is set
Definition at line 287 of file btconfig.h.
Referenced by BtConfig(), and getDefaultFont().
|
staticprivate |
Definition at line 290 of file btconfig.h.
Referenced by BtConfig(), and getSearchScopesForCurrentLocale().
|
private |
a cache for the fonts saved in the configuration file for speed
Definition at line 288 of file btconfig.h.
Referenced by getFontForLanguage(), and setFontForLanguage().
|
staticprivate |
singleton instance
Definition at line 285 of file btconfig.h.
Referenced by BtConfig(), destroyInstance(), forceMigrate(), getInstance(), initBtConfig(), and BibleTimeApp::~BibleTimeApp().
|
private |
Definition at line 292 of file btconfig.h.
Referenced by addSession(), BtConfig(), currentSessionName(), deleteSession(), sessionNames(), and setCurrentSession().