-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 968 | ||||
-rw-r--r-- | noncore/settings/appearance2/stylelistitem.h | 12 | ||||
-rw-r--r-- | noncore/settings/aqpkg/categoryfilterimpl.cpp | 28 | ||||
-rw-r--r-- | noncore/settings/aqpkg/instoptionsimpl.cpp | 44 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 176 | ||||
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 243 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 17 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/devices.cpp | 25 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 1783 | ||||
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 88 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 76 | ||||
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 743 |
12 files changed, 2197 insertions, 2006 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 9e5eede..ba12e55 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -22,16 +22,40 @@ | |||
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "appearance.h" | ||
31 | #include "editScheme.h" | ||
32 | #include "stylelistitem.h" | ||
33 | #include "decolistitem.h" | ||
34 | #include "colorlistitem.h" | ||
35 | #include "exceptlistitem.h" | ||
36 | #include "sample.h" | ||
37 | |||
38 | /* OPIE */ | ||
39 | #include <opie/ofontselector.h> | ||
40 | #include <opie/odevice.h> | ||
41 | #include <opie/ofiledialog.h> | ||
42 | #include <opie/otabwidget.h> | ||
43 | |||
44 | #include <qpe/config.h> | ||
45 | #include <qpe/global.h> | ||
46 | #include <qpe/qpeapplication.h> | ||
47 | #include <qpe/qpemessagebox.h> | ||
48 | #include <qpe/qcopenvelope_qws.h> | ||
49 | #include <qpe/qpestyle.h> | ||
50 | #include <qpe/lightstyle.h> | ||
51 | #include <qpe/styleinterface.h> | ||
52 | |||
53 | /* QT */ | ||
30 | #include <qbuttongroup.h> | 54 | #include <qbuttongroup.h> |
31 | #include <qcheckbox.h> | 55 | #include <qcheckbox.h> |
32 | #include <qcombobox.h> | 56 | #include <qcombobox.h> |
33 | #include <qdialog.h> | 57 | #include <qdialog.h> |
34 | #include <qdir.h> | 58 | #include <qdir.h> |
35 | #include <qlabel.h> | 59 | #include <qlabel.h> |
36 | #include <qlayout.h> | 60 | #include <qlayout.h> |
37 | #include <qlineedit.h> | 61 | #include <qlineedit.h> |
@@ -44,813 +68,823 @@ | |||
44 | #endif | 68 | #endif |
45 | #include <qtoolbutton.h> | 69 | #include <qtoolbutton.h> |
46 | #include <qwindowsstyle.h> | 70 | #include <qwindowsstyle.h> |
47 | #include <qlistview.h> | 71 | #include <qlistview.h> |
48 | #include <qheader.h> | 72 | #include <qheader.h> |
49 | #include <qvbox.h> | 73 | #include <qvbox.h> |
50 | #include <qwhatsthis.h> | 74 | #include <qwhatsthis.h> |
51 | 75 | ||
52 | #include <qpe/config.h> | ||
53 | #include <qpe/global.h> | ||
54 | #include <qpe/resource.h> | ||
55 | #include <qpe/qpeapplication.h> | ||
56 | #include <qpe/qpemessagebox.h> | ||
57 | #include <qpe/qcopenvelope_qws.h> | ||
58 | #include <qpe/qpestyle.h> | ||
59 | #include <qpe/lightstyle.h> | ||
60 | #include <qpe/qlibrary.h> | ||
61 | #include <qpe/styleinterface.h> | ||
62 | |||
63 | #include <opie/ofontselector.h> | ||
64 | #include <opie/odevice.h> | ||
65 | #include <opie/ofiledialog.h> | ||
66 | #include <opie/otabwidget.h> | ||
67 | |||
68 | #include "appearance.h" | ||
69 | #include "editScheme.h" | ||
70 | #include "stylelistitem.h" | ||
71 | #include "decolistitem.h" | ||
72 | #include "colorlistitem.h" | ||
73 | #include "exceptlistitem.h" | ||
74 | #include "sample.h" | ||
75 | |||
76 | |||
77 | using namespace Opie; | 76 | using namespace Opie; |
78 | 77 | ||
79 | 78 | ||
80 | class DefaultWindowDecoration : public WindowDecorationInterface | 79 | class DefaultWindowDecoration : public WindowDecorationInterface |
81 | { | 80 | { |
82 | public: | 81 | public: |
83 | DefaultWindowDecoration() : ref(0) {} | 82 | DefaultWindowDecoration() : ref(0) {} |
84 | QString name() const { | 83 | QString name() const |
85 | return "Default"; | 84 | { |
85 | return "Default"; | ||
86 | } | 86 | } |
87 | QPixmap icon() const { | 87 | QPixmap icon() const |
88 | return QPixmap(); | 88 | { |
89 | return QPixmap(); | ||
89 | } | 90 | } |
90 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 91 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
91 | *iface = 0; | 92 | { |
92 | if ( uuid == IID_QUnknown ) | 93 | *iface = 0; |
93 | *iface = this; | 94 | if ( uuid == IID_QUnknown ) |
94 | else if ( uuid == IID_WindowDecoration ) | 95 | *iface = this; |
95 | *iface = this; | 96 | else if ( uuid == IID_WindowDecoration ) |
96 | 97 | *iface = this; | |
97 | if ( *iface ) | 98 | |
98 | (*iface)->addRef(); | 99 | if ( *iface ) |
99 | return QS_OK; | 100 | (*iface)->addRef(); |
101 | return QS_OK; | ||
100 | } | 102 | } |
101 | Q_REFCOUNT | 103 | Q_REFCOUNT |
102 | 104 | ||
103 | private: | 105 | private: |
104 | ulong ref; | 106 | ulong ref; |
105 | }; | 107 | }; |
106 | 108 | ||
107 | 109 | ||
108 | 110 | ||
109 | 111 | ||
110 | 112 | ||
111 | 113 | ||
112 | 114 | ||
113 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) | 115 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) |
114 | { | 116 | { |
115 | QWidget* tab = new QWidget( parent, "StyleTab" ); | 117 | QWidget* tab = new QWidget( parent, "StyleTab" ); |
116 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | 118 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
117 | 119 | ||
118 | m_style_list = new QListBox( tab, "m_style_list" ); | 120 | m_style_list = new QListBox( tab, "m_style_list" ); |
119 | vertLayout->addWidget( m_style_list ); | 121 | vertLayout->addWidget( m_style_list ); |
120 | QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) ); | 122 | QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) ); |
121 | 123 | ||
122 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); | 124 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); |
123 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); | 125 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); |
124 | vertLayout-> addWidget ( m_style_settings ); | 126 | vertLayout-> addWidget ( m_style_settings ); |
125 | QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) ); | 127 | QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) ); |
126 | 128 | ||
127 | QString s = cfg. readEntry ( "Style", "Light" ); | 129 | QString s = cfg. readEntry ( "Style", "Light" ); |
128 | 130 | ||
129 | 131 | ||
130 | #if QT_VERSION >= 300 | 132 | #if QT_VERSION >= 300 |
131 | m_style_list->insertStringList(QStyleFactory::styles()); | 133 | m_style_list->insertStringList(QStyleFactory::styles()); |
132 | #else | 134 | #else |
133 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); | 135 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); |
134 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); | 136 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); |
135 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); | 137 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); |
136 | #endif | 138 | #endif |
137 | { | 139 | |
138 | QString path = QPEApplication::qpeDir ( ); | 140 | { |
139 | path.append( "/plugins/styles/" ); | 141 | QString path = QPEApplication::qpeDir ( ); |
140 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 142 | path.append( "/plugins/styles/" ); |
141 | 143 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | |
142 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 144 | |
143 | QString libstr = path; | 145 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
144 | libstr.append( "/" ); | 146 | { |
145 | libstr.append( *it ); | 147 | QString libstr = path; |
146 | QLibrary *lib = new QLibrary ( libstr ); | 148 | libstr.append( "/" ); |
147 | StyleInterface *iface; | 149 | libstr.append( *it ); |
148 | 150 | QLibrary *lib = new QLibrary ( libstr ); | |
149 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { | 151 | StyleInterface *iface; |
150 | StyleListItem *slit = new StyleListItem ( lib, iface ); | 152 | |
151 | m_style_list-> insertItem ( slit ); | 153 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) |
152 | 154 | { | |
153 | if ( slit-> key ( ) == s ) | 155 | StyleListItem *slit = new StyleListItem ( lib, iface ); |
154 | m_style_list-> setCurrentItem ( slit ); | 156 | m_style_list-> insertItem ( slit ); |
155 | } | 157 | |
156 | else | 158 | if ( slit-> key ( ) == s ) |
157 | delete lib; | 159 | m_style_list-> setCurrentItem ( slit ); |
158 | } | 160 | } |
159 | } | 161 | else |
162 | delete lib; | ||
163 | } | ||
164 | } | ||
160 | 165 | ||
161 | m_original_style = m_style_list-> currentItem ( ); | 166 | m_original_style = m_style_list-> currentItem ( ); |
162 | styleClicked ( m_original_style ); | 167 | styleClicked ( m_original_style ); |
163 | 168 | ||
164 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); | 169 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); |
165 | 170 | ||
166 | return tab; | 171 | return tab; |
167 | } | 172 | } |
168 | 173 | ||
169 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) | 174 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) |
170 | { | 175 | { |
171 | QWidget* tab = new QWidget( parent, "DecoTab" ); | 176 | QWidget* tab = new QWidget( parent, "DecoTab" ); |
172 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | 177 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
173 | 178 | ||
174 | m_deco_list = new QListBox( tab, "m_deco_list" ); | 179 | m_deco_list = new QListBox( tab, "m_deco_list" ); |
175 | vertLayout->addWidget( m_deco_list ); | 180 | vertLayout->addWidget( m_deco_list ); |
176 | QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) ); | 181 | QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) ); |
177 | 182 | ||
178 | QString s = cfg. readEntry ( "Decoration", "libflat.so" ); | 183 | QString s = cfg. readEntry ( "Decoration", "libflat.so" ); |
179 | 184 | ||
180 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); | 185 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); |
181 | 186 | ||
182 | { | 187 | { |
183 | QString path = QPEApplication::qpeDir(); | 188 | QString path = QPEApplication::qpeDir(); |
184 | path.append( "/plugins/decorations/" ); | 189 | path.append( "/plugins/decorations/" ); |
185 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 190 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
186 | 191 | ||
187 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 192 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
188 | QString libstr = path; | 193 | { |
189 | libstr.append( "/" ); | 194 | QString libstr = path; |
190 | libstr.append( *it ); | 195 | libstr.append( "/" ); |
191 | QLibrary *lib = new QLibrary ( libstr ); | 196 | libstr.append( *it ); |
192 | WindowDecorationInterface *iface; | 197 | QLibrary *lib = new QLibrary ( libstr ); |
193 | 198 | WindowDecorationInterface *iface; | |
194 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { | 199 | |
195 | DecoListItem *dlit = new DecoListItem ( lib, iface ); | 200 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) |
196 | m_deco_list-> insertItem ( dlit ); | 201 | { |
197 | 202 | DecoListItem *dlit = new DecoListItem ( lib, iface ); | |
198 | if ( dlit-> key ( ) == s ) | 203 | m_deco_list-> insertItem ( dlit ); |
199 | m_deco_list-> setCurrentItem ( dlit ); | 204 | |
200 | } | 205 | if ( dlit-> key ( ) == s ) |
201 | else | 206 | m_deco_list-> setCurrentItem ( dlit ); |
202 | delete lib; | 207 | } |
203 | } | 208 | else |
204 | } | 209 | delete lib; |
210 | } | ||
211 | } | ||
205 | 212 | ||
206 | m_original_deco = m_deco_list-> currentItem ( ); | 213 | m_original_deco = m_deco_list-> currentItem ( ); |
207 | if ( m_deco_list-> currentItem ( ) < 0 ) | 214 | if ( m_deco_list-> currentItem ( ) < 0 ) |
208 | m_deco_list-> setCurrentItem ( 0 ); | 215 | m_deco_list-> setCurrentItem ( 0 ); |
209 | decoClicked ( m_original_deco ); | 216 | decoClicked ( m_original_deco ); |
210 | 217 | ||
211 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); | 218 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); |
212 | 219 | ||
213 | return tab; | 220 | return tab; |
214 | } | 221 | } |
215 | 222 | ||
216 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) | 223 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) |
217 | { | 224 | { |
218 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); | 225 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); |
219 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); | 226 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); |
220 | int size = cfg. readNumEntry ( "FontSize", 10 ); | 227 | int size = cfg. readNumEntry ( "FontSize", 10 ); |
221 | 228 | ||
222 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); | 229 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); |
223 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); | 230 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); |
224 | QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); | 231 | QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); |
225 | 232 | ||
226 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), | 233 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), |
227 | this, SLOT( fontClicked ( const QFont & ))); | 234 | this, SLOT( fontClicked ( const QFont & ))); |
228 | 235 | ||
229 | return m_fontselect; | 236 | return m_fontselect; |
230 | } | 237 | } |
231 | 238 | ||
232 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) | 239 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) |
233 | { | 240 | { |
234 | QWidget *tab = new QWidget( parent, "ColorTab" ); | 241 | QWidget *tab = new QWidget( parent, "ColorTab" ); |
235 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); | 242 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); |
236 | gridLayout->setRowStretch ( 3, 10 ); | 243 | gridLayout->setRowStretch ( 3, 10 ); |
237 | 244 | ||
238 | m_color_list = new QListBox ( tab ); | 245 | m_color_list = new QListBox ( tab ); |
239 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); | 246 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); |
240 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); | 247 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); |
241 | QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) ); | 248 | QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) ); |
242 | 249 | ||
243 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); | 250 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); |
244 | 251 | ||
245 | QString path = QPEApplication::qpeDir ( ); | 252 | QString path = QPEApplication::qpeDir ( ); |
246 | path.append( "/etc/colors/" ); | 253 | path.append( "/etc/colors/" ); |
247 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | 254 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); |
248 | 255 | ||
249 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 256 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
250 | QString name = (*it). left ((*it). find ( ".scheme" )); | 257 | { |
251 | QString pathstr = path; | 258 | QString name = (*it). left ((*it). find ( ".scheme" )); |
252 | pathstr.append( *it ); | 259 | QString pathstr = path; |
253 | Config config ( pathstr, Config::File ); | 260 | pathstr.append( *it ); |
254 | config. setGroup ( "Colors" ); | 261 | Config config ( pathstr, Config::File ); |
262 | config. setGroup ( "Colors" ); | ||
255 | 263 | ||
256 | m_color_list-> insertItem ( new ColorListItem ( name, config )); | 264 | m_color_list-> insertItem ( new ColorListItem ( name, config )); |
257 | } | 265 | } |
258 | 266 | ||
259 | m_color_list-> setCurrentItem ( 0 ); | 267 | m_color_list-> setCurrentItem ( 0 ); |
260 | 268 | ||
261 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); | 269 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); |
262 | tempButton->setText( tr( "Edit..." ) ); | 270 | tempButton->setText( tr( "Edit..." ) ); |
263 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); | 271 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); |
264 | gridLayout->addWidget( tempButton, 0, 1 ); | 272 | gridLayout->addWidget( tempButton, 0, 1 ); |
265 | QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); | 273 | QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); |
266 | 274 | ||
267 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); | 275 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); |
268 | tempButton->setText( tr( "Delete" ) ); | 276 | tempButton->setText( tr( "Delete" ) ); |
269 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); | 277 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); |
270 | gridLayout->addWidget( tempButton, 1, 1 ); | 278 | gridLayout->addWidget( tempButton, 1, 1 ); |
271 | QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); | 279 | QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); |
272 | 280 | ||
273 | tempButton = new QPushButton( tab, "saveSchemeButton" ); | 281 | tempButton = new QPushButton( tab, "saveSchemeButton" ); |
274 | tempButton->setText( tr( "Save" ) ); | 282 | tempButton->setText( tr( "Save" ) ); |
275 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); | 283 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); |
276 | gridLayout->addWidget( tempButton, 2, 1 ); | 284 | gridLayout->addWidget( tempButton, 2, 1 ); |
277 | QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); | 285 | QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); |
278 | 286 | ||
279 | return tab; | 287 | return tab; |
280 | } | 288 | } |
281 | 289 | ||
282 | QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) | 290 | QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) |
283 | { | 291 | { |
284 | QWidget *tab = new QWidget ( parent ); | 292 | QWidget *tab = new QWidget ( parent ); |
285 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); | 293 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); |
286 | 294 | ||
287 | QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); | 295 | QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); |
288 | 296 | ||
289 | m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); | 297 | m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); |
290 | m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); | 298 | m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); |
291 | lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); | 299 | lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); |
292 | QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) ); | 300 | QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) ); |
293 | 301 | ||
294 | QLabel *l = new QLabel ( tab ); | 302 | QLabel *l = new QLabel ( tab ); |
295 | l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); | 303 | l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); |
296 | lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); | 304 | lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); |
297 | QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); | 305 | QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); |
298 | 306 | ||
299 | m_except = new QListView ( tab ); | 307 | m_except = new QListView ( tab ); |
300 | m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 ); | 308 | m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 ); |
301 | m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 ); | 309 | m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 ); |
302 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 ); | 310 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 ); |
303 | m_except-> addColumn ( tr( "Binary file(s)" )); | 311 | m_except-> addColumn ( tr( "Binary file(s)" )); |
304 | m_except-> setColumnAlignment ( 0, AlignCenter ); | 312 | m_except-> setColumnAlignment ( 0, AlignCenter ); |
305 | m_except-> setColumnAlignment ( 1, AlignCenter ); | 313 | m_except-> setColumnAlignment ( 1, AlignCenter ); |
306 | m_except-> setColumnAlignment ( 2, AlignCenter ); | 314 | m_except-> setColumnAlignment ( 2, AlignCenter ); |
307 | m_except-> setAllColumnsShowFocus ( true ); | 315 | m_except-> setAllColumnsShowFocus ( true ); |
308 | m_except-> setMinimumHeight ( 30 ); | 316 | m_except-> setMinimumHeight ( 30 ); |
309 | m_except-> header ( )-> setClickEnabled ( false ); | 317 | m_except-> header ( )-> setClickEnabled ( false ); |
310 | m_except-> header ( )-> setResizeEnabled ( false ); | 318 | m_except-> header ( )-> setResizeEnabled ( false ); |
311 | m_except-> header ( )-> setMovingEnabled ( false ); | 319 | m_except-> header ( )-> setMovingEnabled ( false ); |
312 | m_except-> setSorting ( -1 ); | 320 | m_except-> setSorting ( -1 ); |
313 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); | 321 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); |
314 | QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); | 322 | QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); |
315 | 323 | ||
316 | connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); | 324 | connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); |
317 | 325 | ||
318 | QToolButton *tb = new QToolButton ( tab ); | 326 | QToolButton *tb = new QToolButton ( tab ); |
319 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); | 327 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); |
320 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 328 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
321 | lay-> addWidget ( tb, 2, 1 ); | 329 | lay-> addWidget ( tb, 2, 1 ); |
322 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); | 330 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); |
323 | QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); | 331 | QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); |
324 | 332 | ||
325 | tb = new QToolButton ( tab ); | 333 | tb = new QToolButton ( tab ); |
326 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); | 334 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); |
327 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 335 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
328 | lay-> addWidget ( tb, 3, 1 ); | 336 | lay-> addWidget ( tb, 3, 1 ); |
329 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); | 337 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); |
330 | QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); | 338 | QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); |
331 | 339 | ||
332 | tb = new QToolButton ( tab ); | 340 | tb = new QToolButton ( tab ); |
333 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); | 341 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); |
334 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 342 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
335 | lay-> addWidget ( tb, 4, 1 ); | 343 | lay-> addWidget ( tb, 4, 1 ); |
336 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); | 344 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); |
337 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); | 345 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); |
338 | 346 | ||
339 | tb = new QToolButton ( tab ); | 347 | tb = new QToolButton ( tab ); |
340 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); | 348 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); |
341 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 349 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
342 | lay-> addWidget ( tb, 5, 1 ); | 350 | lay-> addWidget ( tb, 5, 1 ); |
343 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); | 351 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); |
344 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); | 352 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); |
345 | 353 | ||
346 | lay-> setRowStretch ( 6, 10 ); | 354 | lay-> setRowStretch ( 6, 10 ); |
347 | lay-> setColStretch ( 0, 10 ); | 355 | lay-> setColStretch ( 0, 10 ); |
348 | 356 | ||
349 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); | 357 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); |
350 | QListViewItem *lvit = 0; | 358 | QListViewItem *lvit = 0; |
351 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 359 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
352 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 360 | { |
353 | 361 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); | |
354 | lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); | 362 | |
355 | } | 363 | lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); |
356 | 364 | } | |
357 | 365 | ||
358 | vertLayout-> addSpacing ( 3 ); | 366 | |
359 | QFrame *f = new QFrame ( tab ); | 367 | vertLayout-> addSpacing ( 3 ); |
360 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); | 368 | QFrame *f = new QFrame ( tab ); |
361 | vertLayout-> addWidget ( f ); | 369 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); |
362 | vertLayout-> addSpacing ( 3 ); | 370 | vertLayout-> addWidget ( f ); |
371 | vertLayout-> addSpacing ( 3 ); | ||
363 | 372 | ||
364 | 373 | ||
365 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); | 374 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); |
366 | 375 | ||
367 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; | 376 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; |
368 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); | 377 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); |
369 | 378 | ||
370 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); | 379 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); |
371 | gridLayout-> addWidget ( label, 0, 0 ); | 380 | gridLayout-> addWidget ( label, 0, 0 ); |
372 | QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); | 381 | QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); |
373 | 382 | ||
374 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); | 383 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); |
375 | btngrp-> hide ( ); | 384 | btngrp-> hide ( ); |
376 | btngrp-> setExclusive ( true ); | 385 | btngrp-> setExclusive ( true ); |
377 | 386 | ||
378 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); | 387 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); |
379 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); | 388 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); |
380 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); | 389 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); |
381 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); | 390 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); |
382 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); | 391 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); |
383 | m_tabstyle_list-> setCurrentItem ( style ); | 392 | m_tabstyle_list-> setCurrentItem ( style ); |
384 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); | 393 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); |
385 | QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); | 394 | QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); |
386 | 395 | ||
387 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); | 396 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); |
388 | btngrp-> insert ( m_tabstyle_top ); | 397 | btngrp-> insert ( m_tabstyle_top ); |
389 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); | 398 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); |
390 | QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); | 399 | QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); |
391 | 400 | ||
392 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); | 401 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); |
393 | btngrp-> insert ( m_tabstyle_bottom ); | 402 | btngrp-> insert ( m_tabstyle_bottom ); |
394 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); | 403 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); |
395 | QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); | 404 | QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); |
396 | 405 | ||
397 | m_tabstyle_top-> setChecked ( tabtop ); | 406 | m_tabstyle_top-> setChecked ( tabtop ); |
398 | m_tabstyle_bottom-> setChecked ( !tabtop ); | 407 | m_tabstyle_bottom-> setChecked ( !tabtop ); |
399 | 408 | ||
400 | m_original_tabstyle = style; | 409 | m_original_tabstyle = style; |
401 | m_original_tabpos = tabtop; | 410 | m_original_tabpos = tabtop; |
402 | 411 | ||
403 | vertLayout-> addSpacing ( 3 ); | 412 | vertLayout-> addSpacing ( 3 ); |
404 | QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); | 413 | QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); |
405 | 414 | ||
406 | QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); | 415 | QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); |
407 | m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); | 416 | m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); |
408 | QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); | 417 | QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); |
409 | m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); | 418 | m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); |
410 | QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); | 419 | QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); |
411 | QPixmap ccw1; | 420 | QPixmap ccw1; |
412 | m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); | 421 | m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); |
413 | QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); | 422 | QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); |
414 | QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); | 423 | QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); |
415 | 424 | ||
416 | rotbtngrp-> hide ( ); | 425 | rotbtngrp-> hide ( ); |
417 | rotbtngrp-> setExclusive ( true ); | 426 | rotbtngrp-> setExclusive ( true ); |
418 | rotbtngrp-> insert ( m_rotdir_cw ); | 427 | rotbtngrp-> insert ( m_rotdir_cw ); |
419 | rotbtngrp-> insert ( m_rotdir_ccw ); | 428 | rotbtngrp-> insert ( m_rotdir_ccw ); |
420 | rotbtngrp-> insert ( m_rotdir_flip ); | 429 | rotbtngrp-> insert ( m_rotdir_flip ); |
421 | 430 | ||
422 | ccw1. convertFromImage( ccwImage ); | 431 | ccw1. convertFromImage( ccwImage ); |
423 | m_rotdir_cw-> setPixmap( cw1 ); | 432 | m_rotdir_cw-> setPixmap( cw1 ); |
424 | m_rotdir_ccw-> setPixmap( ccw1 ); | 433 | m_rotdir_ccw-> setPixmap( ccw1 ); |
425 | m_rotdir_flip-> setPixmap( flip1 ); | 434 | m_rotdir_flip-> setPixmap( flip1 ); |
426 | 435 | ||
427 | rotLay-> addWidget ( rotlabel, 0 ); | 436 | rotLay-> addWidget ( rotlabel, 0 ); |
428 | rotLay-> addWidget ( m_rotdir_cw, 0 ); | 437 | rotLay-> addWidget ( m_rotdir_cw, 0 ); |
429 | rotLay-> addWidget ( m_rotdir_ccw, 0 ); | 438 | rotLay-> addWidget ( m_rotdir_ccw, 0 ); |
430 | rotLay-> addWidget ( m_rotdir_flip, 0 ); | 439 | rotLay-> addWidget ( m_rotdir_flip, 0 ); |
431 | 440 | ||
432 | int rotDirection = cfg.readNumEntry( "rotatedir" ); | 441 | int rotDirection = cfg.readNumEntry( "rotatedir" ); |
433 | ODirection rot = CW; | 442 | ODirection rot = CW; |
434 | 443 | ||
435 | if (rotDirection == -1) { | 444 | if (rotDirection == -1) |
436 | rot = ODevice::inst ( )-> direction ( ); | 445 | { |
437 | } else { | 446 | rot = ODevice::inst ( )-> direction ( ); |
438 | rot = (ODirection)rotDirection; | 447 | } |
439 | } | 448 | else |
440 | 449 | { | |
441 | m_rotdir_cw-> setChecked ( rot == CW ); | 450 | rot = (ODirection)rotDirection; |
442 | m_rotdir_ccw-> setChecked ( rot == CCW ); | 451 | } |
443 | m_rotdir_flip-> setChecked ( rot == Flip ); | 452 | |
444 | 453 | m_rotdir_cw-> setChecked ( rot == CW ); | |
445 | return tab; | 454 | m_rotdir_ccw-> setChecked ( rot == CCW ); |
455 | m_rotdir_flip-> setChecked ( rot == Flip ); | ||
456 | |||
457 | return tab; | ||
446 | } | 458 | } |
447 | 459 | ||
448 | 460 | ||
449 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) | 461 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) |
450 | : QDialog ( parent, name, true, WStyle_ContextHelp ) | 462 | : QDialog ( parent, name, true, WStyle_ContextHelp ) |
451 | { | 463 | { |
452 | setCaption( tr( "Appearance Settings" ) ); | 464 | setCaption( tr( "Appearance Settings" ) ); |
453 | 465 | ||
454 | Config config( "qpe" ); | 466 | Config config( "qpe" ); |
455 | config.setGroup( "Appearance" ); | 467 | config.setGroup( "Appearance" ); |
456 | 468 | ||
457 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); | 469 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); |
458 | 470 | ||
459 | m_sample = new SampleWindow ( this ); | 471 | m_sample = new SampleWindow ( this ); |
460 | 472 | ||
461 | m_sample-> setDecoration ( new DefaultWindowDecoration ( ) ); | 473 | m_sample-> setDecoration ( new DefaultWindowDecoration ( ) ); |
462 | QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); | 474 | QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); |
463 | 475 | ||
464 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 476 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
465 | QWidget *styletab; | 477 | QWidget *styletab; |
466 | 478 | ||
467 | m_color_list = 0; | 479 | m_color_list = 0; |
468 | 480 | ||
469 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); | 481 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); |
470 | tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); | 482 | tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); |
471 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); | 483 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); |
472 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); | 484 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); |
473 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); | 485 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); |
474 | 486 | ||
475 | top-> addWidget ( tw, 10 ); | 487 | top-> addWidget ( tw, 10 ); |
476 | top-> addWidget ( m_sample, 1 ); | 488 | top-> addWidget ( m_sample, 1 ); |
477 | 489 | ||
478 | tw-> setCurrentTab ( styletab ); | 490 | tw-> setCurrentTab ( styletab ); |
479 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); | 491 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); |
480 | 492 | ||
481 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; | 493 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; |
482 | } | 494 | } |
483 | 495 | ||
484 | Appearance::~Appearance() | 496 | Appearance::~Appearance() |
485 | { | 497 | {} |
486 | } | ||
487 | 498 | ||
488 | void Appearance::tabChanged ( QWidget *w ) | 499 | void Appearance::tabChanged ( QWidget *w ) |
489 | { | 500 | { |
490 | if ( w == m_advtab ) { | 501 | if ( w == m_advtab ) |
491 | m_sample-> hide ( ); | 502 | { |
492 | updateGeometry ( ); // shouldn't be necessary ... | 503 | m_sample-> hide ( ); |
493 | } | 504 | updateGeometry ( ); // shouldn't be necessary ... |
494 | else | 505 | } |
495 | m_sample-> show ( ); | 506 | else |
507 | m_sample-> show ( ); | ||
496 | } | 508 | } |
497 | 509 | ||
498 | void Appearance::accept ( ) | 510 | void Appearance::accept ( ) |
499 | { | 511 | { |
500 | bool newtabpos = m_tabstyle_top-> isChecked ( ); | 512 | bool newtabpos = m_tabstyle_top-> isChecked ( ); |
501 | int newtabstyle = m_tabstyle_list-> currentItem ( ); | 513 | int newtabstyle = m_tabstyle_list-> currentItem ( ); |
502 | 514 | ||
503 | Config config ( "qpe" ); | 515 | Config config ( "qpe" ); |
504 | config. setGroup ( "Appearance" ); | 516 | config. setGroup ( "Appearance" ); |
505 | 517 | ||
506 | if ( m_style_changed ) { | 518 | if ( m_style_changed ) |
507 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 519 | { |
508 | if ( item ) | 520 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
521 | if ( item ) | ||
509 | config.writeEntry( "Style", item-> key ( )); | 522 | config.writeEntry( "Style", item-> key ( )); |
510 | } | 523 | } |
511 | 524 | ||
512 | if ( m_deco_changed ) { | 525 | if ( m_deco_changed ) |
513 | DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); | 526 | { |
514 | if ( item ) | 527 | DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); |
528 | if ( item ) | ||
515 | config.writeEntry( "Decoration", item-> key ( )); | 529 | config.writeEntry( "Decoration", item-> key ( )); |
516 | } | 530 | } |
517 | 531 | ||
518 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { | 532 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) |
519 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); | 533 | { |
520 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); | 534 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); |
521 | } | 535 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); |
536 | } | ||
522 | 537 | ||
523 | if ( m_font_changed ) { | 538 | if ( m_font_changed ) |
539 | { | ||
524 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); | 540 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); |
525 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); | 541 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); |
526 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); | 542 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); |
527 | } | 543 | } |
528 | 544 | ||
529 | 545 | ||
530 | if ( m_color_changed ) | 546 | if ( m_color_changed ) |
531 | { | 547 | { |
532 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 548 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
533 | 549 | ||
534 | if ( item ) | 550 | if ( item ) |
535 | item-> save ( config ); | 551 | item-> save ( config ); |
536 | } | 552 | } |
537 | 553 | ||
538 | ODirection rot; | 554 | ODirection rot; |
539 | if (m_rotdir_ccw-> isChecked ( )) { | 555 | if (m_rotdir_ccw-> isChecked ( )) |
540 | rot = CCW; | 556 | { |
541 | } else if (m_rotdir_cw-> isChecked ( )) { | 557 | rot = CCW; |
542 | rot = CW; | 558 | } |
543 | } else { | 559 | else if (m_rotdir_cw-> isChecked ( )) |
544 | rot = Flip; | 560 | { |
545 | } | 561 | rot = CW; |
546 | config. writeEntry ( "rotatedir", (int)rot ); | 562 | } |
547 | 563 | else | |
548 | m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated | 564 | { |
549 | 565 | rot = Flip; | |
550 | QStringList sl; | 566 | } |
551 | QString exceptstr; | 567 | config. writeEntry ( "rotatedir", (int)rot ); |
552 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { | 568 | |
553 | int fl = 0; | 569 | m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated |
554 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); | 570 | |
555 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); | 571 | QStringList sl; |
556 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); | 572 | QString exceptstr; |
557 | exceptstr = QString::number ( fl, 32 ); | 573 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) |
558 | exceptstr.append( it-> pattern ( )); | 574 | { |
559 | sl << exceptstr; | 575 | int fl = 0; |
560 | } | 576 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); |
561 | config. writeEntry ( "NoStyle", sl, ';' ); | 577 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); |
562 | config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); | 578 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); |
563 | 579 | exceptstr = QString::number ( fl, 32 ); | |
564 | config. write ( ); // need to flush the config info first | 580 | exceptstr.append( it-> pattern ( )); |
565 | Global::applyStyle ( ); | 581 | sl << exceptstr; |
566 | 582 | } | |
567 | QDialog::accept ( ); | 583 | config. writeEntry ( "NoStyle", sl, ';' ); |
584 | config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); | ||
585 | |||
586 | config. write ( ); // need to flush the config info first | ||
587 | Global::applyStyle ( ); | ||
588 | |||
589 | QDialog::accept ( ); | ||
568 | } | 590 | } |
569 | 591 | ||
570 | void Appearance::done ( int r ) | 592 | void Appearance::done ( int r ) |
571 | { | 593 | { |
572 | QDialog::done ( r ); | 594 | QDialog::done ( r ); |
573 | close ( ); | 595 | close ( ); |
574 | } | 596 | } |
575 | 597 | ||
576 | 598 | ||
577 | void Appearance::styleClicked ( int index ) | 599 | void Appearance::styleClicked ( int index ) |
578 | { | 600 | { |
579 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); | 601 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); |
580 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); | 602 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); |
581 | 603 | ||
582 | if ( m_sample && sli && sli-> style ( )) { | 604 | if ( m_sample && sli && sli-> style ( )) |
583 | int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; | 605 | { |
606 | int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; | ||
584 | 607 | ||
585 | m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); | 608 | m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); |
586 | } | 609 | } |
587 | 610 | ||
588 | m_style_changed |= ( index != m_original_style ); | 611 | m_style_changed |= ( index != m_original_style ); |
589 | } | 612 | } |
590 | 613 | ||
591 | void Appearance::styleSettingsClicked ( ) | 614 | void Appearance::styleSettingsClicked ( ) |
592 | { | 615 | { |
593 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 616 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
594 | 617 | ||
595 | if ( item && item-> hasSettings ( )) { | 618 | if ( item && item-> hasSettings ( )) |
596 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); | 619 | { |
597 | QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); | 620 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); |
621 | QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); | ||
598 | 622 | ||
599 | QWidget *w = item-> settings ( d ); | 623 | QWidget *w = item-> settings ( d ); |
600 | 624 | ||
601 | if ( w ) { | 625 | if ( w ) |
602 | vbox-> addWidget ( w ); | 626 | { |
627 | vbox-> addWidget ( w ); | ||
603 | 628 | ||
604 | d-> setCaption ( w-> caption ( )); | 629 | d-> setCaption ( w-> caption ( )); |
605 | 630 | ||
606 | d-> showMaximized ( ); | 631 | bool accepted = ( QPEApplication::execDialog ( d ) == QDialog::Accepted ); |
607 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); | ||
608 | 632 | ||
609 | if ( item-> setSettings ( accepted )) | 633 | if ( item-> setSettings ( accepted )) |
610 | m_style_changed = true; | 634 | m_style_changed = true; |
611 | } | 635 | } |
612 | delete d; | 636 | delete d; |
613 | } | 637 | } |
614 | } | 638 | } |
615 | 639 | ||
616 | void Appearance::decoClicked ( int index ) | 640 | void Appearance::decoClicked ( int index ) |
617 | { | 641 | { |
618 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); | 642 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); |
619 | 643 | ||
620 | if ( m_sample ) { | 644 | if ( m_sample ) |
621 | if ( dli && dli-> interface ( )) | 645 | { |
622 | m_sample-> setDecoration ( dli-> interface ( )); | 646 | if ( dli && dli-> interface ( )) |
623 | else | 647 | m_sample-> setDecoration ( dli-> interface ( )); |
624 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 648 | else |
625 | m_sample-> repaint ( ); | 649 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
626 | } | 650 | m_sample-> repaint ( ); |
627 | m_deco_changed |= ( index != m_original_deco ); | 651 | } |
652 | m_deco_changed |= ( index != m_original_deco ); | ||
628 | } | 653 | } |
629 | 654 | ||
630 | void Appearance::fontClicked ( const QFont &f ) | 655 | void Appearance::fontClicked ( const QFont &f ) |
631 | { | 656 | { |
632 | m_font_changed |= ( f != m_sample-> font ( )); | 657 | m_font_changed |= ( f != m_sample-> font ( )); |
633 | m_sample-> setFont ( f ); | 658 | m_sample-> setFont ( f ); |
634 | } | 659 | } |
635 | 660 | ||
636 | void Appearance::colorClicked ( int index ) | 661 | void Appearance::colorClicked ( int index ) |
637 | { | 662 | { |
638 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); | 663 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); |
639 | 664 | ||
640 | if ( item ) | 665 | if ( item ) |
641 | m_sample-> setPalette ( item-> palette ( )); | 666 | m_sample-> setPalette ( item-> palette ( )); |
642 | 667 | ||
643 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); | 668 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); |
644 | } | 669 | } |
645 | 670 | ||
646 | 671 | ||
647 | void Appearance::editSchemeClicked ( ) | 672 | void Appearance::editSchemeClicked ( ) |
648 | { | 673 | { |
649 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 674 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
650 | 675 | ||
651 | int cnt = 0; | 676 | int cnt = 0; |
652 | QString labels [QColorGroup::NColorRoles]; | 677 | QString labels [QColorGroup::NColorRoles]; |
653 | QColor colors [QColorGroup::NColorRoles]; | 678 | QColor colors [QColorGroup::NColorRoles]; |
654 | 679 | ||
655 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 680 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) |
656 | QColor col = item-> color ( role ); | 681 | { |
682 | QColor col = item-> color ( role ); | ||
657 | 683 | ||
658 | if ( col. isValid ( )) { | 684 | if ( col. isValid ( )) |
659 | labels [cnt] = item-> label ( role ); | 685 | { |
660 | colors [cnt] = col; | 686 | labels [cnt] = item-> label ( role ); |
687 | colors [cnt] = col; | ||
661 | 688 | ||
662 | cnt++; | 689 | cnt++; |
663 | } | 690 | } |
664 | } | 691 | } |
665 | 692 | ||
666 | EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); | 693 | EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); |
667 | editdlg-> showMaximized ( ); | 694 | if ( QPEApplication::execDialog( editdlg ) == QDialog::Accepted ) |
668 | if ( editdlg-> exec ( ) == QDialog::Accepted ) { | 695 | { |
669 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); | 696 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); |
670 | cnt = 0; | 697 | cnt = 0; |
671 | 698 | ||
672 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 699 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) |
673 | if ( item-> color ( role ). isValid ( )) { | 700 | { |
674 | citem-> setColor ( role, colors [cnt] ); | 701 | if ( item-> color ( role ). isValid ( )) |
675 | cnt++; | 702 | { |
676 | } | 703 | citem-> setColor ( role, colors [cnt] ); |
704 | cnt++; | ||
705 | } | ||
677 | } | 706 | } |
678 | 707 | ||
679 | m_color_list-> setCurrentItem ( 0 ); | 708 | m_color_list-> setCurrentItem ( 0 ); |
680 | colorClicked ( 0 ); | 709 | colorClicked ( 0 ); |
681 | 710 | ||
682 | m_color_changed = true; | 711 | m_color_changed = true; |
683 | } | 712 | } |
684 | delete editdlg; | 713 | delete editdlg; |
685 | } | 714 | } |
686 | 715 | ||
687 | 716 | ||
688 | void Appearance::saveSchemeClicked() | 717 | void Appearance::saveSchemeClicked() |
689 | { | 718 | { |
690 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 719 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
691 | 720 | ||
692 | if ( !item ) | 721 | if ( !item ) |
693 | return; | 722 | return; |
694 | 723 | ||
695 | QDialog *d = new QDialog ( this, 0, true ); | 724 | QDialog *d = new QDialog ( this, 0, true ); |
696 | d-> setCaption ( tr( "Save Scheme" )); | 725 | d-> setCaption ( tr( "Save Scheme" )); |
697 | QLineEdit *ed = new QLineEdit ( d ); | 726 | QLineEdit *ed = new QLineEdit ( d ); |
698 | ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); | 727 | ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); |
699 | ed-> setFocus ( ); | 728 | ed-> setFocus ( ); |
700 | 729 | ||
701 | if ( d-> exec ( ) == QDialog::Accepted ) { | 730 | if ( d-> exec ( ) == QDialog::Accepted ) |
731 | { | ||
702 | QString schemename = ed-> text ( ); | 732 | QString schemename = ed-> text ( ); |
703 | QString filestr = QPEApplication::qpeDir(); | 733 | QString filestr = QPEApplication::qpeDir(); |
704 | filestr.append( "/etc/colors/" ); | 734 | filestr.append( "/etc/colors/" ); |
705 | filestr.append( schemename ); | 735 | filestr.append( schemename ); |
706 | filestr.append( ".scheme" ); | 736 | filestr.append( ".scheme" ); |
707 | QFile file ( filestr ); | 737 | QFile file ( filestr ); |
708 | if ( !file. exists ( )) | 738 | if ( !file. exists ( )) |
709 | { | 739 | { |
710 | QPalette p = item-> palette ( ); | 740 | QPalette p = item-> palette ( ); |
711 | 741 | ||
712 | Config config ( file.name(), Config::File ); | 742 | Config config ( file.name(), Config::File ); |
713 | config. setGroup( "Colors" ); | 743 | config. setGroup( "Colors" ); |
714 | 744 | ||
715 | item-> save ( config ); | 745 | item-> save ( config ); |
716 | 746 | ||
717 | config. write ( ); // need to flush the config info first | 747 | config. write ( ); // need to flush the config info first |
718 | 748 | ||
719 | m_color_list-> insertItem ( new ColorListItem ( schemename, config )); | 749 | m_color_list-> insertItem ( new ColorListItem ( schemename, config )); |
720 | } | 750 | } |
721 | else | 751 | else |
722 | { | 752 | { |
723 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); | 753 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); |
724 | } | 754 | } |
725 | } | 755 | } |
726 | delete d; | 756 | delete d; |
727 | } | 757 | } |
728 | 758 | ||
729 | void Appearance::deleteSchemeClicked() | 759 | void Appearance::deleteSchemeClicked() |
730 | { | 760 | { |
731 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 761 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
732 | 762 | ||
733 | if ( !item ) | 763 | if ( !item ) |
734 | return; | 764 | return; |
735 | 765 | ||
736 | if ( m_color_list-> currentItem ( ) > 0 ) | 766 | if ( m_color_list-> currentItem ( ) > 0 ) |
737 | { | 767 | { |
738 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete scheme" ), item-> text ( ) ) ) | 768 | if ( QPEMessageBox::confirmDelete ( this, tr( "Delete scheme" ), item-> text ( ) ) ) |
739 | { | 769 | { |
740 | QString filestr = QPEApplication::qpeDir ( ); | 770 | QString filestr = QPEApplication::qpeDir ( ); |
741 | filestr.append( "/etc/colors/" ); | 771 | filestr.append( "/etc/colors/" ); |
742 | filestr.append( item-> text ( ) ); | 772 | filestr.append( item-> text ( ) ); |
743 | filestr.append( ".scheme" ); | 773 | filestr.append( ".scheme" ); |
744 | QFile::remove ( filestr ); | 774 | QFile::remove ( filestr ); |
745 | delete item; | 775 | delete item; |
746 | } | 776 | } |
747 | } | 777 | } |
748 | else | 778 | else |
749 | { | 779 | { |
750 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); | 780 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); |
751 | } | 781 | } |
752 | } | 782 | } |
753 | 783 | ||
754 | 784 | ||
755 | void Appearance::addExcept ( ) | 785 | void Appearance::addExcept ( ) |
756 | { | 786 | { |
757 | ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true ); | 787 | ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true ); |
758 | m_except-> ensureItemVisible ( it ); | 788 | m_except-> ensureItemVisible ( it ); |
759 | m_except-> setSelected ( it, true ); | 789 | m_except-> setSelected ( it, true ); |
760 | } | 790 | } |
761 | 791 | ||
762 | void Appearance::delExcept ( ) | 792 | void Appearance::delExcept ( ) |
763 | { | 793 | { |
764 | if ( m_except-> selectedItem ( )) { | 794 | if ( m_except-> selectedItem ( )) |
765 | m_except-> setFocus ( ); | 795 | { |
766 | delete m_except-> selectedItem ( ); | 796 | m_except-> setFocus ( ); |
767 | } | 797 | delete m_except-> selectedItem ( ); |
798 | } | ||
768 | } | 799 | } |
769 | 800 | ||
770 | void Appearance::upExcept ( ) | 801 | void Appearance::upExcept ( ) |
771 | { | 802 | { |
772 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); | 803 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); |
773 | 804 | ||
774 | if ( it && it-> itemAbove ( )) | 805 | if ( it && it-> itemAbove ( )) |
775 | it-> itemAbove ( )-> moveItem ( it ); | 806 | it-> itemAbove ( )-> moveItem ( it ); |
776 | } | 807 | } |
777 | 808 | ||
778 | void Appearance::downExcept ( ) | 809 | void Appearance::downExcept ( ) |
779 | { | 810 | { |
780 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); | 811 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); |
781 | 812 | ||
782 | if ( it && it-> itemBelow ( )) | 813 | if ( it && it-> itemBelow ( )) |
783 | it-> moveItem ( it-> itemBelow ( )); | 814 | it-> moveItem ( it-> itemBelow ( )); |
784 | } | 815 | } |
785 | 816 | ||
786 | class ExEdit : public QLineEdit { | 817 | class ExEdit : public QLineEdit |
818 | { | ||
787 | public: | 819 | public: |
788 | ExEdit ( ExceptListItem *item ) | 820 | ExEdit ( ExceptListItem *item ) |
789 | : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) | 821 | : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) |
790 | { | 822 | { |
791 | setFrame ( false ); | 823 | setFrame ( false ); |
792 | 824 | ||
793 | QRect r = it-> listView ( )-> itemRect ( it ); | 825 | QRect r = it-> listView ( )-> itemRect ( it ); |
794 | 826 | ||
795 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; | 827 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; |
796 | int y = r. y ( ); | 828 | int y = r. y ( ); |
797 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; | 829 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; |
798 | int h = r. height ( ); // + 2; | 830 | int h = r. height ( ); // + 2; |
799 | 831 | ||
800 | setText ( it-> pattern ( )); | 832 | setText ( it-> pattern ( )); |
801 | setGeometry ( x, y, w, h ); | 833 | setGeometry ( x, y, w, h ); |
802 | 834 | ||
803 | qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); | 835 | qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); |
804 | 836 | ||
805 | m_out = true; | 837 | m_out = true; |
806 | 838 | ||
807 | show ( ); | 839 | show ( ); |
808 | setFocus ( ); | 840 | setFocus ( ); |
809 | selectAll ( ); | 841 | selectAll ( ); |
810 | end ( true ); | 842 | end ( true ); |
811 | } | 843 | } |
812 | 844 | ||
813 | virtual void focusOutEvent ( QFocusEvent * ) | 845 | virtual void focusOutEvent ( QFocusEvent * ) |
814 | { | 846 | { |
815 | hide ( ); | 847 | hide ( ); |
816 | if ( m_out ) | 848 | if ( m_out ) |
817 | it-> setPattern ( text ( )); | 849 | it-> setPattern ( text ( )); |
818 | delete this; | 850 | delete this; |
819 | } | 851 | } |
820 | 852 | ||
821 | virtual void keyPressEvent ( QKeyEvent *e ) | 853 | virtual void keyPressEvent ( QKeyEvent *e ) |
822 | { | 854 | { |
823 | if ( e-> key ( ) == Key_Return ) | 855 | if ( e-> key ( ) == Key_Return ) |
824 | it-> listView ( )-> setFocus ( ); | 856 | it-> listView ( )-> setFocus ( ); |
825 | else if ( e-> key ( ) == Key_Escape ) { | 857 | else if ( e-> key ( ) == Key_Escape ) |
826 | m_out = false; | 858 | { |
827 | it-> listView ( )-> setFocus ( ); | 859 | m_out = false; |
828 | } | 860 | it-> listView ( )-> setFocus ( ); |
829 | else | 861 | } |
830 | QLineEdit::keyPressEvent ( e ); | 862 | else |
831 | } | 863 | QLineEdit::keyPressEvent ( e ); |
864 | } | ||
832 | 865 | ||
833 | private: | 866 | private: |
834 | ExceptListItem *it; | 867 | ExceptListItem *it; |
835 | bool m_out; | 868 | bool m_out; |
836 | }; | 869 | }; |
837 | 870 | ||
838 | void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) | 871 | void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) |
839 | { | 872 | { |
840 | if ( !item || c < 0 || c > 3 ) | 873 | if ( !item || c < 0 || c > 3 ) |
841 | return; | 874 | return; |
842 | 875 | ||
843 | ExceptListItem *it = (ExceptListItem *) item; | 876 | ExceptListItem *it = (ExceptListItem *) item; |
844 | 877 | ||
845 | if ( c == 0 ) | 878 | if ( c == 0 ) |
846 | it-> setNoStyle ( !it-> noStyle ( )); | 879 | it-> setNoStyle ( !it-> noStyle ( )); |
847 | else if ( c == 1 ) | 880 | else if ( c == 1 ) |
848 | it-> setNoFont ( !it-> noFont ( )); | 881 | it-> setNoFont ( !it-> noFont ( )); |
849 | else if ( c == 2 ) | 882 | else if ( c == 2 ) |
850 | it-> setNoDeco ( !it-> noDeco ( )); | 883 | it-> setNoDeco ( !it-> noDeco ( )); |
851 | else if ( c == 3 ) { | 884 | else if ( c == 3 ) |
852 | m_except-> ensureItemVisible ( it ); | 885 | { |
853 | new ExEdit ( it ); | 886 | m_except-> ensureItemVisible ( it ); |
854 | } | 887 | new ExEdit ( it ); |
888 | } | ||
855 | } | 889 | } |
856 | 890 | ||
diff --git a/noncore/settings/appearance2/stylelistitem.h b/noncore/settings/appearance2/stylelistitem.h index caefad8..b6c72c3 100644 --- a/noncore/settings/appearance2/stylelistitem.h +++ b/noncore/settings/appearance2/stylelistitem.h | |||
@@ -23,25 +23,31 @@ | |||
23 | 59 Temple Place - Suite 330, | 23 | 59 Temple Place - Suite 330, |
24 | Boston, MA 02111-1307, USA. | 24 | Boston, MA 02111-1307, USA. |
25 | 25 | ||
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef STYLELISTITEM_H | 28 | #ifndef STYLELISTITEM_H |
29 | #define STYLELISTITEM_H | 29 | #define STYLELISTITEM_H |
30 | 30 | ||
31 | #include <qlistbox.h> | 31 | /* OPIE */ |
32 | #include <qpe/styleinterface.h> | 32 | #include <qpe/styleinterface.h> |
33 | #include <qpe/qlibrary.h> | ||
34 | #include <qpe/resource.h> | ||
35 | |||
36 | /* QT */ | ||
37 | #include <qlistbox.h> | ||
38 | #include <qfileinfo.h> | ||
33 | 39 | ||
34 | #include <stdio.h> | 40 | #include <stdio.h> |
35 | 41 | ||
36 | class StyleListItem : public QListBoxText { | 42 | class StyleListItem : public QListBoxText { |
37 | public: | 43 | public: |
38 | StyleListItem ( const QString &t, QStyle *sty ) : QListBoxText ( t ) | 44 | StyleListItem ( const QString &t, QStyle *sty ) : QListBoxText ( t ) |
39 | { | 45 | { |
40 | m_lib = 0; | 46 | m_lib = 0; |
41 | m_style_if = 0; | 47 | m_style_if = 0; |
42 | m_settings_if = 0; | 48 | m_settings_if = 0; |
43 | m_style = sty; | 49 | m_style = sty; |
44 | } | 50 | } |
45 | 51 | ||
46 | StyleListItem ( QLibrary *lib, StyleInterface *iface ) : QListBoxText ( iface-> name ( )) | 52 | StyleListItem ( QLibrary *lib, StyleInterface *iface ) : QListBoxText ( iface-> name ( )) |
47 | { | 53 | { |
diff --git a/noncore/settings/aqpkg/categoryfilterimpl.cpp b/noncore/settings/aqpkg/categoryfilterimpl.cpp index 61e1f93..217d2c9 100644 --- a/noncore/settings/aqpkg/categoryfilterimpl.cpp +++ b/noncore/settings/aqpkg/categoryfilterimpl.cpp | |||
@@ -22,46 +22,52 @@ | |||
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <iostream> | 30 | #include "categoryfilterimpl.h" |
31 | using namespace std; | 31 | |
32 | /* OPIE */ | ||
33 | #include <qpe/qpeapplication.h> | ||
32 | 34 | ||
35 | /* QT */ | ||
33 | #include <qgroupbox.h> | 36 | #include <qgroupbox.h> |
34 | #include <qlayout.h> | 37 | #include <qlayout.h> |
35 | #include <qlistbox.h> | 38 | #include <qlistbox.h> |
36 | #include <qstring.h> | 39 | #include <qstring.h> |
37 | 40 | ||
38 | #include "categoryfilterimpl.h" | 41 | /* STD */ |
42 | #include <iostream> | ||
43 | using namespace std; | ||
44 | |||
39 | 45 | ||
40 | CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) | 46 | CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) |
41 | : QDialog( parent, name, true ) | 47 | : QDialog( parent, name, true ) |
42 | { | 48 | { |
43 | setCaption( tr( "Category Filter" ) ); | 49 | setCaption( tr( "Category Filter" ) ); |
44 | 50 | ||
45 | QVBoxLayout *layout = new QVBoxLayout( this ); | 51 | QVBoxLayout *layout = new QVBoxLayout( this ); |
46 | layout->setMargin( 2 ); | 52 | layout->setMargin( 2 ); |
47 | layout->setSpacing( 4 ); | 53 | layout->setSpacing( 4 ); |
48 | 54 | ||
49 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Select one or more groups" ), this ); | 55 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Select one or more groups" ), this ); |
50 | grpbox->layout()->setSpacing( 2 ); | 56 | grpbox->layout()->setSpacing( 2 ); |
51 | grpbox->layout()->setMargin( 4 ); | 57 | grpbox->layout()->setMargin( 4 ); |
52 | layout->addWidget( grpbox ); | 58 | layout->addWidget( grpbox ); |
53 | 59 | ||
54 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 60 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
55 | 61 | ||
56 | lstCategories = new QListBox( grpbox ); | 62 | lstCategories = new QListBox( grpbox ); |
57 | lstCategories->setSelectionMode( QListBox::Multi ); | 63 | lstCategories->setSelectionMode( QListBox::Multi ); |
58 | grplayout->addWidget( lstCategories ); | 64 | grplayout->addWidget( lstCategories ); |
59 | 65 | ||
60 | // Split up categories and add them to the listbox | 66 | // Split up categories and add them to the listbox |
61 | int start = 1; | 67 | int start = 1; |
62 | 68 | ||
63 | QString item; | 69 | QString item; |
64 | int end; | 70 | int end; |
65 | QString finditem; | 71 | QString finditem; |
66 | do | 72 | do |
67 | { | 73 | { |
@@ -71,26 +77,26 @@ CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QStrin | |||
71 | { | 77 | { |
72 | lstCategories->insertItem( item ); | 78 | lstCategories->insertItem( item ); |
73 | finditem = QString( "#%1#" ).arg( item ); | 79 | finditem = QString( "#%1#" ).arg( item ); |
74 | if ( selectedCategories.find( finditem ) != -1 ) | 80 | if ( selectedCategories.find( finditem ) != -1 ) |
75 | lstCategories->setSelected( lstCategories->count()-1, true ); | 81 | lstCategories->setSelected( lstCategories->count()-1, true ); |
76 | } | 82 | } |
77 | 83 | ||
78 | start = end + 1; | 84 | start = end + 1; |
79 | } while ( start < (int)categories.length() ); | 85 | } |
86 | while ( start < (int)categories.length() ); | ||
80 | 87 | ||
81 | lstCategories->sort( true ); | 88 | lstCategories->sort( true ); |
82 | 89 | ||
83 | showMaximized(); | 90 | QPEApplication::showDialog( this ); |
84 | } | 91 | } |
85 | 92 | ||
86 | CategoryFilterImpl :: ~CategoryFilterImpl() | 93 | CategoryFilterImpl :: ~CategoryFilterImpl() |
87 | { | 94 | {} |
88 | } | ||
89 | 95 | ||
90 | QString CategoryFilterImpl :: getSelectedFilter() | 96 | QString CategoryFilterImpl :: getSelectedFilter() |
91 | { | 97 | { |
92 | // Grab cetegories from listbox | 98 | // Grab cetegories from listbox |
93 | QString ret = "#"; | 99 | QString ret = "#"; |
94 | 100 | ||
95 | for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) | 101 | for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) |
96 | { | 102 | { |
diff --git a/noncore/settings/aqpkg/instoptionsimpl.cpp b/noncore/settings/aqpkg/instoptionsimpl.cpp index 9d52013..126e3b9 100644 --- a/noncore/settings/aqpkg/instoptionsimpl.cpp +++ b/noncore/settings/aqpkg/instoptionsimpl.cpp | |||
@@ -22,91 +22,93 @@ | |||
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "global.h" | ||
31 | #include "instoptionsimpl.h" | ||
32 | #include "ipkg.h" | ||
33 | |||
34 | /* OPIE */ | ||
30 | #ifdef QWS | 35 | #ifdef QWS |
31 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
32 | #endif | 37 | #endif |
38 | #include <qpe/qpeapplication.h> | ||
33 | 39 | ||
40 | /* QT */ | ||
34 | #include <qcheckbox.h> | 41 | #include <qcheckbox.h> |
35 | #include <qcombobox.h> | 42 | #include <qcombobox.h> |
36 | #include <qgroupbox.h> | 43 | #include <qgroupbox.h> |
37 | #include <qlabel.h> | 44 | #include <qlabel.h> |
38 | #include <qlayout.h> | 45 | #include <qlayout.h> |
39 | 46 | ||
40 | #include "global.h" | ||
41 | #include "instoptionsimpl.h" | ||
42 | #include "ipkg.h" | ||
43 | |||
44 | InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * parent, const char* name, bool modal, WFlags fl ) | 47 | InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * parent, const char* name, bool modal, WFlags fl ) |
45 | : QDialog( parent, name, modal, fl ) | 48 | : QDialog( parent, name, modal, fl ) |
46 | { | 49 | { |
47 | setCaption( tr( "Options" ) ); | 50 | setCaption( tr( "Options" ) ); |
48 | 51 | ||
49 | QVBoxLayout *layout = new QVBoxLayout( this ); | 52 | QVBoxLayout *layout = new QVBoxLayout( this ); |
50 | layout->setMargin( 2 ); | 53 | layout->setMargin( 2 ); |
51 | layout->setSpacing( 4 ); | 54 | layout->setSpacing( 4 ); |
52 | 55 | ||
53 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Options" ), this ); | 56 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Options" ), this ); |
54 | grpbox->layout()->setSpacing( 2 ); | 57 | grpbox->layout()->setSpacing( 2 ); |
55 | grpbox->layout()->setMargin( 4 ); | 58 | grpbox->layout()->setMargin( 4 ); |
56 | layout->addWidget( grpbox ); | 59 | layout->addWidget( grpbox ); |
57 | 60 | ||
58 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 61 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
59 | 62 | ||
60 | forceDepends = new QCheckBox( tr( "Force Depends" ), grpbox ); | 63 | forceDepends = new QCheckBox( tr( "Force Depends" ), grpbox ); |
61 | grplayout->addWidget( forceDepends ); | 64 | grplayout->addWidget( forceDepends ); |
62 | 65 | ||
63 | forceReinstall = new QCheckBox( tr( "Force Reinstall" ), grpbox ); | 66 | forceReinstall = new QCheckBox( tr( "Force Reinstall" ), grpbox ); |
64 | grplayout->addWidget( forceReinstall ); | 67 | grplayout->addWidget( forceReinstall ); |
65 | 68 | ||
66 | forceRemove = new QCheckBox( tr( "Force Remove" ), grpbox ); | 69 | forceRemove = new QCheckBox( tr( "Force Remove" ), grpbox ); |
67 | grplayout->addWidget( forceRemove ); | 70 | grplayout->addWidget( forceRemove ); |
68 | 71 | ||
69 | forceOverwrite = new QCheckBox( tr( "Force Overwrite" ), grpbox ); | 72 | forceOverwrite = new QCheckBox( tr( "Force Overwrite" ), grpbox ); |
70 | grplayout->addWidget( forceOverwrite ); | 73 | grplayout->addWidget( forceOverwrite ); |
71 | 74 | ||
72 | QLabel *l = new QLabel( tr( "Information Level" ), grpbox ); | 75 | QLabel *l = new QLabel( tr( "Information Level" ), grpbox ); |
73 | grplayout->addWidget( l ); | 76 | grplayout->addWidget( l ); |
74 | 77 | ||
75 | verboseIpkg = new QComboBox( grpbox ); | 78 | verboseIpkg = new QComboBox( grpbox ); |
76 | verboseIpkg->insertItem( tr( "Errors only" ) ); | 79 | verboseIpkg->insertItem( tr( "Errors only" ) ); |
77 | verboseIpkg->insertItem( tr( "Normal messages" ) ); | 80 | verboseIpkg->insertItem( tr( "Normal messages" ) ); |
78 | verboseIpkg->insertItem( tr( "Informative messages" ) ); | 81 | verboseIpkg->insertItem( tr( "Informative messages" ) ); |
79 | verboseIpkg->insertItem( tr( "Troubleshooting output" ) ); | 82 | verboseIpkg->insertItem( tr( "Troubleshooting output" ) ); |
80 | verboseIpkg->setCurrentItem( verb ); | 83 | verboseIpkg->setCurrentItem( verb ); |
81 | grplayout->addWidget( verboseIpkg ); | 84 | grplayout->addWidget( verboseIpkg ); |
82 | 85 | ||
83 | grplayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); | 86 | grplayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); |
84 | 87 | ||
85 | if ( flags & FORCE_DEPENDS ) | 88 | if ( flags & FORCE_DEPENDS ) |
86 | forceDepends->setChecked( true ); | 89 | forceDepends->setChecked( true ); |
87 | if ( flags & FORCE_REINSTALL ) | 90 | if ( flags & FORCE_REINSTALL ) |
88 | forceReinstall->setChecked( true ); | 91 | forceReinstall->setChecked( true ); |
89 | if ( flags & FORCE_REMOVE ) | 92 | if ( flags & FORCE_REMOVE ) |
90 | forceRemove->setChecked( true ); | 93 | forceRemove->setChecked( true ); |
91 | if ( flags & FORCE_OVERWRITE ) | 94 | if ( flags & FORCE_OVERWRITE ) |
92 | forceOverwrite->setChecked( true ); | 95 | forceOverwrite->setChecked( true ); |
93 | // if ( flags & VERBOSE_WGET ) | 96 | // if ( flags & VERBOSE_WGET ) |
94 | // verboseWget->setChecked( true ); | 97 | // verboseWget->setChecked( true ); |
95 | // if ( flags & MAKE_LINKS ) | 98 | // if ( flags & MAKE_LINKS ) |
96 | // makeLinks->setChecked( true ); | 99 | // makeLinks->setChecked( true ); |
97 | 100 | ||
98 | showMaximized(); | 101 | QPEApplication::showDialog( this ); |
99 | 102 | ||
100 | } | 103 | } |
101 | 104 | ||
102 | InstallOptionsDlgImpl::~InstallOptionsDlgImpl() | 105 | InstallOptionsDlgImpl::~InstallOptionsDlgImpl() |
103 | { | 106 | {} |
104 | } | ||
105 | 107 | ||
106 | 108 | ||
107 | int InstallOptionsDlgImpl :: getFlags() | 109 | int InstallOptionsDlgImpl :: getFlags() |
108 | { | 110 | { |
109 | int flags = 0; | 111 | int flags = 0; |
110 | 112 | ||
111 | if ( forceDepends->isChecked() ) | 113 | if ( forceDepends->isChecked() ) |
112 | flags |= FORCE_DEPENDS; | 114 | flags |= FORCE_DEPENDS; |
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index dbe694e..6f5c712 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,11 +1,11 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
@@ -22,57 +22,60 @@ | |||
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/limits.h> | 30 | #include "categoryfilterimpl.h" |
31 | #include <unistd.h> | 31 | #include "datamgr.h" |
32 | #include "global.h" | ||
33 | #include "inputdlg.h" | ||
34 | #include "ipkg.h" | ||
35 | #include "installdlgimpl.h" | ||
36 | #include "letterpushbutton.h" | ||
37 | #include "mainwin.h" | ||
38 | #include "packagewin.h" | ||
39 | #include "settingsimpl.h" | ||
40 | #include "utils.h" | ||
32 | 41 | ||
42 | /* OPIE */ | ||
33 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
34 | #include <qmenubar.h> | ||
35 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
36 | #include <qtoolbar.h> | ||
37 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
38 | #include <qpe/resource.h> | 46 | #include <qpe/resource.h> |
39 | 47 | ||
48 | /* QT */ | ||
49 | #include <qmenubar.h> | ||
50 | #include <qtoolbar.h> | ||
40 | #include <qaction.h> | 51 | #include <qaction.h> |
41 | #include <qcombobox.h> | 52 | #include <qcombobox.h> |
42 | #include <qfile.h> | 53 | #include <qfile.h> |
43 | #include <qlabel.h> | 54 | #include <qlabel.h> |
44 | #include <qlayout.h> | 55 | #include <qlayout.h> |
45 | #include <qlineedit.h> | 56 | #include <qlineedit.h> |
46 | #include <qlistview.h> | 57 | #include <qlistview.h> |
47 | #include <qmenubar.h> | 58 | #include <qmenubar.h> |
48 | #include <qmessagebox.h> | 59 | #include <qmessagebox.h> |
49 | #include <qpopupmenu.h> | 60 | #include <qpopupmenu.h> |
50 | #include <qprogressbar.h> | 61 | #include <qprogressbar.h> |
51 | #include <qtimer.h> | 62 | #include <qtimer.h> |
52 | #include <qwhatsthis.h> | 63 | #include <qwhatsthis.h> |
53 | #include <qwidgetstack.h> | 64 | #include <qwidgetstack.h> |
54 | 65 | ||
55 | #include "categoryfilterimpl.h" | 66 | /* STD */ |
56 | #include "datamgr.h" | 67 | #include <linux/limits.h> |
57 | #include "global.h" | 68 | #include <unistd.h> |
58 | #include "inputdlg.h" | ||
59 | #include "ipkg.h" | ||
60 | #include "installdlgimpl.h" | ||
61 | #include "letterpushbutton.h" | ||
62 | #include "mainwin.h" | ||
63 | #include "packagewin.h" | ||
64 | #include "settingsimpl.h" | ||
65 | #include "utils.h" | ||
66 | 69 | ||
67 | extern int compareVersions( const char *v1, const char *v2 ); | 70 | extern int compareVersions( const char *v1, const char *v2 ); |
68 | 71 | ||
69 | MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) | 72 | MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) |
70 | :QMainWindow( parent, name, fl || WStyle_ContextHelp ) | 73 | :QMainWindow( parent, name, fl || WStyle_ContextHelp ) |
71 | { | 74 | { |
72 | // Disable suspend mode | 75 | // Disable suspend mode |
73 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 76 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
74 | 77 | ||
75 | LOCAL_SERVER = QObject::tr( "Installed packages" ); | 78 | LOCAL_SERVER = QObject::tr( "Installed packages" ); |
76 | LOCAL_IPKGS = QObject::tr( "Local packages" ); | 79 | LOCAL_IPKGS = QObject::tr( "Local packages" ); |
77 | 80 | ||
78 | setCaption( tr( "AQPkg - Package Manager" ) ); | 81 | setCaption( tr( "AQPkg - Package Manager" ) ); |
@@ -234,17 +237,17 @@ MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) | |||
234 | stack->raiseWidget( progressWindow ); | 237 | stack->raiseWidget( progressWindow ); |
235 | 238 | ||
236 | // Delayed call to finish initialization | 239 | // Delayed call to finish initialization |
237 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 240 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
238 | } | 241 | } |
239 | 242 | ||
240 | MainWindow :: ~MainWindow() | 243 | MainWindow :: ~MainWindow() |
241 | { | 244 | { |
242 | delete mgr; | 245 | delete mgr; |
243 | 246 | ||
244 | // Reenable suspend mode | 247 | // Reenable suspend mode |
245 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 248 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
246 | } | 249 | } |
247 | 250 | ||
248 | void MainWindow :: initMainWidget() | 251 | void MainWindow :: initMainWidget() |
249 | { | 252 | { |
250 | networkPkgWindow = new QWidget( this ); | 253 | networkPkgWindow = new QWidget( this ); |
@@ -291,17 +294,17 @@ void MainWindow :: initProgressWidget() | |||
291 | 294 | ||
292 | void MainWindow :: init() | 295 | void MainWindow :: init() |
293 | { | 296 | { |
294 | #ifdef QWS | 297 | #ifdef QWS |
295 | // read download directory from config file | 298 | // read download directory from config file |
296 | Config cfg( "aqpkg" ); | 299 | Config cfg( "aqpkg" ); |
297 | cfg.setGroup( "settings" ); | 300 | cfg.setGroup( "settings" ); |
298 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 301 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
299 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 302 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
300 | 303 | ||
301 | #endif | 304 | #endif |
302 | 305 | ||
303 | stack->raiseWidget( progressWindow ); | 306 | stack->raiseWidget( progressWindow ); |
304 | 307 | ||
305 | mgr = new DataManager(); | 308 | mgr = new DataManager(); |
306 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 309 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); |
307 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 310 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), |
@@ -332,34 +335,34 @@ void MainWindow :: setDocument( const QString &doc ) | |||
332 | serversList->setCurrentItem( i ); | 335 | serversList->setCurrentItem( i ); |
333 | break; | 336 | break; |
334 | } | 337 | } |
335 | } | 338 | } |
336 | serverSelected( 0 ); | 339 | serverSelected( 0 ); |
337 | 340 | ||
338 | // Now set the check box of the selected package | 341 | // Now set the check box of the selected package |
339 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 342 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
340 | item != 0 ; | 343 | item != 0 ; |
341 | item = (QCheckListItem *)item->nextSibling() ) | 344 | item = (QCheckListItem *)item->nextSibling() ) |
342 | { | 345 | { |
343 | if ( item->text().startsWith( package ) ) | 346 | if ( item->text().startsWith( package ) ) |
344 | { | 347 | { |
345 | item->setOn( true ); | 348 | item->setOn( true ); |
346 | break; | 349 | break; |
347 | } | 350 | } |
348 | } | 351 | } |
349 | } | 352 | } |
350 | 353 | ||
351 | void MainWindow :: displaySettings() | 354 | void MainWindow :: displaySettings() |
352 | { | 355 | { |
353 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 356 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
354 | if ( dlg->showDlg() ) | 357 | if ( dlg->showDlg() ) |
355 | { | 358 | { |
356 | stack->raiseWidget( progressWindow ); | 359 | stack->raiseWidget( progressWindow ); |
357 | updateData(); | 360 | updateData(); |
358 | stack->raiseWidget( networkPkgWindow ); | 361 | stack->raiseWidget( networkPkgWindow ); |
359 | } | 362 | } |
360 | delete dlg; | 363 | delete dlg; |
361 | } | 364 | } |
362 | 365 | ||
363 | void MainWindow :: closeEvent( QCloseEvent *e ) | 366 | void MainWindow :: closeEvent( QCloseEvent *e ) |
364 | { | 367 | { |
365 | // If install dialog is visible, return to main view, otherwise close app | 368 | // If install dialog is visible, return to main view, otherwise close app |
@@ -577,22 +580,22 @@ void MainWindow :: updateData() | |||
577 | if ( !server->isServerActive() ) | 580 | if ( !server->isServerActive() ) |
578 | { | 581 | { |
579 | i--; | 582 | i--; |
580 | continue; | 583 | continue; |
581 | } | 584 | } |
582 | 585 | ||
583 | serversList->insertItem( serverName ); | 586 | serversList->insertItem( serverName ); |
584 | if ( serverName == currentlySelectedServer ) | 587 | if ( serverName == currentlySelectedServer ) |
585 | activeItem = i; | 588 | activeItem = i; |
586 | } | 589 | } |
587 | 590 | ||
588 | // set selected server to be active server | 591 | // set selected server to be active server |
589 | if ( activeItem != -1 ) | 592 | if ( activeItem != -1 ) |
590 | serversList->setCurrentItem( activeItem ); | 593 | serversList->setCurrentItem( activeItem ); |
591 | serverSelected( 0, FALSE ); | 594 | serverSelected( 0, FALSE ); |
592 | } | 595 | } |
593 | 596 | ||
594 | void MainWindow :: serverSelected( int index ) | 597 | void MainWindow :: serverSelected( int index ) |
595 | { | 598 | { |
596 | serverSelected( index, TRUE ); | 599 | serverSelected( index, TRUE ); |
597 | } | 600 | } |
598 | 601 | ||
@@ -620,20 +623,20 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
620 | } | 623 | } |
621 | m_progress->setTotalSteps( list.count() ); | 624 | m_progress->setTotalSteps( list.count() ); |
622 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 625 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
623 | } | 626 | } |
624 | 627 | ||
625 | packagesList->clear(); | 628 | packagesList->clear(); |
626 | 629 | ||
627 | #ifdef QWS | 630 | #ifdef QWS |
628 | // read download directory from config file | 631 | // read download directory from config file |
629 | Config cfg( "aqpkg" ); | 632 | Config cfg( "aqpkg" ); |
630 | cfg.setGroup( "settings" ); | 633 | cfg.setGroup( "settings" ); |
631 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 634 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
632 | #endif | 635 | #endif |
633 | 636 | ||
634 | int i = 0; | 637 | int i = 0; |
635 | Package *package; | 638 | Package *package; |
636 | for ( ; it.current(); ++it ) | 639 | for ( ; it.current(); ++it ) |
637 | { | 640 | { |
638 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 641 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
639 | i++; | 642 | i++; |
@@ -673,17 +676,17 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
673 | } | 676 | } |
674 | 677 | ||
675 | // If the local server, only display installed packages | 678 | // If the local server, only display installed packages |
676 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) | 679 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
677 | continue; | 680 | continue; |
678 | 681 | ||
679 | 682 | ||
680 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), | 683 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
681 | QCheckListItem::CheckBox ); | 684 | QCheckListItem::CheckBox ); |
682 | 685 | ||
683 | if ( package->isInstalled() ) | 686 | if ( package->isInstalled() ) |
684 | { | 687 | { |
685 | // If a different version of package is available, show update available icon | 688 | // If a different version of package is available, show update available icon |
686 | // Otherwise, show installed icon | 689 | // Otherwise, show installed icon |
687 | if ( package->getNewVersionAvailable()) | 690 | if ( package->getNewVersionAvailable()) |
688 | { | 691 | { |
689 | 692 | ||
@@ -733,17 +736,17 @@ void MainWindow :: searchForPackage( const QString &text ) | |||
733 | { | 736 | { |
734 | // look through package list for text startng at current position | 737 | // look through package list for text startng at current position |
735 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 738 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
736 | 739 | ||
737 | if ( start == 0 ) | 740 | if ( start == 0 ) |
738 | start = (QCheckListItem *)packagesList->firstChild(); | 741 | start = (QCheckListItem *)packagesList->firstChild(); |
739 | 742 | ||
740 | for ( QCheckListItem *item = start; item != 0 ; | 743 | for ( QCheckListItem *item = start; item != 0 ; |
741 | item = (QCheckListItem *)item->nextSibling() ) | 744 | item = (QCheckListItem *)item->nextSibling() ) |
742 | { | 745 | { |
743 | if ( item->text().lower().find( text ) != -1 ) | 746 | if ( item->text().lower().find( text ) != -1 ) |
744 | { | 747 | { |
745 | packagesList->ensureItemVisible( item ); | 748 | packagesList->ensureItemVisible( item ); |
746 | packagesList->setCurrentItem( item ); | 749 | packagesList->setCurrentItem( item ); |
747 | break; | 750 | break; |
748 | } | 751 | } |
749 | } | 752 | } |
@@ -761,67 +764,67 @@ void MainWindow :: updateServer() | |||
761 | 764 | ||
762 | // First, write out ipkg_conf file so that ipkg can use it | 765 | // First, write out ipkg_conf file so that ipkg can use it |
763 | mgr->writeOutIpkgConf(); | 766 | mgr->writeOutIpkgConf(); |
764 | 767 | ||
765 | Ipkg *ipkg = new Ipkg; | 768 | Ipkg *ipkg = new Ipkg; |
766 | ipkg->setOption( "update" ); | 769 | ipkg->setOption( "update" ); |
767 | 770 | ||
768 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), | 771 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), |
769 | tr( "Update lists" ) ); | 772 | tr( "Update lists" ) ); |
770 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 773 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
771 | reloadDocuments = FALSE; | 774 | reloadDocuments = FALSE; |
772 | stack->addWidget( dlg, 3 ); | 775 | stack->addWidget( dlg, 3 ); |
773 | stack->raiseWidget( dlg ); | 776 | stack->raiseWidget( dlg ); |
774 | 777 | ||
775 | // delete progDlg; | 778 | // delete progDlg; |
776 | } | 779 | } |
777 | 780 | ||
778 | void MainWindow :: upgradePackages() | 781 | void MainWindow :: upgradePackages() |
779 | { | 782 | { |
780 | // We're gonna do an upgrade of all packages | 783 | // We're gonna do an upgrade of all packages |
781 | // First warn user that this isn't recommended | 784 | // First warn user that this isn't recommended |
782 | // TODO - ODevice???? | 785 | // TODO - ODevice???? |
783 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); | 786 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); |
784 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | 787 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, |
785 | QMessageBox::Yes, | 788 | QMessageBox::Yes, |
786 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 789 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
787 | 0, this ); | 790 | 0, this ); |
788 | warn.adjustSize(); | 791 | warn.adjustSize(); |
789 | 792 | ||
790 | if ( warn.exec() == QMessageBox::Yes ) | 793 | if ( warn.exec() == QMessageBox::Yes ) |
791 | { | 794 | { |
792 | // First, write out ipkg_conf file so that ipkg can use it | 795 | // First, write out ipkg_conf file so that ipkg can use it |
793 | mgr->writeOutIpkgConf(); | 796 | mgr->writeOutIpkgConf(); |
794 | 797 | ||
795 | // Now run upgrade | 798 | // Now run upgrade |
796 | Ipkg *ipkg = new Ipkg; | 799 | Ipkg *ipkg = new Ipkg; |
797 | ipkg->setOption( "upgrade" ); | 800 | ipkg->setOption( "upgrade" ); |
798 | 801 | ||
799 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), | 802 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), |
800 | tr ( "Upgrade" ) ); | 803 | tr ( "Upgrade" ) ); |
801 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 804 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
802 | reloadDocuments = TRUE; | 805 | reloadDocuments = TRUE; |
803 | stack->addWidget( dlg, 3 ); | 806 | stack->addWidget( dlg, 3 ); |
804 | stack->raiseWidget( dlg ); | 807 | stack->raiseWidget( dlg ); |
805 | } | 808 | } |
806 | } | 809 | } |
807 | 810 | ||
808 | void MainWindow :: downloadPackage() | 811 | void MainWindow :: downloadPackage() |
809 | { | 812 | { |
810 | bool doUpdate = true; | 813 | bool doUpdate = true; |
811 | if ( downloadEnabled ) | 814 | if ( downloadEnabled ) |
812 | { | 815 | { |
813 | // See if any packages are selected | 816 | // See if any packages are selected |
814 | bool found = false; | 817 | bool found = false; |
815 | if ( serversList->currentText() != LOCAL_SERVER ) | 818 | if ( serversList->currentText() != LOCAL_SERVER ) |
816 | { | 819 | { |
817 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 820 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
818 | item != 0 && !found; | 821 | item != 0 && !found; |
819 | item = (QCheckListItem *)item->nextSibling() ) | 822 | item = (QCheckListItem *)item->nextSibling() ) |
820 | { | 823 | { |
821 | if ( item->isOn() ) | 824 | if ( item->isOn() ) |
822 | found = true; | 825 | found = true; |
823 | } | 826 | } |
824 | } | 827 | } |
825 | 828 | ||
826 | // If user selected some packages then download the and store the locally | 829 | // If user selected some packages then download the and store the locally |
827 | // otherwise, display dialog asking user what package to download from an http server | 830 | // otherwise, display dialog asking user what package to download from an http server |
@@ -831,18 +834,18 @@ void MainWindow :: downloadPackage() | |||
831 | else | 834 | else |
832 | downloadRemotePackage(); | 835 | downloadRemotePackage(); |
833 | 836 | ||
834 | } | 837 | } |
835 | else | 838 | else |
836 | { | 839 | { |
837 | doUpdate = false; | 840 | doUpdate = false; |
838 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 841 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
839 | item != 0 ; | 842 | item != 0 ; |
840 | item = (QCheckListItem *)item->nextSibling() ) | 843 | item = (QCheckListItem *)item->nextSibling() ) |
841 | { | 844 | { |
842 | if ( item->isOn() ) | 845 | if ( item->isOn() ) |
843 | { | 846 | { |
844 | QString name = item->text(); | 847 | QString name = item->text(); |
845 | int pos = name.find( "*" ); | 848 | int pos = name.find( "*" ); |
846 | name.truncate( pos ); | 849 | name.truncate( pos ); |
847 | 850 | ||
848 | // if (there is a (installed), remove it | 851 | // if (there is a (installed), remove it |
@@ -850,17 +853,17 @@ void MainWindow :: downloadPackage() | |||
850 | if ( pos > 0 ) | 853 | if ( pos > 0 ) |
851 | name.truncate( pos - 1 ); | 854 | name.truncate( pos - 1 ); |
852 | 855 | ||
853 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | 856 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); |
854 | 857 | ||
855 | QString msgtext; | 858 | QString msgtext; |
856 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); | 859 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); |
857 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | 860 | if ( QMessageBox::information( this, tr( "Are you sure?" ), |
858 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | 861 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) |
859 | { | 862 | { |
860 | doUpdate = true; | 863 | doUpdate = true; |
861 | QFile f( p->getFilename() ); | 864 | QFile f( p->getFilename() ); |
862 | f.remove(); | 865 | f.remove(); |
863 | } | 866 | } |
864 | } | 867 | } |
865 | } | 868 | } |
866 | } | 869 | } |
@@ -903,51 +906,51 @@ void MainWindow :: downloadSelectedPackages() | |||
903 | 906 | ||
904 | // Download each package | 907 | // Download each package |
905 | Ipkg ipkg; | 908 | Ipkg ipkg; |
906 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 909 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
907 | 910 | ||
908 | ipkg.setOption( "download" ); | 911 | ipkg.setOption( "download" ); |
909 | ipkg.setRuntimeDirectory( dir ); | 912 | ipkg.setRuntimeDirectory( dir ); |
910 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 913 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
911 | item != 0 ; | 914 | item != 0 ; |
912 | item = (QCheckListItem *)item->nextSibling() ) | 915 | item = (QCheckListItem *)item->nextSibling() ) |
913 | { | 916 | { |
914 | if ( item->isOn() ) | 917 | if ( item->isOn() ) |
915 | { | 918 | { |
916 | ipkg.setPackage( item->text() ); | 919 | ipkg.setPackage( item->text() ); |
917 | ipkg.runIpkg( ); | 920 | ipkg.runIpkg( ); |
918 | } | 921 | } |
919 | } | 922 | } |
920 | } | 923 | } |
921 | 924 | ||
922 | void MainWindow :: downloadRemotePackage() | 925 | void MainWindow :: downloadRemotePackage() |
923 | { | 926 | { |
924 | // Display dialog | 927 | // Display dialog |
925 | bool ok; | 928 | bool ok; |
926 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | 929 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); |
927 | if ( !ok || package.isEmpty() ) | 930 | if ( !ok || package.isEmpty() ) |
928 | return; | 931 | return; |
929 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 932 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
930 | // if ( dlg.exec() == QDialog::Rejected ) | 933 | // if ( dlg.exec() == QDialog::Rejected ) |
931 | // return; | 934 | // return; |
932 | 935 | ||
933 | // grab details from dialog | 936 | // grab details from dialog |
934 | // QString package = dlg.getPackageLocation(); | 937 | // QString package = dlg.getPackageLocation(); |
935 | 938 | ||
936 | InstallData *item = new InstallData(); | 939 | InstallData *item = new InstallData(); |
937 | item->option = "I"; | 940 | item->option = "I"; |
938 | item->packageName = package; | 941 | item->packageName = package; |
939 | QList<InstallData> workingPackages; | 942 | QList<InstallData> workingPackages; |
940 | workingPackages.setAutoDelete( TRUE ); | 943 | workingPackages.setAutoDelete( TRUE ); |
941 | workingPackages.append( item ); | 944 | workingPackages.append( item ); |
942 | 945 | ||
943 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); | 946 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); |
944 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 947 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
945 | reloadDocuments = TRUE; | 948 | reloadDocuments = TRUE; |
946 | stack->addWidget( dlg, 3 ); | 949 | stack->addWidget( dlg, 3 ); |
947 | stack->raiseWidget( dlg ); | 950 | stack->raiseWidget( dlg ); |
948 | } | 951 | } |
949 | 952 | ||
950 | 953 | ||
951 | void MainWindow :: applyChanges() | 954 | void MainWindow :: applyChanges() |
952 | { | 955 | { |
953 | stickyOption = ""; | 956 | stickyOption = ""; |
@@ -956,42 +959,42 @@ void MainWindow :: applyChanges() | |||
956 | mgr->writeOutIpkgConf(); | 959 | mgr->writeOutIpkgConf(); |
957 | 960 | ||
958 | // Now for each selected item | 961 | // Now for each selected item |
959 | // deal with it | 962 | // deal with it |
960 | 963 | ||
961 | QList<InstallData> workingPackages; | 964 | QList<InstallData> workingPackages; |
962 | workingPackages.setAutoDelete( TRUE ); | 965 | workingPackages.setAutoDelete( TRUE ); |
963 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 966 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
964 | item != 0 ; | 967 | item != 0 ; |
965 | item = (QCheckListItem *)item->nextSibling() ) | 968 | item = (QCheckListItem *)item->nextSibling() ) |
966 | { | 969 | { |
967 | if ( item->isOn() ) | 970 | if ( item->isOn() ) |
968 | { | 971 | { |
969 | InstallData *instdata = dealWithItem( item ); | 972 | InstallData *instdata = dealWithItem( item ); |
970 | if ( instdata ) | 973 | if ( instdata ) |
971 | workingPackages.append( instdata ); | 974 | workingPackages.append( instdata ); |
972 | else | 975 | else |
973 | return; | 976 | return; |
974 | } | 977 | } |
975 | } | 978 | } |
976 | 979 | ||
977 | if ( workingPackages.count() == 0 ) | 980 | if ( workingPackages.count() == 0 ) |
978 | { | 981 | { |
979 | // Nothing to do | 982 | // Nothing to do |
980 | QMessageBox::information( this, tr( "Nothing to do" ), | 983 | QMessageBox::information( this, tr( "Nothing to do" ), |
981 | tr( "No packages selected" ), tr( "OK" ) ); | 984 | tr( "No packages selected" ), tr( "OK" ) ); |
982 | 985 | ||
983 | return; | 986 | return; |
984 | } | 987 | } |
985 | 988 | ||
986 | // do the stuff | 989 | // do the stuff |
987 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); | 990 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); |
988 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 991 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
989 | reloadDocuments = TRUE; | 992 | reloadDocuments = TRUE; |
990 | stack->addWidget( dlg, 3 ); | 993 | stack->addWidget( dlg, 3 ); |
991 | stack->raiseWidget( dlg ); | 994 | stack->raiseWidget( dlg ); |
992 | } | 995 | } |
993 | 996 | ||
994 | // decide what to do - either remove, upgrade or install | 997 | // decide what to do - either remove, upgrade or install |
995 | // Current rules: | 998 | // Current rules: |
996 | // If not installed - install | 999 | // If not installed - install |
997 | // If installed and different version available - upgrade | 1000 | // If installed and different version available - upgrade |
@@ -1019,17 +1022,17 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1019 | } | 1022 | } |
1020 | else | 1023 | else |
1021 | { | 1024 | { |
1022 | InstallData *newitem = new InstallData(); | 1025 | InstallData *newitem = new InstallData(); |
1023 | newitem->option = "D"; | 1026 | newitem->option = "D"; |
1024 | // If local file, remove using package name, not filename | 1027 | // If local file, remove using package name, not filename |
1025 | if ( p->isPackageStoredLocally() ) | 1028 | if ( p->isPackageStoredLocally() ) |
1026 | name = item->text(); | 1029 | name = item->text(); |
1027 | 1030 | ||
1028 | if ( !p->isPackageStoredLocally() ) | 1031 | if ( !p->isPackageStoredLocally() ) |
1029 | newitem->packageName = p->getInstalledPackageName(); | 1032 | newitem->packageName = p->getInstalledPackageName(); |
1030 | else | 1033 | else |
1031 | newitem->packageName = name; | 1034 | newitem->packageName = name; |
1032 | 1035 | ||
1033 | if ( p->getInstalledTo() ) | 1036 | if ( p->getInstalledTo() ) |
1034 | { | 1037 | { |
1035 | newitem->destination = p->getInstalledTo(); | 1038 | newitem->destination = p->getInstalledTo(); |
@@ -1085,43 +1088,43 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | |||
1085 | // the user to say something like 'remove all' | 1088 | // the user to say something like 'remove all' |
1086 | if ( stickyOption == "" ) | 1089 | if ( stickyOption == "" ) |
1087 | { | 1090 | { |
1088 | QString msgtext; | 1091 | QString msgtext; |
1089 | msgtext = caption.arg( ( const char * )name ); | 1092 | msgtext = caption.arg( ( const char * )name ); |
1090 | QuestionDlg dlg( text, msgtext, secondButton ); | 1093 | QuestionDlg dlg( text, msgtext, secondButton ); |
1091 | switch( dlg.exec() ) | 1094 | switch( dlg.exec() ) |
1092 | { | 1095 | { |
1093 | case 0: // Cancel | 1096 | case 0: // Cancel |
1094 | delete newitem; | 1097 | delete newitem; |
1095 | return 0x0; | 1098 | return 0x0; |
1096 | break; | 1099 | break; |
1097 | case 1: // Remove | 1100 | case 1: // Remove |
1098 | newitem->option = "D"; | 1101 | newitem->option = "D"; |
1099 | // If local file, remove using package name, not filename | 1102 | // If local file, remove using package name, not filename |
1100 | if ( p->isPackageStoredLocally() ) | 1103 | if ( p->isPackageStoredLocally() ) |
1101 | name = item->text(); | 1104 | name = item->text(); |
1102 | break; | 1105 | break; |
1103 | case 2: // Reinstall or Upgrade | 1106 | case 2: // Reinstall or Upgrade |
1104 | newitem->option = secondOption; | 1107 | newitem->option = secondOption; |
1105 | break; | 1108 | break; |
1106 | } | 1109 | } |
1107 | } | 1110 | } |
1108 | else | 1111 | else |
1109 | { | 1112 | { |
1110 | // newitem->option = stickyOption; | 1113 | // newitem->option = stickyOption; |
1111 | } | 1114 | } |
1112 | } | 1115 | } |
1113 | 1116 | ||
1114 | 1117 | ||
1115 | // Check if we are reinstalling the same version | 1118 | // Check if we are reinstalling the same version |
1116 | if ( newitem->option != "R" ) | 1119 | if ( newitem->option != "R" ) |
1117 | newitem->recreateLinks = true; | 1120 | newitem->recreateLinks = true; |
1118 | else | 1121 | else |
1119 | newitem->recreateLinks = false; | 1122 | newitem->recreateLinks = false; |
1120 | 1123 | ||
1121 | // User hit cancel (on dlg - assume remove) | 1124 | // User hit cancel (on dlg - assume remove) |
1122 | return newitem; | 1125 | return newitem; |
1123 | } | 1126 | } |
1124 | } | 1127 | } |
1125 | 1128 | ||
1126 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) | 1129 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) |
1127 | { | 1130 | { |
@@ -1133,24 +1136,24 @@ void MainWindow :: reloadData( InstallDlgImpl *dlg ) | |||
1133 | delete dlg; | 1136 | delete dlg; |
1134 | } | 1137 | } |
1135 | 1138 | ||
1136 | mgr->reloadServerData(); | 1139 | mgr->reloadServerData(); |
1137 | serverSelected( -1, FALSE ); | 1140 | serverSelected( -1, FALSE ); |
1138 | 1141 | ||
1139 | #ifdef QWS | 1142 | #ifdef QWS |
1140 | if ( reloadDocuments ) | 1143 | if ( reloadDocuments ) |
1141 | { | 1144 | { |
1142 | m_status->setText( tr( "Updating Launcher..." ) ); | 1145 | m_status->setText( tr( "Updating Launcher..." ) ); |
1143 | 1146 | ||
1144 | // Finally let the main system update itself | 1147 | // Finally let the main system update itself |
1145 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 1148 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
1146 | QString lf = QString::null; | 1149 | QString lf = QString::null; |
1147 | e << lf; | 1150 | e << lf; |
1148 | } | 1151 | } |
1149 | #endif | 1152 | #endif |
1150 | 1153 | ||
1151 | stack->raiseWidget( networkPkgWindow ); | 1154 | stack->raiseWidget( networkPkgWindow ); |
1152 | } | 1155 | } |
1153 | 1156 | ||
1154 | void MainWindow :: letterPushed( QString t ) | 1157 | void MainWindow :: letterPushed( QString t ) |
1155 | { | 1158 | { |
1156 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 1159 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
@@ -1176,28 +1179,29 @@ void MainWindow :: letterPushed( QString t ) | |||
1176 | packagesList->setSelected( item, true ); | 1179 | packagesList->setSelected( item, true ); |
1177 | packagesList->ensureItemVisible( item ); | 1180 | packagesList->ensureItemVisible( item ); |
1178 | break; | 1181 | break; |
1179 | } | 1182 | } |
1180 | 1183 | ||
1181 | item = (QCheckListItem *)item->nextSibling(); | 1184 | item = (QCheckListItem *)item->nextSibling(); |
1182 | if ( !item ) | 1185 | if ( !item ) |
1183 | item = (QCheckListItem *)packagesList->firstChild(); | 1186 | item = (QCheckListItem *)packagesList->firstChild(); |
1184 | } while ( item != start); | 1187 | } |
1188 | while ( item != start); | ||
1185 | } | 1189 | } |
1186 | 1190 | ||
1187 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) | 1191 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) |
1188 | { | 1192 | { |
1189 | QString itemstr( ((QCheckListItem*)item)->text() ); | 1193 | QString itemstr( ((QCheckListItem*)item)->text() ); |
1190 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); | 1194 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); |
1191 | p->showMaximized(); | 1195 | QPEApplication::showWidget( p ); |
1192 | } | 1196 | } |
1193 | 1197 | ||
1194 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) | 1198 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) |
1195 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) | 1199 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) |
1196 | { | 1200 | { |
1197 | setCaption( caption ); | 1201 | setCaption( caption ); |
1198 | resize( 175, 100 ); | 1202 | resize( 175, 100 ); |
1199 | 1203 | ||
1200 | QGridLayout *layout = new QGridLayout( this ); | 1204 | QGridLayout *layout = new QGridLayout( this ); |
1201 | 1205 | ||
1202 | QLabel *l = new QLabel( text, this ); | 1206 | QLabel *l = new QLabel( text, this ); |
1203 | l->setAlignment( AlignCenter | WordBreak ); | 1207 | l->setAlignment( AlignCenter | WordBreak ); |
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index 4887ceb..9fdf31e 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -19,82 +19,81 @@ | |||
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <fstream> | 30 | #include "settingsimpl.h" |
31 | #include <algorithm> | 31 | #include "global.h" |
32 | using namespace std; | ||
33 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <opie/otabwidget.h> | ||
35 | #ifdef QWS | ||
36 | #include <qpe/config.h> | ||
37 | #include <qpe/resource.h> | ||
38 | #endif | ||
39 | #include <qpe/qpeapplication.h> | ||
40 | |||
41 | /* QT */ | ||
34 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
35 | #include <qgroupbox.h> | 43 | #include <qgroupbox.h> |
36 | #include <qlabel.h> | 44 | #include <qlabel.h> |
37 | #include <qlayout.h> | 45 | #include <qlayout.h> |
38 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
39 | #include <qlistbox.h> | 47 | #include <qlistbox.h> |
40 | #include <qpushbutton.h> | 48 | #include <qpushbutton.h> |
41 | 49 | ||
42 | #include <opie/otabwidget.h> | 50 | /* STD */ |
43 | 51 | #include <fstream> | |
44 | #ifdef QWS | 52 | #include <algorithm> |
45 | #include <qpe/config.h> | 53 | using namespace std; |
46 | #include <qpe/resource.h> | ||
47 | #endif | ||
48 | |||
49 | #include "settingsimpl.h" | ||
50 | |||
51 | #include "global.h" | ||
52 | 54 | ||
53 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 55 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) |
54 | : QDialog( parent, name, modal, fl ) | 56 | : QDialog( parent, name, modal, fl ) |
55 | { | 57 | { |
56 | setCaption( tr( "Configuration" ) ); | 58 | setCaption( tr( "Configuration" ) ); |
57 | 59 | ||
58 | // Setup layout to make everything pretty | 60 | // Setup layout to make everything pretty |
59 | QVBoxLayout *layout = new QVBoxLayout( this ); | 61 | QVBoxLayout *layout = new QVBoxLayout( this ); |
60 | layout->setMargin( 2 ); | 62 | layout->setMargin( 2 ); |
61 | layout->setSpacing( 4 ); | 63 | layout->setSpacing( 4 ); |
62 | 64 | ||
63 | // Setup tabs for all info | 65 | // Setup tabs for all info |
64 | OTabWidget *tabwidget = new OTabWidget( this ); | 66 | OTabWidget *tabwidget = new OTabWidget( this ); |
65 | layout->addWidget( tabwidget ); | 67 | layout->addWidget( tabwidget ); |
66 | 68 | ||
67 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); | 69 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); |
68 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); | 70 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); |
69 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); | 71 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); |
70 | tabwidget->setCurrentTab( tr( "Servers" ) ); | 72 | tabwidget->setCurrentTab( tr( "Servers" ) ); |
71 | 73 | ||
72 | dataMgr = dataManager; | 74 | dataMgr = dataManager; |
73 | setupData(); | 75 | setupData(); |
74 | changed = false; | 76 | changed = false; |
75 | newserver = false; | 77 | newserver = false; |
76 | newdestination = false; | 78 | newdestination = false; |
77 | } | 79 | } |
78 | 80 | ||
79 | SettingsImpl :: ~SettingsImpl() | 81 | SettingsImpl :: ~SettingsImpl() |
80 | { | 82 | { |
81 | |||
82 | } | 83 | } |
83 | 84 | ||
84 | bool SettingsImpl :: showDlg() | 85 | bool SettingsImpl :: showDlg() |
85 | { | 86 | { |
86 | showMaximized(); | 87 | QPEApplication::execDialog( this ); |
87 | exec(); | 88 | if ( changed ) |
88 | 89 | dataMgr->writeOutIpkgConf(); | |
89 | if ( changed ) | ||
90 | dataMgr->writeOutIpkgConf(); | ||
91 | 90 | ||
92 | return changed; | 91 | return changed; |
93 | } | 92 | } |
94 | 93 | ||
95 | QWidget *SettingsImpl :: initServerTab() | 94 | QWidget *SettingsImpl :: initServerTab() |
96 | { | 95 | { |
97 | QWidget *control = new QWidget( this ); | 96 | QWidget *control = new QWidget( this ); |
98 | 97 | ||
99 | QVBoxLayout *vb = new QVBoxLayout( control ); | 98 | QVBoxLayout *vb = new QVBoxLayout( control ); |
100 | 99 | ||
@@ -113,45 +112,45 @@ QWidget *SettingsImpl :: initServerTab() | |||
113 | servers = new QListBox( container ); | 112 | servers = new QListBox( container ); |
114 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 113 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
115 | connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) ); | 114 | connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) ); |
116 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); | 115 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); |
117 | 116 | ||
118 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 117 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
119 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); | 118 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); |
120 | layout->addWidget( btn, 1, 0 ); | 119 | layout->addWidget( btn, 1, 0 ); |
121 | 120 | ||
122 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 121 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
123 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); | 122 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); |
124 | layout->addWidget( btn, 1, 1 ); | 123 | layout->addWidget( btn, 1, 1 ); |
125 | 124 | ||
126 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); | 125 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); |
127 | grpbox->layout()->setSpacing( 2 ); | 126 | grpbox->layout()->setSpacing( 2 ); |
128 | grpbox->layout()->setMargin( 4 ); | 127 | grpbox->layout()->setMargin( 4 ); |
129 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 128 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
130 | 129 | ||
131 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 130 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
132 | 131 | ||
133 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 132 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
134 | grplayout->addWidget( label, 0, 0 ); | 133 | grplayout->addWidget( label, 0, 0 ); |
135 | servername = new QLineEdit( grpbox ); | 134 | servername = new QLineEdit( grpbox ); |
136 | grplayout->addWidget( servername, 0, 1 ); | 135 | grplayout->addWidget( servername, 0, 1 ); |
137 | 136 | ||
138 | label = new QLabel( tr( "Address:" ), grpbox ); | 137 | label = new QLabel( tr( "Address:" ), grpbox ); |
139 | grplayout->addWidget( label, 1, 0 ); | 138 | grplayout->addWidget( label, 1, 0 ); |
140 | serverurl = new QLineEdit( grpbox ); | 139 | serverurl = new QLineEdit( grpbox ); |
141 | grplayout->addWidget( serverurl, 1, 1 ); | 140 | grplayout->addWidget( serverurl, 1, 1 ); |
142 | 141 | ||
143 | active = new QCheckBox( tr( "Active Server" ), grpbox ); | 142 | active = new QCheckBox( tr( "Active Server" ), grpbox ); |
144 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); | 143 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); |
145 | 144 | ||
146 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 145 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
147 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); | 146 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); |
148 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 147 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
149 | 148 | ||
150 | return control; | 149 | return control; |
151 | } | 150 | } |
152 | 151 | ||
153 | QWidget *SettingsImpl :: initDestinationTab() | 152 | QWidget *SettingsImpl :: initDestinationTab() |
154 | { | 153 | { |
155 | QWidget *control = new QWidget( this ); | 154 | QWidget *control = new QWidget( this ); |
156 | 155 | ||
157 | QVBoxLayout *vb = new QVBoxLayout( control ); | 156 | QVBoxLayout *vb = new QVBoxLayout( control ); |
@@ -171,45 +170,45 @@ QWidget *SettingsImpl :: initDestinationTab() | |||
171 | destinations = new QListBox( container ); | 170 | destinations = new QListBox( container ); |
172 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 171 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
173 | connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); | 172 | connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); |
174 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); | 173 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); |
175 | 174 | ||
176 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 175 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
177 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); | 176 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); |
178 | layout->addWidget( btn, 1, 0 ); | 177 | layout->addWidget( btn, 1, 0 ); |
179 | 178 | ||
180 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 179 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
181 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); | 180 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); |
182 | layout->addWidget( btn, 1, 1 ); | 181 | layout->addWidget( btn, 1, 1 ); |
183 | 182 | ||
184 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); | 183 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); |
185 | grpbox->layout()->setSpacing( 2 ); | 184 | grpbox->layout()->setSpacing( 2 ); |
186 | grpbox->layout()->setMargin( 4 ); | 185 | grpbox->layout()->setMargin( 4 ); |
187 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 186 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
188 | 187 | ||
189 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 188 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
190 | 189 | ||
191 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 190 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
192 | grplayout->addWidget( label, 0, 0 ); | 191 | grplayout->addWidget( label, 0, 0 ); |
193 | destinationname = new QLineEdit( grpbox ); | 192 | destinationname = new QLineEdit( grpbox ); |
194 | grplayout->addWidget( destinationname, 0, 1 ); | 193 | grplayout->addWidget( destinationname, 0, 1 ); |
195 | 194 | ||
196 | label = new QLabel( tr( "Location:" ), grpbox ); | 195 | label = new QLabel( tr( "Location:" ), grpbox ); |
197 | grplayout->addWidget( label, 1, 0 ); | 196 | grplayout->addWidget( label, 1, 0 ); |
198 | destinationurl = new QLineEdit( grpbox ); | 197 | destinationurl = new QLineEdit( grpbox ); |
199 | grplayout->addWidget( destinationurl, 1, 1 ); | 198 | grplayout->addWidget( destinationurl, 1, 1 ); |
200 | 199 | ||
201 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); | 200 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); |
202 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); | 201 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); |
203 | 202 | ||
204 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 203 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
205 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); | 204 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); |
206 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 205 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
207 | 206 | ||
208 | return control; | 207 | return control; |
209 | } | 208 | } |
210 | 209 | ||
211 | QWidget *SettingsImpl :: initProxyTab() | 210 | QWidget *SettingsImpl :: initProxyTab() |
212 | { | 211 | { |
213 | QWidget *control = new QWidget( this ); | 212 | QWidget *control = new QWidget( this ); |
214 | 213 | ||
215 | QVBoxLayout *vb = new QVBoxLayout( control ); | 214 | QVBoxLayout *vb = new QVBoxLayout( control ); |
@@ -230,64 +229,64 @@ QWidget *SettingsImpl :: initProxyTab() | |||
230 | grpbox->layout()->setSpacing( 2 ); | 229 | grpbox->layout()->setSpacing( 2 ); |
231 | grpbox->layout()->setMargin( 4 ); | 230 | grpbox->layout()->setMargin( 4 ); |
232 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); | 231 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); |
233 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 232 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
234 | txtHttpProxy = new QLineEdit( grpbox ); | 233 | txtHttpProxy = new QLineEdit( grpbox ); |
235 | grplayout->addWidget( txtHttpProxy ); | 234 | grplayout->addWidget( txtHttpProxy ); |
236 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 235 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
237 | grplayout->addWidget( chkHttpProxyEnabled ); | 236 | grplayout->addWidget( chkHttpProxyEnabled ); |
238 | 237 | ||
239 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 238 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
240 | grpbox->layout()->setSpacing( 2 ); | 239 | grpbox->layout()->setSpacing( 2 ); |
241 | grpbox->layout()->setMargin( 4 ); | 240 | grpbox->layout()->setMargin( 4 ); |
242 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); | 241 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); |
243 | grplayout = new QVBoxLayout( grpbox->layout() ); | 242 | grplayout = new QVBoxLayout( grpbox->layout() ); |
244 | txtFtpProxy = new QLineEdit( grpbox ); | 243 | txtFtpProxy = new QLineEdit( grpbox ); |
245 | grplayout->addWidget( txtFtpProxy ); | 244 | grplayout->addWidget( txtFtpProxy ); |
246 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 245 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
247 | grplayout->addWidget( chkFtpProxyEnabled ); | 246 | grplayout->addWidget( chkFtpProxyEnabled ); |
248 | 247 | ||
249 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 248 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
250 | layout->addWidget( label, 2, 0 ); | 249 | layout->addWidget( label, 2, 0 ); |
251 | txtUsername = new QLineEdit( container ); | 250 | txtUsername = new QLineEdit( container ); |
252 | layout->addWidget( txtUsername, 2, 1 ); | 251 | layout->addWidget( txtUsername, 2, 1 ); |
253 | 252 | ||
254 | label = new QLabel( tr( "Password:" ), container ); | 253 | label = new QLabel( tr( "Password:" ), container ); |
255 | layout->addWidget( label, 3, 0 ); | 254 | layout->addWidget( label, 3, 0 ); |
256 | txtPassword = new QLineEdit( container ); | 255 | txtPassword = new QLineEdit( container ); |
257 | layout->addWidget( txtPassword, 3, 1 ); | 256 | layout->addWidget( txtPassword, 3, 1 ); |
258 | 257 | ||
259 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); | 258 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); |
260 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); | 259 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); |
261 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); | 260 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); |
262 | 261 | ||
263 | return control; | 262 | return control; |
264 | } | 263 | } |
265 | 264 | ||
266 | void SettingsImpl :: setupData() | 265 | void SettingsImpl :: setupData() |
267 | { | 266 | { |
268 | // add servers | 267 | // add servers |
269 | QString serverName; | 268 | QString serverName; |
270 | QListIterator<Server> it( dataMgr->getServerList() ); | 269 | QListIterator<Server> it( dataMgr->getServerList() ); |
271 | for ( ; it.current(); ++it ) | 270 | for ( ; it.current(); ++it ) |
272 | { | 271 | { |
273 | serverName = it.current()->getServerName(); | 272 | serverName = it.current()->getServerName(); |
274 | if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) | 273 | if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) |
275 | continue; | 274 | continue; |
276 | 275 | ||
277 | servers->insertItem( serverName ); | 276 | servers->insertItem( serverName ); |
278 | } | 277 | } |
279 | 278 | ||
280 | 279 | ||
281 | // add destinations | 280 | // add destinations |
282 | QListIterator<Destination> it2( dataMgr->getDestinationList() ); | 281 | QListIterator<Destination> it2( dataMgr->getDestinationList() ); |
283 | for ( ; it2.current(); ++it2 ) | 282 | for ( ; it2.current(); ++it2 ) |
284 | destinations->insertItem( it2.current()->getDestinationName() ); | 283 | destinations->insertItem( it2.current()->getDestinationName() ); |
285 | 284 | ||
286 | // setup proxy tab | 285 | // setup proxy tab |
287 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); | 286 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); |
288 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); | 287 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); |
289 | txtUsername->setText( dataMgr->getProxyUsername() ); | 288 | txtUsername->setText( dataMgr->getProxyUsername() ); |
290 | txtPassword->setText( dataMgr->getProxyPassword() ); | 289 | txtPassword->setText( dataMgr->getProxyPassword() ); |
291 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); | 290 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); |
292 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); | 291 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); |
293 | } | 292 | } |
@@ -331,63 +330,63 @@ void SettingsImpl :: removeServer() | |||
331 | { | 330 | { |
332 | dataMgr->getServerList().removeRef( s ); | 331 | dataMgr->getServerList().removeRef( s ); |
333 | servers->removeItem( currentSelectedServer ); | 332 | servers->removeItem( currentSelectedServer ); |
334 | } | 333 | } |
335 | } | 334 | } |
336 | 335 | ||
337 | void SettingsImpl :: changeServerDetails() | 336 | void SettingsImpl :: changeServerDetails() |
338 | { | 337 | { |
339 | changed = true; | 338 | changed = true; |
340 | 339 | ||
341 | QString newName = servername->text(); | 340 | QString newName = servername->text(); |
342 | 341 | ||
343 | // Convert any spaces to underscores | 342 | // Convert any spaces to underscores |
344 | char *tmpStr = new char[newName.length() + 1]; | 343 | char *tmpStr = new char[newName.length() + 1]; |
345 | for ( unsigned int i = 0 ; i < newName.length() ; ++i ) | 344 | for ( unsigned int i = 0 ; i < newName.length() ; ++i ) |
346 | { | 345 | { |
347 | if ( newName[i] == ' ' ) | 346 | if ( newName[i] == ' ' ) |
348 | tmpStr[i] = '_'; | 347 | tmpStr[i] = '_'; |
349 | else | 348 | else |
350 | tmpStr[i] = newName[i].latin1(); | 349 | tmpStr[i] = newName[i].latin1(); |
351 | } | 350 | } |
352 | tmpStr[newName.length()] = '\0'; | 351 | tmpStr[newName.length()] = '\0'; |
353 | 352 | ||
354 | newName = tmpStr; | 353 | newName = tmpStr; |
355 | delete tmpStr; | 354 | delete tmpStr; |
356 | 355 | ||
357 | if ( !newserver ) | 356 | if ( !newserver ) |
358 | { | 357 | { |
359 | Server *s = dataMgr->getServer( servers->currentText() ); | 358 | Server *s = dataMgr->getServer( servers->currentText() ); |
360 | if ( s ) | 359 | if ( s ) |
361 | { | 360 | { |
362 | // Update url | 361 | // Update url |
363 | s->setServerUrl( serverurl->text() ); | 362 | s->setServerUrl( serverurl->text() ); |
364 | s->setActive( active->isChecked() ); | 363 | s->setActive( active->isChecked() ); |
365 | 364 | ||
366 | // Check if server name has changed, if it has then we need to replace the key in the map | 365 | // Check if server name has changed, if it has then we need to replace the key in the map |
367 | if ( serverName != newName ) | 366 | if ( serverName != newName ) |
368 | { | 367 | { |
369 | // Update server name | 368 | // Update server name |
370 | s->setServerName( newName ); | 369 | s->setServerName( newName ); |
371 | } | 370 | } |
372 | 371 | ||
373 | // Update list box | 372 | // Update list box |
374 | servers->changeItem( newName, currentSelectedServer ); | 373 | servers->changeItem( newName, currentSelectedServer ); |
375 | } | 374 | } |
376 | } | 375 | } |
377 | else | 376 | else |
378 | { | 377 | { |
379 | Server s( newName, serverurl->text() ); | 378 | Server s( newName, serverurl->text() ); |
380 | dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); | 379 | dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); |
381 | dataMgr->getServerList().last()->setActive( active->isChecked() ); | 380 | dataMgr->getServerList().last()->setActive( active->isChecked() ); |
382 | servers->insertItem( newName ); | 381 | servers->insertItem( newName ); |
383 | servers->setCurrentItem( servers->count() ); | 382 | servers->setCurrentItem( servers->count() ); |
384 | newserver = false; | 383 | newserver = false; |
385 | } | 384 | } |
386 | } | 385 | } |
387 | 386 | ||
388 | //------------------ Destinations tab ---------------------- | 387 | //------------------ Destinations tab ---------------------- |
389 | 388 | ||
390 | void SettingsImpl :: editDestination( int sel ) | 389 | void SettingsImpl :: editDestination( int sel ) |
391 | { | 390 | { |
392 | currentSelectedDestination = sel; | 391 | currentSelectedDestination = sel; |
393 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 392 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
@@ -404,84 +403,86 @@ void SettingsImpl :: editDestination( int sel ) | |||
404 | destinationname->setText( "" ); | 403 | destinationname->setText( "" ); |
405 | destinationurl->setText( "" ); | 404 | destinationurl->setText( "" ); |
406 | linkToRoot->setChecked( false ); | 405 | linkToRoot->setChecked( false ); |
407 | } | 406 | } |
408 | } | 407 | } |
409 | 408 | ||
410 | void SettingsImpl :: newDestination() | 409 | void SettingsImpl :: newDestination() |
411 | { | 410 | { |
412 | newdestination = true; | 411 | newdestination = true; |
413 | destinationname->setText( "" ); | 412 | destinationname->setText( "" ); |
414 | destinationurl->setText( "" ); | 413 | destinationurl->setText( "" ); |
415 | destinationname->setFocus(); | 414 | destinationname->setFocus(); |
416 | linkToRoot->setChecked( true ); | 415 | linkToRoot->setChecked( true ); |
417 | } | 416 | } |
418 | 417 | ||
419 | void SettingsImpl :: removeDestination() | 418 | void SettingsImpl :: removeDestination() |
420 | { | 419 | { |
421 | changed = true; | 420 | changed = true; |
422 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 421 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
423 | if ( d ) | 422 | if ( d ) |
424 | { | 423 | { |
425 | dataMgr->getDestinationList().removeRef( d ); | 424 | dataMgr->getDestinationList().removeRef( d ); |
426 | destinations->removeItem( currentSelectedDestination ); | 425 | destinations->removeItem( currentSelectedDestination ); |
427 | } | 426 | } |
428 | } | 427 | } |
429 | 428 | ||
430 | void SettingsImpl :: changeDestinationDetails() | 429 | void SettingsImpl :: changeDestinationDetails() |
431 | { | 430 | { |
432 | changed = true; | 431 | changed = true; |
433 | 432 | ||
434 | #ifdef QWS | 433 | #ifdef QWS |
435 | Config cfg( "aqpkg" ); | 434 | Config cfg( "aqpkg" ); |
436 | cfg.setGroup( "destinations" ); | 435 | cfg.setGroup( "destinations" ); |
437 | #endif | 436 | #endif |
438 | 437 | ||
439 | QString newName = destinationname->text(); | 438 | QString newName = destinationname->text(); |
440 | if ( !newdestination ) | 439 | if ( !newdestination ) |
441 | { | 440 | { |
442 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 441 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
443 | if ( d ) | 442 | if ( d ) |
444 | { | 443 | { |
445 | // Update url | 444 | // Update url |
446 | d->setDestinationPath( destinationurl->text() ); | 445 | d->setDestinationPath( destinationurl->text() ); |
447 | d->linkToRoot( linkToRoot->isChecked() ); | 446 | d->linkToRoot( linkToRoot->isChecked() ); |
448 | 447 | ||
449 | // Check if server name has changed, if it has then we need to replace the key in the map | 448 | // Check if server name has changed, if it has then we need to replace the key in the map |
450 | if ( destinationName != newName ) | 449 | if ( destinationName != newName ) |
451 | { | 450 | { |
452 | // Update server name | 451 | // Update server name |
453 | d->setDestinationName( newName ); | 452 | d->setDestinationName( newName ); |
454 | 453 | ||
455 | // Update list box | 454 | // Update list box |
456 | destinations->changeItem( newName, currentSelectedDestination ); | 455 | destinations->changeItem( newName, currentSelectedDestination ); |
457 | } | 456 | } |
458 | 457 | ||
459 | #ifdef QWS | 458 | #ifdef QWS |
460 | QString key = newName; | 459 | QString key = newName; |
461 | key += "_linkToRoot"; | 460 | key += "_linkToRoot"; |
462 | int val = d->linkToRoot(); | 461 | int val = d->linkToRoot(); |
463 | cfg.writeEntry( key, val ); | 462 | cfg.writeEntry( key, val ); |
464 | #endif | 463 | #endif |
465 | } | 464 | |
466 | } | 465 | } |
467 | else | 466 | } |
468 | { | 467 | else |
469 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); | 468 | { |
470 | destinations->insertItem( newName ); | 469 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); |
471 | destinations->setCurrentItem( destinations->count() ); | 470 | destinations->insertItem( newName ); |
472 | newdestination = false; | 471 | destinations->setCurrentItem( destinations->count() ); |
472 | newdestination = false; | ||
473 | 473 | ||
474 | #ifdef QWS | 474 | #ifdef QWS |
475 | QString key = newName; | 475 | QString key = newName; |
476 | key += "_linkToRoot"; | 476 | key += "_linkToRoot"; |
477 | cfg.writeEntry( key, true ); | 477 | cfg.writeEntry( key, true ); |
478 | #endif | 478 | #endif |
479 | } | 479 | |
480 | } | ||
480 | } | 481 | } |
481 | 482 | ||
482 | //------------------ Proxy tab ---------------------- | 483 | //------------------ Proxy tab ---------------------- |
483 | void SettingsImpl :: proxyApplyChanges() | 484 | void SettingsImpl :: proxyApplyChanges() |
484 | { | 485 | { |
485 | changed = true; | 486 | changed = true; |
486 | dataMgr->setHttpProxy( txtHttpProxy->text() ); | 487 | dataMgr->setHttpProxy( txtHttpProxy->text() ); |
487 | dataMgr->setFtpProxy( txtFtpProxy->text() ); | 488 | dataMgr->setFtpProxy( txtFtpProxy->text() ); |
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index a00193d..977c283 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp | |||
@@ -1,33 +1,36 @@ | |||
1 | 1 | ||
2 | #include "backuprestore.h" | 2 | #include "backuprestore.h" |
3 | //#include "output.h" | ||
4 | #include "errordialog.h" | 3 | #include "errordialog.h" |
5 | 4 | ||
5 | /* OPIE */ | ||
6 | #include <opie2/ostorageinfo.h> | ||
7 | #include <qpe/qpeapplication.h> | ||
8 | |||
9 | /* QT */ | ||
6 | #include <qapplication.h> | 10 | #include <qapplication.h> |
7 | #include <qmultilineedit.h> | 11 | #include <qmultilineedit.h> |
8 | |||
9 | #include <qdir.h> | 12 | #include <qdir.h> |
10 | #include <qfile.h> | 13 | #include <qfile.h> |
11 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
12 | #include <qlistview.h> | 15 | #include <qlistview.h> |
13 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
14 | #include <qheader.h> | 17 | #include <qheader.h> |
15 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
16 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
17 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
18 | #include <qcombobox.h> | 21 | #include <qcombobox.h> |
19 | #include <qlist.h> | 22 | #include <qlist.h> |
20 | #include <stdlib.h> | 23 | #include <stdlib.h> |
21 | #include <qregexp.h> | 24 | #include <qregexp.h> |
22 | #include <qtextstream.h> | 25 | #include <qtextstream.h> |
23 | #include <qtextview.h> | 26 | #include <qtextview.h> |
24 | #include <opie2/ostorageinfo.h> | ||
25 | 27 | ||
28 | /* STD */ | ||
26 | #include <errno.h> | 29 | #include <errno.h> |
27 | #include <stdlib.h> | 30 | #include <stdlib.h> |
28 | #include <unistd.h> | 31 | #include <unistd.h> |
29 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
30 | #include <dirent.h> | 33 | #include <dirent.h> |
31 | 34 | ||
32 | #define HEADER_NAME 0 | 35 | #define HEADER_NAME 0 |
33 | #define HEADER_BACKUP 1 | 36 | #define HEADER_BACKUP 1 |
@@ -36,17 +39,16 @@ | |||
36 | #define EXTENSION ".bck" | 39 | #define EXTENSION ".bck" |
37 | 40 | ||
38 | const QString tempFileName = "/tmp/backup.err"; | 41 | const QString tempFileName = "/tmp/backup.err"; |
39 | 42 | ||
40 | 43 | ||
41 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) | 44 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) |
42 | : BackupAndRestoreBase(parent, name, fl) | 45 | : BackupAndRestoreBase(parent, name, fl) |
43 | { | 46 | { |
44 | this->showMaximized(); | ||
45 | backupList->header()->hide(); | 47 | backupList->header()->hide(); |
46 | restoreList->header()->hide(); | 48 | restoreList->header()->hide(); |
47 | connect(backupButton, SIGNAL(clicked()), | 49 | connect(backupButton, SIGNAL(clicked()), |
48 | this, SLOT(backup())); | 50 | this, SLOT(backup())); |
49 | connect(restoreButton, SIGNAL(clicked()), | 51 | connect(restoreButton, SIGNAL(clicked()), |
50 | this, SLOT(restore())); | 52 | this, SLOT(restore())); |
51 | connect(backupList, SIGNAL(clicked( QListViewItem * )), | 53 | connect(backupList, SIGNAL(clicked( QListViewItem * )), |
52 | this, SLOT(selectItem(QListViewItem*))); | 54 | this, SLOT(selectItem(QListViewItem*))); |
@@ -125,16 +127,17 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f | |||
125 | { | 127 | { |
126 | if(*dontBackupList.at(i2) == text) | 128 | if(*dontBackupList.at(i2) == text) |
127 | { | 129 | { |
128 | selectItem(list.at(i)); | 130 | selectItem(list.at(i)); |
129 | break; | 131 | break; |
130 | } | 132 | } |
131 | } | 133 | } |
132 | } | 134 | } |
135 | QPEApplication::showWidget( this ); | ||
133 | } | 136 | } |
134 | 137 | ||
135 | BackupAndRestore::~BackupAndRestore() | 138 | BackupAndRestore::~BackupAndRestore() |
136 | { | 139 | { |
137 | QList<QListViewItem> list; | 140 | QList<QListViewItem> list; |
138 | getAllItems(backupList->firstChild(), list); | 141 | getAllItems(backupList->firstChild(), list); |
139 | 142 | ||
140 | Config config("BackupAndRestore"); | 143 | Config config("BackupAndRestore"); |
@@ -282,18 +285,17 @@ void BackupAndRestore::backup() | |||
282 | errorFile.close(); | 285 | errorFile.close(); |
283 | 286 | ||
284 | pErrDialog->m_textarea->setText( s ); | 287 | pErrDialog->m_textarea->setText( s ); |
285 | } | 288 | } |
286 | else | 289 | else |
287 | { | 290 | { |
288 | pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); | 291 | pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); |
289 | } | 292 | } |
290 | pErrDialog->showMaximized(); | 293 | QPEApplication::execDialog( pErrDialog ); |
291 | pErrDialog->exec(); | ||
292 | delete pErrDialog; | 294 | delete pErrDialog; |
293 | break; | 295 | break; |
294 | } | 296 | } |
295 | setCaption(tr("Backup and Restore.. Failed !!")); | 297 | setCaption(tr("Backup and Restore.. Failed !!")); |
296 | return; | 298 | return; |
297 | } | 299 | } |
298 | else | 300 | else |
299 | { | 301 | { |
@@ -447,18 +449,17 @@ void BackupAndRestore::restore() | |||
447 | errorFile.close(); | 449 | errorFile.close(); |
448 | 450 | ||
449 | pErrDialog->m_textarea->setText( s ); | 451 | pErrDialog->m_textarea->setText( s ); |
450 | } | 452 | } |
451 | else | 453 | else |
452 | { | 454 | { |
453 | pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) ); | 455 | pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) ); |
454 | } | 456 | } |
455 | pErrDialog->showMaximized(); | 457 | QPEApplication::execDialog( pErrDialog ); |
456 | pErrDialog->exec(); | ||
457 | delete pErrDialog; | 458 | delete pErrDialog; |
458 | 459 | ||
459 | setCaption(tr("Backup and Restore.. Failed !!")); | 460 | setCaption(tr("Backup and Restore.. Failed !!")); |
460 | return; | 461 | return; |
461 | 462 | ||
462 | break; | 463 | break; |
463 | 464 | ||
464 | } | 465 | } |
diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp index e94904b..9da090d 100644 --- a/noncore/settings/networksettings/ppp/devices.cpp +++ b/noncore/settings/networksettings/ppp/devices.cpp | |||
@@ -19,35 +19,41 @@ | |||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | * Library General Public License for more details. | 20 | * Library General Public License for more details. |
21 | * | 21 | * |
22 | * You should have received a copy of the GNU Library General Public | 22 | * You should have received a copy of the GNU Library General Public |
23 | * License along with this program; if not, write to the Free | 23 | * License along with this program; if not, write to the Free |
24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "interfaceppp.h" | ||
28 | #include "devices.h" | ||
29 | #include "authwidget.h" | ||
30 | #include "pppdata.h" | ||
31 | #include "edit.h" | ||
32 | #include "general.h" | ||
33 | |||
34 | /* OPIE */ | ||
35 | #include <qpe/qpeapplication.h> | ||
36 | |||
37 | /* QT */ | ||
27 | #include <qdir.h> | 38 | #include <qdir.h> |
28 | #include <stdlib.h> | ||
29 | #include <qlayout.h> | 39 | #include <qlayout.h> |
30 | #include <qtabwidget.h> | 40 | #include <qtabwidget.h> |
31 | #include <qtabdialog.h> | 41 | #include <qtabdialog.h> |
32 | #include <qwhatsthis.h> | 42 | #include <qwhatsthis.h> |
33 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
34 | |||
35 | #include <qapplication.h> | 44 | #include <qapplication.h> |
36 | #include <qbuttongroup.h> | 45 | #include <qbuttongroup.h> |
37 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
38 | #include <qvgroupbox.h> | 47 | #include <qvgroupbox.h> |
39 | 48 | ||
40 | #include "interfaceppp.h" | 49 | /* STD */ |
41 | #include "devices.h" | 50 | #include <stdlib.h> |
42 | #include "authwidget.h" | 51 | |
43 | #include "pppdata.h" | ||
44 | #include "edit.h" | ||
45 | #include "general.h" | ||
46 | 52 | ||
47 | void parseargs(char* buf, char** args); | 53 | void parseargs(char* buf, char** args); |
48 | 54 | ||
49 | DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) | 55 | DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) |
50 | : ChooserWidget(ip->data(), parent, name, f) | 56 | : ChooserWidget(ip->data(), parent, name, f) |
51 | { | 57 | { |
52 | _ifaceppp = ip; | 58 | _ifaceppp = ip; |
53 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected device")); | 59 | QWhatsThis::add(edit_b, tr("Allows you to modify the selected device")); |
@@ -186,18 +192,17 @@ int DevicesWidget::doTab(){ | |||
186 | tabWindow->addTab( modem1, tr("&Device") ); | 192 | tabWindow->addTab( modem1, tr("&Device") ); |
187 | modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" ); | 193 | modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" ); |
188 | tabWindow->addTab( modem2, tr("&Modem") ); | 194 | tabWindow->addTab( modem2, tr("&Modem") ); |
189 | 195 | ||
190 | int result = 0; | 196 | int result = 0; |
191 | bool ok = false; | 197 | bool ok = false; |
192 | 198 | ||
193 | while (!ok){ | 199 | while (!ok){ |
194 | dlg->showMaximized(); | 200 | result = QPEApplication::execDialog( dlg ); |
195 | result = dlg->exec(); | ||
196 | ok = true; | 201 | ok = true; |
197 | 202 | ||
198 | if(result == QDialog::Accepted) { | 203 | if(result == QDialog::Accepted) { |
199 | if (!modem1->save()){ | 204 | if (!modem1->save()){ |
200 | QMessageBox::critical(this, "error", tr( "You must enter a unique device name")); | 205 | QMessageBox::critical(this, "error", tr( "You must enter a unique device name")); |
201 | ok = false; | 206 | ok = false; |
202 | }else{ | 207 | }else{ |
203 | modem2->save(); | 208 | modem2->save(); |
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index ceac90c..7d21605 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -18,1117 +18,1194 @@ | |||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 | * Library General Public License for more details. | 19 | * Library General Public License for more details. |
20 | * | 20 | * |
21 | * You should have received a copy of the GNU Library General Public | 21 | * You should have received a copy of the GNU Library General Public |
22 | * License along with this program; if not, write to the Free | 22 | * License along with this program; if not, write to the Free |
23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <string.h> | 26 | #include "edit.h" |
27 | #include <termios.h> | 27 | #include "pppdata.h" |
28 | #include "iplined.h" | ||
29 | #include "auth.h" | ||
30 | |||
31 | /* OPIE */ | ||
32 | #include <qpe/resource.h> | ||
33 | #include <qpe/qpeapplication.h> | ||
34 | |||
35 | /* QT */ | ||
28 | #include <qlayout.h> | 36 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
30 | #include <qwhatsthis.h> | 38 | #include <qwhatsthis.h> |
31 | #include <qregexp.h> | 39 | #include <qregexp.h> |
32 | #include <qapplication.h> | 40 | #include <qapplication.h> |
33 | #include <qbuttongroup.h> | 41 | #include <qbuttongroup.h> |
34 | #include <qvgroupbox.h> | 42 | #include <qvgroupbox.h> |
35 | #include <qhbox.h> | 43 | #include <qhbox.h> |
36 | #include <qdialog.h> | 44 | #include <qdialog.h> |
37 | #include <qpe/resource.h> | ||
38 | 45 | ||
39 | #include "edit.h" | 46 | /* STD */ |
40 | #include "pppdata.h" | 47 | |
41 | #include "iplined.h" | 48 | #include <string.h> |
42 | #include "auth.h" | 49 | #include <termios.h> |
43 | 50 | ||
44 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount | 51 | DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount |
45 | , const char *name ) | 52 | , const char *name ) |
46 | : QWidget(parent, name), _pppdata(pd) | 53 | : QWidget(parent, name), _pppdata(pd) |
47 | { | 54 | { |
48 | const int GRIDROWS = 6; | 55 | const int GRIDROWS = 6; |
49 | 56 | ||
50 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); | 57 | QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); |
51 | 58 | ||
52 | connect_label = new QLabel(tr("Connection name:"), this); | 59 | connect_label = new QLabel(tr("Connection name:"), this); |
53 | tl->addWidget(connect_label, 0, 0); | 60 | tl->addWidget(connect_label, 0, 0); |
54 | 61 | ||
55 | connectname_l = new QLineEdit(this); | 62 | connectname_l = new QLineEdit(this); |
56 | // connectname_l->setMaxLength(ACCNAME_SIZE); | 63 | // connectname_l->setMaxLength(ACCNAME_SIZE); |
57 | tl->addWidget(connectname_l, 0, 1); | 64 | tl->addWidget(connectname_l, 0, 1); |
58 | QString tmp = tr("Type in a unique name for this connection"); | 65 | QString tmp = tr("Type in a unique name for this connection"); |
59 | 66 | ||
60 | QWhatsThis::add(connect_label,tmp); | 67 | QWhatsThis::add(connect_label,tmp); |
61 | QWhatsThis::add(connectname_l,tmp); | 68 | QWhatsThis::add(connectname_l,tmp); |
62 | 69 | ||
63 | 70 | ||
64 | number_label = new QLabel(tr("Phone number:"), this); | 71 | number_label = new QLabel(tr("Phone number:"), this); |
65 | number_label->setAlignment(AlignTop|AlignLeft); | 72 | number_label->setAlignment(AlignTop|AlignLeft); |
66 | tl->addWidget(number_label, 1, 0); | 73 | tl->addWidget(number_label, 1, 0); |
67 | 74 | ||
68 | QHBoxLayout *lpn = new QHBoxLayout(5); | 75 | QHBoxLayout *lpn = new QHBoxLayout(5); |
69 | tl->addLayout(lpn, 1, 1); | 76 | tl->addLayout(lpn, 1, 1); |
70 | numbers = new QListBox(this); | 77 | numbers = new QListBox(this); |
71 | // numbers->setMinimumSize(120, 70); | 78 | // numbers->setMinimumSize(120, 70); |
72 | lpn->addWidget(numbers); | 79 | lpn->addWidget(numbers); |
73 | QVBoxLayout *lpn1 = new QVBoxLayout; | 80 | QVBoxLayout *lpn1 = new QVBoxLayout; |
74 | lpn->addLayout(lpn1); | 81 | lpn->addLayout(lpn1); |
75 | add = new QPushButton(tr("&Add..."), this); | 82 | add = new QPushButton(tr("&Add..."), this); |
76 | del = new QPushButton(tr("&Remove"), this); | 83 | del = new QPushButton(tr("&Remove"), this); |
77 | 84 | ||
78 | up = new QPushButton(this); | 85 | up = new QPushButton(this); |
79 | up->setPixmap( Resource::loadPixmap("up") ); | 86 | up->setPixmap( Resource::loadPixmap("up") ); |
80 | down = new QPushButton(this); | 87 | down = new QPushButton(this); |
81 | down->setPixmap( Resource::loadPixmap("down") ); | 88 | down->setPixmap( Resource::loadPixmap("down") ); |
82 | lpn1->addWidget(add); | 89 | lpn1->addWidget(add); |
83 | lpn1->addWidget(del); | 90 | lpn1->addWidget(del); |
84 | lpn1->addStretch(1); | 91 | lpn1->addStretch(1); |
85 | lpn1->addWidget(up); | 92 | lpn1->addWidget(up); |
86 | lpn1->addWidget(down); | 93 | lpn1->addWidget(down); |
87 | connect(add, SIGNAL(clicked()), | 94 | connect(add, SIGNAL(clicked()), |
88 | this, SLOT(addNumber())); | 95 | this, SLOT(addNumber())); |
89 | connect(del, SIGNAL(clicked()), | 96 | connect(del, SIGNAL(clicked()), |
90 | this, SLOT(delNumber())); | 97 | this, SLOT(delNumber())); |
91 | connect(up, SIGNAL(clicked()), | 98 | connect(up, SIGNAL(clicked()), |
92 | this, SLOT(upNumber())); | 99 | this, SLOT(upNumber())); |
93 | connect(down, SIGNAL(clicked()), | 100 | connect(down, SIGNAL(clicked()), |
94 | this, SLOT(downNumber())); | 101 | this, SLOT(downNumber())); |
95 | connect(numbers, SIGNAL(highlighted(int)), | 102 | connect(numbers, SIGNAL(highlighted(int)), |
96 | this, SLOT(selectionChanged(int))); | 103 | this, SLOT(selectionChanged(int))); |
97 | numbersChanged(); | 104 | numbersChanged(); |
98 | 105 | ||
99 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" | 106 | tmp = tr("<p>Specifies the phone numbers to dial. You\n" |
100 | "can supply multiple numbers here, simply\n" | 107 | "can supply multiple numbers here, simply\n" |
101 | "click on \"Add\". You can arrange the\n" | 108 | "click on \"Add\". You can arrange the\n" |
102 | "order the numbers are tried by using the\n" | 109 | "order the numbers are tried by using the\n" |
103 | "arrow buttons.\n\n" | 110 | "arrow buttons.\n\n" |
104 | "When a number is busy or fails, <i>kppp</i> will \n" | 111 | "When a number is busy or fails, <i>kppp</i> will \n" |
105 | "try the next number and so on"); | 112 | "try the next number and so on"); |
106 | |||
107 | QWhatsThis::add(number_label,tmp); | ||
108 | QWhatsThis::add(numbers,tmp); | ||
109 | |||
110 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); | ||
111 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | ||
112 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | ||
113 | |||
114 | // Set defaults if editing an existing connection | ||
115 | if(!isnewaccount) { | ||
116 | connectname_l->setText(_pppdata->accname()); | ||
117 | |||
118 | // insert the phone numbers into the listbox | ||
119 | QString n = _pppdata->phonenumber(); | ||
120 | QString tmp = ""; | ||
121 | uint idx = 0; | ||
122 | while(idx != n.length()) { | ||
123 | if(n[idx] == ':') { | ||
124 | if(tmp.length() > 0) | ||
125 | numbers->insertItem(tmp); | ||
126 | tmp = ""; | ||
127 | } else | ||
128 | tmp += n[idx]; | ||
129 | idx++; | ||
130 | } | ||
131 | if(tmp.length() > 0) | ||
132 | numbers->insertItem(tmp); | ||
133 | 113 | ||
134 | } | 114 | QWhatsThis::add(number_label,tmp); |
115 | QWhatsThis::add(numbers,tmp); | ||
116 | |||
117 | pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); | ||
118 | connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); | ||
119 | tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); | ||
120 | |||
121 | // Set defaults if editing an existing connection | ||
122 | if(!isnewaccount) | ||
123 | { | ||
124 | connectname_l->setText(_pppdata->accname()); | ||
125 | |||
126 | // insert the phone numbers into the listbox | ||
127 | QString n = _pppdata->phonenumber(); | ||
128 | QString tmp = ""; | ||
129 | uint idx = 0; | ||
130 | while(idx != n.length()) | ||
131 | { | ||
132 | if(n[idx] == ':') | ||
133 | { | ||
134 | if(tmp.length() > 0) | ||
135 | numbers->insertItem(tmp); | ||
136 | tmp = ""; | ||
137 | } | ||
138 | else | ||
139 | tmp += n[idx]; | ||
140 | idx++; | ||
141 | } | ||
142 | if(tmp.length() > 0) | ||
143 | numbers->insertItem(tmp); | ||
135 | 144 | ||
136 | numbersChanged(); | 145 | } |
137 | tl->activate(); | 146 | |
147 | numbersChanged(); | ||
148 | tl->activate(); | ||
138 | } | 149 | } |
139 | 150 | ||
140 | bool DialWidget::save() { | 151 | bool DialWidget::save() |
141 | //first check to make sure that the account name is unique! | 152 | { |
142 | if(connectname_l->text().isEmpty() || | 153 | //first check to make sure that the account name is unique! |
143 | !_pppdata->isUniqueAccname(connectname_l->text())) { | 154 | if(connectname_l->text().isEmpty() || |
144 | return false; | 155 | !_pppdata->isUniqueAccname(connectname_l->text())) |
145 | } else { | 156 | { |
146 | _pppdata->setAccname(connectname_l->text()); | 157 | return false; |
147 | |||
148 | QString number = ""; | ||
149 | for(uint i = 0; i < numbers->count(); i++) { | ||
150 | if(i != 0) | ||
151 | number += ":"; | ||
152 | number += numbers->text(i); | ||
153 | } | 158 | } |
159 | else | ||
160 | { | ||
161 | _pppdata->setAccname(connectname_l->text()); | ||
162 | |||
163 | QString number = ""; | ||
164 | for(uint i = 0; i < numbers->count(); i++) | ||
165 | { | ||
166 | if(i != 0) | ||
167 | number += ":"; | ||
168 | number += numbers->text(i); | ||
169 | } | ||
154 | 170 | ||
155 | _pppdata->setPhonenumber(number); | 171 | _pppdata->setPhonenumber(number); |
156 | return true; | 172 | return true; |
157 | } | 173 | } |
158 | } | 174 | } |
159 | 175 | ||
160 | 176 | ||
161 | void DialWidget::numbersChanged() { | 177 | void DialWidget::numbersChanged() |
162 | int sel = numbers->currentItem(); | 178 | { |
179 | int sel = numbers->currentItem(); | ||
163 | 180 | ||
164 | del->setEnabled(sel != -1); | 181 | del->setEnabled(sel != -1); |
165 | up->setEnabled(sel != -1 && sel != 0); | 182 | up->setEnabled(sel != -1 && sel != 0); |
166 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); | 183 | down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); |
167 | } | 184 | } |
168 | 185 | ||
169 | 186 | ||
170 | void DialWidget::selectionChanged(int) { | 187 | void DialWidget::selectionChanged(int) |
171 | numbersChanged(); | 188 | { |
189 | numbersChanged(); | ||
172 | } | 190 | } |
173 | 191 | ||
174 | 192 | ||
175 | void DialWidget::addNumber() { | 193 | void DialWidget::addNumber() |
194 | { | ||
176 | PhoneNumberDialog dlg(this); | 195 | PhoneNumberDialog dlg(this); |
177 | if(dlg.exec()) { | 196 | if(dlg.exec()) |
178 | numbers->insertItem(dlg.phoneNumber()); | 197 | { |
179 | numbersChanged(); | 198 | numbers->insertItem(dlg.phoneNumber()); |
180 | } | 199 | numbersChanged(); |
200 | } | ||
181 | } | 201 | } |
182 | 202 | ||
183 | 203 | ||
184 | void DialWidget::delNumber() { | 204 | void DialWidget::delNumber() |
185 | if(numbers->currentItem() != -1) { | 205 | { |
186 | numbers->removeItem(numbers->currentItem()); | 206 | if(numbers->currentItem() != -1) |
187 | numbersChanged(); | 207 | { |
188 | } | 208 | numbers->removeItem(numbers->currentItem()); |
209 | numbersChanged(); | ||
210 | } | ||
189 | } | 211 | } |
190 | 212 | ||
191 | 213 | ||
192 | void DialWidget::upNumber() { | 214 | void DialWidget::upNumber() |
193 | int idx = numbers->currentItem(); | 215 | { |
194 | if(idx != -1) { | 216 | int idx = numbers->currentItem(); |
195 | QString item = numbers->text(idx); | 217 | if(idx != -1) |
196 | numbers->removeItem(idx); | 218 | { |
197 | numbers->insertItem(item, idx-1); | 219 | QString item = numbers->text(idx); |
198 | numbers->setCurrentItem(idx-1); | 220 | numbers->removeItem(idx); |
199 | numbersChanged(); | 221 | numbers->insertItem(item, idx-1); |
200 | } | 222 | numbers->setCurrentItem(idx-1); |
223 | numbersChanged(); | ||
224 | } | ||
201 | } | 225 | } |
202 | 226 | ||
203 | 227 | ||
204 | void DialWidget::downNumber() { | 228 | void DialWidget::downNumber() |
205 | int idx = numbers->currentItem(); | 229 | { |
206 | if(idx != -1) { | 230 | int idx = numbers->currentItem(); |
207 | QString item = numbers->text(idx); | 231 | if(idx != -1) |
208 | numbers->removeItem(idx); | 232 | { |
209 | numbers->insertItem(item, idx+1); | 233 | QString item = numbers->text(idx); |
210 | numbers->setCurrentItem(idx+1); | 234 | numbers->removeItem(idx); |
211 | numbersChanged(); | 235 | numbers->insertItem(item, idx+1); |
212 | } | 236 | numbers->setCurrentItem(idx+1); |
237 | numbersChanged(); | ||
238 | } | ||
213 | } | 239 | } |
214 | 240 | ||
215 | 241 | ||
216 | void DialWidget::pppdargsbutton() { | 242 | void DialWidget::pppdargsbutton() |
243 | { | ||
217 | PPPdArguments pa(_pppdata, this); | 244 | PPPdArguments pa(_pppdata, this); |
218 | pa.showMaximized(); | 245 | QPEApplication::execDialog( &pa ); |
219 | pa.exec(); | ||
220 | } | 246 | } |
221 | 247 | ||
222 | 248 | ||
223 | 249 | ||
224 | ///////////////////////////////////////////////////////////////////////////// | 250 | ///////////////////////////////////////////////////////////////////////////// |
225 | // ExecWidget | 251 | // ExecWidget |
226 | ///////////////////////////////////////////////////////////////////////////// | 252 | ///////////////////////////////////////////////////////////////////////////// |
227 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : | 253 | ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : |
228 | QWidget(parent, name), _pppdata(pd) | 254 | QWidget(parent, name), _pppdata(pd) |
229 | { | 255 | { |
230 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); | 256 | QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); |
231 | 257 | ||
232 | QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); | 258 | QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); |
233 | 259 | ||
234 | tl->addWidget(l); | 260 | tl->addWidget(l); |
235 | tl->addStretch(1); | 261 | tl->addStretch(1); |
236 | 262 | ||
237 | QGridLayout *l1 = new QGridLayout(4, 2, 10); | 263 | QGridLayout *l1 = new QGridLayout(4, 2, 10); |
238 | tl->addLayout(l1); | 264 | tl->addLayout(l1); |
239 | l1->setColStretch(0, 0); | 265 | l1->setColStretch(0, 0); |
240 | l1->setColStretch(1, 1); | 266 | l1->setColStretch(1, 1); |
241 | 267 | ||
242 | before_connect_l = new QLabel(tr("Before connect:"), this); | 268 | before_connect_l = new QLabel(tr("Before connect:"), this); |
243 | before_connect_l->setAlignment(AlignVCenter); | 269 | before_connect_l->setAlignment(AlignVCenter); |
244 | l1->addWidget(before_connect_l, 0, 0); | 270 | l1->addWidget(before_connect_l, 0, 0); |
245 | before_connect = new QLineEdit(this); | 271 | before_connect = new QLineEdit(this); |
246 | // before_connect->setMaxLength(COMMAND_SIZE); | 272 | // before_connect->setMaxLength(COMMAND_SIZE); |
247 | l1->addWidget(before_connect, 0, 1); | 273 | l1->addWidget(before_connect, 0, 1); |
248 | QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" | 274 | QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" |
249 | "is established. It is called immediately before\n" | 275 | "is established. It is called immediately before\n" |
250 | "dialing has begun.\n\n" | 276 | "dialing has begun.\n\n" |
251 | "This might be useful, e.g. to stop HylaFAX blocking the\n" | 277 | "This might be useful, e.g. to stop HylaFAX blocking the\n" |
252 | "modem."); | 278 | "modem."); |
253 | 279 | ||
254 | QWhatsThis::add(before_connect_l,tmp); | 280 | QWhatsThis::add(before_connect_l,tmp); |
255 | QWhatsThis::add(before_connect,tmp); | 281 | QWhatsThis::add(before_connect,tmp); |
256 | 282 | ||
257 | command_label = new QLabel(tr("Upon connect:"), this); | 283 | command_label = new QLabel(tr("Upon connect:"), this); |
258 | command_label->setAlignment(AlignVCenter); | 284 | command_label->setAlignment(AlignVCenter); |
259 | l1->addWidget(command_label, 1, 0); | 285 | l1->addWidget(command_label, 1, 0); |
260 | command = new QLineEdit(this); | 286 | command = new QLineEdit(this); |
261 | // command->setMaxLength(COMMAND_SIZE); | 287 | // command->setMaxLength(COMMAND_SIZE); |
262 | l1->addWidget(command, 1, 1); | 288 | l1->addWidget(command, 1, 1); |
263 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" | 289 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" |
264 | "is established. When your program is called, all\n" | 290 | "is established. When your program is called, all\n" |
265 | "preparations for an Internet connection are finished.\n" | 291 | "preparations for an Internet connection are finished.\n" |
266 | "\n" | 292 | "\n" |
267 | "Very useful for fetching mail and news"); | 293 | "Very useful for fetching mail and news"); |
268 | 294 | ||
269 | QWhatsThis::add(command_label,tmp); | 295 | QWhatsThis::add(command_label,tmp); |
270 | QWhatsThis::add(command,tmp); | 296 | QWhatsThis::add(command,tmp); |
271 | 297 | ||
272 | predisconnect_label = new QLabel(tr("Before disconnect:"), | 298 | predisconnect_label = new QLabel(tr("Before disconnect:"), |
273 | this); | 299 | this); |
274 | predisconnect_label->setAlignment(AlignVCenter); | 300 | predisconnect_label->setAlignment(AlignVCenter); |
275 | l1->addWidget(predisconnect_label, 2, 0); | 301 | l1->addWidget(predisconnect_label, 2, 0); |
276 | predisconnect = new QLineEdit(this); | 302 | predisconnect = new QLineEdit(this); |
277 | // predisconnect->setMaxLength(COMMAND_SIZE); | 303 | // predisconnect->setMaxLength(COMMAND_SIZE); |
278 | l1->addWidget(predisconnect, 2, 1); | 304 | l1->addWidget(predisconnect, 2, 1); |
279 | tmp = tr("Allows you to run a program <b>before</b> a connection\n" | 305 | tmp = tr("Allows you to run a program <b>before</b> a connection\n" |
280 | "is closed. The connection will stay open until\n" | 306 | "is closed. The connection will stay open until\n" |
281 | "the program exits."); | 307 | "the program exits."); |
282 | 308 | ||
283 | QWhatsThis::add(predisconnect_label,tmp); | 309 | QWhatsThis::add(predisconnect_label,tmp); |
284 | QWhatsThis::add(predisconnect,tmp); | 310 | QWhatsThis::add(predisconnect,tmp); |
285 | 311 | ||
286 | discommand_label = new QLabel(tr("Upon disconnect:"), | 312 | discommand_label = new QLabel(tr("Upon disconnect:"), |
287 | this); | 313 | this); |
288 | discommand_label->setAlignment(AlignVCenter); | 314 | discommand_label->setAlignment(AlignVCenter); |
289 | l1->addWidget(discommand_label, 3, 0); | 315 | l1->addWidget(discommand_label, 3, 0); |
290 | 316 | ||
291 | discommand = new QLineEdit(this); | 317 | discommand = new QLineEdit(this); |
292 | // discommand->setMaxLength(COMMAND_SIZE); | 318 | // discommand->setMaxLength(COMMAND_SIZE); |
293 | l1->addWidget(discommand, 3, 1); | 319 | l1->addWidget(discommand, 3, 1); |
294 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" | 320 | tmp = tr("Allows you to run a program <b>after</b> a connection\n" |
295 | "has been closed."); | 321 | "has been closed."); |
296 | 322 | ||
297 | QWhatsThis::add(discommand_label,tmp); | 323 | QWhatsThis::add(discommand_label,tmp); |
298 | QWhatsThis::add(discommand,tmp); | 324 | QWhatsThis::add(discommand,tmp); |
299 | 325 | ||
300 | // extra space between entries | 326 | // extra space between entries |
301 | l1->addRowSpacing(1, 5); | 327 | l1->addRowSpacing(1, 5); |
302 | l1->addRowSpacing(3, 5); | 328 | l1->addRowSpacing(3, 5); |
303 | 329 | ||
304 | tl->addStretch(1); | 330 | tl->addStretch(1); |
305 | tl->activate(); | 331 | tl->activate(); |
306 | 332 | ||
307 | // Set defaults if editing an existing connection | 333 | // Set defaults if editing an existing connection |
308 | if(!isnewaccount) { | 334 | if(!isnewaccount) |
309 | before_connect->setText(_pppdata->command_before_connect()); | 335 | { |
310 | command->setText(_pppdata->command_on_connect()); | 336 | before_connect->setText(_pppdata->command_before_connect()); |
311 | discommand->setText(_pppdata->command_on_disconnect()); | 337 | command->setText(_pppdata->command_on_connect()); |
312 | predisconnect->setText(_pppdata->command_before_disconnect()); | 338 | discommand->setText(_pppdata->command_on_disconnect()); |
313 | } | 339 | predisconnect->setText(_pppdata->command_before_disconnect()); |
340 | } | ||
314 | } | 341 | } |
315 | 342 | ||
316 | 343 | ||
317 | bool ExecWidget::save() { | 344 | bool ExecWidget::save() |
318 | _pppdata->setCommand_before_connect(before_connect->text()); | 345 | { |
319 | _pppdata->setCommand_on_connect(command->text()); | 346 | _pppdata->setCommand_before_connect(before_connect->text()); |
320 | _pppdata->setCommand_before_disconnect(predisconnect->text()); | 347 | _pppdata->setCommand_on_connect(command->text()); |
321 | _pppdata->setCommand_on_disconnect(discommand->text()); | 348 | _pppdata->setCommand_before_disconnect(predisconnect->text()); |
322 | return true; | 349 | _pppdata->setCommand_on_disconnect(discommand->text()); |
350 | return true; | ||
323 | } | 351 | } |
324 | 352 | ||
325 | 353 | ||
326 | 354 | ||
327 | ///////////////////////////////////////////////////////////////////////////// | 355 | ///////////////////////////////////////////////////////////////////////////// |
328 | // | 356 | // |
329 | // IPWidget | 357 | // IPWidget |
330 | // | 358 | // |
331 | ///////////////////////////////////////////////////////////////////////////// | 359 | ///////////////////////////////////////////////////////////////////////////// |
332 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 360 | IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
333 | : QWidget(parent, name), _pppdata(pd) | 361 | : QWidget(parent, name), _pppdata(pd) |
334 | { | 362 | { |
335 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 363 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
336 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); | 364 | topLayout->setSpacing( 3 );//KDialog::spacingHint()); |
337 | 365 | ||
338 | box = new QVGroupBox(tr("Configuration"), this); | 366 | box = new QVGroupBox(tr("Configuration"), this); |
339 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); | 367 | // box->setInsideSpacing( 1 );//KDialog::spacingHint()); |
340 | 368 | ||
341 | rb = new QButtonGroup(this); | 369 | rb = new QButtonGroup(this); |
342 | rb->hide(); | 370 | rb->hide(); |
343 | connect(rb, SIGNAL(clicked(int)), | 371 | connect(rb, SIGNAL(clicked(int)), |
344 | SLOT(hitIPSelect(int))); | 372 | SLOT(hitIPSelect(int))); |
345 | 373 | ||
346 | dynamicadd_rb = new QRadioButton(box); | 374 | dynamicadd_rb = new QRadioButton(box); |
347 | dynamicadd_rb->setText(tr("Dynamic IP address")); | 375 | dynamicadd_rb->setText(tr("Dynamic IP address")); |
348 | QWhatsThis::add(dynamicadd_rb, | 376 | QWhatsThis::add(dynamicadd_rb, |
349 | tr("Select this option when your computer gets an\n" | 377 | tr("Select this option when your computer gets an\n" |
350 | "internet address (IP) every time a\n" | 378 | "internet address (IP) every time a\n" |
351 | "connection is made.\n" | 379 | "connection is made.\n" |
352 | "\n" | 380 | "\n" |
353 | "Almost every Internet Service Provider uses\n" | 381 | "Almost every Internet Service Provider uses\n" |
354 | "this method, so this should be turned on.")); | 382 | "this method, so this should be turned on.")); |
355 | 383 | ||
356 | staticadd_rb = new QRadioButton(box); | 384 | staticadd_rb = new QRadioButton(box); |
357 | staticadd_rb->setText(tr("Static IP address")); | 385 | staticadd_rb->setText(tr("Static IP address")); |
358 | rb->insert(dynamicadd_rb, 0); | 386 | rb->insert(dynamicadd_rb, 0); |
359 | rb->insert(staticadd_rb, 1); | 387 | rb->insert(staticadd_rb, 1); |
360 | QWhatsThis::add(staticadd_rb, | 388 | QWhatsThis::add(staticadd_rb, |
361 | tr("Select this option when your computer has a\n" | 389 | tr("Select this option when your computer has a\n" |
362 | "fixed internet address (IP). Most computers\n" | 390 | "fixed internet address (IP). Most computers\n" |
363 | "don't have this, so you should probably select\n" | 391 | "don't have this, so you should probably select\n" |
364 | "dynamic IP addressing unless you know what you\n" | 392 | "dynamic IP addressing unless you know what you\n" |
365 | "are doing.")); | 393 | "are doing.")); |
366 | 394 | ||
367 | QWidget *ipWidget = new QWidget(box); | 395 | QWidget *ipWidget = new QWidget(box); |
368 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); | 396 | QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); |
369 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); | 397 | ipLayout->setSpacing( 2 );//KDialog::spacingHint()); |
370 | 398 | ||
371 | ipaddress_label = new QLabel(tr("IP address:"), ipWidget); | 399 | ipaddress_label = new QLabel(tr("IP address:"), ipWidget); |
372 | QString tmp = tr("If your computer has a permanent internet\n" | 400 | QString tmp = tr("If your computer has a permanent internet\n" |
373 | "address, you must supply your IP address here."); | 401 | "address, you must supply your IP address here."); |
374 | ipLayout->addWidget(ipaddress_label, 0, 0); | 402 | ipLayout->addWidget(ipaddress_label, 0, 0); |
375 | 403 | ||
376 | ipaddress_l = new IPLineEdit(ipWidget); | 404 | ipaddress_l = new IPLineEdit(ipWidget); |
377 | ipLayout->addWidget(ipaddress_l, 0, 1); | 405 | ipLayout->addWidget(ipaddress_l, 0, 1); |
378 | 406 | ||
379 | QWhatsThis::add(ipaddress_label,tmp); | 407 | QWhatsThis::add(ipaddress_label,tmp); |
380 | QWhatsThis::add(ipaddress_l,tmp); | 408 | QWhatsThis::add(ipaddress_l,tmp); |
381 | 409 | ||
382 | sub_label = new QLabel(tr("Subnet mask:"), ipWidget); | 410 | sub_label = new QLabel(tr("Subnet mask:"), ipWidget); |
383 | tmp = tr("<p>If your computer has a static Internet address,\n" | 411 | tmp = tr("<p>If your computer has a static Internet address,\n" |
384 | "you must supply a network mask here. In almost\n" | 412 | "you must supply a network mask here. In almost\n" |
385 | "all cases this netmask will be <b>255.255.255.0</b>,\n" | 413 | "all cases this netmask will be <b>255.255.255.0</b>,\n" |
386 | "but your mileage may vary.\n" | 414 | "but your mileage may vary.\n" |
387 | "\n" | 415 | "\n" |
388 | "If unsure, contact your Internet Service Provider"); | 416 | "If unsure, contact your Internet Service Provider"); |
389 | ipLayout->addWidget(sub_label, 1, 0); | 417 | ipLayout->addWidget(sub_label, 1, 0); |
390 | 418 | ||
391 | subnetmask_l = new IPLineEdit(ipWidget); | 419 | subnetmask_l = new IPLineEdit(ipWidget); |
392 | ipLayout->addWidget(subnetmask_l, 1, 1); | 420 | ipLayout->addWidget(subnetmask_l, 1, 1); |
393 | 421 | ||
394 | QWhatsThis::add(sub_label,tmp); | 422 | QWhatsThis::add(sub_label,tmp); |
395 | QWhatsThis::add(subnetmask_l,tmp); | 423 | QWhatsThis::add(subnetmask_l,tmp); |
396 | 424 | ||
397 | autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); | 425 | autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); |
398 | autoname->setChecked(_pppdata->autoname()); | 426 | autoname->setChecked(_pppdata->autoname()); |
399 | connect(autoname,SIGNAL(toggled(bool)), | 427 | connect(autoname,SIGNAL(toggled(bool)), |
400 | this,SLOT(autoname_t(bool))); | 428 | this,SLOT(autoname_t(bool))); |
401 | 429 | ||
402 | QWhatsThis::add(autoname, | 430 | QWhatsThis::add(autoname, |
403 | tr("<p>Whenever you connect, this reconfigures\n" | 431 | tr("<p>Whenever you connect, this reconfigures\n" |
404 | "your hostname to match the IP address you\n" | 432 | "your hostname to match the IP address you\n" |
405 | "got from the PPP server. This may be useful\n" | 433 | "got from the PPP server. This may be useful\n" |
406 | "if you need to use a protocol which depends\n" | 434 | "if you need to use a protocol which depends\n" |
407 | "on this information, but it can also cause several\n" | 435 | "on this information, but it can also cause several\n" |
408 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" | 436 | "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" |
409 | "\n" | 437 | "\n" |
410 | "Don't enable this unless you really need it.")); | 438 | "Don't enable this unless you really need it.")); |
411 | 439 | ||
412 | topLayout->addWidget(box); | 440 | topLayout->addWidget(box); |
413 | topLayout->addWidget(autoname); | 441 | topLayout->addWidget(autoname); |
414 | topLayout->addStretch(); | 442 | topLayout->addStretch(); |
415 | 443 | ||
416 | //load info from gpppdata | 444 | //load info from gpppdata |
417 | if(!isnewaccount) { | 445 | if(!isnewaccount) |
418 | if(_pppdata->ipaddr() == "0.0.0.0" && | 446 | { |
419 | _pppdata->subnetmask() == "0.0.0.0") { | 447 | if(_pppdata->ipaddr() == "0.0.0.0" && |
420 | dynamicadd_rb->setChecked(true); | 448 | _pppdata->subnetmask() == "0.0.0.0") |
421 | hitIPSelect(0); | 449 | { |
422 | autoname->setChecked(_pppdata->autoname()); | 450 | dynamicadd_rb->setChecked(true); |
451 | hitIPSelect(0); | ||
452 | autoname->setChecked(_pppdata->autoname()); | ||
453 | } | ||
454 | else | ||
455 | { | ||
456 | ipaddress_l->setText(_pppdata->ipaddr()); | ||
457 | subnetmask_l->setText(_pppdata->subnetmask()); | ||
458 | staticadd_rb->setChecked(true); | ||
459 | autoname->setChecked(false); | ||
460 | } | ||
423 | } | 461 | } |
424 | else { | 462 | else |
425 | ipaddress_l->setText(_pppdata->ipaddr()); | 463 | { |
426 | subnetmask_l->setText(_pppdata->subnetmask()); | 464 | dynamicadd_rb->setChecked(true); |
427 | staticadd_rb->setChecked(true); | 465 | hitIPSelect(0); |
428 | autoname->setChecked(false); | ||
429 | } | 466 | } |
430 | } | ||
431 | else { | ||
432 | dynamicadd_rb->setChecked(true); | ||
433 | hitIPSelect(0); | ||
434 | } | ||
435 | 467 | ||
436 | } | 468 | } |
437 | 469 | ||
438 | void IPWidget::autoname_t(bool on) { | 470 | void IPWidget::autoname_t(bool on) |
439 | static bool was_warned = false; | 471 | { |
440 | 472 | static bool was_warned = false; | |
441 | // big-fat warning when selecting the auto configure hostname option | 473 | |
442 | if(on && !was_warned) { | 474 | // big-fat warning when selecting the auto configure hostname option |
443 | QMessageBox::information(this, | 475 | if(on && !was_warned) |
444 | tr("Selecting this option might cause some weird " | 476 | { |
445 | "problems with the X-server and applications " | 477 | QMessageBox::information(this, |
446 | "while kppp is connected. Don't use it until " | 478 | tr("Selecting this option might cause some weird " |
447 | "you know what you are doing!\n" | 479 | "problems with the X-server and applications " |
448 | "For more information take a look at the " | 480 | "while kppp is connected. Don't use it until " |
449 | "handbook (or help) in the section \"Frequently " | 481 | "you know what you are doing!\n" |
450 | "asked questions\"."), | 482 | "For more information take a look at the " |
451 | tr("Warning")); | 483 | "handbook (or help) in the section \"Frequently " |
452 | was_warned = true; | 484 | "asked questions\"."), |
453 | } | 485 | tr("Warning")); |
486 | was_warned = true; | ||
487 | } | ||
454 | } | 488 | } |
455 | 489 | ||
456 | 490 | ||
457 | void IPWidget::save() { | 491 | void IPWidget::save() |
458 | if(dynamicadd_rb->isChecked()) { | 492 | { |
459 | _pppdata->setIpaddr("0.0.0.0"); | 493 | if(dynamicadd_rb->isChecked()) |
460 | _pppdata->setSubnetmask("0.0.0.0"); | 494 | { |
461 | } else { | 495 | _pppdata->setIpaddr("0.0.0.0"); |
462 | _pppdata->setIpaddr(ipaddress_l->text()); | 496 | _pppdata->setSubnetmask("0.0.0.0"); |
463 | _pppdata->setSubnetmask(subnetmask_l->text()); | 497 | } |
464 | } | 498 | else |
465 | _pppdata->setAutoname(autoname->isChecked()); | 499 | { |
500 | _pppdata->setIpaddr(ipaddress_l->text()); | ||
501 | _pppdata->setSubnetmask(subnetmask_l->text()); | ||
502 | } | ||
503 | _pppdata->setAutoname(autoname->isChecked()); | ||
466 | } | 504 | } |
467 | 505 | ||
468 | 506 | ||
469 | void IPWidget::hitIPSelect( int i ) { | 507 | void IPWidget::hitIPSelect( int i ) |
470 | if(i == 0) { | 508 | { |
471 | ipaddress_label->setEnabled(false); | 509 | if(i == 0) |
472 | sub_label->setEnabled(false); | 510 | { |
473 | ipaddress_l->setEnabled(false); | 511 | ipaddress_label->setEnabled(false); |
474 | subnetmask_l->setEnabled(false); | 512 | sub_label->setEnabled(false); |
475 | } | 513 | ipaddress_l->setEnabled(false); |
476 | else { | 514 | subnetmask_l->setEnabled(false); |
477 | ipaddress_label->setEnabled(true); | 515 | } |
478 | sub_label->setEnabled(true); | 516 | else |
479 | ipaddress_l->setEnabled(true); | 517 | { |
480 | subnetmask_l->setEnabled(true); | 518 | ipaddress_label->setEnabled(true); |
481 | } | 519 | sub_label->setEnabled(true); |
520 | ipaddress_l->setEnabled(true); | ||
521 | subnetmask_l->setEnabled(true); | ||
522 | } | ||
482 | } | 523 | } |
483 | 524 | ||
484 | 525 | ||
485 | 526 | ||
486 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 527 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
487 | : QWidget(parent, name), _pppdata(pd) | 528 | : QWidget(parent, name), _pppdata(pd) |
488 | { | 529 | { |
489 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); | 530 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); |
490 | 531 | ||
491 | dnsdomain_label = new QLabel(tr("Domain name:"), this); | 532 | dnsdomain_label = new QLabel(tr("Domain name:"), this); |
492 | tl->addWidget(dnsdomain_label, 0, 0); | 533 | tl->addWidget(dnsdomain_label, 0, 0); |
493 | 534 | ||
494 | dnsdomain = new QLineEdit(this); | 535 | dnsdomain = new QLineEdit(this); |
495 | 536 | ||
496 | tl->addWidget(dnsdomain, 0, 1); | 537 | tl->addWidget(dnsdomain, 0, 1); |
497 | QString tmp = tr("If you enter a domain name here, this domain\n" | 538 | QString tmp = tr("If you enter a domain name here, this domain\n" |
498 | "name is used for your computer while you are\n" | 539 | "name is used for your computer while you are\n" |
499 | "connected. When the connection is closed, the\n" | 540 | "connected. When the connection is closed, the\n" |
500 | "original domain name of your computer is\n" | 541 | "original domain name of your computer is\n" |
501 | "restored.\n" | 542 | "restored.\n" |
502 | "\n" | 543 | "\n" |
503 | "If you leave this field blank, no changes are\n" | 544 | "If you leave this field blank, no changes are\n" |
504 | "made to the domain name."); | 545 | "made to the domain name."); |
505 | 546 | ||
506 | QWhatsThis::add(dnsdomain_label,tmp); | 547 | QWhatsThis::add(dnsdomain_label,tmp); |
507 | QWhatsThis::add(dnsdomain,tmp); | 548 | QWhatsThis::add(dnsdomain,tmp); |
508 | 549 | ||
509 | conf_label = new QLabel(tr("Configuration:"), this); | 550 | conf_label = new QLabel(tr("Configuration:"), this); |
510 | tl->addWidget(conf_label, 1, 0); | 551 | tl->addWidget(conf_label, 1, 0); |
511 | 552 | ||
512 | bg = new QButtonGroup("Group", this); | 553 | bg = new QButtonGroup("Group", this); |
513 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); | 554 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); |
514 | bg->hide(); | 555 | bg->hide(); |
515 | 556 | ||
516 | autodns = new QRadioButton(tr("Automatic"), this); | 557 | autodns = new QRadioButton(tr("Automatic"), this); |
517 | bg->insert(autodns, 0); | 558 | bg->insert(autodns, 0); |
518 | tl->addWidget(autodns, 1, 1); | 559 | tl->addWidget(autodns, 1, 1); |
519 | if(!_pppdata->pppdVersionMin(2, 3, 7)) | 560 | if(!_pppdata->pppdVersionMin(2, 3, 7)) |
520 | autodns->setEnabled(false); | 561 | autodns->setEnabled(false); |
521 | 562 | ||
522 | mandns = new QRadioButton(tr("Manual"), this); | 563 | mandns = new QRadioButton(tr("Manual"), this); |
523 | bg->insert(mandns, 1); | 564 | bg->insert(mandns, 1); |
524 | tl->addWidget(mandns, 2, 1); | 565 | tl->addWidget(mandns, 2, 1); |
525 | 566 | ||
526 | dns_label = new QLabel(tr("DNS IP address:"), this); | 567 | dns_label = new QLabel(tr("DNS IP address:"), this); |
527 | tl->addWidget(dns_label, 3, 0); | 568 | tl->addWidget(dns_label, 3, 0); |
528 | 569 | ||
529 | QHBoxLayout *l2 = new QHBoxLayout; | 570 | QHBoxLayout *l2 = new QHBoxLayout; |
530 | tl->addLayout(l2, 3, 1); | 571 | tl->addLayout(l2, 3, 1); |
531 | dnsipaddr = new IPLineEdit(this); | 572 | dnsipaddr = new IPLineEdit(this); |
532 | connect(dnsipaddr, SIGNAL(returnPressed()), | 573 | connect(dnsipaddr, SIGNAL(returnPressed()), |
533 | SLOT(adddns())); | 574 | SLOT(adddns())); |
534 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), | 575 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), |
535 | SLOT(DNS_Edit_Changed(const QString &))); | 576 | SLOT(DNS_Edit_Changed(const QString &))); |
536 | l2->addWidget(dnsipaddr, 1); | 577 | l2->addWidget(dnsipaddr, 1); |
537 | l2->addStretch(1); | 578 | l2->addStretch(1); |
538 | tmp = tr("<p>Allows you to specify a new DNS server to be\n" | 579 | tmp = tr("<p>Allows you to specify a new DNS server to be\n" |
539 | "used while you are connected. When the\n" | 580 | "used while you are connected. When the\n" |
540 | "connection is closed, this DNS entry will be\n" | 581 | "connection is closed, this DNS entry will be\n" |
541 | "removed again.\n" | 582 | "removed again.\n" |
542 | "\n" | 583 | "\n" |
543 | "To add a DNS server, type in the IP address of\n" | 584 | "To add a DNS server, type in the IP address of\n" |
544 | "the DNS server here and click on <b>Add</b>"); | 585 | "the DNS server here and click on <b>Add</b>"); |
545 | 586 | ||
546 | QWhatsThis::add(dns_label, tmp); | 587 | QWhatsThis::add(dns_label, tmp); |
547 | QWhatsThis::add(dnsipaddr, tmp); | 588 | QWhatsThis::add(dnsipaddr, tmp); |
548 | 589 | ||
549 | QHBoxLayout *l1 = new QHBoxLayout; | 590 | QHBoxLayout *l1 = new QHBoxLayout; |
550 | tl->addLayout(l1, 4, 1); | 591 | tl->addLayout(l1, 4, 1); |
551 | add = new QPushButton(tr("Add"), this); | 592 | add = new QPushButton(tr("Add"), this); |
552 | connect(add, SIGNAL(clicked()), SLOT(adddns())); | 593 | connect(add, SIGNAL(clicked()), SLOT(adddns())); |
553 | l1->addWidget(add); | 594 | l1->addWidget(add); |
554 | // l1->addStretch(1); | 595 | // l1->addStretch(1); |
555 | QWhatsThis::add(add, | 596 | QWhatsThis::add(add, |
556 | tr("Click this button to add the DNS server\n" | 597 | tr("Click this button to add the DNS server\n" |
557 | "specified in the field above. The entry\n" | 598 | "specified in the field above. The entry\n" |
558 | "will then be added to the list below")); | 599 | "will then be added to the list below")); |
559 | 600 | ||
560 | remove = new QPushButton(tr("Remove"), this); | 601 | remove = new QPushButton(tr("Remove"), this); |
561 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); | 602 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); |
562 | l1->addWidget(remove); | 603 | l1->addWidget(remove); |
563 | QWhatsThis::add(remove, | 604 | QWhatsThis::add(remove, |
564 | tr("Click this button to remove the selected DNS\n" | 605 | tr("Click this button to remove the selected DNS\n" |
565 | "server entry from the list below")); | 606 | "server entry from the list below")); |
566 | 607 | ||
567 | servers_label = new QLabel(tr("DNS address list:"), this); | 608 | servers_label = new QLabel(tr("DNS address list:"), this); |
568 | servers_label->setAlignment(AlignTop|AlignLeft); | 609 | servers_label->setAlignment(AlignTop|AlignLeft); |
569 | tl->addWidget(servers_label, 5, 0); | 610 | tl->addWidget(servers_label, 5, 0); |
570 | 611 | ||
571 | dnsservers = new QListBox(this); | 612 | dnsservers = new QListBox(this); |
572 | dnsservers->setMinimumSize(150, 80); | 613 | dnsservers->setMinimumSize(150, 80); |
573 | connect(dnsservers, SIGNAL(highlighted(int)), | 614 | connect(dnsservers, SIGNAL(highlighted(int)), |
574 | SLOT(DNS_Entry_Selected(int))); | 615 | SLOT(DNS_Entry_Selected(int))); |
575 | tl->addWidget(dnsservers, 5, 1); | 616 | tl->addWidget(dnsservers, 5, 1); |
576 | tmp = tr("<p>This shows all defined DNS servers to use\n" | 617 | tmp = tr("<p>This shows all defined DNS servers to use\n" |
577 | "while you are connected. Use the <b>Add</b> and\n" | 618 | "while you are connected. Use the <b>Add</b> and\n" |
578 | "<b>Remove</b> buttons to modify the list"); | 619 | "<b>Remove</b> buttons to modify the list"); |
579 | 620 | ||
580 | QWhatsThis::add(servers_label,tmp); | 621 | QWhatsThis::add(servers_label,tmp); |
581 | QWhatsThis::add(dnsservers,tmp); | 622 | QWhatsThis::add(dnsservers,tmp); |
582 | 623 | ||
583 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); | 624 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); |
584 | // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); | 625 | // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); |
585 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); | 626 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); |
586 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); | 627 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); |
587 | QWhatsThis::add(exdnsdisabled_toggle, | 628 | QWhatsThis::add(exdnsdisabled_toggle, |
588 | tr("<p>When this option is selected, all DNS\n" | 629 | tr("<p>When this option is selected, all DNS\n" |
589 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" | 630 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" |
590 | "temporary disabled while the dialup connection\n" | 631 | "temporary disabled while the dialup connection\n" |
591 | "is established. After the connection is\n" | 632 | "is established. After the connection is\n" |
592 | "closed, the servers will be re-enabled\n" | 633 | "closed, the servers will be re-enabled\n" |
593 | "\n" | 634 | "\n" |
594 | "Typically, there is no reason to use this\n" | 635 | "Typically, there is no reason to use this\n" |
595 | "option, but it may become useful under \n" | 636 | "option, but it may become useful under \n" |
596 | "some circumstances.")); | 637 | "some circumstances.")); |
597 | 638 | ||
598 | 639 | ||
599 | // restore data if editing | 640 | // restore data if editing |
600 | if(!isnewaccount) { | 641 | if(!isnewaccount) |
601 | dnsservers->insertStringList(_pppdata->dns()); | 642 | { |
602 | dnsdomain->setText(_pppdata->domain()); | 643 | dnsservers->insertStringList(_pppdata->dns()); |
603 | } | 644 | dnsdomain->setText(_pppdata->domain()); |
604 | 645 | } | |
605 | int mode = _pppdata->autoDNS() ? 0 : 1; | 646 | |
606 | bg->setButton(mode); | 647 | int mode = _pppdata->autoDNS() ? 0 : 1; |
607 | DNS_Mode_Selected(mode); | 648 | bg->setButton(mode); |
608 | 649 | DNS_Mode_Selected(mode); | |
609 | tl->activate(); | 650 | |
651 | tl->activate(); | ||
610 | } | 652 | } |
611 | 653 | ||
612 | void DNSWidget::DNS_Edit_Changed(const QString &text) { | 654 | void DNSWidget::DNS_Edit_Changed(const QString &text) |
613 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | 655 | { |
614 | add->setEnabled(text.find(r) != -1); | 656 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); |
657 | add->setEnabled(text.find(r) != -1); | ||
615 | } | 658 | } |
616 | 659 | ||
617 | void DNSWidget::DNS_Entry_Selected(int) { | 660 | void DNSWidget::DNS_Entry_Selected(int) |
618 | remove->setEnabled(true); | 661 | { |
662 | remove->setEnabled(true); | ||
619 | } | 663 | } |
620 | 664 | ||
621 | void DNSWidget::DNS_Mode_Selected(int mode) { | 665 | void DNSWidget::DNS_Mode_Selected(int mode) |
622 | bool on = (mode == 1); | 666 | { |
623 | dns_label->setEnabled(on); | 667 | bool on = (mode == 1); |
624 | servers_label->setEnabled(on); | 668 | dns_label->setEnabled(on); |
625 | dnsipaddr->setText(""); | 669 | servers_label->setEnabled(on); |
626 | dnsipaddr->setEnabled(on); | 670 | dnsipaddr->setText(""); |
627 | add->setEnabled(false); | 671 | dnsipaddr->setEnabled(on); |
628 | remove->setEnabled(dnsservers->count()>0 && on); | 672 | add->setEnabled(false); |
629 | dnsservers->clearSelection(); | 673 | remove->setEnabled(dnsservers->count()>0 && on); |
630 | dnsservers->setEnabled(on); | 674 | dnsservers->clearSelection(); |
631 | dnsservers->triggerUpdate(false); | 675 | dnsservers->setEnabled(on); |
676 | dnsservers->triggerUpdate(false); | ||
632 | } | 677 | } |
633 | 678 | ||
634 | void DNSWidget::save() { | 679 | void DNSWidget::save() |
635 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); | 680 | { |
636 | QStringList serverlist; | 681 | _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); |
637 | for(uint i=0; i < dnsservers->count(); i++) | 682 | QStringList serverlist; |
638 | serverlist.append(dnsservers->text(i)); | 683 | for(uint i=0; i < dnsservers->count(); i++) |
639 | _pppdata->setDns(serverlist); | 684 | serverlist.append(dnsservers->text(i)); |
640 | 685 | _pppdata->setDns(serverlist); | |
641 | // strip leading dot | 686 | |
642 | QString s(dnsdomain->text()); | 687 | // strip leading dot |
643 | if(s.left(1) == ".") | 688 | QString s(dnsdomain->text()); |
644 | _pppdata->setDomain(s.mid(1)); | 689 | if(s.left(1) == ".") |
645 | else | 690 | _pppdata->setDomain(s.mid(1)); |
646 | _pppdata->setDomain(dnsdomain->text()); | 691 | else |
647 | 692 | _pppdata->setDomain(dnsdomain->text()); | |
648 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); | 693 | |
694 | _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); | ||
649 | } | 695 | } |
650 | 696 | ||
651 | 697 | ||
652 | void DNSWidget::adddns() { | 698 | void DNSWidget::adddns() |
653 | if(dnsservers->count() < MAX_DNS_ENTRIES) { | 699 | { |
654 | dnsservers->insertItem(dnsipaddr->text()); | 700 | if(dnsservers->count() < MAX_DNS_ENTRIES) |
655 | dnsipaddr->setText(""); | 701 | { |
656 | } | 702 | dnsservers->insertItem(dnsipaddr->text()); |
703 | dnsipaddr->setText(""); | ||
704 | } | ||
657 | } | 705 | } |
658 | 706 | ||
659 | 707 | ||
660 | void DNSWidget::removedns() { | 708 | void DNSWidget::removedns() |
661 | int i; | 709 | { |
662 | i = dnsservers->currentItem(); | 710 | int i; |
663 | if(i != -1) | 711 | i = dnsservers->currentItem(); |
664 | dnsservers->removeItem(i); | 712 | if(i != -1) |
665 | remove->setEnabled(dnsservers->count()>0); | 713 | dnsservers->removeItem(i); |
714 | remove->setEnabled(dnsservers->count()>0); | ||
666 | } | 715 | } |
667 | 716 | ||
668 | 717 | ||
669 | // | 718 | // |
670 | // GatewayWidget | 719 | // GatewayWidget |
671 | // | 720 | // |
672 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 721 | GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
673 | : QWidget(parent, name), _pppdata(pd) | 722 | : QWidget(parent, name), _pppdata(pd) |
674 | { | 723 | { |
675 | QVBoxLayout *topLayout = new QVBoxLayout(this); | 724 | QVBoxLayout *topLayout = new QVBoxLayout(this); |
676 | topLayout->setSpacing( 2 ); | 725 | topLayout->setSpacing( 2 ); |
677 | topLayout->setMargin( 0 ); | 726 | topLayout->setMargin( 0 ); |
678 | 727 | ||
679 | box = new QVGroupBox(tr("Configuration"), this); | 728 | box = new QVGroupBox(tr("Configuration"), this); |
680 | 729 | ||
681 | rb = new QButtonGroup(this); | 730 | rb = new QButtonGroup(this); |
682 | rb->hide(); | 731 | rb->hide(); |
683 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); | 732 | connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); |
684 | 733 | ||
685 | defaultgateway = new QRadioButton(box); | 734 | defaultgateway = new QRadioButton(box); |
686 | defaultgateway->setText(tr("Default gateway")); | 735 | defaultgateway->setText(tr("Default gateway")); |
687 | rb->insert(defaultgateway, 0); | 736 | rb->insert(defaultgateway, 0); |
688 | QWhatsThis::add(defaultgateway, | 737 | QWhatsThis::add(defaultgateway, |
689 | tr("This makes the PPP peer computer (the computer\n" | 738 | tr("This makes the PPP peer computer (the computer\n" |
690 | "you are connected to with your modem) to act as\n" | 739 | "you are connected to with your modem) to act as\n" |
691 | "a gateway. Your computer will send all packets not\n" | 740 | "a gateway. Your computer will send all packets not\n" |
692 | "going to a computer inside your local net to this\n" | 741 | "going to a computer inside your local net to this\n" |
693 | "computer, which will route these packets.\n" | 742 | "computer, which will route these packets.\n" |
694 | "\n" | 743 | "\n" |
695 | "This is the default for most ISPs, so you should\n" | 744 | "This is the default for most ISPs, so you should\n" |
696 | "probably leave this option on.")); | 745 | "probably leave this option on.")); |
697 | 746 | ||
698 | 747 | ||
699 | staticgateway = new QRadioButton(box); | 748 | staticgateway = new QRadioButton(box); |
700 | staticgateway->setText(tr("Static gateway")); | 749 | staticgateway->setText(tr("Static gateway")); |
701 | rb->insert(staticgateway, 1); | 750 | rb->insert(staticgateway, 1); |
702 | QWhatsThis::add(staticgateway, | 751 | QWhatsThis::add(staticgateway, |
703 | tr("<p>Allows you to specify which computer you want\n" | 752 | tr("<p>Allows you to specify which computer you want\n" |
704 | "to use as gateway (see <i>Default Gateway</i> above)")); | 753 | "to use as gateway (see <i>Default Gateway</i> above)")); |
705 | 754 | ||
706 | QHBox *gateBox = new QHBox(box); | 755 | QHBox *gateBox = new QHBox(box); |
707 | gate_label = new QLabel(tr("Gateway IP address:"), gateBox); | 756 | gate_label = new QLabel(tr("Gateway IP address:"), gateBox); |
708 | gatewayaddr = new IPLineEdit(gateBox); | 757 | gatewayaddr = new IPLineEdit(gateBox); |
709 | 758 | ||
710 | defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), | 759 | defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), |
711 | this); | 760 | this); |
712 | QWhatsThis::add(defaultroute, | 761 | QWhatsThis::add(defaultroute, |
713 | tr("If this option is enabled, all packets not\n" | 762 | tr("If this option is enabled, all packets not\n" |
714 | "going to the local net are routed through\n" | 763 | "going to the local net are routed through\n" |
715 | "the PPP connection.\n" | 764 | "the PPP connection.\n" |
716 | "\n" | 765 | "\n" |
717 | "Normally, you should turn this on")); | 766 | "Normally, you should turn this on")); |
718 | 767 | ||
719 | topLayout->addWidget(box); | 768 | topLayout->addWidget(box); |
720 | topLayout->addWidget(defaultroute); | 769 | topLayout->addWidget(defaultroute); |
721 | topLayout->addStretch(); | 770 | topLayout->addStretch(); |
722 | 771 | ||
723 | //load info from gpppdata | 772 | //load info from gpppdata |
724 | if(!isnewaccount) { | 773 | if(!isnewaccount) |
725 | if(_pppdata->gateway() == "0.0.0.0") { | 774 | { |
726 | defaultgateway->setChecked(true); | 775 | if(_pppdata->gateway() == "0.0.0.0") |
727 | hitGatewaySelect(0); | 776 | { |
777 | defaultgateway->setChecked(true); | ||
778 | hitGatewaySelect(0); | ||
779 | } | ||
780 | else | ||
781 | { | ||
782 | gatewayaddr->setText(_pppdata->gateway()); | ||
783 | staticgateway->setChecked(true); | ||
784 | } | ||
785 | defaultroute->setChecked(_pppdata->defaultroute()); | ||
728 | } | 786 | } |
729 | else { | 787 | else |
730 | gatewayaddr->setText(_pppdata->gateway()); | 788 | { |
731 | staticgateway->setChecked(true); | 789 | defaultgateway->setChecked(true); |
790 | hitGatewaySelect(0); | ||
791 | defaultroute->setChecked(true); | ||
732 | } | 792 | } |
733 | defaultroute->setChecked(_pppdata->defaultroute()); | ||
734 | } | ||
735 | else { | ||
736 | defaultgateway->setChecked(true); | ||
737 | hitGatewaySelect(0); | ||
738 | defaultroute->setChecked(true); | ||
739 | } | ||
740 | } | 793 | } |
741 | 794 | ||
742 | void GatewayWidget::save() { | 795 | void GatewayWidget::save() |
743 | _pppdata->setGateway(gatewayaddr->text()); | 796 | { |
744 | _pppdata->setDefaultroute(defaultroute->isChecked()); | 797 | _pppdata->setGateway(gatewayaddr->text()); |
798 | _pppdata->setDefaultroute(defaultroute->isChecked()); | ||
745 | } | 799 | } |
746 | 800 | ||
747 | 801 | ||
748 | void GatewayWidget::hitGatewaySelect( int i ) { | 802 | void GatewayWidget::hitGatewaySelect( int i ) |
749 | if(i == 0) { | 803 | { |
750 | gatewayaddr->setText("0.0.0.0"); | 804 | if(i == 0) |
751 | gatewayaddr->setEnabled(false); | 805 | { |
752 | gate_label->setEnabled(false); | 806 | gatewayaddr->setText("0.0.0.0"); |
753 | } | 807 | gatewayaddr->setEnabled(false); |
754 | else { | 808 | gate_label->setEnabled(false); |
755 | gatewayaddr->setEnabled(true); | 809 | } |
756 | gatewayaddr->setText(""); | 810 | else |
757 | gate_label->setEnabled(true); | 811 | { |
758 | } | 812 | gatewayaddr->setEnabled(true); |
813 | gatewayaddr->setText(""); | ||
814 | gate_label->setEnabled(true); | ||
815 | } | ||
759 | } | 816 | } |
760 | 817 | ||
761 | 818 | ||
762 | 819 | ||
763 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 820 | ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
764 | : QWidget(parent, name),_pppdata(pd) | 821 | : QWidget(parent, name),_pppdata(pd) |
765 | { | 822 | { |
766 | 823 | ||
767 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); | 824 | QVBoxLayout *tl = new QVBoxLayout(this, 0 ); |
768 | se = new ScriptEdit(this); | 825 | se = new ScriptEdit(this); |
769 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); | 826 | connect(se, SIGNAL(returnPressed()), SLOT(addButton())); |
770 | tl->addWidget(se); | 827 | tl->addWidget(se); |
771 | 828 | ||
772 | // insert equal-sized buttons | 829 | // insert equal-sized buttons |
773 | QHBoxLayout *hl = new QHBoxLayout( this ); | 830 | QHBoxLayout *hl = new QHBoxLayout( this ); |
774 | tl->addLayout( hl ); | 831 | tl->addLayout( hl ); |
775 | add = new QPushButton( tr("Add"), this ); | 832 | add = new QPushButton( tr("Add"), this ); |
776 | hl->addWidget( add ); | 833 | hl->addWidget( add ); |
777 | connect(add, SIGNAL(clicked()), SLOT(addButton())); | 834 | connect(add, SIGNAL(clicked()), SLOT(addButton())); |
778 | insert = new QPushButton( tr("Insert"), this ); | 835 | insert = new QPushButton( tr("Insert"), this ); |
779 | hl->addWidget( insert ); | 836 | hl->addWidget( insert ); |
780 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); | 837 | connect(insert, SIGNAL(clicked()), SLOT(insertButton())); |
781 | remove = new QPushButton( tr("Remove"), this ); | 838 | remove = new QPushButton( tr("Remove"), this ); |
782 | hl->addWidget( remove ); | 839 | hl->addWidget( remove ); |
783 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); | 840 | connect(remove, SIGNAL(clicked()), SLOT(removeButton())); |
784 | 841 | ||
785 | QHBoxLayout *l12 = new QHBoxLayout(0); | 842 | QHBoxLayout *l12 = new QHBoxLayout(0); |
786 | tl->addLayout(l12); | 843 | tl->addLayout(l12); |
787 | stl = new QListBox(this); | 844 | stl = new QListBox(this); |
788 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); | 845 | // stl->setVScrollBarMode( QScrollView::AlwaysOff ); |
789 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); | 846 | connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); |
790 | // stl->setMinimumSize(QSize(70, 140)); | 847 | // stl->setMinimumSize(QSize(70, 140)); |
791 | 848 | ||
792 | sl = new QListBox(this); | 849 | sl = new QListBox(this); |
793 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); | 850 | // sl->setVScrollBarMode( QScrollView::AlwaysOff ); |
794 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); | 851 | connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); |
795 | // sl->setMinimumSize(QSize(150, 140)); | 852 | // sl->setMinimumSize(QSize(150, 140)); |
796 | 853 | ||
797 | slb = new QScrollBar(this); | 854 | slb = new QScrollBar(this); |
798 | // slb->setFixedWidth(slb->sizeHint().width()); | 855 | // slb->setFixedWidth(slb->sizeHint().width()); |
799 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); | 856 | connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); |
800 | 857 | ||
801 | l12->addWidget(stl, 1); | 858 | l12->addWidget(stl, 1); |
802 | l12->addWidget(sl, 3); | 859 | l12->addWidget(sl, 3); |
803 | l12->addWidget(slb, 0); | 860 | l12->addWidget(slb, 0); |
804 | 861 | ||
805 | //load data from gpppdata | 862 | //load data from gpppdata |
806 | if(!isnewaccount) { | 863 | if(!isnewaccount) |
807 | QStringList &comlist = _pppdata->scriptType(); | ||
808 | QStringList &arglist = _pppdata->script(); | ||
809 | QStringList::Iterator itcom = comlist.begin(); | ||
810 | QStringList::Iterator itarg = arglist.begin(); | ||
811 | |||
812 | for ( ; | ||
813 | itcom != comlist.end() && itarg != arglist.end(); | ||
814 | ++itcom, ++itarg ) | ||
815 | { | 864 | { |
816 | stl->insertItem(*itcom); | 865 | QStringList &comlist = _pppdata->scriptType(); |
817 | sl->insertItem(*itarg); | 866 | QStringList &arglist = _pppdata->script(); |
867 | QStringList::Iterator itcom = comlist.begin(); | ||
868 | QStringList::Iterator itarg = arglist.begin(); | ||
869 | |||
870 | for ( ; | ||
871 | itcom != comlist.end() && itarg != arglist.end(); | ||
872 | ++itcom, ++itarg ) | ||
873 | { | ||
874 | stl->insertItem(*itcom); | ||
875 | sl->insertItem(*itarg); | ||
876 | } | ||
818 | } | 877 | } |
819 | } | ||
820 | 878 | ||
821 | insert->setEnabled(false); | 879 | insert->setEnabled(false); |
822 | remove->setEnabled(false); | 880 | remove->setEnabled(false); |
823 | adjustScrollBar(); | 881 | adjustScrollBar(); |
824 | tl->activate(); | 882 | tl->activate(); |
825 | } | 883 | } |
826 | 884 | ||
827 | bool ScriptWidget::check() { | 885 | bool ScriptWidget::check() |
828 | uint lstart = 0; | 886 | { |
829 | uint lend = 0; | 887 | uint lstart = 0; |
830 | uint errcnt = 0; | 888 | uint lend = 0; |
889 | uint errcnt = 0; | ||
831 | 890 | ||
832 | if(sl->count() > 0) { | 891 | if(sl->count() > 0) |
833 | for( uint i=0; i <= sl->count()-1; i++) { | 892 | { |
834 | if(stl->text(i) == "LoopStart") { | 893 | for( uint i=0; i <= sl->count()-1; i++) |
835 | lstart++; | 894 | { |
836 | } | 895 | if(stl->text(i) == "LoopStart") |
837 | if (stl->text(i) == "LoopEnd") { | 896 | { |
838 | lend++; | 897 | lstart++; |
898 | } | ||
899 | if (stl->text(i) == "LoopEnd") | ||
900 | { | ||
901 | lend++; | ||
902 | } | ||
903 | if ( lend > lstart ) errcnt++; | ||
839 | } | 904 | } |
840 | if ( lend > lstart ) errcnt++; | 905 | return ( (errcnt == 0 ) && (lstart == lend) ); |
841 | } | 906 | } |
842 | return ( (errcnt == 0 ) && (lstart == lend) ); | 907 | return true; |
843 | } | ||
844 | return true; | ||
845 | } | 908 | } |
846 | 909 | ||
847 | 910 | ||
848 | void ScriptWidget::save() { | 911 | void ScriptWidget::save() |
849 | QStringList typelist, arglist; | 912 | { |
850 | for(uint i=0; i < sl->count(); i++) { | 913 | QStringList typelist, arglist; |
851 | typelist.append(stl->text(i)); | 914 | for(uint i=0; i < sl->count(); i++) |
852 | arglist.append(sl->text(i)); | 915 | { |
853 | } | 916 | typelist.append(stl->text(i)); |
854 | _pppdata->setScriptType(typelist); | 917 | arglist.append(sl->text(i)); |
855 | _pppdata->setScript(arglist); | 918 | } |
919 | _pppdata->setScriptType(typelist); | ||
920 | _pppdata->setScript(arglist); | ||
856 | } | 921 | } |
857 | 922 | ||
858 | 923 | ||
859 | 924 | ||
860 | void ScriptWidget::adjustScrollBar() { | 925 | void ScriptWidget::adjustScrollBar() |
861 | if((int)sl->count() <= sl->numItemsVisible()) | 926 | { |
862 | slb->setRange(0, 0); | 927 | if((int)sl->count() <= sl->numItemsVisible()) |
863 | else | 928 | slb->setRange(0, 0); |
864 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); | 929 | else |
930 | slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); | ||
865 | } | 931 | } |
866 | 932 | ||
867 | 933 | ||
868 | void ScriptWidget::scrolling(int i) { | 934 | void ScriptWidget::scrolling(int i) |
869 | sl->setTopItem(i); | 935 | { |
870 | stl->setTopItem(i); | 936 | sl->setTopItem(i); |
937 | stl->setTopItem(i); | ||
871 | } | 938 | } |
872 | 939 | ||
873 | 940 | ||
874 | void ScriptWidget::slhighlighted(int i) { | 941 | void ScriptWidget::slhighlighted(int i) |
875 | insert->setEnabled(true); | 942 | { |
876 | remove->setEnabled(true); | 943 | insert->setEnabled(true); |
877 | stl->setCurrentItem(i); | 944 | remove->setEnabled(true); |
945 | stl->setCurrentItem(i); | ||
878 | } | 946 | } |
879 | 947 | ||
880 | 948 | ||
881 | void ScriptWidget::stlhighlighted(int i) { | 949 | void ScriptWidget::stlhighlighted(int i) |
882 | insert->setEnabled(true); | 950 | { |
883 | remove->setEnabled(true); | 951 | insert->setEnabled(true); |
884 | sl->setCurrentItem(i); | 952 | remove->setEnabled(true); |
953 | sl->setCurrentItem(i); | ||
885 | } | 954 | } |
886 | 955 | ||
887 | 956 | ||
888 | void ScriptWidget::addButton() { | 957 | void ScriptWidget::addButton() |
889 | //don't allow more than the maximum script entries | 958 | { |
890 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) | 959 | //don't allow more than the maximum script entries |
891 | return; | 960 | if(sl->count() == MAX_SCRIPT_ENTRIES-1) |
961 | return; | ||
892 | 962 | ||
893 | switch(se->type()) { | 963 | switch(se->type()) |
964 | { | ||
894 | case ScriptEdit::Expect: | 965 | case ScriptEdit::Expect: |
895 | stl->insertItem("Expect"); | 966 | stl->insertItem("Expect"); |
896 | sl->insertItem(se->text()); | 967 | sl->insertItem(se->text()); |
897 | break; | 968 | break; |
898 | 969 | ||
899 | case ScriptEdit::Send: | 970 | case ScriptEdit::Send: |
900 | stl->insertItem("Send"); | 971 | stl->insertItem("Send"); |
901 | sl->insertItem(se->text()); | 972 | sl->insertItem(se->text()); |
902 | break; | 973 | break; |
903 | 974 | ||
904 | case ScriptEdit::SendNoEcho: | 975 | case ScriptEdit::SendNoEcho: |
905 | stl->insertItem("SendNoEcho"); | 976 | stl->insertItem("SendNoEcho"); |
906 | sl->insertItem(se->text()); | 977 | sl->insertItem(se->text()); |
907 | break; | 978 | break; |
908 | 979 | ||
909 | case ScriptEdit::Pause: | 980 | case ScriptEdit::Pause: |
910 | stl->insertItem("Pause"); | 981 | stl->insertItem("Pause"); |
911 | sl->insertItem(se->text()); | 982 | sl->insertItem(se->text()); |
912 | break; | 983 | break; |
913 | 984 | ||
914 | case ScriptEdit::Hangup: | 985 | case ScriptEdit::Hangup: |
915 | stl->insertItem("Hangup"); | 986 | stl->insertItem("Hangup"); |
916 | sl->insertItem(""); | 987 | sl->insertItem(""); |
917 | break; | 988 | break; |
918 | 989 | ||
919 | case ScriptEdit::Answer: | 990 | case ScriptEdit::Answer: |
920 | stl->insertItem("Answer"); | 991 | stl->insertItem("Answer"); |
921 | sl->insertItem(""); | 992 | sl->insertItem(""); |
922 | break; | 993 | break; |
923 | 994 | ||
924 | case ScriptEdit::Timeout: | 995 | case ScriptEdit::Timeout: |
925 | stl->insertItem("Timeout"); | 996 | stl->insertItem("Timeout"); |
926 | sl->insertItem(se->text()); | 997 | sl->insertItem(se->text()); |
927 | break; | 998 | break; |
928 | 999 | ||
929 | case ScriptEdit::Password: | 1000 | case ScriptEdit::Password: |
930 | stl->insertItem("Password"); | 1001 | stl->insertItem("Password"); |
931 | sl->insertItem(se->text()); | 1002 | sl->insertItem(se->text()); |
932 | break; | 1003 | break; |
933 | 1004 | ||
934 | case ScriptEdit::ID: | 1005 | case ScriptEdit::ID: |
935 | stl->insertItem("ID"); | 1006 | stl->insertItem("ID"); |
936 | sl->insertItem(se->text()); | 1007 | sl->insertItem(se->text()); |
937 | break; | 1008 | break; |
938 | 1009 | ||
939 | case ScriptEdit::Prompt: | 1010 | case ScriptEdit::Prompt: |
940 | stl->insertItem("Prompt"); | 1011 | stl->insertItem("Prompt"); |
941 | sl->insertItem(se->text()); | 1012 | sl->insertItem(se->text()); |
942 | break; | 1013 | break; |
943 | 1014 | ||
944 | case ScriptEdit::PWPrompt: | 1015 | case ScriptEdit::PWPrompt: |
945 | stl->insertItem("PWPrompt"); | 1016 | stl->insertItem("PWPrompt"); |
946 | sl->insertItem(se->text()); | 1017 | sl->insertItem(se->text()); |
947 | break; | 1018 | break; |
948 | 1019 | ||
949 | case ScriptEdit::LoopStart: | 1020 | case ScriptEdit::LoopStart: |
950 | stl->insertItem("LoopStart"); | 1021 | stl->insertItem("LoopStart"); |
951 | sl->insertItem(se->text()); | 1022 | sl->insertItem(se->text()); |
952 | break; | 1023 | break; |
953 | 1024 | ||
954 | case ScriptEdit::LoopEnd: | 1025 | case ScriptEdit::LoopEnd: |
955 | stl->insertItem("LoopEnd"); | 1026 | stl->insertItem("LoopEnd"); |
956 | sl->insertItem(se->text()); | 1027 | sl->insertItem(se->text()); |
957 | break; | 1028 | break; |
958 | 1029 | ||
959 | case ScriptEdit::Scan: | 1030 | case ScriptEdit::Scan: |
960 | stl->insertItem("Scan"); | 1031 | stl->insertItem("Scan"); |
961 | sl->insertItem(se->text()); | 1032 | sl->insertItem(se->text()); |
962 | break; | 1033 | break; |
963 | 1034 | ||
964 | case ScriptEdit::Save: | 1035 | case ScriptEdit::Save: |
965 | stl->insertItem("Save"); | 1036 | stl->insertItem("Save"); |
966 | sl->insertItem(se->text()); | 1037 | sl->insertItem(se->text()); |
967 | break; | 1038 | break; |
968 | 1039 | ||
969 | default: | 1040 | default: |
970 | break; | 1041 | break; |
971 | } | 1042 | } |
972 | 1043 | ||
973 | //get the scrollbar adjusted, and scroll the list so we can see what | 1044 | //get the scrollbar adjusted, and scroll the list so we can see what |
974 | //we're adding to | 1045 | //we're adding to |
975 | adjustScrollBar(); | 1046 | adjustScrollBar(); |
976 | slb->setValue(slb->maxValue()); | 1047 | slb->setValue(slb->maxValue()); |
977 | 1048 | ||
978 | //clear the text in the entry box | 1049 | //clear the text in the entry box |
979 | se->setText(""); | 1050 | se->setText(""); |
980 | } | 1051 | } |
981 | 1052 | ||
982 | 1053 | ||
983 | void ScriptWidget::insertButton() { | 1054 | void ScriptWidget::insertButton() |
984 | //exit if there is no highlighted item, or we've reached the | 1055 | { |
985 | //maximum entries in the script list | 1056 | //exit if there is no highlighted item, or we've reached the |
986 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) | 1057 | //maximum entries in the script list |
987 | return; | 1058 | if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) |
1059 | return; | ||
988 | 1060 | ||
989 | switch(se->type()) { | 1061 | switch(se->type()) |
1062 | { | ||
990 | case ScriptEdit::Expect: | 1063 | case ScriptEdit::Expect: |
991 | stl->insertItem("Expect", stl->currentItem()); | 1064 | stl->insertItem("Expect", stl->currentItem()); |
992 | sl->insertItem(se->text(), sl->currentItem()); | 1065 | sl->insertItem(se->text(), sl->currentItem()); |
993 | break; | 1066 | break; |
994 | 1067 | ||
995 | case ScriptEdit::Send: | 1068 | case ScriptEdit::Send: |
996 | stl->insertItem("Send", stl->currentItem()); | 1069 | stl->insertItem("Send", stl->currentItem()); |
997 | sl->insertItem(se->text(), sl->currentItem()); | 1070 | sl->insertItem(se->text(), sl->currentItem()); |
998 | break; | 1071 | break; |
999 | 1072 | ||
1000 | case ScriptEdit::SendNoEcho: | 1073 | case ScriptEdit::SendNoEcho: |
1001 | stl->insertItem("SendNoEcho", stl->currentItem()); | 1074 | stl->insertItem("SendNoEcho", stl->currentItem()); |
1002 | sl->insertItem(se->text(), sl->currentItem()); | 1075 | sl->insertItem(se->text(), sl->currentItem()); |
1003 | break; | 1076 | break; |
1004 | 1077 | ||
1005 | case ScriptEdit::Pause: | 1078 | case ScriptEdit::Pause: |
1006 | stl->insertItem("Pause", stl->currentItem()); | 1079 | stl->insertItem("Pause", stl->currentItem()); |
1007 | sl->insertItem(se->text(), sl->currentItem()); | 1080 | sl->insertItem(se->text(), sl->currentItem()); |
1008 | break; | 1081 | break; |
1009 | 1082 | ||
1010 | case ScriptEdit::Hangup: | 1083 | case ScriptEdit::Hangup: |
1011 | stl->insertItem("Hangup", stl->currentItem()); | 1084 | stl->insertItem("Hangup", stl->currentItem()); |
1012 | sl->insertItem("", sl->currentItem()); | 1085 | sl->insertItem("", sl->currentItem()); |
1013 | break; | 1086 | break; |
1014 | 1087 | ||
1015 | case ScriptEdit::Answer: | 1088 | case ScriptEdit::Answer: |
1016 | stl->insertItem("Answer", stl->currentItem()); | 1089 | stl->insertItem("Answer", stl->currentItem()); |
1017 | sl->insertItem("", sl->currentItem()); | 1090 | sl->insertItem("", sl->currentItem()); |
1018 | break; | 1091 | break; |
1019 | 1092 | ||
1020 | case ScriptEdit::Timeout: | 1093 | case ScriptEdit::Timeout: |
1021 | stl->insertItem("Timeout", stl->currentItem()); | 1094 | stl->insertItem("Timeout", stl->currentItem()); |
1022 | sl->insertItem(se->text(), sl->currentItem()); | 1095 | sl->insertItem(se->text(), sl->currentItem()); |
1023 | break; | 1096 | break; |
1024 | 1097 | ||
1025 | case ScriptEdit::Password: | 1098 | case ScriptEdit::Password: |
1026 | stl->insertItem("Password", stl->currentItem()); | 1099 | stl->insertItem("Password", stl->currentItem()); |
1027 | sl->insertItem(se->text(), sl->currentItem()); | 1100 | sl->insertItem(se->text(), sl->currentItem()); |
1028 | break; | 1101 | break; |
1029 | 1102 | ||
1030 | case ScriptEdit::ID: | 1103 | case ScriptEdit::ID: |
1031 | stl->insertItem("ID", stl->currentItem()); | 1104 | stl->insertItem("ID", stl->currentItem()); |
1032 | sl->insertItem(se->text(), sl->currentItem()); | 1105 | sl->insertItem(se->text(), sl->currentItem()); |
1033 | break; | 1106 | break; |
1034 | 1107 | ||
1035 | case ScriptEdit::Prompt: | 1108 | case ScriptEdit::Prompt: |
1036 | stl->insertItem("Prompt", stl->currentItem()); | 1109 | stl->insertItem("Prompt", stl->currentItem()); |
1037 | sl->insertItem(se->text(), sl->currentItem()); | 1110 | sl->insertItem(se->text(), sl->currentItem()); |
1038 | break; | 1111 | break; |
1039 | 1112 | ||
1040 | case ScriptEdit::PWPrompt: | 1113 | case ScriptEdit::PWPrompt: |
1041 | stl->insertItem("PWPrompt", stl->currentItem()); | 1114 | stl->insertItem("PWPrompt", stl->currentItem()); |
1042 | sl->insertItem(se->text(), sl->currentItem()); | 1115 | sl->insertItem(se->text(), sl->currentItem()); |
1043 | break; | 1116 | break; |
1044 | 1117 | ||
1045 | case ScriptEdit::LoopStart: | 1118 | case ScriptEdit::LoopStart: |
1046 | stl->insertItem("LoopStart", stl->currentItem()); | 1119 | stl->insertItem("LoopStart", stl->currentItem()); |
1047 | sl->insertItem(se->text(), sl->currentItem()); | 1120 | sl->insertItem(se->text(), sl->currentItem()); |
1048 | break; | 1121 | break; |
1049 | 1122 | ||
1050 | case ScriptEdit::LoopEnd: | 1123 | case ScriptEdit::LoopEnd: |
1051 | stl->insertItem("LoopEnd", stl->currentItem()); | 1124 | stl->insertItem("LoopEnd", stl->currentItem()); |
1052 | sl->insertItem(se->text(), sl->currentItem()); | 1125 | sl->insertItem(se->text(), sl->currentItem()); |
1053 | break; | 1126 | break; |
1054 | 1127 | ||
1055 | case ScriptEdit::Scan: | 1128 | case ScriptEdit::Scan: |
1056 | stl->insertItem("Scan", stl->currentItem()); | 1129 | stl->insertItem("Scan", stl->currentItem()); |
1057 | sl->insertItem(se->text(), sl->currentItem()); | 1130 | sl->insertItem(se->text(), sl->currentItem()); |
1058 | break; | 1131 | break; |
1059 | 1132 | ||
1060 | case ScriptEdit::Save: | 1133 | case ScriptEdit::Save: |
1061 | stl->insertItem("Save", stl->currentItem()); | 1134 | stl->insertItem("Save", stl->currentItem()); |
1062 | sl->insertItem(se->text(), sl->currentItem()); | 1135 | sl->insertItem(se->text(), sl->currentItem()); |
1063 | break; | 1136 | break; |
1064 | 1137 | ||
1065 | default: | 1138 | default: |
1066 | break; | 1139 | break; |
1067 | } | 1140 | } |
1068 | adjustScrollBar(); | 1141 | adjustScrollBar(); |
1069 | se->setText(""); | 1142 | se->setText(""); |
1070 | } | 1143 | } |
1071 | 1144 | ||
1072 | 1145 | ||
1073 | void ScriptWidget::removeButton() { | 1146 | void ScriptWidget::removeButton() |
1074 | if(sl->currentItem() >= 0) { | 1147 | { |
1075 | int stlc = stl->currentItem(); | 1148 | if(sl->currentItem() >= 0) |
1076 | sl->removeItem(sl->currentItem()); | 1149 | { |
1077 | stl->removeItem(stlc); | 1150 | int stlc = stl->currentItem(); |
1078 | adjustScrollBar(); | 1151 | sl->removeItem(sl->currentItem()); |
1079 | insert->setEnabled(sl->currentItem() != -1); | 1152 | stl->removeItem(stlc); |
1080 | remove->setEnabled(sl->currentItem() != -1); | 1153 | adjustScrollBar(); |
1081 | } | 1154 | insert->setEnabled(sl->currentItem() != -1); |
1155 | remove->setEnabled(sl->currentItem() != -1); | ||
1156 | } | ||
1082 | } | 1157 | } |
1083 | 1158 | ||
1084 | 1159 | ||
1085 | 1160 | ||
1086 | ///////////////////////////////////////////////////////////////////////////// | 1161 | ///////////////////////////////////////////////////////////////////////////// |
1087 | // | 1162 | // |
1088 | // Used to specify a new phone number | 1163 | // Used to specify a new phone number |
1089 | // | 1164 | // |
1090 | ///////////////////////////////////////////////////////////////////////////// | 1165 | ///////////////////////////////////////////////////////////////////////////// |
1091 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) | 1166 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) |
1092 | : QDialog(parent,"PhoneNumberDialog",true) | 1167 | : QDialog(parent,"PhoneNumberDialog",true) |
1093 | { | 1168 | { |
1094 | setCaption( tr("Add Phone Number") ); | 1169 | setCaption( tr("Add Phone Number") ); |
1095 | 1170 | ||
1096 | 1171 | ||
1097 | QVBoxLayout *layout = new QVBoxLayout( this ); | 1172 | QVBoxLayout *layout = new QVBoxLayout( this ); |
1098 | layout->setSpacing( 3 ); | 1173 | layout->setSpacing( 3 ); |
1099 | layout->setMargin( 3 ); | 1174 | layout->setMargin( 3 ); |
1100 | 1175 | ||
1101 | // QHBox *hbox = new QHBox(this); | 1176 | // QHBox *hbox = new QHBox(this); |
1102 | // setMainWidget(hbox); | 1177 | // setMainWidget(hbox); |
1103 | 1178 | ||
1104 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); | 1179 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); |
1105 | 1180 | ||
1106 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); | 1181 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); |
1107 | layout->addWidget( label ); | 1182 | layout->addWidget( label ); |
1108 | 1183 | ||
1109 | le = new QLineEdit(this, "lineEdit"); | 1184 | le = new QLineEdit(this, "lineEdit"); |
1110 | layout->addWidget( le ); | 1185 | layout->addWidget( le ); |
1111 | 1186 | ||
1112 | connect(le, SIGNAL(textChanged(const QString &)), | 1187 | connect(le, SIGNAL(textChanged(const QString &)), |
1113 | this, SLOT(textChanged(const QString &))); | 1188 | this, SLOT(textChanged(const QString &))); |
1114 | 1189 | ||
1115 | le->setFocus(); | 1190 | le->setFocus(); |
1116 | textChanged(""); | 1191 | textChanged(""); |
1117 | 1192 | ||
1118 | 1193 | ||
1119 | } | 1194 | } |
1120 | 1195 | ||
1121 | 1196 | ||
1122 | QString PhoneNumberDialog::phoneNumber() { | 1197 | QString PhoneNumberDialog::phoneNumber() |
1123 | QString s = le->text(); | 1198 | { |
1199 | QString s = le->text(); | ||
1124 | 1200 | ||
1125 | return s; | 1201 | return s; |
1126 | } | 1202 | } |
1127 | 1203 | ||
1128 | 1204 | ||
1129 | void PhoneNumberDialog::textChanged(const QString &s) { | 1205 | void PhoneNumberDialog::textChanged(const QString &s) |
1130 | // enableButtonOK(s.length() > 0); | 1206 | { |
1207 | // enableButtonOK(s.length() > 0); | ||
1131 | } | 1208 | } |
1132 | 1209 | ||
1133 | 1210 | ||
1134 | //#include "edit.moc" | 1211 | //#include "edit.moc" |
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 566b179..9cb8ad2 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp | |||
@@ -14,52 +14,54 @@ | |||
14 | ** Foundation and appearing in the file LICENSE.GPL included in the | 14 | ** Foundation and appearing in the file LICENSE.GPL included in the |
15 | ** packaging of this file. | 15 | ** packaging of this file. |
16 | ** | 16 | ** |
17 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 17 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
18 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 18 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #include "modulesinfo.h" | ||
23 | #include "detail.h" | ||
24 | |||
25 | /* OPIE */ | ||
22 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
23 | 27 | ||
28 | /* QT */ | ||
24 | #include <qfile.h> | 29 | #include <qfile.h> |
25 | #include <qlayout.h> | 30 | #include <qlayout.h> |
26 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
27 | #include <qtimer.h> | 32 | #include <qtimer.h> |
28 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
29 | 34 | ||
30 | #include "modulesinfo.h" | ||
31 | #include "detail.h" | ||
32 | |||
33 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 35 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) |
34 | : QWidget( parent, name, fl ) | 36 | : QWidget( parent, name, fl ) |
35 | { | 37 | { |
36 | QGridLayout *layout = new QGridLayout( this ); | 38 | QGridLayout *layout = new QGridLayout( this ); |
37 | layout->setSpacing( 4 ); | 39 | layout->setSpacing( 4 ); |
38 | layout->setMargin( 4 ); | 40 | layout->setMargin( 4 ); |
39 | 41 | ||
40 | ModulesView = new QListView( this ); | 42 | ModulesView = new QListView( this ); |
41 | int colnum = ModulesView->addColumn( tr( "Module" ) ); | 43 | int colnum = ModulesView->addColumn( tr( "Module" ) ); |
42 | colnum = ModulesView->addColumn( tr( "Size" ) ); | 44 | colnum = ModulesView->addColumn( tr( "Size" ) ); |
43 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
44 | colnum = ModulesView->addColumn( tr( "Use#" ) ); | 46 | colnum = ModulesView->addColumn( tr( "Use#" ) ); |
45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
46 | colnum = ModulesView->addColumn( tr( "Used by" ) ); | 48 | colnum = ModulesView->addColumn( tr( "Used by" ) ); |
47 | ModulesView->setAllColumnsShowFocus( TRUE ); | 49 | ModulesView->setAllColumnsShowFocus( TRUE ); |
48 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); | 50 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); |
49 | QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); | 51 | QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); |
50 | 52 | ||
51 | // Test if we have /sbin/modinfo, and if so, allow module detail window | 53 | // Test if we have /sbin/modinfo, and if so, allow module detail window |
52 | if ( QFile::exists( "/sbin/modinfo" ) ) | 54 | if ( QFile::exists( "/sbin/modinfo" ) ) |
53 | { | 55 | { |
54 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); | 56 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); |
55 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 57 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
56 | this, SLOT( viewModules( QListViewItem * ) ) ); | 58 | this, SLOT( viewModules( QListViewItem * ) ) ); |
57 | } | 59 | } |
58 | 60 | ||
59 | CommandCB = new QComboBox( FALSE, this ); | 61 | CommandCB = new QComboBox( FALSE, this ); |
60 | CommandCB->insertItem( "modprobe -r" ); | 62 | CommandCB->insertItem( "modprobe -r" ); |
61 | CommandCB->insertItem( "rmmod" ); | 63 | CommandCB->insertItem( "rmmod" ); |
62 | // I can't think of other useful commands yet. Anyone? | 64 | // I can't think of other useful commands yet. Anyone? |
63 | layout->addWidget( CommandCB, 1, 0 ); | 65 | layout->addWidget( CommandCB, 1, 0 ); |
64 | QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); | 66 | QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); |
65 | 67 | ||
@@ -69,49 +71,49 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | |||
69 | btn->setText( tr( "Send" ) ); | 71 | btn->setText( tr( "Send" ) ); |
70 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 72 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
71 | layout->addWidget( btn, 1, 1 ); | 73 | layout->addWidget( btn, 1, 1 ); |
72 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); | 74 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); |
73 | 75 | ||
74 | QTimer *t = new QTimer( this ); | 76 | QTimer *t = new QTimer( this ); |
75 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 77 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
76 | t->start( 5000 ); | 78 | t->start( 5000 ); |
77 | 79 | ||
78 | updateData(); | 80 | updateData(); |
79 | 81 | ||
80 | ModulesDtl = new Detail(); | 82 | ModulesDtl = new Detail(); |
81 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); | 83 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); |
82 | } | 84 | } |
83 | 85 | ||
84 | ModulesInfo::~ModulesInfo() | 86 | ModulesInfo::~ModulesInfo() |
85 | { | 87 | {} |
86 | } | ||
87 | 88 | ||
88 | void ModulesInfo::updateData() | 89 | void ModulesInfo::updateData() |
89 | { | 90 | { |
90 | char modname[64]; | 91 | char modname[64]; |
91 | char usage[200]; | 92 | char usage[200]; |
92 | int modsize, usecount; | 93 | int modsize, usecount; |
93 | 94 | ||
94 | QString selectedmod; | 95 | QString selectedmod; |
95 | QListViewItem *curritem = ModulesView->currentItem(); | 96 | QListViewItem *curritem = ModulesView->currentItem(); |
96 | if ( curritem ) | 97 | if ( curritem ) |
97 | { | 98 | { |
98 | selectedmod = curritem->text( 0 ); | 99 | selectedmod = curritem->text( 0 ); |
99 | } | 100 | } |
100 | 101 | ||
101 | ModulesView->clear(); | 102 | ModulesView->clear(); |
102 | 103 | ||
103 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 104 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
104 | 105 | ||
105 | if ( procfile ) | 106 | if ( procfile ) |
106 | { | 107 | { |
107 | QListViewItem *newitem; | 108 | QListViewItem *newitem; |
108 | QListViewItem *selecteditem = 0x0; | 109 | QListViewItem *selecteditem = 0x0; |
109 | while ( true ) { | 110 | while ( true ) |
111 | { | ||
110 | modname[0] = '\0'; | 112 | modname[0] = '\0'; |
111 | usage[0] = '\0'; | 113 | usage[0] = '\0'; |
112 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); | 114 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); |
113 | 115 | ||
114 | if ( success == EOF ) | 116 | if ( success == EOF ) |
115 | break; | 117 | break; |
116 | 118 | ||
117 | QString qmodname = QString( modname ); | 119 | QString qmodname = QString( modname ); |
@@ -128,61 +130,61 @@ void ModulesInfo::updateData() | |||
128 | ModulesView->setCurrentItem( selecteditem ); | 130 | ModulesView->setCurrentItem( selecteditem ); |
129 | 131 | ||
130 | fclose( procfile ); | 132 | fclose( procfile ); |
131 | } | 133 | } |
132 | } | 134 | } |
133 | 135 | ||
134 | void ModulesInfo::slotSendClicked() | 136 | void ModulesInfo::slotSendClicked() |
135 | { | 137 | { |
136 | if ( !ModulesView->currentItem() ) | 138 | if ( !ModulesView->currentItem() ) |
137 | { | 139 | { |
138 | return; | 140 | return; |
139 | } | 141 | } |
140 | 142 | ||
141 | QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); | 143 | QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); |
142 | 144 | ||
143 | QString modname = ModulesView->currentItem()->text( 0 ); | 145 | QString modname = ModulesView->currentItem()->text( 0 ); |
144 | 146 | ||
145 | if ( QMessageBox::warning( this, modname, capstr, | 147 | if ( QMessageBox::warning( this, modname, capstr, |
146 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 148 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
147 | { | 149 | { |
148 | QString command = "/sbin/"; | 150 | QString command = "/sbin/"; |
149 | command.append( CommandCB->currentText() ); | 151 | command.append( CommandCB->currentText() ); |
150 | command.append( " " ); | 152 | command.append( " " ); |
151 | command.append( modname ); | 153 | command.append( modname ); |
152 | 154 | ||
153 | FILE* stream = popen( command, "r" ); | 155 | FILE* stream = popen( command, "r" ); |
154 | if ( stream ) | 156 | if ( stream ) |
155 | pclose( stream ); | 157 | pclose( stream ); |
156 | } | 158 | } |
157 | 159 | ||
158 | } | 160 | } |
159 | 161 | ||
160 | void ModulesInfo::viewModules( QListViewItem *modules ) | 162 | void ModulesInfo::viewModules( QListViewItem *modules ) |
161 | { | 163 | { |
162 | QString modname = modules->text( 0 ); | 164 | QString modname = modules->text( 0 ); |
163 | QString capstr = "Module: "; | 165 | QString capstr = "Module: "; |
164 | capstr.append( modname ); | 166 | capstr.append( modname ); |
165 | ModulesDtl->setCaption( capstr ); | 167 | ModulesDtl->setCaption( capstr ); |
166 | QString command = "/sbin/modinfo "; | 168 | QString command = "/sbin/modinfo "; |
167 | command.append( modname ); | 169 | command.append( modname ); |
168 | FILE* modinfo = popen( command, "r" ); | 170 | FILE* modinfo = popen( command, "r" ); |
169 | 171 | ||
170 | if ( modinfo ) | 172 | if ( modinfo ) |
171 | { | 173 | { |
172 | char line[200]; | 174 | char line[200]; |
173 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); | 175 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); |
174 | 176 | ||
175 | while( true ) | 177 | while( true ) |
176 | { | 178 | { |
177 | int success = fscanf( modinfo, "%[^\n]\n", line ); | 179 | int success = fscanf( modinfo, "%[^\n]\n", line ); |
178 | if ( success == EOF ) | 180 | if ( success == EOF ) |
179 | break; | 181 | break; |
180 | ModulesDtl->detailView->append( line ); | 182 | ModulesDtl->detailView->append( line ); |
181 | } | 183 | } |
182 | 184 | ||
183 | pclose( modinfo ); | 185 | pclose( modinfo ); |
184 | } | 186 | } |
185 | 187 | ||
186 | ModulesDtl->showMaximized(); | 188 | QPEApplication::showWidget( ModulesDtl ); |
187 | } | 189 | } |
188 | 190 | ||
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index af0fe26..2a90b0f 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -12,52 +12,55 @@ | |||
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
17 | ** | 17 | ** |
18 | **********************************************************************/ | 18 | **********************************************************************/ |
19 | 19 | ||
20 | #include "processinfo.h" | ||
21 | #include "detail.h" | ||
22 | |||
23 | /* OPIE */ | ||
20 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
21 | 25 | ||
26 | /* QT */ | ||
22 | #include <qdir.h> | 27 | #include <qdir.h> |
23 | #include <qlayout.h> | 28 | #include <qlayout.h> |
24 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
25 | #include <qtimer.h> | 30 | #include <qtimer.h> |
26 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
27 | 32 | ||
33 | /* STD */ | ||
28 | #include <sys/types.h> | 34 | #include <sys/types.h> |
29 | #include <signal.h> | 35 | #include <signal.h> |
30 | 36 | ||
31 | #include "processinfo.h" | ||
32 | #include "detail.h" | ||
33 | |||
34 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | 37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) |
35 | : QWidget( parent, name, fl ) | 38 | : QWidget( parent, name, fl ) |
36 | { | 39 | { |
37 | QGridLayout *layout = new QGridLayout( this ); | 40 | QGridLayout *layout = new QGridLayout( this ); |
38 | layout->setSpacing( 4 ); | 41 | layout->setSpacing( 4 ); |
39 | layout->setMargin( 4 ); | 42 | layout->setMargin( 4 ); |
40 | 43 | ||
41 | 44 | ||
42 | ProcessView = new QListView( this, "ProcessView" ); | 45 | ProcessView = new QListView( this, "ProcessView" ); |
43 | int colnum = ProcessView->addColumn( tr( "PID" ) ); | 46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); |
44 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
45 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); | 48 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); |
46 | colnum = ProcessView->addColumn( tr( "Status" ) ); | 49 | colnum = ProcessView->addColumn( tr( "Status" ) ); |
47 | colnum = ProcessView->addColumn( tr( "Time" ) ); | 50 | colnum = ProcessView->addColumn( tr( "Time" ) ); |
48 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
49 | ProcessView->setAllColumnsShowFocus( TRUE ); | 52 | ProcessView->setAllColumnsShowFocus( TRUE ); |
50 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); | 53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); |
51 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
52 | this, SLOT( viewProcess( QListViewItem * ) ) ); | 55 | this, SLOT( viewProcess( QListViewItem * ) ) ); |
53 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); | 56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); |
54 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); | 57 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); |
55 | 58 | ||
56 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); | 59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); |
57 | SignalCB->insertItem( " 1: SIGHUP" ); | 60 | SignalCB->insertItem( " 1: SIGHUP" ); |
58 | SignalCB->insertItem( " 2: SIGINT" ); | 61 | SignalCB->insertItem( " 2: SIGINT" ); |
59 | SignalCB->insertItem( " 3: SIGQUIT" ); | 62 | SignalCB->insertItem( " 3: SIGQUIT" ); |
60 | SignalCB->insertItem( " 5: SIGTRAP" ); | 63 | SignalCB->insertItem( " 5: SIGTRAP" ); |
61 | SignalCB->insertItem( " 6: SIGABRT" ); | 64 | SignalCB->insertItem( " 6: SIGABRT" ); |
62 | SignalCB->insertItem( " 9: SIGKILL" ); | 65 | SignalCB->insertItem( " 9: SIGKILL" ); |
63 | SignalCB->insertItem( "14: SIGALRM" ); | 66 | SignalCB->insertItem( "14: SIGALRM" ); |
@@ -81,35 +84,34 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | |||
81 | 84 | ||
82 | updateData(); | 85 | updateData(); |
83 | 86 | ||
84 | ProcessDtl = new Detail(); | 87 | ProcessDtl = new Detail(); |
85 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); | 88 | QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); |
86 | } | 89 | } |
87 | 90 | ||
88 | ProcessInfo::~ProcessInfo() | 91 | ProcessInfo::~ProcessInfo() |
89 | { | 92 | {} |
90 | } | ||
91 | 93 | ||
92 | void ProcessInfo::updateData() | 94 | void ProcessInfo::updateData() |
93 | { | 95 | { |
94 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, | 96 | int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, |
95 | signal, blocked, sigignore, sigcatch; | 97 | signal, blocked, sigignore, sigcatch; |
96 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, | 98 | uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, |
97 | endcode, startstack, kstkesp, kstkeip, wchan; | 99 | endcode, startstack, kstkesp, kstkeip, wchan; |
98 | char state; | 100 | char state; |
99 | char comm[64]; | 101 | char comm[64]; |
100 | 102 | ||
101 | QString selectedpid; | 103 | QString selectedpid; |
102 | QListViewItem *curritem = ProcessView->currentItem(); | 104 | QListViewItem *curritem = ProcessView->currentItem(); |
103 | if ( curritem ) | 105 | if ( curritem ) |
104 | { | 106 | { |
105 | selectedpid = curritem->text( 0 ); | 107 | selectedpid = curritem->text( 0 ); |
106 | } | 108 | } |
107 | 109 | ||
108 | ProcessView->clear(); | 110 | ProcessView->clear(); |
109 | 111 | ||
110 | QListViewItem *newitem; | 112 | QListViewItem *newitem; |
111 | QListViewItem *selecteditem = 0x0; | 113 | QListViewItem *selecteditem = 0x0; |
112 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); | 114 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); |
113 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); | 115 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); |
114 | if ( proclist ) | 116 | if ( proclist ) |
115 | { | 117 | { |
@@ -121,21 +123,21 @@ void ProcessInfo::updateData() | |||
121 | QString processnum = f->fileName(); | 123 | QString processnum = f->fileName(); |
122 | if ( processnum >= "1" && processnum <= "99999" ) | 124 | if ( processnum >= "1" && processnum <= "99999" ) |
123 | { | 125 | { |
124 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); | 126 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); |
125 | 127 | ||
126 | if ( procfile ) | 128 | if ( procfile ) |
127 | { | 129 | { |
128 | fscanf( procfile, | 130 | fscanf( procfile, |
129 | "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", | 131 | "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", |
130 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, | 132 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, |
131 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, | 133 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, |
132 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, | 134 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, |
133 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); | 135 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); |
134 | processnum = processnum.rightJustify( 5, ' ' ); | 136 | processnum = processnum.rightJustify( 5, ' ' ); |
135 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); | 137 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); |
136 | QString processstatus = QChar(state); | 138 | QString processstatus = QChar(state); |
137 | QString processtime = QString::number( ( utime + stime ) / 100 ); | 139 | QString processtime = QString::number( ( utime + stime ) / 100 ); |
138 | processtime = processtime.rightJustify( 9, ' ' ); | 140 | processtime = processtime.rightJustify( 9, ' ' ); |
139 | fclose( procfile ); | 141 | fclose( procfile ); |
140 | 142 | ||
141 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); | 143 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); |
@@ -150,36 +152,36 @@ void ProcessInfo::updateData() | |||
150 | } | 152 | } |
151 | 153 | ||
152 | delete proclist; | 154 | delete proclist; |
153 | delete procdir; | 155 | delete procdir; |
154 | } | 156 | } |
155 | 157 | ||
156 | void ProcessInfo::slotSendClicked() | 158 | void ProcessInfo::slotSendClicked() |
157 | { | 159 | { |
158 | QListViewItem *currprocess = ProcessView->currentItem(); | 160 | QListViewItem *currprocess = ProcessView->currentItem(); |
159 | if ( !currprocess ) | 161 | if ( !currprocess ) |
160 | { | 162 | { |
161 | return; | 163 | return; |
162 | } | 164 | } |
163 | 165 | ||
164 | QString capstr = tr( "Really want to send %1\nto this process?" ).arg( SignalCB->currentText() ); | 166 | QString capstr = tr( "Really want to send %1\nto this process?" ).arg( SignalCB->currentText() ); |
165 | 167 | ||
166 | 168 | ||
167 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, | 169 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, |
168 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 170 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
169 | { | 171 | { |
170 | currprocess = ProcessView->currentItem(); | 172 | currprocess = ProcessView->currentItem(); |
171 | if ( currprocess ) | 173 | if ( currprocess ) |
172 | { | 174 | { |
173 | QString sigstr = SignalCB->currentText(); | 175 | QString sigstr = SignalCB->currentText(); |
174 | sigstr.truncate(2); | 176 | sigstr.truncate(2); |
175 | int sigid = sigstr.toUInt(); | 177 | int sigid = sigstr.toUInt(); |
176 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); | 178 | kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); |
177 | } | 179 | } |
178 | } | 180 | } |
179 | 181 | ||
180 | } | 182 | } |
181 | 183 | ||
182 | void ProcessInfo::viewProcess( QListViewItem *process ) | 184 | void ProcessInfo::viewProcess( QListViewItem *process ) |
183 | { | 185 | { |
184 | QString pid= process->text( 0 ).stripWhiteSpace(); | 186 | QString pid= process->text( 0 ).stripWhiteSpace(); |
185 | QString command = process->text( 1 ); | 187 | QString command = process->text( 1 ); |
@@ -191,10 +193,10 @@ void ProcessInfo::viewProcess( QListViewItem *process ) | |||
191 | fgets( line, 81, statfile ); | 193 | fgets( line, 81, statfile ); |
192 | ProcessDtl->detailView->setText( line ); | 194 | ProcessDtl->detailView->setText( line ); |
193 | while ( fgets( line, 81, statfile ) ) | 195 | while ( fgets( line, 81, statfile ) ) |
194 | { | 196 | { |
195 | ProcessDtl->detailView->append( line ); | 197 | ProcessDtl->detailView->append( line ); |
196 | } | 198 | } |
197 | fclose( statfile ); | 199 | fclose( statfile ); |
198 | } | 200 | } |
199 | ProcessDtl->showMaximized(); | 201 | QPEApplication::showWidget( ProcessDtl ); |
200 | } | 202 | } |
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 | |||
@@ -3,436 +3,487 @@ | |||
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" | ||
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 | ||
28 | /** | 33 | /** |
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) |
33 | vm=viewmode; | 38 | { |
34 | QVBoxLayout *layout = new QVBoxLayout(this); | 39 | vm=viewmode; |
35 | myTabWidget=new QTabWidget(this,"User Tab Widget"); | 40 | QVBoxLayout *layout = new QVBoxLayout(this); |
36 | layout->addWidget(myTabWidget); | 41 | myTabWidget=new QTabWidget(this,"User Tab Widget"); |
37 | setupTab1(); | 42 | layout->addWidget(myTabWidget); |
38 | setupTab2(); | 43 | setupTab1(); |
39 | 44 | setupTab2(); | |
40 | accounts->groupStringList.sort(); | 45 | |
41 | // And also fill the listview & the combobox with all available groups. | 46 | accounts->groupStringList.sort(); |
42 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { | 47 | // And also fill the listview & the combobox with all available groups. |
43 | accounts->splitGroupEntry(*it); | 48 | for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) |
44 | if(accounts->gr_name.find(QRegExp("^#"),0)) {// Skip commented lines. | 49 | { |
45 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); | 50 | accounts->splitGroupEntry(*it); |
46 | groupComboBox->insertItem(accounts->gr_name); | 51 | if(accounts->gr_name.find(QRegExp("^#"),0)) |
47 | } | 52 | {// Skip commented lines. |
48 | } | 53 | new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); |
49 | showMaximized(); | 54 | groupComboBox->insertItem(accounts->gr_name); |
55 | } | ||
56 | } | ||
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() |
64 | QPixmap mypixmap; | 72 | { |
65 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); | 73 | QPixmap mypixmap; |
66 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 74 | QWidget *tabpage = new QWidget(myTabWidget,"page1"); |
67 | layout->setMargin(5); | 75 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
68 | 76 | layout->setMargin(5); | |
69 | // Picture | 77 | |
70 | picturePushButton = new QPushButton(tabpage,"Label"); | 78 | // Picture |
71 | picturePushButton->setMinimumSize(48,48); | 79 | picturePushButton = new QPushButton(tabpage,"Label"); |
72 | picturePushButton->setMaximumSize(48,48); | 80 | picturePushButton->setMinimumSize(48,48); |
73 | picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon"));// Load default usericon. | 81 | picturePushButton->setMaximumSize(48,48); |
74 | connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture()));// Clicking the picture should invoke pictureselector. | 82 | picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon"));// Load default usericon. |
75 | 83 | connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture()));// Clicking the picture should invoke pictureselector. | |
76 | // Login | 84 | |
77 | QLabel *loginLabel=new QLabel(tabpage,"Login: "); | 85 | // Login |
78 | loginLabel->setText("Login: "); | 86 | QLabel *loginLabel=new QLabel(tabpage,"Login: "); |
79 | loginLineEdit=new QLineEdit(tabpage,"Login: "); | 87 | loginLabel->setText("Login: "); |
80 | 88 | loginLineEdit=new QLineEdit(tabpage,"Login: "); | |
81 | // UID | 89 | |
82 | QLabel *uidLabel=new QLabel(tabpage,"uid: "); | 90 | // UID |
83 | uidLabel->setText("UserID: "); | 91 | QLabel *uidLabel=new QLabel(tabpage,"uid: "); |
84 | uidLineEdit=new QLineEdit(tabpage,"uid: "); | 92 | uidLabel->setText("UserID: "); |
85 | uidLineEdit->setEnabled(false); | 93 | uidLineEdit=new QLineEdit(tabpage,"uid: "); |
86 | 94 | uidLineEdit->setEnabled(false); | |
87 | // Username (gecos) | 95 | |
88 | QLabel *gecosLabel=new QLabel(tabpage,"gecos"); | 96 | // Username (gecos) |
89 | gecosLabel->setText("Username: "); | 97 | QLabel *gecosLabel=new QLabel(tabpage,"gecos"); |
90 | gecosLineEdit=new QLineEdit(tabpage,"gecos"); | 98 | gecosLabel->setText("Username: "); |
91 | 99 | gecosLineEdit=new QLineEdit(tabpage,"gecos"); | |
92 | // Password | 100 | |
93 | QLabel *passwordLabel=new QLabel(tabpage,"password"); | 101 | // Password |
94 | passwordLabel->setText("Password: "); | 102 | QLabel *passwordLabel=new QLabel(tabpage,"password"); |
95 | passwordLineEdit=new QLineEdit(tabpage,"password"); | 103 | passwordLabel->setText("Password: "); |
96 | passwordLineEdit->setEchoMode(QLineEdit::Password); | 104 | passwordLineEdit=new QLineEdit(tabpage,"password"); |
97 | 105 | passwordLineEdit->setEchoMode(QLineEdit::Password); | |
98 | // Shell | 106 | |
99 | QLabel *shellLabel=new QLabel(tabpage,"shell"); | 107 | // Shell |
100 | shellLabel->setText("Shell: "); | 108 | QLabel *shellLabel=new QLabel(tabpage,"shell"); |
101 | shellComboBox=new QComboBox(tabpage,"shell"); | 109 | shellLabel->setText("Shell: "); |
102 | shellComboBox->setEditable(true); | 110 | shellComboBox=new QComboBox(tabpage,"shell"); |
103 | shellComboBox->insertItem("/bin/sh"); | 111 | shellComboBox->setEditable(true); |
104 | shellComboBox->insertItem("/bin/ash"); | 112 | shellComboBox->insertItem("/bin/sh"); |
105 | shellComboBox->insertItem("/bin/false"); | 113 | shellComboBox->insertItem("/bin/ash"); |
106 | 114 | shellComboBox->insertItem("/bin/false"); | |
107 | // Primary Group | 115 | |
108 | QLabel *groupLabel=new QLabel(tabpage,"group"); | 116 | // Primary Group |
109 | groupLabel->setText("Primary group: "); | 117 | QLabel *groupLabel=new QLabel(tabpage,"group"); |
110 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); | 118 | groupLabel->setText("Primary group: "); |
111 | 119 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); | |
112 | if(vm==VIEWMODE_NEW) { | 120 | |
113 | // Copy /etc/skel | 121 | if(vm==VIEWMODE_NEW) |
114 | skelLabel=new QLabel(tabpage,"skel"); | 122 | { |
115 | skelLabel->setText("Copy /etc/skel: "); | 123 | // Copy /etc/skel |
116 | skelCheckBox=new QCheckBox(tabpage); | 124 | skelLabel=new QLabel(tabpage,"skel"); |
117 | skelCheckBox->setChecked(true); | 125 | skelLabel->setText("Copy /etc/skel: "); |
118 | } | 126 | skelCheckBox=new QCheckBox(tabpage); |
119 | 127 | skelCheckBox->setChecked(true); | |
120 | // Widget layout | 128 | } |
121 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); | 129 | |
122 | layout->addWidget(picturePushButton); | 130 | // Widget layout |
123 | layout->addSpacing(5); | 131 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); |
124 | layout->addLayout(hlayout); | 132 | layout->addWidget(picturePushButton); |
125 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); | 133 | layout->addSpacing(5); |
126 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); | 134 | layout->addLayout(hlayout); |
127 | // First column, labels | 135 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); |
128 | vlayout1->addWidget(loginLabel); | 136 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); |
129 | vlayout1->addSpacing(5); | 137 | // First column, labels |
130 | vlayout1->addWidget(uidLabel); | 138 | vlayout1->addWidget(loginLabel); |
131 | vlayout1->addSpacing(5); | 139 | vlayout1->addSpacing(5); |
132 | vlayout1->addWidget(gecosLabel); | 140 | vlayout1->addWidget(uidLabel); |
133 | vlayout1->addSpacing(5); | 141 | vlayout1->addSpacing(5); |
134 | vlayout1->addWidget(passwordLabel); | 142 | vlayout1->addWidget(gecosLabel); |
135 | vlayout1->addSpacing(5); | 143 | vlayout1->addSpacing(5); |
136 | vlayout1->addWidget(shellLabel); | 144 | vlayout1->addWidget(passwordLabel); |
137 | vlayout1->addSpacing(5); | 145 | vlayout1->addSpacing(5); |
138 | vlayout1->addWidget(groupLabel); | 146 | vlayout1->addWidget(shellLabel); |
139 | if(vm==VIEWMODE_NEW) { | 147 | vlayout1->addSpacing(5); |
140 | vlayout1->addSpacing(5); | 148 | vlayout1->addWidget(groupLabel); |
141 | vlayout1->addWidget(skelLabel); | 149 | if(vm==VIEWMODE_NEW) |
142 | } | 150 | { |
143 | // Second column, data | 151 | vlayout1->addSpacing(5); |
144 | vlayout2->addWidget(loginLineEdit); | 152 | vlayout1->addWidget(skelLabel); |
145 | vlayout2->addSpacing(5); | 153 | } |
146 | vlayout2->addWidget(uidLineEdit); | 154 | // Second column, data |
147 | vlayout2->addSpacing(5); | 155 | vlayout2->addWidget(loginLineEdit); |
148 | vlayout2->addWidget(gecosLineEdit); | 156 | vlayout2->addSpacing(5); |
149 | vlayout2->addSpacing(5); | 157 | vlayout2->addWidget(uidLineEdit); |
150 | vlayout2->addWidget(passwordLineEdit); | 158 | vlayout2->addSpacing(5); |
151 | vlayout2->addSpacing(5); | 159 | vlayout2->addWidget(gecosLineEdit); |
152 | vlayout2->addWidget(shellComboBox); | 160 | vlayout2->addSpacing(5); |
153 | vlayout2->addSpacing(5); | 161 | vlayout2->addWidget(passwordLineEdit); |
154 | vlayout2->addWidget(groupComboBox); | 162 | vlayout2->addSpacing(5); |
155 | if(vm==VIEWMODE_NEW) { | 163 | vlayout2->addWidget(shellComboBox); |
156 | vlayout2->addSpacing(5); | 164 | vlayout2->addSpacing(5); |
157 | vlayout2->addWidget(skelCheckBox); | 165 | vlayout2->addWidget(groupComboBox); |
158 | } | 166 | if(vm==VIEWMODE_NEW) |
159 | hlayout->addLayout(vlayout1); | 167 | { |
160 | hlayout->addLayout(vlayout2); | 168 | vlayout2->addSpacing(5); |
161 | 169 | vlayout2->addWidget(skelCheckBox); | |
162 | myTabWidget->addTab(tabpage,"User Info"); | 170 | } |
171 | hlayout->addLayout(vlayout1); | ||
172 | hlayout->addLayout(vlayout2); | ||
173 | |||
174 | myTabWidget->addTab(tabpage,"User Info"); | ||
163 | } | 175 | } |
164 | 176 | ||
165 | /** | 177 | /** |
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() |
170 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); | 182 | { |
171 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 183 | QWidget *tabpage = new QWidget(myTabWidget,"page2"); |
172 | layout->setMargin(5); | 184 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
173 | 185 | layout->setMargin(5); | |
174 | // Additional groups | 186 | |
175 | groupsListView=new QListView(tabpage,"groups"); | 187 | // Additional groups |
176 | groupsListView->addColumn("Additional groups"); | 188 | groupsListView=new QListView(tabpage,"groups"); |
177 | groupsListView->setColumnWidthMode(0,QListView::Maximum); | 189 | groupsListView->addColumn("Additional groups"); |
178 | groupsListView->setMultiSelection(false); | 190 | groupsListView->setColumnWidthMode(0,QListView::Maximum); |
179 | groupsListView->setAllColumnsShowFocus(false); | 191 | groupsListView->setMultiSelection(false); |
180 | 192 | groupsListView->setAllColumnsShowFocus(false); | |
181 | layout->addSpacing(5); | 193 | |
182 | // Grouplist | 194 | layout->addSpacing(5); |
183 | layout->addWidget(groupsListView); | 195 | // Grouplist |
184 | 196 | layout->addWidget(groupsListView); | |
185 | myTabWidget->addTab(tabpage,"User Groups"); | 197 | |
198 | myTabWidget->addTab(tabpage,"User Groups"); | ||
186 | } | 199 | } |
187 | 200 | ||
188 | /** | 201 | /** |
189 | * Static function that creates the userinfo dialog. | 202 | * Static function that creates the userinfo dialog. |
190 | * The user will be prompted to add a user. | 203 | * The user will be prompted to add a user. |
191 | * | 204 | * |
192 | * @param uid This is a suggested available UID. | 205 | * @param uid This is a suggested available UID. |
193 | * @param gid This is a suggested available GID. | 206 | * @param gid This is a suggested available GID. |
194 | * | 207 | * |
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) |
199 | QCheckListItem *temp; | 212 | { |
200 | QFile ozTest; | 213 | QCheckListItem *temp; |
201 | int oz=false; | 214 | QFile ozTest; |
202 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; | 215 | int oz=false; |
203 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. | 216 | if(ODevice::inst()->system()==System_OpenZaurus) oz=true; |
204 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); | 217 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. |
205 | adduserDialog->setCaption(tr("Add User")); | 218 | UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); |
206 | adduserDialog->userID=uid;// Set next available UID as default uid. | 219 | adduserDialog->setCaption(tr("Add User")); |
207 | adduserDialog->groupID=gid;// Set next available GID as default gid. | 220 | adduserDialog->userID=uid;// Set next available UID as default uid. |
208 | // Insert default group into groupComboBox | 221 | adduserDialog->groupID=gid;// Set next available GID as default gid. |
209 | adduserDialog->groupComboBox->insertItem("<create new group>",0); | 222 | // Insert default group into groupComboBox |
210 | adduserDialog->uidLineEdit->setText(QString::number(uid)); | 223 | adduserDialog->groupComboBox->insertItem("<create new group>",0); |
211 | // If we're running on OZ, add new users to some default groups. | 224 | adduserDialog->uidLineEdit->setText(QString::number(uid)); |
212 | if(oz) { | 225 | // If we're running on OZ, add new users to some default groups. |
213 | QListViewItemIterator iter( adduserDialog->groupsListView ); | 226 | if(oz) |
214 | for ( ; iter.current(); ++iter ) { | 227 | { |
215 | temp=(QCheckListItem*)iter.current(); | 228 | QListViewItemIterator iter( adduserDialog->groupsListView ); |
216 | if (temp->text()=="video") temp->setOn(true); | 229 | for ( ; iter.current(); ++iter ) |
217 | if (temp->text()=="audio") temp->setOn(true); | 230 | { |
218 | if (temp->text()=="time") temp->setOn(true); | 231 | temp=(QCheckListItem*)iter.current(); |
219 | if (temp->text()=="power") temp->setOn(true); | 232 | if (temp->text()=="video") temp->setOn(true); |
220 | if (temp->text()=="input") temp->setOn(true); | 233 | if (temp->text()=="audio") temp->setOn(true); |
221 | if (temp->text()=="sharp") temp->setOn(true); | 234 | if (temp->text()=="time") temp->setOn(true); |
222 | if (temp->text()=="tty") temp->setOn(true); | 235 | if (temp->text()=="power") temp->setOn(true); |
223 | } | 236 | if (temp->text()=="input") temp->setOn(true); |
224 | } | 237 | if (temp->text()=="sharp") temp->setOn(true); |
225 | // Show the dialog! | 238 | if (temp->text()=="tty") temp->setOn(true); |
226 | if(!(adduserDialog->exec())) return false; | 239 | } |
227 | if((adduserDialog->groupComboBox->currentItem()!=0)) { | 240 | } |
228 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); | 241 | // Show the dialog! |
229 | adduserDialog->groupID=accounts->gr_gid; | 242 | if(!(adduserDialog->exec())) return false; |
230 | qWarning(QString::number(accounts->gr_gid)); | 243 | if((adduserDialog->groupComboBox->currentItem()!=0)) |
231 | } | 244 | { |
232 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), | 245 | accounts->findGroup(adduserDialog->groupComboBox->currentText()); |
233 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), | 246 | adduserDialog->groupID=accounts->gr_gid; |
234 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { | 247 | qWarning(QString::number(accounts->gr_gid)); |
235 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); | 248 | } |
236 | return false; | 249 | if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), |
237 | } | 250 | adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), |
238 | 251 | QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) | |
239 | // Add User to additional groups. | 252 | { |
240 | QListViewItemIterator it( adduserDialog->groupsListView ); | 253 | QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); |
241 | for ( ; it.current(); ++it ) { | 254 | return false; |
242 | temp=(QCheckListItem*)it.current(); | 255 | } |
243 | if (temp->isOn() ) | 256 | |
244 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); | 257 | // Add User to additional groups. |
245 | } | 258 | QListViewItemIterator it( adduserDialog->groupsListView ); |
246 | // Copy image to pics/users/ | 259 | for ( ; it.current(); ++it ) |
247 | if(!(adduserDialog->userImage.isNull())) { | 260 | { |
248 | QDir d; | 261 | temp=(QCheckListItem*)it.current(); |
249 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 262 | if (temp->isOn() ) |
250 | d.mkdir("/opt/QtPalmtop/pics/users"); | 263 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); |
251 | } | 264 | } |
252 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 265 | // Copy image to pics/users/ |
253 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); | 266 | if(!(adduserDialog->userImage.isNull())) |
254 | adduserDialog->userImage.save(filename,"PNG"); | 267 | { |
255 | } | 268 | QDir d; |
256 | 269 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) | |
257 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? | 270 | { |
258 | accounts->findUser(adduserDialog->loginLineEdit->text()); | 271 | d.mkdir("/opt/QtPalmtop/pics/users"); |
259 | if(adduserDialog->skelCheckBox->isChecked()) { | 272 | } |
260 | QString command_cp; | 273 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
261 | QString command_chown; | 274 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); |
262 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); | 275 | adduserDialog->userImage.save(filename,"PNG"); |
263 | system(command_cp); | 276 | } |
264 | 277 | ||
265 | command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1());// Bug in busybox, ".*" includes parent directory, does this work as a workaround? | 278 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? |
266 | system(command_cp); | 279 | accounts->findUser(adduserDialog->loginLineEdit->text()); |
267 | 280 | if(adduserDialog->skelCheckBox->isChecked()) | |
268 | command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); | 281 | { |
269 | system(command_chown); | 282 | QString command_cp; |
270 | } | 283 | QString command_chown; |
271 | 284 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); | |
272 | return true; | 285 | system(command_cp); |
286 | |||
287 | command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1());// Bug in busybox, ".*" includes parent directory, does this work as a workaround? | ||
288 | system(command_cp); | ||
289 | |||
290 | command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); | ||
291 | system(command_chown); | ||
292 | } | ||
293 | |||
294 | return true; | ||
273 | } | 295 | } |
274 | 296 | ||
275 | /** | 297 | /** |
276 | * Deletes the user account. | 298 | * Deletes the user account. |
277 | * | 299 | * |
278 | * @param username User to be deleted. | 300 | * @param username User to be deleted. |
279 | * | 301 | * |
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))) |
286 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); | 308 | {// Does that user exist? |
287 | } | 309 | if(!(accounts->delUser(username))) |
288 | } else { | 310 | {// Delete the user. |
289 | QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); | 311 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); |
290 | return false; | 312 | } |
291 | } | 313 | } |
292 | return true; | 314 | else |
315 | { | ||
316 | QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); | ||
317 | return false; | ||
318 | } | ||
319 | return true; | ||
293 | } | 320 | } |
294 | 321 | ||
295 | /** | 322 | /** |
296 | * This displays a confirmation dialog wether a user should be deleted or not. | 323 | * This displays a confirmation dialog wether a user should be deleted or not. |
297 | * (And also deletes the account) | 324 | * (And also deletes the account) |
298 | * | 325 | * |
299 | * @param username User to be deleted. | 326 | * @param username User to be deleted. |
300 | * | 327 | * |
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) |
305 | int invalid_group=0; | 332 | { |
306 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. | 333 | int invalid_group=0; |
307 | UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT);// Create Dialog | 334 | // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. |
308 | edituserDialog->setCaption(tr("Edit User")); | 335 | UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT);// Create Dialog |
309 | accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. | 336 | edituserDialog->setCaption(tr("Edit User")); |
310 | if(!(accounts->findGroup(accounts->pw_gid))) {// Locate the user's primary group, and fill group variables in 'accounts' object. | 337 | accounts->findUser(username);// Locate user in database and fill variables in 'accounts' object. |
311 | invalid_group=1; | 338 | if(!(accounts->findGroup(accounts->pw_gid))) |
312 | } | 339 | {// Locate the user's primary group, and fill group variables in 'accounts' object. |
313 | // Fill widgets with userinfo. | 340 | invalid_group=1; |
314 | edituserDialog->loginLineEdit->setText(accounts->pw_name); | 341 | } |
315 | edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); | 342 | // Fill widgets with userinfo. |
316 | edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); | 343 | edituserDialog->loginLineEdit->setText(accounts->pw_name); |
317 | // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. | 344 | edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); |
318 | edituserDialog->passwordLineEdit->setText("........"); | 345 | edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); |
319 | // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. | 346 | // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. |
320 | if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { | 347 | edituserDialog->passwordLineEdit->setText("........"); |
321 | edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); | 348 | // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. |
322 | edituserDialog->shellComboBox->setCurrentItem(0); | 349 | if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") |
323 | } | 350 | { |
324 | // Select the primary group for this user. | 351 | edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); |
325 | for(int i=0;i<edituserDialog->groupComboBox->count();++i) { | 352 | edituserDialog->shellComboBox->setCurrentItem(0); |
326 | if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { | 353 | } |
327 | edituserDialog->groupComboBox->setCurrentItem(i); | 354 | // Select the primary group for this user. |
328 | break; | 355 | for(int i=0;i<edituserDialog->groupComboBox->count();++i) |
329 | } | 356 | { |
330 | } | 357 | if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) |
331 | if(invalid_group) { | 358 | { |
332 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); | 359 | edituserDialog->groupComboBox->setCurrentItem(i); |
333 | edituserDialog->groupComboBox->setCurrentItem(0); | 360 | break; |
334 | } | 361 | } |
335 | 362 | } | |
336 | // Select the groups in the listview, to which the user belongs. | 363 | if(invalid_group) |
337 | QCheckListItem *temp; | 364 | { |
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. | 365 | edituserDialog->groupComboBox->insertItem("<Undefined group>",0); |
339 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. | 366 | edituserDialog->groupComboBox->setCurrentItem(0); |
340 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 367 | } |
341 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 368 | |
342 | qWarning(*it); | 369 | // Select the groups in the listview, to which the user belongs. |
343 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 370 | QCheckListItem *temp; |
344 | for ( ; lvit.current(); ++lvit ) { | 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. |
345 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 372 | QRegExp userRegExp(QString("[:,]%1$").arg(username));// The end of line variant. |
346 | temp=(QCheckListItem*)lvit.current(); | 373 | QStringList tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
347 | temp->setOn(true);// If we find a line with that groupname, select it.; | 374 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) |
348 | } | 375 | {// Iterate over all of them. |
349 | } | 376 | qWarning(*it); |
350 | } | 377 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. |
351 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) | 378 | for ( ; lvit.current(); ++lvit ) |
352 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. | 379 | { |
353 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) {// Iterate over all of them. | 380 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) |
354 | qWarning(*it); | 381 | { |
355 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | 382 | temp=(QCheckListItem*)lvit.current(); |
356 | for ( ; lvit.current(); ++lvit ) { | 383 | temp->setOn(true);// If we find a line with that groupname, select it.; |
357 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { | 384 | } |
358 | temp=(QCheckListItem*)lvit.current(); | 385 | } |
359 | temp->setOn(true);// If we find a line with that groupname, select it.; | 386 | } |
360 | } | 387 | userRegExp=QRegExp(QString("[:,]%1,").arg(username));// And the other one. (not end of line.) |
361 | } | 388 | tempList=accounts->groupStringList.grep(userRegExp);// Find all entries in the group database, that the user is a member of. |
362 | } | 389 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) |
363 | 390 | {// Iterate over all of them. | |
364 | if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! | 391 | qWarning(*it); |
365 | 392 | QListViewItemIterator lvit( edituserDialog->groupsListView );// Compare to all groups. | |
366 | accounts->findUser(username);// Fill user variables in 'acccounts' object. | 393 | for ( ; lvit.current(); ++lvit ) |
367 | accounts->pw_name=edituserDialog->loginLineEdit->text(); | 394 | { |
368 | // Has the password been changed ? Make a new "crypt":ed password. | 395 | if(lvit.current()->text(0)==(*it).left((*it).find(":"))) |
369 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); | 396 | { |
370 | 397 | temp=(QCheckListItem*)lvit.current(); | |
371 | // Set all variables in accounts object, that will be used when calling 'updateUser()' | 398 | temp->setOn(true);// If we find a line with that groupname, select it.; |
372 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); | 399 | } |
373 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) {// Fill all group variables in 'accounts' object. | 400 | } |
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. | 401 | } |
375 | } | 402 | |
376 | accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); | 403 | if(!(edituserDialog->exec())) return false;// SHOW THE DIALOG! |
377 | accounts->pw_shell=edituserDialog->shellComboBox->currentText(); | 404 | |
378 | // Update userinfo, using the information stored in the user variables stored in the accounts object. | 405 | accounts->findUser(username);// Fill user variables in 'acccounts' object. |
379 | accounts->updateUser(username); | 406 | accounts->pw_name=edituserDialog->loginLineEdit->text(); |
380 | 407 | // Has the password been changed ? Make a new "crypt":ed password. | |
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.) | 408 | if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); |
382 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { | 409 | |
383 | accounts->delGroupMember((*it).left((*it).find(":")),username); | 410 | // Set all variables in accounts object, that will be used when calling 'updateUser()' |
384 | } | 411 | accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); |
385 | 412 | if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) | |
386 | // Add User to additional groups that he/she is a member of. | 413 | {// Fill all group variables in 'accounts' object. |
387 | QListViewItemIterator it( edituserDialog->groupsListView ); | 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. |
388 | for ( ; it.current(); ++it ) { | 415 | } |
389 | temp=(QCheckListItem*)it.current(); | 416 | accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); |
390 | if ( temp->isOn() ) | 417 | accounts->pw_shell=edituserDialog->shellComboBox->currentText(); |
391 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); | 418 | // Update userinfo, using the information stored in the user variables stored in the accounts object. |
392 | } | 419 | accounts->updateUser(username); |
393 | 420 | ||
394 | // Copy image to pics/users/ | 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.) |
395 | if(!(edituserDialog->userImage.isNull())) { | 422 | for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) |
396 | QDir d; | 423 | { |
397 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 424 | accounts->delGroupMember((*it).left((*it).find(":")),username); |
398 | d.mkdir("/opt/QtPalmtop/pics/users"); | 425 | } |
399 | } | 426 | |
400 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 427 | // Add User to additional groups that he/she is a member of. |
401 | // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); | 428 | QListViewItemIterator it( edituserDialog->groupsListView ); |
402 | edituserDialog->userImage.save(filename,"PNG"); | 429 | for ( ; it.current(); ++it ) |
403 | } | 430 | { |
404 | return true; | 431 | temp=(QCheckListItem*)it.current(); |
432 | if ( temp->isOn() ) | ||
433 | accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); | ||
434 | } | ||
435 | |||
436 | // Copy image to pics/users/ | ||
437 | if(!(edituserDialog->userImage.isNull())) | ||
438 | { | ||
439 | QDir d; | ||
440 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) | ||
441 | { | ||
442 | d.mkdir("/opt/QtPalmtop/pics/users"); | ||
443 | } | ||
444 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | ||
445 | // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); | ||
446 | edituserDialog->userImage.save(filename,"PNG"); | ||
447 | } | ||
448 | return true; | ||
405 | } | 449 | } |
406 | 450 | ||
407 | /** | 451 | /** |
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() |
412 | // Add checking... valid username? username taken? | 456 | { |
413 | if(loginLineEdit->text().isEmpty()) { | 457 | // Add checking... valid username? username taken? |
414 | QMessageBox::information(0,"Empty Login","Please enter a login."); | 458 | if(loginLineEdit->text().isEmpty()) |
415 | return; | 459 | { |
416 | } | 460 | QMessageBox::information(0,"Empty Login","Please enter a login."); |
417 | QDialog::accept(); | 461 | return; |
462 | } | ||
463 | QDialog::accept(); | ||
418 | } | 464 | } |
419 | 465 | ||
420 | /** | 466 | /** |
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() |
425 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); | 471 | { |
426 | if(!(filename.isEmpty())) { | 472 | QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); |
427 | userImage.reset(); | 473 | if(!(filename.isEmpty())) |
428 | if(!(userImage.load(filename))) { | 474 | { |
429 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); | 475 | userImage.reset(); |
430 | } else { | 476 | if(!(userImage.load(filename))) |
431 | // userImage=userImage.smoothScale(48,48); | 477 | { |
432 | QPixmap *picture; | 478 | QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); |
433 | picture=(QPixmap *)picturePushButton->pixmap(); | 479 | } |
434 | picture->convertFromImage(userImage,0); | 480 | else |
435 | picturePushButton->update(); | 481 | { |
436 | } | 482 | // userImage=userImage.smoothScale(48,48); |
437 | } | 483 | QPixmap *picture; |
484 | picture=(QPixmap *)picturePushButton->pixmap(); | ||
485 | picture->convertFromImage(userImage,0); | ||
486 | picturePushButton->update(); | ||
487 | } | ||
488 | } | ||
438 | } | 489 | } |