Setup accessors for user's preferences

This commit is contained in:
Grégory Soutadé 2017-10-15 11:36:27 +02:00
parent ea7491aff7
commit 74ca6a2285
4 changed files with 22 additions and 4 deletions

View File

@ -30,8 +30,7 @@ std::vector<ExportEngine*> * KissCount::_exportEngines;
KissCount::KissCount(int& argc, char** argv) : QApplication(argc, argv), _user(0)
{
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
QTextCodec::setCodecForLocale(QTextCodec::codecForName("utf8"));
_wxUI = new wxUI(this, "KissCount");
@ -417,7 +416,7 @@ void KissCount::KillMe()
void KissCount::SetLanguage(QString language)
{
_user->_preferences["language"] = language;
_user->SetLanguage(language);
_db->UpdatePreference(_user, "language");
}

View File

@ -312,6 +312,21 @@ QString User::GetLanguage()
// return (wxLanguage)val;
}
void User::SetLanguage(QString language)
{
_preferences["language"] = language;
}
int User::GetDefaultCurrency()
{
return _preferences["defaultCurrency"].toInt();
}
void User::SetDefaultCurrency(int currency)
{
_preferences["defaultCurrency"] = QString(currency);
}
void User::LinkOrUnlinkOperation(Operation& op)
{
std::vector<Operation>::iterator it;

View File

@ -88,7 +88,11 @@ public:
int GetOperationsNumber(int month, int year);
QString GetLanguage();
void SetLanguage(QString language);
int GetDefaultCurrency();
void SetDefaultCurrency(int currency);
void LinkOrUnlinkOperation(Operation& op);
void Group(const Operation& op);

View File

@ -240,7 +240,7 @@ void wxUI::LoadUser()
User* user = _kiss->GetUser();
int i;
if (user->_preferences["language"].size())
if (user->GetLanguage().size())
SetLanguage(user->GetLanguage());
else
SetLanguage(SupportedLanguages::languages[0].name);