Use new emacs indentation rules (4 spaces instead of tabs and braces position)~
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
Copyright 2010 Grégory Soutadé
|
||||
Copyright 2010 Grégory Soutadé
|
||||
|
||||
This file is part of KissCount.
|
||||
This file is part of KissCount.
|
||||
|
||||
KissCount is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
KissCount is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
KissCount is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
KissCount is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "UsersDialog.h"
|
||||
@@ -29,96 +29,96 @@ END_EVENT_TABLE()
|
||||
|
||||
UsersDialog::UsersDialog(KissCount* kiss, wxUI *parent) : wxDialog(&(*parent), -1, _("Users")), _kiss(kiss), _wxUI(parent)
|
||||
{
|
||||
wxGridBagSizer *gridBagSizer;
|
||||
wxStaticText* label;
|
||||
wxCommandEvent event;
|
||||
wxGridBagSizer *gridBagSizer;
|
||||
wxStaticText* label;
|
||||
wxCommandEvent event;
|
||||
|
||||
gridBagSizer = new wxGridBagSizer(4, 4);
|
||||
gridBagSizer = new wxGridBagSizer(4, 4);
|
||||
|
||||
label = new wxStaticText(this, -1, _("User "));
|
||||
gridBagSizer->Add(label, wxGBPosition(0, 0));
|
||||
_users = new wxChoice(this, wxID_ANY);
|
||||
gridBagSizer->Add(_users, wxGBPosition(0, 1));
|
||||
label = new wxStaticText(this, -1, _("User "));
|
||||
gridBagSizer->Add(label, wxGBPosition(0, 0));
|
||||
_users = new wxChoice(this, wxID_ANY);
|
||||
gridBagSizer->Add(_users, wxGBPosition(0, 1));
|
||||
|
||||
label = new wxStaticText(this, -1, _("Password "));
|
||||
gridBagSizer->Add(label, wxGBPosition(1, 0));
|
||||
_password = new wxTextCtrl(this, wxID_ANY);
|
||||
gridBagSizer->Add(_password, wxGBPosition(1, 1));
|
||||
label = new wxStaticText(this, -1, _("Password "));
|
||||
gridBagSizer->Add(label, wxGBPosition(1, 0));
|
||||
_password = new wxTextCtrl(this, wxID_ANY);
|
||||
gridBagSizer->Add(_password, wxGBPosition(1, 1));
|
||||
|
||||
_password->SetWindowStyle(wxTE_PASSWORD);
|
||||
_password->SetWindowStyle(wxTE_PASSWORD);
|
||||
|
||||
wxButton* ok = new wxButton(this, BUTTON_OK_ID, _("OK"));
|
||||
wxButton* cancel = new wxButton(this, BUTTON_CANCEL_ID, _("Cancel"));
|
||||
wxButton* newUser = new wxButton(this, BUTTON_NEW_USER_ID, _("New User"));
|
||||
gridBagSizer->Add(ok, wxGBPosition(3, 1));
|
||||
gridBagSizer->Add(cancel, wxGBPosition(3, 2));
|
||||
gridBagSizer->Add(newUser, wxGBPosition(3, 3));
|
||||
wxButton* ok = new wxButton(this, BUTTON_OK_ID, _("OK"));
|
||||
wxButton* cancel = new wxButton(this, BUTTON_CANCEL_ID, _("Cancel"));
|
||||
wxButton* newUser = new wxButton(this, BUTTON_NEW_USER_ID, _("New User"));
|
||||
gridBagSizer->Add(ok, wxGBPosition(3, 1));
|
||||
gridBagSizer->Add(cancel, wxGBPosition(3, 2));
|
||||
gridBagSizer->Add(newUser, wxGBPosition(3, 3));
|
||||
|
||||
std::list<wxString> users_list = _kiss->GetUsers();
|
||||
std::list<wxString> users_list = _kiss->GetUsers();
|
||||
|
||||
for(std::list<wxString>::iterator i = users_list.begin(); i != users_list.end(); i++)
|
||||
for(std::list<wxString>::iterator i = users_list.begin(); i != users_list.end(); i++)
|
||||
{
|
||||
_users->Append(*i);
|
||||
_users->Append(*i);
|
||||
}
|
||||
|
||||
_users->Select(0);
|
||||
_users->Select(0);
|
||||
|
||||
SetSizer(gridBagSizer);
|
||||
SetSizer(gridBagSizer);
|
||||
|
||||
_users->SetFocus();
|
||||
Layout();
|
||||
Center();
|
||||
_users->SetFocus();
|
||||
Layout();
|
||||
Center();
|
||||
|
||||
if (users_list.size() == 0)
|
||||
OnNewUser(event);
|
||||
else
|
||||
ShowModal();
|
||||
if (users_list.size() == 0)
|
||||
OnNewUser(event);
|
||||
else
|
||||
ShowModal();
|
||||
}
|
||||
|
||||
void UsersDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
// No users in database
|
||||
if (!_users->GetStringSelection().Length())
|
||||
// No users in database
|
||||
if (!_users->GetStringSelection().Length())
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_kiss->IsValidUser(_users->GetStringSelection(), _password->GetLineText(0)))
|
||||
if (!_kiss->IsValidUser(_users->GetStringSelection(), _password->GetLineText(0)))
|
||||
{
|
||||
wxMessageBox(_("Invalid password"), _("Error"), wxICON_ERROR | wxOK);
|
||||
wxMessageBox(_("Invalid password"), _("Error"), wxICON_ERROR | wxOK);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
_kiss->LoadUser(_users->GetStringSelection());
|
||||
Close();
|
||||
_kiss->LoadUser(_users->GetStringSelection());
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
void UsersDialog::OnCancel(wxCommandEvent& event)
|
||||
{
|
||||
Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
void UsersDialog::OnNewUser(wxCommandEvent& event)
|
||||
{
|
||||
wxString name;
|
||||
wxTextEntryDialog u(this, wxT(""), _("New User"));
|
||||
wxString name;
|
||||
wxTextEntryDialog u(this, wxT(""), _("New User"));
|
||||
|
||||
if (u.ShowModal() == wxID_CANCEL)
|
||||
return;
|
||||
if (u.ShowModal() == wxID_CANCEL)
|
||||
return;
|
||||
|
||||
name = u.GetValue();
|
||||
name = u.GetValue();
|
||||
|
||||
if (!name.size()) return;
|
||||
if (!name.size()) return;
|
||||
|
||||
if (_kiss->UserExists(name))
|
||||
if (_kiss->UserExists(name))
|
||||
{
|
||||
wxMessageBox(_("User ") + name + _(" already exists"), _("Error"), wxICON_ERROR | wxOK);
|
||||
return;
|
||||
wxMessageBox(_("User ") + name + _(" already exists"), _("Error"), wxICON_ERROR | wxOK);
|
||||
return;
|
||||
}
|
||||
|
||||
_kiss->NewUser(name);
|
||||
_kiss->LoadUser(name);
|
||||
_kiss->NewUser(name);
|
||||
_kiss->LoadUser(name);
|
||||
|
||||
Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user