Polish the tmp_login class.
- Use the new register functions. - Updated wiki comment. - change the scroll_label by a wrapping label.
This commit is contained in:
parent
62ed384d10
commit
925d897241
3 changed files with 26 additions and 44 deletions
|
@ -52,12 +52,12 @@
|
||||||
border = "all"
|
border = "all"
|
||||||
border_size = 5
|
border_size = 5
|
||||||
horizontal_alignment = "left"
|
horizontal_alignment = "left"
|
||||||
[scroll_label]
|
[label]
|
||||||
id = "login_label"
|
id = "login_label"
|
||||||
definition = "default"
|
definition = "default"
|
||||||
|
|
||||||
label = ""
|
wrap = "true"
|
||||||
[/scroll_label]
|
[/label]
|
||||||
|
|
||||||
[/column]
|
[/column]
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,10 @@ namespace gui2 {
|
||||||
* password & & text_box & m &
|
* password & & text_box & m &
|
||||||
* The password. $
|
* The password. $
|
||||||
*
|
*
|
||||||
|
* remember_password & & toggle_button & o &
|
||||||
|
* A toggle button to offer to remember the password in the
|
||||||
|
* preferences.$
|
||||||
|
*
|
||||||
* password_reminder & & button & o &
|
* password_reminder & & button & o &
|
||||||
* Request a password reminder. $
|
* Request a password reminder. $
|
||||||
*
|
*
|
||||||
|
@ -57,24 +61,29 @@ namespace gui2 {
|
||||||
|
|
||||||
REGISTER_DIALOG(mp_login)
|
REGISTER_DIALOG(mp_login)
|
||||||
|
|
||||||
tmp_login::tmp_login(const t_string& label, const bool focus_password)
|
tmp_login::tmp_login(const std::string& label, const bool focus_password)
|
||||||
: label_(label)
|
|
||||||
, focus_password_(focus_password)
|
|
||||||
{
|
{
|
||||||
|
register_label2("login_label", false, label);
|
||||||
|
register_text2("user_name"
|
||||||
|
, true
|
||||||
|
, &preferences::login
|
||||||
|
, &preferences::set_login
|
||||||
|
, !focus_password);
|
||||||
|
|
||||||
|
register_text2("password"
|
||||||
|
, true
|
||||||
|
, &preferences::password
|
||||||
|
, NULL /* The password box returns '*' as value. */
|
||||||
|
, focus_password);
|
||||||
|
|
||||||
|
register_bool("remember_password"
|
||||||
|
, true
|
||||||
|
, &preferences::remember_password
|
||||||
|
, &preferences::set_remember_password);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmp_login::pre_show(CVideo& /*video*/, twindow& window)
|
void tmp_login::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
{
|
{
|
||||||
ttext_box* username =
|
|
||||||
find_widget<ttext_box>(&window, "user_name", false, true);
|
|
||||||
username->set_value(preferences::login());
|
|
||||||
|
|
||||||
tpassword_box* password =
|
|
||||||
find_widget<tpassword_box>(&window, "password", false, true);
|
|
||||||
password->set_value(preferences::password());
|
|
||||||
|
|
||||||
window.keyboard_capture(focus_password_ ? password : username);
|
|
||||||
|
|
||||||
if(tbutton* button = find_widget<tbutton>(
|
if(tbutton* button = find_widget<tbutton>(
|
||||||
&window, "password_reminder", false, false)) {
|
&window, "password_reminder", false, false)) {
|
||||||
|
|
||||||
|
@ -86,32 +95,11 @@ void tmp_login::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
|
|
||||||
button->set_retval(2);
|
button->set_retval(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needs to be a scroll_label since the text can get long and a normal
|
|
||||||
// label can't wrap (at the moment).
|
|
||||||
tcontrol* label =
|
|
||||||
dynamic_cast<tscroll_label*>(window.find("login_label", false));
|
|
||||||
if(label) label->set_label(label_);
|
|
||||||
|
|
||||||
if(ttoggle_button* button = find_widget<ttoggle_button>(
|
|
||||||
&window, "remember_password", false, false)) {
|
|
||||||
|
|
||||||
button->set_value(preferences::remember_password());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmp_login::post_show(twindow& window)
|
void tmp_login::post_show(twindow& window)
|
||||||
{
|
{
|
||||||
if(get_retval() == twindow::OK) {
|
if(get_retval() == twindow::OK) {
|
||||||
if(ttoggle_button* button = find_widget<ttoggle_button>(
|
|
||||||
&window, "remember_password", false, false)) {
|
|
||||||
|
|
||||||
preferences::set_remember_password(button->get_value());
|
|
||||||
}
|
|
||||||
|
|
||||||
preferences::set_login(find_widget<ttext_box>(
|
|
||||||
&window, "user_name", false).get_value());
|
|
||||||
|
|
||||||
preferences::set_password(find_widget<tpassword_box>(
|
preferences::set_password(find_widget<tpassword_box>(
|
||||||
&window, "password", false).get_real_value());
|
&window, "password", false).get_real_value());
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,13 @@
|
||||||
#define GUI_DIALOGS_MP_LOGIN_HPP_INCLUDED
|
#define GUI_DIALOGS_MP_LOGIN_HPP_INCLUDED
|
||||||
|
|
||||||
#include "gui/dialogs/dialog.hpp"
|
#include "gui/dialogs/dialog.hpp"
|
||||||
#include "tstring.hpp"
|
|
||||||
|
|
||||||
namespace gui2 {
|
namespace gui2 {
|
||||||
|
|
||||||
class tmp_login : public tdialog
|
class tmp_login : public tdialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
tmp_login(const t_string& label,
|
tmp_login(const std::string& label,
|
||||||
const bool focus_password);
|
const bool focus_password);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -37,11 +36,6 @@ private:
|
||||||
|
|
||||||
/** Inherited from tdialog. */
|
/** Inherited from tdialog. */
|
||||||
void post_show(twindow& window);
|
void post_show(twindow& window);
|
||||||
|
|
||||||
t_string label_;
|
|
||||||
|
|
||||||
/** Should the password box be focussed upon showing the dialog? */
|
|
||||||
bool focus_password_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gui2
|
} // namespace gui2
|
||||||
|
|
Loading…
Add table
Reference in a new issue