Diffstat (limited to 'noncore/settings/usermanager/userdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index c06f639..19b0e84 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -332,110 +332,110 @@ bool UserDialog::editUser(const char *username) { | |||
332 | } | 332 | } |
333 | } | 333 | } |
334 | if(invalid_group) { | 334 | if(invalid_group) { |
335 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); | 335 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); |
336 | edituserDialog->groupComboBox->setCurrentItem(0); | 336 | edituserDialog->groupComboBox->setCurrentItem(0); |
337 | } | 337 | } |
338 | 338 | ||
339 | // Select the groups in the listview, to which the user belongs. | 339 | // Select the groups in the listview, to which the user belongs. |
340 | QCheckListItem *temp; | 340 | QCheckListItem *temp; |
341 | // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead. | 341 | // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead. |
342 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. | 342 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. |
343 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 343 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
344 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 344 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. |
345 | qWarning(*it); | 345 | qWarning(*it); |
346 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 346 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
347 | for ( ; lvit.current(); ++lvit ) { | 347 | for ( ; lvit.current(); ++lvit ) { |
348 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 348 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { |
349 | temp=(QCheckListItem*)lvit.current(); | 349 | temp=(QCheckListItem*)lvit.current(); |
350 | temp->setOn(true);// If we find a line with that groupname, select it.; | 350 | temp->setOn(true);// If we find a line with that groupname, select it.; |
351 | } | 351 | } |
352 | } | 352 | } |
353 | } | 353 | } |
354 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) | 354 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) |
355 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 355 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
356 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 356 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. |
357 | qWarning(*it); | 357 | qWarning(*it); |
358 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 358 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
359 | for ( ; lvit.current(); ++lvit ) { | 359 | for ( ; lvit.current(); ++lvit ) { |
360 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 360 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { |
361 | temp=(QCheckListItem*)lvit.current(); | 361 | temp=(QCheckListItem*)lvit.current(); |
362 | temp->setOn(true);// If we find a line with that groupname, select it.; | 362 | temp->setOn(true);// If we find a line with that groupname, select it.; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | } | 365 | } |
366 | 366 | ||
367 | if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! | 367 | if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! |
368 | 368 | ||
369 | accounts->findUser(username);// Fill user variables in 'acccounts' object. | 369 | accounts->findUser(username);// Fill user variables in 'acccounts' object. |
370 | accounts->pw_name=edituserDialog->loginLineEdit->text(); | 370 | accounts->pw_name=edituserDialog->loginLineEdit->text(); |
371 | // Has the password been changed ? Make a new "crypt":ed password. | 371 | // Has the password been changed ? Make a new "crypt":ed password. |
372 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); | 372 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); |
373 | 373 | ||
374 | // Set all variables in accounts object, that will be used when calling 'updateUser()' | 374 | // Set all variables in accounts object, that will be used when calling 'updateUser()' |
375 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); | 375 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); |
376 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object. | 376 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object. |
377 | accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. | 377 | accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. |
378 | } | 378 | } |
379 | accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); | 379 | accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); |
380 | accounts->pw_shell=edituserDialog->shellComboBox->currentText(); | 380 | accounts->pw_shell=edituserDialog->shellComboBox->currentText(); |
381 | // Update userinfo, using the information stored in the user variables stored in the accounts object. | 381 | // Update userinfo, using the information stored in the user variables stored in the accounts object. |
382 | accounts->updateUser(username); | 382 | accounts->updateUser(username); |
383 | 383 | ||
384 | // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) | 384 | // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) |
385 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { | 385 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { |
386 | accounts->delGroupMember((*it).left((*it).find(":")),username); | 386 | accounts->delGroupMember((*it).left((*it).find(":")),username); |
387 | } | 387 | } |
388 | 388 | ||
389 | // Add User to additional groups that he/she is a member of. | 389 | // Add User to additional groups that he/she is a member of. |
390 | QListViewItemIterator it( edituserDialog->groupsListView ); | 390 | QListViewItemIterator it( edituserDialog->groupsListView ); |
391 | for ( ; it.current(); ++it ) { | 391 | for ( ; it.current(); ++it ) { |
392 | temp=(QCheckListItem*)it.current(); | 392 | temp=(QCheckListItem*)it.current(); |
393 | if ( temp->isOn() ) | 393 | if ( temp->isOn() ) |
394 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); | 394 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); |
395 | } | 395 | } |
396 | 396 | ||
397 | // Copy image to pics/users/ | 397 | // Copy image to pics/users/ |
398 | if(!(edituserDialog->userImage.isNull())) { | 398 | if(!(edituserDialog->userImage.isNull())) { |
399 | QDir d; | 399 | QDir d; |
400 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 400 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { |
401 | d.mkdir("/opt/QtPalmtop/pics/users"); | 401 | d.mkdir("/opt/QtPalmtop/pics/users"); |
402 | } | 402 | } |
403 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 403 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
404 | // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); | 404 | // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); |
405 | edituserDialog->userImage.save(filename,"PNG"); | 405 | edituserDialog->userImage.save(filename,"PNG"); |
406 | } | 406 | } |
407 | return true; | 407 | return true; |
408 | } | 408 | } |
409 | 409 | ||
410 | /** | 410 | /** |
411 | * "OK" has been clicked. Verify some information before closing the dialog. | 411 | * "OK" has been clicked. Verify some information before closing the dialog. |
412 | * | 412 | * |
413 | */ | 413 | */ |
414 | void UserDialog::accept() { | 414 | void UserDialog::accept() { |
415 | // Add checking... valid username? username taken? | 415 | // Add checking... valid username? username taken? |
416 | if(loginLineEdit->text().isEmpty()) { | 416 | if(loginLineEdit->text().isEmpty()) { |
417 | QMessageBox::information(0,"Empty Login","Please enter a login."); | 417 | QMessageBox::information(0,"Empty Login","Please enter a login."); |
418 | return; | 418 | return; |
419 | } | 419 | } |
420 | QDialog::accept(); | 420 | QDialog::accept(); |
421 | } | 421 | } |
422 | 422 | ||
423 | /** | 423 | /** |
424 | * This slot is called when the usericon is clicked, this loads (should) the iconselector. | 424 | * This slot is called when the usericon is clicked, this loads (should) the iconselector. |
425 | * | 425 | * |
426 | */ | 426 | */ |
427 | void UserDialog::clickedPicture() { | 427 | void UserDialog::clickedPicture() { |
428 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics"); | 428 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); |
429 | if(!(filename.isEmpty())) { | 429 | if(!(filename.isEmpty())) { |
430 | userImage.reset(); | 430 | userImage.reset(); |
431 | if(!(userImage.load(filename))) { | 431 | if(!(userImage.load(filename))) { |
432 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); | 432 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); |
433 | } else { | 433 | } else { |
434 | // userImage=userImage.smoothScale(48,48); | 434 | // userImage=userImage.smoothScale(48,48); |
435 | QPixmap *picture; | 435 | QPixmap *picture; |
436 | picture=(QPixmap *)picturePushButton->pixmap(); | 436 | picture=(QPixmap *)picturePushButton->pixmap(); |
437 | picture->convertFromImage(userImage,0); | 437 | picture->convertFromImage(userImage,0); |
438 | picturePushButton->update(); | 438 | picturePushButton->update(); |
439 | } | 439 | } |
440 | } | 440 | } |
441 | } | 441 | } |