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

View File

@ -312,6 +312,21 @@ QString User::GetLanguage()
// return (wxLanguage)val; // 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) void User::LinkOrUnlinkOperation(Operation& op)
{ {
std::vector<Operation>::iterator it; std::vector<Operation>::iterator it;

View File

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

View File

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