-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 19 | ||||
-rw-r--r-- | noncore/settings/usermanager/usermanager.cpp | 19 | ||||
-rw-r--r-- | noncore/settings/usermanager/usermanager.h | 4 |
3 files changed, 24 insertions, 18 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index 719dd1e..b7827a4 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -154,9 +154,9 @@ void UserDialog::setupTab2() { | |||
154 | // Additional groups | 154 | // Additional groups |
155 | groupsListView=new QListView(tabpage,"groups"); | 155 | groupsListView=new QListView(tabpage,"groups"); |
156 | groupsListView->addColumn("Additional groups"); | 156 | groupsListView->addColumn("Additional groups"); |
157 | groupsListView->setColumnWidthMode(0,QListView::Maximum); | 157 | groupsListView->setColumnWidthMode(0,QListView::Maximum); |
158 | groupsListView->setMultiSelection(true); | 158 | groupsListView->setMultiSelection(false); |
159 | groupsListView->setAllColumnsShowFocus(false); | 159 | groupsListView->setAllColumnsShowFocus(false); |
160 | 160 | ||
161 | layout->addSpacing(5); | 161 | layout->addSpacing(5); |
162 | // Grouplist | 162 | // Grouplist |
@@ -197,11 +197,13 @@ bool UserDialog::addUser(int uid, int gid) { | |||
197 | return false; | 197 | return false; |
198 | } | 198 | } |
199 | 199 | ||
200 | // Add User to additional groups. | 200 | // Add User to additional groups. |
201 | QCheckListItem *temp; | ||
201 | QListViewItemIterator it( adduserDialog->groupsListView ); | 202 | QListViewItemIterator it( adduserDialog->groupsListView ); |
202 | for ( ; it.current(); ++it ) { | 203 | for ( ; it.current(); ++it ) { |
203 | if ( it.current()->isSelected() ) | 204 | temp=(QCheckListItem*)it.current(); |
205 | if (temp->isOn() ) | ||
204 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); | 206 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); |
205 | } | 207 | } |
206 | // Copy image to pics/users/ | 208 | // Copy image to pics/users/ |
207 | if(!(adduserDialog->userImage.isNull())) { | 209 | if(!(adduserDialog->userImage.isNull())) { |
@@ -209,9 +211,9 @@ bool UserDialog::addUser(int uid, int gid) { | |||
209 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 211 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { |
210 | d.mkdir("/opt/QtPalmtop/pics/users"); | 212 | d.mkdir("/opt/QtPalmtop/pics/users"); |
211 | } | 213 | } |
212 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 214 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
213 | adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); | 215 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); |
214 | adduserDialog->userImage.save(filename,"PNG"); | 216 | adduserDialog->userImage.save(filename,"PNG"); |
215 | } | 217 | } |
216 | return true; | 218 | return true; |
217 | } | 219 | } |
@@ -267,15 +269,17 @@ bool UserDialog::editUser(const char *username) { | |||
267 | edituserDialog->groupComboBox->setCurrentItem(i); | 269 | edituserDialog->groupComboBox->setCurrentItem(i); |
268 | } | 270 | } |
269 | } | 271 | } |
270 | // Select the groups in the listview, to which the user belongs. | 272 | // Select the groups in the listview, to which the user belongs. |
273 | QCheckListItem *temp; | ||
271 | QRegExp userRegExp(QString("[:\\s]%1\\s").arg(username)); | 274 | QRegExp userRegExp(QString("[:\\s]%1\\s").arg(username)); |
272 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 275 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
273 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 276 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. |
274 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 277 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
275 | for ( ; lvit.current(); ++lvit ) { | 278 | for ( ; lvit.current(); ++lvit ) { |
276 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 279 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { |
277 | lvit.current()->setSelected(true);// If we find a line with that groupname, select it.; | 280 | temp=(QCheckListItem*)lvit.current(); |
281 | temp->setOn(true);// If we find a line with that groupname, select it.; | ||
278 | } | 282 | } |
279 | } | 283 | } |
280 | } | 284 | } |
281 | 285 | ||
@@ -302,9 +306,10 @@ bool UserDialog::editUser(const char *username) { | |||
302 | 306 | ||
303 | // Add User to additional groups that he/she is a member of. | 307 | // Add User to additional groups that he/she is a member of. |
304 | QListViewItemIterator it( edituserDialog->groupsListView ); | 308 | QListViewItemIterator it( edituserDialog->groupsListView ); |
305 | for ( ; it.current(); ++it ) { | 309 | for ( ; it.current(); ++it ) { |
306 | if ( it.current()->isSelected() ) | 310 | temp=(QCheckListItem*)it.current(); |
311 | if ( temp->isOn() ) | ||
307 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); | 312 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); |
308 | } | 313 | } |
309 | 314 | ||
310 | // Copy image to pics/users/ | 315 | // Copy image to pics/users/ |
@@ -313,9 +318,9 @@ bool UserDialog::editUser(const char *username) { | |||
313 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 318 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { |
314 | d.mkdir("/opt/QtPalmtop/pics/users"); | 319 | d.mkdir("/opt/QtPalmtop/pics/users"); |
315 | } | 320 | } |
316 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 321 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
317 | edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); | 322 | // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); |
318 | edituserDialog->userImage.save(filename,"PNG"); | 323 | edituserDialog->userImage.save(filename,"PNG"); |
319 | } | 324 | } |
320 | return true; | 325 | return true; |
321 | } | 326 | } |
@@ -343,9 +348,9 @@ void UserDialog::clickedPicture() { | |||
343 | userImage.reset(); | 348 | userImage.reset(); |
344 | if(!(userImage.load(filename))) { | 349 | if(!(userImage.load(filename))) { |
345 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); | 350 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); |
346 | } else { | 351 | } else { |
347 | userImage=userImage.smoothScale(48,48); | 352 | // userImage=userImage.smoothScale(48,48); |
348 | QPixmap *picture; | 353 | QPixmap *picture; |
349 | picture=(QPixmap *)picturePushButton->pixmap(); | 354 | picture=(QPixmap *)picturePushButton->pixmap(); |
350 | picture->convertFromImage(userImage,0); | 355 | picture->convertFromImage(userImage,0); |
351 | picturePushButton->update(); | 356 | picturePushButton->update(); |
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp index ed18b7f..2735e6a 100644 --- a/noncore/settings/usermanager/usermanager.cpp +++ b/noncore/settings/usermanager/usermanager.cpp | |||
@@ -70,11 +70,12 @@ void UserConfig::setupTabAccounts() { | |||
70 | QWidget *tabpage = new QWidget(this); | 70 | QWidget *tabpage = new QWidget(this); |
71 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 71 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
72 | layout->setMargin(5); | 72 | layout->setMargin(5); |
73 | 73 | ||
74 | usersIconView=new QIconView(tabpage,"users"); | 74 | usersIconView=new QListView(tabpage,"users"); |
75 | usersIconView->setItemTextPos(QIconView::Right); | 75 | usersIconView->addColumn("Icon"); |
76 | usersIconView->setArrangement(QIconView::LeftToRight); | 76 | usersIconView->addColumn("Username"); |
77 | usersIconView->setAllColumnsShowFocus(true); | ||
77 | layout->addWidget(usersIconView); | 78 | layout->addWidget(usersIconView); |
78 | 79 | ||
79 | myTabWidget->addTab(tabpage,"Users"); | 80 | myTabWidget->addTab(tabpage,"Users"); |
80 | } | 81 | } |
@@ -111,8 +112,9 @@ void UserConfig::setupTabAllGroups() { | |||
111 | } | 112 | } |
112 | void UserConfig::getUsers() { | 113 | void UserConfig::getUsers() { |
113 | QString mytext; | 114 | QString mytext; |
114 | QPixmap mypixmap; | 115 | QPixmap mypixmap; |
116 | QListViewItem *listviewitem; | ||
115 | 117 | ||
116 | // Empty the iconview & the listview. | 118 | // Empty the iconview & the listview. |
117 | usersIconView->clear(); | 119 | usersIconView->clear(); |
118 | usersListView->clear(); | 120 | usersListView->clear(); |
@@ -123,14 +125,13 @@ void UserConfig::getUsers() { | |||
123 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) | 125 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) |
124 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); | 126 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); |
125 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? | 127 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? |
126 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. | 128 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. |
127 | // mypixmap=Resource::loadPixmap(QString("users/"+accounts->pw_name));// Is there an icon for this user? Resource::loadPixmap is caching, doesn't work. | 129 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work. |
128 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { | ||
129 | // if(mypixmap.isNull()) { | ||
130 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. | 130 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. |
131 | } | 131 | } |
132 | new QIconViewItem(usersIconView,mytext,mypixmap);// Add the icon+text to the qiconview. | 132 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. |
133 | listviewitem->setPixmap(0,mypixmap); | ||
133 | } | 134 | } |
134 | 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. | 135 | 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. |
135 | } | 136 | } |
136 | usersIconView->sort(); | 137 | usersIconView->sort(); |
@@ -146,9 +147,9 @@ void UserConfig::addUser() { | |||
146 | void UserConfig::editUser() { | 147 | void UserConfig::editUser() { |
147 | QString username; | 148 | QString username; |
148 | if(myTabWidget->currentPageIndex()==0) {// Users | 149 | if(myTabWidget->currentPageIndex()==0) {// Users |
149 | if(usersIconView->currentItem()) {// Any icon selected? | 150 | if(usersIconView->currentItem()) {// Any icon selected? |
150 | username=usersIconView->currentItem()->text();// Get the text associated with the icon. | 151 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. |
151 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 152 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
152 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 153 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
153 | // If there were any changed also update the views. | 154 | // If there were any changed also update the views. |
154 | getUsers(); | 155 | getUsers(); |
@@ -176,9 +177,9 @@ void UserConfig::delUser() { | |||
176 | QString username; | 177 | QString username; |
177 | 178 | ||
178 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. | 179 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. |
179 | if(usersIconView->currentItem()) {// Anything selected? | 180 | if(usersIconView->currentItem()) {// Anything selected? |
180 | username=usersIconView->currentItem()->text();// Get string associated with icon. | 181 | username=usersIconView->currentItem()->text(1);// Get string associated with icon. |
181 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 182 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
182 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { | 183 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { |
183 | if(UserDialog::delUser(username)) {// Delete the user if possible. | 184 | if(UserDialog::delUser(username)) {// Delete the user if possible. |
184 | // Update views. | 185 | // Update views. |
diff --git a/noncore/settings/usermanager/usermanager.h b/noncore/settings/usermanager/usermanager.h index bb5d04f..9909242 100644 --- a/noncore/settings/usermanager/usermanager.h +++ b/noncore/settings/usermanager/usermanager.h | |||
@@ -12,9 +12,9 @@ | |||
12 | 12 | ||
13 | #include <qmainwindow.h> | 13 | #include <qmainwindow.h> |
14 | #include <qtabwidget.h> | 14 | #include <qtabwidget.h> |
15 | #include <qlistview.h> | 15 | #include <qlistview.h> |
16 | #include <qiconview.h> | 16 | //#include <qiconview.h> |
17 | 17 | ||
18 | #include <qpe/qpemenubar.h> | 18 | #include <qpe/qpemenubar.h> |
19 | #include <qpopupmenu.h> | 19 | #include <qpopupmenu.h> |
20 | #include <qpe/qpetoolbar.h> | 20 | #include <qpe/qpetoolbar.h> |
@@ -39,9 +39,9 @@ private: | |||
39 | QToolButton *addgroupToolButton; | 39 | QToolButton *addgroupToolButton; |
40 | QToolButton *editgroupToolButton; | 40 | QToolButton *editgroupToolButton; |
41 | QToolButton *deletegroupToolButton; | 41 | QToolButton *deletegroupToolButton; |
42 | QTabWidget *myTabWidget; | 42 | QTabWidget *myTabWidget; |
43 | QIconView *usersIconView; | 43 | QListView *usersIconView; |
44 | QListView *usersListView; | 44 | QListView *usersListView; |
45 | QListView *groupsListView; | 45 | QListView *groupsListView; |
46 | int availableUID; | 46 | int availableUID; |
47 | int availableGID; | 47 | int availableGID; |