UI: Add "Show" button to password text properties
Allows the user to be able to optionally toggle the password text if they wish. Mostly useful for troubleshooting purposes.
This commit is contained in:
parent
5cb8916522
commit
cce2eb9387
@ -37,6 +37,7 @@ SceneProjector="Fullscreen Projector (Scene)"
|
||||
SourceProjector="Fullscreen Projector (Source)"
|
||||
Clear="Clear"
|
||||
Revert="Revert"
|
||||
Show="Show"
|
||||
|
||||
# "name already exists" dialog box
|
||||
NameExists.Title="Name already exists"
|
||||
|
@ -184,7 +184,8 @@ QWidget *OBSPropertiesView::AddCheckbox(obs_property_t *prop)
|
||||
return NewWidget(prop, checkbox, SIGNAL(stateChanged(int)));
|
||||
}
|
||||
|
||||
QWidget *OBSPropertiesView::AddText(obs_property_t *prop)
|
||||
QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout,
|
||||
QLabel *&label)
|
||||
{
|
||||
const char *name = obs_property_name(prop);
|
||||
const char *val = obs_data_get_string(settings, name);
|
||||
@ -193,13 +194,32 @@ QWidget *OBSPropertiesView::AddText(obs_property_t *prop)
|
||||
if (type == OBS_TEXT_MULTILINE) {
|
||||
QPlainTextEdit *edit = new QPlainTextEdit(QT_UTF8(val));
|
||||
return NewWidget(prop, edit, SIGNAL(textChanged()));
|
||||
|
||||
} else if (type == OBS_TEXT_PASSWORD) {
|
||||
QLayout *subLayout = new QHBoxLayout();
|
||||
QLineEdit *edit = new QLineEdit();
|
||||
QPushButton *show = new QPushButton();
|
||||
|
||||
show->setText(QTStr("Show"));
|
||||
show->setCheckable(true);
|
||||
edit->setText(QT_UTF8(val));
|
||||
edit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
subLayout->addWidget(edit);
|
||||
subLayout->addWidget(show);
|
||||
|
||||
WidgetInfo *info = new WidgetInfo(this, prop, edit);
|
||||
connect(show, &QAbstractButton::toggled,
|
||||
info, &WidgetInfo::TogglePasswordText);
|
||||
children.emplace_back(info);
|
||||
|
||||
label = new QLabel(QT_UTF8(obs_property_description(prop)));
|
||||
layout->addRow(label, subLayout);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QLineEdit *edit = new QLineEdit();
|
||||
|
||||
if (type == OBS_TEXT_PASSWORD)
|
||||
edit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
edit->setText(QT_UTF8(val));
|
||||
|
||||
return NewWidget(prop, edit, SIGNAL(textEdited(const QString &)));
|
||||
@ -571,7 +591,7 @@ void OBSPropertiesView::AddProperty(obs_property_t *property,
|
||||
AddFloat(property, layout, &label);
|
||||
break;
|
||||
case OBS_PROPERTY_TEXT:
|
||||
widget = AddText(property);
|
||||
widget = AddText(property, layout, label);
|
||||
break;
|
||||
case OBS_PROPERTY_PATH:
|
||||
AddPath(property, layout, &label);
|
||||
@ -794,6 +814,12 @@ void WidgetInfo::ButtonClicked()
|
||||
}
|
||||
}
|
||||
|
||||
void WidgetInfo::TogglePasswordText(bool show)
|
||||
{
|
||||
reinterpret_cast<QLineEdit*>(widget)->setEchoMode(
|
||||
show ? QLineEdit::Normal : QLineEdit::Password);
|
||||
}
|
||||
|
||||
void WidgetInfo::ControlChanged()
|
||||
{
|
||||
const char *setting = obs_property_name(property);
|
||||
|
@ -18,6 +18,8 @@ typedef void (*PropertiesUpdateCallback)(void *obj,
|
||||
class WidgetInfo : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
friend class OBSPropertiesView;
|
||||
|
||||
private:
|
||||
OBSPropertiesView *view;
|
||||
obs_property_t *property;
|
||||
@ -33,6 +35,8 @@ private:
|
||||
bool FontChanged(const char *setting);
|
||||
void ButtonClicked();
|
||||
|
||||
void TogglePasswordText(bool checked);
|
||||
|
||||
public:
|
||||
inline WidgetInfo(OBSPropertiesView *view_, obs_property_t *prop,
|
||||
QWidget *widget_)
|
||||
@ -40,6 +44,7 @@ public:
|
||||
{}
|
||||
|
||||
public slots:
|
||||
|
||||
void ControlChanged();
|
||||
};
|
||||
|
||||
@ -72,7 +77,8 @@ private:
|
||||
const char *signal);
|
||||
|
||||
QWidget *AddCheckbox(obs_property_t *prop);
|
||||
QWidget *AddText(obs_property_t *prop);
|
||||
QWidget *AddText(obs_property_t *prop, QFormLayout *layout,
|
||||
QLabel *&label);
|
||||
void AddPath(obs_property_t *prop, QFormLayout *layout, QLabel **label);
|
||||
void AddInt(obs_property_t *prop, QFormLayout *layout, QLabel **label);
|
||||
void AddFloat(obs_property_t *prop, QFormLayout *layout,
|
||||
|
Loading…
x
Reference in New Issue
Block a user