author | drw <drw> | 2005-06-09 21:34:17 (UTC) |
---|---|---|
committer | drw <drw> | 2005-06-09 21:34:17 (UTC) |
commit | 9fe80ebf4fbe9b31d9f91a33e4cfc163b7236a62 (patch) (unidiff) | |
tree | 874045053074a769c6dc634f9c7a7175e191ac99 | |
parent | d5c8de3585a6e94c18156e51299f1e49cc992285 (diff) | |
download | opie-9fe80ebf4fbe9b31d9f91a33e4cfc163b7236a62.zip opie-9fe80ebf4fbe9b31d9f91a33e4cfc163b7236a62.tar.gz opie-9fe80ebf4fbe9b31d9f91a33e4cfc163b7236a62.tar.bz2 |
Resource -> OResource
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 3 | ||||
-rw-r--r-- | noncore/settings/usermanager/usermanager.cpp | 44 |
2 files changed, 31 insertions, 16 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index 9dfb2af..3654639 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -1,209 +1,210 @@ | |||
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 "userdialog.h" | 10 | #include "userdialog.h" |
11 | #include "passwd.h" | 11 | #include "passwd.h" |
12 | 12 | ||
13 | /* OPIE */ | 13 | /* OPIE */ |
14 | #include <opie2/odebug.h> | 14 | #include <opie2/odebug.h> |
15 | #include <opie2/odevice.h> | 15 | #include <opie2/odevice.h> |
16 | #include <opie2/oresource.h> | ||
16 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
17 | using namespace Opie::Core; | 18 | using namespace Opie::Core; |
18 | using namespace Opie::Ui; | 19 | using namespace Opie::Ui; |
19 | 20 | ||
20 | /* QT */ | 21 | /* QT */ |
21 | #include <qlayout.h> | 22 | #include <qlayout.h> |
22 | #include <qlabel.h> | 23 | #include <qlabel.h> |
23 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
24 | #include <qfile.h> | 25 | #include <qfile.h> |
25 | 26 | ||
26 | /* STD */ | 27 | /* STD */ |
27 | #include <sys/types.h> | 28 | #include <sys/types.h> |
28 | #include <sys/wait.h> | 29 | #include <sys/wait.h> |
29 | #include <unistd.h> | 30 | #include <unistd.h> |
30 | #include <signal.h> | 31 | #include <signal.h> |
31 | 32 | ||
32 | /** | 33 | /** |
33 | * 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. |
34 | * | 35 | * |
35 | */ | 36 | */ |
36 | 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) |
37 | { | 38 | { |
38 | vm=viewmode; | 39 | vm=viewmode; |
39 | QVBoxLayout *layout = new QVBoxLayout(this); | 40 | QVBoxLayout *layout = new QVBoxLayout(this); |
40 | myTabWidget=new QTabWidget(this,"User Tab Widget"); | 41 | myTabWidget=new QTabWidget(this,"User Tab Widget"); |
41 | layout->addWidget(myTabWidget); | 42 | layout->addWidget(myTabWidget); |
42 | setupTab1(); | 43 | setupTab1(); |
43 | setupTab2(); | 44 | setupTab2(); |
44 | 45 | ||
45 | accounts->groupStringList.sort(); | 46 | accounts->groupStringList.sort(); |
46 | // And also fill the listview & the combobox with all available groups. | 47 | // And also fill the listview & the combobox with all available groups. |
47 | 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) |
48 | { | 49 | { |
49 | accounts->splitGroupEntry(*it); | 50 | accounts->splitGroupEntry(*it); |
50 | if(accounts->gr_name.find(QRegExp("^#"),0)) | 51 | if(accounts->gr_name.find(QRegExp("^#"),0)) |
51 | { // Skip commented lines. | 52 | { // Skip commented lines. |
52 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); | 53 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); |
53 | groupComboBox->insertItem(accounts->gr_name); | 54 | groupComboBox->insertItem(accounts->gr_name); |
54 | } | 55 | } |
55 | } | 56 | } |
56 | QPEApplication::showDialog( this ); | 57 | QPEApplication::showDialog( this ); |
57 | } | 58 | } |
58 | 59 | ||
59 | /** | 60 | /** |
60 | * Empty destructor. | 61 | * Empty destructor. |
61 | * | 62 | * |
62 | */ | 63 | */ |
63 | UserDialog::~UserDialog() | 64 | UserDialog::~UserDialog() |
64 | {} | 65 | {} |
65 | 66 | ||
66 | /** | 67 | /** |
67 | * Creates the first tab, all userinfo is here. | 68 | * Creates the first tab, all userinfo is here. |
68 | * | 69 | * |
69 | */ | 70 | */ |
70 | void UserDialog::setupTab1() | 71 | void UserDialog::setupTab1() |
71 | { | 72 | { |
72 | QPixmap mypixmap; | 73 | QPixmap mypixmap; |
73 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); | 74 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); |
74 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 75 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
75 | layout->setMargin(5); | 76 | layout->setMargin(5); |
76 | 77 | ||
77 | // Picture | 78 | // Picture |
78 | picturePushButton = new QPushButton(tabpage,"Label"); | 79 | picturePushButton = new QPushButton(tabpage,"Label"); |
79 | picturePushButton->setMinimumSize(48,48); | 80 | picturePushButton->setMinimumSize(48,48); |
80 | picturePushButton->setMaximumSize(48,48); | 81 | picturePushButton->setMaximumSize(48,48); |
81 | picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon")); // Load default usericon. | 82 | picturePushButton->setPixmap(Opie::Core::OResource::loadPixmap("usermanager/usericon")); // Load default usericon. |
82 | connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture())); // Clicking the picture should invoke pictureselector. | 83 | connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture())); // Clicking the picture should invoke pictureselector. |
83 | 84 | ||
84 | // Login | 85 | // Login |
85 | QLabel *loginLabel=new QLabel(tabpage,"Login: "); | 86 | QLabel *loginLabel=new QLabel(tabpage,"Login: "); |
86 | loginLabel->setText("Login: "); | 87 | loginLabel->setText("Login: "); |
87 | loginLineEdit=new QLineEdit(tabpage,"Login: "); | 88 | loginLineEdit=new QLineEdit(tabpage,"Login: "); |
88 | 89 | ||
89 | // UID | 90 | // UID |
90 | QLabel *uidLabel=new QLabel(tabpage,"uid: "); | 91 | QLabel *uidLabel=new QLabel(tabpage,"uid: "); |
91 | uidLabel->setText("UserID: "); | 92 | uidLabel->setText("UserID: "); |
92 | uidLineEdit=new QLineEdit(tabpage,"uid: "); | 93 | uidLineEdit=new QLineEdit(tabpage,"uid: "); |
93 | uidLineEdit->setEnabled(false); | 94 | uidLineEdit->setEnabled(false); |
94 | 95 | ||
95 | // Username (gecos) | 96 | // Username (gecos) |
96 | QLabel *gecosLabel=new QLabel(tabpage,"gecos"); | 97 | QLabel *gecosLabel=new QLabel(tabpage,"gecos"); |
97 | gecosLabel->setText("Username: "); | 98 | gecosLabel->setText("Username: "); |
98 | gecosLineEdit=new QLineEdit(tabpage,"gecos"); | 99 | gecosLineEdit=new QLineEdit(tabpage,"gecos"); |
99 | 100 | ||
100 | // Password | 101 | // Password |
101 | QLabel *passwordLabel=new QLabel(tabpage,"password"); | 102 | QLabel *passwordLabel=new QLabel(tabpage,"password"); |
102 | passwordLabel->setText("Password: "); | 103 | passwordLabel->setText("Password: "); |
103 | passwordLineEdit=new QLineEdit(tabpage,"password"); | 104 | passwordLineEdit=new QLineEdit(tabpage,"password"); |
104 | passwordLineEdit->setEchoMode(QLineEdit::Password); | 105 | passwordLineEdit->setEchoMode(QLineEdit::Password); |
105 | 106 | ||
106 | // Shell | 107 | // Shell |
107 | QLabel *shellLabel=new QLabel(tabpage,"shell"); | 108 | QLabel *shellLabel=new QLabel(tabpage,"shell"); |
108 | shellLabel->setText("Shell: "); | 109 | shellLabel->setText("Shell: "); |
109 | shellComboBox=new QComboBox(tabpage,"shell"); | 110 | shellComboBox=new QComboBox(tabpage,"shell"); |
110 | shellComboBox->setEditable(true); | 111 | shellComboBox->setEditable(true); |
111 | shellComboBox->insertItem("/bin/sh"); | 112 | shellComboBox->insertItem("/bin/sh"); |
112 | shellComboBox->insertItem("/bin/ash"); | 113 | shellComboBox->insertItem("/bin/ash"); |
113 | shellComboBox->insertItem("/bin/false"); | 114 | shellComboBox->insertItem("/bin/false"); |
114 | 115 | ||
115 | // Primary Group | 116 | // Primary Group |
116 | QLabel *groupLabel=new QLabel(tabpage,"group"); | 117 | QLabel *groupLabel=new QLabel(tabpage,"group"); |
117 | groupLabel->setText("Primary group: "); | 118 | groupLabel->setText("Primary group: "); |
118 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); | 119 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); |
119 | 120 | ||
120 | if(vm==VIEWMODE_NEW) | 121 | if(vm==VIEWMODE_NEW) |
121 | { | 122 | { |
122 | // Copy /etc/skel | 123 | // Copy /etc/skel |
123 | skelLabel=new QLabel(tabpage,"skel"); | 124 | skelLabel=new QLabel(tabpage,"skel"); |
124 | skelLabel->setText("Copy /etc/skel: "); | 125 | skelLabel->setText("Copy /etc/skel: "); |
125 | skelCheckBox=new QCheckBox(tabpage); | 126 | skelCheckBox=new QCheckBox(tabpage); |
126 | skelCheckBox->setChecked(true); | 127 | skelCheckBox->setChecked(true); |
127 | } | 128 | } |
128 | 129 | ||
129 | // Widget layout | 130 | // Widget layout |
130 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); | 131 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); |
131 | layout->addWidget(picturePushButton); | 132 | layout->addWidget(picturePushButton); |
132 | layout->addSpacing(5); | 133 | layout->addSpacing(5); |
133 | layout->addLayout(hlayout); | 134 | layout->addLayout(hlayout); |
134 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); | 135 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); |
135 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); | 136 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); |
136 | // First column, labels | 137 | // First column, labels |
137 | vlayout1->addWidget(loginLabel); | 138 | vlayout1->addWidget(loginLabel); |
138 | vlayout1->addSpacing(5); | 139 | vlayout1->addSpacing(5); |
139 | vlayout1->addWidget(uidLabel); | 140 | vlayout1->addWidget(uidLabel); |
140 | vlayout1->addSpacing(5); | 141 | vlayout1->addSpacing(5); |
141 | vlayout1->addWidget(gecosLabel); | 142 | vlayout1->addWidget(gecosLabel); |
142 | vlayout1->addSpacing(5); | 143 | vlayout1->addSpacing(5); |
143 | vlayout1->addWidget(passwordLabel); | 144 | vlayout1->addWidget(passwordLabel); |
144 | vlayout1->addSpacing(5); | 145 | vlayout1->addSpacing(5); |
145 | vlayout1->addWidget(shellLabel); | 146 | vlayout1->addWidget(shellLabel); |
146 | vlayout1->addSpacing(5); | 147 | vlayout1->addSpacing(5); |
147 | vlayout1->addWidget(groupLabel); | 148 | vlayout1->addWidget(groupLabel); |
148 | if(vm==VIEWMODE_NEW) | 149 | if(vm==VIEWMODE_NEW) |
149 | { | 150 | { |
150 | vlayout1->addSpacing(5); | 151 | vlayout1->addSpacing(5); |
151 | vlayout1->addWidget(skelLabel); | 152 | vlayout1->addWidget(skelLabel); |
152 | } | 153 | } |
153 | // Second column, data | 154 | // Second column, data |
154 | vlayout2->addWidget(loginLineEdit); | 155 | vlayout2->addWidget(loginLineEdit); |
155 | vlayout2->addSpacing(5); | 156 | vlayout2->addSpacing(5); |
156 | vlayout2->addWidget(uidLineEdit); | 157 | vlayout2->addWidget(uidLineEdit); |
157 | vlayout2->addSpacing(5); | 158 | vlayout2->addSpacing(5); |
158 | vlayout2->addWidget(gecosLineEdit); | 159 | vlayout2->addWidget(gecosLineEdit); |
159 | vlayout2->addSpacing(5); | 160 | vlayout2->addSpacing(5); |
160 | vlayout2->addWidget(passwordLineEdit); | 161 | vlayout2->addWidget(passwordLineEdit); |
161 | vlayout2->addSpacing(5); | 162 | vlayout2->addSpacing(5); |
162 | vlayout2->addWidget(shellComboBox); | 163 | vlayout2->addWidget(shellComboBox); |
163 | vlayout2->addSpacing(5); | 164 | vlayout2->addSpacing(5); |
164 | vlayout2->addWidget(groupComboBox); | 165 | vlayout2->addWidget(groupComboBox); |
165 | if(vm==VIEWMODE_NEW) | 166 | if(vm==VIEWMODE_NEW) |
166 | { | 167 | { |
167 | vlayout2->addSpacing(5); | 168 | vlayout2->addSpacing(5); |
168 | vlayout2->addWidget(skelCheckBox); | 169 | vlayout2->addWidget(skelCheckBox); |
169 | } | 170 | } |
170 | hlayout->addLayout(vlayout1); | 171 | hlayout->addLayout(vlayout1); |
171 | hlayout->addLayout(vlayout2); | 172 | hlayout->addLayout(vlayout2); |
172 | 173 | ||
173 | myTabWidget->addTab(tabpage,"User Info"); | 174 | myTabWidget->addTab(tabpage,"User Info"); |
174 | } | 175 | } |
175 | 176 | ||
176 | /** | 177 | /** |
177 | * Creates the second tab containing additional groups for the user. | 178 | * Creates the second tab containing additional groups for the user. |
178 | * | 179 | * |
179 | */ | 180 | */ |
180 | void UserDialog::setupTab2() | 181 | void UserDialog::setupTab2() |
181 | { | 182 | { |
182 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); | 183 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); |
183 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 184 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
184 | layout->setMargin(5); | 185 | layout->setMargin(5); |
185 | 186 | ||
186 | // Additional groups | 187 | // Additional groups |
187 | groupsListView=new QListView(tabpage,"groups"); | 188 | groupsListView=new QListView(tabpage,"groups"); |
188 | groupsListView->addColumn("Additional groups"); | 189 | groupsListView->addColumn("Additional groups"); |
189 | groupsListView->setColumnWidthMode(0,QListView::Maximum); | 190 | groupsListView->setColumnWidthMode(0,QListView::Maximum); |
190 | groupsListView->setMultiSelection(false); | 191 | groupsListView->setMultiSelection(false); |
191 | groupsListView->setAllColumnsShowFocus(false); | 192 | groupsListView->setAllColumnsShowFocus(false); |
192 | 193 | ||
193 | layout->addSpacing(5); | 194 | layout->addSpacing(5); |
194 | // Grouplist | 195 | // Grouplist |
195 | layout->addWidget(groupsListView); | 196 | layout->addWidget(groupsListView); |
196 | 197 | ||
197 | myTabWidget->addTab(tabpage,"User Groups"); | 198 | myTabWidget->addTab(tabpage,"User Groups"); |
198 | } | 199 | } |
199 | 200 | ||
200 | /** | 201 | /** |
201 | * Static function that creates the userinfo dialog. | 202 | * Static function that creates the userinfo dialog. |
202 | * The user will be prompted to add a user. | 203 | * The user will be prompted to add a user. |
203 | * | 204 | * |
204 | * @param uid This is a suggested available UID. | 205 | * @param uid This is a suggested available UID. |
205 | * @param gid This is a suggested available GID. | 206 | * @param gid This is a suggested available GID. |
206 | * | 207 | * |
207 | * @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>. |
208 | * | 209 | * |
209 | */ | 210 | */ |
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp index 1d345ee..2c046b1 100644 --- a/noncore/settings/usermanager/usermanager.cpp +++ b/noncore/settings/usermanager/usermanager.cpp | |||
@@ -1,260 +1,274 @@ | |||
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 | /* OPIE */ | 12 | /* OPIE */ |
13 | #include <opie2/odebug.h> | 13 | #include <opie2/odebug.h> |
14 | #include <qpe/resource.h> | 14 | #include <opie2/oresource.h> |
15 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
16 | 16 | #include <qpe/qpeapplication.h> | |
17 | /* QT */ | 17 | /* QT */ |
18 | #include <qlayout.h> | 18 | #include <qlayout.h> |
19 | #include <qmessagebox.h> | 19 | #include <qmessagebox.h> |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
21 | #include <qregexp.h> | 21 | #include <qregexp.h> |
22 | 22 | ||
23 | /** | 23 | /** |
24 | * The mainwindow constructor. | 24 | * The mainwindow constructor. |
25 | * | 25 | * |
26 | * @param QWidget *parent | 26 | * @param QWidget *parent |
27 | * @param const char *name | 27 | * @param const char *name |
28 | * @ param WFlags fl | 28 | * @ param WFlags fl |
29 | * | 29 | * |
30 | */ | 30 | */ |
31 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { | 31 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { |
32 | setCaption(tr("Opie User Manager")); | 32 | setCaption(tr("Opie User Manager")); |
33 | 33 | ||
34 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. | 34 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. |
35 | accounts=new Passwd(); | 35 | accounts=new Passwd(); |
36 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. | 36 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. |
37 | 37 | ||
38 | // Create the toolbar. | 38 | // Create the toolbar. |
39 | setToolBarsMovable( false ); | ||
40 | bool useBigIcon = qApp->desktop()->size().width() > 330; | ||
39 | QToolBar *toolbar = new QToolBar(this,"Toolbar"); | 41 | QToolBar *toolbar = new QToolBar(this,"Toolbar"); |
40 | toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? | 42 | toolbar->setHorizontalStretchable( true ); |
41 | adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); | 43 | adduserToolButton = new QToolButton(Opie::Core::OResource::loadPixmap("usermanager/adduser", Opie::Core::OResource::SmallIcon), |
42 | edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); | 44 | "Add User",0,this,SLOT(addUser()),toolbar,"Add User"); |
43 | deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); | 45 | adduserToolButton->setUsesBigPixmap( useBigIcon ); |
44 | QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); | 46 | edituserToolButton = new QToolButton(Opie::Core::OResource::loadPixmap("usermanager/edituser", Opie::Core::OResource::SmallIcon), |
45 | userstext->setUsesTextLabel(true); | 47 | "Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); |
48 | edituserToolButton->setUsesBigPixmap( useBigIcon ); | ||
49 | deleteuserToolButton = new QToolButton(Opie::Core::OResource::loadPixmap("usermanager/deleteuser", Opie::Core::OResource::SmallIcon), | ||
50 | "Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); | ||
51 | deleteuserToolButton->setUsesBigPixmap( useBigIcon ); | ||
52 | //QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); | ||
53 | //userstext->setUsesTextLabel(true); | ||
46 | toolbar->addSeparator(); | 54 | toolbar->addSeparator(); |
47 | addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); | 55 | addgroupToolButton = new QToolButton(Opie::Core::OResource::loadPixmap("usermanager/addgroup", Opie::Core::OResource::SmallIcon), |
48 | editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); | 56 | "Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); |
49 | deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); | 57 | addgroupToolButton->setUsesBigPixmap( useBigIcon ); |
50 | QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); | 58 | editgroupToolButton = new QToolButton(Opie::Core::OResource::loadPixmap("usermanager/editgroup", Opie::Core::OResource::SmallIcon), |
51 | groupstext->setUsesTextLabel(true); | 59 | "Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); |
60 | editgroupToolButton->setUsesBigPixmap( useBigIcon ); | ||
61 | deletegroupToolButton = new QToolButton(Opie::Core::OResource::loadPixmap("usermanager/deletegroup", Opie::Core::OResource::SmallIcon), | ||
62 | "Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); | ||
63 | deletegroupToolButton->setUsesBigPixmap( useBigIcon ); | ||
64 | //QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); | ||
65 | //groupstext->setUsesTextLabel(true); | ||
52 | addToolBar(toolbar,"myToolBar"); | 66 | addToolBar(toolbar,"myToolBar"); |
53 | 67 | ||
54 | // Add a tabwidget and all the tabs. | 68 | // Add a tabwidget and all the tabs. |
55 | myTabWidget = new QTabWidget(this,"My Tab Widget"); | 69 | myTabWidget = new QTabWidget(this,"My Tab Widget"); |
56 | setupTabAccounts(); | 70 | setupTabAccounts(); |
57 | setupTabAllUsers(); | 71 | setupTabAllUsers(); |
58 | setupTabAllGroups(); | 72 | setupTabAllGroups(); |
59 | userPopupMenu.insertItem("Copy",0); | 73 | userPopupMenu.insertItem("Copy",0); |
60 | 74 | ||
61 | getUsers(); // Fill out the iconview & listview with all users. | 75 | getUsers(); // Fill out the iconview & listview with all users. |
62 | getGroups(); // Fill out the group listview with all groups. | 76 | getGroups(); // Fill out the group listview with all groups. |
63 | 77 | ||
64 | setCentralWidget(myTabWidget); | 78 | setCentralWidget(myTabWidget); |
65 | } | 79 | } |
66 | 80 | ||
67 | UserConfig::~UserConfig() { | 81 | UserConfig::~UserConfig() { |
68 | accounts->close(); | 82 | accounts->close(); |
69 | delete accounts; | 83 | delete accounts; |
70 | } | 84 | } |
71 | 85 | ||
72 | void UserConfig::setupTabAccounts() { | 86 | void UserConfig::setupTabAccounts() { |
73 | QWidget *tabpage = new QWidget(this); | 87 | QWidget *tabpage = new QWidget(this); |
74 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 88 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
75 | layout->setMargin(5); | 89 | layout->setMargin(5); |
76 | 90 | ||
77 | usersIconView=new QListView(tabpage,"users"); | 91 | usersIconView=new QListView(tabpage,"users"); |
78 | usersIconView->addColumn("Icon"); | 92 | usersIconView->addColumn("Icon"); |
79 | usersIconView->addColumn("Username"); | 93 | usersIconView->addColumn("Username"); |
80 | usersIconView->setAllColumnsShowFocus(true); | 94 | usersIconView->setAllColumnsShowFocus(true); |
81 | layout->addWidget(usersIconView); | 95 | layout->addWidget(usersIconView); |
82 | 96 | ||
83 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem*)),this,SLOT(showUserMenu(QListViewItem*))); | 97 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem*)),this,SLOT(showUserMenu(QListViewItem*))); |
84 | 98 | ||
85 | myTabWidget->addTab(tabpage,"Users"); | 99 | myTabWidget->addTab(tabpage,"Users"); |
86 | } | 100 | } |
87 | 101 | ||
88 | void UserConfig::setupTabAllUsers() { | 102 | void UserConfig::setupTabAllUsers() { |
89 | QWidget *tabpage = new QWidget(this); | 103 | QWidget *tabpage = new QWidget(this); |
90 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 104 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
91 | layout->setMargin(5); | 105 | layout->setMargin(5); |
92 | 106 | ||
93 | usersListView=new QListView(tabpage,"allusers"); | 107 | usersListView=new QListView(tabpage,"allusers"); |
94 | usersListView->addColumn("UID"); | 108 | usersListView->addColumn("UID"); |
95 | usersListView->addColumn("Login"); | 109 | usersListView->addColumn("Login"); |
96 | usersListView->addColumn("Username"); | 110 | usersListView->addColumn("Username"); |
97 | layout->addWidget(usersListView); | 111 | layout->addWidget(usersListView); |
98 | usersListView->setSorting(1,1); | 112 | usersListView->setSorting(1,1); |
99 | usersListView->setAllColumnsShowFocus(true); | 113 | usersListView->setAllColumnsShowFocus(true); |
100 | 114 | ||
101 | myTabWidget->addTab(tabpage,"All Users"); | 115 | myTabWidget->addTab(tabpage,"All Users"); |
102 | } | 116 | } |
103 | 117 | ||
104 | void UserConfig::setupTabAllGroups() { | 118 | void UserConfig::setupTabAllGroups() { |
105 | QWidget *tabpage = new QWidget(this); | 119 | QWidget *tabpage = new QWidget(this); |
106 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 120 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
107 | layout->setMargin(5); | 121 | layout->setMargin(5); |
108 | 122 | ||
109 | groupsListView=new QListView(tabpage,"groups"); | 123 | groupsListView=new QListView(tabpage,"groups"); |
110 | groupsListView->addColumn("GID"); | 124 | groupsListView->addColumn("GID"); |
111 | groupsListView->addColumn("Groupname"); | 125 | groupsListView->addColumn("Groupname"); |
112 | layout->addWidget(groupsListView); | 126 | layout->addWidget(groupsListView); |
113 | groupsListView->setSorting(1,1); | 127 | groupsListView->setSorting(1,1); |
114 | groupsListView->setAllColumnsShowFocus(true); | 128 | groupsListView->setAllColumnsShowFocus(true); |
115 | 129 | ||
116 | myTabWidget->addTab(tabpage,"All Groups"); | 130 | myTabWidget->addTab(tabpage,"All Groups"); |
117 | } | 131 | } |
118 | void UserConfig::getUsers() { | 132 | void UserConfig::getUsers() { |
119 | QString mytext; | 133 | QString mytext; |
120 | QPixmap mypixmap; | 134 | QPixmap mypixmap; |
121 | QListViewItem *listviewitem; | 135 | QListViewItem *listviewitem; |
122 | 136 | ||
123 | // Empty the iconview & the listview. | 137 | // Empty the iconview & the listview. |
124 | usersIconView->clear(); | 138 | usersIconView->clear(); |
125 | usersListView->clear(); | 139 | usersListView->clear(); |
126 | 140 | ||
127 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. | 141 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. |
128 | availableUID=500; | 142 | availableUID=500; |
129 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { | 143 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { |
130 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) | 144 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) |
131 | if(accounts->pw_name.find(QRegExp("^#"),0)) {// Skip commented lines. | 145 | if(accounts->pw_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
132 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); | 146 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); |
133 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? | 147 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? |
134 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. | 148 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. |
135 | 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. | 149 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { // Is there an icon for this user? Opie::Core::OResource::loadPixmap is caching, doesn't work. |
136 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. | 150 | mypixmap=Opie::Core::OResource::loadPixmap("usermanager/usericon", Opie::Core::OResource::SmallIcon);// If this user has no icon, load the default icon. |
137 | } | 151 | } |
138 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. | 152 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. |
139 | listviewitem->setPixmap(0,mypixmap); | 153 | listviewitem->setPixmap(0,mypixmap); |
140 | } | 154 | } |
141 | 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. | 155 | 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. |
142 | } | 156 | } |
143 | } | 157 | } |
144 | usersIconView->sort(); | 158 | usersIconView->sort(); |
145 | } | 159 | } |
146 | 160 | ||
147 | void UserConfig::addUser() { | 161 | void UserConfig::addUser() { |
148 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. | 162 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. |
149 | getUsers(); // Update users views. | 163 | getUsers(); // Update users views. |
150 | getGroups(); // Update groups view. | 164 | getGroups(); // Update groups view. |
151 | } | 165 | } |
152 | } | 166 | } |
153 | 167 | ||
154 | void UserConfig::editUser() { | 168 | void UserConfig::editUser() { |
155 | QString username; | 169 | QString username; |
156 | if(myTabWidget->currentPageIndex()==0) {// Users | 170 | if(myTabWidget->currentPageIndex()==0) {// Users |
157 | if(usersIconView->currentItem()) {// Any icon selected? | 171 | if(usersIconView->currentItem()) {// Any icon selected? |
158 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. | 172 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. |
159 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 173 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
160 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 174 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
161 | // If there were any changed also update the views. | 175 | // If there were any changed also update the views. |
162 | getUsers(); | 176 | getUsers(); |
163 | getGroups(); | 177 | getGroups(); |
164 | } | 178 | } |
165 | } else { | 179 | } else { |
166 | QMessageBox::information(this,"No selection.","No user has been selected."); | 180 | QMessageBox::information(this,"No selection.","No user has been selected."); |
167 | } | 181 | } |
168 | } | 182 | } |
169 | if(myTabWidget->currentPageIndex()==1) {// All users | 183 | if(myTabWidget->currentPageIndex()==1) {// All users |
170 | if(usersListView->currentItem()) {// Anything changed!? | 184 | if(usersListView->currentItem()) {// Anything changed!? |
171 | username=usersListView->currentItem()->text(1);// Get the username. | 185 | username=usersListView->currentItem()->text(1);// Get the username. |
172 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 186 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
173 | // And again update the views if there were any changes. | 187 | // And again update the views if there were any changes. |
174 | getUsers(); | 188 | getUsers(); |
175 | getGroups(); | 189 | getGroups(); |
176 | } | 190 | } |
177 | } else { | 191 | } else { |
178 | QMessageBox::information(this,"No selection.","No user has been selected."); | 192 | QMessageBox::information(this,"No selection.","No user has been selected."); |
179 | } | 193 | } |
180 | } | 194 | } |
181 | } | 195 | } |
182 | 196 | ||
183 | void UserConfig::delUser() { | 197 | void UserConfig::delUser() { |
184 | QString username; | 198 | QString username; |
185 | 199 | ||
186 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. | 200 | if(myTabWidget->currentPageIndex()==0) {// Users, Iconview. |
187 | if(usersIconView->currentItem()) {// Anything selected? | 201 | if(usersIconView->currentItem()) {// Anything selected? |
188 | username=usersIconView->currentItem()->text(1);// Get string associated with icon. | 202 | username=usersIconView->currentItem()->text(1);// Get string associated with icon. |
189 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 203 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
190 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { | 204 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { |
191 | if(UserDialog::delUser(username)) {// Delete the user if possible. | 205 | if(UserDialog::delUser(username)) {// Delete the user if possible. |
192 | // Update views. | 206 | // Update views. |
193 | getUsers(); | 207 | getUsers(); |
194 | getGroups(); | 208 | getGroups(); |
195 | } | 209 | } |
196 | } | 210 | } |
197 | } else { | 211 | } else { |
198 | QMessageBox::information(this,"No selection","No user has been selected."); | 212 | QMessageBox::information(this,"No selection","No user has been selected."); |
199 | } | 213 | } |
200 | } | 214 | } |
201 | if(myTabWidget->currentPageIndex()==1) {// All users | 215 | if(myTabWidget->currentPageIndex()==1) {// All users |
202 | if(usersListView->currentItem()) {// Anything changed!? | 216 | if(usersListView->currentItem()) {// Anything changed!? |
203 | username=usersListView->currentItem()->text(1);// Get the username. | 217 | username=usersListView->currentItem()->text(1);// Get the username. |
204 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { | 218 | if(QMessageBox::warning(this,"Delete user","Are you sure you want to\ndelete this user? \""+QString(username)+"\" ?","&No","&Yes",0,0,1)) { |
205 | if(UserDialog::delUser(username)) {// Try to delete the user. | 219 | if(UserDialog::delUser(username)) {// Try to delete the user. |
206 | // Update views. | 220 | // Update views. |
207 | getUsers(); | 221 | getUsers(); |
208 | getGroups(); | 222 | getGroups(); |
209 | } | 223 | } |
210 | } | 224 | } |
211 | } else { | 225 | } else { |
212 | QMessageBox::information(this,"No selection","No user has been selected."); | 226 | QMessageBox::information(this,"No selection","No user has been selected."); |
213 | } | 227 | } |
214 | } | 228 | } |
215 | 229 | ||
216 | } | 230 | } |
217 | 231 | ||
218 | void UserConfig::getGroups() { | 232 | void UserConfig::getGroups() { |
219 | groupsListView->clear();// Empty the listview. | 233 | groupsListView->clear();// Empty the listview. |
220 | availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. | 234 | availableGID=500;// We need to find the next free GID, and are only interested in values between 500 & 65000. |
221 | for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines. | 235 | for(QStringList::Iterator it=accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {// Split the list into lines. |
222 | accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem). | 236 | accounts->splitGroupEntry(*it);// Split the line into its components and fill the variables of 'accounts'. (gr_name, gr_uid & gr_mem). |
223 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. | 237 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
224 | new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name); | 238 | new QListViewItem(groupsListView,QString::number(accounts->gr_gid),accounts->gr_name); |
225 | if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID. | 239 | if((accounts->gr_gid>=availableGID) && (accounts->gr_gid<65000)) availableGID=accounts->gr_gid+1;// Maybe a new free GID. |
226 | } | 240 | } |
227 | } | 241 | } |
228 | } | 242 | } |
229 | 243 | ||
230 | void UserConfig::addGroup() { | 244 | void UserConfig::addGroup() { |
231 | if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog. | 245 | if(GroupDialog::addGroup(availableGID)) getGroups();// Bring up the add group dialog. |
232 | } | 246 | } |
233 | 247 | ||
234 | void UserConfig::editGroup() { | 248 | void UserConfig::editGroup() { |
235 | int gid; | 249 | int gid; |
236 | if(groupsListView->currentItem()) {// Any group selected? | 250 | if(groupsListView->currentItem()) {// Any group selected? |
237 | gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview. | 251 | gid=groupsListView->currentItem()->text(0).toInt();// Get the GID from the listview. |
238 | if(GroupDialog::editGroup(gid)) getGroups();// Bring up the edit group dialog. | 252 | if(GroupDialog::editGroup(gid)) getGroups();// Bring up the edit group dialog. |
239 | } else { | 253 | } else { |
240 | QMessageBox::information(this,"No selection","No group has been selected."); | 254 | QMessageBox::information(this,"No selection","No group has been selected."); |
241 | } | 255 | } |
242 | } | 256 | } |
243 | 257 | ||
244 | void UserConfig::delGroup() { | 258 | void UserConfig::delGroup() { |
245 | const char *groupname; | 259 | const char *groupname; |
246 | if(groupsListView->currentItem()) {// Any group selected? | 260 | if(groupsListView->currentItem()) {// Any group selected? |
247 | groupname=groupsListView->currentItem()->text(1);// Get the groupname from the listview. | 261 | groupname=groupsListView->currentItem()->text(1);// Get the groupname from the listview. |
248 | if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) { | 262 | if(QMessageBox::warning(this,"Delete group","Are you sure you want to\ndelete the group \""+QString(groupname)+"\" ?","&No","&Yes",0,0,1)) { |
249 | // If confirmed, try to delete the group. | 263 | // If confirmed, try to delete the group. |
250 | if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted. | 264 | if(GroupDialog::delGroup(groupname)) getGroups(); // And also update the view afterwards if the user was deleted. |
251 | } | 265 | } |
252 | } else { | 266 | } else { |
253 | QMessageBox::information(this,"No selection","No group has been selected."); | 267 | QMessageBox::information(this,"No selection","No group has been selected."); |
254 | } | 268 | } |
255 | } | 269 | } |
256 | 270 | ||
257 | void UserConfig::showUserMenu(QListViewItem *item) { | 271 | void UserConfig::showUserMenu(QListViewItem *item) { |
258 | //userPopupMenu.exec(item->mapToGlobal(QPoint(0,0))); | 272 | //userPopupMenu.exec(item->mapToGlobal(QPoint(0,0))); |
259 | owarn << "Pressed!" << oendl; | 273 | owarn << "Pressed!" << oendl; |
260 | } | 274 | } |