Skip to content

Commit be11952

Browse files
committed
add 'password' option to <edit>
1 parent 2041e9c commit be11952

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Diff for: widgets.xml

+6
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@
267267
<default>???</default>
268268
<description>Initial text.</description>
269269
</attribute>
270+
<attribute>
271+
<name>password</name>
272+
<type>bool</type>
273+
<default>false</default>
274+
<description>If true, display platform-dependent password mask characters instead of the characters actually entered.</description>
275+
</attribute>
270276
<attribute>
271277
<name>on-change</name>
272278
<type>string</type>

Diff for: widgets/Edit.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ void Edit::parse(Widget *parent, std::map<int, Widget*>& widgets, tinyxml2::XMLE
2121

2222
value = xmlutils::getAttrStr(e, "value", "");
2323

24+
password = xmlutils::getAttrBool(e, "password", false);
25+
2426
onchange = xmlutils::getAttrStr(e, "on-change", "");
2527

2628
oneditingfinished = xmlutils::getAttrStr(e, "on-editing-finished", "");
@@ -33,6 +35,7 @@ QWidget * Edit::createQtWidget(Proxy *proxy, UIProxy *uiproxy, QWidget *parent)
3335
edit->setVisible(visible);
3436
edit->setStyleSheet(QString::fromStdString(style));
3537
edit->setText(QString::fromStdString(value));
38+
edit->setEchoMode(password ? QLineEdit::Password : QLineEdit::Normal);
3639
QObject::connect(edit, &QLineEdit::textChanged, uiproxy, &UIProxy::onValueChangeString);
3740
QObject::connect(edit, &QLineEdit::editingFinished, uiproxy, &UIProxy::onEditingFinished);
3841
setQWidget(edit);

Diff for: widgets/Edit.h

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Edit : public Widget, public EventOnChangeString, public EventOnEditingFin
2020
{
2121
protected:
2222
std::string value;
23+
bool password;
2324

2425
public:
2526
Edit();

0 commit comments

Comments
 (0)