summaryrefslogtreecommitdiff
path: root/noncore/settings/usermanager/userdialog.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/usermanager/userdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/usermanager/userdialog.cpp37
1 files changed, 33 insertions, 4 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp
index 6940a3b..c6b8a57 100644
--- a/noncore/settings/usermanager/userdialog.cpp
+++ b/noncore/settings/usermanager/userdialog.cpp
@@ -194,24 +194,34 @@ bool UserDialog::addUser(int uid, int gid) {
adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(),
QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) {
QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user.");
return false;
}
// Add User to additional groups.
QListViewItemIterator it( adduserDialog->groupsListView );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() )
accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text());
}
+ // Copy image to pics/users/
+ if(!(adduserDialog->userImage.isNull())) {
+ QDir d;
+ if(!(d.exists("/opt/QtPalmtop/pics/users"))) {
+ d.mkdir("/opt/QtPalmtop/pics/users");
+ }
+ QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png";
+ adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48);
+ adduserDialog->userImage.save(filename,"PNG");
+ }
return true;
}
/**
* Deletes the user account.
*
* @param username User to be deleted.
*
* @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
*
*/
bool UserDialog::delUser(const char *username) {
@@ -287,39 +297,58 @@ bool UserDialog::editUser(const char *username) {
// Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.)
for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {
accounts->delGroupMember((*it).left((*it).find(":")),username);
}
// Add User to additional groups that he/she is a member of.
QListViewItemIterator it( edituserDialog->groupsListView );
for ( ; it.current(); ++it ) {
if ( it.current()->isSelected() )
accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text());
}
+
+ // Copy image to pics/users/
+ if(!(edituserDialog->userImage.isNull())) {
+ QDir d;
+ if(!(d.exists("/opt/QtPalmtop/pics/users"))) {
+ d.mkdir("/opt/QtPalmtop/pics/users");
+ }
+ QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png";
+ edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48);
+ edituserDialog->userImage.save(filename,"PNG");
+ }
return true;
}
/**
* "OK" has been clicked. Verify some information before closing the dialog.
*
*/
void UserDialog::accept() {
// Add checking... valid username? username taken?
if(loginLineEdit->text().isEmpty()) {
QMessageBox::information(0,"Empty Login","Please enter a login.");
return;
}
QDialog::accept();
}
/**
* This slot is called when the usericon is clicked, this loads (should) the iconselector.
*
*/
void UserDialog::clickedPicture() {
QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics");
- // OFileDialog *fd=new OFileDialog("Select Icon",this, OFileSelector::OPEN, OFileSelector::EXTENDED,"/");
- //fd->showMaximized();
- //fd->exec();
- QMessageBox::information(0,"Sorry!","Icon selection not yet implemented.\nComming real soon now! (tm)\n"+filename);
+ if(!(filename.isEmpty())) {
+ userImage.reset();
+ if(!(userImage.load(filename))) {
+ QMessageBox::information(0,"Sorry!","Icon selection not yet implemented.\nComming real soon now! (tm)\n"+filename);
+ } else {
+ userImage=userImage.smoothScale(48,48);
+ QPixmap *picture;
+ picture=(QPixmap *)picturePushButton->pixmap();
+ picture->convertFromImage(userImage,0);
+ picturePushButton->update();
+ }
+ }
}