summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2002-09-29 19:17:07 (UTC)
committer umopapisdn <umopapisdn>2002-09-29 19:17:07 (UTC)
commitd61d575feac628fe4afb3cc9bf4fc8f24fc8616a (patch) (unidiff)
tree147ded7eb7f3cc2b42bd6b731b93b5c9a108d9ad
parent84a7530b51f537552ea03776c9d8ade88254dc51 (diff)
downloadopie-d61d575feac628fe4afb3cc9bf4fc8f24fc8616a.zip
opie-d61d575feac628fe4afb3cc9bf4fc8f24fc8616a.tar.gz
opie-d61d575feac628fe4afb3cc9bf4fc8f24fc8616a.tar.bz2
Icon selection now works. User listing lists 1 user per row now. (moved from qiconlist to qlistview)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/usermanager/userdialog.cpp19
-rw-r--r--noncore/settings/usermanager/usermanager.cpp21
-rw-r--r--noncore/settings/usermanager/usermanager.h4
3 files changed, 25 insertions, 19 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
@@ -126,229 +126,234 @@ void UserDialog::setupTab1() {
126 vlayout1->addWidget(groupLabel); 126 vlayout1->addWidget(groupLabel);
127 // Second column, data 127 // Second column, data
128 vlayout2->addWidget(loginLineEdit); 128 vlayout2->addWidget(loginLineEdit);
129 vlayout2->addSpacing(5); 129 vlayout2->addSpacing(5);
130 vlayout2->addWidget(uidLineEdit); 130 vlayout2->addWidget(uidLineEdit);
131 vlayout2->addSpacing(5); 131 vlayout2->addSpacing(5);
132 vlayout2->addWidget(gecosLineEdit); 132 vlayout2->addWidget(gecosLineEdit);
133 vlayout2->addSpacing(5); 133 vlayout2->addSpacing(5);
134 vlayout2->addWidget(passwordLineEdit); 134 vlayout2->addWidget(passwordLineEdit);
135 vlayout2->addSpacing(5); 135 vlayout2->addSpacing(5);
136 vlayout2->addWidget(shellComboBox); 136 vlayout2->addWidget(shellComboBox);
137 vlayout2->addSpacing(5); 137 vlayout2->addSpacing(5);
138 vlayout2->addWidget(groupComboBox); 138 vlayout2->addWidget(groupComboBox);
139 hlayout->addLayout(vlayout1); 139 hlayout->addLayout(vlayout1);
140 hlayout->addLayout(vlayout2); 140 hlayout->addLayout(vlayout2);
141 141
142 myTabWidget->addTab(tabpage,"User Info"); 142 myTabWidget->addTab(tabpage,"User Info");
143} 143}
144 144
145/** 145/**
146 * Creates the second tab containing additional groups for the user. 146 * Creates the second tab containing additional groups for the user.
147 * 147 *
148 */ 148 */
149void UserDialog::setupTab2() { 149void UserDialog::setupTab2() {
150 QWidget *tabpage = new QWidget(myTabWidget,"page2"); 150 QWidget *tabpage = new QWidget(myTabWidget,"page2");
151 QVBoxLayout *layout = new QVBoxLayout(tabpage); 151 QVBoxLayout *layout = new QVBoxLayout(tabpage);
152 layout->setMargin(5); 152 layout->setMargin(5);
153 153
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
163 layout->addWidget(groupsListView); 163 layout->addWidget(groupsListView);
164 164
165 myTabWidget->addTab(tabpage,"User Groups"); 165 myTabWidget->addTab(tabpage,"User Groups");
166} 166}
167 167
168/** 168/**
169 * Static function that creates the userinfo dialog. 169 * Static function that creates the userinfo dialog.
170 * The user will be prompted to add a user. 170 * The user will be prompted to add a user.
171 * 171 *
172 * @param uid This is a suggested available UID. 172 * @param uid This is a suggested available UID.
173 * @param gid This is a suggested available GID. 173 * @param gid This is a suggested available GID.
174 * 174 *
175 * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. 175 * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>.
176 * 176 *
177 */ 177 */
178bool UserDialog::addUser(int uid, int gid) { 178bool UserDialog::addUser(int uid, int gid) {
179 UserDialog *adduserDialog=new UserDialog(); 179 UserDialog *adduserDialog=new UserDialog();
180 adduserDialog->setCaption(tr("Add User")); 180 adduserDialog->setCaption(tr("Add User"));
181 adduserDialog->userID=uid;// Set next available UID as default uid. 181 adduserDialog->userID=uid;// Set next available UID as default uid.
182 adduserDialog->groupID=gid;// Set next available GID as default gid. 182 adduserDialog->groupID=gid;// Set next available GID as default gid.
183 // Insert default group into groupComboBox 183 // Insert default group into groupComboBox
184 adduserDialog->groupComboBox->insertItem("<create new group>",0); 184 adduserDialog->groupComboBox->insertItem("<create new group>",0);
185 adduserDialog->uidLineEdit->setText(QString::number(uid)); 185 adduserDialog->uidLineEdit->setText(QString::number(uid));
186 // Show the dialog! 186 // Show the dialog!
187 if(!(adduserDialog->exec())) return false; 187 if(!(adduserDialog->exec())) return false;
188 if((adduserDialog->groupComboBox->currentItem()!=0)) { 188 if((adduserDialog->groupComboBox->currentItem()!=0)) {
189 accounts->findGroup(adduserDialog->groupComboBox->currentText()); 189 accounts->findGroup(adduserDialog->groupComboBox->currentText());
190 adduserDialog->groupID=accounts->gr_gid; 190 adduserDialog->groupID=accounts->gr_gid;
191 qWarning(QString::number(accounts->gr_gid)); 191 qWarning(QString::number(accounts->gr_gid));
192 } 192 }
193 if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), 193 if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(),
194 adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), 194 adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(),
195 QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { 195 QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) {
196 QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); 196 QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user.");
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())) {
208 QDir d; 210 QDir d;
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}
218 220
219/** 221/**
220 * Deletes the user account. 222 * Deletes the user account.
221 * 223 *
222 * @param username User to be deleted. 224 * @param username User to be deleted.
223 * 225 *
224 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 226 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
225 * 227 *
226 */ 228 */
227bool UserDialog::delUser(const char *username) { 229bool UserDialog::delUser(const char *username) {
228 if((accounts->findUser(username))) {// Does that user exist? 230 if((accounts->findUser(username))) {// Does that user exist?
229 if(!(accounts->delUser(username))) {// Delete the user. 231 if(!(accounts->delUser(username))) {// Delete the user.
230 QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); 232 QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+".");
231 } 233 }
232 } else { 234 } else {
233 QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); 235 QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist.");
234 return false; 236 return false;
235 } 237 }
236 return true; 238 return true;
237} 239}
238 240
239/** 241/**
240 * This displays a confirmation dialog wether a user should be deleted or not. 242 * This displays a confirmation dialog wether a user should be deleted or not.
241 * (And also deletes the account) 243 * (And also deletes the account)
242 * 244 *
243 * @param username User to be deleted. 245 * @param username User to be deleted.
244 * 246 *
245 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. 247 * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
246 * 248 *
247 */ 249 */
248bool UserDialog::editUser(const char *username) { 250bool UserDialog::editUser(const char *username) {
249 UserDialog *edituserDialog=new UserDialog();// Create Dialog 251 UserDialog *edituserDialog=new UserDialog();// Create Dialog
250 edituserDialog->setCaption(tr("Edit User")); 252 edituserDialog->setCaption(tr("Edit User"));
251 accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. 253 accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object.
252 accounts->findGroup(accounts->pw_gid);// Locate the user's primary group, and fill group variables in 'accounts' object. 254 accounts->findGroup(accounts->pw_gid);// Locate the user's primary group, and fill group variables in 'accounts' object.
253 // Fill widgets with userinfo. 255 // Fill widgets with userinfo.
254 edituserDialog->loginLineEdit->setText(accounts->pw_name); 256 edituserDialog->loginLineEdit->setText(accounts->pw_name);
255 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); 257 edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid));
256 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); 258 edituserDialog->gecosLineEdit->setText(accounts->pw_gecos);
257 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. 259 // Set password to '........', we will later check if this still is the contents, if not, the password has been changed.
258 edituserDialog->passwordLineEdit->setText("........"); 260 edituserDialog->passwordLineEdit->setText("........");
259 // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. 261 // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox.
260 if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { 262 if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") {
261 edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); 263 edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0);
262 edituserDialog->shellComboBox->setCurrentItem(0); 264 edituserDialog->shellComboBox->setCurrentItem(0);
263 } 265 }
264 // Select the primary group for this user. 266 // Select the primary group for this user.
265 for(int i=0;i<edituserDialog->groupComboBox->count();++i) { 267 for(int i=0;i<edituserDialog->groupComboBox->count();++i) {
266 if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { 268 if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) {
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
282 if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! 286 if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG!
283 287
284 accounts->findUser(username);// Fill user variables in 'acccounts' object. 288 accounts->findUser(username);// Fill user variables in 'acccounts' object.
285 accounts->pw_name=edituserDialog->loginLineEdit->text(); 289 accounts->pw_name=edituserDialog->loginLineEdit->text();
286 // Has the password been changed ? Make a new "crypt":ed password. 290 // Has the password been changed ? Make a new "crypt":ed password.
287 if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); 291 if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt());
288 292
289 // Set all variables in accounts object, that will be used when calling 'updateUser()' 293 // Set all variables in accounts object, that will be used when calling 'updateUser()'
290 accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); 294 accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt();
291 accounts->findGroup(edituserDialog->groupComboBox->currentText());// Fill all group variables in 'accounts' object. 295 accounts->findGroup(edituserDialog->groupComboBox->currentText());// Fill all group variables in 'accounts' object.
292 accounts->pw_gid=accounts->gr_gid; 296 accounts->pw_gid=accounts->gr_gid;
293 accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); 297 accounts->pw_gecos=edituserDialog->gecosLineEdit->text();
294 accounts->pw_shell=edituserDialog->shellComboBox->currentText(); 298 accounts->pw_shell=edituserDialog->shellComboBox->currentText();
295 // Update userinfo, using the information stored in the user variables stored in the accounts object. 299 // Update userinfo, using the information stored in the user variables stored in the accounts object.
296 accounts->updateUser(username); 300 accounts->updateUser(username);
297 301
298 // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) 302 // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.)
299 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { 303 for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {
300 accounts->delGroupMember((*it).left((*it).find(":")),username); 304 accounts->delGroupMember((*it).left((*it).find(":")),username);
301 } 305 }
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/
311 if(!(edituserDialog->userImage.isNull())) { 316 if(!(edituserDialog->userImage.isNull())) {
312 QDir d; 317 QDir d;
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}
322 327
323/** 328/**
324 * "OK" has been clicked. Verify some information before closing the dialog. 329 * "OK" has been clicked. Verify some information before closing the dialog.
325 * 330 *
326 */ 331 */
327void UserDialog::accept() { 332void UserDialog::accept() {
328 // Add checking... valid username? username taken? 333 // Add checking... valid username? username taken?
329 if(loginLineEdit->text().isEmpty()) { 334 if(loginLineEdit->text().isEmpty()) {
330 QMessageBox::information(0,"Empty Login","Please enter a login."); 335 QMessageBox::information(0,"Empty Login","Please enter a login.");
331 return; 336 return;
332 } 337 }
333 QDialog::accept(); 338 QDialog::accept();
334} 339}
335 340
336/** 341/**
337 * This slot is called when the usericon is clicked, this loads (should) the iconselector. 342 * This slot is called when the usericon is clicked, this loads (should) the iconselector.
338 * 343 *
339 */ 344 */
340void UserDialog::clickedPicture() { 345void UserDialog::clickedPicture() {
341 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics"); 346 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics");
342 if(!(filename.isEmpty())) { 347 if(!(filename.isEmpty())) {
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();
352 } 357 }
353 } 358 }
354} 359}
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
@@ -42,171 +42,172 @@ UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWind
42 QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); 42 QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User");
43 userstext->setUsesTextLabel(true); 43 userstext->setUsesTextLabel(true);
44 toolbar->addSeparator(); 44 toolbar->addSeparator();
45 addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); 45 addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group");
46 editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); 46 editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group");
47 deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); 47 deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group");
48 QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); 48 QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group");
49 groupstext->setUsesTextLabel(true); 49 groupstext->setUsesTextLabel(true);
50 addToolBar(toolbar,"myToolBar"); 50 addToolBar(toolbar,"myToolBar");
51 51
52 // Add a tabwidget and all the tabs. 52 // Add a tabwidget and all the tabs.
53 myTabWidget = new QTabWidget(this,"My Tab Widget"); 53 myTabWidget = new QTabWidget(this,"My Tab Widget");
54 setupTabAccounts(); 54 setupTabAccounts();
55 setupTabAllUsers(); 55 setupTabAllUsers();
56 setupTabAllGroups(); 56 setupTabAllGroups();
57 57
58 getUsers(); // Fill out the iconview & listview with all users. 58 getUsers(); // Fill out the iconview & listview with all users.
59 getGroups(); // Fill out the group listview with all groups. 59 getGroups(); // Fill out the group listview with all groups.
60 60
61 setCentralWidget(myTabWidget); 61 setCentralWidget(myTabWidget);
62} 62}
63 63
64UserConfig::~UserConfig() { 64UserConfig::~UserConfig() {
65 accounts->close(); 65 accounts->close();
66 delete accounts; 66 delete accounts;
67} 67}
68 68
69void UserConfig::setupTabAccounts() { 69void 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}
81 82
82void UserConfig::setupTabAllUsers() { 83void UserConfig::setupTabAllUsers() {
83 QWidget *tabpage = new QWidget(this); 84 QWidget *tabpage = new QWidget(this);
84 QVBoxLayout *layout = new QVBoxLayout(tabpage); 85 QVBoxLayout *layout = new QVBoxLayout(tabpage);
85 layout->setMargin(5); 86 layout->setMargin(5);
86 87
87 usersListView=new QListView(tabpage,"allusers"); 88 usersListView=new QListView(tabpage,"allusers");
88 usersListView->addColumn("UID"); 89 usersListView->addColumn("UID");
89 usersListView->addColumn("Login"); 90 usersListView->addColumn("Login");
90 usersListView->addColumn("Username"); 91 usersListView->addColumn("Username");
91 layout->addWidget(usersListView); 92 layout->addWidget(usersListView);
92 usersListView->setSorting(1,1); 93 usersListView->setSorting(1,1);
93 usersListView->setAllColumnsShowFocus(true); 94 usersListView->setAllColumnsShowFocus(true);
94 95
95 myTabWidget->addTab(tabpage,"All Users"); 96 myTabWidget->addTab(tabpage,"All Users");
96} 97}
97 98
98void UserConfig::setupTabAllGroups() { 99void UserConfig::setupTabAllGroups() {
99 QWidget *tabpage = new QWidget(this); 100 QWidget *tabpage = new QWidget(this);
100 QVBoxLayout *layout = new QVBoxLayout(tabpage); 101 QVBoxLayout *layout = new QVBoxLayout(tabpage);
101 layout->setMargin(5); 102 layout->setMargin(5);
102 103
103 groupsListView=new QListView(tabpage,"groups"); 104 groupsListView=new QListView(tabpage,"groups");
104 groupsListView->addColumn("GID"); 105 groupsListView->addColumn("GID");
105 groupsListView->addColumn("Groupname"); 106 groupsListView->addColumn("Groupname");
106 layout->addWidget(groupsListView); 107 layout->addWidget(groupsListView);
107 groupsListView->setSorting(1,1); 108 groupsListView->setSorting(1,1);
108 groupsListView->setAllColumnsShowFocus(true); 109 groupsListView->setAllColumnsShowFocus(true);
109 110
110 myTabWidget->addTab(tabpage,"All Groups"); 111 myTabWidget->addTab(tabpage,"All Groups");
111} 112}
112void UserConfig::getUsers() { 113void UserConfig::getUsers() {
113 QString mytext; 114 QString mytext;
114 QPixmap mypixmap; 115 QPixmap mypixmap;
115 116 QListViewItem *listviewitem;
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();
119 121
120 // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. 122 // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500.
121 availableUID=500; 123 availableUID=500;
122 for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { 124 for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) {
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();
137} 138}
138 139
139void UserConfig::addUser() { 140void UserConfig::addUser() {
140 if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. 141 if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID.
141 getUsers(); // Update users views. 142 getUsers(); // Update users views.
142 getGroups(); // Update groups view. 143 getGroups(); // Update groups view.
143 } 144 }
144} 145}
145 146
146void UserConfig::editUser() { 147void 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();
155 getGroups(); 156 getGroups();
156 } 157 }
157 } else { 158 } else {
158 QMessageBox::information(this,"No selection.","No user has been selected."); 159 QMessageBox::information(this,"No selection.","No user has been selected.");
159 } 160 }
160 } 161 }
161 if(myTabWidget->currentPageIndex()==1) {// All users 162 if(myTabWidget->currentPageIndex()==1) {// All users
162 if(usersListView->currentItem()) {// Anything changed!? 163 if(usersListView->currentItem()) {// Anything changed!?
163 username=usersListView->currentItem()->text(1);// Get the username. 164 username=usersListView->currentItem()->text(1);// Get the username.
164 if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. 165 if(UserDialog::editUser(username)) {// Bring up the userinfo dialog.
165 // And again update the views if there were any changes. 166 // And again update the views if there were any changes.
166 getUsers(); 167 getUsers();
167 getGroups(); 168 getGroups();
168 } 169 }
169 } else { 170 } else {
170 QMessageBox::information(this,"No selection.","No user has been selected."); 171 QMessageBox::information(this,"No selection.","No user has been selected.");
171 } 172 }
172 } 173 }
173} 174}
174 175
175void UserConfig::delUser() { 176void 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.
185 getUsers(); 186 getUsers();
186 getGroups(); 187 getGroups();
187 } 188 }
188 } 189 }
189 } else { 190 } else {
190 QMessageBox::information(this,"No selection","No user has been selected."); 191 QMessageBox::information(this,"No selection","No user has been selected.");
191 } 192 }
192 } 193 }
193 if(myTabWidget->currentPageIndex()==1) {// All users 194 if(myTabWidget->currentPageIndex()==1) {// All users
194 if(usersListView->currentItem()) {// Anything changed!? 195 if(usersListView->currentItem()) {// Anything changed!?
195 username=usersListView->currentItem()->text(1);// Get the username. 196 username=usersListView->currentItem()->text(1);// Get the username.
196 if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { 197 if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) {
197 if(UserDialog::delUser(username)) {// Try to delete the user. 198 if(UserDialog::delUser(username)) {// Try to delete the user.
198 // Update views. 199 // Update views.
199 getUsers(); 200 getUsers();
200 getGroups(); 201 getGroups();
201 } 202 }
202 } 203 }
203 } else { 204 } else {
204 QMessageBox::information(this,"No selection","No user has been selected."); 205 QMessageBox::information(this,"No selection","No user has been selected.");
205 } 206 }
206 } 207 }
207 208
208} 209}
209 210
210void UserConfig::getGroups() { 211void UserConfig::getGroups() {
211 groupsListView->clear();// Empty the listview. 212 groupsListView->clear();// Empty the listview.
212 availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. 213 availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000.
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
@@ -1,65 +1,65 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10#ifndef USERCONFIG_H 10#ifndef USERCONFIG_H
11#define USERCONFIG_H 11#define USERCONFIG_H
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>
21#include <qtoolbutton.h> 21#include <qtoolbutton.h>
22 22
23#include "userdialog.h" 23#include "userdialog.h"
24#include "groupdialog.h" 24#include "groupdialog.h"
25#include "passwd.h" 25#include "passwd.h"
26 26
27class UserConfig : public QMainWindow 27class UserConfig : public QMainWindow
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30 30
31public: 31public:
32 UserConfig( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 32 UserConfig( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
33 ~UserConfig(); 33 ~UserConfig();
34 34
35private: 35private:
36 QToolButton *adduserToolButton; 36 QToolButton *adduserToolButton;
37 QToolButton *edituserToolButton; 37 QToolButton *edituserToolButton;
38 QToolButton *deleteuserToolButton; 38 QToolButton *deleteuserToolButton;
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;
48 void setupTabAccounts(); 48 void setupTabAccounts();
49 void setupTabAllUsers(); 49 void setupTabAllUsers();
50 void setupTabAllGroups(); 50 void setupTabAllGroups();
51 void setupTabPrefs(); 51 void setupTabPrefs();
52 void setupTabAbout(); 52 void setupTabAbout();
53 void getUsers(); 53 void getUsers();
54 void getGroups(); 54 void getGroups();
55 55
56private slots: 56private slots:
57 void addUser(); 57 void addUser();
58 void editUser(); 58 void editUser();
59 void delUser(); 59 void delUser();
60 void addGroup(); 60 void addGroup();
61 void editGroup(); 61 void editGroup();
62 void delGroup(); 62 void delGroup();
63}; 63};
64 64
65#endif // USERCONFIG_H 65#endif // USERCONFIG_H