void ChangePasswordDialog::buttonApply_clicked()
{
    // Check passwords
    QString password = ui->textBoxVerifiedPassword->text();
    if ( ui->textBoxPassword->text() != password )
    {
        QMessageBox::warning( this, tr( "Error!" ), tr( "Your passwords do not match!" ), QMessageBox::Ok, QMessageBox::Ok );
        return;
    }

    // Set password
    KAuth::Action installAction( QLatin1String( "org.manjaro.msm.users.changepassword" ) );
    installAction.setHelperId( QLatin1String( "org.manjaro.msm.users" ) );
    QVariantMap args;
    args["arguments"] = QStringList() << username;
    args["writeArgs"] = QStringList() << password << password;
    installAction.setArguments( args );
    KAuth::ExecuteJob* job = installAction.execute();
    connect( job, &KAuth::ExecuteJob::newData,
             [=] ( const QVariantMap &data )
    {
        qDebug() << data;
    } );
    if ( job->exec() )
        qDebug() << "Add User Job Succesfull";
    else
    {
        QMessageBox::warning( this, tr( "Error!" ), QString( tr( "Failed to set user's password!" ) ), QMessageBox::Ok, QMessageBox::Ok );
        close();
        return;
    }
    close();
}
// TODO: Now it ask twice for a password (add user and change password) fix this.
void AddUserDialog::buttonCreate_clicked()
{
    QString errorMessage;
    QString username = ui->textBoxUsername->text();
    QString password = ui->textBoxPassword->text();

    // Check username
    QRegExp rx( "^[a-z][-a-z0-9_]*\\$" );
    QRegExpValidator val( rx );
    int pos = -1;

    if ( val.validate( username, pos ) == QValidator::Invalid )
        errorMessage = tr( "Your username contains invalid characters!" );

    // Check passwords
    if ( password != ui->textBoxVerifiedPassword->text() )
        errorMessage = tr( "Your passwords do not match!" );

    // Show messagebox if error appeared
    if ( !errorMessage.isEmpty() )
    {
        QMessageBox::warning( this, tr( "Error!" ), errorMessage, QMessageBox::Ok, QMessageBox::Ok );
        return;
    }

    dataChanged = true;

    // Add user
    KAuth::Action installActionAdd( QLatin1String( "org.manjaro.msm.users.add" ) );
    installActionAdd.setHelperId( QLatin1String( "org.manjaro.msm.users" ) );
    QVariantMap args;
    QString defaultUserGroups {"video,audio,power,optical,network,lp,scanner,sys"};
    args["arguments"] = QStringList() << "-m" << "-p" << "" << "-U" << "-G" << defaultUserGroups << username;
    installActionAdd.setArguments( args );
    KAuth::ExecuteJob* jobAdd = installActionAdd.execute();
    connect( jobAdd, &KAuth::ExecuteJob::newData,
             [=] ( const QVariantMap &data )
    {
        qDebug() << data;
    } );
    if ( jobAdd->exec() )
        qDebug() << "Add User Job Succesfull";
    else
    {
        QMessageBox::warning( this, tr( "Error!" ), QString( tr( "Failed to add user!" ) + "\n" + errorMessage ), QMessageBox::Ok, QMessageBox::Ok );
        close();
        return;
    }

    // Set password
    KAuth::Action installActionUsersChangePassword( QLatin1String( "org.manjaro.msm.users.changepassword" ) );
    installActionUsersChangePassword.setHelperId( QLatin1String( "org.manjaro.msm.users" ) );
    args.clear();
    args["arguments"] = QStringList() << username;
    args["writeArgs"] = QStringList() << password << password;
    installActionUsersChangePassword.setArguments( args );
    KAuth::ExecuteJob* jobChangePassword = installActionUsersChangePassword.execute();
    connect( jobChangePassword, &KAuth::ExecuteJob::newData,
             [=] ( const QVariantMap &data )
    {
        qDebug() << data;
    } );
    if ( jobChangePassword->exec() )
        qDebug() << "Add User Job Succesfull";
    else
    {
        QMessageBox::warning( this, tr( "Error!" ), QString( tr( "Failed to set user's password!" ) + "\n" + errorMessage ), QMessageBox::Ok, QMessageBox::Ok );
        close();
        return;
    }
    close();
}