From cbab9d6d4c3a38ece9bd97ac866b28c4d83ecc1a Mon Sep 17 00:00:00 2001 From: ewew ukek Date: Sun, 7 Apr 2024 15:51:18 +0000 Subject: Fix for login button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the simpler solution for issue #64 proposed by @bjorn. `logic()` gets called on every tick after input is processed so I removed redundant code from `keyPressed()`. * Update login button in logic() instead of keyPressed() See merge request mana/plus!67 **** Reviewed-by: Thorbjørn Lindeijer --- src/gui/windows/logindialog.cpp | 16 ++++++---------- src/gui/windows/logindialog.h | 2 ++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 3facc7030..96f371660 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -238,6 +238,12 @@ LoginDialog::~LoginDialog() delete2(mUpdateListModel) } +void LoginDialog::logic() +{ + mLoginButton->setEnabled(canSubmit()); + Window::logic(); +} + void LoginDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); @@ -287,12 +293,6 @@ void LoginDialog::action(const ActionEvent &event) void LoginDialog::keyPressed(KeyEvent &event) { - if (event.isConsumed()) - { - mLoginButton->setEnabled(canSubmit()); - return; - } - const InputActionT actionId = event.getActionId(); if (actionId == InputAction::GUI_CANCEL) { @@ -307,10 +307,6 @@ void LoginDialog::keyPressed(KeyEvent &event) { action(ActionEvent(nullptr, mLoginButton->getActionEventId())); } - else - { - mLoginButton->setEnabled(canSubmit()); - } } bool LoginDialog::canSubmit() const diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h index 4b9fc86db..95e394291 100644 --- a/src/gui/windows/logindialog.h +++ b/src/gui/windows/logindialog.h @@ -64,6 +64,8 @@ class LoginDialog final : public Window, void postInit() override final; + void logic() override final; + /** * Called when receiving actions from the widgets. */ -- cgit v1.2.3-70-g09d2