summaryrefslogtreecommitdiff
path: root/noncore/settings/usermanager
authorumopapisdn <umopapisdn>2002-09-28 22:28:39 (UTC)
committer umopapisdn <umopapisdn>2002-09-28 22:28:39 (UTC)
commitaa347496d408431d85ff2d7a2cf60479407620af (patch) (side-by-side diff)
tree64e7fed8efd41d2c4b3bdf26c863a5486ee0ede3 /noncore/settings/usermanager
parent7980189a2cb34e2864c339ef68bfbe7fb4910750 (diff)
downloadopie-aa347496d408431d85ff2d7a2cf60479407620af.zip
opie-aa347496d408431d85ff2d7a2cf60479407620af.tar.gz
opie-aa347496d408431d85ff2d7a2cf60479407620af.tar.bz2
*** empty log message ***
Diffstat (limited to 'noncore/settings/usermanager') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/usermanager/userdialog.cpp35
-rw-r--r--noncore/settings/usermanager/userdialog.h1
-rw-r--r--noncore/settings/usermanager/usermanager.cpp7
3 files changed, 38 insertions, 5 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
@@ -200,12 +200,22 @@ bool UserDialog::addUser(int uid, int gid) {
// 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.
*
@@ -293,12 +303,23 @@ bool UserDialog::editUser(const char *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.
*
@@ -315,11 +336,19 @@ void UserDialog::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();
+ 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();
+ }
+ }
}
diff --git a/noncore/settings/usermanager/userdialog.h b/noncore/settings/usermanager/userdialog.h
index df54269..a878588 100644
--- a/noncore/settings/usermanager/userdialog.h
+++ b/noncore/settings/usermanager/userdialog.h
@@ -33,12 +33,13 @@ private:
QComboBox *shellComboBox;
QComboBox *groupComboBox;
QListView *groupsListView;
QStringList groupMembers;
QString pictureLocation;
+ QImage userImage;
int groupID;
int userID;
void setupTab1(void);
void setupTab2(void);
void accept(void);
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp
index 87dd7f1..ed18b7f 100644
--- a/noncore/settings/usermanager/usermanager.cpp
+++ b/noncore/settings/usermanager/usermanager.cpp
@@ -70,12 +70,13 @@ void UserConfig::setupTabAccounts() {
QWidget *tabpage = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(tabpage);
layout->setMargin(5);
usersIconView=new QIconView(tabpage,"users");
usersIconView->setItemTextPos(QIconView::Right);
+ usersIconView->setArrangement(QIconView::LeftToRight);
layout->addWidget(usersIconView);
myTabWidget->addTab(tabpage,"Users");
}
void UserConfig::setupTabAllUsers() {
@@ -120,20 +121,22 @@ void UserConfig::getUsers() {
availableUID=500;
for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) {
accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.)
new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos);
if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) { // Is this user a "normal" user ?
mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon.
- mypixmap=Resource::loadPixmap(QString("users/"+accounts->pw_name)); // Is there an icon for this user?
- if(mypixmap.isNull()) {
+// mypixmap=Resource::loadPixmap(QString("users/"+accounts->pw_name)); // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work.
+ if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) {
+// if(mypixmap.isNull()) {
mypixmap=Resource::loadPixmap(QString("usermanager/usericon")); // If this user has no icon, load the default icon.
}
new QIconViewItem(usersIconView,mytext,mypixmap); // Add the icon+text to the qiconview.
}
if((accounts->pw_uid>=availableUID) && (accounts->pw_uid<65000)) availableUID=accounts->pw_uid+1; // Increase 1 to the latest know UID to get a free uid.
}
+ usersIconView->sort();
}
void UserConfig::addUser() {
if(UserDialog::addUser(availableUID,availableGID)) { // Add the user to the system, also send next available UID and GID.
getUsers(); // Update users views.
getGroups(); // Update groups view.