ui/qt/text.cpp

changeset 524
ce7a198b54b0
parent 523
0797c87a2c02
child 527
7273a78e8e5b
equal deleted inserted replaced
523:0797c87a2c02 524:ce7a198b54b0
35 35
36 36
37 37
38 /* ------------------------------ TextField ------------------------------ */ 38 /* ------------------------------ TextField ------------------------------ */
39 39
40 UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args) { 40 static UIWIDGET create_textfield(UiObject *obj, UiTextFieldArgs args, bool password, bool frameless) {
41 UiContainerPrivate *ctn = ui_obj_container(obj); 41 UiContainerPrivate *ctn = ui_obj_container(obj);
42 UI_APPLY_LAYOUT(ctn->layout, args); 42 UI_APPLY_LAYOUT(ctn->layout, args);
43 43
44 QLineEdit *textfield = new QLineEdit(); 44 QLineEdit *textfield = new QLineEdit();
45 ctn->add(textfield, false); 45 ctn->add(textfield, false);
46
47 if(password) {
48 textfield->setEchoMode(QLineEdit::Password);
49 }
46 50
47 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_STRING); 51 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_STRING);
48 if(var) { 52 if(var) {
49 UiString *value = (UiString*)var->value; 53 UiString *value = (UiString*)var->value;
50 if(value->value.ptr) { 54 if(value->value.ptr) {
60 value->get = ui_textfield_get; 64 value->get = ui_textfield_get;
61 value->obj = textfield; 65 value->obj = textfield;
62 } 66 }
63 67
64 return textfield; 68 return textfield;
69 }
70
71 UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args) {
72 return create_textfield(obj, args, false, false);
73 }
74
75 UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs args) {
76 return create_textfield(obj, args, false, true);
77 }
78
79 UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs args) {
80 return create_textfield(obj, args, true, false);
65 } 81 }
66 82
67 char* ui_textfield_get(UiString *str) { 83 char* ui_textfield_get(UiString *str) {
68 QLineEdit *textfield = (QLineEdit*)str->obj; 84 QLineEdit *textfield = (QLineEdit*)str->obj;
69 QString qstr = textfield->text(); 85 QString qstr = textfield->text();

mercurial