author | ar <ar> | 2004-02-21 16:02:01 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-21 16:02:01 (UTC) |
commit | db2afda83e495bff9fc19fa14a30072f1cd4c67a (patch) (side-by-side diff) | |
tree | 0281ec10dad24d83179283370661ae9225016de0 /noncore/settings/usermanager/userdialog.cpp | |
parent | 460258f203be746ff79e14f32a823f381b8ea513 (diff) | |
download | opie-db2afda83e495bff9fc19fa14a30072f1cd4c67a.zip opie-db2afda83e495bff9fc19fa14a30072f1cd4c67a.tar.gz opie-db2afda83e495bff9fc19fa14a30072f1cd4c67a.tar.bz2 |
improve support for BigScreen
Diffstat (limited to 'noncore/settings/usermanager/userdialog.cpp') (more/less context) (show whitespace changes)
-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 @@ -10,3 +10,9 @@ #include "userdialog.h" +#include "passwd.h" + +/* OPIE */ +#include <opie/odevice.h> +#include <qpe/qpeapplication.h> +/* QT */ #include <qlayout.h> @@ -16,2 +22,3 @@ +/* STD */ #include <sys/types.h> @@ -21,5 +28,3 @@ -#include "passwd.h" -#include <opie/odevice.h> using namespace Opie; @@ -31,3 +36,4 @@ using namespace Opie; */ -UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { +UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) +{ vm=viewmode; @@ -41,5 +47,7 @@ UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool mod // And also fill the listview & the combobox with all available groups. - for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { + for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) + { accounts->splitGroupEntry(*it); - if(accounts->gr_name.find(QRegExp("^#"),0)) { // Skip commented lines. + if(accounts->gr_name.find(QRegExp("^#"),0)) + { // Skip commented lines. new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); @@ -48,3 +56,3 @@ UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool mod } - showMaximized(); + QPEApplication::showDialog( this ); } @@ -55,4 +63,4 @@ UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool mod */ -UserDialog::~UserDialog() { -} +UserDialog::~UserDialog() +{} @@ -62,3 +70,4 @@ UserDialog::~UserDialog() { */ -void UserDialog::setupTab1() { +void UserDialog::setupTab1() +{ QPixmap mypixmap; @@ -111,3 +120,4 @@ void UserDialog::setupTab1() { - if(vm==VIEWMODE_NEW) { + if(vm==VIEWMODE_NEW) + { // Copy /etc/skel @@ -138,3 +148,4 @@ void UserDialog::setupTab1() { vlayout1->addWidget(groupLabel); - if(vm==VIEWMODE_NEW) { + if(vm==VIEWMODE_NEW) + { vlayout1->addSpacing(5); @@ -154,3 +165,4 @@ void UserDialog::setupTab1() { vlayout2->addWidget(groupComboBox); - if(vm==VIEWMODE_NEW) { + if(vm==VIEWMODE_NEW) + { vlayout2->addSpacing(5); @@ -168,3 +180,4 @@ void UserDialog::setupTab1() { */ -void UserDialog::setupTab2() { +void UserDialog::setupTab2() +{ QWidget *tabpage = new QWidget(myTabWidget,"page2"); @@ -197,3 +210,4 @@ void UserDialog::setupTab2() { */ -bool UserDialog::addUser(int uid, int gid) { +bool UserDialog::addUser(int uid, int gid) +{ QCheckListItem *temp; @@ -211,5 +225,7 @@ bool UserDialog::addUser(int uid, int gid) { // If we're running on OZ, add new users to some default groups. - if(oz) { + if(oz) + { QListViewItemIterator iter( adduserDialog->groupsListView ); - for ( ; iter.current(); ++iter ) { + for ( ; iter.current(); ++iter ) + { temp=(QCheckListItem*)iter.current(); @@ -226,3 +242,4 @@ bool UserDialog::addUser(int uid, int gid) { if(!(adduserDialog->exec())) return false; - if((adduserDialog->groupComboBox->currentItem()!=0)) { + if((adduserDialog->groupComboBox->currentItem()!=0)) + { accounts->findGroup(adduserDialog->groupComboBox->currentText()); @@ -233,3 +250,4 @@ bool UserDialog::addUser(int uid, int gid) { adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), - QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { + QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) + { QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); @@ -240,3 +258,4 @@ bool UserDialog::addUser(int uid, int gid) { QListViewItemIterator it( adduserDialog->groupsListView ); - for ( ; it.current(); ++it ) { + for ( ; it.current(); ++it ) + { temp=(QCheckListItem*)it.current(); @@ -246,5 +265,7 @@ bool UserDialog::addUser(int uid, int gid) { // Copy image to pics/users/ - if(!(adduserDialog->userImage.isNull())) { + if(!(adduserDialog->userImage.isNull())) + { QDir d; - if(!(d.exists("/opt/QtPalmtop/pics/users"))) { + if(!(d.exists("/opt/QtPalmtop/pics/users"))) + { d.mkdir("/opt/QtPalmtop/pics/users"); @@ -258,3 +279,4 @@ bool UserDialog::addUser(int uid, int gid) { accounts->findUser(adduserDialog->loginLineEdit->text()); - if(adduserDialog->skelCheckBox->isChecked()) { + if(adduserDialog->skelCheckBox->isChecked()) + { QString command_cp; @@ -282,8 +304,13 @@ bool UserDialog::addUser(int uid, int gid) { */ -bool UserDialog::delUser(const char *username) { - if((accounts->findUser(username))) { // Does that user exist? - if(!(accounts->delUser(username))) { // Delete the user. +bool UserDialog::delUser(const char *username) +{ + if((accounts->findUser(username))) + { // Does that user exist? + if(!(accounts->delUser(username))) + { // Delete the user. QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); } - } else { + } + else + { QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); @@ -303,3 +330,4 @@ bool UserDialog::delUser(const char *username) { */ -bool UserDialog::editUser(const char *username) { +bool UserDialog::editUser(const char *username) +{ int invalid_group=0; @@ -309,3 +337,4 @@ bool UserDialog::editUser(const char *username) { accounts->findUser(username); // Locate user in database and fill variables in 'accounts' object. - if(!(accounts->findGroup(accounts->pw_gid))) { // Locate the user's primary group, and fill group variables in 'accounts' object. + if(!(accounts->findGroup(accounts->pw_gid))) + { // Locate the user's primary group, and fill group variables in 'accounts' object. invalid_group=1; @@ -319,3 +348,4 @@ bool UserDialog::editUser(const char *username) { // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. - if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { + if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") + { edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); @@ -324,4 +354,6 @@ bool UserDialog::editUser(const char *username) { // Select the primary group for this user. - for(int i=0;i<edituserDialog->groupComboBox->count();++i) { - if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { + for(int i=0;i<edituserDialog->groupComboBox->count();++i) + { + if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) + { edituserDialog->groupComboBox->setCurrentItem(i); @@ -330,3 +362,4 @@ bool UserDialog::editUser(const char *username) { } - if(invalid_group) { + if(invalid_group) + { edituserDialog->groupComboBox->insertItem("<Undefined group>",0); @@ -340,7 +373,10 @@ bool UserDialog::editUser(const char *username) { QStringList tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. - for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { // Iterate over all of them. + for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) + { // Iterate over all of them. qWarning(*it); QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. - for ( ; lvit.current(); ++lvit ) { - if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { + for ( ; lvit.current(); ++lvit ) + { + if(lvit.current()->text(0)==(*it).left((*it).find(":"))) + { temp=(QCheckListItem*)lvit.current(); @@ -352,7 +388,10 @@ bool UserDialog::editUser(const char *username) { tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. - for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { // Iterate over all of them. + for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) + { // Iterate over all of them. qWarning(*it); QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. - for ( ; lvit.current(); ++lvit ) { - if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { + for ( ; lvit.current(); ++lvit ) + { + if(lvit.current()->text(0)==(*it).left((*it).find(":"))) + { temp=(QCheckListItem*)lvit.current(); @@ -372,3 +411,4 @@ bool UserDialog::editUser(const char *username) { accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); - if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) { // Fill all group variables in 'accounts' object. + if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) + { // Fill all group variables in 'accounts' object. accounts->pw_gid=accounts->gr_gid; // Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. @@ -381,3 +421,4 @@ 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) { + for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) + { accounts->delGroupMember((*it).left((*it).find(":")),username); @@ -387,3 +428,4 @@ bool UserDialog::editUser(const char *username) { QListViewItemIterator it( edituserDialog->groupsListView ); - for ( ; it.current(); ++it ) { + for ( ; it.current(); ++it ) + { temp=(QCheckListItem*)it.current(); @@ -394,5 +436,7 @@ bool UserDialog::editUser(const char *username) { // Copy image to pics/users/ - if(!(edituserDialog->userImage.isNull())) { + if(!(edituserDialog->userImage.isNull())) + { QDir d; - if(!(d.exists("/opt/QtPalmtop/pics/users"))) { + if(!(d.exists("/opt/QtPalmtop/pics/users"))) + { d.mkdir("/opt/QtPalmtop/pics/users"); @@ -410,5 +454,7 @@ bool UserDialog::editUser(const char *username) { */ -void UserDialog::accept() { +void UserDialog::accept() +{ // Add checking... valid username? username taken? - if(loginLineEdit->text().isEmpty()) { + if(loginLineEdit->text().isEmpty()) + { QMessageBox::information(0,"Empty Login","Please enter a login."); @@ -423,9 +469,14 @@ void UserDialog::accept() { */ -void UserDialog::clickedPicture() { +void UserDialog::clickedPicture() +{ QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); - if(!(filename.isEmpty())) { + if(!(filename.isEmpty())) + { userImage.reset(); - if(!(userImage.load(filename))) { + if(!(userImage.load(filename))) + { QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); - } else { + } + else + { // userImage=userImage.smoothScale(48,48); |