Localization in progress ...
This commit is contained in:
parent
4544a5c3ad
commit
f6c64d5448
|
@ -4,7 +4,7 @@ KissCount::KissCount() : _user(NULL)
|
|||
{
|
||||
_wxUI = new wxUI(this, wxT("KissCount"), wxPoint(50, 50), wxSize(1024, 768));
|
||||
|
||||
_wxUI->InitLanguage(wxLocale::GetSystemLanguage());
|
||||
_wxUI->SetLanguage(wxLocale::GetSystemLanguage());
|
||||
|
||||
_wxUI->Show(true);
|
||||
_wxUI->Centre();
|
||||
|
|
|
@ -85,3 +85,16 @@ int User::GetOperationsNumber(int month, int year)
|
|||
{
|
||||
return (*_operations[year])[month].size();
|
||||
}
|
||||
|
||||
wxLanguage User::GetLanguage()
|
||||
{
|
||||
wxString res = _preferences[wxT("language")];
|
||||
long val;
|
||||
|
||||
if (res == wxT(""))
|
||||
return wxLANGUAGE_ENGLISH_UK ;
|
||||
|
||||
res.ToLong(&val);
|
||||
|
||||
return (wxLanguage)val;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ class User
|
|||
int GetCategoriesNumber();
|
||||
int GetAccountsNumber();
|
||||
int GetOperationsNumber(int month, int year);
|
||||
wxLanguage GetLanguage();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
enum {ACCOUNT_NAME, ACCOUNT_NUMBER, ACCOUNT_SHARED, ACCOUNT_DEFAULT, ACCOUNT_DELETE, NUMBER_COLS_ACCOUNT};
|
||||
enum {CATEGORY_NAME, CATEGORY_COLOR, CATEGORY_FONT, CATEGORY_DELETE, NUMBER_COLS_CATEGORY};
|
||||
|
||||
enum {CATEGORIES_GRID_ID=1, ACCOUNTS_GRID_ID, NAME_ID, CHANGE_NAME_ID, CHANGE_PASSWORD_ID, KILL_ME_ID};
|
||||
enum {CATEGORIES_GRID_ID=1, ACCOUNTS_GRID_ID, NAME_ID, CHANGE_NAME_ID, CHANGE_PASSWORD_ID, KILL_ME_ID, LANGUAGE_ID};
|
||||
|
||||
BEGIN_EVENT_TABLE(PreferencesPanel, wxPanel)
|
||||
EVT_BUTTON(CHANGE_NAME_ID, PreferencesPanel::OnChangeName)
|
||||
|
@ -11,6 +11,7 @@ EVT_BUTTON(CHANGE_PASSWORD_ID, PreferencesPanel::OnChangePassword)
|
|||
EVT_BUTTON(KILL_ME_ID, PreferencesPanel::OnKillMe)
|
||||
EVT_GRID_CMD_CELL_CHANGE(CATEGORIES_GRID_ID, PreferencesPanel::OnCategoryModified)
|
||||
EVT_GRID_CMD_CELL_CHANGE(ACCOUNTS_GRID_ID, PreferencesPanel::OnAccountModified)
|
||||
EVT_COMBOBOX(LANGUAGE_ID, PreferencesPanel::OnLanguageChange)
|
||||
EVT_SHOW(PreferencesPanel::OnShow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
@ -18,7 +19,7 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
|
|||
{
|
||||
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
||||
//wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxStaticBox* staticUser, *staticAccount, *staticCategories;
|
||||
wxStaticBox* staticUser, *staticAccount, *staticCategories, *staticLanguage;
|
||||
User* user = _kiss->GetUser();
|
||||
wxGridBagSizer *gridBagSizer;
|
||||
wxStaticText* label;
|
||||
|
@ -30,6 +31,7 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
|
|||
staticUser = new wxStaticBox(this, -1, _("User"));
|
||||
staticAccount = new wxStaticBox(this, -1, _("Accounts"));
|
||||
staticCategories = new wxStaticBox(this, -1, _("Categories"));
|
||||
staticLanguage = new wxStaticBox(this, -1, _("Language"));
|
||||
|
||||
// User
|
||||
staticBoxSizer = new wxStaticBoxSizer (staticUser, wxVERTICAL);
|
||||
|
@ -76,6 +78,21 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent) : wxPanel(&(*p
|
|||
InitCategories(user);
|
||||
|
||||
vbox->Add(staticBoxSizer);
|
||||
vbox->Add(-1, 20);
|
||||
|
||||
// Language
|
||||
staticBoxSizer = new wxStaticBoxSizer (staticLanguage, wxVERTICAL);
|
||||
|
||||
_language = new wxBitmapComboBox(this, LANGUAGE_ID);
|
||||
_language->SetWindowStyle(wxCB_READONLY);
|
||||
|
||||
staticBoxSizer->Add(_language);
|
||||
|
||||
vbox->Add(staticBoxSizer);
|
||||
|
||||
InitLanguage(user);
|
||||
|
||||
_language->Fit();
|
||||
|
||||
Fit();
|
||||
SetMinSize(GetSize());
|
||||
|
@ -176,6 +193,21 @@ void PreferencesPanel::InitCategories(User* user)
|
|||
SET_ROW_COLOR(curLine, OWN_GREEN);
|
||||
}
|
||||
|
||||
void PreferencesPanel::InitLanguage(User* user)
|
||||
{
|
||||
int i, select=0;
|
||||
wxLanguage pref = user->GetLanguage();
|
||||
|
||||
for (i=0; i<NB_SUPPORTED_LANGUAGES; i++)
|
||||
{
|
||||
_language->Append(languages[i].name, wxBitmap(languages[i].icon));
|
||||
if (languages[i].language == pref)
|
||||
select = i;
|
||||
}
|
||||
|
||||
_language->Select(select);
|
||||
}
|
||||
|
||||
void PreferencesPanel::OnAccountModified(wxGridEvent& event)
|
||||
{
|
||||
int op_complete = 2;
|
||||
|
@ -443,6 +475,12 @@ void PreferencesPanel::OnChangePassword(wxCommandEvent& event)
|
|||
p.ShowModal();
|
||||
}
|
||||
|
||||
void PreferencesPanel::OnLanguageChange(wxCommandEvent& event)
|
||||
{
|
||||
wxLanguage language = languages[_language->GetSelection()].language;
|
||||
_wxUI->SetLanguage(language);
|
||||
}
|
||||
|
||||
void PreferencesPanel::OnShow(wxShowEvent& event)
|
||||
{
|
||||
_wxUI->SetTitle(_kiss->GetUser()->_name + _(" - ") +_("Preferences"));
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
#include <wx/gbsizer.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/bmpcbox.h>
|
||||
|
||||
#include <controller/KissCount.h>
|
||||
#include "wxUI.h"
|
||||
#include <model/model.h>
|
||||
#include "PasswordDialog.h"
|
||||
#include "SupportedLanguages.h"
|
||||
|
||||
class wxUI;
|
||||
class KissCount;
|
||||
|
@ -27,6 +29,7 @@ class PreferencesPanel: public wxPanel
|
|||
void OnCategoryModified(wxGridEvent& event);
|
||||
void OnChangeName(wxCommandEvent& event);
|
||||
void OnChangePassword(wxCommandEvent& event);
|
||||
void OnLanguageChange(wxCommandEvent& event);
|
||||
void OnShow(wxShowEvent& event);
|
||||
void OnKillMe(wxCommandEvent& event);
|
||||
|
||||
|
@ -36,9 +39,11 @@ class PreferencesPanel: public wxPanel
|
|||
wxGrid* _accountsGrid;
|
||||
wxGrid* _categoriesGrid;
|
||||
wxTextCtrl* _name;
|
||||
wxBitmapComboBox* _language;
|
||||
|
||||
void InitAccounts(User* user);
|
||||
void InitCategories(User* user);
|
||||
void InitLanguage(User* user);
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
|
|
@ -47,9 +47,10 @@ wxUI::~wxUI()
|
|||
if (_locale) delete _locale;
|
||||
}
|
||||
|
||||
bool wxUI::InitLanguage(long language)
|
||||
bool wxUI::SetLanguage(long language)
|
||||
{
|
||||
if (_locale) delete _locale;
|
||||
_locale = NULL;
|
||||
|
||||
// load language if possible, fall back to english otherwise
|
||||
if(wxLocale::IsAvailable(language))
|
||||
|
@ -68,7 +69,6 @@ bool wxUI::InitLanguage(long language)
|
|||
{
|
||||
if (_locale) delete _locale;
|
||||
_locale = new wxLocale( wxLANGUAGE_ENGLISH );
|
||||
language = wxLANGUAGE_ENGLISH;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class wxUI: public wxFrame
|
|||
wxUI(KissCount* kiss, const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||
~wxUI();
|
||||
|
||||
bool InitLanguage(long language);
|
||||
bool SetLanguage(long language);
|
||||
|
||||
void ChangeUser();
|
||||
void LoadUser();
|
||||
|
|
Loading…
Reference in New Issue
Block a user