Skip to content

Commit

Permalink
Made enter key pressed unlock password forms. fixes #89
Browse files Browse the repository at this point in the history
  • Loading branch information
epoupon committed Jul 25, 2023
1 parent 6a2fb27 commit 9d0e57e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
31 changes: 17 additions & 14 deletions src/fileshelter/ui/ShareCreatePassword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,9 @@ namespace UserInterface

ShareCreatePassword::ShareCreatePassword()
{
auto model = std::make_shared<ShareCreatePasswordFormModel>();
auto model {std::make_shared<ShareCreatePasswordFormModel>()};

setTemplateText(tr("template-share-create-password"));
addFunction("id", &WTemplate::Functions::id);
addFunction("block", &WTemplate::Functions::block);

// Password
auto password = std::make_unique<Wt::WLineEdit>();
password->setEchoMode(Wt::EchoMode::Password);
setFormWidget(ShareCreatePasswordFormModel::PasswordField, std::move(password));

// Buttons
Wt::WPushButton* unlockBtn {bindNew<Wt::WPushButton>("unlock-btn", tr("msg-unlock"))};
unlockBtn->clicked().connect([=]
auto validateForm {[this, model]
{
updateModel(model.get());

Expand All @@ -100,7 +89,21 @@ namespace UserInterface
std::this_thread::sleep_for(std::chrono::seconds {1});

updateView(model.get());
});
}};

setTemplateText(tr("template-share-create-password"));
addFunction("id", &WTemplate::Functions::id);
addFunction("block", &WTemplate::Functions::block);

// Password
auto password = std::make_unique<Wt::WLineEdit>();
password->setEchoMode(Wt::EchoMode::Password);
password->enterPressed().connect([=]{ validateForm(); });
setFormWidget(ShareCreatePasswordFormModel::PasswordField, std::move(password));

// Buttons
Wt::WPushButton* unlockBtn {bindNew<Wt::WPushButton>("unlock-btn", tr("msg-unlock"))};
unlockBtn->clicked().connect([=] { validateForm(); });

updateView(model.get());
}
Expand Down
29 changes: 16 additions & 13 deletions src/fileshelter/ui/ShareDownloadPassword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,7 @@ namespace UserInterface
{
auto model {std::make_shared<ShareDownloadPasswordFormModel>(shareUUID)};

setTemplateText(tr("template-share-download-password"));
addFunction("id", &WTemplate::Functions::id);
addFunction("block", &WTemplate::Functions::block);

// Password
auto password = std::make_unique<Wt::WLineEdit>();
password->setEchoMode(Wt::EchoMode::Password);
setFormWidget(ShareDownloadPasswordFormModel::PasswordField, std::move(password));

// Buttons
Wt::WPushButton *unlockBtn = bindNew<Wt::WPushButton>("unlock-btn", tr("msg-unlock"));
unlockBtn->clicked().connect([=]
auto validateForm {[this, model]
{
updateModel(model.get());

Expand All @@ -117,7 +106,21 @@ namespace UserInterface
FS_LOG(UI, DEBUG) << "Download password validation failed";

updateView(model.get());
});
}};

setTemplateText(tr("template-share-download-password"));
addFunction("id", &WTemplate::Functions::id);
addFunction("block", &WTemplate::Functions::block);

// Password
auto password = std::make_unique<Wt::WLineEdit>();
password->setEchoMode(Wt::EchoMode::Password);
password->enterPressed().connect([=]{ validateForm(); });
setFormWidget(ShareDownloadPasswordFormModel::PasswordField, std::move(password));

// Buttons
Wt::WPushButton *unlockBtn = bindNew<Wt::WPushButton>("unlock-btn", tr("msg-unlock"));
unlockBtn->clicked().connect([=] { validateForm(); });

updateView(model.get());
}
Expand Down

0 comments on commit 9d0e57e

Please sign in to comment.