[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.
main
Adriaan de Groot 4 years ago
parent 9fcf9b5fa8
commit 3ea796d009

@ -23,6 +23,7 @@
#include <QCoreApplication>
#include <QFile>
#include <QRegExp>
#include <QTimer>
#ifdef HAVE_ICU
#include <unicode/translit.h>
@ -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;
}

Loading…
Cancel
Save