mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-11-16 23:05:58 +01:00
config: add input-field fail_timeout option (#406)
* config: add input-field fail_timeout option * config: change input-field fail_timeout to milliseconds * input-field: fix configFailTimeoutMs type and init
This commit is contained in:
parent
d8ccc6f96a
commit
944caff79f
4 changed files with 10 additions and 8 deletions
|
@ -125,6 +125,7 @@ void CConfigManager::init() {
|
||||||
m_config.addSpecialConfigValue("input-field", "check_color", Hyprlang::INT{0xFFCC8822});
|
m_config.addSpecialConfigValue("input-field", "check_color", Hyprlang::INT{0xFFCC8822});
|
||||||
m_config.addSpecialConfigValue("input-field", "fail_color", Hyprlang::INT{0xFFCC2222});
|
m_config.addSpecialConfigValue("input-field", "fail_color", Hyprlang::INT{0xFFCC2222});
|
||||||
m_config.addSpecialConfigValue("input-field", "fail_text", Hyprlang::STRING{"<i>$FAIL</i>"});
|
m_config.addSpecialConfigValue("input-field", "fail_text", Hyprlang::STRING{"<i>$FAIL</i>"});
|
||||||
|
m_config.addSpecialConfigValue("input-field", "fail_timeout", Hyprlang::INT{2000});
|
||||||
m_config.addSpecialConfigValue("input-field", "fail_transition", Hyprlang::INT{300});
|
m_config.addSpecialConfigValue("input-field", "fail_transition", Hyprlang::INT{300});
|
||||||
m_config.addSpecialConfigValue("input-field", "capslock_color", Hyprlang::INT{-1});
|
m_config.addSpecialConfigValue("input-field", "capslock_color", Hyprlang::INT{-1});
|
||||||
m_config.addSpecialConfigValue("input-field", "numlock_color", Hyprlang::INT{-1});
|
m_config.addSpecialConfigValue("input-field", "numlock_color", Hyprlang::INT{-1});
|
||||||
|
@ -277,6 +278,7 @@ std::vector<CConfigManager::SWidgetConfig> CConfigManager::getWidgetConfigs() {
|
||||||
{"check_color", m_config.getSpecialConfigValue("input-field", "check_color", k.c_str())},
|
{"check_color", m_config.getSpecialConfigValue("input-field", "check_color", k.c_str())},
|
||||||
{"fail_color", m_config.getSpecialConfigValue("input-field", "fail_color", k.c_str())},
|
{"fail_color", m_config.getSpecialConfigValue("input-field", "fail_color", k.c_str())},
|
||||||
{"fail_text", m_config.getSpecialConfigValue("input-field", "fail_text", k.c_str())},
|
{"fail_text", m_config.getSpecialConfigValue("input-field", "fail_text", k.c_str())},
|
||||||
|
{"fail_timeout", m_config.getSpecialConfigValue("input-field", "fail_timeout", k.c_str())},
|
||||||
{"fail_transition", m_config.getSpecialConfigValue("input-field", "fail_transition", k.c_str())},
|
{"fail_transition", m_config.getSpecialConfigValue("input-field", "fail_transition", k.c_str())},
|
||||||
{"capslock_color", m_config.getSpecialConfigValue("input-field", "capslock_color", k.c_str())},
|
{"capslock_color", m_config.getSpecialConfigValue("input-field", "capslock_color", k.c_str())},
|
||||||
{"numlock_color", m_config.getSpecialConfigValue("input-field", "numlock_color", k.c_str())},
|
{"numlock_color", m_config.getSpecialConfigValue("input-field", "numlock_color", k.c_str())},
|
||||||
|
|
|
@ -760,12 +760,6 @@ static const ext_session_lock_v1_listener sessionLockListener = {
|
||||||
|
|
||||||
// end session_lock
|
// end session_lock
|
||||||
|
|
||||||
static void displayFailTextTimerCallback(std::shared_ptr<CTimer> self, void* data) {
|
|
||||||
g_pAuth->m_bDisplayFailText = false;
|
|
||||||
|
|
||||||
g_pHyprlock->renderAllOutputs();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHyprlock::onPasswordCheckTimer() {
|
void CHyprlock::onPasswordCheckTimer() {
|
||||||
// check result
|
// check result
|
||||||
if (g_pAuth->didAuthSucceed()) {
|
if (g_pAuth->didAuthSucceed()) {
|
||||||
|
@ -778,8 +772,6 @@ void CHyprlock::onPasswordCheckTimer() {
|
||||||
g_pAuth->m_bDisplayFailText = true;
|
g_pAuth->m_bDisplayFailText = true;
|
||||||
forceUpdateTimers();
|
forceUpdateTimers();
|
||||||
|
|
||||||
g_pHyprlock->addTimer(/* controls error message duration */ std::chrono::seconds(1), displayFailTextTimerCallback, nullptr);
|
|
||||||
|
|
||||||
g_pAuth->start();
|
g_pAuth->start();
|
||||||
|
|
||||||
renderAllOutputs();
|
renderAllOutputs();
|
||||||
|
|
|
@ -28,6 +28,7 @@ CPasswordInputField::CPasswordInputField(const Vector2D& viewport_, const std::u
|
||||||
rounding = std::any_cast<Hyprlang::INT>(props.at("rounding"));
|
rounding = std::any_cast<Hyprlang::INT>(props.at("rounding"));
|
||||||
configPlaceholderText = std::any_cast<Hyprlang::STRING>(props.at("placeholder_text"));
|
configPlaceholderText = std::any_cast<Hyprlang::STRING>(props.at("placeholder_text"));
|
||||||
configFailText = std::any_cast<Hyprlang::STRING>(props.at("fail_text"));
|
configFailText = std::any_cast<Hyprlang::STRING>(props.at("fail_text"));
|
||||||
|
configFailTimeoutMs = std::any_cast<Hyprlang::INT>(props.at("fail_timeout"));
|
||||||
col.transitionMs = std::any_cast<Hyprlang::INT>(props.at("fail_transition"));
|
col.transitionMs = std::any_cast<Hyprlang::INT>(props.at("fail_transition"));
|
||||||
col.outer = std::any_cast<Hyprlang::INT>(props.at("outer_color"));
|
col.outer = std::any_cast<Hyprlang::INT>(props.at("outer_color"));
|
||||||
col.inner = std::any_cast<Hyprlang::INT>(props.at("inner_color"));
|
col.inner = std::any_cast<Hyprlang::INT>(props.at("inner_color"));
|
||||||
|
@ -304,6 +305,11 @@ bool CPasswordInputField::draw(const SRenderData& data) {
|
||||||
return dots.currentAmount != passwordLength || fade.animated || col.animated || redrawShadow || data.opacity < 1.0 || forceReload;
|
return dots.currentAmount != passwordLength || fade.animated || col.animated || redrawShadow || data.opacity < 1.0 || forceReload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void failTimeoutCallback(std::shared_ptr<CTimer> self, void* data) {
|
||||||
|
g_pAuth->m_bDisplayFailText = false;
|
||||||
|
g_pHyprlock->renderAllOutputs();
|
||||||
|
}
|
||||||
|
|
||||||
void CPasswordInputField::updatePlaceholder() {
|
void CPasswordInputField::updatePlaceholder() {
|
||||||
if (passwordLength != 0) {
|
if (passwordLength != 0) {
|
||||||
if (placeholder.asset && /* keep prompt asset cause it is likely to be used again */ placeholder.isFailText) {
|
if (placeholder.asset && /* keep prompt asset cause it is likely to be used again */ placeholder.isFailText) {
|
||||||
|
@ -328,6 +334,7 @@ void CPasswordInputField::updatePlaceholder() {
|
||||||
placeholder.asset = nullptr;
|
placeholder.asset = nullptr;
|
||||||
|
|
||||||
if (placeholder.isFailText) {
|
if (placeholder.isFailText) {
|
||||||
|
g_pHyprlock->addTimer(std::chrono::milliseconds(configFailTimeoutMs), failTimeoutCallback, nullptr);
|
||||||
placeholder.currentText = configFailText;
|
placeholder.currentText = configFailText;
|
||||||
replaceAll(placeholder.currentText, "$FAIL", AUTHFEEDBACK);
|
replaceAll(placeholder.currentText, "$FAIL", AUTHFEEDBACK);
|
||||||
replaceAll(placeholder.currentText, "$ATTEMPTS", std::to_string(placeholder.failedAttempts));
|
replaceAll(placeholder.currentText, "$ATTEMPTS", std::to_string(placeholder.failedAttempts));
|
||||||
|
|
|
@ -39,6 +39,7 @@ class CPasswordInputField : public IWidget {
|
||||||
Vector2D configSize;
|
Vector2D configSize;
|
||||||
|
|
||||||
std::string halign, valign, configFailText, outputStringPort, configPlaceholderText;
|
std::string halign, valign, configFailText, outputStringPort, configPlaceholderText;
|
||||||
|
uint64_t configFailTimeoutMs = 2000;
|
||||||
|
|
||||||
int outThick, rounding;
|
int outThick, rounding;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue