author | ar <ar> | 2004-02-21 16:02:01 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-21 16:02:01 (UTC) |
commit | db2afda83e495bff9fc19fa14a30072f1cd4c67a (patch) (unidiff) | |
tree | 0281ec10dad24d83179283370661ae9225016de0 /noncore/settings/usermanager | |
parent | 460258f203be746ff79e14f32a823f381b8ea513 (diff) | |
download | opie-db2afda83e495bff9fc19fa14a30072f1cd4c67a.zip opie-db2afda83e495bff9fc19fa14a30072f1cd4c67a.tar.gz opie-db2afda83e495bff9fc19fa14a30072f1cd4c67a.tar.bz2 |
improve support for BigScreen
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 149 |
1 files changed, 100 insertions, 49 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index d87a005..08de352 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -8,20 +8,25 @@ | |||
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | #include "userdialog.h" | 10 | #include "userdialog.h" |
11 | #include "passwd.h" | ||
12 | |||
13 | /* OPIE */ | ||
14 | #include <opie/odevice.h> | ||
15 | #include <qpe/qpeapplication.h> | ||
11 | 16 | ||
17 | /* QT */ | ||
12 | #include <qlayout.h> | 18 | #include <qlayout.h> |
13 | #include <qlabel.h> | 19 | #include <qlabel.h> |
14 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
15 | #include <qfile.h> | 21 | #include <qfile.h> |
16 | 22 | ||
23 | /* STD */ | ||
17 | #include <sys/types.h> | 24 | #include <sys/types.h> |
18 | #include <sys/wait.h> | 25 | #include <sys/wait.h> |
19 | #include <unistd.h> | 26 | #include <unistd.h> |
20 | #include <signal.h> | 27 | #include <signal.h> |
21 | 28 | ||
22 | #include "passwd.h" | ||
23 | 29 | ||
24 | #include <opie/odevice.h> | ||
25 | using namespace Opie; | 30 | using namespace Opie; |
26 | 31 | ||
27 | 32 | ||
@@ -29,7 +34,8 @@ using namespace Opie; | |||
29 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. | 34 | * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. |
30 | * | 35 | * |
31 | */ | 36 | */ |
32 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { | 37 | UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) |
38 | { | ||
33 | vm=viewmode; | 39 | vm=viewmode; |
34 | QVBoxLayout *layout = new QVBoxLayout(this); | 40 | QVBoxLayout *layout = new QVBoxLayout(this); |
35 | myTabWidget=new QTabWidget(this,"User Tab Widget"); | 41 | myTabWidget=new QTabWidget(this,"User Tab Widget"); |
@@ -39,28 +45,31 @@ UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool mod | |||
39 | 45 | ||
40 | accounts->groupStringList.sort(); | 46 | accounts->groupStringList.sort(); |
41 | // And also fill the listview & the combobox with all available groups. | 47 | // And also fill the listview & the combobox with all available groups. |
42 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { | 48 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) |
49 | { | ||
43 | accounts->splitGroupEntry(*it); | 50 | accounts->splitGroupEntry(*it); |
44 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. | 51 | if(accounts->gr_name.find(QRegExp("^#"),0)) |
52 | {// Skip commented lines. | ||
45 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); | 53 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); |
46 | groupComboBox->insertItem(accounts->gr_name); | 54 | groupComboBox->insertItem(accounts->gr_name); |
47 | } | 55 | } |
48 | } | 56 | } |
49 | showMaximized(); | 57 | QPEApplication::showDialog( this ); |
50 | } | 58 | } |
51 | 59 | ||
52 | /** | 60 | /** |
53 | * Empty destructor. | 61 | * Empty destructor. |
54 | * | 62 | * |
55 | */ | 63 | */ |
56 | UserDialog::~UserDialog() { | 64 | UserDialog::~UserDialog() |
57 | } | 65 | {} |
58 | 66 | ||
59 | /** | 67 | /** |
60 | * Creates the first tab, all userinfo is here. | 68 | * Creates the first tab, all userinfo is here. |
61 | * | 69 | * |
62 | */ | 70 | */ |
63 | void UserDialog::setupTab1() { | 71 | void UserDialog::setupTab1() |
72 | { | ||
64 | QPixmap mypixmap; | 73 | QPixmap mypixmap; |
65 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); | 74 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); |
66 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 75 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
@@ -109,7 +118,8 @@ void UserDialog::setupTab1() { | |||
109 | groupLabel->setText("Primary group: "); | 118 | groupLabel->setText("Primary group: "); |
110 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); | 119 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); |
111 | 120 | ||
112 | if(vm==VIEWMODE_NEW) { | 121 | if(vm==VIEWMODE_NEW) |
122 | { | ||
113 | // Copy /etc/skel | 123 | // Copy /etc/skel |
114 | skelLabel=new QLabel(tabpage,"skel"); | 124 | skelLabel=new QLabel(tabpage,"skel"); |
115 | skelLabel->setText("Copy /etc/skel: "); | 125 | skelLabel->setText("Copy /etc/skel: "); |
@@ -136,7 +146,8 @@ void UserDialog::setupTab1() { | |||
136 | vlayout1->addWidget(shellLabel); | 146 | vlayout1->addWidget(shellLabel); |
137 | vlayout1->addSpacing(5); | 147 | vlayout1->addSpacing(5); |
138 | vlayout1->addWidget(groupLabel); | 148 | vlayout1->addWidget(groupLabel); |
139 | if(vm==VIEWMODE_NEW) { | 149 | if(vm==VIEWMODE_NEW) |
150 | { | ||
140 | vlayout1->addSpacing(5); | 151 | vlayout1->addSpacing(5); |
141 | vlayout1->addWidget(skelLabel); | 152 | vlayout1->addWidget(skelLabel); |
142 | } | 153 | } |
@@ -152,7 +163,8 @@ void UserDialog::setupTab1() { | |||
152 | vlayout2->addWidget(shellComboBox); | 163 | vlayout2->addWidget(shellComboBox); |
153 | vlayout2->addSpacing(5); | 164 | vlayout2->addSpacing(5); |
154 | vlayout2->addWidget(groupComboBox); | 165 | vlayout2->addWidget(groupComboBox); |
155 | if(vm==VIEWMODE_NEW) { | 166 | if(vm==VIEWMODE_NEW) |
167 | { | ||
156 | vlayout2->addSpacing(5); | 168 | vlayout2->addSpacing(5); |
157 | vlayout2->addWidget(skelCheckBox); | 169 | vlayout2->addWidget(skelCheckBox); |
158 | } | 170 | } |
@@ -166,7 +178,8 @@ void UserDialog::setupTab1() { | |||
166 | * Creates the second tab containing additional groups for the user. | 178 | * Creates the second tab containing additional groups for the user. |
167 | * | 179 | * |
168 | */ | 180 | */ |
169 | void UserDialog::setupTab2() { | 181 | void UserDialog::setupTab2() |
182 | { | ||
170 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); | 183 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); |
171 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 184 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
172 | layout->setMargin(5); | 185 | layout->setMargin(5); |
@@ -195,7 +208,8 @@ void UserDialog::setupTab2() { | |||
195 | * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. | 208 | * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. |
196 | * | 209 | * |
197 | */ | 210 | */ |
198 | bool UserDialog::addUser(int uid, int gid) { | 211 | bool UserDialog::addUser(int uid, int gid) |
212 | { | ||
199 | QCheckListItem *temp; | 213 | QCheckListItem *temp; |
200 | QFile ozTest; | 214 | QFile ozTest; |
201 | int oz=false; | 215 | int oz=false; |
@@ -209,9 +223,11 @@ bool UserDialog::addUser(int uid, int gid) { | |||
209 | adduserDialog->groupComboBox->insertItem("<create new group>",0); | 223 | adduserDialog->groupComboBox->insertItem("<create new group>",0); |
210 | adduserDialog->uidLineEdit->setText(QString::number(uid)); | 224 | adduserDialog->uidLineEdit->setText(QString::number(uid)); |
211 | // If we're running on OZ, add new users to some default groups. | 225 | // If we're running on OZ, add new users to some default groups. |
212 | if(oz) { | 226 | if(oz) |
227 | { | ||
213 | QListViewItemIterator iter( adduserDialog->groupsListView ); | 228 | QListViewItemIterator iter( adduserDialog->groupsListView ); |
214 | for ( ; iter.current(); ++iter ) { | 229 | for ( ; iter.current(); ++iter ) |
230 | { | ||
215 | temp=(QCheckListItem*)iter.current(); | 231 | temp=(QCheckListItem*)iter.current(); |
216 | if (temp->text()=="video") temp->setOn(true); | 232 | if (temp->text()=="video") temp->setOn(true); |
217 | if (temp->text()=="audio") temp->setOn(true); | 233 | if (temp->text()=="audio") temp->setOn(true); |
@@ -224,29 +240,34 @@ bool UserDialog::addUser(int uid, int gid) { | |||
224 | } | 240 | } |
225 | // Show the dialog! | 241 | // Show the dialog! |
226 | if(!(adduserDialog->exec())) return false; | 242 | if(!(adduserDialog->exec())) return false; |
227 | if((adduserDialog->groupComboBox->currentItem()!=0)) { | 243 | if((adduserDialog->groupComboBox->currentItem()!=0)) |
244 | { | ||
228 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); | 245 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); |
229 | adduserDialog->groupID=accounts->gr_gid; | 246 | adduserDialog->groupID=accounts->gr_gid; |
230 | qWarning(QString::number(accounts->gr_gid)); | 247 | qWarning(QString::number(accounts->gr_gid)); |
231 | } | 248 | } |
232 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), | 249 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), |
233 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), | 250 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), |
234 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { | 251 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) |
252 | { | ||
235 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); | 253 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); |
236 | return false; | 254 | return false; |
237 | } | 255 | } |
238 | 256 | ||
239 | // Add User to additional groups. | 257 | // Add User to additional groups. |
240 | QListViewItemIterator it( adduserDialog->groupsListView ); | 258 | QListViewItemIterator it( adduserDialog->groupsListView ); |
241 | for ( ; it.current(); ++it ) { | 259 | for ( ; it.current(); ++it ) |
260 | { | ||
242 | temp=(QCheckListItem*)it.current(); | 261 | temp=(QCheckListItem*)it.current(); |
243 | if (temp->isOn() ) | 262 | if (temp->isOn() ) |
244 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); | 263 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); |
245 | } | 264 | } |
246 | // Copy image to pics/users/ | 265 | // Copy image to pics/users/ |
247 | if(!(adduserDialog->userImage.isNull())) { | 266 | if(!(adduserDialog->userImage.isNull())) |
267 | { | ||
248 | QDir d; | 268 | QDir d; |
249 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 269 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) |
270 | { | ||
250 | d.mkdir("/opt/QtPalmtop/pics/users"); | 271 | d.mkdir("/opt/QtPalmtop/pics/users"); |
251 | } | 272 | } |
252 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 273 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
@@ -256,7 +277,8 @@ bool UserDialog::addUser(int uid, int gid) { | |||
256 | 277 | ||
257 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? | 278 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? |
258 | accounts->findUser(adduserDialog->loginLineEdit->text()); | 279 | accounts->findUser(adduserDialog->loginLineEdit->text()); |
259 | if(adduserDialog->skelCheckBox->isChecked()) { | 280 | if(adduserDialog->skelCheckBox->isChecked()) |
281 | { | ||
260 | QString command_cp; | 282 | QString command_cp; |
261 | QString command_chown; | 283 | QString command_chown; |
262 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); | 284 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); |
@@ -280,12 +302,17 @@ bool UserDialog::addUser(int uid, int gid) { | |||
280 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. | 302 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. |
281 | * | 303 | * |
282 | */ | 304 | */ |
283 | bool UserDialog::delUser(const char *username) { | 305 | bool UserDialog::delUser(const char *username) |
284 | if((accounts->findUser(username))) {// Does that user exist? | 306 | { |
285 | if(!(accounts->delUser(username))) {// Delete the user. | 307 | if((accounts->findUser(username))) |
308 | {// Does that user exist? | ||
309 | if(!(accounts->delUser(username))) | ||
310 | {// Delete the user. | ||
286 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); | 311 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); |
287 | } | 312 | } |
288 | } else { | 313 | } |
314 | else | ||
315 | { | ||
289 | QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); | 316 | QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); |
290 | return false; | 317 | return false; |
291 | } | 318 | } |
@@ -301,13 +328,15 @@ bool UserDialog::delUser(const char *username) { | |||
301 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. | 328 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. |
302 | * | 329 | * |
303 | */ | 330 | */ |
304 | bool UserDialog::editUser(const char *username) { | 331 | bool UserDialog::editUser(const char *username) |
332 | { | ||
305 | int invalid_group=0; | 333 | int invalid_group=0; |
306 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. | 334 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. |
307 | UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT);// Create Dialog | 335 | UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT);// Create Dialog |
308 | edituserDialog->setCaption(tr("Edit User")); | 336 | edituserDialog->setCaption(tr("Edit User")); |
309 | accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. | 337 | accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. |
310 | if(!(accounts->findGroup(accounts->pw_gid))) {// Locate the user's primary group, and fill group variables in 'accounts' object. | 338 | if(!(accounts->findGroup(accounts->pw_gid))) |
339 | {// Locate the user's primary group, and fill group variables in 'accounts' object. | ||
311 | invalid_group=1; | 340 | invalid_group=1; |
312 | } | 341 | } |
313 | // Fill widgets with userinfo. | 342 | // Fill widgets with userinfo. |
@@ -317,18 +346,22 @@ bool UserDialog::editUser(const char *username) { | |||
317 | // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. | 346 | // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. |
318 | edituserDialog->passwordLineEdit->setText("........"); | 347 | edituserDialog->passwordLineEdit->setText("........"); |
319 | // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. | 348 | // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. |
320 | if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { | 349 | if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") |
350 | { | ||
321 | edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); | 351 | edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); |
322 | edituserDialog->shellComboBox->setCurrentItem(0); | 352 | edituserDialog->shellComboBox->setCurrentItem(0); |
323 | } | 353 | } |
324 | // Select the primary group for this user. | 354 | // Select the primary group for this user. |
325 | for(int i=0;i<edituserDialog->groupComboBox->count();++i) { | 355 | for(int i=0;i<edituserDialog->groupComboBox->count();++i) |
326 | if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { | 356 | { |
357 | if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) | ||
358 | { | ||
327 | edituserDialog->groupComboBox->setCurrentItem(i); | 359 | edituserDialog->groupComboBox->setCurrentItem(i); |
328 | break; | 360 | break; |
329 | } | 361 | } |
330 | } | 362 | } |
331 | if(invalid_group) { | 363 | if(invalid_group) |
364 | { | ||
332 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); | 365 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); |
333 | edituserDialog->groupComboBox->setCurrentItem(0); | 366 | edituserDialog->groupComboBox->setCurrentItem(0); |
334 | } | 367 | } |
@@ -338,11 +371,14 @@ bool UserDialog::editUser(const char *username) { | |||
338 | // 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. | 371 | // 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. |
339 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. | 372 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. |
340 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 373 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
341 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 374 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) |
375 | {// Iterate over all of them. | ||
342 | qWarning(*it); | 376 | qWarning(*it); |
343 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 377 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
344 | for ( ; lvit.current(); ++lvit ) { | 378 | for ( ; lvit.current(); ++lvit ) |
345 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 379 | { |
380 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) | ||
381 | { | ||
346 | temp=(QCheckListItem*)lvit.current(); | 382 | temp=(QCheckListItem*)lvit.current(); |
347 | temp->setOn(true);// If we find a line with that groupname, select it.; | 383 | temp->setOn(true);// If we find a line with that groupname, select it.; |
348 | } | 384 | } |
@@ -350,11 +386,14 @@ bool UserDialog::editUser(const char *username) { | |||
350 | } | 386 | } |
351 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) | 387 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) |
352 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 388 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
353 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 389 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) |
390 | {// Iterate over all of them. | ||
354 | qWarning(*it); | 391 | qWarning(*it); |
355 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 392 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
356 | for ( ; lvit.current(); ++lvit ) { | 393 | for ( ; lvit.current(); ++lvit ) |
357 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 394 | { |
395 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) | ||
396 | { | ||
358 | temp=(QCheckListItem*)lvit.current(); | 397 | temp=(QCheckListItem*)lvit.current(); |
359 | temp->setOn(true);// If we find a line with that groupname, select it.; | 398 | temp->setOn(true);// If we find a line with that groupname, select it.; |
360 | } | 399 | } |
@@ -370,7 +409,8 @@ bool UserDialog::editUser(const char *username) { | |||
370 | 409 | ||
371 | // Set all variables in accounts object, that will be used when calling 'updateUser()' | 410 | // Set all variables in accounts object, that will be used when calling 'updateUser()' |
372 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); | 411 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); |
373 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object. | 412 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) |
413 | {// Fill all group variables in 'accounts' object. | ||
374 | accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. | 414 | accounts->pw_gid=accounts->gr_gid;// Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. |
375 | } | 415 | } |
376 | accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); | 416 | accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); |
@@ -379,22 +419,26 @@ bool UserDialog::editUser(const char *username) { | |||
379 | accounts->updateUser(username); | 419 | accounts->updateUser(username); |
380 | 420 | ||
381 | // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) | 421 | // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) |
382 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { | 422 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) |
423 | { | ||
383 | accounts->delGroupMember((*it).left((*it).find(":")),username); | 424 | accounts->delGroupMember((*it).left((*it).find(":")),username); |
384 | } | 425 | } |
385 | 426 | ||
386 | // Add User to additional groups that he/she is a member of. | 427 | // Add User to additional groups that he/she is a member of. |
387 | QListViewItemIterator it( edituserDialog->groupsListView ); | 428 | QListViewItemIterator it( edituserDialog->groupsListView ); |
388 | for ( ; it.current(); ++it ) { | 429 | for ( ; it.current(); ++it ) |
430 | { | ||
389 | temp=(QCheckListItem*)it.current(); | 431 | temp=(QCheckListItem*)it.current(); |
390 | if ( temp->isOn() ) | 432 | if ( temp->isOn() ) |
391 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); | 433 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); |
392 | } | 434 | } |
393 | 435 | ||
394 | // Copy image to pics/users/ | 436 | // Copy image to pics/users/ |
395 | if(!(edituserDialog->userImage.isNull())) { | 437 | if(!(edituserDialog->userImage.isNull())) |
438 | { | ||
396 | QDir d; | 439 | QDir d; |
397 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 440 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) |
441 | { | ||
398 | d.mkdir("/opt/QtPalmtop/pics/users"); | 442 | d.mkdir("/opt/QtPalmtop/pics/users"); |
399 | } | 443 | } |
400 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 444 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
@@ -408,9 +452,11 @@ bool UserDialog::editUser(const char *username) { | |||
408 | * "OK" has been clicked. Verify some information before closing the dialog. | 452 | * "OK" has been clicked. Verify some information before closing the dialog. |
409 | * | 453 | * |
410 | */ | 454 | */ |
411 | void UserDialog::accept() { | 455 | void UserDialog::accept() |
456 | { | ||
412 | // Add checking... valid username? username taken? | 457 | // Add checking... valid username? username taken? |
413 | if(loginLineEdit->text().isEmpty()) { | 458 | if(loginLineEdit->text().isEmpty()) |
459 | { | ||
414 | QMessageBox::information(0,"Empty Login","Please enter a login."); | 460 | QMessageBox::information(0,"Empty Login","Please enter a login."); |
415 | return; | 461 | return; |
416 | } | 462 | } |
@@ -421,13 +467,18 @@ void UserDialog::accept() { | |||
421 | * This slot is called when the usericon is clicked, this loads (should) the iconselector. | 467 | * This slot is called when the usericon is clicked, this loads (should) the iconselector. |
422 | * | 468 | * |
423 | */ | 469 | */ |
424 | void UserDialog::clickedPicture() { | 470 | void UserDialog::clickedPicture() |
471 | { | ||
425 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); | 472 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); |
426 | if(!(filename.isEmpty())) { | 473 | if(!(filename.isEmpty())) |
474 | { | ||
427 | userImage.reset(); | 475 | userImage.reset(); |
428 | if(!(userImage.load(filename))) { | 476 | if(!(userImage.load(filename))) |
477 | { | ||
429 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); | 478 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); |
430 | } else { | 479 | } |
480 | else | ||
481 | { | ||
431 | // userImage=userImage.smoothScale(48,48); | 482 | // userImage=userImage.smoothScale(48,48); |
432 | QPixmap *picture; | 483 | QPixmap *picture; |
433 | picture=(QPixmap *)picturePushButton->pixmap(); | 484 | picture=(QPixmap *)picturePushButton->pixmap(); |