From 3ea796d0099e7d8c00ed097816cebf1f439e5648 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 14 Mar 2021 12:27:53 +0100 Subject: [PATCH] [users] 'undo' changes to values if the UI is wonky - you can still call set*(), eg. from the UI, when the field is not editable. Although the code previously ignored the change, this would lead to a mismatch between what the UI is showing (the changed value) and what the Config has (old value). Emit a changed-signal (notify) with the old value so that the UI is changed *back* as soon as possible. --- src/modules/users/Config.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/modules/users/Config.cpp b/src/modules/users/Config.cpp index 4e02cdcdf..71bd48725 100644 --- a/src/modules/users/Config.cpp +++ b/src/modules/users/Config.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef HAVE_ICU #include @@ -183,7 +184,13 @@ Config::setSudoersGroup( const QString& group ) void Config::setLoginName( const QString& login ) { - if ( login != m_loginName && isEditable( QStringLiteral( "loginName" ) ) ) + if ( !isEditable( QStringLiteral( "loginName" ) ) ) + { + // Should not have arrived here anyway + QTimer::singleShot( 0, this, [=]() { emit loginNameChanged( m_loginName ); } ); + return; + } + if ( login != m_loginName ) { m_customLoginName = !login.isEmpty(); m_loginName = login; @@ -395,6 +402,8 @@ Config::setFullName( const QString& name ) { if ( !isEditable( QStringLiteral( "fullName" ) ) ) { + // Should not have arrived here anyway + QTimer::singleShot( 0, this, [=]() { emit fullNameChanged( m_fullName ); } ); return; }