summaryrefslogtreecommitdiff
authorumopapisdn <umopapisdn>2002-09-24 21:48:42 (UTC)
committer umopapisdn <umopapisdn>2002-09-24 21:48:42 (UTC)
commit0792061c7f1758216f9d31314dc2c1bdabda653f (patch) (unidiff)
treedf041dfd0c7144db69cb1a9a419cf28a87741d96
parent5fb5e6b63bbbffcc240380c57f186991253d0bd2 (diff)
downloadopie-0792061c7f1758216f9d31314dc2c1bdabda653f.zip
opie-0792061c7f1758216f9d31314dc2c1bdabda653f.tar.gz
opie-0792061c7f1758216f9d31314dc2c1bdabda653f.tar.bz2
Fixed searchpath for icons.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/usermanager/usermanager.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp
index 883e5d7..87dd7f1 100644
--- a/noncore/settings/usermanager/usermanager.cpp
+++ b/noncore/settings/usermanager/usermanager.cpp
@@ -1,224 +1,224 @@
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#include "usermanager.h" 10#include "usermanager.h"
11 11
12#include <qlayout.h> 12#include <qlayout.h>
13#include <stdio.h> 13#include <stdio.h>
14 14
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16#include <qfile.h> 16#include <qfile.h>
17#include <qpe/resource.h> 17#include <qpe/resource.h>
18 18
19#include <qregexp.h> 19#include <qregexp.h>
20 20
21/** 21/**
22 * The mainwindow constructor. 22 * The mainwindow constructor.
23 * 23 *
24 * @param QWidget *parent 24 * @param QWidget *parent
25 * @param const char *name 25 * @param const char *name
26 * @ param WFlags fl 26 * @ param WFlags fl
27 * 27 *
28 */ 28 */
29UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { 29UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) {
30 setCaption(tr("OPIE User Manager")); 30 setCaption(tr("OPIE User Manager"));
31 31
32 // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. 32 // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them.
33 accounts=new Passwd(); 33 accounts=new Passwd();
34 accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. 34 accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory.
35 35
36 // Create the toolbar. 36 // Create the toolbar.
37 QPEToolBar *toolbar = new QPEToolBar(this,"Toolbar"); 37 QPEToolBar *toolbar = new QPEToolBar(this,"Toolbar");
38 toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? 38 toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!?
39 adduserToolButton = new QToolButton(Resource::loadPixmap("userconfig/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); 39 adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User");
40 edituserToolButton = new QToolButton(Resource::loadPixmap("userconfig/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); 40 edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User");
41 deleteuserToolButton = new QToolButton(Resource::loadPixmap("userconfig/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); 41 deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User");
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("userconfig/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("userconfig/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("userconfig/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 QIconView(tabpage,"users");
75 usersIconView->setItemTextPos(QIconView::Right); 75 usersIconView->setItemTextPos(QIconView::Right);
76 layout->addWidget(usersIconView); 76 layout->addWidget(usersIconView);
77 77
78 myTabWidget->addTab(tabpage,"Users"); 78 myTabWidget->addTab(tabpage,"Users");
79} 79}
80 80
81void UserConfig::setupTabAllUsers() { 81void UserConfig::setupTabAllUsers() {
82 QWidget *tabpage = new QWidget(this); 82 QWidget *tabpage = new QWidget(this);
83 QVBoxLayout *layout = new QVBoxLayout(tabpage); 83 QVBoxLayout *layout = new QVBoxLayout(tabpage);
84 layout->setMargin(5); 84 layout->setMargin(5);
85 85
86 usersListView=new QListView(tabpage,"allusers"); 86 usersListView=new QListView(tabpage,"allusers");
87 usersListView->addColumn("UID"); 87 usersListView->addColumn("UID");
88 usersListView->addColumn("Login"); 88 usersListView->addColumn("Login");
89 usersListView->addColumn("Username"); 89 usersListView->addColumn("Username");
90 layout->addWidget(usersListView); 90 layout->addWidget(usersListView);
91 usersListView->setSorting(1,1); 91 usersListView->setSorting(1,1);
92 usersListView->setAllColumnsShowFocus(true); 92 usersListView->setAllColumnsShowFocus(true);
93 93
94 myTabWidget->addTab(tabpage,"All Users"); 94 myTabWidget->addTab(tabpage,"All Users");
95} 95}
96 96
97void UserConfig::setupTabAllGroups() { 97void UserConfig::setupTabAllGroups() {
98 QWidget *tabpage = new QWidget(this); 98 QWidget *tabpage = new QWidget(this);
99 QVBoxLayout *layout = new QVBoxLayout(tabpage); 99 QVBoxLayout *layout = new QVBoxLayout(tabpage);
100 layout->setMargin(5); 100 layout->setMargin(5);
101 101
102 groupsListView=new QListView(tabpage,"groups"); 102 groupsListView=new QListView(tabpage,"groups");
103 groupsListView->addColumn("GID"); 103 groupsListView->addColumn("GID");
104 groupsListView->addColumn("Groupname"); 104 groupsListView->addColumn("Groupname");
105 layout->addWidget(groupsListView); 105 layout->addWidget(groupsListView);
106 groupsListView->setSorting(1,1); 106 groupsListView->setSorting(1,1);
107 groupsListView->setAllColumnsShowFocus(true); 107 groupsListView->setAllColumnsShowFocus(true);
108 108
109 myTabWidget->addTab(tabpage,"All Groups"); 109 myTabWidget->addTab(tabpage,"All Groups");
110} 110}
111void UserConfig::getUsers() { 111void UserConfig::getUsers() {
112 QString mytext; 112 QString mytext;
113 QPixmap mypixmap; 113 QPixmap mypixmap;
114 114
115 // Empty the iconview & the listview. 115 // Empty the iconview & the listview.
116 usersIconView->clear(); 116 usersIconView->clear();
117 usersListView->clear(); 117 usersListView->clear();
118 118
119 // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. 119 // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500.
120 availableUID=500; 120 availableUID=500;
121 for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { 121 for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) {
122 accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) 122 accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.)
123 new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); 123 new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos);
124 if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? 124 if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ?
125 mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. 125 mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon.
126 mypixmap=Resource::loadPixmap(QString("users/"+accounts->pw_name));// Is there an icon for this user? 126 mypixmap=Resource::loadPixmap(QString("users/"+accounts->pw_name));// Is there an icon for this user?
127 if(mypixmap.isNull()) { 127 if(mypixmap.isNull()) {
128 mypixmap=Resource::loadPixmap(QString("userconfig/usericon"));// If this user has no icon, load the default icon. 128 mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon.
129 } 129 }
130 new QIconViewItem(usersIconView,mytext,mypixmap);// Add the icon+text to the qiconview. 130 new QIconViewItem(usersIconView,mytext,mypixmap);// Add the icon+text to the qiconview.
131 } 131 }
132 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. 132 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.
133 } 133 }
134} 134}
135 135
136void UserConfig::addUser() { 136void UserConfig::addUser() {
137 if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. 137 if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID.
138 getUsers(); // Update users views. 138 getUsers(); // Update users views.
139 getGroups(); // Update groups view. 139 getGroups(); // Update groups view.
140 } 140 }
141} 141}
142 142
143void UserConfig::editUser() { 143void UserConfig::editUser() {
144 QString username; 144 QString username;
145 if(myTabWidget->currentPageIndex()==0) {// Users 145 if(myTabWidget->currentPageIndex()==0) {// Users
146 if(usersIconView->currentItem()) {// Any icon selected? 146 if(usersIconView->currentItem()) {// Any icon selected?
147 username=usersIconView->currentItem()->text();// Get the text associated with the icon. 147 username=usersIconView->currentItem()->text();// Get the text associated with the icon.
148 username=username.left(username.find(" - (",0,true));// Strip out the username. 148 username=username.left(username.find(" - (",0,true));// Strip out the username.
149 if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. 149 if(UserDialog::editUser(username)) {// Bring up the userinfo dialog.
150 // If there were any changed also update the views. 150 // If there were any changed also update the views.
151 getUsers(); 151 getUsers();
152 getGroups(); 152 getGroups();
153 } 153 }
154 } else { 154 } else {
155 QMessageBox::information(this,"No selection.","No user has been selected."); 155 QMessageBox::information(this,"No selection.","No user has been selected.");
156 } 156 }
157 } 157 }
158 if(myTabWidget->currentPageIndex()==1) {// All users 158 if(myTabWidget->currentPageIndex()==1) {// All users
159 if(usersListView->currentItem()) {// Anything changed!? 159 if(usersListView->currentItem()) {// Anything changed!?
160 username=usersListView->currentItem()->text(1);// Get the username. 160 username=usersListView->currentItem()->text(1);// Get the username.
161 if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. 161 if(UserDialog::editUser(username)) {// Bring up the userinfo dialog.
162 // And again update the views if there were any changes. 162 // And again update the views if there were any changes.
163 getUsers(); 163 getUsers();
164 getGroups(); 164 getGroups();
165 } 165 }
166 } else { 166 } else {
167 QMessageBox::information(this,"No selection.","No user has been selected."); 167 QMessageBox::information(this,"No selection.","No user has been selected.");
168 } 168 }
169 } 169 }
170} 170}
171 171
172void UserConfig::delUser() { 172void UserConfig::delUser() {
173 QString username; 173 QString username;
174 174
175 if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. 175 if(myTabWidget->currentPageIndex()==0) {// Users, Iconview.
176 if(usersIconView->currentItem()) {// Anything selected? 176 if(usersIconView->currentItem()) {// Anything selected?
177 username=usersIconView->currentItem()->text();// Get string associated with icon. 177 username=usersIconView->currentItem()->text();// Get string associated with icon.
178 username=username.left(username.find(" - (",0,true));// Strip out the username. 178 username=username.left(username.find(" - (",0,true));// Strip out the username.
179 if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { 179 if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) {
180 if(UserDialog::delUser(username)) {// Delete the user if possible. 180 if(UserDialog::delUser(username)) {// Delete the user if possible.
181 // Update views. 181 // Update views.
182 getUsers(); 182 getUsers();
183 getGroups(); 183 getGroups();
184 } 184 }
185 } 185 }
186 } else { 186 } else {
187 QMessageBox::information(this,"No selection","No user has been selected."); 187 QMessageBox::information(this,"No selection","No user has been selected.");
188 } 188 }
189 } 189 }
190 if(myTabWidget->currentPageIndex()==1) {// All users 190 if(myTabWidget->currentPageIndex()==1) {// All users
191 if(usersListView->currentItem()) {// Anything changed!? 191 if(usersListView->currentItem()) {// Anything changed!?
192 username=usersListView->currentItem()->text(1);// Get the username. 192 username=usersListView->currentItem()->text(1);// Get the username.
193 if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { 193 if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) {
194 if(UserDialog::delUser(username)) {// Try to delete the user. 194 if(UserDialog::delUser(username)) {// Try to delete the user.
195 // Update views. 195 // Update views.
196 getUsers(); 196 getUsers();
197 getGroups(); 197 getGroups();
198 } 198 }
199 } 199 }
200 } else { 200 } else {
201 QMessageBox::information(this,"No selection","No user has been selected."); 201 QMessageBox::information(this,"No selection","No user has been selected.");
202 } 202 }
203 } 203 }
204 204
205} 205}
206 206
207void UserConfig::getGroups() { 207void UserConfig::getGroups() {
208 groupsListView->clear();// Empty the listview. 208 groupsListView->clear();// Empty the listview.
209 availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. 209 availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000.
210 for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines. 210 for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines.
211 accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem). 211 accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem).
212 new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name); 212 new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name);
213 if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID. 213 if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID.
214 } 214 }
215} 215}
216 216
217void UserConfig::addGroup() { 217void UserConfig::addGroup() {
218 if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog. 218 if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog.
219} 219}
220 220
221void UserConfig::editGroup() { 221void UserConfig::editGroup() {
222 int gid; 222 int gid;
223 if(groupsListView->currentItem()) {// Any group selected? 223 if(groupsListView->currentItem()) {// Any group selected?
224 gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview. 224 gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview.