Application's config is global now

This commit is contained in:
Simon Rozman 2016-04-06 13:09:33 +02:00
parent 8fd0437502
commit 1cb4f470c6
2 changed files with 6 additions and 7 deletions

View File

@ -27,23 +27,23 @@
wxIMPLEMENT_APP(ZRColaApp); wxIMPLEMENT_APP(ZRColaApp);
ZRColaApp::ZRColaApp() : ZRColaApp::ZRColaApp() : wxApp()
m_config(wxT(ZRCOLA_CFG_APPLICATION), wxT(ZRCOLA_CFG_VENDOR)),
wxApp()
{ {
} }
bool ZRColaApp::OnInit() bool ZRColaApp::OnInit()
{ {
wxConfigBase::Set(new wxConfig(wxT(ZRCOLA_CFG_APPLICATION), wxT(ZRCOLA_CFG_VENDOR)));
if (!wxApp::OnInit()) if (!wxApp::OnInit())
return false; return false;
// Set desired locale. // Set desired locale.
wxLanguage language = (wxLanguage)m_config.Read(wxT("Language"), wxLANGUAGE_DEFAULT); wxLanguage language = (wxLanguage)wxConfigBase::Get()->Read(wxT("Language"), wxLANGUAGE_DEFAULT);
if (wxLocale::IsAvailable(language)) { if (wxLocale::IsAvailable(language)) {
wxString sPath; wxString sPath;
if (m_config.Read(wxT("LocalizationRepositoryPath"), &sPath)) if (wxConfigBase::Get()->Read(wxT("LocalizationRepositoryPath"), &sPath))
m_locale.AddCatalogLookupPathPrefix(sPath); m_locale.AddCatalogLookupPathPrefix(sPath);
wxVERIFY(m_locale.Init(language)); wxVERIFY(m_locale.Init(language));
wxVERIFY(m_locale.AddCatalog(wxT("wxExtend"))); wxVERIFY(m_locale.AddCatalog(wxT("wxExtend")));

View File

@ -55,7 +55,6 @@ public:
protected: protected:
wxConfig m_config; ///< Application configuration
wxLocale m_locale; ///< Current locale wxLocale m_locale; ///< Current locale
}; };
@ -66,7 +65,7 @@ wxDECLARE_APP(ZRColaApp);
inline wxString ZRColaApp::GetDatabasePath() const inline wxString ZRColaApp::GetDatabasePath() const
{ {
wxString sPath; wxString sPath;
if (m_config.Read(wxT("DatabasePath"), &sPath)) { if (wxConfigBase::Get()->Read(wxT("DatabasePath"), &sPath)) {
if (!wxEndsWithPathSeparator(sPath)) if (!wxEndsWithPathSeparator(sPath))
sPath << wxFILE_SEP_PATH; sPath << wxFILE_SEP_PATH;
} else { } else {