summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -152,13 +152,13 @@ void UserDialog::setupTab2() {
layout->setMargin(5);
// Additional groups
groupsListView=new QListView(tabpage,"groups");
groupsListView->addColumn("Additional groups");
groupsListView->setColumnWidthMode(0,QListView::Maximum);
- groupsListView->setMultiSelection(true);
+ groupsListView->setMultiSelection(false);
groupsListView->setAllColumnsShowFocus(false);
layout->addSpacing(5);
// Grouplist
layout->addWidget(groupsListView);
@@ -195,25 +195,27 @@ bool UserDialog::addUser(int uid, int gid) {
QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) {
QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user.");
return false;
}
// Add User to additional groups.
+ QCheckListItem *temp;
QListViewItemIterator it( adduserDialog->groupsListView );
for ( ; it.current(); ++it ) {
- if ( it.current()->isSelected() )
+ temp=(QCheckListItem*)it.current();
+ if (temp->isOn() )
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=adduserDialog->userImage.smoothScale(48,48);
adduserDialog->userImage.save(filename,"PNG");
}
return true;
}
/**
@@ -265,19 +267,21 @@ bool UserDialog::editUser(const char *username) {
for(int i=0;i<edituserDialog->groupComboBox->count();++i) {
if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) {
edituserDialog->groupComboBox->setCurrentItem(i);
}
}
// Select the groups in the listview, to which the user belongs.
+ QCheckListItem *temp;
QRegExp userRegExp(QString("[:\\s]%1\\s").arg(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.
QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups.
for ( ; lvit.current(); ++lvit ) {
if(lvit.current()->text(0)==(*it).left((*it).find(":"))) {
- lvit.current()->setSelected(true); // If we find a line with that groupname, select it.;
+ temp=(QCheckListItem*)lvit.current();
+ temp->setOn(true); // If we find a line with that groupname, select it.;
}
}
}
if(!(edituserDialog->exec())) return false; // SHOW THE DIALOG!
@@ -300,24 +304,25 @@ bool UserDialog::editUser(const char *username) {
accounts->delGroupMember((*it).left((*it).find(":")),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() )
+ temp=(QCheckListItem*)it.current();
+ if ( temp->isOn() )
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=edituserDialog->userImage.smoothScale(48,48);
edituserDialog->userImage.save(filename,"PNG");
}
return true;
}
/**
@@ -341,13 +346,13 @@ void UserDialog::clickedPicture() {
QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics");
if(!(filename.isEmpty())) {
userImage.reset();
if(!(userImage.load(filename))) {
QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename);
} else {
- userImage=userImage.smoothScale(48,48);
+// userImage=userImage.smoothScale(48,48);
QPixmap *picture;
picture=(QPixmap *)picturePushButton->pixmap();
picture->convertFromImage(userImage,0);
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
@@ -68,15 +68,16 @@ UserConfig::~UserConfig() {
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);
+ usersIconView=new QListView(tabpage,"users");
+ usersIconView->addColumn("Icon");
+ usersIconView->addColumn("Username");
+ usersIconView->setAllColumnsShowFocus(true);
layout->addWidget(usersIconView);
myTabWidget->addTab(tabpage,"Users");
}
void UserConfig::setupTabAllUsers() {
@@ -109,30 +110,30 @@ void UserConfig::setupTabAllGroups() {
myTabWidget->addTab(tabpage,"All Groups");
}
void UserConfig::getUsers() {
QString mytext;
QPixmap mypixmap;
-
+ QListViewItem *listviewitem;
+
// Empty the iconview & the listview.
usersIconView->clear();
usersListView->clear();
// availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500.
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? Resource::loadPixmap is caching, doesn't work.
- if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) {
-// if(mypixmap.isNull()) {
+ 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.
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.
+ listviewitem=new QListViewItem(usersIconView,"",mytext); // Add the icon+text to the qiconview.
+ listviewitem->setPixmap(0,mypixmap);
}
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();
}
@@ -144,13 +145,13 @@ void UserConfig::addUser() {
}
void UserConfig::editUser() {
QString username;
if(myTabWidget->currentPageIndex()==0) { // Users
if(usersIconView->currentItem()) { // Any icon selected?
- username=usersIconView->currentItem()->text(); // Get the text associated with the icon.
+ username=usersIconView->currentItem()->text(1); // Get the text associated with the icon.
username=username.left(username.find(" - (",0,true)); // Strip out the username.
if(UserDialog::editUser(username)) { // Bring up the userinfo dialog.
// If there were any changed also update the views.
getUsers();
getGroups();
}
@@ -174,13 +175,13 @@ void UserConfig::editUser() {
void UserConfig::delUser() {
QString username;
if(myTabWidget->currentPageIndex()==0) { // Users, Iconview.
if(usersIconView->currentItem()) { // Anything selected?
- username=usersIconView->currentItem()->text(); // Get string associated with icon.
+ username=usersIconView->currentItem()->text(1); // Get string associated with icon.
username=username.left(username.find(" - (",0,true)); // Strip out the username.
if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) {
if(UserDialog::delUser(username)) { // Delete the user if possible.
// Update views.
getUsers();
getGroups();
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
@@ -10,13 +10,13 @@
#ifndef USERCONFIG_H
#define USERCONFIG_H
#include <qmainwindow.h>
#include <qtabwidget.h>
#include <qlistview.h>
-#include <qiconview.h>
+//#include <qiconview.h>
#include <qpe/qpemenubar.h>
#include <qpopupmenu.h>
#include <qpe/qpetoolbar.h>
#include <qtoolbutton.h>
@@ -37,13 +37,13 @@ private:
QToolButton *edituserToolButton;
QToolButton *deleteuserToolButton;
QToolButton *addgroupToolButton;
QToolButton *editgroupToolButton;
QToolButton *deletegroupToolButton;
QTabWidget *myTabWidget;
- QIconView *usersIconView;
+ QListView *usersIconView;
QListView *usersListView;
QListView *groupsListView;
int availableUID;
int availableGID;
void setupTabAccounts();
void setupTabAllUsers();