27 files changed, 107 insertions, 107 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index b39203b..8ae87fe 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -28,559 +28,559 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "appearance.h" | 30 | #include "appearance.h" |
31 | #include "editScheme.h" | 31 | #include "editScheme.h" |
32 | #include "stylelistitem.h" | 32 | #include "stylelistitem.h" |
33 | #include "decolistitem.h" | 33 | #include "decolistitem.h" |
34 | #include "colorlistitem.h" | 34 | #include "colorlistitem.h" |
35 | #include "exceptlistitem.h" | 35 | #include "exceptlistitem.h" |
36 | #include "sample.h" | 36 | #include "sample.h" |
37 | 37 | ||
38 | /* OPIE */ | 38 | /* OPIE */ |
39 | #include <opie2/odevice.h> | 39 | #include <opie2/odevice.h> |
40 | #include <opie2/ofiledialog.h> | 40 | #include <opie2/ofiledialog.h> |
41 | #include <opie2/otabwidget.h> | 41 | #include <opie2/otabwidget.h> |
42 | 42 | ||
43 | #include <qpe/config.h> | 43 | #include <qpe/config.h> |
44 | #include <qpe/global.h> | 44 | #include <qpe/global.h> |
45 | #include <qpe/qpeapplication.h> | 45 | #include <qpe/qpeapplication.h> |
46 | #include <qpe/qpemessagebox.h> | 46 | #include <qpe/qpemessagebox.h> |
47 | #include <qpe/qcopenvelope_qws.h> | 47 | #include <qpe/qcopenvelope_qws.h> |
48 | #include <qpe/qpestyle.h> | 48 | #include <qpe/qpestyle.h> |
49 | #include <qpe/lightstyle.h> | 49 | #include <qpe/lightstyle.h> |
50 | #include <qpe/styleinterface.h> | 50 | #include <qpe/styleinterface.h> |
51 | 51 | ||
52 | /* QT */ | 52 | /* QT */ |
53 | #include <qbuttongroup.h> | 53 | #include <qbuttongroup.h> |
54 | #include <qcheckbox.h> | 54 | #include <qcheckbox.h> |
55 | #include <qcombobox.h> | 55 | #include <qcombobox.h> |
56 | #include <qdialog.h> | 56 | #include <qdialog.h> |
57 | #include <qdir.h> | 57 | #include <qdir.h> |
58 | #include <qlabel.h> | 58 | #include <qlabel.h> |
59 | #include <qlayout.h> | 59 | #include <qlayout.h> |
60 | #include <qlineedit.h> | 60 | #include <qlineedit.h> |
61 | #include <qlistbox.h> | 61 | #include <qlistbox.h> |
62 | #include <qmessagebox.h> | 62 | #include <qmessagebox.h> |
63 | #include <qpushbutton.h> | 63 | #include <qpushbutton.h> |
64 | #include <qradiobutton.h> | 64 | #include <qradiobutton.h> |
65 | #if QT_VERSION >= 300 | 65 | #if QT_VERSION >= 300 |
66 | #include <qstylefactory.h> | 66 | #include <qstylefactory.h> |
67 | #endif | 67 | #endif |
68 | #include <qtoolbutton.h> | 68 | #include <qtoolbutton.h> |
69 | #include <qwindowsstyle.h> | 69 | #include <qwindowsstyle.h> |
70 | #include <qlistview.h> | 70 | #include <qlistview.h> |
71 | #include <qheader.h> | 71 | #include <qheader.h> |
72 | #include <qvbox.h> | 72 | #include <qvbox.h> |
73 | #include <qwhatsthis.h> | 73 | #include <qwhatsthis.h> |
74 | 74 | ||
75 | using namespace Opie; | 75 | using namespace Opie; |
76 | 76 | ||
77 | 77 | ||
78 | class DefaultWindowDecoration : public WindowDecorationInterface | 78 | class DefaultWindowDecoration : public WindowDecorationInterface |
79 | { | 79 | { |
80 | public: | 80 | public: |
81 | DefaultWindowDecoration() : ref(0) {} | 81 | DefaultWindowDecoration() : ref(0) {} |
82 | QString name() const | 82 | QString name() const |
83 | { | 83 | { |
84 | return "Default"; | 84 | return "Default"; |
85 | } | 85 | } |
86 | QPixmap icon() const | 86 | QPixmap icon() const |
87 | { | 87 | { |
88 | return QPixmap(); | 88 | return QPixmap(); |
89 | } | 89 | } |
90 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 90 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
91 | { | 91 | { |
92 | *iface = 0; | 92 | *iface = 0; |
93 | if ( uuid == IID_QUnknown ) | 93 | if ( uuid == IID_QUnknown ) |
94 | *iface = this; | 94 | *iface = this; |
95 | else if ( uuid == IID_WindowDecoration ) | 95 | else if ( uuid == IID_WindowDecoration ) |
96 | *iface = this; | 96 | *iface = this; |
97 | 97 | ||
98 | if ( *iface ) | 98 | if ( *iface ) |
99 | (*iface)->addRef(); | 99 | (*iface)->addRef(); |
100 | return QS_OK; | 100 | return QS_OK; |
101 | } | 101 | } |
102 | Q_REFCOUNT | 102 | Q_REFCOUNT |
103 | 103 | ||
104 | private: | 104 | private: |
105 | ulong ref; | 105 | ulong ref; |
106 | }; | 106 | }; |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | 113 | ||
114 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) | 114 | QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) |
115 | { | 115 | { |
116 | QWidget* tab = new QWidget( parent, "StyleTab" ); | 116 | QWidget* tab = new QWidget( parent, "StyleTab" ); |
117 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | 117 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
118 | 118 | ||
119 | m_style_list = new QListBox( tab, "m_style_list" ); | 119 | m_style_list = new QListBox( tab, "m_style_list" ); |
120 | vertLayout->addWidget( m_style_list ); | 120 | vertLayout->addWidget( m_style_list ); |
121 | 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 | 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 | 122 | ||
123 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); | 123 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); |
124 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); | 124 | connect ( m_style_settings, SIGNAL( clicked()), this, SLOT( styleSettingsClicked())); |
125 | vertLayout-> addWidget ( m_style_settings ); | 125 | vertLayout-> addWidget ( m_style_settings ); |
126 | 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 | 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 | 127 | ||
128 | QString s = cfg. readEntry ( "Style", "Light" ); | 128 | QString s = cfg. readEntry ( "Style", "Light" ); |
129 | 129 | ||
130 | 130 | ||
131 | #if QT_VERSION >= 300 | 131 | #if QT_VERSION >= 300 |
132 | m_style_list->insertStringList(QStyleFactory::styles()); | 132 | m_style_list->insertStringList(QStyleFactory::styles()); |
133 | #else | 133 | #else |
134 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); | 134 | m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); |
135 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); | 135 | m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); |
136 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); | 136 | m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); |
137 | #endif | 137 | #endif |
138 | 138 | ||
139 | { | 139 | { |
140 | QString path = QPEApplication::qpeDir ( ); | 140 | QString path = QPEApplication::qpeDir ( ); |
141 | path.append( "/plugins/styles/" ); | 141 | path.append( "/plugins/styles/" ); |
142 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 142 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
143 | 143 | ||
144 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | 144 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
145 | { | 145 | { |
146 | QString libstr = path; | 146 | QString libstr = path; |
147 | libstr.append( "/" ); | 147 | libstr.append( "/" ); |
148 | libstr.append( *it ); | 148 | libstr.append( *it ); |
149 | QLibrary *lib = new QLibrary ( libstr ); | 149 | QLibrary *lib = new QLibrary ( libstr ); |
150 | StyleInterface *iface; | 150 | StyleInterface *iface; |
151 | 151 | ||
152 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) | 152 | if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) |
153 | { | 153 | { |
154 | StyleListItem *slit = new StyleListItem ( lib, iface ); | 154 | StyleListItem *slit = new StyleListItem ( lib, iface ); |
155 | m_style_list-> insertItem ( slit ); | 155 | m_style_list-> insertItem ( slit ); |
156 | 156 | ||
157 | if ( slit-> key ( ) == s ) | 157 | if ( slit-> key ( ) == s ) |
158 | m_style_list-> setCurrentItem ( slit ); | 158 | m_style_list-> setCurrentItem ( slit ); |
159 | } | 159 | } |
160 | else | 160 | else |
161 | delete lib; | 161 | delete lib; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | m_original_style = m_style_list-> currentItem ( ); | 165 | m_original_style = m_style_list-> currentItem ( ); |
166 | styleClicked ( m_original_style ); | 166 | styleClicked ( m_original_style ); |
167 | 167 | ||
168 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); | 168 | connect( m_style_list, SIGNAL( highlighted(int) ), this, SLOT( styleClicked(int) ) ); |
169 | 169 | ||
170 | return tab; | 170 | return tab; |
171 | } | 171 | } |
172 | 172 | ||
173 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) | 173 | QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) |
174 | { | 174 | { |
175 | QWidget* tab = new QWidget( parent, "DecoTab" ); | 175 | QWidget* tab = new QWidget( parent, "DecoTab" ); |
176 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); | 176 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); |
177 | 177 | ||
178 | m_deco_list = new QListBox( tab, "m_deco_list" ); | 178 | m_deco_list = new QListBox( tab, "m_deco_list" ); |
179 | vertLayout->addWidget( m_deco_list ); | 179 | vertLayout->addWidget( m_deco_list ); |
180 | 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." ) ); | 180 | 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 | 181 | ||
182 | QString s = cfg. readEntry ( "Decoration", "libflat.so" ); | 182 | QString s = cfg. readEntry ( "Decoration", "libflat.so" ); |
183 | 183 | ||
184 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); | 184 | m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); |
185 | 185 | ||
186 | { | 186 | { |
187 | QString path = QPEApplication::qpeDir(); | 187 | QString path = QPEApplication::qpeDir(); |
188 | path.append( "/plugins/decorations/" ); | 188 | path.append( "/plugins/decorations/" ); |
189 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 189 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
190 | 190 | ||
191 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | 191 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
192 | { | 192 | { |
193 | QString libstr = path; | 193 | QString libstr = path; |
194 | libstr.append( "/" ); | 194 | libstr.append( "/" ); |
195 | libstr.append( *it ); | 195 | libstr.append( *it ); |
196 | QLibrary *lib = new QLibrary ( libstr ); | 196 | QLibrary *lib = new QLibrary ( libstr ); |
197 | WindowDecorationInterface *iface; | 197 | WindowDecorationInterface *iface; |
198 | 198 | ||
199 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) | 199 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) |
200 | { | 200 | { |
201 | DecoListItem *dlit = new DecoListItem ( lib, iface ); | 201 | DecoListItem *dlit = new DecoListItem ( lib, iface ); |
202 | m_deco_list-> insertItem ( dlit ); | 202 | m_deco_list-> insertItem ( dlit ); |
203 | 203 | ||
204 | if ( dlit-> key ( ) == s ) | 204 | if ( dlit-> key ( ) == s ) |
205 | m_deco_list-> setCurrentItem ( dlit ); | 205 | m_deco_list-> setCurrentItem ( dlit ); |
206 | } | 206 | } |
207 | else | 207 | else |
208 | delete lib; | 208 | delete lib; |
209 | } | 209 | } |
210 | } | 210 | } |
211 | 211 | ||
212 | m_original_deco = m_deco_list-> currentItem ( ); | 212 | m_original_deco = m_deco_list-> currentItem ( ); |
213 | if ( m_deco_list-> currentItem ( ) < 0 ) | 213 | if ( m_deco_list-> currentItem ( ) < 0 ) |
214 | m_deco_list-> setCurrentItem ( 0 ); | 214 | m_deco_list-> setCurrentItem ( 0 ); |
215 | decoClicked ( m_original_deco ); | 215 | decoClicked ( m_original_deco ); |
216 | 216 | ||
217 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); | 217 | connect( m_deco_list, SIGNAL( highlighted(int) ), this, SLOT( decoClicked(int) ) ); |
218 | 218 | ||
219 | return tab; | 219 | return tab; |
220 | } | 220 | } |
221 | 221 | ||
222 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) | 222 | QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) |
223 | { | 223 | { |
224 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); | 224 | QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); |
225 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); | 225 | QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); |
226 | int size = cfg. readNumEntry ( "FontSize", 10 ); | 226 | int size = cfg. readNumEntry ( "FontSize", 10 ); |
227 | 227 | ||
228 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); | 228 | m_fontselect = new OFontSelector ( false, parent, "FontTab" ); |
229 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); | 229 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); |
230 | QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); | 230 | QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); |
231 | 231 | ||
232 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), | 232 | connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), |
233 | this, SLOT( fontClicked ( const QFont & ))); | 233 | this, SLOT( fontClicked(const QFont&))); |
234 | 234 | ||
235 | return m_fontselect; | 235 | return m_fontselect; |
236 | } | 236 | } |
237 | 237 | ||
238 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) | 238 | QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) |
239 | { | 239 | { |
240 | QWidget *tab = new QWidget( parent, "ColorTab" ); | 240 | QWidget *tab = new QWidget( parent, "ColorTab" ); |
241 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); | 241 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); |
242 | gridLayout->setRowStretch ( 3, 10 ); | 242 | gridLayout->setRowStretch ( 3, 10 ); |
243 | 243 | ||
244 | m_color_list = new QListBox ( tab ); | 244 | m_color_list = new QListBox ( tab ); |
245 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); | 245 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); |
246 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); | 246 | connect( m_color_list, SIGNAL( highlighted(int) ), this, SLOT( colorClicked(int) ) ); |
247 | 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." ) ); | 247 | 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 | 248 | ||
249 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); | 249 | m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); |
250 | 250 | ||
251 | QString path = QPEApplication::qpeDir ( ); | 251 | QString path = QPEApplication::qpeDir ( ); |
252 | path.append( "/etc/colors/" ); | 252 | path.append( "/etc/colors/" ); |
253 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | 253 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); |
254 | 254 | ||
255 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | 255 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
256 | { | 256 | { |
257 | QString name = (*it). left ((*it). find ( ".scheme" )); | 257 | QString name = (*it). left ((*it). find ( ".scheme" )); |
258 | QString pathstr = path; | 258 | QString pathstr = path; |
259 | pathstr.append( *it ); | 259 | pathstr.append( *it ); |
260 | Config config ( pathstr, Config::File ); | 260 | Config config ( pathstr, Config::File ); |
261 | config. setGroup ( "Colors" ); | 261 | config. setGroup ( "Colors" ); |
262 | 262 | ||
263 | m_color_list-> insertItem ( new ColorListItem ( name, config )); | 263 | m_color_list-> insertItem ( new ColorListItem ( name, config )); |
264 | } | 264 | } |
265 | 265 | ||
266 | m_color_list-> setCurrentItem ( 0 ); | 266 | m_color_list-> setCurrentItem ( 0 ); |
267 | 267 | ||
268 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); | 268 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); |
269 | tempButton->setText( tr( "Edit..." ) ); | 269 | tempButton->setText( tr( "Edit..." ) ); |
270 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); | 270 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); |
271 | gridLayout->addWidget( tempButton, 0, 1 ); | 271 | gridLayout->addWidget( tempButton, 0, 1 ); |
272 | QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); | 272 | QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); |
273 | 273 | ||
274 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); | 274 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); |
275 | tempButton->setText( tr( "Delete" ) ); | 275 | tempButton->setText( tr( "Delete" ) ); |
276 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); | 276 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); |
277 | gridLayout->addWidget( tempButton, 1, 1 ); | 277 | gridLayout->addWidget( tempButton, 1, 1 ); |
278 | QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); | 278 | QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); |
279 | 279 | ||
280 | tempButton = new QPushButton( tab, "saveSchemeButton" ); | 280 | tempButton = new QPushButton( tab, "saveSchemeButton" ); |
281 | tempButton->setText( tr( "Save" ) ); | 281 | tempButton->setText( tr( "Save" ) ); |
282 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); | 282 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); |
283 | gridLayout->addWidget( tempButton, 2, 1 ); | 283 | gridLayout->addWidget( tempButton, 2, 1 ); |
284 | QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); | 284 | QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); |
285 | 285 | ||
286 | return tab; | 286 | return tab; |
287 | } | 287 | } |
288 | 288 | ||
289 | QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) | 289 | QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) |
290 | { | 290 | { |
291 | QWidget *tab = new QWidget ( parent ); | 291 | QWidget *tab = new QWidget ( parent ); |
292 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); | 292 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); |
293 | 293 | ||
294 | QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); | 294 | QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); |
295 | 295 | ||
296 | m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); | 296 | m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); |
297 | m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); | 297 | m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); |
298 | lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); | 298 | lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); |
299 | QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) ); | 299 | QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) ); |
300 | 300 | ||
301 | QLabel *l = new QLabel ( tab ); | 301 | QLabel *l = new QLabel ( tab ); |
302 | l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); | 302 | l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); |
303 | lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); | 303 | lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); |
304 | 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." ) ); | 304 | 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 | 305 | ||
306 | m_except = new QListView ( tab ); | 306 | m_except = new QListView ( tab ); |
307 | m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 ); | 307 | m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 ); |
308 | m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 ); | 308 | m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 ); |
309 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 ); | 309 | m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 ); |
310 | m_except-> addColumn ( tr( "Binary file(s)" )); | 310 | m_except-> addColumn ( tr( "Binary file(s)" )); |
311 | m_except-> setColumnAlignment ( 0, AlignCenter ); | 311 | m_except-> setColumnAlignment ( 0, AlignCenter ); |
312 | m_except-> setColumnAlignment ( 1, AlignCenter ); | 312 | m_except-> setColumnAlignment ( 1, AlignCenter ); |
313 | m_except-> setColumnAlignment ( 2, AlignCenter ); | 313 | m_except-> setColumnAlignment ( 2, AlignCenter ); |
314 | m_except-> setAllColumnsShowFocus ( true ); | 314 | m_except-> setAllColumnsShowFocus ( true ); |
315 | m_except-> setMinimumHeight ( 30 ); | 315 | m_except-> setMinimumHeight ( 30 ); |
316 | m_except-> header ( )-> setClickEnabled ( false ); | 316 | m_except-> header ( )-> setClickEnabled ( false ); |
317 | m_except-> header ( )-> setResizeEnabled ( false ); | 317 | m_except-> header ( )-> setResizeEnabled ( false ); |
318 | m_except-> header ( )-> setMovingEnabled ( false ); | 318 | m_except-> header ( )-> setMovingEnabled ( false ); |
319 | m_except-> setSorting ( -1 ); | 319 | m_except-> setSorting ( -1 ); |
320 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); | 320 | lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); |
321 | 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." ) ); | 321 | 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 | 322 | ||
323 | connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); | 323 | connect ( m_except, SIGNAL( clicked(QListViewItem*,const QPoint&,int)), this, SLOT( clickedExcept(QListViewItem*,const QPoint&,int))); |
324 | 324 | ||
325 | QToolButton *tb = new QToolButton ( tab ); | 325 | QToolButton *tb = new QToolButton ( tab ); |
326 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); | 326 | tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); |
327 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 327 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
328 | lay-> addWidget ( tb, 2, 1 ); | 328 | lay-> addWidget ( tb, 2, 1 ); |
329 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); | 329 | connect ( tb, SIGNAL( clicked()), this, SLOT( addExcept())); |
330 | QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); | 330 | QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); |
331 | 331 | ||
332 | tb = new QToolButton ( tab ); | 332 | tb = new QToolButton ( tab ); |
333 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); | 333 | tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); |
334 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 334 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
335 | lay-> addWidget ( tb, 3, 1 ); | 335 | lay-> addWidget ( tb, 3, 1 ); |
336 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); | 336 | connect ( tb, SIGNAL( clicked()), this, SLOT( delExcept())); |
337 | QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); | 337 | QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); |
338 | 338 | ||
339 | tb = new QToolButton ( tab ); | 339 | tb = new QToolButton ( tab ); |
340 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); | 340 | tb-> setIconSet ( Resource::loadIconSet ( "up" )); |
341 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 341 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
342 | lay-> addWidget ( tb, 4, 1 ); | 342 | lay-> addWidget ( tb, 4, 1 ); |
343 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); | 343 | connect ( tb, SIGNAL( clicked()), this, SLOT( upExcept())); |
344 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); | 344 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); |
345 | 345 | ||
346 | tb = new QToolButton ( tab ); | 346 | tb = new QToolButton ( tab ); |
347 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); | 347 | tb-> setIconSet ( Resource::loadIconSet ( "down" )); |
348 | tb-> setFocusPolicy ( QWidget::StrongFocus ); | 348 | tb-> setFocusPolicy ( QWidget::StrongFocus ); |
349 | lay-> addWidget ( tb, 5, 1 ); | 349 | lay-> addWidget ( tb, 5, 1 ); |
350 | connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); | 350 | connect ( tb, SIGNAL( clicked()), this, SLOT( downExcept())); |
351 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); | 351 | QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); |
352 | 352 | ||
353 | lay-> setRowStretch ( 6, 10 ); | 353 | lay-> setRowStretch ( 6, 10 ); |
354 | lay-> setColStretch ( 0, 10 ); | 354 | lay-> setColStretch ( 0, 10 ); |
355 | 355 | ||
356 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); | 356 | QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); |
357 | QListViewItem *lvit = 0; | 357 | QListViewItem *lvit = 0; |
358 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | 358 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) |
359 | { | 359 | { |
360 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 360 | int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
361 | 361 | ||
362 | lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); | 362 | lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | vertLayout-> addSpacing ( 3 ); | 366 | vertLayout-> addSpacing ( 3 ); |
367 | QFrame *f = new QFrame ( tab ); | 367 | QFrame *f = new QFrame ( tab ); |
368 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); | 368 | f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); |
369 | vertLayout-> addWidget ( f ); | 369 | vertLayout-> addWidget ( f ); |
370 | vertLayout-> addSpacing ( 3 ); | 370 | vertLayout-> addSpacing ( 3 ); |
371 | 371 | ||
372 | 372 | ||
373 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); | 373 | QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); |
374 | 374 | ||
375 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; | 375 | int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; |
376 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); | 376 | bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); |
377 | 377 | ||
378 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); | 378 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); |
379 | gridLayout-> addWidget ( label, 0, 0 ); | 379 | gridLayout-> addWidget ( label, 0, 0 ); |
380 | 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" ) ); | 380 | 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 | 381 | ||
382 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); | 382 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); |
383 | btngrp-> hide ( ); | 383 | btngrp-> hide ( ); |
384 | btngrp-> setExclusive ( true ); | 384 | btngrp-> setExclusive ( true ); |
385 | 385 | ||
386 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); | 386 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); |
387 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); | 387 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); |
388 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); | 388 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); |
389 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); | 389 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); |
390 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); | 390 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); |
391 | m_tabstyle_list-> setCurrentItem ( style ); | 391 | m_tabstyle_list-> setCurrentItem ( style ); |
392 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); | 392 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); |
393 | 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" ) ); | 393 | 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 | 394 | ||
395 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); | 395 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); |
396 | btngrp-> insert ( m_tabstyle_top ); | 396 | btngrp-> insert ( m_tabstyle_top ); |
397 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); | 397 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); |
398 | QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); | 398 | QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); |
399 | 399 | ||
400 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); | 400 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); |
401 | btngrp-> insert ( m_tabstyle_bottom ); | 401 | btngrp-> insert ( m_tabstyle_bottom ); |
402 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); | 402 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); |
403 | QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); | 403 | QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); |
404 | 404 | ||
405 | m_tabstyle_top-> setChecked ( tabtop ); | 405 | m_tabstyle_top-> setChecked ( tabtop ); |
406 | m_tabstyle_bottom-> setChecked ( !tabtop ); | 406 | m_tabstyle_bottom-> setChecked ( !tabtop ); |
407 | 407 | ||
408 | m_original_tabstyle = style; | 408 | m_original_tabstyle = style; |
409 | m_original_tabpos = tabtop; | 409 | m_original_tabpos = tabtop; |
410 | 410 | ||
411 | vertLayout-> addSpacing ( 3 ); | 411 | vertLayout-> addSpacing ( 3 ); |
412 | QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); | 412 | QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); |
413 | 413 | ||
414 | QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); | 414 | QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); |
415 | m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); | 415 | m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); |
416 | QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); | 416 | QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); |
417 | m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); | 417 | m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); |
418 | QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); | 418 | QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); |
419 | QPixmap ccw1; | 419 | QPixmap ccw1; |
420 | m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); | 420 | m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); |
421 | QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); | 421 | QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); |
422 | QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); | 422 | QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); |
423 | 423 | ||
424 | rotbtngrp-> hide ( ); | 424 | rotbtngrp-> hide ( ); |
425 | rotbtngrp-> setExclusive ( true ); | 425 | rotbtngrp-> setExclusive ( true ); |
426 | rotbtngrp-> insert ( m_rotdir_cw ); | 426 | rotbtngrp-> insert ( m_rotdir_cw ); |
427 | rotbtngrp-> insert ( m_rotdir_ccw ); | 427 | rotbtngrp-> insert ( m_rotdir_ccw ); |
428 | rotbtngrp-> insert ( m_rotdir_flip ); | 428 | rotbtngrp-> insert ( m_rotdir_flip ); |
429 | 429 | ||
430 | ccw1. convertFromImage( ccwImage ); | 430 | ccw1. convertFromImage( ccwImage ); |
431 | m_rotdir_cw-> setPixmap( cw1 ); | 431 | m_rotdir_cw-> setPixmap( cw1 ); |
432 | m_rotdir_ccw-> setPixmap( ccw1 ); | 432 | m_rotdir_ccw-> setPixmap( ccw1 ); |
433 | m_rotdir_flip-> setPixmap( flip1 ); | 433 | m_rotdir_flip-> setPixmap( flip1 ); |
434 | 434 | ||
435 | rotLay-> addWidget ( rotlabel, 0 ); | 435 | rotLay-> addWidget ( rotlabel, 0 ); |
436 | rotLay-> addWidget ( m_rotdir_cw, 0 ); | 436 | rotLay-> addWidget ( m_rotdir_cw, 0 ); |
437 | rotLay-> addWidget ( m_rotdir_ccw, 0 ); | 437 | rotLay-> addWidget ( m_rotdir_ccw, 0 ); |
438 | rotLay-> addWidget ( m_rotdir_flip, 0 ); | 438 | rotLay-> addWidget ( m_rotdir_flip, 0 ); |
439 | 439 | ||
440 | int rotDirection = cfg.readNumEntry( "rotatedir" ); | 440 | int rotDirection = cfg.readNumEntry( "rotatedir" ); |
441 | ODirection rot = CW; | 441 | ODirection rot = CW; |
442 | 442 | ||
443 | if (rotDirection == -1) | 443 | if (rotDirection == -1) |
444 | { | 444 | { |
445 | rot = ODevice::inst ( )-> direction ( ); | 445 | rot = ODevice::inst ( )-> direction ( ); |
446 | } | 446 | } |
447 | else | 447 | else |
448 | { | 448 | { |
449 | rot = (ODirection)rotDirection; | 449 | rot = (ODirection)rotDirection; |
450 | } | 450 | } |
451 | 451 | ||
452 | m_rotdir_cw-> setChecked ( rot == CW ); | 452 | m_rotdir_cw-> setChecked ( rot == CW ); |
453 | m_rotdir_ccw-> setChecked ( rot == CCW ); | 453 | m_rotdir_ccw-> setChecked ( rot == CCW ); |
454 | m_rotdir_flip-> setChecked ( rot == Flip ); | 454 | m_rotdir_flip-> setChecked ( rot == Flip ); |
455 | 455 | ||
456 | return tab; | 456 | return tab; |
457 | } | 457 | } |
458 | 458 | ||
459 | 459 | ||
460 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) | 460 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) |
461 | : QDialog ( parent, name, true, WStyle_ContextHelp ) | 461 | : QDialog ( parent, name, true, WStyle_ContextHelp ) |
462 | { | 462 | { |
463 | setCaption( tr( "Appearance Settings" ) ); | 463 | setCaption( tr( "Appearance Settings" ) ); |
464 | 464 | ||
465 | Config config( "qpe" ); | 465 | Config config( "qpe" ); |
466 | config.setGroup( "Appearance" ); | 466 | config.setGroup( "Appearance" ); |
467 | 467 | ||
468 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); | 468 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); |
469 | 469 | ||
470 | m_sample = new SampleWindow ( this ); | 470 | m_sample = new SampleWindow ( this ); |
471 | 471 | ||
472 | m_sample-> setDecoration ( new DefaultWindowDecoration ( ) ); | 472 | m_sample-> setDecoration ( new DefaultWindowDecoration ( ) ); |
473 | QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); | 473 | QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); |
474 | 474 | ||
475 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 475 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
476 | QWidget *styletab; | 476 | QWidget *styletab; |
477 | 477 | ||
478 | m_color_list = 0; | 478 | m_color_list = 0; |
479 | 479 | ||
480 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); | 480 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); |
481 | tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); | 481 | tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); |
482 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); | 482 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); |
483 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); | 483 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); |
484 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); | 484 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); |
485 | 485 | ||
486 | top-> addWidget ( tw, 10 ); | 486 | top-> addWidget ( tw, 10 ); |
487 | top-> addWidget ( m_sample, 1 ); | 487 | top-> addWidget ( m_sample, 1 ); |
488 | 488 | ||
489 | tw-> setCurrentTab ( styletab ); | 489 | tw-> setCurrentTab ( styletab ); |
490 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); | 490 | connect ( tw, SIGNAL( currentChanged(QWidget*)), this, SLOT( tabChanged(QWidget*))); |
491 | 491 | ||
492 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; | 492 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; |
493 | } | 493 | } |
494 | 494 | ||
495 | Appearance::~Appearance() | 495 | Appearance::~Appearance() |
496 | {} | 496 | {} |
497 | 497 | ||
498 | void Appearance::tabChanged ( QWidget *w ) | 498 | void Appearance::tabChanged ( QWidget *w ) |
499 | { | 499 | { |
500 | if ( w == m_advtab ) | 500 | if ( w == m_advtab ) |
501 | { | 501 | { |
502 | m_sample-> hide ( ); | 502 | m_sample-> hide ( ); |
503 | updateGeometry ( ); // shouldn't be necessary ... | 503 | updateGeometry ( ); // shouldn't be necessary ... |
504 | } | 504 | } |
505 | else | 505 | else |
506 | m_sample-> show ( ); | 506 | m_sample-> show ( ); |
507 | } | 507 | } |
508 | 508 | ||
509 | void Appearance::accept ( ) | 509 | void Appearance::accept ( ) |
510 | { | 510 | { |
511 | bool newtabpos = m_tabstyle_top-> isChecked ( ); | 511 | bool newtabpos = m_tabstyle_top-> isChecked ( ); |
512 | int newtabstyle = m_tabstyle_list-> currentItem ( ); | 512 | int newtabstyle = m_tabstyle_list-> currentItem ( ); |
513 | 513 | ||
514 | Config config ( "qpe" ); | 514 | Config config ( "qpe" ); |
515 | config. setGroup ( "Appearance" ); | 515 | config. setGroup ( "Appearance" ); |
516 | 516 | ||
517 | if ( m_style_changed ) | 517 | if ( m_style_changed ) |
518 | { | 518 | { |
519 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 519 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
520 | if ( item ) | 520 | if ( item ) |
521 | config.writeEntry( "Style", item-> key ( )); | 521 | config.writeEntry( "Style", item-> key ( )); |
522 | } | 522 | } |
523 | 523 | ||
524 | if ( m_deco_changed ) | 524 | if ( m_deco_changed ) |
525 | { | 525 | { |
526 | DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); | 526 | DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); |
527 | if ( item ) | 527 | if ( item ) |
528 | config.writeEntry( "Decoration", item-> key ( )); | 528 | config.writeEntry( "Decoration", item-> key ( )); |
529 | } | 529 | } |
530 | 530 | ||
531 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) | 531 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) |
532 | { | 532 | { |
533 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); | 533 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); |
534 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); | 534 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); |
535 | } | 535 | } |
536 | 536 | ||
537 | if ( m_font_changed ) | 537 | if ( m_font_changed ) |
538 | { | 538 | { |
539 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); | 539 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); |
540 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); | 540 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); |
541 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); | 541 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); |
542 | } | 542 | } |
543 | 543 | ||
544 | 544 | ||
545 | if ( m_color_changed ) | 545 | if ( m_color_changed ) |
546 | { | 546 | { |
547 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 547 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
548 | 548 | ||
549 | if ( item ) | 549 | if ( item ) |
550 | item-> save ( config ); | 550 | item-> save ( config ); |
551 | } | 551 | } |
552 | 552 | ||
553 | ODirection rot; | 553 | ODirection rot; |
554 | if (m_rotdir_ccw-> isChecked ( )) | 554 | if (m_rotdir_ccw-> isChecked ( )) |
555 | { | 555 | { |
556 | rot = CCW; | 556 | rot = CCW; |
557 | } | 557 | } |
558 | else if (m_rotdir_cw-> isChecked ( )) | 558 | else if (m_rotdir_cw-> isChecked ( )) |
559 | { | 559 | { |
560 | rot = CW; | 560 | rot = CW; |
561 | } | 561 | } |
562 | else | 562 | else |
563 | { | 563 | { |
564 | rot = Flip; | 564 | rot = Flip; |
565 | } | 565 | } |
566 | config. writeEntry ( "rotatedir", (int)rot ); | 566 | config. writeEntry ( "rotatedir", (int)rot ); |
567 | 567 | ||
568 | m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated | 568 | m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated |
569 | 569 | ||
570 | QStringList sl; | 570 | QStringList sl; |
571 | QString exceptstr; | 571 | QString exceptstr; |
572 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) | 572 | for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) |
573 | { | 573 | { |
574 | int fl = 0; | 574 | int fl = 0; |
575 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); | 575 | fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); |
576 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); | 576 | fl |= ( it-> noFont ( ) ? 0x02 : 0 ); |
577 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); | 577 | fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); |
578 | exceptstr = QString::number ( fl, 32 ); | 578 | exceptstr = QString::number ( fl, 32 ); |
579 | exceptstr.append( it-> pattern ( )); | 579 | exceptstr.append( it-> pattern ( )); |
580 | sl << exceptstr; | 580 | sl << exceptstr; |
581 | } | 581 | } |
582 | config. writeEntry ( "NoStyle", sl, ';' ); | 582 | config. writeEntry ( "NoStyle", sl, ';' ); |
583 | config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); | 583 | config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); |
584 | 584 | ||
585 | config. write ( ); // need to flush the config info first | 585 | config. write ( ); // need to flush the config info first |
586 | Global::applyStyle ( ); | 586 | Global::applyStyle ( ); |
diff --git a/noncore/settings/appearance2/sample.cpp b/noncore/settings/appearance2/sample.cpp index b3a9d48..f6c4dca 100644 --- a/noncore/settings/appearance2/sample.cpp +++ b/noncore/settings/appearance2/sample.cpp | |||
@@ -1,220 +1,220 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> | 3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> |
4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | 4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <qvbox.h> | 29 | #include <qvbox.h> |
30 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qcheckbox.h> | 33 | #include <qcheckbox.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qscrollbar.h> | 35 | #include <qscrollbar.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qwhatsthis.h> | 37 | #include <qwhatsthis.h> |
38 | #include <qpixmapcache.h> | 38 | #include <qpixmapcache.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | #include <qobjectlist.h> | 40 | #include <qobjectlist.h> |
41 | #include <qcommonstyle.h> | 41 | #include <qcommonstyle.h> |
42 | 42 | ||
43 | #include "sample.h" | 43 | #include "sample.h" |
44 | 44 | ||
45 | 45 | ||
46 | class SampleText : public QWidget | 46 | class SampleText : public QWidget |
47 | { | 47 | { |
48 | public: | 48 | public: |
49 | SampleText( const QString &t, bool h, QWidget *parent ) | 49 | SampleText( const QString &t, bool h, QWidget *parent ) |
50 | : QWidget( parent ), hl(h), text(t) | 50 | : QWidget( parent ), hl(h), text(t) |
51 | { | 51 | { |
52 | if ( hl ) | 52 | if ( hl ) |
53 | setBackgroundMode( PaletteHighlight ); | 53 | setBackgroundMode( PaletteHighlight ); |
54 | else | 54 | else |
55 | setBackgroundMode( PaletteBase ); | 55 | setBackgroundMode( PaletteBase ); |
56 | } | 56 | } |
57 | 57 | ||
58 | QSize sizeHint() const | 58 | QSize sizeHint() const |
59 | { | 59 | { |
60 | QFontMetrics fm(font()); | 60 | QFontMetrics fm(font()); |
61 | return QSize( fm.width(text)+10, fm.height()+4 ); | 61 | return QSize( fm.width(text)+10, fm.height()+4 ); |
62 | } | 62 | } |
63 | 63 | ||
64 | void paintEvent( QPaintEvent * ) | 64 | void paintEvent( QPaintEvent * ) |
65 | { | 65 | { |
66 | QPainter p(this); | 66 | QPainter p(this); |
67 | if ( hl ) | 67 | if ( hl ) |
68 | p.setPen( colorGroup().highlightedText() ); | 68 | p.setPen( colorGroup().highlightedText() ); |
69 | else | 69 | else |
70 | p.setPen( colorGroup().text() ); | 70 | p.setPen( colorGroup().text() ); |
71 | p.drawText( rect(), AlignCenter, text ); | 71 | p.drawText( rect(), AlignCenter, text ); |
72 | } | 72 | } |
73 | 73 | ||
74 | private: | 74 | private: |
75 | bool hl; | 75 | bool hl; |
76 | QString text; | 76 | QString text; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | 79 | ||
80 | SampleWindow::SampleWindow( QWidget *parent ) : QWidget(parent), iface(0) | 80 | SampleWindow::SampleWindow( QWidget *parent ) : QWidget(parent), iface(0) |
81 | { | 81 | { |
82 | init(); | 82 | init(); |
83 | } | 83 | } |
84 | 84 | ||
85 | QSize SampleWindow::sizeHint() const | 85 | QSize SampleWindow::sizeHint() const |
86 | { | 86 | { |
87 | return container->sizeHint() + QSize( 10, 35 ); | 87 | return container->sizeHint() + QSize( 10, 35 ); |
88 | } | 88 | } |
89 | 89 | ||
90 | void SampleWindow::setFont( const QFont &f ) | 90 | void SampleWindow::setFont( const QFont &f ) |
91 | { | 91 | { |
92 | QWidget::setFont( f ); | 92 | QWidget::setFont( f ); |
93 | popup->setFont( f ); | 93 | popup->setFont( f ); |
94 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); | 94 | QTimer::singleShot ( 0, this, SLOT( fixGeometry())); |
95 | } | 95 | } |
96 | 96 | ||
97 | static void setStyleRecursive ( QWidget *w, QStyle *s ) | 97 | static void setStyleRecursive ( QWidget *w, QStyle *s ) |
98 | { | 98 | { |
99 | w->setStyle( s ); | 99 | w->setStyle( s ); |
100 | QObjectList *childObjects=(QObjectList*)w->children(); | 100 | QObjectList *childObjects=(QObjectList*)w->children(); |
101 | if ( childObjects ) { | 101 | if ( childObjects ) { |
102 | QObject * o; | 102 | QObject * o; |
103 | for(o=childObjects->first();o!=0;o=childObjects->next()) { | 103 | for(o=childObjects->first();o!=0;o=childObjects->next()) { |
104 | if( o->isWidgetType() ) { | 104 | if( o->isWidgetType() ) { |
105 | setStyleRecursive((QWidget *)o,s); | 105 | setStyleRecursive((QWidget *)o,s); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | void SampleWindow::setStyle2 ( QStyle *sty, const QPalette &pal ) | 112 | void SampleWindow::setStyle2 ( QStyle *sty, const QPalette &pal ) |
113 | { | 113 | { |
114 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, QColorGroup &, bool, bool); | 114 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, QColorGroup &, bool, bool); |
115 | 115 | ||
116 | extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl); | 116 | extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl); |
117 | 117 | ||
118 | QPixmapCache::clear ( ); | 118 | QPixmapCache::clear ( ); |
119 | QPalette p = pal; // ette ( ); | 119 | QPalette p = pal; // ette ( ); |
120 | sty-> polish ( p ); | 120 | sty-> polish ( p ); |
121 | qt_set_draw_menu_bar_impl ( 0 ); | 121 | qt_set_draw_menu_bar_impl ( 0 ); |
122 | setStyleRecursive ( this, sty ); | 122 | setStyleRecursive ( this, sty ); |
123 | setPalette ( p ); | 123 | setPalette ( p ); |
124 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); | 124 | QTimer::singleShot ( 0, this, SLOT( fixGeometry())); |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | void SampleWindow::setDecoration( WindowDecorationInterface *i ) | 128 | void SampleWindow::setDecoration( WindowDecorationInterface *i ) |
129 | { | 129 | { |
130 | iface = i; | 130 | iface = i; |
131 | wd.rect = QRect( 0, 0, 150, 75 ); | 131 | wd.rect = QRect( 0, 0, 150, 75 ); |
132 | wd.caption = tr("Sample"); | 132 | wd.caption = tr("Sample"); |
133 | wd.palette = palette(); | 133 | wd.palette = palette(); |
134 | wd.flags = WindowDecorationInterface::WindowData::Dialog | | 134 | wd.flags = WindowDecorationInterface::WindowData::Dialog | |
135 | WindowDecorationInterface::WindowData::Active; | 135 | WindowDecorationInterface::WindowData::Active; |
136 | wd.reserved = 1; | 136 | wd.reserved = 1; |
137 | 137 | ||
138 | th = iface->metric(WindowDecorationInterface::TitleHeight, &wd); | 138 | th = iface->metric(WindowDecorationInterface::TitleHeight, &wd); |
139 | tb = iface->metric(WindowDecorationInterface::TopBorder, &wd); | 139 | tb = iface->metric(WindowDecorationInterface::TopBorder, &wd); |
140 | lb = iface->metric(WindowDecorationInterface::LeftBorder, &wd); | 140 | lb = iface->metric(WindowDecorationInterface::LeftBorder, &wd); |
141 | rb = iface->metric(WindowDecorationInterface::RightBorder, &wd); | 141 | rb = iface->metric(WindowDecorationInterface::RightBorder, &wd); |
142 | bb = iface->metric(WindowDecorationInterface::BottomBorder, &wd); | 142 | bb = iface->metric(WindowDecorationInterface::BottomBorder, &wd); |
143 | 143 | ||
144 | int yoff = th + tb; | 144 | int yoff = th + tb; |
145 | int xoff = lb; | 145 | int xoff = lb; |
146 | 146 | ||
147 | wd.rect.setX( 0 ); | 147 | wd.rect.setX( 0 ); |
148 | wd.rect.setWidth( width() - lb - rb ); | 148 | wd.rect.setWidth( width() - lb - rb ); |
149 | wd.rect.setY( 0 ); | 149 | wd.rect.setY( 0 ); |
150 | wd.rect.setHeight( height() - yoff - bb ); | 150 | wd.rect.setHeight( height() - yoff - bb ); |
151 | 151 | ||
152 | container->setGeometry( xoff, yoff, wd.rect.width(), wd.rect.height() ); | 152 | container->setGeometry( xoff, yoff, wd.rect.width(), wd.rect.height() ); |
153 | setMinimumSize( container->sizeHint().width()+lb+rb, | 153 | setMinimumSize( container->sizeHint().width()+lb+rb, |
154 | container->sizeHint().height()+tb+th+bb ); | 154 | container->sizeHint().height()+tb+th+bb ); |
155 | } | 155 | } |
156 | 156 | ||
157 | void SampleWindow::paintEvent( QPaintEvent * ) | 157 | void SampleWindow::paintEvent( QPaintEvent * ) |
158 | { | 158 | { |
159 | if ( !iface ) | 159 | if ( !iface ) |
160 | return; | 160 | return; |
161 | 161 | ||
162 | QPainter p( this ); | 162 | QPainter p( this ); |
163 | 163 | ||
164 | p.translate( lb, th+tb ); | 164 | p.translate( lb, th+tb ); |
165 | 165 | ||
166 | iface->drawArea(WindowDecorationInterface::Border, &p, &wd); | 166 | iface->drawArea(WindowDecorationInterface::Border, &p, &wd); |
167 | iface->drawArea(WindowDecorationInterface::Title, &p, &wd); | 167 | iface->drawArea(WindowDecorationInterface::Title, &p, &wd); |
168 | 168 | ||
169 | p.setPen(palette().active().color(QColorGroup::HighlightedText)); | 169 | p.setPen(palette().active().color(QColorGroup::HighlightedText)); |
170 | QFont f( font() ); | 170 | QFont f( font() ); |
171 | f.setWeight( QFont::Bold ); | 171 | f.setWeight( QFont::Bold ); |
172 | p.setFont(f); | 172 | p.setFont(f); |
173 | iface->drawArea(WindowDecorationInterface::TitleText, &p, &wd); | 173 | iface->drawArea(WindowDecorationInterface::TitleText, &p, &wd); |
174 | 174 | ||
175 | QRect brect( 0, -th, iface->metric(WindowDecorationInterface::HelpWidth,&wd), th ); | 175 | QRect brect( 0, -th, iface->metric(WindowDecorationInterface::HelpWidth,&wd), th ); |
176 | iface->drawButton( WindowDecorationInterface::Help, &p, &wd, | 176 | iface->drawButton( WindowDecorationInterface::Help, &p, &wd, |
177 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); | 177 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); |
178 | brect.moveBy( wd.rect.width() - | 178 | brect.moveBy( wd.rect.width() - |
179 | iface->metric(WindowDecorationInterface::OKWidth,&wd) - | 179 | iface->metric(WindowDecorationInterface::OKWidth,&wd) - |
180 | iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); | 180 | iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); |
181 | iface->drawButton( WindowDecorationInterface::Close, &p, &wd, | 181 | iface->drawButton( WindowDecorationInterface::Close, &p, &wd, |
182 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); | 182 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); |
183 | brect.moveBy( iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); | 183 | brect.moveBy( iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); |
184 | iface->drawButton( WindowDecorationInterface::OK, &p, &wd, | 184 | iface->drawButton( WindowDecorationInterface::OK, &p, &wd, |
185 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); | 185 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void SampleWindow::init() | 188 | void SampleWindow::init() |
189 | { | 189 | { |
190 | container = new QVBox( this ); | 190 | container = new QVBox( this ); |
191 | popup = new QPopupMenu( this ); | 191 | popup = new QPopupMenu( this ); |
192 | popup->insertItem( tr("Normal Item"), 1 ); | 192 | popup->insertItem( tr("Normal Item"), 1 ); |
193 | popup->insertItem( tr("Disabled Item"), 2 ); | 193 | popup->insertItem( tr("Disabled Item"), 2 ); |
194 | popup->setItemEnabled(2, FALSE); | 194 | popup->setItemEnabled(2, FALSE); |
195 | QMenuBar *mb = new QMenuBar( container ); | 195 | QMenuBar *mb = new QMenuBar( container ); |
196 | mb->insertItem( tr("Menu"), popup ); | 196 | mb->insertItem( tr("Menu"), popup ); |
197 | QHBox *hb = new QHBox( container ); | 197 | QHBox *hb = new QHBox( container ); |
198 | QWidget *w = new QWidget( hb ); | 198 | QWidget *w = new QWidget( hb ); |
199 | (void)new QScrollBar( 0, 0, 0, 0, 0, Vertical, hb ); | 199 | (void)new QScrollBar( 0, 0, 0, 0, 0, Vertical, hb ); |
200 | 200 | ||
201 | QGridLayout *gl = new QGridLayout( w, 2, 2, 4 ); | 201 | QGridLayout *gl = new QGridLayout( w, 2, 2, 4 ); |
202 | SampleText *l = new SampleText( tr("Normal Text"), FALSE, w ); | 202 | SampleText *l = new SampleText( tr("Normal Text"), FALSE, w ); |
203 | gl->addWidget( l, 0, 0 ); | 203 | gl->addWidget( l, 0, 0 ); |
204 | 204 | ||
205 | l = new SampleText( tr("Highlighted Text"), TRUE, w ); | 205 | l = new SampleText( tr("Highlighted Text"), TRUE, w ); |
206 | gl->addWidget( l, 1, 0 ); | 206 | gl->addWidget( l, 1, 0 ); |
207 | 207 | ||
208 | QPushButton *pb = new QPushButton( tr("Button"), w ); | 208 | QPushButton *pb = new QPushButton( tr("Button"), w ); |
209 | gl->addWidget( pb, 0, 1 ); | 209 | gl->addWidget( pb, 0, 1 ); |
210 | pb->setFocusPolicy( NoFocus ); | 210 | pb->setFocusPolicy( NoFocus ); |
211 | 211 | ||
212 | QCheckBox *cb = new QCheckBox( tr("Check Box"), w ); | 212 | QCheckBox *cb = new QCheckBox( tr("Check Box"), w ); |
213 | gl->addWidget( cb, 1, 1 ); | 213 | gl->addWidget( cb, 1, 1 ); |
214 | cb->setFocusPolicy( NoFocus ); | 214 | cb->setFocusPolicy( NoFocus ); |
215 | cb->setChecked( TRUE ); | 215 | cb->setChecked( TRUE ); |
216 | 216 | ||
217 | QWhatsThis::add( this, tr("Sample window using the selected settings.") ); | 217 | QWhatsThis::add( this, tr("Sample window using the selected settings.") ); |
218 | } | 218 | } |
219 | 219 | ||
220 | bool SampleWindow::eventFilter( QObject *, QEvent *e ) | 220 | bool SampleWindow::eventFilter( QObject *, QEvent *e ) |
diff --git a/noncore/settings/aqpkg/inputdlg.cpp b/noncore/settings/aqpkg/inputdlg.cpp index 06e934c..30f0527 100644 --- a/noncore/settings/aqpkg/inputdlg.cpp +++ b/noncore/settings/aqpkg/inputdlg.cpp | |||
@@ -1,134 +1,134 @@ | |||
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, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
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 <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qspinbox.h> | 34 | #include <qspinbox.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qwidgetstack.h> | 36 | #include <qwidgetstack.h> |
37 | #include <qvalidator.h> | 37 | #include <qvalidator.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include "inputdlg.h" | 40 | #include "inputdlg.h" |
41 | #include "global.h" | 41 | #include "global.h" |
42 | 42 | ||
43 | 43 | ||
44 | InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name, | 44 | InputDialog :: InputDialog( const QString &label, QWidget* parent, const char* name, |
45 | bool modal ) | 45 | bool modal ) |
46 | : QDialog( parent, name, modal ) | 46 | : QDialog( parent, name, modal ) |
47 | { | 47 | { |
48 | lineEdit = 0; | 48 | lineEdit = 0; |
49 | 49 | ||
50 | QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); | 50 | QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); |
51 | 51 | ||
52 | QLabel* l = new QLabel( label, this ); | 52 | QLabel* l = new QLabel( label, this ); |
53 | vbox->addWidget( l ); | 53 | vbox->addWidget( l ); |
54 | 54 | ||
55 | lineEdit = new QLineEdit( this ); | 55 | lineEdit = new QLineEdit( this ); |
56 | vbox->addWidget( lineEdit ); | 56 | vbox->addWidget( lineEdit ); |
57 | 57 | ||
58 | QHBoxLayout *hbox = new QHBoxLayout( 6 ); | 58 | QHBoxLayout *hbox = new QHBoxLayout( 6 ); |
59 | vbox->addLayout( hbox, AlignRight ); | 59 | vbox->addLayout( hbox, AlignRight ); |
60 | 60 | ||
61 | ok = new QPushButton( tr( "&OK" ), this ); | 61 | ok = new QPushButton( tr( "&OK" ), this ); |
62 | ok->setDefault( TRUE ); | 62 | ok->setDefault( TRUE ); |
63 | QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); | 63 | QPushButton *cancel = new QPushButton( tr( "&Cancel" ), this ); |
64 | 64 | ||
65 | QSize bs( ok->sizeHint() ); | 65 | QSize bs( ok->sizeHint() ); |
66 | if ( cancel->sizeHint().width() > bs.width() ) | 66 | if ( cancel->sizeHint().width() > bs.width() ) |
67 | bs.setWidth( cancel->sizeHint().width() ); | 67 | bs.setWidth( cancel->sizeHint().width() ); |
68 | 68 | ||
69 | ok->setFixedSize( bs ); | 69 | ok->setFixedSize( bs ); |
70 | cancel->setFixedSize( bs ); | 70 | cancel->setFixedSize( bs ); |
71 | 71 | ||
72 | hbox->addWidget( new QWidget( this ) ); | 72 | hbox->addWidget( new QWidget( this ) ); |
73 | hbox->addWidget( ok ); | 73 | hbox->addWidget( ok ); |
74 | hbox->addWidget( cancel ); | 74 | hbox->addWidget( cancel ); |
75 | 75 | ||
76 | connect( lineEdit, SIGNAL( returnPressed() ), | 76 | connect( lineEdit, SIGNAL( returnPressed() ), |
77 | this, SLOT( tryAccept() ) ); | 77 | this, SLOT( tryAccept() ) ); |
78 | connect( lineEdit, SIGNAL( textChanged( const QString & ) ), | 78 | connect( lineEdit, SIGNAL( textChanged(const QString&) ), |
79 | this, SLOT( textChanged( const QString & ) ) ); | 79 | this, SLOT( textChanged(const QString&) ) ); |
80 | 80 | ||
81 | connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); | 81 | connect( ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); |
82 | connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); | 82 | connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); |
83 | 83 | ||
84 | resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() ); | 84 | resize( QMAX( sizeHint().width(), 240 ), sizeHint().height() ); |
85 | } | 85 | } |
86 | 86 | ||
87 | /*! | 87 | /*! |
88 | Destructor. | 88 | Destructor. |
89 | */ | 89 | */ |
90 | 90 | ||
91 | InputDialog::~InputDialog() | 91 | InputDialog::~InputDialog() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | void InputDialog :: setText( const QString &text ) | 95 | void InputDialog :: setText( const QString &text ) |
96 | { | 96 | { |
97 | lineEdit->setText( text ); | 97 | lineEdit->setText( text ); |
98 | lineEdit->selectAll(); | 98 | lineEdit->selectAll(); |
99 | } | 99 | } |
100 | 100 | ||
101 | QString InputDialog :: getText() | 101 | QString InputDialog :: getText() |
102 | { | 102 | { |
103 | return lineEdit->text(); | 103 | return lineEdit->text(); |
104 | } | 104 | } |
105 | 105 | ||
106 | QString InputDialog::getText( const QString &caption, const QString &label, | 106 | QString InputDialog::getText( const QString &caption, const QString &label, |
107 | const QString &text, bool *ok, QWidget *parent, | 107 | const QString &text, bool *ok, QWidget *parent, |
108 | const char *name ) | 108 | const char *name ) |
109 | { | 109 | { |
110 | InputDialog *dlg = new InputDialog( label, parent, name, true ); | 110 | InputDialog *dlg = new InputDialog( label, parent, name, true ); |
111 | dlg->setCaption( caption ); | 111 | dlg->setCaption( caption ); |
112 | dlg->setText( text ); | 112 | dlg->setText( text ); |
113 | 113 | ||
114 | QString result; | 114 | QString result; |
115 | *ok = dlg->exec() == QDialog::Accepted; | 115 | *ok = dlg->exec() == QDialog::Accepted; |
116 | if ( *ok ) | 116 | if ( *ok ) |
117 | result = dlg->getText(); | 117 | result = dlg->getText(); |
118 | 118 | ||
119 | delete dlg; | 119 | delete dlg; |
120 | return result; | 120 | return result; |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | 124 | ||
125 | void InputDialog :: textChanged( const QString &s ) | 125 | void InputDialog :: textChanged( const QString &s ) |
126 | { | 126 | { |
127 | ok->setEnabled( !s.isEmpty() ); | 127 | ok->setEnabled( !s.isEmpty() ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void InputDialog :: tryAccept() | 130 | void InputDialog :: tryAccept() |
131 | { | 131 | { |
132 | if ( !lineEdit->text().isEmpty() ) | 132 | if ( !lineEdit->text().isEmpty() ) |
133 | accept(); | 133 | accept(); |
134 | } | 134 | } |
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index d927a36..d2babb4 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -79,321 +79,321 @@ InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManag | |||
79 | 79 | ||
80 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) | 80 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) |
81 | flags = cfg.readNumEntry( "installFlags", 0 ); | 81 | flags = cfg.readNumEntry( "installFlags", 0 ); |
82 | infoLevel = cfg.readNumEntry( "infoLevel", 1 ); | 82 | infoLevel = cfg.readNumEntry( "infoLevel", 1 ); |
83 | #else | 83 | #else |
84 | flags = 0; | 84 | flags = 0; |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | // Output text is read only | 87 | // Output text is read only |
88 | output->setReadOnly( true ); | 88 | output->setReadOnly( true ); |
89 | // QFont f( "helvetica" ); | 89 | // QFont f( "helvetica" ); |
90 | // f.setPointSize( 10 ); | 90 | // f.setPointSize( 10 ); |
91 | // output->setFont( f ); | 91 | // output->setFont( f ); |
92 | 92 | ||
93 | 93 | ||
94 | // setup destination data | 94 | // setup destination data |
95 | int defIndex = 0; | 95 | int defIndex = 0; |
96 | int i; | 96 | int i; |
97 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); | 97 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); |
98 | for ( i = 0; dit.current(); ++dit, ++i ) | 98 | for ( i = 0; dit.current(); ++dit, ++i ) |
99 | { | 99 | { |
100 | destination->insertItem( dit.current()->getDestinationName() ); | 100 | destination->insertItem( dit.current()->getDestinationName() ); |
101 | if ( dit.current()->getDestinationName() == defaultDest ) | 101 | if ( dit.current()->getDestinationName() == defaultDest ) |
102 | defIndex = i; | 102 | defIndex = i; |
103 | } | 103 | } |
104 | 104 | ||
105 | destination->setCurrentItem( defIndex ); | 105 | destination->setCurrentItem( defIndex ); |
106 | 106 | ||
107 | QListIterator<InstallData> it( packageList ); | 107 | QListIterator<InstallData> it( packageList ); |
108 | // setup package data | 108 | // setup package data |
109 | QString remove = tr( "Remove\n" ); | 109 | QString remove = tr( "Remove\n" ); |
110 | QString install = tr( "Install\n" ); | 110 | QString install = tr( "Install\n" ); |
111 | QString upgrade = tr( "Upgrade\n" ); | 111 | QString upgrade = tr( "Upgrade\n" ); |
112 | for ( ; it.current(); ++it ) | 112 | for ( ; it.current(); ++it ) |
113 | { | 113 | { |
114 | InstallData *item = it.current(); | 114 | InstallData *item = it.current(); |
115 | InstallData *newitem = new InstallData(); | 115 | InstallData *newitem = new InstallData(); |
116 | 116 | ||
117 | newitem->option = item->option; | 117 | newitem->option = item->option; |
118 | newitem->packageName = item->packageName; | 118 | newitem->packageName = item->packageName; |
119 | newitem->destination = item->destination; | 119 | newitem->destination = item->destination; |
120 | newitem->recreateLinks = item->recreateLinks; | 120 | newitem->recreateLinks = item->recreateLinks; |
121 | packages.append( newitem ); | 121 | packages.append( newitem ); |
122 | 122 | ||
123 | if ( item->option == "I" ) | 123 | if ( item->option == "I" ) |
124 | { | 124 | { |
125 | install.append( QString( " %1\n" ).arg( item->packageName ) ); | 125 | install.append( QString( " %1\n" ).arg( item->packageName ) ); |
126 | } | 126 | } |
127 | else if ( item->option == "D" ) | 127 | else if ( item->option == "D" ) |
128 | { | 128 | { |
129 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); | 129 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); |
130 | } | 130 | } |
131 | else if ( item->option == "U" || item->option == "R" ) | 131 | else if ( item->option == "U" || item->option == "R" ) |
132 | { | 132 | { |
133 | QString type; | 133 | QString type; |
134 | if ( item->option == "R" ) | 134 | if ( item->option == "R" ) |
135 | type = tr( "(ReInstall)" ); | 135 | type = tr( "(ReInstall)" ); |
136 | else | 136 | else |
137 | type = tr( "(Upgrade)" ); | 137 | type = tr( "(Upgrade)" ); |
138 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); | 138 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); | 142 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); |
143 | 143 | ||
144 | displayAvailableSpace( destination->currentText() ); | 144 | displayAvailableSpace( destination->currentText() ); |
145 | } | 145 | } |
146 | 146 | ||
147 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) | 147 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) |
148 | : QWidget( 0, 0, 0 ) | 148 | : QWidget( 0, 0, 0 ) |
149 | { | 149 | { |
150 | setCaption( title ); | 150 | setCaption( title ); |
151 | init( FALSE ); | 151 | init( FALSE ); |
152 | pIpkg = ipkg; | 152 | pIpkg = ipkg; |
153 | output->setText( initialText ); | 153 | output->setText( initialText ); |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | InstallDlgImpl::~InstallDlgImpl() | 157 | InstallDlgImpl::~InstallDlgImpl() |
158 | { | 158 | { |
159 | if ( pIpkg ) | 159 | if ( pIpkg ) |
160 | delete pIpkg; | 160 | delete pIpkg; |
161 | } | 161 | } |
162 | 162 | ||
163 | void InstallDlgImpl :: init( bool displayextrainfo ) | 163 | void InstallDlgImpl :: init( bool displayextrainfo ) |
164 | { | 164 | { |
165 | QGridLayout *layout = new QGridLayout( this ); | 165 | QGridLayout *layout = new QGridLayout( this ); |
166 | layout->setSpacing( 4 ); | 166 | layout->setSpacing( 4 ); |
167 | layout->setMargin( 4 ); | 167 | layout->setMargin( 4 ); |
168 | 168 | ||
169 | if ( displayextrainfo ) | 169 | if ( displayextrainfo ) |
170 | { | 170 | { |
171 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 171 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
172 | layout->addWidget( label, 0, 0 ); | 172 | layout->addWidget( label, 0, 0 ); |
173 | destination = new QComboBox( FALSE, this ); | 173 | destination = new QComboBox( FALSE, this ); |
174 | layout->addWidget( destination, 0, 1 ); | 174 | layout->addWidget( destination, 0, 1 ); |
175 | connect( destination, SIGNAL( highlighted( const QString & ) ), | 175 | connect( destination, SIGNAL( highlighted(const QString&) ), |
176 | this, SLOT( displayAvailableSpace( const QString & ) ) ); | 176 | this, SLOT( displayAvailableSpace(const QString&) ) ); |
177 | 177 | ||
178 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); | 178 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); |
179 | layout->addWidget( label2, 1, 0 ); | 179 | layout->addWidget( label2, 1, 0 ); |
180 | txtAvailableSpace = new QLabel( "", this ); | 180 | txtAvailableSpace = new QLabel( "", this ); |
181 | layout->addWidget( txtAvailableSpace, 1, 1 ); | 181 | layout->addWidget( txtAvailableSpace, 1, 1 ); |
182 | } | 182 | } |
183 | else | 183 | else |
184 | { | 184 | { |
185 | destination = 0x0; | 185 | destination = 0x0; |
186 | txtAvailableSpace = 0x0; | 186 | txtAvailableSpace = 0x0; |
187 | } | 187 | } |
188 | 188 | ||
189 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 189 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
190 | GroupBox2->layout()->setSpacing( 0 ); | 190 | GroupBox2->layout()->setSpacing( 0 ); |
191 | GroupBox2->layout()->setMargin( 4 ); | 191 | GroupBox2->layout()->setMargin( 4 ); |
192 | 192 | ||
193 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); | 193 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); |
194 | output = new QMultiLineEdit( GroupBox2 ); | 194 | output = new QMultiLineEdit( GroupBox2 ); |
195 | GroupBox2Layout->addWidget( output ); | 195 | GroupBox2Layout->addWidget( output ); |
196 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); | 196 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); |
197 | 197 | ||
198 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); | 198 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); |
199 | layout->addWidget( btnInstall, 3, 0 ); | 199 | layout->addWidget( btnInstall, 3, 0 ); |
200 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); | 200 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); |
201 | 201 | ||
202 | btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); | 202 | btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); |
203 | layout->addWidget( btnOptions, 3, 1 ); | 203 | layout->addWidget( btnOptions, 3, 1 ); |
204 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); | 204 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); |
205 | } | 205 | } |
206 | 206 | ||
207 | void InstallDlgImpl :: optionsSelected() | 207 | void InstallDlgImpl :: optionsSelected() |
208 | { | 208 | { |
209 | if ( btnOptions->text() == tr( "Options" ) ) | 209 | if ( btnOptions->text() == tr( "Options" ) ) |
210 | { | 210 | { |
211 | InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); | 211 | InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); |
212 | if ( opt.exec() == QDialog::Accepted ) | 212 | if ( opt.exec() == QDialog::Accepted ) |
213 | { | 213 | { |
214 | // set options selected from dialog | 214 | // set options selected from dialog |
215 | flags = opt.getFlags(); | 215 | flags = opt.getFlags(); |
216 | infoLevel = opt.getInfoLevel(); | 216 | infoLevel = opt.getInfoLevel(); |
217 | 217 | ||
218 | #ifdef QWS | 218 | #ifdef QWS |
219 | Config cfg( "aqpkg" ); | 219 | Config cfg( "aqpkg" ); |
220 | cfg.setGroup( "settings" ); | 220 | cfg.setGroup( "settings" ); |
221 | cfg.writeEntry( "installFlags", flags ); | 221 | cfg.writeEntry( "installFlags", flags ); |
222 | cfg.writeEntry( "infoLevel", infoLevel ); | 222 | cfg.writeEntry( "infoLevel", infoLevel ); |
223 | #endif | 223 | #endif |
224 | } | 224 | } |
225 | } | 225 | } |
226 | else // Save output | 226 | else // Save output |
227 | { | 227 | { |
228 | QMap<QString, QStringList> map; | 228 | QMap<QString, QStringList> map; |
229 | map.insert( tr( "All" ), QStringList() ); | 229 | map.insert( tr( "All" ), QStringList() ); |
230 | QStringList text; | 230 | QStringList text; |
231 | text << "text/*"; | 231 | text << "text/*"; |
232 | map.insert(tr( "Text" ), text ); | 232 | map.insert(tr( "Text" ), text ); |
233 | text << "*"; | 233 | text << "*"; |
234 | map.insert( tr( "All" ), text ); | 234 | map.insert( tr( "All" ), text ); |
235 | 235 | ||
236 | QString filename = Opie::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 236 | QString filename = Opie::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
237 | if( !filename.isEmpty() ) | 237 | if( !filename.isEmpty() ) |
238 | { | 238 | { |
239 | QString currentFileName = QFileInfo( filename ).fileName(); | 239 | QString currentFileName = QFileInfo( filename ).fileName(); |
240 | DocLnk doc; | 240 | DocLnk doc; |
241 | doc.setType( "text/plain" ); | 241 | doc.setType( "text/plain" ); |
242 | doc.setFile( filename ); | 242 | doc.setFile( filename ); |
243 | doc.setName( currentFileName ); | 243 | doc.setName( currentFileName ); |
244 | FileManager fm; | 244 | FileManager fm; |
245 | fm.saveFile( doc, output->text() ); | 245 | fm.saveFile( doc, output->text() ); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | void InstallDlgImpl :: installSelected() | 250 | void InstallDlgImpl :: installSelected() |
251 | { | 251 | { |
252 | if ( btnInstall->text() == tr( "Abort" ) ) | 252 | if ( btnInstall->text() == tr( "Abort" ) ) |
253 | { | 253 | { |
254 | if ( pIpkg ) | 254 | if ( pIpkg ) |
255 | { | 255 | { |
256 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); | 256 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); |
257 | pIpkg->abort(); | 257 | pIpkg->abort(); |
258 | displayText( tr( "**** Process Aborted ****" ) ); | 258 | displayText( tr( "**** Process Aborted ****" ) ); |
259 | } | 259 | } |
260 | 260 | ||
261 | btnInstall->setText( tr( "Close" ) ); | 261 | btnInstall->setText( tr( "Close" ) ); |
262 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 262 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | else if ( btnInstall->text() == tr( "Close" ) ) | 265 | else if ( btnInstall->text() == tr( "Close" ) ) |
266 | { | 266 | { |
267 | emit reloadData( this ); | 267 | emit reloadData( this ); |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | 270 | ||
271 | // Disable buttons | 271 | // Disable buttons |
272 | btnOptions->setEnabled( false ); | 272 | btnOptions->setEnabled( false ); |
273 | // btnInstall->setEnabled( false ); | 273 | // btnInstall->setEnabled( false ); |
274 | 274 | ||
275 | btnInstall->setText( tr( "Abort" ) ); | 275 | btnInstall->setText( tr( "Abort" ) ); |
276 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); | 276 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); |
277 | 277 | ||
278 | if ( pIpkg ) | 278 | if ( pIpkg ) |
279 | { | 279 | { |
280 | output->setText( "" ); | 280 | output->setText( "" ); |
281 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 281 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
282 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); | 282 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); |
283 | pIpkg->runIpkg(); | 283 | pIpkg->runIpkg(); |
284 | } | 284 | } |
285 | else | 285 | else |
286 | { | 286 | { |
287 | output->setText( "" ); | 287 | output->setText( "" ); |
288 | Destination *d = dataMgr->getDestination( destination->currentText() ); | 288 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
289 | QString dest = d->getDestinationName(); | 289 | QString dest = d->getDestinationName(); |
290 | QString destDir = d->getDestinationPath(); | 290 | QString destDir = d->getDestinationPath(); |
291 | int instFlags = flags; | 291 | int instFlags = flags; |
292 | if ( d->linkToRoot() ) | 292 | if ( d->linkToRoot() ) |
293 | instFlags |= MAKE_LINKS; | 293 | instFlags |= MAKE_LINKS; |
294 | 294 | ||
295 | #ifdef QWS | 295 | #ifdef QWS |
296 | // Save settings | 296 | // Save settings |
297 | Config cfg( "aqpkg" ); | 297 | Config cfg( "aqpkg" ); |
298 | cfg.setGroup( "settings" ); | 298 | cfg.setGroup( "settings" ); |
299 | cfg.writeEntry( "dest", dest ); | 299 | cfg.writeEntry( "dest", dest ); |
300 | #endif | 300 | #endif |
301 | 301 | ||
302 | pIpkg = new Ipkg; | 302 | pIpkg = new Ipkg; |
303 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 303 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
304 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); | 304 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); |
305 | 305 | ||
306 | firstPackage = TRUE; | 306 | firstPackage = TRUE; |
307 | ipkgFinished(); | 307 | ipkgFinished(); |
308 | 308 | ||
309 | // First run through the remove list, then the install list then the upgrade list | 309 | // First run through the remove list, then the install list then the upgrade list |
310 | /* | 310 | /* |
311 | pIpkg->setOption( "remove" ); | 311 | pIpkg->setOption( "remove" ); |
312 | QListIterator<InstallData> it( removeList ); | 312 | QListIterator<InstallData> it( removeList ); |
313 | InstallData *idata; | 313 | InstallData *idata; |
314 | for ( ; it.current(); ++it ) | 314 | for ( ; it.current(); ++it ) |
315 | { | 315 | { |
316 | idata = it.current(); | 316 | idata = it.current(); |
317 | pIpkg->setDestination( idata->destination->getDestinationName() ); | 317 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
318 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); | 318 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
319 | pIpkg->setPackage( idata->packageName ); | 319 | pIpkg->setPackage( idata->packageName ); |
320 | 320 | ||
321 | int tmpFlags = flags; | 321 | int tmpFlags = flags; |
322 | if ( idata->destination->linkToRoot() ) | 322 | if ( idata->destination->linkToRoot() ) |
323 | tmpFlags |= MAKE_LINKS; | 323 | tmpFlags |= MAKE_LINKS; |
324 | 324 | ||
325 | pIpkg->setFlags( tmpFlags, infoLevel ); | 325 | pIpkg->setFlags( tmpFlags, infoLevel ); |
326 | pIpkg->runIpkg(); | 326 | pIpkg->runIpkg(); |
327 | } | 327 | } |
328 | 328 | ||
329 | pIpkg->setOption( "install" ); | 329 | pIpkg->setOption( "install" ); |
330 | pIpkg->setDestination( dest ); | 330 | pIpkg->setDestination( dest ); |
331 | pIpkg->setDestinationDir( destDir ); | 331 | pIpkg->setDestinationDir( destDir ); |
332 | pIpkg->setFlags( instFlags, infoLevel ); | 332 | pIpkg->setFlags( instFlags, infoLevel ); |
333 | QListIterator<InstallData> it2( installList ); | 333 | QListIterator<InstallData> it2( installList ); |
334 | for ( ; it2.current(); ++it2 ) | 334 | for ( ; it2.current(); ++it2 ) |
335 | { | 335 | { |
336 | pIpkg->setPackage( it2.current()->packageName ); | 336 | pIpkg->setPackage( it2.current()->packageName ); |
337 | pIpkg->runIpkg(); | 337 | pIpkg->runIpkg(); |
338 | } | 338 | } |
339 | 339 | ||
340 | flags |= FORCE_REINSTALL; | 340 | flags |= FORCE_REINSTALL; |
341 | QListIterator<InstallData> it3( updateList ); | 341 | QListIterator<InstallData> it3( updateList ); |
342 | for ( ; it3.current() ; ++it3 ) | 342 | for ( ; it3.current() ; ++it3 ) |
343 | { | 343 | { |
344 | idata = it3.current(); | 344 | idata = it3.current(); |
345 | if ( idata->option == "R" ) | 345 | if ( idata->option == "R" ) |
346 | pIpkg->setOption( "reinstall" ); | 346 | pIpkg->setOption( "reinstall" ); |
347 | else | 347 | else |
348 | pIpkg->setOption( "upgrade" ); | 348 | pIpkg->setOption( "upgrade" ); |
349 | pIpkg->setDestination( idata->destination->getDestinationName() ); | 349 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
350 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); | 350 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
351 | pIpkg->setPackage( idata->packageName ); | 351 | pIpkg->setPackage( idata->packageName ); |
352 | 352 | ||
353 | int tmpFlags = flags; | 353 | int tmpFlags = flags; |
354 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) | 354 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) |
355 | tmpFlags |= MAKE_LINKS; | 355 | tmpFlags |= MAKE_LINKS; |
356 | pIpkg->setFlags( tmpFlags, infoLevel ); | 356 | pIpkg->setFlags( tmpFlags, infoLevel ); |
357 | pIpkg->runIpkg(); | 357 | pIpkg->runIpkg(); |
358 | } | 358 | } |
359 | 359 | ||
360 | delete pIpkg; | 360 | delete pIpkg; |
361 | pIpkg = 0; | 361 | pIpkg = 0; |
362 | */ | 362 | */ |
363 | } | 363 | } |
364 | } | 364 | } |
365 | 365 | ||
366 | 366 | ||
367 | void InstallDlgImpl :: displayText(const QString &text ) | 367 | void InstallDlgImpl :: displayText(const QString &text ) |
368 | { | 368 | { |
369 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); | 369 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); |
370 | 370 | ||
371 | /* Set a max line count for the QMultiLineEdit, as users have reported | 371 | /* Set a max line count for the QMultiLineEdit, as users have reported |
372 | * performance issues when line count gets extreme. | 372 | * performance issues when line count gets extreme. |
373 | */ | 373 | */ |
374 | if(output->numLines() >= MAXLINES) | 374 | if(output->numLines() >= MAXLINES) |
375 | output->removeLine(0); | 375 | output->removeLine(0); |
376 | output->setText( newtext ); | 376 | output->setText( newtext ); |
377 | output->setCursorPosition( output->numLines(), 0 ); | 377 | output->setCursorPosition( output->numLines(), 0 ); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | 381 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) |
382 | { | 382 | { |
383 | Destination *d = dataMgr->getDestination( text ); | 383 | Destination *d = dataMgr->getDestination( text ); |
384 | QString destDir = d->getDestinationPath(); | 384 | QString destDir = d->getDestinationPath(); |
385 | 385 | ||
386 | long blockSize = 0; | 386 | long blockSize = 0; |
387 | long totalBlocks = 0; | 387 | long totalBlocks = 0; |
388 | long availBlocks = 0; | 388 | long availBlocks = 0; |
389 | QString space; | 389 | QString space; |
390 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) | 390 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) |
391 | { | 391 | { |
392 | long mult = blockSize / 1024; | 392 | long mult = blockSize / 1024; |
393 | long div = 1024 / blockSize; | 393 | long div = 1024 / blockSize; |
394 | 394 | ||
395 | if ( !mult ) mult = 1; | 395 | if ( !mult ) mult = 1; |
396 | if ( !div ) div = 1; | 396 | if ( !div ) div = 1; |
397 | long avail = availBlocks * mult / div; | 397 | long avail = availBlocks * mult / div; |
398 | 398 | ||
399 | space = tr( "%1 Kb" ).arg( avail ); | 399 | space = tr( "%1 Kb" ).arg( avail ); |
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 3761b67..866afed 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp | |||
@@ -195,200 +195,200 @@ void Ipkg :: removeStatusEntry() | |||
195 | tempstr = tr("package - "); | 195 | tempstr = tr("package - "); |
196 | tempstr.append( package ); | 196 | tempstr.append( package ); |
197 | emit outputText( tempstr ); | 197 | emit outputText( tempstr ); |
198 | 198 | ||
199 | QFile readFile( statusFile ); | 199 | QFile readFile( statusFile ); |
200 | QFile writeFile( outStatusFile ); | 200 | QFile writeFile( outStatusFile ); |
201 | 201 | ||
202 | if ( !readFile.open( IO_ReadOnly ) ) | 202 | if ( !readFile.open( IO_ReadOnly ) ) |
203 | { | 203 | { |
204 | tempstr = tr("Couldn't open status file - "); | 204 | tempstr = tr("Couldn't open status file - "); |
205 | tempstr.append( statusFile ); | 205 | tempstr.append( statusFile ); |
206 | emit outputText( tempstr ); | 206 | emit outputText( tempstr ); |
207 | return; | 207 | return; |
208 | } | 208 | } |
209 | 209 | ||
210 | if ( !writeFile.open( IO_WriteOnly ) ) | 210 | if ( !writeFile.open( IO_WriteOnly ) ) |
211 | { | 211 | { |
212 | tempstr = tr("Couldn't create tempory status file - "); | 212 | tempstr = tr("Couldn't create tempory status file - "); |
213 | tempstr.append( outStatusFile ); | 213 | tempstr.append( outStatusFile ); |
214 | emit outputText( tempstr ); | 214 | emit outputText( tempstr ); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | 217 | ||
218 | int i = 0; | 218 | int i = 0; |
219 | 219 | ||
220 | QTextStream readStream( &readFile ); | 220 | QTextStream readStream( &readFile ); |
221 | QTextStream writeStream( &writeFile ); | 221 | QTextStream writeStream( &writeFile ); |
222 | QString line; | 222 | QString line; |
223 | 223 | ||
224 | char k[21]; | 224 | char k[21]; |
225 | char v[1001]; | 225 | char v[1001]; |
226 | QString key; | 226 | QString key; |
227 | QString value; | 227 | QString value; |
228 | 228 | ||
229 | while ( !readStream.atEnd() ) | 229 | while ( !readStream.atEnd() ) |
230 | { | 230 | { |
231 | //read new line | 231 | //read new line |
232 | line = readStream.readLine(); | 232 | line = readStream.readLine(); |
233 | 233 | ||
234 | if ( line.contains( ":", TRUE ) ) | 234 | if ( line.contains( ":", TRUE ) ) |
235 | { | 235 | { |
236 | //grep key and value from line | 236 | //grep key and value from line |
237 | k[0] = '\0'; | 237 | k[0] = '\0'; |
238 | v[0] = '\0'; | 238 | v[0] = '\0'; |
239 | sscanf( line, "%[^:]: %[^\n]", k, v ); | 239 | sscanf( line, "%[^:]: %[^\n]", k, v ); |
240 | key = k; | 240 | key = k; |
241 | value = v; | 241 | value = v; |
242 | key = key.stripWhiteSpace(); | 242 | key = key.stripWhiteSpace(); |
243 | value = value.stripWhiteSpace(); | 243 | value = value.stripWhiteSpace(); |
244 | } else { | 244 | } else { |
245 | key = ""; | 245 | key = ""; |
246 | value = ""; | 246 | value = ""; |
247 | } | 247 | } |
248 | 248 | ||
249 | if ( key == "Package" && value == package ) | 249 | if ( key == "Package" && value == package ) |
250 | { | 250 | { |
251 | //skip lines from the deleted package | 251 | //skip lines from the deleted package |
252 | while ( ( !readStream.atEnd() ) && ( line.stripWhiteSpace() != "" ) ) | 252 | while ( ( !readStream.atEnd() ) && ( line.stripWhiteSpace() != "" ) ) |
253 | { | 253 | { |
254 | line = readStream.readLine(); | 254 | line = readStream.readLine(); |
255 | } | 255 | } |
256 | } else { | 256 | } else { |
257 | 257 | ||
258 | //write other lines into the tempfile | 258 | //write other lines into the tempfile |
259 | writeStream << line << "\n"; | 259 | writeStream << line << "\n"; |
260 | 260 | ||
261 | // Improve UI responsiveness | 261 | // Improve UI responsiveness |
262 | i++; | 262 | i++; |
263 | if ( ( i % 50 ) == 0 ) | 263 | if ( ( i % 50 ) == 0 ) |
264 | qApp->processEvents(); | 264 | qApp->processEvents(); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | readFile.close(); | 268 | readFile.close(); |
269 | writeFile.close(); | 269 | writeFile.close(); |
270 | 270 | ||
271 | // Remove old status file and put tmp stats file in its place | 271 | // Remove old status file and put tmp stats file in its place |
272 | remove( statusFile ); | 272 | remove( statusFile ); |
273 | rename( outStatusFile, statusFile ); | 273 | rename( outStatusFile, statusFile ); |
274 | } | 274 | } |
275 | 275 | ||
276 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | 276 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) |
277 | { | 277 | { |
278 | // If one is already running - should never be but just to be safe | 278 | // If one is already running - should never be but just to be safe |
279 | if ( proc ) | 279 | if ( proc ) |
280 | { | 280 | { |
281 | delete proc; | 281 | delete proc; |
282 | proc = 0; | 282 | proc = 0; |
283 | } | 283 | } |
284 | 284 | ||
285 | // OK we're gonna use OProcess to run this thing | 285 | // OK we're gonna use OProcess to run this thing |
286 | proc = new OProcess(); | 286 | proc = new OProcess(); |
287 | aborted = false; | 287 | aborted = false; |
288 | 288 | ||
289 | 289 | ||
290 | // Connect up our slots | 290 | // Connect up our slots |
291 | connect(proc, SIGNAL(processExited(OProcess *)), | 291 | connect(proc, SIGNAL(processExited(OProcess*)), |
292 | this, SLOT( processFinished())); | 292 | this, SLOT( processFinished())); |
293 | 293 | ||
294 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), | 294 | connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), |
295 | this, SLOT(commandStdout(OProcess *, char *, int))); | 295 | this, SLOT(commandStdout(OProcess*,char*,int))); |
296 | 296 | ||
297 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), | 297 | connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), |
298 | this, SLOT(commandStderr(OProcess *, char *, int))); | 298 | this, SLOT(commandStderr(OProcess*,char*,int))); |
299 | 299 | ||
300 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) | 300 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) |
301 | { | 301 | { |
302 | *proc << (*it).latin1(); | 302 | *proc << (*it).latin1(); |
303 | } | 303 | } |
304 | 304 | ||
305 | // Start the process going | 305 | // Start the process going |
306 | finished = false; | 306 | finished = false; |
307 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) | 307 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) |
308 | { | 308 | { |
309 | emit outputText( tr("Couldn't start ipkg process" ) ); | 309 | emit outputText( tr("Couldn't start ipkg process" ) ); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) | 313 | void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) |
314 | { | 314 | { |
315 | QString lineStr = buffer; | 315 | QString lineStr = buffer; |
316 | if ( lineStr[buflen-1] == '\n' ) | 316 | if ( lineStr[buflen-1] == '\n' ) |
317 | buflen --; | 317 | buflen --; |
318 | lineStr = lineStr.left( buflen ); | 318 | lineStr = lineStr.left( buflen ); |
319 | emit outputText( lineStr ); | 319 | emit outputText( lineStr ); |
320 | 320 | ||
321 | // check if we are installing dependant packages | 321 | // check if we are installing dependant packages |
322 | if ( option == "install" || option == "reinstall" ) | 322 | if ( option == "install" || option == "reinstall" ) |
323 | { | 323 | { |
324 | // Need to keep track of any dependant packages that get installed | 324 | // Need to keep track of any dependant packages that get installed |
325 | // so that we can create links to them as necessary | 325 | // so that we can create links to them as necessary |
326 | if ( lineStr.startsWith( "Installing " ) ) | 326 | if ( lineStr.startsWith( "Installing " ) ) |
327 | { | 327 | { |
328 | int start = lineStr.find( " " ) + 1; | 328 | int start = lineStr.find( " " ) + 1; |
329 | int end = lineStr.find( " ", start ); | 329 | int end = lineStr.find( " ", start ); |
330 | QString *package = new QString( lineStr.mid( start, end-start ) ); | 330 | QString *package = new QString( lineStr.mid( start, end-start ) ); |
331 | dependantPackages->append( package ); | 331 | dependantPackages->append( package ); |
332 | } | 332 | } |
333 | } | 333 | } |
334 | else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && | 334 | else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && |
335 | lineStr.find( "is depended upon by packages:" ) != -1 ) | 335 | lineStr.find( "is depended upon by packages:" ) != -1 ) |
336 | { | 336 | { |
337 | // Ipkg should send this to STDERR, but doesn't - so trap here | 337 | // Ipkg should send this to STDERR, but doesn't - so trap here |
338 | error = true; | 338 | error = true; |
339 | } | 339 | } |
340 | 340 | ||
341 | buffer[0] = '\0'; | 341 | buffer[0] = '\0'; |
342 | } | 342 | } |
343 | 343 | ||
344 | void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) | 344 | void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) |
345 | { | 345 | { |
346 | QString lineStr = buffer; | 346 | QString lineStr = buffer; |
347 | if ( lineStr[buflen-1] == '\n' ) | 347 | if ( lineStr[buflen-1] == '\n' ) |
348 | buflen --; | 348 | buflen --; |
349 | lineStr=lineStr.left( buflen ); | 349 | lineStr=lineStr.left( buflen ); |
350 | emit outputText( lineStr ); | 350 | emit outputText( lineStr ); |
351 | buffer[0] = '\0'; | 351 | buffer[0] = '\0'; |
352 | error = true; | 352 | error = true; |
353 | } | 353 | } |
354 | 354 | ||
355 | void Ipkg::processFinished() | 355 | void Ipkg::processFinished() |
356 | { | 356 | { |
357 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file | 357 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file |
358 | // to workaround an ipkg bug which stops reinstall to a different location | 358 | // to workaround an ipkg bug which stops reinstall to a different location |
359 | 359 | ||
360 | if ( !error && option == "remove" ) | 360 | if ( !error && option == "remove" ) |
361 | removeStatusEntry(); | 361 | removeStatusEntry(); |
362 | 362 | ||
363 | delete proc; | 363 | delete proc; |
364 | proc = 0; | 364 | proc = 0; |
365 | finished = true; | 365 | finished = true; |
366 | 366 | ||
367 | emit ipkgFinished(); | 367 | emit ipkgFinished(); |
368 | } | 368 | } |
369 | 369 | ||
370 | 370 | ||
371 | void Ipkg :: abort() | 371 | void Ipkg :: abort() |
372 | { | 372 | { |
373 | if ( proc ) | 373 | if ( proc ) |
374 | { | 374 | { |
375 | proc->kill(); | 375 | proc->kill(); |
376 | aborted = true; | 376 | aborted = true; |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) | 380 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) |
381 | { | 381 | { |
382 | if ( dest == "root" || dest == "/" ) | 382 | if ( dest == "root" || dest == "/" ) |
383 | return; | 383 | return; |
384 | 384 | ||
385 | qApp->processEvents(); | 385 | qApp->processEvents(); |
386 | QStringList *fileList = getList( packFileName, destDir ); | 386 | QStringList *fileList = getList( packFileName, destDir ); |
387 | qApp->processEvents(); | 387 | qApp->processEvents(); |
388 | processFileList( fileList, destDir ); | 388 | processFileList( fileList, destDir ); |
389 | delete fileList; | 389 | delete fileList; |
390 | } | 390 | } |
391 | 391 | ||
392 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) | 392 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) |
393 | { | 393 | { |
394 | QString packageFileDir = destDir; | 394 | QString packageFileDir = destDir; |
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 6f5c712..6b31cd1 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -7,402 +7,402 @@ | |||
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, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
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 "categoryfilterimpl.h" | 30 | #include "categoryfilterimpl.h" |
31 | #include "datamgr.h" | 31 | #include "datamgr.h" |
32 | #include "global.h" | 32 | #include "global.h" |
33 | #include "inputdlg.h" | 33 | #include "inputdlg.h" |
34 | #include "ipkg.h" | 34 | #include "ipkg.h" |
35 | #include "installdlgimpl.h" | 35 | #include "installdlgimpl.h" |
36 | #include "letterpushbutton.h" | 36 | #include "letterpushbutton.h" |
37 | #include "mainwin.h" | 37 | #include "mainwin.h" |
38 | #include "packagewin.h" | 38 | #include "packagewin.h" |
39 | #include "settingsimpl.h" | 39 | #include "settingsimpl.h" |
40 | #include "utils.h" | 40 | #include "utils.h" |
41 | 41 | ||
42 | /* OPIE */ | 42 | /* OPIE */ |
43 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
44 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | #include <qpe/resource.h> | 46 | #include <qpe/resource.h> |
47 | 47 | ||
48 | /* QT */ | 48 | /* QT */ |
49 | #include <qmenubar.h> | 49 | #include <qmenubar.h> |
50 | #include <qtoolbar.h> | 50 | #include <qtoolbar.h> |
51 | #include <qaction.h> | 51 | #include <qaction.h> |
52 | #include <qcombobox.h> | 52 | #include <qcombobox.h> |
53 | #include <qfile.h> | 53 | #include <qfile.h> |
54 | #include <qlabel.h> | 54 | #include <qlabel.h> |
55 | #include <qlayout.h> | 55 | #include <qlayout.h> |
56 | #include <qlineedit.h> | 56 | #include <qlineedit.h> |
57 | #include <qlistview.h> | 57 | #include <qlistview.h> |
58 | #include <qmenubar.h> | 58 | #include <qmenubar.h> |
59 | #include <qmessagebox.h> | 59 | #include <qmessagebox.h> |
60 | #include <qpopupmenu.h> | 60 | #include <qpopupmenu.h> |
61 | #include <qprogressbar.h> | 61 | #include <qprogressbar.h> |
62 | #include <qtimer.h> | 62 | #include <qtimer.h> |
63 | #include <qwhatsthis.h> | 63 | #include <qwhatsthis.h> |
64 | #include <qwidgetstack.h> | 64 | #include <qwidgetstack.h> |
65 | 65 | ||
66 | /* STD */ | 66 | /* STD */ |
67 | #include <linux/limits.h> | 67 | #include <linux/limits.h> |
68 | #include <unistd.h> | 68 | #include <unistd.h> |
69 | 69 | ||
70 | extern int compareVersions( const char *v1, const char *v2 ); | 70 | extern int compareVersions( const char *v1, const char *v2 ); |
71 | 71 | ||
72 | MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) | 72 | MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) |
73 | :QMainWindow( parent, name, fl || WStyle_ContextHelp ) | 73 | :QMainWindow( parent, name, fl || WStyle_ContextHelp ) |
74 | { | 74 | { |
75 | // Disable suspend mode | 75 | // Disable suspend mode |
76 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 76 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
77 | 77 | ||
78 | LOCAL_SERVER = QObject::tr( "Installed packages" ); | 78 | LOCAL_SERVER = QObject::tr( "Installed packages" ); |
79 | LOCAL_IPKGS = QObject::tr( "Local packages" ); | 79 | LOCAL_IPKGS = QObject::tr( "Local packages" ); |
80 | 80 | ||
81 | setCaption( tr( "AQPkg - Package Manager" ) ); | 81 | setCaption( tr( "AQPkg - Package Manager" ) ); |
82 | 82 | ||
83 | // Create UI widgets | 83 | // Create UI widgets |
84 | initMainWidget(); | 84 | initMainWidget(); |
85 | initProgressWidget(); | 85 | initProgressWidget(); |
86 | 86 | ||
87 | // Build menu and tool bars | 87 | // Build menu and tool bars |
88 | setToolBarsMovable( FALSE ); | 88 | setToolBarsMovable( FALSE ); |
89 | 89 | ||
90 | QToolBar *bar = new QToolBar( this ); | 90 | QToolBar *bar = new QToolBar( this ); |
91 | bar->setHorizontalStretchable( TRUE ); | 91 | bar->setHorizontalStretchable( TRUE ); |
92 | QMenuBar *mb = new QMenuBar( bar ); | 92 | QMenuBar *mb = new QMenuBar( bar ); |
93 | mb->setMargin( 0 ); | 93 | mb->setMargin( 0 ); |
94 | bar = new QToolBar( this ); | 94 | bar = new QToolBar( this ); |
95 | 95 | ||
96 | // Find toolbar | 96 | // Find toolbar |
97 | findBar = new QToolBar( this ); | 97 | findBar = new QToolBar( this ); |
98 | addToolBar( findBar, QMainWindow::Top, true ); | 98 | addToolBar( findBar, QMainWindow::Top, true ); |
99 | findBar->setHorizontalStretchable( true ); | 99 | findBar->setHorizontalStretchable( true ); |
100 | findEdit = new QLineEdit( findBar ); | 100 | findEdit = new QLineEdit( findBar ); |
101 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 101 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
102 | findBar->setStretchableWidget( findEdit ); | 102 | findBar->setStretchableWidget( findEdit ); |
103 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); | 103 | connect( findEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( findPackage(const QString&) ) ); |
104 | 104 | ||
105 | // Quick jump toolbar | 105 | // Quick jump toolbar |
106 | jumpBar = new QToolBar( this ); | 106 | jumpBar = new QToolBar( this ); |
107 | addToolBar( jumpBar, QMainWindow::Top, true ); | 107 | addToolBar( jumpBar, QMainWindow::Top, true ); |
108 | jumpBar->setHorizontalStretchable( true ); | 108 | jumpBar->setHorizontalStretchable( true ); |
109 | QWidget *w = new QWidget( jumpBar ); | 109 | QWidget *w = new QWidget( jumpBar ); |
110 | jumpBar->setStretchableWidget( w ); | 110 | jumpBar->setStretchableWidget( w ); |
111 | 111 | ||
112 | QGridLayout *layout = new QGridLayout( w ); | 112 | QGridLayout *layout = new QGridLayout( w ); |
113 | 113 | ||
114 | char text[2]; | 114 | char text[2]; |
115 | text[1] = '\0'; | 115 | text[1] = '\0'; |
116 | for ( int i = 0 ; i < 26 ; ++i ) | 116 | for ( int i = 0 ; i < 26 ; ++i ) |
117 | { | 117 | { |
118 | text[0] = 'A' + i; | 118 | text[0] = 'A' + i; |
119 | LetterPushButton *b = new LetterPushButton( text, w ); | 119 | LetterPushButton *b = new LetterPushButton( text, w ); |
120 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 120 | connect( b, SIGNAL( released(QString) ), this, SLOT( letterPushed(QString) ) ); |
121 | layout->addWidget( b, i / 13, i % 13); | 121 | layout->addWidget( b, i / 13, i % 13); |
122 | } | 122 | } |
123 | 123 | ||
124 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); | 124 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); |
125 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); | 125 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); |
126 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); | 126 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); |
127 | a->addTo( jumpBar ); | 127 | a->addTo( jumpBar ); |
128 | jumpBar->hide(); | 128 | jumpBar->hide(); |
129 | 129 | ||
130 | // Packages menu | 130 | // Packages menu |
131 | QPopupMenu *popup = new QPopupMenu( this ); | 131 | QPopupMenu *popup = new QPopupMenu( this ); |
132 | 132 | ||
133 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 133 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); |
134 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 134 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
135 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); | 135 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
136 | a->addTo( popup ); | 136 | a->addTo( popup ); |
137 | a->addTo( bar ); | 137 | a->addTo( bar ); |
138 | 138 | ||
139 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 139 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); |
140 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 140 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
141 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); | 141 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
142 | actionUpgrade->addTo( popup ); | 142 | actionUpgrade->addTo( popup ); |
143 | actionUpgrade->addTo( bar ); | 143 | actionUpgrade->addTo( bar ); |
144 | 144 | ||
145 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 145 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); |
146 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 146 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); |
147 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 147 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
148 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 148 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
149 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); | 149 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
150 | actionDownload->addTo( popup ); | 150 | actionDownload->addTo( popup ); |
151 | actionDownload->addTo( bar ); | 151 | actionDownload->addTo( bar ); |
152 | 152 | ||
153 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 153 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); |
154 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 154 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
155 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); | 155 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
156 | a->addTo( popup ); | 156 | a->addTo( popup ); |
157 | a->addTo( bar ); | 157 | a->addTo( bar ); |
158 | 158 | ||
159 | popup->insertSeparator(); | 159 | popup->insertSeparator(); |
160 | 160 | ||
161 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 161 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
162 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 162 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
163 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | 163 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); |
164 | a->addTo( popup ); | 164 | a->addTo( popup ); |
165 | mb->insertItem( tr( "Actions" ), popup ); | 165 | mb->insertItem( tr( "Actions" ), popup ); |
166 | 166 | ||
167 | // View menu | 167 | // View menu |
168 | popup = new QPopupMenu( this ); | 168 | popup = new QPopupMenu( this ); |
169 | 169 | ||
170 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 170 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
171 | actionUninstalled->setToggleAction( TRUE ); | 171 | actionUninstalled->setToggleAction( TRUE ); |
172 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 172 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
173 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 173 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
174 | actionUninstalled->addTo( popup ); | 174 | actionUninstalled->addTo( popup ); |
175 | 175 | ||
176 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 176 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
177 | actionInstalled->setToggleAction( TRUE ); | 177 | actionInstalled->setToggleAction( TRUE ); |
178 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 178 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
179 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 179 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
180 | actionInstalled->addTo( popup ); | 180 | actionInstalled->addTo( popup ); |
181 | 181 | ||
182 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 182 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
183 | actionUpdated->setToggleAction( TRUE ); | 183 | actionUpdated->setToggleAction( TRUE ); |
184 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 184 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
185 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | 185 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
186 | actionUpdated->addTo( popup ); | 186 | actionUpdated->addTo( popup ); |
187 | 187 | ||
188 | popup->insertSeparator(); | 188 | popup->insertSeparator(); |
189 | 189 | ||
190 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | 190 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); |
191 | actionFilter->setToggleAction( TRUE ); | 191 | actionFilter->setToggleAction( TRUE ); |
192 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | 192 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); |
193 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 193 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
194 | actionFilter->addTo( popup ); | 194 | actionFilter->addTo( popup ); |
195 | 195 | ||
196 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | 196 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); |
197 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); | 197 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); |
198 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
199 | a->addTo( popup ); | 199 | a->addTo( popup ); |
200 | 200 | ||
201 | popup->insertSeparator(); | 201 | popup->insertSeparator(); |
202 | 202 | ||
203 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 203 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
204 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 204 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
205 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 205 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
206 | a->addTo( popup ); | 206 | a->addTo( popup ); |
207 | 207 | ||
208 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 208 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
209 | actionFindNext->setEnabled( FALSE ); | 209 | actionFindNext->setEnabled( FALSE ); |
210 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 210 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
211 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); | 211 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
212 | actionFindNext->addTo( popup ); | 212 | actionFindNext->addTo( popup ); |
213 | actionFindNext->addTo( findBar ); | 213 | actionFindNext->addTo( findBar ); |
214 | 214 | ||
215 | 215 | ||
216 | popup->insertSeparator(); | 216 | popup->insertSeparator(); |
217 | 217 | ||
218 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); | 218 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); |
219 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); | 219 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); |
220 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); | 220 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); |
221 | a->addTo( popup ); | 221 | a->addTo( popup ); |
222 | 222 | ||
223 | mb->insertItem( tr( "View" ), popup ); | 223 | mb->insertItem( tr( "View" ), popup ); |
224 | 224 | ||
225 | // Finish find toolbar creation | 225 | // Finish find toolbar creation |
226 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 226 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
227 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 227 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
228 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 228 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
229 | a->addTo( findBar ); | 229 | a->addTo( findBar ); |
230 | findBar->hide(); | 230 | findBar->hide(); |
231 | 231 | ||
232 | // Create widget stack and add UI widgets | 232 | // Create widget stack and add UI widgets |
233 | stack = new QWidgetStack( this ); | 233 | stack = new QWidgetStack( this ); |
234 | stack->addWidget( progressWindow, 2 ); | 234 | stack->addWidget( progressWindow, 2 ); |
235 | stack->addWidget( networkPkgWindow, 1 ); | 235 | stack->addWidget( networkPkgWindow, 1 ); |
236 | setCentralWidget( stack ); | 236 | setCentralWidget( stack ); |
237 | stack->raiseWidget( progressWindow ); | 237 | stack->raiseWidget( progressWindow ); |
238 | 238 | ||
239 | // Delayed call to finish initialization | 239 | // Delayed call to finish initialization |
240 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 240 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
241 | } | 241 | } |
242 | 242 | ||
243 | MainWindow :: ~MainWindow() | 243 | MainWindow :: ~MainWindow() |
244 | { | 244 | { |
245 | delete mgr; | 245 | delete mgr; |
246 | 246 | ||
247 | // Reenable suspend mode | 247 | // Reenable suspend mode |
248 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 248 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
249 | } | 249 | } |
250 | 250 | ||
251 | void MainWindow :: initMainWidget() | 251 | void MainWindow :: initMainWidget() |
252 | { | 252 | { |
253 | networkPkgWindow = new QWidget( this ); | 253 | networkPkgWindow = new QWidget( this ); |
254 | 254 | ||
255 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 255 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
256 | 256 | ||
257 | serversList = new QComboBox( networkPkgWindow ); | 257 | serversList = new QComboBox( networkPkgWindow ); |
258 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); | 258 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); |
259 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 259 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
260 | 260 | ||
261 | installedIcon = Resource::loadPixmap( "installed" ); | 261 | installedIcon = Resource::loadPixmap( "installed" ); |
262 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 262 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
263 | 263 | ||
264 | packagesList = new QListView( networkPkgWindow ); | 264 | packagesList = new QListView( networkPkgWindow ); |
265 | packagesList->addColumn( tr( "Packages" ), 225 ); | 265 | packagesList->addColumn( tr( "Packages" ), 225 ); |
266 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 266 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); |
267 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); | 267 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); |
268 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), | 268 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), |
269 | this, SLOT(slotDisplayPackage(QListViewItem *)) ); | 269 | this, SLOT(slotDisplayPackage(QListViewItem*)) ); |
270 | 270 | ||
271 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 271 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
272 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 272 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
273 | hbox1->addWidget( l ); | 273 | hbox1->addWidget( l ); |
274 | hbox1->addWidget( serversList ); | 274 | hbox1->addWidget( serversList ); |
275 | 275 | ||
276 | vbox->addWidget( packagesList ); | 276 | vbox->addWidget( packagesList ); |
277 | 277 | ||
278 | downloadEnabled = TRUE; | 278 | downloadEnabled = TRUE; |
279 | } | 279 | } |
280 | 280 | ||
281 | void MainWindow :: initProgressWidget() | 281 | void MainWindow :: initProgressWidget() |
282 | { | 282 | { |
283 | progressWindow = new QWidget( this ); | 283 | progressWindow = new QWidget( this ); |
284 | 284 | ||
285 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 285 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
286 | 286 | ||
287 | m_status = new QLabel( progressWindow ); | 287 | m_status = new QLabel( progressWindow ); |
288 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 288 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
289 | layout->addWidget( m_status ); | 289 | layout->addWidget( m_status ); |
290 | 290 | ||
291 | m_progress = new QProgressBar( progressWindow ); | 291 | m_progress = new QProgressBar( progressWindow ); |
292 | layout->addWidget( m_progress ); | 292 | layout->addWidget( m_progress ); |
293 | } | 293 | } |
294 | 294 | ||
295 | void MainWindow :: init() | 295 | void MainWindow :: init() |
296 | { | 296 | { |
297 | #ifdef QWS | 297 | #ifdef QWS |
298 | // read download directory from config file | 298 | // read download directory from config file |
299 | Config cfg( "aqpkg" ); | 299 | Config cfg( "aqpkg" ); |
300 | cfg.setGroup( "settings" ); | 300 | cfg.setGroup( "settings" ); |
301 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 301 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
302 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 302 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
303 | 303 | ||
304 | #endif | 304 | #endif |
305 | 305 | ||
306 | stack->raiseWidget( progressWindow ); | 306 | stack->raiseWidget( progressWindow ); |
307 | 307 | ||
308 | mgr = new DataManager(); | 308 | mgr = new DataManager(); |
309 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 309 | connect( mgr, SIGNAL( progressSetSteps(int) ), this, SLOT( setProgressSteps(int) ) ); |
310 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 310 | connect( mgr, SIGNAL( progressSetMessage(const QString&) ), |
311 | this, SLOT( setProgressMessage( const QString & ) ) ); | 311 | this, SLOT( setProgressMessage(const QString&) ) ); |
312 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); | 312 | connect( mgr, SIGNAL( progressUpdate(int) ), this, SLOT( updateProgress(int) ) ); |
313 | mgr->loadServers(); | 313 | mgr->loadServers(); |
314 | 314 | ||
315 | showUninstalledPkgs = false; | 315 | showUninstalledPkgs = false; |
316 | showInstalledPkgs = false; | 316 | showInstalledPkgs = false; |
317 | showUpgradedPkgs = false; | 317 | showUpgradedPkgs = false; |
318 | categoryFilterEnabled = false; | 318 | categoryFilterEnabled = false; |
319 | 319 | ||
320 | updateData(); | 320 | updateData(); |
321 | 321 | ||
322 | stack->raiseWidget( networkPkgWindow ); | 322 | stack->raiseWidget( networkPkgWindow ); |
323 | } | 323 | } |
324 | 324 | ||
325 | void MainWindow :: setDocument( const QString &doc ) | 325 | void MainWindow :: setDocument( const QString &doc ) |
326 | { | 326 | { |
327 | // Remove path from package | 327 | // Remove path from package |
328 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 328 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
329 | 329 | ||
330 | // First select local server | 330 | // First select local server |
331 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 331 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
332 | { | 332 | { |
333 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 333 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
334 | { | 334 | { |
335 | serversList->setCurrentItem( i ); | 335 | serversList->setCurrentItem( i ); |
336 | break; | 336 | break; |
337 | } | 337 | } |
338 | } | 338 | } |
339 | serverSelected( 0 ); | 339 | serverSelected( 0 ); |
340 | 340 | ||
341 | // Now set the check box of the selected package | 341 | // Now set the check box of the selected package |
342 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 342 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
343 | item != 0 ; | 343 | item != 0 ; |
344 | item = (QCheckListItem *)item->nextSibling() ) | 344 | item = (QCheckListItem *)item->nextSibling() ) |
345 | { | 345 | { |
346 | if ( item->text().startsWith( package ) ) | 346 | if ( item->text().startsWith( package ) ) |
347 | { | 347 | { |
348 | item->setOn( true ); | 348 | item->setOn( true ); |
349 | break; | 349 | break; |
350 | } | 350 | } |
351 | } | 351 | } |
352 | } | 352 | } |
353 | 353 | ||
354 | void MainWindow :: displaySettings() | 354 | void MainWindow :: displaySettings() |
355 | { | 355 | { |
356 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 356 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
357 | if ( dlg->showDlg() ) | 357 | if ( dlg->showDlg() ) |
358 | { | 358 | { |
359 | stack->raiseWidget( progressWindow ); | 359 | stack->raiseWidget( progressWindow ); |
360 | updateData(); | 360 | updateData(); |
361 | stack->raiseWidget( networkPkgWindow ); | 361 | stack->raiseWidget( networkPkgWindow ); |
362 | } | 362 | } |
363 | delete dlg; | 363 | delete dlg; |
364 | } | 364 | } |
365 | 365 | ||
366 | void MainWindow :: closeEvent( QCloseEvent *e ) | 366 | void MainWindow :: closeEvent( QCloseEvent *e ) |
367 | { | 367 | { |
368 | // 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 |
369 | QWidget *widget = stack->visibleWidget(); | 369 | QWidget *widget = stack->visibleWidget(); |
370 | 370 | ||
371 | if ( widget != networkPkgWindow && widget != progressWindow ) | 371 | if ( widget != networkPkgWindow && widget != progressWindow ) |
372 | { | 372 | { |
373 | if ( widget ) delete widget; | 373 | if ( widget ) delete widget; |
374 | stack->raiseWidget( networkPkgWindow ); | 374 | stack->raiseWidget( networkPkgWindow ); |
375 | e->ignore(); | 375 | e->ignore(); |
376 | } | 376 | } |
377 | else | 377 | else |
378 | { | 378 | { |
379 | e->accept(); | 379 | e->accept(); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | void MainWindow :: displayFindBar() | 383 | void MainWindow :: displayFindBar() |
384 | { | 384 | { |
385 | findBar->show(); | 385 | findBar->show(); |
386 | findEdit->setFocus(); | 386 | findEdit->setFocus(); |
387 | } | 387 | } |
388 | 388 | ||
389 | void MainWindow :: displayJumpBar() | 389 | void MainWindow :: displayJumpBar() |
390 | { | 390 | { |
391 | jumpBar->show(); | 391 | jumpBar->show(); |
392 | } | 392 | } |
393 | 393 | ||
394 | void MainWindow :: repeatFind() | 394 | void MainWindow :: repeatFind() |
395 | { | 395 | { |
396 | searchForPackage( findEdit->text() ); | 396 | searchForPackage( findEdit->text() ); |
397 | } | 397 | } |
398 | 398 | ||
399 | void MainWindow :: findPackage( const QString &text ) | 399 | void MainWindow :: findPackage( const QString &text ) |
400 | { | 400 | { |
401 | actionFindNext->setEnabled( !text.isEmpty() ); | 401 | actionFindNext->setEnabled( !text.isEmpty() ); |
402 | searchForPackage( text ); | 402 | searchForPackage( text ); |
403 | } | 403 | } |
404 | 404 | ||
405 | void MainWindow :: hideFindBar() | 405 | void MainWindow :: hideFindBar() |
406 | { | 406 | { |
407 | findBar->hide(); | 407 | findBar->hide(); |
408 | } | 408 | } |
@@ -677,411 +677,411 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) | |||
677 | 677 | ||
678 | // If the local server, only display installed packages | 678 | // If the local server, only display installed packages |
679 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) | 679 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
680 | continue; | 680 | continue; |
681 | 681 | ||
682 | 682 | ||
683 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), | 683 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
684 | QCheckListItem::CheckBox ); | 684 | QCheckListItem::CheckBox ); |
685 | 685 | ||
686 | if ( package->isInstalled() ) | 686 | if ( package->isInstalled() ) |
687 | { | 687 | { |
688 | // 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 |
689 | // Otherwise, show installed icon | 689 | // Otherwise, show installed icon |
690 | if ( package->getNewVersionAvailable()) | 690 | if ( package->getNewVersionAvailable()) |
691 | { | 691 | { |
692 | 692 | ||
693 | item->setPixmap( 0, updatedIcon ); | 693 | item->setPixmap( 0, updatedIcon ); |
694 | } | 694 | } |
695 | else | 695 | else |
696 | { | 696 | { |
697 | item->setPixmap( 0, installedIcon ); | 697 | item->setPixmap( 0, installedIcon ); |
698 | } | 698 | } |
699 | } | 699 | } |
700 | else | 700 | else |
701 | { | 701 | { |
702 | item->setPixmap( 0, nullIcon ); | 702 | item->setPixmap( 0, nullIcon ); |
703 | } | 703 | } |
704 | 704 | ||
705 | packagesList->insertItem( item ); | 705 | packagesList->insertItem( item ); |
706 | } | 706 | } |
707 | 707 | ||
708 | // If the local server or the local ipkgs server disable the download button | 708 | // If the local server or the local ipkgs server disable the download button |
709 | if ( serverName == LOCAL_SERVER ) | 709 | if ( serverName == LOCAL_SERVER ) |
710 | { | 710 | { |
711 | downloadEnabled = TRUE; | 711 | downloadEnabled = TRUE; |
712 | actionUpgrade->setEnabled( FALSE ); | 712 | actionUpgrade->setEnabled( FALSE ); |
713 | } | 713 | } |
714 | else if ( serverName == LOCAL_IPKGS ) | 714 | else if ( serverName == LOCAL_IPKGS ) |
715 | { | 715 | { |
716 | downloadEnabled = FALSE; | 716 | downloadEnabled = FALSE; |
717 | actionUpgrade->setEnabled( FALSE ); | 717 | actionUpgrade->setEnabled( FALSE ); |
718 | } | 718 | } |
719 | else | 719 | else |
720 | { | 720 | { |
721 | downloadEnabled = TRUE; | 721 | downloadEnabled = TRUE; |
722 | actionUpgrade->setEnabled( TRUE ); | 722 | actionUpgrade->setEnabled( TRUE ); |
723 | } | 723 | } |
724 | enableDownload( downloadEnabled ); | 724 | enableDownload( downloadEnabled ); |
725 | 725 | ||
726 | // Display this widget once everything is done | 726 | // Display this widget once everything is done |
727 | if ( doProgress && raiseProgress ) | 727 | if ( doProgress && raiseProgress ) |
728 | { | 728 | { |
729 | stack->raiseWidget( networkPkgWindow ); | 729 | stack->raiseWidget( networkPkgWindow ); |
730 | } | 730 | } |
731 | } | 731 | } |
732 | 732 | ||
733 | void MainWindow :: searchForPackage( const QString &text ) | 733 | void MainWindow :: searchForPackage( const QString &text ) |
734 | { | 734 | { |
735 | if ( !text.isEmpty() ) | 735 | if ( !text.isEmpty() ) |
736 | { | 736 | { |
737 | // look through package list for text startng at current position | 737 | // look through package list for text startng at current position |
738 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 738 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
739 | 739 | ||
740 | if ( start == 0 ) | 740 | if ( start == 0 ) |
741 | start = (QCheckListItem *)packagesList->firstChild(); | 741 | start = (QCheckListItem *)packagesList->firstChild(); |
742 | 742 | ||
743 | for ( QCheckListItem *item = start; item != 0 ; | 743 | for ( QCheckListItem *item = start; item != 0 ; |
744 | item = (QCheckListItem *)item->nextSibling() ) | 744 | item = (QCheckListItem *)item->nextSibling() ) |
745 | { | 745 | { |
746 | if ( item->text().lower().find( text ) != -1 ) | 746 | if ( item->text().lower().find( text ) != -1 ) |
747 | { | 747 | { |
748 | packagesList->ensureItemVisible( item ); | 748 | packagesList->ensureItemVisible( item ); |
749 | packagesList->setCurrentItem( item ); | 749 | packagesList->setCurrentItem( item ); |
750 | break; | 750 | break; |
751 | } | 751 | } |
752 | } | 752 | } |
753 | } | 753 | } |
754 | } | 754 | } |
755 | 755 | ||
756 | void MainWindow :: updateServer() | 756 | void MainWindow :: updateServer() |
757 | { | 757 | { |
758 | QString serverName = serversList->currentText(); | 758 | QString serverName = serversList->currentText(); |
759 | 759 | ||
760 | // Update the current server | 760 | // Update the current server |
761 | // Display dialog | 761 | // Display dialog |
762 | 762 | ||
763 | // Disable buttons to stop silly people clicking lots on them :) | 763 | // Disable buttons to stop silly people clicking lots on them :) |
764 | 764 | ||
765 | // 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 |
766 | mgr->writeOutIpkgConf(); | 766 | mgr->writeOutIpkgConf(); |
767 | 767 | ||
768 | Ipkg *ipkg = new Ipkg; | 768 | Ipkg *ipkg = new Ipkg; |
769 | ipkg->setOption( "update" ); | 769 | ipkg->setOption( "update" ); |
770 | 770 | ||
771 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), | 771 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), |
772 | tr( "Update lists" ) ); | 772 | tr( "Update lists" ) ); |
773 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 773 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
774 | reloadDocuments = FALSE; | 774 | reloadDocuments = FALSE; |
775 | stack->addWidget( dlg, 3 ); | 775 | stack->addWidget( dlg, 3 ); |
776 | stack->raiseWidget( dlg ); | 776 | stack->raiseWidget( dlg ); |
777 | 777 | ||
778 | // delete progDlg; | 778 | // delete progDlg; |
779 | } | 779 | } |
780 | 780 | ||
781 | void MainWindow :: upgradePackages() | 781 | void MainWindow :: upgradePackages() |
782 | { | 782 | { |
783 | // We're gonna do an upgrade of all packages | 783 | // We're gonna do an upgrade of all packages |
784 | // First warn user that this isn't recommended | 784 | // First warn user that this isn't recommended |
785 | // TODO - ODevice???? | 785 | // TODO - ODevice???? |
786 | 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" ); |
787 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | 787 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, |
788 | QMessageBox::Yes, | 788 | QMessageBox::Yes, |
789 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 789 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
790 | 0, this ); | 790 | 0, this ); |
791 | warn.adjustSize(); | 791 | warn.adjustSize(); |
792 | 792 | ||
793 | if ( warn.exec() == QMessageBox::Yes ) | 793 | if ( warn.exec() == QMessageBox::Yes ) |
794 | { | 794 | { |
795 | // 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 |
796 | mgr->writeOutIpkgConf(); | 796 | mgr->writeOutIpkgConf(); |
797 | 797 | ||
798 | // Now run upgrade | 798 | // Now run upgrade |
799 | Ipkg *ipkg = new Ipkg; | 799 | Ipkg *ipkg = new Ipkg; |
800 | ipkg->setOption( "upgrade" ); | 800 | ipkg->setOption( "upgrade" ); |
801 | 801 | ||
802 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), | 802 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), |
803 | tr ( "Upgrade" ) ); | 803 | tr ( "Upgrade" ) ); |
804 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 804 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
805 | reloadDocuments = TRUE; | 805 | reloadDocuments = TRUE; |
806 | stack->addWidget( dlg, 3 ); | 806 | stack->addWidget( dlg, 3 ); |
807 | stack->raiseWidget( dlg ); | 807 | stack->raiseWidget( dlg ); |
808 | } | 808 | } |
809 | } | 809 | } |
810 | 810 | ||
811 | void MainWindow :: downloadPackage() | 811 | void MainWindow :: downloadPackage() |
812 | { | 812 | { |
813 | bool doUpdate = true; | 813 | bool doUpdate = true; |
814 | if ( downloadEnabled ) | 814 | if ( downloadEnabled ) |
815 | { | 815 | { |
816 | // See if any packages are selected | 816 | // See if any packages are selected |
817 | bool found = false; | 817 | bool found = false; |
818 | if ( serversList->currentText() != LOCAL_SERVER ) | 818 | if ( serversList->currentText() != LOCAL_SERVER ) |
819 | { | 819 | { |
820 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 820 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
821 | item != 0 && !found; | 821 | item != 0 && !found; |
822 | item = (QCheckListItem *)item->nextSibling() ) | 822 | item = (QCheckListItem *)item->nextSibling() ) |
823 | { | 823 | { |
824 | if ( item->isOn() ) | 824 | if ( item->isOn() ) |
825 | found = true; | 825 | found = true; |
826 | } | 826 | } |
827 | } | 827 | } |
828 | 828 | ||
829 | // 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 |
830 | // 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 | // and whether to install it | 831 | // and whether to install it |
832 | if ( found ) | 832 | if ( found ) |
833 | downloadSelectedPackages(); | 833 | downloadSelectedPackages(); |
834 | else | 834 | else |
835 | downloadRemotePackage(); | 835 | downloadRemotePackage(); |
836 | 836 | ||
837 | } | 837 | } |
838 | else | 838 | else |
839 | { | 839 | { |
840 | doUpdate = false; | 840 | doUpdate = false; |
841 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 841 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
842 | item != 0 ; | 842 | item != 0 ; |
843 | item = (QCheckListItem *)item->nextSibling() ) | 843 | item = (QCheckListItem *)item->nextSibling() ) |
844 | { | 844 | { |
845 | if ( item->isOn() ) | 845 | if ( item->isOn() ) |
846 | { | 846 | { |
847 | QString name = item->text(); | 847 | QString name = item->text(); |
848 | int pos = name.find( "*" ); | 848 | int pos = name.find( "*" ); |
849 | name.truncate( pos ); | 849 | name.truncate( pos ); |
850 | 850 | ||
851 | // if (there is a (installed), remove it | 851 | // if (there is a (installed), remove it |
852 | pos = name.find( "(installed)" ); | 852 | pos = name.find( "(installed)" ); |
853 | if ( pos > 0 ) | 853 | if ( pos > 0 ) |
854 | name.truncate( pos - 1 ); | 854 | name.truncate( pos - 1 ); |
855 | 855 | ||
856 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | 856 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); |
857 | 857 | ||
858 | QString msgtext; | 858 | QString msgtext; |
859 | 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() ); |
860 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | 860 | if ( QMessageBox::information( this, tr( "Are you sure?" ), |
861 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | 861 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) |
862 | { | 862 | { |
863 | doUpdate = true; | 863 | doUpdate = true; |
864 | QFile f( p->getFilename() ); | 864 | QFile f( p->getFilename() ); |
865 | f.remove(); | 865 | f.remove(); |
866 | } | 866 | } |
867 | } | 867 | } |
868 | } | 868 | } |
869 | } | 869 | } |
870 | 870 | ||
871 | if ( doUpdate ) | 871 | if ( doUpdate ) |
872 | { | 872 | { |
873 | reloadData( 0x0 ); | 873 | reloadData( 0x0 ); |
874 | } | 874 | } |
875 | } | 875 | } |
876 | 876 | ||
877 | void MainWindow :: downloadSelectedPackages() | 877 | void MainWindow :: downloadSelectedPackages() |
878 | { | 878 | { |
879 | // First, write out ipkg_conf file so that ipkg can use it | 879 | // First, write out ipkg_conf file so that ipkg can use it |
880 | mgr->writeOutIpkgConf(); | 880 | mgr->writeOutIpkgConf(); |
881 | 881 | ||
882 | // Display dialog to user asking where to download the files to | 882 | // Display dialog to user asking where to download the files to |
883 | bool ok = FALSE; | 883 | bool ok = FALSE; |
884 | QString dir = ""; | 884 | QString dir = ""; |
885 | #ifdef QWS | 885 | #ifdef QWS |
886 | // read download directory from config file | 886 | // read download directory from config file |
887 | Config cfg( "aqpkg" ); | 887 | Config cfg( "aqpkg" ); |
888 | cfg.setGroup( "settings" ); | 888 | cfg.setGroup( "settings" ); |
889 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 889 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
890 | #endif | 890 | #endif |
891 | 891 | ||
892 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 892 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
893 | if ( ok && !text.isEmpty() ) | 893 | if ( ok && !text.isEmpty() ) |
894 | dir = text; // user entered something and pressed ok | 894 | dir = text; // user entered something and pressed ok |
895 | else | 895 | else |
896 | return; // user entered nothing or pressed cancel | 896 | return; // user entered nothing or pressed cancel |
897 | 897 | ||
898 | #ifdef QWS | 898 | #ifdef QWS |
899 | // Store download directory in config file | 899 | // Store download directory in config file |
900 | cfg.writeEntry( "downloadDir", dir ); | 900 | cfg.writeEntry( "downloadDir", dir ); |
901 | #endif | 901 | #endif |
902 | 902 | ||
903 | // Get starting directory | 903 | // Get starting directory |
904 | char initDir[PATH_MAX]; | 904 | char initDir[PATH_MAX]; |
905 | getcwd( initDir, PATH_MAX ); | 905 | getcwd( initDir, PATH_MAX ); |
906 | 906 | ||
907 | // Download each package | 907 | // Download each package |
908 | Ipkg ipkg; | 908 | Ipkg ipkg; |
909 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 909 | connect( &ipkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
910 | 910 | ||
911 | ipkg.setOption( "download" ); | 911 | ipkg.setOption( "download" ); |
912 | ipkg.setRuntimeDirectory( dir ); | 912 | ipkg.setRuntimeDirectory( dir ); |
913 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 913 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
914 | item != 0 ; | 914 | item != 0 ; |
915 | item = (QCheckListItem *)item->nextSibling() ) | 915 | item = (QCheckListItem *)item->nextSibling() ) |
916 | { | 916 | { |
917 | if ( item->isOn() ) | 917 | if ( item->isOn() ) |
918 | { | 918 | { |
919 | ipkg.setPackage( item->text() ); | 919 | ipkg.setPackage( item->text() ); |
920 | ipkg.runIpkg( ); | 920 | ipkg.runIpkg( ); |
921 | } | 921 | } |
922 | } | 922 | } |
923 | } | 923 | } |
924 | 924 | ||
925 | void MainWindow :: downloadRemotePackage() | 925 | void MainWindow :: downloadRemotePackage() |
926 | { | 926 | { |
927 | // Display dialog | 927 | // Display dialog |
928 | bool ok; | 928 | bool ok; |
929 | 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 ); |
930 | if ( !ok || package.isEmpty() ) | 930 | if ( !ok || package.isEmpty() ) |
931 | return; | 931 | return; |
932 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 932 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
933 | // if ( dlg.exec() == QDialog::Rejected ) | 933 | // if ( dlg.exec() == QDialog::Rejected ) |
934 | // return; | 934 | // return; |
935 | 935 | ||
936 | // grab details from dialog | 936 | // grab details from dialog |
937 | // QString package = dlg.getPackageLocation(); | 937 | // QString package = dlg.getPackageLocation(); |
938 | 938 | ||
939 | InstallData *item = new InstallData(); | 939 | InstallData *item = new InstallData(); |
940 | item->option = "I"; | 940 | item->option = "I"; |
941 | item->packageName = package; | 941 | item->packageName = package; |
942 | QList<InstallData> workingPackages; | 942 | QList<InstallData> workingPackages; |
943 | workingPackages.setAutoDelete( TRUE ); | 943 | workingPackages.setAutoDelete( TRUE ); |
944 | workingPackages.append( item ); | 944 | workingPackages.append( item ); |
945 | 945 | ||
946 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); | 946 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); |
947 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 947 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
948 | reloadDocuments = TRUE; | 948 | reloadDocuments = TRUE; |
949 | stack->addWidget( dlg, 3 ); | 949 | stack->addWidget( dlg, 3 ); |
950 | stack->raiseWidget( dlg ); | 950 | stack->raiseWidget( dlg ); |
951 | } | 951 | } |
952 | 952 | ||
953 | 953 | ||
954 | void MainWindow :: applyChanges() | 954 | void MainWindow :: applyChanges() |
955 | { | 955 | { |
956 | stickyOption = ""; | 956 | stickyOption = ""; |
957 | 957 | ||
958 | // First, write out ipkg_conf file so that ipkg can use it | 958 | // First, write out ipkg_conf file so that ipkg can use it |
959 | mgr->writeOutIpkgConf(); | 959 | mgr->writeOutIpkgConf(); |
960 | 960 | ||
961 | // Now for each selected item | 961 | // Now for each selected item |
962 | // deal with it | 962 | // deal with it |
963 | 963 | ||
964 | QList<InstallData> workingPackages; | 964 | QList<InstallData> workingPackages; |
965 | workingPackages.setAutoDelete( TRUE ); | 965 | workingPackages.setAutoDelete( TRUE ); |
966 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 966 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
967 | item != 0 ; | 967 | item != 0 ; |
968 | item = (QCheckListItem *)item->nextSibling() ) | 968 | item = (QCheckListItem *)item->nextSibling() ) |
969 | { | 969 | { |
970 | if ( item->isOn() ) | 970 | if ( item->isOn() ) |
971 | { | 971 | { |
972 | InstallData *instdata = dealWithItem( item ); | 972 | InstallData *instdata = dealWithItem( item ); |
973 | if ( instdata ) | 973 | if ( instdata ) |
974 | workingPackages.append( instdata ); | 974 | workingPackages.append( instdata ); |
975 | else | 975 | else |
976 | return; | 976 | return; |
977 | } | 977 | } |
978 | } | 978 | } |
979 | 979 | ||
980 | if ( workingPackages.count() == 0 ) | 980 | if ( workingPackages.count() == 0 ) |
981 | { | 981 | { |
982 | // Nothing to do | 982 | // Nothing to do |
983 | QMessageBox::information( this, tr( "Nothing to do" ), | 983 | QMessageBox::information( this, tr( "Nothing to do" ), |
984 | tr( "No packages selected" ), tr( "OK" ) ); | 984 | tr( "No packages selected" ), tr( "OK" ) ); |
985 | 985 | ||
986 | return; | 986 | return; |
987 | } | 987 | } |
988 | 988 | ||
989 | // do the stuff | 989 | // do the stuff |
990 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); | 990 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); |
991 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 991 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
992 | reloadDocuments = TRUE; | 992 | reloadDocuments = TRUE; |
993 | stack->addWidget( dlg, 3 ); | 993 | stack->addWidget( dlg, 3 ); |
994 | stack->raiseWidget( dlg ); | 994 | stack->raiseWidget( dlg ); |
995 | } | 995 | } |
996 | 996 | ||
997 | // decide what to do - either remove, upgrade or install | 997 | // decide what to do - either remove, upgrade or install |
998 | // Current rules: | 998 | // Current rules: |
999 | // If not installed - install | 999 | // If not installed - install |
1000 | // If installed and different version available - upgrade | 1000 | // If installed and different version available - upgrade |
1001 | // If installed and version up to date - remove | 1001 | // If installed and version up to date - remove |
1002 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | 1002 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) |
1003 | { | 1003 | { |
1004 | QString name = item->text(); | 1004 | QString name = item->text(); |
1005 | 1005 | ||
1006 | // Get package | 1006 | // Get package |
1007 | Server *s = mgr->getServer( serversList->currentText() ); | 1007 | Server *s = mgr->getServer( serversList->currentText() ); |
1008 | Package *p = s->getPackage( name ); | 1008 | Package *p = s->getPackage( name ); |
1009 | 1009 | ||
1010 | // If the package has a filename then it is a local file | 1010 | // If the package has a filename then it is a local file |
1011 | if ( p->isPackageStoredLocally() ) | 1011 | if ( p->isPackageStoredLocally() ) |
1012 | name = p->getFilename(); | 1012 | name = p->getFilename(); |
1013 | 1013 | ||
1014 | QString option; | 1014 | QString option; |
1015 | QString dest = "root"; | 1015 | QString dest = "root"; |
1016 | if ( !p->isInstalled() ) | 1016 | if ( !p->isInstalled() ) |
1017 | { | 1017 | { |
1018 | InstallData *newitem = new InstallData(); | 1018 | InstallData *newitem = new InstallData(); |
1019 | newitem->option = "I"; | 1019 | newitem->option = "I"; |
1020 | newitem->packageName = name; | 1020 | newitem->packageName = name; |
1021 | return newitem; | 1021 | return newitem; |
1022 | } | 1022 | } |
1023 | else | 1023 | else |
1024 | { | 1024 | { |
1025 | InstallData *newitem = new InstallData(); | 1025 | InstallData *newitem = new InstallData(); |
1026 | newitem->option = "D"; | 1026 | newitem->option = "D"; |
1027 | // If local file, remove using package name, not filename | 1027 | // If local file, remove using package name, not filename |
1028 | if ( p->isPackageStoredLocally() ) | 1028 | if ( p->isPackageStoredLocally() ) |
1029 | name = item->text(); | 1029 | name = item->text(); |
1030 | 1030 | ||
1031 | if ( !p->isPackageStoredLocally() ) | 1031 | if ( !p->isPackageStoredLocally() ) |
1032 | newitem->packageName = p->getInstalledPackageName(); | 1032 | newitem->packageName = p->getInstalledPackageName(); |
1033 | else | 1033 | else |
1034 | newitem->packageName = name; | 1034 | newitem->packageName = name; |
1035 | 1035 | ||
1036 | if ( p->getInstalledTo() ) | 1036 | if ( p->getInstalledTo() ) |
1037 | { | 1037 | { |
1038 | newitem->destination = p->getInstalledTo(); | 1038 | newitem->destination = p->getInstalledTo(); |
1039 | } | 1039 | } |
1040 | else | 1040 | else |
1041 | { | 1041 | { |
1042 | newitem->destination = p->getLocalPackage()->getInstalledTo(); | 1042 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | // Now see if version is newer or not | 1045 | // Now see if version is newer or not |
1046 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 1046 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
1047 | 1047 | ||
1048 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 1048 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
1049 | if ( p->isPackageStoredLocally() && val == -1 ) | 1049 | if ( p->isPackageStoredLocally() && val == -1 ) |
1050 | val = 0; | 1050 | val = 0; |
1051 | 1051 | ||
1052 | if ( val == -2 ) | 1052 | if ( val == -2 ) |
1053 | { | 1053 | { |
1054 | // Error - should handle | 1054 | // Error - should handle |
1055 | } | 1055 | } |
1056 | else if ( val == -1 ) | 1056 | else if ( val == -1 ) |
1057 | { | 1057 | { |
1058 | // Version available is older - remove only | 1058 | // Version available is older - remove only |
1059 | newitem->option = "D"; | 1059 | newitem->option = "D"; |
1060 | // If local file, remove using package name, not filename | 1060 | // If local file, remove using package name, not filename |
1061 | if ( p->isPackageStoredLocally() ) | 1061 | if ( p->isPackageStoredLocally() ) |
1062 | name = item->text(); | 1062 | name = item->text(); |
1063 | } | 1063 | } |
1064 | else | 1064 | else |
1065 | { | 1065 | { |
1066 | QString caption; | 1066 | QString caption; |
1067 | QString text; | 1067 | QString text; |
1068 | QString secondButton; | 1068 | QString secondButton; |
1069 | QString secondOption; | 1069 | QString secondOption; |
1070 | if ( val == 0 ) | 1070 | if ( val == 0 ) |
1071 | { | 1071 | { |
1072 | // Version available is the same - option to remove or reinstall | 1072 | // Version available is the same - option to remove or reinstall |
1073 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1073 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1074 | text = tr( "Remove or ReInstall" ); | 1074 | text = tr( "Remove or ReInstall" ); |
1075 | secondButton = tr( "ReInstall" ); | 1075 | secondButton = tr( "ReInstall" ); |
1076 | secondOption = "R"; // Internal action code, do not translate | 1076 | secondOption = "R"; // Internal action code, do not translate |
1077 | } | 1077 | } |
1078 | else if ( val == 1 ) | 1078 | else if ( val == 1 ) |
1079 | { | 1079 | { |
1080 | // Version available is newer - option to remove or upgrade | 1080 | // Version available is newer - option to remove or upgrade |
1081 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1081 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1082 | text = tr( "Remove or Upgrade" ); | 1082 | text = tr( "Remove or Upgrade" ); |
1083 | secondButton = tr( "Upgrade" ); | 1083 | secondButton = tr( "Upgrade" ); |
1084 | secondOption = "U"; // Internal action code, do not translate | 1084 | secondOption = "U"; // Internal action code, do not translate |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | // Sticky option not implemented yet, but will eventually allow | 1087 | // Sticky option not implemented yet, but will eventually allow |
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index 6e9dd99..b9dbb6e 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -18,251 +18,251 @@ | |||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
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 "settingsimpl.h" | 30 | #include "settingsimpl.h" |
31 | #include "global.h" | 31 | #include "global.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/otabwidget.h> | 34 | #include <opie2/otabwidget.h> |
35 | #ifdef QWS | 35 | #ifdef QWS |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
38 | #endif | 38 | #endif |
39 | #include <qpe/qpeapplication.h> | 39 | #include <qpe/qpeapplication.h> |
40 | 40 | ||
41 | /* QT */ | 41 | /* QT */ |
42 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
43 | #include <qgroupbox.h> | 43 | #include <qgroupbox.h> |
44 | #include <qlabel.h> | 44 | #include <qlabel.h> |
45 | #include <qlayout.h> | 45 | #include <qlayout.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qlistbox.h> | 47 | #include <qlistbox.h> |
48 | #include <qpushbutton.h> | 48 | #include <qpushbutton.h> |
49 | 49 | ||
50 | /* STD */ | 50 | /* STD */ |
51 | #include <fstream> | 51 | #include <fstream> |
52 | #include <algorithm> | 52 | #include <algorithm> |
53 | using namespace std; | 53 | using namespace std; |
54 | 54 | ||
55 | 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 ) |
56 | : QDialog( parent, name, modal, fl ) | 56 | : QDialog( parent, name, modal, fl ) |
57 | { | 57 | { |
58 | setCaption( tr( "Configuration" ) ); | 58 | setCaption( tr( "Configuration" ) ); |
59 | 59 | ||
60 | // Setup layout to make everything pretty | 60 | // Setup layout to make everything pretty |
61 | QVBoxLayout *layout = new QVBoxLayout( this ); | 61 | QVBoxLayout *layout = new QVBoxLayout( this ); |
62 | layout->setMargin( 2 ); | 62 | layout->setMargin( 2 ); |
63 | layout->setSpacing( 4 ); | 63 | layout->setSpacing( 4 ); |
64 | 64 | ||
65 | // Setup tabs for all info | 65 | // Setup tabs for all info |
66 | Opie::OTabWidget *tabwidget = new Opie::OTabWidget( this ); | 66 | Opie::OTabWidget *tabwidget = new Opie::OTabWidget( this ); |
67 | layout->addWidget( tabwidget ); | 67 | layout->addWidget( tabwidget ); |
68 | 68 | ||
69 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); | 69 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); |
70 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); | 70 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); |
71 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); | 71 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); |
72 | tabwidget->setCurrentTab( tr( "Servers" ) ); | 72 | tabwidget->setCurrentTab( tr( "Servers" ) ); |
73 | 73 | ||
74 | dataMgr = dataManager; | 74 | dataMgr = dataManager; |
75 | setupData(); | 75 | setupData(); |
76 | changed = false; | 76 | changed = false; |
77 | newserver = false; | 77 | newserver = false; |
78 | newdestination = false; | 78 | newdestination = false; |
79 | } | 79 | } |
80 | 80 | ||
81 | SettingsImpl :: ~SettingsImpl() | 81 | SettingsImpl :: ~SettingsImpl() |
82 | { | 82 | { |
83 | } | 83 | } |
84 | 84 | ||
85 | bool SettingsImpl :: showDlg() | 85 | bool SettingsImpl :: showDlg() |
86 | { | 86 | { |
87 | QPEApplication::execDialog( this ); | 87 | QPEApplication::execDialog( this ); |
88 | if ( changed ) | 88 | if ( changed ) |
89 | dataMgr->writeOutIpkgConf(); | 89 | dataMgr->writeOutIpkgConf(); |
90 | 90 | ||
91 | return changed; | 91 | return changed; |
92 | } | 92 | } |
93 | 93 | ||
94 | QWidget *SettingsImpl :: initServerTab() | 94 | QWidget *SettingsImpl :: initServerTab() |
95 | { | 95 | { |
96 | QWidget *control = new QWidget( this ); | 96 | QWidget *control = new QWidget( this ); |
97 | 97 | ||
98 | QVBoxLayout *vb = new QVBoxLayout( control ); | 98 | QVBoxLayout *vb = new QVBoxLayout( control ); |
99 | 99 | ||
100 | QScrollView *sv = new QScrollView( control ); | 100 | QScrollView *sv = new QScrollView( control ); |
101 | vb->addWidget( sv, 0, 0 ); | 101 | vb->addWidget( sv, 0, 0 ); |
102 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 102 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
103 | sv->setFrameStyle( QFrame::NoFrame ); | 103 | sv->setFrameStyle( QFrame::NoFrame ); |
104 | 104 | ||
105 | QWidget *container = new QWidget( sv->viewport() ); | 105 | QWidget *container = new QWidget( sv->viewport() ); |
106 | sv->addChild( container ); | 106 | sv->addChild( container ); |
107 | 107 | ||
108 | QGridLayout *layout = new QGridLayout( container ); | 108 | QGridLayout *layout = new QGridLayout( container ); |
109 | layout->setSpacing( 2 ); | 109 | layout->setSpacing( 2 ); |
110 | layout->setMargin( 4 ); | 110 | layout->setMargin( 4 ); |
111 | 111 | ||
112 | servers = new QListBox( container ); | 112 | servers = new QListBox( container ); |
113 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 113 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
114 | connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) ); | 114 | connect( servers, SIGNAL( highlighted(int) ), this, SLOT( editServer(int) ) ); |
115 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); | 115 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); |
116 | 116 | ||
117 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 117 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
118 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); | 118 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); |
119 | layout->addWidget( btn, 1, 0 ); | 119 | layout->addWidget( btn, 1, 0 ); |
120 | 120 | ||
121 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 121 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
122 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); | 122 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); |
123 | layout->addWidget( btn, 1, 1 ); | 123 | layout->addWidget( btn, 1, 1 ); |
124 | 124 | ||
125 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); | 125 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); |
126 | grpbox->layout()->setSpacing( 2 ); | 126 | grpbox->layout()->setSpacing( 2 ); |
127 | grpbox->layout()->setMargin( 4 ); | 127 | grpbox->layout()->setMargin( 4 ); |
128 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 128 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
129 | 129 | ||
130 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 130 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
131 | 131 | ||
132 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 132 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
133 | grplayout->addWidget( label, 0, 0 ); | 133 | grplayout->addWidget( label, 0, 0 ); |
134 | servername = new QLineEdit( grpbox ); | 134 | servername = new QLineEdit( grpbox ); |
135 | grplayout->addWidget( servername, 0, 1 ); | 135 | grplayout->addWidget( servername, 0, 1 ); |
136 | 136 | ||
137 | label = new QLabel( tr( "Address:" ), grpbox ); | 137 | label = new QLabel( tr( "Address:" ), grpbox ); |
138 | grplayout->addWidget( label, 1, 0 ); | 138 | grplayout->addWidget( label, 1, 0 ); |
139 | serverurl = new QLineEdit( grpbox ); | 139 | serverurl = new QLineEdit( grpbox ); |
140 | grplayout->addWidget( serverurl, 1, 1 ); | 140 | grplayout->addWidget( serverurl, 1, 1 ); |
141 | 141 | ||
142 | active = new QCheckBox( tr( "Active Server" ), grpbox ); | 142 | active = new QCheckBox( tr( "Active Server" ), grpbox ); |
143 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); | 143 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); |
144 | 144 | ||
145 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 145 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
146 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); | 146 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); |
147 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 147 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
148 | 148 | ||
149 | return control; | 149 | return control; |
150 | } | 150 | } |
151 | 151 | ||
152 | QWidget *SettingsImpl :: initDestinationTab() | 152 | QWidget *SettingsImpl :: initDestinationTab() |
153 | { | 153 | { |
154 | QWidget *control = new QWidget( this ); | 154 | QWidget *control = new QWidget( this ); |
155 | 155 | ||
156 | QVBoxLayout *vb = new QVBoxLayout( control ); | 156 | QVBoxLayout *vb = new QVBoxLayout( control ); |
157 | 157 | ||
158 | QScrollView *sv = new QScrollView( control ); | 158 | QScrollView *sv = new QScrollView( control ); |
159 | vb->addWidget( sv, 0, 0 ); | 159 | vb->addWidget( sv, 0, 0 ); |
160 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 160 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
161 | sv->setFrameStyle( QFrame::NoFrame ); | 161 | sv->setFrameStyle( QFrame::NoFrame ); |
162 | 162 | ||
163 | QWidget *container = new QWidget( sv->viewport() ); | 163 | QWidget *container = new QWidget( sv->viewport() ); |
164 | sv->addChild( container ); | 164 | sv->addChild( container ); |
165 | 165 | ||
166 | QGridLayout *layout = new QGridLayout( container ); | 166 | QGridLayout *layout = new QGridLayout( container ); |
167 | layout->setSpacing( 2 ); | 167 | layout->setSpacing( 2 ); |
168 | layout->setMargin( 4 ); | 168 | layout->setMargin( 4 ); |
169 | 169 | ||
170 | destinations = new QListBox( container ); | 170 | destinations = new QListBox( container ); |
171 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 171 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
172 | connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); | 172 | connect( destinations, SIGNAL( highlighted(int) ), this, SLOT( editDestination(int) ) ); |
173 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); | 173 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); |
174 | 174 | ||
175 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 175 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); |
176 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); | 176 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); |
177 | layout->addWidget( btn, 1, 0 ); | 177 | layout->addWidget( btn, 1, 0 ); |
178 | 178 | ||
179 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 179 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); |
180 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); | 180 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); |
181 | layout->addWidget( btn, 1, 1 ); | 181 | layout->addWidget( btn, 1, 1 ); |
182 | 182 | ||
183 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); | 183 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); |
184 | grpbox->layout()->setSpacing( 2 ); | 184 | grpbox->layout()->setSpacing( 2 ); |
185 | grpbox->layout()->setMargin( 4 ); | 185 | grpbox->layout()->setMargin( 4 ); |
186 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 186 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
187 | 187 | ||
188 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 188 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
189 | 189 | ||
190 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 190 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
191 | grplayout->addWidget( label, 0, 0 ); | 191 | grplayout->addWidget( label, 0, 0 ); |
192 | destinationname = new QLineEdit( grpbox ); | 192 | destinationname = new QLineEdit( grpbox ); |
193 | grplayout->addWidget( destinationname, 0, 1 ); | 193 | grplayout->addWidget( destinationname, 0, 1 ); |
194 | 194 | ||
195 | label = new QLabel( tr( "Location:" ), grpbox ); | 195 | label = new QLabel( tr( "Location:" ), grpbox ); |
196 | grplayout->addWidget( label, 1, 0 ); | 196 | grplayout->addWidget( label, 1, 0 ); |
197 | destinationurl = new QLineEdit( grpbox ); | 197 | destinationurl = new QLineEdit( grpbox ); |
198 | grplayout->addWidget( destinationurl, 1, 1 ); | 198 | grplayout->addWidget( destinationurl, 1, 1 ); |
199 | 199 | ||
200 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); | 200 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); |
201 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); | 201 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); |
202 | 202 | ||
203 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 203 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); |
204 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); | 204 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); |
205 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 205 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
206 | 206 | ||
207 | return control; | 207 | return control; |
208 | } | 208 | } |
209 | 209 | ||
210 | QWidget *SettingsImpl :: initProxyTab() | 210 | QWidget *SettingsImpl :: initProxyTab() |
211 | { | 211 | { |
212 | QWidget *control = new QWidget( this ); | 212 | QWidget *control = new QWidget( this ); |
213 | 213 | ||
214 | QVBoxLayout *vb = new QVBoxLayout( control ); | 214 | QVBoxLayout *vb = new QVBoxLayout( control ); |
215 | 215 | ||
216 | QScrollView *sv = new QScrollView( control ); | 216 | QScrollView *sv = new QScrollView( control ); |
217 | vb->addWidget( sv, 0, 0 ); | 217 | vb->addWidget( sv, 0, 0 ); |
218 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 218 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
219 | sv->setFrameStyle( QFrame::NoFrame ); | 219 | sv->setFrameStyle( QFrame::NoFrame ); |
220 | 220 | ||
221 | QWidget *container = new QWidget( sv->viewport() ); | 221 | QWidget *container = new QWidget( sv->viewport() ); |
222 | sv->addChild( container ); | 222 | sv->addChild( container ); |
223 | 223 | ||
224 | QGridLayout *layout = new QGridLayout( container ); | 224 | QGridLayout *layout = new QGridLayout( container ); |
225 | layout->setSpacing( 2 ); | 225 | layout->setSpacing( 2 ); |
226 | layout->setMargin( 4 ); | 226 | layout->setMargin( 4 ); |
227 | 227 | ||
228 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); | 228 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); |
229 | grpbox->layout()->setSpacing( 2 ); | 229 | grpbox->layout()->setSpacing( 2 ); |
230 | grpbox->layout()->setMargin( 4 ); | 230 | grpbox->layout()->setMargin( 4 ); |
231 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); | 231 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); |
232 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 232 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
233 | txtHttpProxy = new QLineEdit( grpbox ); | 233 | txtHttpProxy = new QLineEdit( grpbox ); |
234 | grplayout->addWidget( txtHttpProxy ); | 234 | grplayout->addWidget( txtHttpProxy ); |
235 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 235 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
236 | grplayout->addWidget( chkHttpProxyEnabled ); | 236 | grplayout->addWidget( chkHttpProxyEnabled ); |
237 | 237 | ||
238 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 238 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
239 | grpbox->layout()->setSpacing( 2 ); | 239 | grpbox->layout()->setSpacing( 2 ); |
240 | grpbox->layout()->setMargin( 4 ); | 240 | grpbox->layout()->setMargin( 4 ); |
241 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); | 241 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); |
242 | grplayout = new QVBoxLayout( grpbox->layout() ); | 242 | grplayout = new QVBoxLayout( grpbox->layout() ); |
243 | txtFtpProxy = new QLineEdit( grpbox ); | 243 | txtFtpProxy = new QLineEdit( grpbox ); |
244 | grplayout->addWidget( txtFtpProxy ); | 244 | grplayout->addWidget( txtFtpProxy ); |
245 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 245 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
246 | grplayout->addWidget( chkFtpProxyEnabled ); | 246 | grplayout->addWidget( chkFtpProxyEnabled ); |
247 | 247 | ||
248 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 248 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
249 | layout->addWidget( label, 2, 0 ); | 249 | layout->addWidget( label, 2, 0 ); |
250 | txtUsername = new QLineEdit( container ); | 250 | txtUsername = new QLineEdit( container ); |
251 | layout->addWidget( txtUsername, 2, 1 ); | 251 | layout->addWidget( txtUsername, 2, 1 ); |
252 | 252 | ||
253 | label = new QLabel( tr( "Password:" ), container ); | 253 | label = new QLabel( tr( "Password:" ), container ); |
254 | layout->addWidget( label, 3, 0 ); | 254 | layout->addWidget( label, 3, 0 ); |
255 | txtPassword = new QLineEdit( container ); | 255 | txtPassword = new QLineEdit( container ); |
256 | layout->addWidget( txtPassword, 3, 1 ); | 256 | layout->addWidget( txtPassword, 3, 1 ); |
257 | 257 | ||
258 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); | 258 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); |
259 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); | 259 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); |
260 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); | 260 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); |
261 | 261 | ||
262 | return control; | 262 | return control; |
263 | } | 263 | } |
264 | 264 | ||
265 | void SettingsImpl :: setupData() | 265 | void SettingsImpl :: setupData() |
266 | { | 266 | { |
267 | // add servers | 267 | // add servers |
268 | QString serverName; | 268 | QString serverName; |
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 977c283..6b83bc9 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp | |||
@@ -1,151 +1,151 @@ | |||
1 | 1 | ||
2 | #include "backuprestore.h" | 2 | #include "backuprestore.h" |
3 | #include "errordialog.h" | 3 | #include "errordialog.h" |
4 | 4 | ||
5 | /* OPIE */ | 5 | /* OPIE */ |
6 | #include <opie2/ostorageinfo.h> | 6 | #include <opie2/ostorageinfo.h> |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | 8 | ||
9 | /* QT */ | 9 | /* QT */ |
10 | #include <qapplication.h> | 10 | #include <qapplication.h> |
11 | #include <qmultilineedit.h> | 11 | #include <qmultilineedit.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qfile.h> | 13 | #include <qfile.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlistview.h> | 15 | #include <qlistview.h> |
16 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
17 | #include <qheader.h> | 17 | #include <qheader.h> |
18 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qcombobox.h> | 21 | #include <qcombobox.h> |
22 | #include <qlist.h> | 22 | #include <qlist.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <qregexp.h> | 24 | #include <qregexp.h> |
25 | #include <qtextstream.h> | 25 | #include <qtextstream.h> |
26 | #include <qtextview.h> | 26 | #include <qtextview.h> |
27 | 27 | ||
28 | /* STD */ | 28 | /* STD */ |
29 | #include <errno.h> | 29 | #include <errno.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <unistd.h> | 31 | #include <unistd.h> |
32 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <dirent.h> | 33 | #include <dirent.h> |
34 | 34 | ||
35 | #define HEADER_NAME 0 | 35 | #define HEADER_NAME 0 |
36 | #define HEADER_BACKUP 1 | 36 | #define HEADER_BACKUP 1 |
37 | #define BACKUP_LOCATION 2 | 37 | #define BACKUP_LOCATION 2 |
38 | 38 | ||
39 | #define EXTENSION ".bck" | 39 | #define EXTENSION ".bck" |
40 | 40 | ||
41 | const QString tempFileName = "/tmp/backup.err"; | 41 | const QString tempFileName = "/tmp/backup.err"; |
42 | 42 | ||
43 | 43 | ||
44 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) | 44 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) |
45 | : BackupAndRestoreBase(parent, name, fl) | 45 | : BackupAndRestoreBase(parent, name, fl) |
46 | { | 46 | { |
47 | backupList->header()->hide(); | 47 | backupList->header()->hide(); |
48 | restoreList->header()->hide(); | 48 | restoreList->header()->hide(); |
49 | connect(backupButton, SIGNAL(clicked()), | 49 | connect(backupButton, SIGNAL(clicked()), |
50 | this, SLOT(backup())); | 50 | this, SLOT(backup())); |
51 | connect(restoreButton, SIGNAL(clicked()), | 51 | connect(restoreButton, SIGNAL(clicked()), |
52 | this, SLOT(restore())); | 52 | this, SLOT(restore())); |
53 | connect(backupList, SIGNAL(clicked( QListViewItem * )), | 53 | connect(backupList, SIGNAL(clicked(QListViewItem*)), |
54 | this, SLOT(selectItem(QListViewItem*))); | 54 | this, SLOT(selectItem(QListViewItem*))); |
55 | connect(restoreSource, SIGNAL(activated( int )), | 55 | connect(restoreSource, SIGNAL(activated(int)), |
56 | this, SLOT(sourceDirChanged(int))); | 56 | this, SLOT(sourceDirChanged(int))); |
57 | connect(updateList, SIGNAL(clicked()), | 57 | connect(updateList, SIGNAL(clicked()), |
58 | this, SLOT( fileListUpdate())); | 58 | this, SLOT( fileListUpdate())); |
59 | 59 | ||
60 | //add directorys for backing up | 60 | //add directorys for backing up |
61 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); | 61 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); |
62 | selectItem(applicationSettings); | 62 | selectItem(applicationSettings); |
63 | applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); | 63 | applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); |
64 | selectItem(applicationSettings); | 64 | selectItem(applicationSettings); |
65 | documents= new QListViewItem(backupList, "Documents", "", "Documents/"); | 65 | documents= new QListViewItem(backupList, "Documents", "", "Documents/"); |
66 | selectItem(documents); | 66 | selectItem(documents); |
67 | 67 | ||
68 | scanForApplicationSettings(); | 68 | scanForApplicationSettings(); |
69 | 69 | ||
70 | OStorageInfo storage; | 70 | OStorageInfo storage; |
71 | 71 | ||
72 | backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); | 72 | backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); |
73 | if ( storage.hasCf() ) | 73 | if ( storage.hasCf() ) |
74 | { | 74 | { |
75 | backupLocations.insert( "CF", storage.cfPath() ); | 75 | backupLocations.insert( "CF", storage.cfPath() ); |
76 | qDebug( "Cf Path: " + storage.cfPath() ); | 76 | qDebug( "Cf Path: " + storage.cfPath() ); |
77 | } | 77 | } |
78 | if ( storage.hasSd() ) | 78 | if ( storage.hasSd() ) |
79 | { | 79 | { |
80 | backupLocations.insert( "SD", storage.sdPath() ); | 80 | backupLocations.insert( "SD", storage.sdPath() ); |
81 | qDebug( " Sd Path: " + storage.sdPath() ); | 81 | qDebug( " Sd Path: " + storage.sdPath() ); |
82 | } | 82 | } |
83 | if ( storage.hasMmc() ) | 83 | if ( storage.hasMmc() ) |
84 | { | 84 | { |
85 | backupLocations.insert( "MMC", storage.mmcPath() ); | 85 | backupLocations.insert( "MMC", storage.mmcPath() ); |
86 | qDebug( "Mmc Path: " + storage.mmcPath() ); | 86 | qDebug( "Mmc Path: " + storage.mmcPath() ); |
87 | } | 87 | } |
88 | 88 | ||
89 | Config config("BackupAndRestore"); | 89 | Config config("BackupAndRestore"); |
90 | //read last locations | 90 | //read last locations |
91 | config.setGroup("LastLocation"); | 91 | config.setGroup("LastLocation"); |
92 | QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); | 92 | QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); |
93 | QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); | 93 | QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); |
94 | int locationIndex = 0; | 94 | int locationIndex = 0; |
95 | 95 | ||
96 | QMap<QString, QString>::Iterator it; | 96 | QMap<QString, QString>::Iterator it; |
97 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) | 97 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) |
98 | { | 98 | { |
99 | storeToLocation->insertItem(it.key()); | 99 | storeToLocation->insertItem(it.key()); |
100 | restoreSource->insertItem(it.key()); | 100 | restoreSource->insertItem(it.key()); |
101 | 101 | ||
102 | //check for last locations | 102 | //check for last locations |
103 | if ( it.key() == lastStoreLocation ) | 103 | if ( it.key() == lastStoreLocation ) |
104 | storeToLocation->setCurrentItem( locationIndex ); | 104 | storeToLocation->setCurrentItem( locationIndex ); |
105 | if ( it.key() == lastRestoreLocation ) | 105 | if ( it.key() == lastRestoreLocation ) |
106 | restoreSource->setCurrentItem( locationIndex ); | 106 | restoreSource->setCurrentItem( locationIndex ); |
107 | locationIndex++; | 107 | locationIndex++; |
108 | } | 108 | } |
109 | 109 | ||
110 | // Read the list of items to ignore. | 110 | // Read the list of items to ignore. |
111 | QList<QString> dontBackupList; | 111 | QList<QString> dontBackupList; |
112 | dontBackupList.setAutoDelete(true); | 112 | dontBackupList.setAutoDelete(true); |
113 | config.setGroup("DontBackup"); | 113 | config.setGroup("DontBackup"); |
114 | int total = config.readNumEntry("Total", 0); | 114 | int total = config.readNumEntry("Total", 0); |
115 | for(int i = 0; i < total; i++) | 115 | for(int i = 0; i < total; i++) |
116 | { | 116 | { |
117 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); | 117 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); |
118 | } | 118 | } |
119 | 119 | ||
120 | QList<QListViewItem> list; | 120 | QList<QListViewItem> list; |
121 | getAllItems(backupList->firstChild(), list); | 121 | getAllItems(backupList->firstChild(), list); |
122 | 122 | ||
123 | for(uint i = 0; i < list.count(); i++) | 123 | for(uint i = 0; i < list.count(); i++) |
124 | { | 124 | { |
125 | QString text = list.at(i)->text(HEADER_NAME); | 125 | QString text = list.at(i)->text(HEADER_NAME); |
126 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++) | 126 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++) |
127 | { | 127 | { |
128 | if(*dontBackupList.at(i2) == text) | 128 | if(*dontBackupList.at(i2) == text) |
129 | { | 129 | { |
130 | selectItem(list.at(i)); | 130 | selectItem(list.at(i)); |
131 | break; | 131 | break; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | QPEApplication::showWidget( this ); | 135 | QPEApplication::showWidget( this ); |
136 | } | 136 | } |
137 | 137 | ||
138 | BackupAndRestore::~BackupAndRestore() | 138 | BackupAndRestore::~BackupAndRestore() |
139 | { | 139 | { |
140 | QList<QListViewItem> list; | 140 | QList<QListViewItem> list; |
141 | getAllItems(backupList->firstChild(), list); | 141 | getAllItems(backupList->firstChild(), list); |
142 | 142 | ||
143 | Config config("BackupAndRestore"); | 143 | Config config("BackupAndRestore"); |
144 | config.setGroup("DontBackup"); | 144 | config.setGroup("DontBackup"); |
145 | config.clearGroup(); | 145 | config.clearGroup(); |
146 | 146 | ||
147 | int count = 0; | 147 | int count = 0; |
148 | for(uint i = 0; i < list.count(); i++) | 148 | for(uint i = 0; i < list.count(); i++) |
149 | { | 149 | { |
150 | if(list.at(i)->text(HEADER_BACKUP) == "") | 150 | if(list.at(i)->text(HEADER_BACKUP) == "") |
151 | { | 151 | { |
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp index 7df41d4..c995d6e 100644 --- a/noncore/settings/netsystemtime/mainwindow.cpp +++ b/noncore/settings/netsystemtime/mainwindow.cpp | |||
@@ -1,199 +1,199 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> | 4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "timetabwidget.h" | 30 | #include "timetabwidget.h" |
31 | #include "formattabwidget.h" | 31 | #include "formattabwidget.h" |
32 | #include "settingstabwidget.h" | 32 | #include "settingstabwidget.h" |
33 | #include "ntptabwidget.h" | 33 | #include "ntptabwidget.h" |
34 | #include "predicttabwidget.h" | 34 | #include "predicttabwidget.h" |
35 | 35 | ||
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/datebookdb.h> | 37 | #include <qpe/datebookdb.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include <qpe/qpedialog.h> | 39 | #include <qpe/qpedialog.h> |
40 | 40 | ||
41 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 41 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | #include <qlayout.h> | 45 | #include <qlayout.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qsocket.h> | 47 | #include <qsocket.h> |
48 | #include <qstring.h> | 48 | #include <qstring.h> |
49 | #include <qtimer.h> | 49 | #include <qtimer.h> |
50 | 50 | ||
51 | MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) | 51 | MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) |
52 | : QDialog( 0x0, 0x0, TRUE, 0 ) | 52 | : QDialog( 0x0, 0x0, TRUE, 0 ) |
53 | { | 53 | { |
54 | setCaption( tr( "SystemTime" ) ); | 54 | setCaption( tr( "SystemTime" ) ); |
55 | 55 | ||
56 | QVBoxLayout *layout = new QVBoxLayout( this ); | 56 | QVBoxLayout *layout = new QVBoxLayout( this ); |
57 | layout->setMargin( 2 ); | 57 | layout->setMargin( 2 ); |
58 | layout->setSpacing( 4 ); | 58 | layout->setSpacing( 4 ); |
59 | 59 | ||
60 | // Create main tabbed control | 60 | // Create main tabbed control |
61 | mainWidget = new OTabWidget( this ); | 61 | mainWidget = new OTabWidget( this ); |
62 | 62 | ||
63 | // Default object pointers to null | 63 | // Default object pointers to null |
64 | ntpProcess = 0x0; | 64 | ntpProcess = 0x0; |
65 | ntpTab = 0x0; | 65 | ntpTab = 0x0; |
66 | 66 | ||
67 | // Add tab widgets | 67 | // Add tab widgets |
68 | mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); | 68 | mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); |
69 | mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); | 69 | mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); |
70 | mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); | 70 | mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); |
71 | mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); | 71 | mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); |
72 | Config config( "ntp" ); | 72 | Config config( "ntp" ); |
73 | config.setGroup( "settings" ); | 73 | config.setGroup( "settings" ); |
74 | slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); | 74 | slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); |
75 | slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); | 75 | slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); |
76 | 76 | ||
77 | mainWidget->setCurrentTab( tr( "Time" ) ); | 77 | mainWidget->setCurrentTab( tr( "Time" ) ); |
78 | layout->addWidget( mainWidget ); | 78 | layout->addWidget( mainWidget ); |
79 | 79 | ||
80 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 80 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
81 | this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) ); | 81 | this, SLOT(slotQCopReceive(const QCString&,const QByteArray&)) ); |
82 | 82 | ||
83 | 83 | ||
84 | // Create NTP socket | 84 | // Create NTP socket |
85 | ntpSock = new QSocket( this ); | 85 | ntpSock = new QSocket( this ); |
86 | connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); | 86 | connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); |
87 | slotProbeNTPServer(); | 87 | slotProbeNTPServer(); |
88 | 88 | ||
89 | // Create timer for automatic time lookups | 89 | // Create timer for automatic time lookups |
90 | ntpTimer = new QTimer( this ); | 90 | ntpTimer = new QTimer( this ); |
91 | 91 | ||
92 | // Connect everything together | 92 | // Connect everything together |
93 | connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); | 93 | connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); |
94 | connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) ); | 94 | connect( timeTab, SIGNAL(tzChanged(const QString&)), predictTab, SLOT(slotTZChanged(const QString&)) ); |
95 | connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); | 95 | connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); |
96 | connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime( int )) ); | 96 | connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime(int)) ); |
97 | connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat &)), | 97 | connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat&)), |
98 | timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) ); | 98 | timeTab, SLOT(slotDateFormatChanged(const DateFormat&)) ); |
99 | connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); | 99 | connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); |
100 | connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); | 100 | connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); |
101 | connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); | 101 | connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); |
102 | connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); | 102 | connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); |
103 | connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) ); | 103 | connect( predictTab, SIGNAL(setTime(const QDateTime&)), this, SLOT(slotSetTime(const QDateTime&)) ); |
104 | 104 | ||
105 | // Do initial time server check | 105 | // Do initial time server check |
106 | slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); | 106 | slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); |
107 | slotCheckNtp( -1 ); | 107 | slotCheckNtp( -1 ); |
108 | 108 | ||
109 | // Display app | 109 | // Display app |
110 | //showMaximized(); | 110 | //showMaximized(); |
111 | (void)new QPEDialogListener(this); | 111 | (void)new QPEDialogListener(this); |
112 | } | 112 | } |
113 | 113 | ||
114 | MainWindow::~MainWindow() | 114 | MainWindow::~MainWindow() |
115 | { | 115 | { |
116 | if ( ntpProcess ) | 116 | if ( ntpProcess ) |
117 | delete ntpProcess; | 117 | delete ntpProcess; |
118 | } | 118 | } |
119 | 119 | ||
120 | void MainWindow::accept() | 120 | void MainWindow::accept() |
121 | { | 121 | { |
122 | // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) | 122 | // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) |
123 | { | 123 | { |
124 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 124 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
125 | disableScreenSaver << 0 << 0 << 0; | 125 | disableScreenSaver << 0 << 0 << 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | // Update the systemtime | 128 | // Update the systemtime |
129 | timeTab->saveSettings( TRUE ); | 129 | timeTab->saveSettings( TRUE ); |
130 | 130 | ||
131 | // Save format options | 131 | // Save format options |
132 | formatTab->saveSettings( TRUE ); | 132 | formatTab->saveSettings( TRUE ); |
133 | 133 | ||
134 | // Save settings options | 134 | // Save settings options |
135 | settingsTab->saveSettings(); | 135 | settingsTab->saveSettings(); |
136 | 136 | ||
137 | // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better | 137 | // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better |
138 | // grip on itself (example re-trigger alarms for when we travel back in time). | 138 | // grip on itself (example re-trigger alarms for when we travel back in time). |
139 | DateBookDB db; | 139 | DateBookDB db; |
140 | 140 | ||
141 | // Turn back on the screensaver | 141 | // Turn back on the screensaver |
142 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 142 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
143 | enableScreenSaver << -1 << -1 << -1; | 143 | enableScreenSaver << -1 << -1 << -1; |
144 | 144 | ||
145 | // Exit app | 145 | // Exit app |
146 | qApp->quit(); | 146 | qApp->quit(); |
147 | } | 147 | } |
148 | 148 | ||
149 | void MainWindow::reject() | 149 | void MainWindow::reject() |
150 | { | 150 | { |
151 | // Reset time settings | 151 | // Reset time settings |
152 | timeTab->saveSettings( FALSE ); | 152 | timeTab->saveSettings( FALSE ); |
153 | 153 | ||
154 | // Send notifications but do not save settings | 154 | // Send notifications but do not save settings |
155 | formatTab->saveSettings( FALSE ); | 155 | formatTab->saveSettings( FALSE ); |
156 | 156 | ||
157 | // Exit app | 157 | // Exit app |
158 | qApp->quit(); | 158 | qApp->quit(); |
159 | } | 159 | } |
160 | 160 | ||
161 | void MainWindow::runNTP() | 161 | void MainWindow::runNTP() |
162 | { | 162 | { |
163 | if ( !ntpDelayElapsed() && ntpInteractive ) | 163 | if ( !ntpDelayElapsed() && ntpInteractive ) |
164 | { | 164 | { |
165 | QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) ); | 165 | QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) ); |
166 | 166 | ||
167 | switch ( | 167 | switch ( |
168 | QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) | 168 | QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) |
169 | ) | 169 | ) |
170 | { | 170 | { |
171 | case QMessageBox::Yes: break; | 171 | case QMessageBox::Yes: break; |
172 | case QMessageBox::No: return; | 172 | case QMessageBox::No: return; |
173 | default: return; | 173 | default: return; |
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | QString srv = settingsTab->ntpServer(); | 177 | QString srv = settingsTab->ntpServer(); |
178 | 178 | ||
179 | // Send information to time server tab if enabled | 179 | // Send information to time server tab if enabled |
180 | if ( ntpTabEnabled ) | 180 | if ( ntpTabEnabled ) |
181 | { | 181 | { |
182 | ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); | 182 | ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); |
183 | QString output = tr( "Running:\nntpdate " ); | 183 | QString output = tr( "Running:\nntpdate " ); |
184 | output.append( srv ); | 184 | output.append( srv ); |
185 | ntpTab->addNtpOutput( output ); | 185 | ntpTab->addNtpOutput( output ); |
186 | } | 186 | } |
187 | 187 | ||
188 | if ( !ntpProcess ) | 188 | if ( !ntpProcess ) |
189 | { | 189 | { |
190 | ntpProcess = new OProcess(); | 190 | ntpProcess = new OProcess(); |
191 | connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), | 191 | connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), |
192 | this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); | 192 | this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); |
193 | connect( ntpProcess, SIGNAL(processExited(OProcess*)), | 193 | connect( ntpProcess, SIGNAL(processExited(OProcess*)), |
194 | this, SLOT(slotNtpFinished(OProcess*)) ); | 194 | this, SLOT(slotNtpFinished(OProcess*)) ); |
195 | } | 195 | } |
196 | 196 | ||
197 | else | 197 | else |
198 | ntpProcess->clearArguments(); | 198 | ntpProcess->clearArguments(); |
199 | 199 | ||
diff --git a/noncore/settings/netsystemtime/settingstabwidget.cpp b/noncore/settings/netsystemtime/settingstabwidget.cpp index 2a7e28d..ad80e05 100644 --- a/noncore/settings/netsystemtime/settingstabwidget.cpp +++ b/noncore/settings/netsystemtime/settingstabwidget.cpp | |||
@@ -1,159 +1,159 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> | 4 | .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "settingstabwidget.h" | 29 | #include "settingstabwidget.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | 33 | ||
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qlayout.h> | 37 | #include <qlayout.h> |
38 | #include <qscrollview.h> | 38 | #include <qscrollview.h> |
39 | #include <qspinbox.h> | 39 | #include <qspinbox.h> |
40 | 40 | ||
41 | SettingsTabWidget::SettingsTabWidget( QWidget *parent ) | 41 | SettingsTabWidget::SettingsTabWidget( QWidget *parent ) |
42 | : QWidget( parent, 0x0, 0 ) | 42 | : QWidget( parent, 0x0, 0 ) |
43 | { | 43 | { |
44 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); | 44 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); |
45 | QScrollView *sv = new QScrollView( this ); | 45 | QScrollView *sv = new QScrollView( this ); |
46 | tmpvb->addWidget( sv, 0, 0 ); | 46 | tmpvb->addWidget( sv, 0, 0 ); |
47 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 47 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
48 | sv->setFrameStyle( QFrame::NoFrame ); | 48 | sv->setFrameStyle( QFrame::NoFrame ); |
49 | QWidget *container = new QWidget( sv->viewport() ); | 49 | QWidget *container = new QWidget( sv->viewport() ); |
50 | sv->addChild( container ); | 50 | sv->addChild( container ); |
51 | 51 | ||
52 | QGridLayout *layout = new QGridLayout( container ); | 52 | QGridLayout *layout = new QGridLayout( container ); |
53 | layout->setMargin( 2 ); | 53 | layout->setMargin( 2 ); |
54 | layout->setSpacing( 4 ); | 54 | layout->setSpacing( 4 ); |
55 | 55 | ||
56 | // Time server selector | 56 | // Time server selector |
57 | layout->addWidget( new QLabel( tr( "Time server" ), container ), 0, 0 ); | 57 | layout->addWidget( new QLabel( tr( "Time server" ), container ), 0, 0 ); |
58 | cbTimeServer = new QComboBox( TRUE, container ); | 58 | cbTimeServer = new QComboBox( TRUE, container ); |
59 | layout->addMultiCellWidget( cbTimeServer, 1, 1, 0, 1 ); | 59 | layout->addMultiCellWidget( cbTimeServer, 1, 1, 0, 1 ); |
60 | 60 | ||
61 | // Lookup delay selector | 61 | // Lookup delay selector |
62 | layout->addWidget( new QLabel( tr( "minutes between time updates" ), container ), 2, 1 ); | 62 | layout->addWidget( new QLabel( tr( "minutes between time updates" ), container ), 2, 1 ); |
63 | sbNtpDelay = new QSpinBox( 1, 9999999, 1, container ); | 63 | sbNtpDelay = new QSpinBox( 1, 9999999, 1, container ); |
64 | sbNtpDelay->setWrapping( TRUE ); | 64 | sbNtpDelay->setWrapping( TRUE ); |
65 | sbNtpDelay->setMaximumWidth( 50 ); | 65 | sbNtpDelay->setMaximumWidth( 50 ); |
66 | connect( sbNtpDelay, SIGNAL(valueChanged(int)), this, SIGNAL(ntpDelayChanged(int)) ); | 66 | connect( sbNtpDelay, SIGNAL(valueChanged(int)), this, SIGNAL(ntpDelayChanged(int)) ); |
67 | layout->addWidget( sbNtpDelay, 2, 0 ); | 67 | layout->addWidget( sbNtpDelay, 2, 0 ); |
68 | 68 | ||
69 | // Prediction delay selector | 69 | // Prediction delay selector |
70 | layout->addWidget( new QLabel( tr( "minutes between prediction updates" ), container ), 3, 1 ); | 70 | layout->addWidget( new QLabel( tr( "minutes between prediction updates" ), container ), 3, 1 ); |
71 | sbPredictDelay = new QSpinBox( 42, 9999999, 1, container ); | 71 | sbPredictDelay = new QSpinBox( 42, 9999999, 1, container ); |
72 | sbPredictDelay->setWrapping( TRUE ); | 72 | sbPredictDelay->setWrapping( TRUE ); |
73 | sbPredictDelay->setMaximumWidth( 50 ); | 73 | sbPredictDelay->setMaximumWidth( 50 ); |
74 | layout->addWidget( sbPredictDelay, 3, 0 ); | 74 | layout->addWidget( sbPredictDelay, 3, 0 ); |
75 | 75 | ||
76 | // Space filler | 76 | // Space filler |
77 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 ); | 77 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 ); |
78 | 78 | ||
79 | // Display time server information selector | 79 | // Display time server information selector |
80 | chNtpTab = new QCheckBox( tr( "Display time server information" ), container ); | 80 | chNtpTab = new QCheckBox( tr( "Display time server information" ), container ); |
81 | connect( chNtpTab, SIGNAL( toggled( bool ) ), this, SIGNAL( displayNTPTab( bool ) ) ); | 81 | connect( chNtpTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayNTPTab(bool) ) ); |
82 | layout->addMultiCellWidget( chNtpTab, 5, 5, 0, 1 ); | 82 | layout->addMultiCellWidget( chNtpTab, 5, 5, 0, 1 ); |
83 | 83 | ||
84 | // Display time prediction information selector | 84 | // Display time prediction information selector |
85 | chPredictTab = new QCheckBox( tr( "Display time prediction information" ), container ); | 85 | chPredictTab = new QCheckBox( tr( "Display time prediction information" ), container ); |
86 | connect( chPredictTab, SIGNAL( toggled( bool ) ), this, SIGNAL( displayPredictTab( bool ) ) ); | 86 | connect( chPredictTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayPredictTab(bool) ) ); |
87 | layout->addMultiCellWidget( chPredictTab, 6, 6, 0, 1 ); | 87 | layout->addMultiCellWidget( chPredictTab, 6, 6, 0, 1 ); |
88 | 88 | ||
89 | // Space filler | 89 | // Space filler |
90 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); | 90 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); |
91 | 91 | ||
92 | // Initialize values | 92 | // Initialize values |
93 | QString ntpSrvsFile = QPEApplication::qpeDir(); | 93 | QString ntpSrvsFile = QPEApplication::qpeDir(); |
94 | ntpSrvsFile.append( "etc/ntpservers" ); | 94 | ntpSrvsFile.append( "etc/ntpservers" ); |
95 | Config ntpSrvs( ntpSrvsFile, Config::File ); | 95 | Config ntpSrvs( ntpSrvsFile, Config::File ); |
96 | ntpSrvs.setGroup( "servers" ); | 96 | ntpSrvs.setGroup( "servers" ); |
97 | int srvCount = ntpSrvs.readNumEntry( "count", 0 ); | 97 | int srvCount = ntpSrvs.readNumEntry( "count", 0 ); |
98 | for ( int i = 0; i < srvCount; i++ ) | 98 | for ( int i = 0; i < srvCount; i++ ) |
99 | { | 99 | { |
100 | ntpSrvs.setGroup( QString::number( i ) ); | 100 | ntpSrvs.setGroup( QString::number( i ) ); |
101 | cbTimeServer->insertItem( ntpSrvs.readEntry( "name" ) ); | 101 | cbTimeServer->insertItem( ntpSrvs.readEntry( "name" ) ); |
102 | } | 102 | } |
103 | if ( srvCount==0 ) | 103 | if ( srvCount==0 ) |
104 | cbTimeServer->insertItem( "time.fu-berlin.de" ); | 104 | cbTimeServer->insertItem( "time.fu-berlin.de" ); |
105 | 105 | ||
106 | Config config( "ntp" ); | 106 | Config config( "ntp" ); |
107 | config.setGroup( "settings" ); | 107 | config.setGroup( "settings" ); |
108 | sbPredictDelay->setValue( config.readNumEntry( "minLookupDiff", 720 ) ); | 108 | sbPredictDelay->setValue( config.readNumEntry( "minLookupDiff", 720 ) ); |
109 | sbNtpDelay->setValue( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); | 109 | sbNtpDelay->setValue( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); |
110 | cbTimeServer->setCurrentItem( config.readNumEntry( "ntpServer", 0 ) ); | 110 | cbTimeServer->setCurrentItem( config.readNumEntry( "ntpServer", 0 ) ); |
111 | chNtpTab->setChecked( config.readBoolEntry( "displayNtpTab", FALSE ) ); | 111 | chNtpTab->setChecked( config.readBoolEntry( "displayNtpTab", FALSE ) ); |
112 | chPredictTab->setChecked( config.readBoolEntry( "displayPredictTab", FALSE ) ); | 112 | chPredictTab->setChecked( config.readBoolEntry( "displayPredictTab", FALSE ) ); |
113 | } | 113 | } |
114 | 114 | ||
115 | SettingsTabWidget::~SettingsTabWidget() | 115 | SettingsTabWidget::~SettingsTabWidget() |
116 | { | 116 | { |
117 | } | 117 | } |
118 | 118 | ||
119 | void SettingsTabWidget::saveSettings() | 119 | void SettingsTabWidget::saveSettings() |
120 | { | 120 | { |
121 | int srvCount = cbTimeServer->count(); | 121 | int srvCount = cbTimeServer->count(); |
122 | bool serversChanged = TRUE; | 122 | bool serversChanged = TRUE; |
123 | int curSrv = cbTimeServer->currentItem(); | 123 | int curSrv = cbTimeServer->currentItem(); |
124 | QString edit = cbTimeServer->currentText(); | 124 | QString edit = cbTimeServer->currentText(); |
125 | for ( int i = 0; i < srvCount; i++ ) | 125 | for ( int i = 0; i < srvCount; i++ ) |
126 | { | 126 | { |
127 | if ( edit == cbTimeServer->text( i ) ) | 127 | if ( edit == cbTimeServer->text( i ) ) |
128 | serversChanged = FALSE; | 128 | serversChanged = FALSE; |
129 | } | 129 | } |
130 | if ( serversChanged ) | 130 | if ( serversChanged ) |
131 | { | 131 | { |
132 | QString ntpSrvsFile = QPEApplication::qpeDir(); | 132 | QString ntpSrvsFile = QPEApplication::qpeDir(); |
133 | ntpSrvsFile.append( "etc/ntpservers" ); | 133 | ntpSrvsFile.append( "etc/ntpservers" ); |
134 | Config ntpSrvs( ntpSrvsFile, Config::File ); | 134 | Config ntpSrvs( ntpSrvsFile, Config::File ); |
135 | ntpSrvs.setGroup( "servers" ); | 135 | ntpSrvs.setGroup( "servers" ); |
136 | ntpSrvs.writeEntry( "count", ++srvCount ); | 136 | ntpSrvs.writeEntry( "count", ++srvCount ); |
137 | ntpSrvs.setGroup( "0" ); | 137 | ntpSrvs.setGroup( "0" ); |
138 | ntpSrvs.writeEntry( "name", edit ); | 138 | ntpSrvs.writeEntry( "name", edit ); |
139 | curSrv = 0; | 139 | curSrv = 0; |
140 | for ( int i = 1; i < srvCount; i++ ) | 140 | for ( int i = 1; i < srvCount; i++ ) |
141 | { | 141 | { |
142 | // qDebug( "ntpSrvs[%i/%i]=%s", i, srvCount, cbTimeServer->text( i ).latin1() ); | 142 | // qDebug( "ntpSrvs[%i/%i]=%s", i, srvCount, cbTimeServer->text( i ).latin1() ); |
143 | ntpSrvs.setGroup( QString::number( i ) ); | 143 | ntpSrvs.setGroup( QString::number( i ) ); |
144 | ntpSrvs.writeEntry( "name", cbTimeServer->text( i-1 ) ); | 144 | ntpSrvs.writeEntry( "name", cbTimeServer->text( i-1 ) ); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | Config config( "ntp", Config::User ); | 147 | Config config( "ntp", Config::User ); |
148 | config.setGroup( "settings" ); | 148 | config.setGroup( "settings" ); |
149 | config.writeEntry( "ntpServer", curSrv ); | 149 | config.writeEntry( "ntpServer", curSrv ); |
150 | config.writeEntry( "minLookupDiff", sbPredictDelay->value() ); | 150 | config.writeEntry( "minLookupDiff", sbPredictDelay->value() ); |
151 | config.writeEntry( "ntpRefreshFreq", sbNtpDelay->value() ); | 151 | config.writeEntry( "ntpRefreshFreq", sbNtpDelay->value() ); |
152 | config.writeEntry( "displayNtpTab", chNtpTab->isChecked() ); | 152 | config.writeEntry( "displayNtpTab", chNtpTab->isChecked() ); |
153 | config.writeEntry( "displayPredictTab", chPredictTab->isChecked() ); | 153 | config.writeEntry( "displayPredictTab", chPredictTab->isChecked() ); |
154 | } | 154 | } |
155 | 155 | ||
156 | QString SettingsTabWidget::ntpServer() | 156 | QString SettingsTabWidget::ntpServer() |
157 | { | 157 | { |
158 | return cbTimeServer->currentText(); | 158 | return cbTimeServer->currentText(); |
159 | } | 159 | } |
diff --git a/noncore/settings/netsystemtime/timetabwidget.cpp b/noncore/settings/netsystemtime/timetabwidget.cpp index 6f24462..1ea460e 100644 --- a/noncore/settings/netsystemtime/timetabwidget.cpp +++ b/noncore/settings/netsystemtime/timetabwidget.cpp | |||
@@ -9,193 +9,193 @@ | |||
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "timetabwidget.h" | 29 | #include "timetabwidget.h" |
30 | 30 | ||
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/datebookmonth.h> | 32 | #include <qpe/datebookmonth.h> |
33 | #include <qpe/global.h> | 33 | #include <qpe/global.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/tzselect.h> | 35 | #include <qpe/tzselect.h> |
36 | 36 | ||
37 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 37 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
38 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qdatetime.h> | 42 | #include <qdatetime.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qlabel.h> | 44 | #include <qlabel.h> |
45 | #include <qlayout.h> | 45 | #include <qlayout.h> |
46 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
47 | #include <qscrollview.h> | 47 | #include <qscrollview.h> |
48 | #include <qspinbox.h> | 48 | #include <qspinbox.h> |
49 | 49 | ||
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include <sys/time.h> | 51 | #include <sys/time.h> |
52 | 52 | ||
53 | static const int ValueAM = 0; | 53 | static const int ValueAM = 0; |
54 | static const int ValuePM = 1; | 54 | static const int ValuePM = 1; |
55 | 55 | ||
56 | TimeTabWidget::TimeTabWidget( QWidget *parent ) | 56 | TimeTabWidget::TimeTabWidget( QWidget *parent ) |
57 | : QWidget( parent, 0x0, 0 ) | 57 | : QWidget( parent, 0x0, 0 ) |
58 | { | 58 | { |
59 | // Synchronize HW clock to systemtime | 59 | // Synchronize HW clock to systemtime |
60 | // This app will update systemtime | 60 | // This app will update systemtime |
61 | // - if Cancel is clicked, will reset systemtime to HW clock's time | 61 | // - if Cancel is clicked, will reset systemtime to HW clock's time |
62 | // - if Ok is clicked, will leave systemtime as is | 62 | // - if Ok is clicked, will leave systemtime as is |
63 | system("/sbin/hwclock --systohc --utc"); | 63 | system("/sbin/hwclock --systohc --utc"); |
64 | 64 | ||
65 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); | 65 | QVBoxLayout *tmpvb = new QVBoxLayout( this ); |
66 | QScrollView *sv = new QScrollView( this ); | 66 | QScrollView *sv = new QScrollView( this ); |
67 | tmpvb->addWidget( sv, 0, 0 ); | 67 | tmpvb->addWidget( sv, 0, 0 ); |
68 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 68 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
69 | sv->setFrameStyle( QFrame::NoFrame ); | 69 | sv->setFrameStyle( QFrame::NoFrame ); |
70 | QWidget *container = new QWidget( sv->viewport() ); | 70 | QWidget *container = new QWidget( sv->viewport() ); |
71 | sv->addChild( container ); | 71 | sv->addChild( container ); |
72 | 72 | ||
73 | QGridLayout *layout = new QGridLayout( container ); | 73 | QGridLayout *layout = new QGridLayout( container ); |
74 | layout->setMargin( 2 ); | 74 | layout->setMargin( 2 ); |
75 | layout->setSpacing( 4 ); | 75 | layout->setSpacing( 4 ); |
76 | 76 | ||
77 | // Hours | 77 | // Hours |
78 | layout->addMultiCellWidget( new QLabel( tr( "Hour" ), container ), 1, 1, 0, 1 ); | 78 | layout->addMultiCellWidget( new QLabel( tr( "Hour" ), container ), 1, 1, 0, 1 ); |
79 | sbHour = new QSpinBox( container ); | 79 | sbHour = new QSpinBox( container ); |
80 | sbHour->setWrapping( TRUE ); | 80 | sbHour->setWrapping( TRUE ); |
81 | layout->addMultiCellWidget( sbHour, 2, 2, 0, 1 ); | 81 | layout->addMultiCellWidget( sbHour, 2, 2, 0, 1 ); |
82 | 82 | ||
83 | // Minutes | 83 | // Minutes |
84 | layout->addMultiCellWidget( new QLabel( tr( "Minute" ), container ), 1, 1, 2, 3 ); | 84 | layout->addMultiCellWidget( new QLabel( tr( "Minute" ), container ), 1, 1, 2, 3 ); |
85 | sbMin = new QSpinBox( container ); | 85 | sbMin = new QSpinBox( container ); |
86 | sbMin->setWrapping( TRUE ); | 86 | sbMin->setWrapping( TRUE ); |
87 | sbMin->setMinValue( 0 ); | 87 | sbMin->setMinValue( 0 ); |
88 | sbMin->setMaxValue( 59 ); | 88 | sbMin->setMaxValue( 59 ); |
89 | layout->addMultiCellWidget( sbMin, 2, 2, 2, 3 ); | 89 | layout->addMultiCellWidget( sbMin, 2, 2, 2, 3 ); |
90 | 90 | ||
91 | // AM/PM | 91 | // AM/PM |
92 | cbAmpm = new QComboBox( container ); | 92 | cbAmpm = new QComboBox( container ); |
93 | cbAmpm->insertItem( tr( "AM" ), ValueAM ); | 93 | cbAmpm->insertItem( tr( "AM" ), ValueAM ); |
94 | cbAmpm->insertItem( tr( "PM" ), ValuePM ); | 94 | cbAmpm->insertItem( tr( "PM" ), ValuePM ); |
95 | layout->addMultiCellWidget( cbAmpm, 2, 2, 4, 5 ); | 95 | layout->addMultiCellWidget( cbAmpm, 2, 2, 4, 5 ); |
96 | 96 | ||
97 | // Date | 97 | // Date |
98 | layout->addWidget( new QLabel( tr( "Date" ), container ), 4, 0 ); | 98 | layout->addWidget( new QLabel( tr( "Date" ), container ), 4, 0 ); |
99 | btnDate = new DateButton( TRUE, container ); | 99 | btnDate = new DateButton( TRUE, container ); |
100 | layout->addMultiCellWidget( btnDate, 4, 4, 1, 5 ); | 100 | layout->addMultiCellWidget( btnDate, 4, 4, 1, 5 ); |
101 | 101 | ||
102 | // Timezone | 102 | // Timezone |
103 | layout->addMultiCellWidget( new QLabel( tr( "Time zone" ), container ), 6, 6, 0, 1 ); | 103 | layout->addMultiCellWidget( new QLabel( tr( "Time zone" ), container ), 6, 6, 0, 1 ); |
104 | selTimeZone = new TimeZoneSelector( container ); | 104 | selTimeZone = new TimeZoneSelector( container ); |
105 | connect( selTimeZone, SIGNAL(signalNewTz(const QString &)), this, SLOT(slotTZChanged(const QString &)) ); | 105 | connect( selTimeZone, SIGNAL(signalNewTz(const QString&)), this, SLOT(slotTZChanged(const QString&)) ); |
106 | layout->addMultiCellWidget( selTimeZone, 6, 6, 2, 5 ); | 106 | layout->addMultiCellWidget( selTimeZone, 6, 6, 2, 5 ); |
107 | 107 | ||
108 | // Space filler | 108 | // Space filler |
109 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); | 109 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); |
110 | 110 | ||
111 | // Set NTP time button | 111 | // Set NTP time button |
112 | QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), | 112 | QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), |
113 | tr( "Get time from the network" ), container ); | 113 | tr( "Get time from the network" ), container ); |
114 | connect( pb, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); | 114 | connect( pb, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); |
115 | layout->addMultiCellWidget( pb, 8, 8, 0, 5 ); | 115 | layout->addMultiCellWidget( pb, 8, 8, 0, 5 ); |
116 | 116 | ||
117 | // Set predicted time button | 117 | // Set predicted time button |
118 | pb = new QPushButton( Resource::loadPixmap( "netsystemtime/predicttab" ), tr( "Set predicted time" ), | 118 | pb = new QPushButton( Resource::loadPixmap( "netsystemtime/predicttab" ), tr( "Set predicted time" ), |
119 | container ); | 119 | container ); |
120 | connect( pb, SIGNAL(clicked()), this, SIGNAL(getPredictedTime()) ); | 120 | connect( pb, SIGNAL(clicked()), this, SIGNAL(getPredictedTime()) ); |
121 | layout->addMultiCellWidget( pb, 9, 9, 0, 5 ); | 121 | layout->addMultiCellWidget( pb, 9, 9, 0, 5 ); |
122 | 122 | ||
123 | // Space filler at bottom of widget | 123 | // Space filler at bottom of widget |
124 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 10, 0 ); | 124 | layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 10, 0 ); |
125 | 125 | ||
126 | // Initialize values | 126 | // Initialize values |
127 | Config config( "locale" ); | 127 | Config config( "locale" ); |
128 | config.setGroup( "Location" ); | 128 | config.setGroup( "Location" ); |
129 | selTimeZone->setCurrentZone( config.readEntry( "Timezone", "America/New_York" ) ); | 129 | selTimeZone->setCurrentZone( config.readEntry( "Timezone", "America/New_York" ) ); |
130 | use12HourTime = FALSE; | 130 | use12HourTime = FALSE; |
131 | setDateTime( QDateTime::currentDateTime() ); | 131 | setDateTime( QDateTime::currentDateTime() ); |
132 | } | 132 | } |
133 | 133 | ||
134 | TimeTabWidget::~TimeTabWidget() | 134 | TimeTabWidget::~TimeTabWidget() |
135 | { | 135 | { |
136 | } | 136 | } |
137 | 137 | ||
138 | void TimeTabWidget::saveSettings( bool commit ) | 138 | void TimeTabWidget::saveSettings( bool commit ) |
139 | { | 139 | { |
140 | if ( commit ) | 140 | if ( commit ) |
141 | { | 141 | { |
142 | // Set timezone and announce to world | 142 | // Set timezone and announce to world |
143 | QString tz = selTimeZone->currentZone(); | 143 | QString tz = selTimeZone->currentZone(); |
144 | Config config("locale"); | 144 | Config config("locale"); |
145 | config.setGroup( "Location" ); | 145 | config.setGroup( "Location" ); |
146 | config.writeEntry( "Timezone", tz ); | 146 | config.writeEntry( "Timezone", tz ); |
147 | setenv( "TZ", tz, 1 ); | 147 | setenv( "TZ", tz, 1 ); |
148 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 148 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
149 | setTimeZone << tz; | 149 | setTimeZone << tz; |
150 | 150 | ||
151 | // If controls have a valid date & time, update systemtime | 151 | // If controls have a valid date & time, update systemtime |
152 | int hour = sbHour->value(); | 152 | int hour = sbHour->value(); |
153 | if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) | 153 | if ( use12HourTime && cbAmpm->currentItem() == ValuePM ) |
154 | hour += 12; | 154 | hour += 12; |
155 | QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) ); | 155 | QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) ); |
156 | setSystemTime( dt ); | 156 | setSystemTime( dt ); |
157 | } | 157 | } |
158 | else | 158 | else |
159 | { | 159 | { |
160 | // Reset systemtime to hardware clock (i.e. undo any changes made by this app) | 160 | // Reset systemtime to hardware clock (i.e. undo any changes made by this app) |
161 | system("/sbin/hwclock --hctosys --utc"); | 161 | system("/sbin/hwclock --hctosys --utc"); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | void TimeTabWidget::setDateTime( const QDateTime &dt ) | 165 | void TimeTabWidget::setDateTime( const QDateTime &dt ) |
166 | { | 166 | { |
167 | // Set time | 167 | // Set time |
168 | QTime t = dt.time(); | 168 | QTime t = dt.time(); |
169 | if( use12HourTime ) | 169 | if( use12HourTime ) |
170 | { | 170 | { |
171 | int show_hour = t.hour(); | 171 | int show_hour = t.hour(); |
172 | if ( t.hour() >= 12 ) | 172 | if ( t.hour() >= 12 ) |
173 | { | 173 | { |
174 | show_hour -= 12; | 174 | show_hour -= 12; |
175 | cbAmpm->setCurrentItem( ValuePM ); | 175 | cbAmpm->setCurrentItem( ValuePM ); |
176 | } | 176 | } |
177 | else | 177 | else |
178 | { | 178 | { |
179 | cbAmpm->setCurrentItem( ValueAM ); | 179 | cbAmpm->setCurrentItem( ValueAM ); |
180 | } | 180 | } |
181 | if ( show_hour == 0 ) | 181 | if ( show_hour == 0 ) |
182 | show_hour = 12; | 182 | show_hour = 12; |
183 | sbHour->setValue( show_hour ); | 183 | sbHour->setValue( show_hour ); |
184 | } | 184 | } |
185 | else | 185 | else |
186 | { | 186 | { |
187 | sbHour->setValue( t.hour() ); | 187 | sbHour->setValue( t.hour() ); |
188 | } | 188 | } |
189 | sbMin->setValue( t.minute() ); | 189 | sbMin->setValue( t.minute() ); |
190 | 190 | ||
191 | // Set date | 191 | // Set date |
192 | btnDate->setDate( dt.date() ); | 192 | btnDate->setDate( dt.date() ); |
193 | } | 193 | } |
194 | 194 | ||
195 | void TimeTabWidget::setSystemTime( const QDateTime &dt ) | 195 | void TimeTabWidget::setSystemTime( const QDateTime &dt ) |
196 | { | 196 | { |
197 | // Set system clock | 197 | // Set system clock |
198 | if ( dt.isValid() ) | 198 | if ( dt.isValid() ) |
199 | { | 199 | { |
200 | struct timeval myTv; | 200 | struct timeval myTv; |
201 | int t = TimeConversion::toUTC( dt ); | 201 | int t = TimeConversion::toUTC( dt ); |
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp index 698dfd3..ff65424 100644 --- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp | |||
@@ -1,104 +1,104 @@ | |||
1 | 1 | ||
2 | #include "interfaceinformationimp.h" | 2 | #include "interfaceinformationimp.h" |
3 | #include "interfaceadvanced.h" | 3 | #include "interfaceadvanced.h" |
4 | 4 | ||
5 | /* OPIE */ | 5 | /* OPIE */ |
6 | #include <qpe/config.h> | 6 | #include <qpe/config.h> |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | 8 | ||
9 | /* QT */ | 9 | /* QT */ |
10 | #include <qcheckbox.h> | 10 | #include <qcheckbox.h> |
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | #include <qlabel.h> | 12 | #include <qlabel.h> |
13 | #include <qgroupbox.h> | 13 | #include <qgroupbox.h> |
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | 15 | ||
16 | 16 | ||
17 | #ifdef QWS | 17 | #ifdef QWS |
18 | #else | 18 | #else |
19 | #define showMaximized show | 19 | #define showMaximized show |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Constructor for the InterfaceInformationImp class. This class pretty much | 23 | * Constructor for the InterfaceInformationImp class. This class pretty much |
24 | * just display's information about the interface that is passed to it. | 24 | * just display's information about the interface that is passed to it. |
25 | */ | 25 | */ |
26 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i) | 26 | InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i) |
27 | { | 27 | { |
28 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 28 | connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); |
29 | connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &))); | 29 | connect(i, SIGNAL(updateMessage(const QString&)), this, SLOT(showMessage(const QString&))); |
30 | updateInterface(interface); | 30 | updateInterface(interface); |
31 | connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); | 31 | connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); |
32 | connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); | 32 | connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); |
33 | connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); | 33 | connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); |
34 | connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); | 34 | connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); |
35 | connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); | 35 | connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); |
36 | Config cfg("networksettings", Config::User); | 36 | Config cfg("networksettings", Config::User); |
37 | cfg.setGroup("interface"); | 37 | cfg.setGroup("interface"); |
38 | CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) ); | 38 | CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) ); |
39 | } | 39 | } |
40 | 40 | ||
41 | InterfaceInformationImp::~InterfaceInformationImp() | 41 | InterfaceInformationImp::~InterfaceInformationImp() |
42 | { | 42 | { |
43 | Config cfg("networksettings", Config::User); | 43 | Config cfg("networksettings", Config::User); |
44 | cfg.setGroup("interface"); | 44 | cfg.setGroup("interface"); |
45 | cfg.writeEntry("silent", CheckBoxSilent->isChecked() ); | 45 | cfg.writeEntry("silent", CheckBoxSilent->isChecked() ); |
46 | } | 46 | } |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Update the interface information and buttons. | 49 | * Update the interface information and buttons. |
50 | * @param Intarface *i the interface to update (should be the one we already | 50 | * @param Intarface *i the interface to update (should be the one we already |
51 | * know about). | 51 | * know about). |
52 | */ | 52 | */ |
53 | void InterfaceInformationImp::updateInterface(Interface *) | 53 | void InterfaceInformationImp::updateInterface(Interface *) |
54 | { | 54 | { |
55 | if(interface->getStatus()) | 55 | if(interface->getStatus()) |
56 | { | 56 | { |
57 | startButton->setEnabled(false); | 57 | startButton->setEnabled(false); |
58 | stopButton->setEnabled(true); | 58 | stopButton->setEnabled(true); |
59 | restartButton->setEnabled(true); | 59 | restartButton->setEnabled(true); |
60 | } | 60 | } |
61 | else | 61 | else |
62 | { | 62 | { |
63 | startButton->setEnabled(true); | 63 | startButton->setEnabled(true); |
64 | stopButton->setEnabled(false); | 64 | stopButton->setEnabled(false); |
65 | restartButton->setEnabled(false); | 65 | restartButton->setEnabled(false); |
66 | } | 66 | } |
67 | macAddressLabel->setText(interface->getMacAddress()); | 67 | macAddressLabel->setText(interface->getMacAddress()); |
68 | ipAddressLabel->setText(interface->getIp()); | 68 | ipAddressLabel->setText(interface->getIp()); |
69 | subnetMaskLabel->setText(interface->getSubnetMask()); | 69 | subnetMaskLabel->setText(interface->getSubnetMask()); |
70 | broadcastLabel->setText(interface->getBroadcast()); | 70 | broadcastLabel->setText(interface->getBroadcast()); |
71 | } | 71 | } |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Create the advanced widget. Fill it with the current interface's information. | 74 | * Create the advanced widget. Fill it with the current interface's information. |
75 | * Display it. | 75 | * Display it. |
76 | */ | 76 | */ |
77 | void InterfaceInformationImp::advanced() | 77 | void InterfaceInformationImp::advanced() |
78 | { | 78 | { |
79 | InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); | 79 | InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); |
80 | a->interfaceName->setText(interface->getInterfaceName()); | 80 | a->interfaceName->setText(interface->getInterfaceName()); |
81 | a->macAddressLabel->setText(interface->getMacAddress()); | 81 | a->macAddressLabel->setText(interface->getMacAddress()); |
82 | a->ipAddressLabel->setText(interface->getIp()); | 82 | a->ipAddressLabel->setText(interface->getIp()); |
83 | a->subnetMaskLabel->setText(interface->getSubnetMask()); | 83 | a->subnetMaskLabel->setText(interface->getSubnetMask()); |
84 | a->broadcastLabel->setText(interface->getBroadcast()); | 84 | a->broadcastLabel->setText(interface->getBroadcast()); |
85 | a->dhcpServerLabel->setText(interface->getDhcpServerIp()); | 85 | a->dhcpServerLabel->setText(interface->getDhcpServerIp()); |
86 | a->leaseObtainedLabel->setText(interface->getLeaseObtained()); | 86 | a->leaseObtainedLabel->setText(interface->getLeaseObtained()); |
87 | a->leaseExpiresLabel->setText(interface->getLeaseExpires()); | 87 | a->leaseExpiresLabel->setText(interface->getLeaseExpires()); |
88 | a->dhcpInformation->setEnabled(interface->isDhcp()); | 88 | a->dhcpInformation->setEnabled(interface->isDhcp()); |
89 | QPEApplication::showWidget( a ); | 89 | QPEApplication::showWidget( a ); |
90 | } | 90 | } |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * Messages from the interface if start/stop went as planned. | 93 | * Messages from the interface if start/stop went as planned. |
94 | * Purly for user feedback. | 94 | * Purly for user feedback. |
95 | * @param message the message to display. | 95 | * @param message the message to display. |
96 | */ | 96 | */ |
97 | void InterfaceInformationImp::showMessage(const QString &message) | 97 | void InterfaceInformationImp::showMessage(const QString &message) |
98 | { | 98 | { |
99 | if (CheckBoxSilent->isChecked()) return; | 99 | if (CheckBoxSilent->isChecked()) return; |
100 | QMessageBox::information(this, "Message", message, QMessageBox::Ok); | 100 | QMessageBox::information(this, "Message", message, QMessageBox::Ok); |
101 | } | 101 | } |
102 | 102 | ||
103 | // infoimp.cpp | 103 | // infoimp.cpp |
104 | 104 | ||
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index b0a1dd9..1e16b97 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -4,365 +4,365 @@ | |||
4 | #include "interfaceinformationimp.h" | 4 | #include "interfaceinformationimp.h" |
5 | #include "interfacesetupimp.h" | 5 | #include "interfacesetupimp.h" |
6 | #include "interfaces.h" | 6 | #include "interfaces.h" |
7 | #include "module.h" | 7 | #include "module.h" |
8 | 8 | ||
9 | /* OPIE */ | 9 | /* OPIE */ |
10 | #include <qpe/qcopenvelope_qws.h> | 10 | #include <qpe/qcopenvelope_qws.h> |
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | #include <qpe/config.h> | 12 | #include <qpe/config.h> |
13 | #include <qpe/qlibrary.h> | 13 | #include <qpe/qlibrary.h> |
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | /* QT */ | 16 | /* QT */ |
17 | #include <qpushbutton.h> | 17 | #include <qpushbutton.h> |
18 | #include <qlistbox.h> | 18 | #include <qlistbox.h> |
19 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
20 | #include <qlistview.h> | 20 | #include <qlistview.h> |
21 | #include <qheader.h> | 21 | #include <qheader.h> |
22 | #include <qlabel.h> | 22 | #include <qlabel.h> |
23 | #include <qtabwidget.h> // in order to disable the profiles tab | 23 | #include <qtabwidget.h> // in order to disable the profiles tab |
24 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
25 | 25 | ||
26 | 26 | ||
27 | #if QT_VERSION < 300 | 27 | #if QT_VERSION < 300 |
28 | #include <qlist.h> | 28 | #include <qlist.h> |
29 | #else | 29 | #else |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #endif | 31 | #endif |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | 36 | ||
37 | /* STD */ | 37 | /* STD */ |
38 | #include <net/if.h> | 38 | #include <net/if.h> |
39 | #include <sys/ioctl.h> | 39 | #include <sys/ioctl.h> |
40 | #include <sys/socket.h> | 40 | #include <sys/socket.h> |
41 | 41 | ||
42 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" | 42 | #define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" |
43 | #define _PROCNETDEV "/proc/net/dev" | 43 | #define _PROCNETDEV "/proc/net/dev" |
44 | 44 | ||
45 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) | 45 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) |
46 | { | 46 | { |
47 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 47 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
48 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 48 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
49 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 49 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
50 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 50 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
51 | 51 | ||
52 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 52 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
53 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 53 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
54 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 54 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
55 | 55 | ||
56 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 56 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
57 | 57 | ||
58 | //FIXME: disable profiles for the moment: | 58 | //FIXME: disable profiles for the moment: |
59 | tabWidget->setTabEnabled( tab, false ); | 59 | tabWidget->setTabEnabled( tab, false ); |
60 | 60 | ||
61 | // Load connections. | 61 | // Load connections. |
62 | // /usr/local/kde/lib/libinterfaces.la | 62 | // /usr/local/kde/lib/libinterfaces.la |
63 | #ifdef QWS | 63 | #ifdef QWS |
64 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); | 64 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); |
65 | #else | 65 | #else |
66 | loader = KLibLoader::self(); | 66 | loader = KLibLoader::self(); |
67 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); | 67 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); |
68 | #endif | 68 | #endif |
69 | getAllInterfaces(); | 69 | getAllInterfaces(); |
70 | 70 | ||
71 | Interfaces i; | 71 | Interfaces i; |
72 | QStringList list = i.getInterfaceList(); | 72 | QStringList list = i.getInterfaceList(); |
73 | QMap<QString, Interface*>::Iterator it; | 73 | QMap<QString, Interface*>::Iterator it; |
74 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) | 74 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) |
75 | { | 75 | { |
76 | /* | 76 | /* |
77 | * we skipped it in getAllInterfaces now | 77 | * we skipped it in getAllInterfaces now |
78 | * we need to ignore it as well | 78 | * we need to ignore it as well |
79 | */ | 79 | */ |
80 | if (m_handledIfaces.contains( *ni) ) | 80 | if (m_handledIfaces.contains( *ni) ) |
81 | { | 81 | { |
82 | qDebug("Not up iface handled by module"); | 82 | qDebug("Not up iface handled by module"); |
83 | continue; | 83 | continue; |
84 | } | 84 | } |
85 | bool found = false; | 85 | bool found = false; |
86 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) | 86 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) |
87 | { | 87 | { |
88 | if(it.key() == (*ni)) | 88 | if(it.key() == (*ni)) |
89 | found = true; | 89 | found = true; |
90 | } | 90 | } |
91 | if(!found) | 91 | if(!found) |
92 | { | 92 | { |
93 | if(!(*ni).contains("_")) | 93 | if(!(*ni).contains("_")) |
94 | { | 94 | { |
95 | Interface *i = new Interface(this, *ni, false); | 95 | Interface *i = new Interface(this, *ni, false); |
96 | i->setAttached(false); | 96 | i->setAttached(false); |
97 | i->setHardwareName(tr("Disconnected")); | 97 | i->setHardwareName(tr("Disconnected")); |
98 | interfaceNames.insert(i->getInterfaceName(), i); | 98 | interfaceNames.insert(i->getInterfaceName(), i); |
99 | updateInterface(i); | 99 | updateInterface(i); |
100 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 100 | connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*))); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | //getInterfaceList(); | 105 | //getInterfaceList(); |
106 | connectionList->header()->hide(); | 106 | connectionList->header()->hide(); |
107 | 107 | ||
108 | Config cfg("NetworkSetup"); | 108 | Config cfg("NetworkSetup"); |
109 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 109 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
110 | for ( QStringList::Iterator it = profiles.begin(); | 110 | for ( QStringList::Iterator it = profiles.begin(); |
111 | it != profiles.end(); ++it) | 111 | it != profiles.end(); ++it) |
112 | profilesList->insertItem((*it)); | 112 | profilesList->insertItem((*it)); |
113 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 113 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
114 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 114 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
115 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 115 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
116 | 116 | ||
117 | QFile file(scheme); | 117 | QFile file(scheme); |
118 | if ( file.open(IO_ReadOnly) ) | 118 | if ( file.open(IO_ReadOnly) ) |
119 | { // file opened successfully | 119 | { // file opened successfully |
120 | QTextStream stream( &file ); // use a text stream | 120 | QTextStream stream( &file ); // use a text stream |
121 | while ( !stream.eof() ) | 121 | while ( !stream.eof() ) |
122 | { // until end of file... | 122 | { // until end of file... |
123 | QString line = stream.readLine(); // line of text excluding '\n' | 123 | QString line = stream.readLine(); // line of text excluding '\n' |
124 | if(line.contains("SCHEME")) | 124 | if(line.contains("SCHEME")) |
125 | { | 125 | { |
126 | line = line.mid(7, line.length()); | 126 | line = line.mid(7, line.length()); |
127 | currentProfileLabel->setText(line); | 127 | currentProfileLabel->setText(line); |
128 | break; | 128 | break; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | file.close(); | 131 | file.close(); |
132 | } | 132 | } |
133 | makeChannel(); | 133 | makeChannel(); |
134 | } | 134 | } |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Deconstructor. Save profiles. Delete loaded libraries. | 137 | * Deconstructor. Save profiles. Delete loaded libraries. |
138 | */ | 138 | */ |
139 | MainWindowImp::~MainWindowImp() | 139 | MainWindowImp::~MainWindowImp() |
140 | { | 140 | { |
141 | // Save profiles. | 141 | // Save profiles. |
142 | Config cfg("NetworkSetup"); | 142 | Config cfg("NetworkSetup"); |
143 | cfg.setGroup("General"); | 143 | cfg.setGroup("General"); |
144 | cfg.writeEntry("Profiles", profiles.join(" ")); | 144 | cfg.writeEntry("Profiles", profiles.join(" ")); |
145 | 145 | ||
146 | // Delete all interfaces that don't have owners. | 146 | // Delete all interfaces that don't have owners. |
147 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 147 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
148 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) | 148 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) |
149 | { | 149 | { |
150 | if(iIt.key()->getModuleOwner() == NULL) | 150 | if(iIt.key()->getModuleOwner() == NULL) |
151 | delete iIt.key(); | 151 | delete iIt.key(); |
152 | } | 152 | } |
153 | 153 | ||
154 | #ifdef QWS | 154 | #ifdef QWS |
155 | // Delete Modules and Libraries | 155 | // Delete Modules and Libraries |
156 | QMap<Module*, QLibrary*>::Iterator it; | 156 | QMap<Module*, QLibrary*>::Iterator it; |
157 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 157 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
158 | { | 158 | { |
159 | delete it.key(); | 159 | delete it.key(); |
160 | // I wonder why I can't delete the libraries | 160 | // I wonder why I can't delete the libraries |
161 | // What fucking shit this is. | 161 | // What fucking shit this is. |
162 | //delete it.data(); | 162 | //delete it.data(); |
163 | } | 163 | } |
164 | #else | 164 | #else |
165 | // klibloader automaticly deletes the libraries for us... | 165 | // klibloader automaticly deletes the libraries for us... |
166 | #endif | 166 | #endif |
167 | } | 167 | } |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * Query the kernel for all of the interfaces. | 170 | * Query the kernel for all of the interfaces. |
171 | */ | 171 | */ |
172 | void MainWindowImp::getAllInterfaces() | 172 | void MainWindowImp::getAllInterfaces() |
173 | { | 173 | { |
174 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); | 174 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
175 | if(sockfd == -1) | 175 | if(sockfd == -1) |
176 | return; | 176 | return; |
177 | 177 | ||
178 | struct ifreq ifr; | 178 | struct ifreq ifr; |
179 | QStringList ifaces; | 179 | QStringList ifaces; |
180 | QFile procFile(QString(_PROCNETDEV)); | 180 | QFile procFile(QString(_PROCNETDEV)); |
181 | int result; | 181 | int result; |
182 | Interface *i; | 182 | Interface *i; |
183 | 183 | ||
184 | if (! procFile.exists()) | 184 | if (! procFile.exists()) |
185 | { | 185 | { |
186 | struct ifreq ifrs[100]; | 186 | struct ifreq ifrs[100]; |
187 | struct ifconf ifc; | 187 | struct ifconf ifc; |
188 | ifc.ifc_len = sizeof(ifrs); | 188 | ifc.ifc_len = sizeof(ifrs); |
189 | ifc.ifc_req = ifrs; | 189 | ifc.ifc_req = ifrs; |
190 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); | 190 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); |
191 | 191 | ||
192 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) | 192 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) |
193 | { | 193 | { |
194 | struct ifreq *pifr = &ifrs[i]; | 194 | struct ifreq *pifr = &ifrs[i]; |
195 | 195 | ||
196 | ifaces += pifr->ifr_name; | 196 | ifaces += pifr->ifr_name; |
197 | } | 197 | } |
198 | } | 198 | } |
199 | else | 199 | else |
200 | { | 200 | { |
201 | procFile.open(IO_ReadOnly); | 201 | procFile.open(IO_ReadOnly); |
202 | QString line; | 202 | QString line; |
203 | QTextStream procTs(&procFile); | 203 | QTextStream procTs(&procFile); |
204 | int loc = -1; | 204 | int loc = -1; |
205 | 205 | ||
206 | procTs.readLine(); // eat a line | 206 | procTs.readLine(); // eat a line |
207 | procTs.readLine(); // eat a line | 207 | procTs.readLine(); // eat a line |
208 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) | 208 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) |
209 | { | 209 | { |
210 | if((loc = line.find(":")) != -1) | 210 | if((loc = line.find(":")) != -1) |
211 | { | 211 | { |
212 | ifaces += line.left(loc); | 212 | ifaces += line.left(loc); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | } | 215 | } |
216 | 216 | ||
217 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) | 217 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) |
218 | { | 218 | { |
219 | int flags = 0; | 219 | int flags = 0; |
220 | if ( m_handledIfaces.contains( (*it) ) ) | 220 | if ( m_handledIfaces.contains( (*it) ) ) |
221 | { | 221 | { |
222 | qDebug(" %s is handled by a module", (*it).latin1() ); | 222 | qDebug(" %s is handled by a module", (*it).latin1() ); |
223 | continue; | 223 | continue; |
224 | } | 224 | } |
225 | // int family; | 225 | // int family; |
226 | i = NULL; | 226 | i = NULL; |
227 | 227 | ||
228 | strcpy(ifr.ifr_name, (*it).latin1()); | 228 | strcpy(ifr.ifr_name, (*it).latin1()); |
229 | 229 | ||
230 | struct ifreq ifcopy; | 230 | struct ifreq ifcopy; |
231 | ifcopy = ifr; | 231 | ifcopy = ifr; |
232 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | 232 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); |
233 | flags = ifcopy.ifr_flags; | 233 | flags = ifcopy.ifr_flags; |
234 | i = new Interface(this, ifr.ifr_name, false); | 234 | i = new Interface(this, ifr.ifr_name, false); |
235 | i->setAttached(true); | 235 | i->setAttached(true); |
236 | if ((flags & IFF_UP) == IFF_UP) | 236 | if ((flags & IFF_UP) == IFF_UP) |
237 | i->setStatus(true); | 237 | i->setStatus(true); |
238 | else | 238 | else |
239 | i->setStatus(false); | 239 | i->setStatus(false); |
240 | 240 | ||
241 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | 241 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) |
242 | i->setHardwareName("Ethernet"); | 242 | i->setHardwareName("Ethernet"); |
243 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | 243 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) |
244 | i->setHardwareName("Point to Point"); | 244 | i->setHardwareName("Point to Point"); |
245 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | 245 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) |
246 | i->setHardwareName("Multicast"); | 246 | i->setHardwareName("Multicast"); |
247 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | 247 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) |
248 | i->setHardwareName("Loopback"); | 248 | i->setHardwareName("Loopback"); |
249 | else | 249 | else |
250 | i->setHardwareName("Unknown"); | 250 | i->setHardwareName("Unknown"); |
251 | 251 | ||
252 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); | 252 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); |
253 | interfaceNames.insert(i->getInterfaceName(), i); | 253 | interfaceNames.insert(i->getInterfaceName(), i); |
254 | updateInterface(i); | 254 | updateInterface(i); |
255 | connect(i, SIGNAL(updateInterface(Interface *)), | 255 | connect(i, SIGNAL(updateInterface(Interface*)), |
256 | this, SLOT(updateInterface(Interface *))); | 256 | this, SLOT(updateInterface(Interface*))); |
257 | } | 257 | } |
258 | // now lets ask the plugins too ;) | 258 | // now lets ask the plugins too ;) |
259 | QMap<Module*, QLibrary*>::Iterator it; | 259 | QMap<Module*, QLibrary*>::Iterator it; |
260 | QList<Interface> ilist; | 260 | QList<Interface> ilist; |
261 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 261 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
262 | { | 262 | { |
263 | if(it.key()) | 263 | if(it.key()) |
264 | { | 264 | { |
265 | ilist = it.key()->getInterfaces(); | 265 | ilist = it.key()->getInterfaces(); |
266 | for( i = ilist.first(); i != 0; i = ilist.next() ) | 266 | for( i = ilist.first(); i != 0; i = ilist.next() ) |
267 | { | 267 | { |
268 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); | 268 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); |
269 | interfaceNames.insert(i->getInterfaceName(), i); | 269 | interfaceNames.insert(i->getInterfaceName(), i); |
270 | updateInterface(i); | 270 | updateInterface(i); |
271 | connect(i, SIGNAL(updateInterface(Interface *)), | 271 | connect(i, SIGNAL(updateInterface(Interface*)), |
272 | this, SLOT(updateInterface(Interface *))); | 272 | this, SLOT(updateInterface(Interface*))); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | /** | 278 | /** |
279 | * Load all modules that are found in the path | 279 | * Load all modules that are found in the path |
280 | * @param path a directory that is scaned for any plugins that can be loaded | 280 | * @param path a directory that is scaned for any plugins that can be loaded |
281 | * and attempts to load them | 281 | * and attempts to load them |
282 | */ | 282 | */ |
283 | void MainWindowImp::loadModules(const QString &path) | 283 | void MainWindowImp::loadModules(const QString &path) |
284 | { | 284 | { |
285 | #ifdef DEBUG | 285 | #ifdef DEBUG |
286 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); | 286 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); |
287 | #endif | 287 | #endif |
288 | QDir d(path); | 288 | QDir d(path); |
289 | if(!d.exists()) | 289 | if(!d.exists()) |
290 | return; | 290 | return; |
291 | 291 | ||
292 | // Don't want sym links | 292 | // Don't want sym links |
293 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 293 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
294 | const QFileInfoList *list = d.entryInfoList(); | 294 | const QFileInfoList *list = d.entryInfoList(); |
295 | QFileInfoListIterator it( *list ); | 295 | QFileInfoListIterator it( *list ); |
296 | QFileInfo *fi; | 296 | QFileInfo *fi; |
297 | while ( (fi=it.current()) ) | 297 | while ( (fi=it.current()) ) |
298 | { | 298 | { |
299 | #ifdef QWS | 299 | #ifdef QWS |
300 | if(fi->fileName().contains(".so")) | 300 | if(fi->fileName().contains(".so")) |
301 | { | 301 | { |
302 | #else | 302 | #else |
303 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")) | 303 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")) |
304 | { | 304 | { |
305 | #endif | 305 | #endif |
306 | loadPlugin(path + "/" + fi->fileName()); | 306 | loadPlugin(path + "/" + fi->fileName()); |
307 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); | 307 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); |
308 | } | 308 | } |
309 | ++it; | 309 | ++it; |
310 | } | 310 | } |
311 | } | 311 | } |
312 | 312 | ||
313 | /** | 313 | /** |
314 | * Attempt to load a function and resolve a function. | 314 | * Attempt to load a function and resolve a function. |
315 | * @param pluginFileName - the name of the file in which to attempt to load | 315 | * @param pluginFileName - the name of the file in which to attempt to load |
316 | * @param resolveString - function pointer to resolve | 316 | * @param resolveString - function pointer to resolve |
317 | * @return pointer to the function with name resolveString or NULL | 317 | * @return pointer to the function with name resolveString or NULL |
318 | */ | 318 | */ |
319 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) | 319 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) |
320 | { | 320 | { |
321 | #ifdef DEBUG | 321 | #ifdef DEBUG |
322 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); | 322 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); |
323 | #endif | 323 | #endif |
324 | #ifdef QWS | 324 | #ifdef QWS |
325 | QLibrary *lib = new QLibrary(pluginFileName); | 325 | QLibrary *lib = new QLibrary(pluginFileName); |
326 | void *functionPointer = lib->resolve(resolveString); | 326 | void *functionPointer = lib->resolve(resolveString); |
327 | if( !functionPointer ) | 327 | if( !functionPointer ) |
328 | { | 328 | { |
329 | #ifdef DEBUG | 329 | #ifdef DEBUG |
330 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); | 330 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); |
331 | #endif | 331 | #endif |
332 | delete lib; | 332 | delete lib; |
333 | return NULL; | 333 | return NULL; |
334 | } | 334 | } |
335 | // Try to get an object. | 335 | // Try to get an object. |
336 | Module *object = ((Module* (*)()) functionPointer)(); | 336 | Module *object = ((Module* (*)()) functionPointer)(); |
337 | if(object == NULL) | 337 | if(object == NULL) |
338 | { | 338 | { |
339 | #ifdef DEBUG | 339 | #ifdef DEBUG |
340 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 340 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
341 | #endif | 341 | #endif |
342 | delete lib; | 342 | delete lib; |
343 | return NULL; | 343 | return NULL; |
344 | } | 344 | } |
345 | 345 | ||
346 | m_handledIfaces += object->handledInterfaceNames(); | 346 | m_handledIfaces += object->handledInterfaceNames(); |
347 | // Store for deletion later | 347 | // Store for deletion later |
348 | libraries.insert(object, lib); | 348 | libraries.insert(object, lib); |
349 | return object; | 349 | return object; |
350 | 350 | ||
351 | #else | 351 | #else |
352 | QLibrary *lib = loader->library(pluginFileName); | 352 | QLibrary *lib = loader->library(pluginFileName); |
353 | if( !lib || !lib->hasSymbol(resolveString) ) | 353 | if( !lib || !lib->hasSymbol(resolveString) ) |
354 | { | 354 | { |
355 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 355 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
356 | return NULL; | 356 | return NULL; |
357 | } | 357 | } |
358 | // Try to get an object. | 358 | // Try to get an object. |
359 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); | 359 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); |
360 | if(object == NULL) | 360 | if(object == NULL) |
361 | { | 361 | { |
362 | #ifdef DEBUG | 362 | #ifdef DEBUG |
363 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 363 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
364 | #endif | 364 | #endif |
365 | return NULL; | 365 | return NULL; |
366 | } | 366 | } |
367 | #ifdef DEBUG | 367 | #ifdef DEBUG |
368 | qDebug("MainWindowImp::loadPlugin:: Found object, storing."); | 368 | qDebug("MainWindowImp::loadPlugin:: Found object, storing."); |
@@ -619,130 +619,130 @@ void MainWindowImp::removeProfile() | |||
619 | { | 619 | { |
620 | if(profilesList->count() <= 1) | 620 | if(profilesList->count() <= 1) |
621 | { | 621 | { |
622 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); | 622 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); |
623 | return; | 623 | return; |
624 | } | 624 | } |
625 | QString profileToRemove = profilesList->currentText(); | 625 | QString profileToRemove = profilesList->currentText(); |
626 | if(profileToRemove == "All") | 626 | if(profileToRemove == "All") |
627 | { | 627 | { |
628 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); | 628 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); |
629 | return; | 629 | return; |
630 | } | 630 | } |
631 | // Can't remove the curent profile | 631 | // Can't remove the curent profile |
632 | if(profileToRemove == currentProfileLabel->text()) | 632 | if(profileToRemove == currentProfileLabel->text()) |
633 | { | 633 | { |
634 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | 634 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); |
635 | return; | 635 | return; |
636 | 636 | ||
637 | } | 637 | } |
638 | 638 | ||
639 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) | 639 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) |
640 | { | 640 | { |
641 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 641 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
642 | profilesList->clear(); | 642 | profilesList->clear(); |
643 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 643 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
644 | profilesList->insertItem((*it)); | 644 | profilesList->insertItem((*it)); |
645 | 645 | ||
646 | // Remove any interface settings and mappings. | 646 | // Remove any interface settings and mappings. |
647 | Interfaces interfaces; | 647 | Interfaces interfaces; |
648 | // Go through them one by one | 648 | // Go through them one by one |
649 | QMap<Interface*, QListViewItem*>::Iterator it; | 649 | QMap<Interface*, QListViewItem*>::Iterator it; |
650 | for( it = items.begin(); it != items.end(); ++it ) | 650 | for( it = items.begin(); it != items.end(); ++it ) |
651 | { | 651 | { |
652 | QString interfaceName = it.key()->getInterfaceName(); | 652 | QString interfaceName = it.key()->getInterfaceName(); |
653 | qDebug(interfaceName.latin1()); | 653 | qDebug(interfaceName.latin1()); |
654 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)) | 654 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)) |
655 | { | 655 | { |
656 | interfaces.removeInterface(); | 656 | interfaces.removeInterface(); |
657 | if(interfaces.setMapping(interfaceName)) | 657 | if(interfaces.setMapping(interfaceName)) |
658 | { | 658 | { |
659 | if(profilesList->count() == 1) | 659 | if(profilesList->count() == 1) |
660 | interfaces.removeMapping(); | 660 | interfaces.removeMapping(); |
661 | else | 661 | else |
662 | { | 662 | { |
663 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 663 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
664 | } | 664 | } |
665 | } | 665 | } |
666 | interfaces.write(); | 666 | interfaces.write(); |
667 | break; | 667 | break; |
668 | } | 668 | } |
669 | } | 669 | } |
670 | } | 670 | } |
671 | } | 671 | } |
672 | 672 | ||
673 | /** | 673 | /** |
674 | * A new profile has been selected, change. | 674 | * A new profile has been selected, change. |
675 | * @param newProfile the new profile. | 675 | * @param newProfile the new profile. |
676 | */ | 676 | */ |
677 | void MainWindowImp::changeProfile() | 677 | void MainWindowImp::changeProfile() |
678 | { | 678 | { |
679 | if(profilesList->currentItem() == -1) | 679 | if(profilesList->currentItem() == -1) |
680 | { | 680 | { |
681 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); | 681 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); |
682 | return; | 682 | return; |
683 | } | 683 | } |
684 | QString newProfile = profilesList->text(profilesList->currentItem()); | 684 | QString newProfile = profilesList->text(profilesList->currentItem()); |
685 | if(newProfile != currentProfileLabel->text()) | 685 | if(newProfile != currentProfileLabel->text()) |
686 | { | 686 | { |
687 | currentProfileLabel->setText(newProfile); | 687 | currentProfileLabel->setText(newProfile); |
688 | QFile::remove(scheme); | 688 | QFile::remove(scheme); |
689 | QFile file(scheme); | 689 | QFile file(scheme); |
690 | if ( file.open(IO_ReadWrite) ) | 690 | if ( file.open(IO_ReadWrite) ) |
691 | { | 691 | { |
692 | QTextStream stream( &file ); | 692 | QTextStream stream( &file ); |
693 | stream << QString("SCHEME=%1").arg(newProfile); | 693 | stream << QString("SCHEME=%1").arg(newProfile); |
694 | file.close(); | 694 | file.close(); |
695 | } | 695 | } |
696 | // restart all up devices? | 696 | // restart all up devices? |
697 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok) | 697 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok) |
698 | { | 698 | { |
699 | // Go through them one by one | 699 | // Go through them one by one |
700 | QMap<Interface*, QListViewItem*>::Iterator it; | 700 | QMap<Interface*, QListViewItem*>::Iterator it; |
701 | for( it = items.begin(); it != items.end(); ++it ) | 701 | for( it = items.begin(); it != items.end(); ++it ) |
702 | { | 702 | { |
703 | if(it.key()->getStatus() == true) | 703 | if(it.key()->getStatus() == true) |
704 | it.key()->restart(); | 704 | it.key()->restart(); |
705 | } | 705 | } |
706 | } | 706 | } |
707 | } | 707 | } |
708 | // TODO change the profile in the modules | 708 | // TODO change the profile in the modules |
709 | } | 709 | } |
710 | 710 | ||
711 | 711 | ||
712 | void MainWindowImp::makeChannel() | 712 | void MainWindowImp::makeChannel() |
713 | { | 713 | { |
714 | channel = new QCopChannel( "QPE/Application/networksettings", this ); | 714 | channel = new QCopChannel( "QPE/Application/networksettings", this ); |
715 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 715 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
716 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 716 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
717 | } | 717 | } |
718 | 718 | ||
719 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | 719 | void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) |
720 | { | 720 | { |
721 | bool found = false; | 721 | bool found = false; |
722 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); | 722 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); |
723 | if (msg == "raise") | 723 | if (msg == "raise") |
724 | { | 724 | { |
725 | raise(); | 725 | raise(); |
726 | return; | 726 | return; |
727 | } | 727 | } |
728 | 728 | ||
729 | QString dest = msg.left(msg.find("(")); | 729 | QString dest = msg.left(msg.find("(")); |
730 | QCString param = msg.right(msg.length() - msg.find("(") - 1); | 730 | QCString param = msg.right(msg.length() - msg.find("(") - 1); |
731 | param = param.left( param.length() - 1 ); | 731 | param = param.left( param.length() - 1 ); |
732 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); | 732 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); |
733 | 733 | ||
734 | QMap<Module*, QLibrary*>::Iterator it; | 734 | QMap<Module*, QLibrary*>::Iterator it; |
735 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 735 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
736 | { | 736 | { |
737 | qDebug("plugin >%s<", it.key()->type().latin1() ); | 737 | qDebug("plugin >%s<", it.key()->type().latin1() ); |
738 | if(it.key()->type() == dest) | 738 | if(it.key()->type() == dest) |
739 | { | 739 | { |
740 | it.key()->receive( param, arg ); | 740 | it.key()->receive( param, arg ); |
741 | found = true; | 741 | found = true; |
742 | } | 742 | } |
743 | } | 743 | } |
744 | 744 | ||
745 | 745 | ||
746 | if (found) QPEApplication::setKeepRunning(); | 746 | if (found) QPEApplication::setKeepRunning(); |
747 | else qDebug("Huh what do ya want"); | 747 | else qDebug("Huh what do ya want"); |
748 | } | 748 | } |
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index 7d21605..3b2393c 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp | |||
@@ -479,194 +479,194 @@ void IPWidget::autoname_t(bool on) | |||
479 | "problems with the X-server and applications " | 479 | "problems with the X-server and applications " |
480 | "while kppp is connected. Don't use it until " | 480 | "while kppp is connected. Don't use it until " |
481 | "you know what you are doing!\n" | 481 | "you know what you are doing!\n" |
482 | "For more information take a look at the " | 482 | "For more information take a look at the " |
483 | "handbook (or help) in the section \"Frequently " | 483 | "handbook (or help) in the section \"Frequently " |
484 | "asked questions\"."), | 484 | "asked questions\"."), |
485 | tr("Warning")); | 485 | tr("Warning")); |
486 | was_warned = true; | 486 | was_warned = true; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | 489 | ||
490 | 490 | ||
491 | void IPWidget::save() | 491 | void IPWidget::save() |
492 | { | 492 | { |
493 | if(dynamicadd_rb->isChecked()) | 493 | if(dynamicadd_rb->isChecked()) |
494 | { | 494 | { |
495 | _pppdata->setIpaddr("0.0.0.0"); | 495 | _pppdata->setIpaddr("0.0.0.0"); |
496 | _pppdata->setSubnetmask("0.0.0.0"); | 496 | _pppdata->setSubnetmask("0.0.0.0"); |
497 | } | 497 | } |
498 | else | 498 | else |
499 | { | 499 | { |
500 | _pppdata->setIpaddr(ipaddress_l->text()); | 500 | _pppdata->setIpaddr(ipaddress_l->text()); |
501 | _pppdata->setSubnetmask(subnetmask_l->text()); | 501 | _pppdata->setSubnetmask(subnetmask_l->text()); |
502 | } | 502 | } |
503 | _pppdata->setAutoname(autoname->isChecked()); | 503 | _pppdata->setAutoname(autoname->isChecked()); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | void IPWidget::hitIPSelect( int i ) | 507 | void IPWidget::hitIPSelect( int i ) |
508 | { | 508 | { |
509 | if(i == 0) | 509 | if(i == 0) |
510 | { | 510 | { |
511 | ipaddress_label->setEnabled(false); | 511 | ipaddress_label->setEnabled(false); |
512 | sub_label->setEnabled(false); | 512 | sub_label->setEnabled(false); |
513 | ipaddress_l->setEnabled(false); | 513 | ipaddress_l->setEnabled(false); |
514 | subnetmask_l->setEnabled(false); | 514 | subnetmask_l->setEnabled(false); |
515 | } | 515 | } |
516 | else | 516 | else |
517 | { | 517 | { |
518 | ipaddress_label->setEnabled(true); | 518 | ipaddress_label->setEnabled(true); |
519 | sub_label->setEnabled(true); | 519 | sub_label->setEnabled(true); |
520 | ipaddress_l->setEnabled(true); | 520 | ipaddress_l->setEnabled(true); |
521 | subnetmask_l->setEnabled(true); | 521 | subnetmask_l->setEnabled(true); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | 525 | ||
526 | 526 | ||
527 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) | 527 | DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) |
528 | : QWidget(parent, name), _pppdata(pd) | 528 | : QWidget(parent, name), _pppdata(pd) |
529 | { | 529 | { |
530 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); | 530 | QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); |
531 | 531 | ||
532 | dnsdomain_label = new QLabel(tr("Domain name:"), this); | 532 | dnsdomain_label = new QLabel(tr("Domain name:"), this); |
533 | tl->addWidget(dnsdomain_label, 0, 0); | 533 | tl->addWidget(dnsdomain_label, 0, 0); |
534 | 534 | ||
535 | dnsdomain = new QLineEdit(this); | 535 | dnsdomain = new QLineEdit(this); |
536 | 536 | ||
537 | tl->addWidget(dnsdomain, 0, 1); | 537 | tl->addWidget(dnsdomain, 0, 1); |
538 | 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" |
539 | "name is used for your computer while you are\n" | 539 | "name is used for your computer while you are\n" |
540 | "connected. When the connection is closed, the\n" | 540 | "connected. When the connection is closed, the\n" |
541 | "original domain name of your computer is\n" | 541 | "original domain name of your computer is\n" |
542 | "restored.\n" | 542 | "restored.\n" |
543 | "\n" | 543 | "\n" |
544 | "If you leave this field blank, no changes are\n" | 544 | "If you leave this field blank, no changes are\n" |
545 | "made to the domain name."); | 545 | "made to the domain name."); |
546 | 546 | ||
547 | QWhatsThis::add(dnsdomain_label,tmp); | 547 | QWhatsThis::add(dnsdomain_label,tmp); |
548 | QWhatsThis::add(dnsdomain,tmp); | 548 | QWhatsThis::add(dnsdomain,tmp); |
549 | 549 | ||
550 | conf_label = new QLabel(tr("Configuration:"), this); | 550 | conf_label = new QLabel(tr("Configuration:"), this); |
551 | tl->addWidget(conf_label, 1, 0); | 551 | tl->addWidget(conf_label, 1, 0); |
552 | 552 | ||
553 | bg = new QButtonGroup("Group", this); | 553 | bg = new QButtonGroup("Group", this); |
554 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); | 554 | connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); |
555 | bg->hide(); | 555 | bg->hide(); |
556 | 556 | ||
557 | autodns = new QRadioButton(tr("Automatic"), this); | 557 | autodns = new QRadioButton(tr("Automatic"), this); |
558 | bg->insert(autodns, 0); | 558 | bg->insert(autodns, 0); |
559 | tl->addWidget(autodns, 1, 1); | 559 | tl->addWidget(autodns, 1, 1); |
560 | if(!_pppdata->pppdVersionMin(2, 3, 7)) | 560 | if(!_pppdata->pppdVersionMin(2, 3, 7)) |
561 | autodns->setEnabled(false); | 561 | autodns->setEnabled(false); |
562 | 562 | ||
563 | mandns = new QRadioButton(tr("Manual"), this); | 563 | mandns = new QRadioButton(tr("Manual"), this); |
564 | bg->insert(mandns, 1); | 564 | bg->insert(mandns, 1); |
565 | tl->addWidget(mandns, 2, 1); | 565 | tl->addWidget(mandns, 2, 1); |
566 | 566 | ||
567 | dns_label = new QLabel(tr("DNS IP address:"), this); | 567 | dns_label = new QLabel(tr("DNS IP address:"), this); |
568 | tl->addWidget(dns_label, 3, 0); | 568 | tl->addWidget(dns_label, 3, 0); |
569 | 569 | ||
570 | QHBoxLayout *l2 = new QHBoxLayout; | 570 | QHBoxLayout *l2 = new QHBoxLayout; |
571 | tl->addLayout(l2, 3, 1); | 571 | tl->addLayout(l2, 3, 1); |
572 | dnsipaddr = new IPLineEdit(this); | 572 | dnsipaddr = new IPLineEdit(this); |
573 | connect(dnsipaddr, SIGNAL(returnPressed()), | 573 | connect(dnsipaddr, SIGNAL(returnPressed()), |
574 | SLOT(adddns())); | 574 | SLOT(adddns())); |
575 | connect(dnsipaddr, SIGNAL(textChanged(const QString &)), | 575 | connect(dnsipaddr, SIGNAL(textChanged(const QString&)), |
576 | SLOT(DNS_Edit_Changed(const QString &))); | 576 | SLOT(DNS_Edit_Changed(const QString&))); |
577 | l2->addWidget(dnsipaddr, 1); | 577 | l2->addWidget(dnsipaddr, 1); |
578 | l2->addStretch(1); | 578 | l2->addStretch(1); |
579 | 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" |
580 | "used while you are connected. When the\n" | 580 | "used while you are connected. When the\n" |
581 | "connection is closed, this DNS entry will be\n" | 581 | "connection is closed, this DNS entry will be\n" |
582 | "removed again.\n" | 582 | "removed again.\n" |
583 | "\n" | 583 | "\n" |
584 | "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" |
585 | "the DNS server here and click on <b>Add</b>"); | 585 | "the DNS server here and click on <b>Add</b>"); |
586 | 586 | ||
587 | QWhatsThis::add(dns_label, tmp); | 587 | QWhatsThis::add(dns_label, tmp); |
588 | QWhatsThis::add(dnsipaddr, tmp); | 588 | QWhatsThis::add(dnsipaddr, tmp); |
589 | 589 | ||
590 | QHBoxLayout *l1 = new QHBoxLayout; | 590 | QHBoxLayout *l1 = new QHBoxLayout; |
591 | tl->addLayout(l1, 4, 1); | 591 | tl->addLayout(l1, 4, 1); |
592 | add = new QPushButton(tr("Add"), this); | 592 | add = new QPushButton(tr("Add"), this); |
593 | connect(add, SIGNAL(clicked()), SLOT(adddns())); | 593 | connect(add, SIGNAL(clicked()), SLOT(adddns())); |
594 | l1->addWidget(add); | 594 | l1->addWidget(add); |
595 | // l1->addStretch(1); | 595 | // l1->addStretch(1); |
596 | QWhatsThis::add(add, | 596 | QWhatsThis::add(add, |
597 | tr("Click this button to add the DNS server\n" | 597 | tr("Click this button to add the DNS server\n" |
598 | "specified in the field above. The entry\n" | 598 | "specified in the field above. The entry\n" |
599 | "will then be added to the list below")); | 599 | "will then be added to the list below")); |
600 | 600 | ||
601 | remove = new QPushButton(tr("Remove"), this); | 601 | remove = new QPushButton(tr("Remove"), this); |
602 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); | 602 | connect(remove, SIGNAL(clicked()), SLOT(removedns())); |
603 | l1->addWidget(remove); | 603 | l1->addWidget(remove); |
604 | QWhatsThis::add(remove, | 604 | QWhatsThis::add(remove, |
605 | tr("Click this button to remove the selected DNS\n" | 605 | tr("Click this button to remove the selected DNS\n" |
606 | "server entry from the list below")); | 606 | "server entry from the list below")); |
607 | 607 | ||
608 | servers_label = new QLabel(tr("DNS address list:"), this); | 608 | servers_label = new QLabel(tr("DNS address list:"), this); |
609 | servers_label->setAlignment(AlignTop|AlignLeft); | 609 | servers_label->setAlignment(AlignTop|AlignLeft); |
610 | tl->addWidget(servers_label, 5, 0); | 610 | tl->addWidget(servers_label, 5, 0); |
611 | 611 | ||
612 | dnsservers = new QListBox(this); | 612 | dnsservers = new QListBox(this); |
613 | dnsservers->setMinimumSize(150, 80); | 613 | dnsservers->setMinimumSize(150, 80); |
614 | connect(dnsservers, SIGNAL(highlighted(int)), | 614 | connect(dnsservers, SIGNAL(highlighted(int)), |
615 | SLOT(DNS_Entry_Selected(int))); | 615 | SLOT(DNS_Entry_Selected(int))); |
616 | tl->addWidget(dnsservers, 5, 1); | 616 | tl->addWidget(dnsservers, 5, 1); |
617 | 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" |
618 | "while you are connected. Use the <b>Add</b> and\n" | 618 | "while you are connected. Use the <b>Add</b> and\n" |
619 | "<b>Remove</b> buttons to modify the list"); | 619 | "<b>Remove</b> buttons to modify the list"); |
620 | 620 | ||
621 | QWhatsThis::add(servers_label,tmp); | 621 | QWhatsThis::add(servers_label,tmp); |
622 | QWhatsThis::add(dnsservers,tmp); | 622 | QWhatsThis::add(dnsservers,tmp); |
623 | 623 | ||
624 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); | 624 | exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); |
625 | // 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); |
626 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); | 626 | exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); |
627 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); | 627 | tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); |
628 | QWhatsThis::add(exdnsdisabled_toggle, | 628 | QWhatsThis::add(exdnsdisabled_toggle, |
629 | tr("<p>When this option is selected, all DNS\n" | 629 | tr("<p>When this option is selected, all DNS\n" |
630 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" | 630 | "servers specified in <tt>/etc/resolv.conf</tt> are\n" |
631 | "temporary disabled while the dialup connection\n" | 631 | "temporary disabled while the dialup connection\n" |
632 | "is established. After the connection is\n" | 632 | "is established. After the connection is\n" |
633 | "closed, the servers will be re-enabled\n" | 633 | "closed, the servers will be re-enabled\n" |
634 | "\n" | 634 | "\n" |
635 | "Typically, there is no reason to use this\n" | 635 | "Typically, there is no reason to use this\n" |
636 | "option, but it may become useful under \n" | 636 | "option, but it may become useful under \n" |
637 | "some circumstances.")); | 637 | "some circumstances.")); |
638 | 638 | ||
639 | 639 | ||
640 | // restore data if editing | 640 | // restore data if editing |
641 | if(!isnewaccount) | 641 | if(!isnewaccount) |
642 | { | 642 | { |
643 | dnsservers->insertStringList(_pppdata->dns()); | 643 | dnsservers->insertStringList(_pppdata->dns()); |
644 | dnsdomain->setText(_pppdata->domain()); | 644 | dnsdomain->setText(_pppdata->domain()); |
645 | } | 645 | } |
646 | 646 | ||
647 | int mode = _pppdata->autoDNS() ? 0 : 1; | 647 | int mode = _pppdata->autoDNS() ? 0 : 1; |
648 | bg->setButton(mode); | 648 | bg->setButton(mode); |
649 | DNS_Mode_Selected(mode); | 649 | DNS_Mode_Selected(mode); |
650 | 650 | ||
651 | tl->activate(); | 651 | tl->activate(); |
652 | } | 652 | } |
653 | 653 | ||
654 | void DNSWidget::DNS_Edit_Changed(const QString &text) | 654 | void DNSWidget::DNS_Edit_Changed(const QString &text) |
655 | { | 655 | { |
656 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); | 656 | QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); |
657 | add->setEnabled(text.find(r) != -1); | 657 | add->setEnabled(text.find(r) != -1); |
658 | } | 658 | } |
659 | 659 | ||
660 | void DNSWidget::DNS_Entry_Selected(int) | 660 | void DNSWidget::DNS_Entry_Selected(int) |
661 | { | 661 | { |
662 | remove->setEnabled(true); | 662 | remove->setEnabled(true); |
663 | } | 663 | } |
664 | 664 | ||
665 | void DNSWidget::DNS_Mode_Selected(int mode) | 665 | void DNSWidget::DNS_Mode_Selected(int mode) |
666 | { | 666 | { |
667 | bool on = (mode == 1); | 667 | bool on = (mode == 1); |
668 | dns_label->setEnabled(on); | 668 | dns_label->setEnabled(on); |
669 | servers_label->setEnabled(on); | 669 | servers_label->setEnabled(on); |
670 | dnsipaddr->setText(""); | 670 | dnsipaddr->setText(""); |
671 | dnsipaddr->setEnabled(on); | 671 | dnsipaddr->setEnabled(on); |
672 | add->setEnabled(false); | 672 | add->setEnabled(false); |
@@ -1091,121 +1091,121 @@ void ScriptWidget::insertButton() | |||
1091 | break; | 1091 | break; |
1092 | 1092 | ||
1093 | case ScriptEdit::Timeout: | 1093 | case ScriptEdit::Timeout: |
1094 | stl->insertItem("Timeout", stl->currentItem()); | 1094 | stl->insertItem("Timeout", stl->currentItem()); |
1095 | sl->insertItem(se->text(), sl->currentItem()); | 1095 | sl->insertItem(se->text(), sl->currentItem()); |
1096 | break; | 1096 | break; |
1097 | 1097 | ||
1098 | case ScriptEdit::Password: | 1098 | case ScriptEdit::Password: |
1099 | stl->insertItem("Password", stl->currentItem()); | 1099 | stl->insertItem("Password", stl->currentItem()); |
1100 | sl->insertItem(se->text(), sl->currentItem()); | 1100 | sl->insertItem(se->text(), sl->currentItem()); |
1101 | break; | 1101 | break; |
1102 | 1102 | ||
1103 | case ScriptEdit::ID: | 1103 | case ScriptEdit::ID: |
1104 | stl->insertItem("ID", stl->currentItem()); | 1104 | stl->insertItem("ID", stl->currentItem()); |
1105 | sl->insertItem(se->text(), sl->currentItem()); | 1105 | sl->insertItem(se->text(), sl->currentItem()); |
1106 | break; | 1106 | break; |
1107 | 1107 | ||
1108 | case ScriptEdit::Prompt: | 1108 | case ScriptEdit::Prompt: |
1109 | stl->insertItem("Prompt", stl->currentItem()); | 1109 | stl->insertItem("Prompt", stl->currentItem()); |
1110 | sl->insertItem(se->text(), sl->currentItem()); | 1110 | sl->insertItem(se->text(), sl->currentItem()); |
1111 | break; | 1111 | break; |
1112 | 1112 | ||
1113 | case ScriptEdit::PWPrompt: | 1113 | case ScriptEdit::PWPrompt: |
1114 | stl->insertItem("PWPrompt", stl->currentItem()); | 1114 | stl->insertItem("PWPrompt", stl->currentItem()); |
1115 | sl->insertItem(se->text(), sl->currentItem()); | 1115 | sl->insertItem(se->text(), sl->currentItem()); |
1116 | break; | 1116 | break; |
1117 | 1117 | ||
1118 | case ScriptEdit::LoopStart: | 1118 | case ScriptEdit::LoopStart: |
1119 | stl->insertItem("LoopStart", stl->currentItem()); | 1119 | stl->insertItem("LoopStart", stl->currentItem()); |
1120 | sl->insertItem(se->text(), sl->currentItem()); | 1120 | sl->insertItem(se->text(), sl->currentItem()); |
1121 | break; | 1121 | break; |
1122 | 1122 | ||
1123 | case ScriptEdit::LoopEnd: | 1123 | case ScriptEdit::LoopEnd: |
1124 | stl->insertItem("LoopEnd", stl->currentItem()); | 1124 | stl->insertItem("LoopEnd", stl->currentItem()); |
1125 | sl->insertItem(se->text(), sl->currentItem()); | 1125 | sl->insertItem(se->text(), sl->currentItem()); |
1126 | break; | 1126 | break; |
1127 | 1127 | ||
1128 | case ScriptEdit::Scan: | 1128 | case ScriptEdit::Scan: |
1129 | stl->insertItem("Scan", stl->currentItem()); | 1129 | stl->insertItem("Scan", stl->currentItem()); |
1130 | sl->insertItem(se->text(), sl->currentItem()); | 1130 | sl->insertItem(se->text(), sl->currentItem()); |
1131 | break; | 1131 | break; |
1132 | 1132 | ||
1133 | case ScriptEdit::Save: | 1133 | case ScriptEdit::Save: |
1134 | stl->insertItem("Save", stl->currentItem()); | 1134 | stl->insertItem("Save", stl->currentItem()); |
1135 | sl->insertItem(se->text(), sl->currentItem()); | 1135 | sl->insertItem(se->text(), sl->currentItem()); |
1136 | break; | 1136 | break; |
1137 | 1137 | ||
1138 | default: | 1138 | default: |
1139 | break; | 1139 | break; |
1140 | } | 1140 | } |
1141 | adjustScrollBar(); | 1141 | adjustScrollBar(); |
1142 | se->setText(""); | 1142 | se->setText(""); |
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | 1145 | ||
1146 | void ScriptWidget::removeButton() | 1146 | void ScriptWidget::removeButton() |
1147 | { | 1147 | { |
1148 | if(sl->currentItem() >= 0) | 1148 | if(sl->currentItem() >= 0) |
1149 | { | 1149 | { |
1150 | int stlc = stl->currentItem(); | 1150 | int stlc = stl->currentItem(); |
1151 | sl->removeItem(sl->currentItem()); | 1151 | sl->removeItem(sl->currentItem()); |
1152 | stl->removeItem(stlc); | 1152 | stl->removeItem(stlc); |
1153 | adjustScrollBar(); | 1153 | adjustScrollBar(); |
1154 | insert->setEnabled(sl->currentItem() != -1); | 1154 | insert->setEnabled(sl->currentItem() != -1); |
1155 | remove->setEnabled(sl->currentItem() != -1); | 1155 | remove->setEnabled(sl->currentItem() != -1); |
1156 | } | 1156 | } |
1157 | } | 1157 | } |
1158 | 1158 | ||
1159 | 1159 | ||
1160 | 1160 | ||
1161 | ///////////////////////////////////////////////////////////////////////////// | 1161 | ///////////////////////////////////////////////////////////////////////////// |
1162 | // | 1162 | // |
1163 | // Used to specify a new phone number | 1163 | // Used to specify a new phone number |
1164 | // | 1164 | // |
1165 | ///////////////////////////////////////////////////////////////////////////// | 1165 | ///////////////////////////////////////////////////////////////////////////// |
1166 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) | 1166 | PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) |
1167 | : QDialog(parent,"PhoneNumberDialog",true) | 1167 | : QDialog(parent,"PhoneNumberDialog",true) |
1168 | { | 1168 | { |
1169 | setCaption( tr("Add Phone Number") ); | 1169 | setCaption( tr("Add Phone Number") ); |
1170 | 1170 | ||
1171 | 1171 | ||
1172 | QVBoxLayout *layout = new QVBoxLayout( this ); | 1172 | QVBoxLayout *layout = new QVBoxLayout( this ); |
1173 | layout->setSpacing( 3 ); | 1173 | layout->setSpacing( 3 ); |
1174 | layout->setMargin( 3 ); | 1174 | layout->setMargin( 3 ); |
1175 | 1175 | ||
1176 | // QHBox *hbox = new QHBox(this); | 1176 | // QHBox *hbox = new QHBox(this); |
1177 | // setMainWidget(hbox); | 1177 | // setMainWidget(hbox); |
1178 | 1178 | ||
1179 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); | 1179 | // hbox->setSpacing( 2 );//KDialog::spacingHint()); |
1180 | 1180 | ||
1181 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); | 1181 | QLabel *label = new QLabel(this, tr("Enter a phone number:")); |
1182 | layout->addWidget( label ); | 1182 | layout->addWidget( label ); |
1183 | 1183 | ||
1184 | le = new QLineEdit(this, "lineEdit"); | 1184 | le = new QLineEdit(this, "lineEdit"); |
1185 | layout->addWidget( le ); | 1185 | layout->addWidget( le ); |
1186 | 1186 | ||
1187 | connect(le, SIGNAL(textChanged(const QString &)), | 1187 | connect(le, SIGNAL(textChanged(const QString&)), |
1188 | this, SLOT(textChanged(const QString &))); | 1188 | this, SLOT(textChanged(const QString&))); |
1189 | 1189 | ||
1190 | le->setFocus(); | 1190 | le->setFocus(); |
1191 | textChanged(""); | 1191 | textChanged(""); |
1192 | 1192 | ||
1193 | 1193 | ||
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | 1196 | ||
1197 | QString PhoneNumberDialog::phoneNumber() | 1197 | QString PhoneNumberDialog::phoneNumber() |
1198 | { | 1198 | { |
1199 | QString s = le->text(); | 1199 | QString s = le->text(); |
1200 | 1200 | ||
1201 | return s; | 1201 | return s; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | 1204 | ||
1205 | void PhoneNumberDialog::textChanged(const QString &s) | 1205 | void PhoneNumberDialog::textChanged(const QString &s) |
1206 | { | 1206 | { |
1207 | // enableButtonOK(s.length() > 0); | 1207 | // enableButtonOK(s.length() > 0); |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | 1210 | ||
1211 | //#include "edit.moc" | 1211 | //#include "edit.moc" |
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index ff1b11b..81dab38 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp | |||
@@ -1,184 +1,184 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd front end for the KDE project | 2 | * kPPP: A pppd front end for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU Library General Public | 13 | * modify it under the terms of the GNU Library General Public |
14 | * License as published by the Free Software Foundation; either | 14 | * License as published by the Free Software Foundation; either |
15 | * version 2 of the License, or (at your option) any later version. | 15 | * version 2 of the License, or (at your option) any later version. |
16 | * | 16 | * |
17 | * This program is distributed in the hope that it will be useful, | 17 | * This program is distributed in the hope that it will be useful, |
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
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 "general.h" | 27 | #include "general.h" |
28 | #include "interfaceppp.h" | 28 | #include "interfaceppp.h" |
29 | #include "modeminfo.h" | 29 | #include "modeminfo.h" |
30 | #include "modemcmds.h" | 30 | #include "modemcmds.h" |
31 | #include "pppdata.h" | 31 | #include "pppdata.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | 36 | ||
37 | /* QT */ | 37 | /* QT */ |
38 | #include <qcheckbox.h> | 38 | #include <qcheckbox.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qlabel.h> | 40 | #include <qlabel.h> |
41 | #include <qlayout.h> | 41 | #include <qlayout.h> |
42 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
43 | #include <qslider.h> | 43 | #include <qslider.h> |
44 | #include <qspinbox.h> | 44 | #include <qspinbox.h> |
45 | #include <qwhatsthis.h> | 45 | #include <qwhatsthis.h> |
46 | 46 | ||
47 | /* STD */ | 47 | /* STD */ |
48 | #include <termios.h> | 48 | #include <termios.h> |
49 | #include <string.h> | 49 | #include <string.h> |
50 | 50 | ||
51 | 51 | ||
52 | ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) | 52 | ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) |
53 | : QWidget(parent, name), _pppdata(pd) | 53 | : QWidget(parent, name), _pppdata(pd) |
54 | { | 54 | { |
55 | int k; | 55 | int k; |
56 | 56 | ||
57 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); | 57 | QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); |
58 | 58 | ||
59 | QLabel *label1; | 59 | QLabel *label1; |
60 | 60 | ||
61 | label1 = new QLabel(tr("Modem &name:"), this); | 61 | label1 = new QLabel(tr("Modem &name:"), this); |
62 | tl->addWidget(label1, 0, 0); | 62 | tl->addWidget(label1, 0, 0); |
63 | 63 | ||
64 | modemname = new QLineEdit(this, "modemName"); | 64 | modemname = new QLineEdit(this, "modemName"); |
65 | modemname->setText( _pppdata->devname() ); | 65 | modemname->setText( _pppdata->devname() ); |
66 | label1->setBuddy(modemname); | 66 | label1->setBuddy(modemname); |
67 | tl->addWidget(modemname, 0, 1); | 67 | tl->addWidget(modemname, 0, 1); |
68 | 68 | ||
69 | label1 = new QLabel(tr("Modem de&vice:"), this); | 69 | label1 = new QLabel(tr("Modem de&vice:"), this); |
70 | tl->addWidget(label1, 1, 0); | 70 | tl->addWidget(label1, 1, 0); |
71 | 71 | ||
72 | modemdevice = new QComboBox(false, this); | 72 | modemdevice = new QComboBox(false, this); |
73 | modemdevice->setEditable( true ); | 73 | modemdevice->setEditable( true ); |
74 | modemdevice->setDuplicatesEnabled ( false ); | 74 | modemdevice->setDuplicatesEnabled ( false ); |
75 | modemdevice->setInsertionPolicy( QComboBox::AtTop ); | 75 | modemdevice->setInsertionPolicy( QComboBox::AtTop ); |
76 | label1->setBuddy(modemdevice); | 76 | label1->setBuddy(modemdevice); |
77 | 77 | ||
78 | Config cfg("NetworkSetupPPP"); | 78 | Config cfg("NetworkSetupPPP"); |
79 | cfg.setGroup("Devices_General"); | 79 | cfg.setGroup("Devices_General"); |
80 | QStringList devs = cfg.readListEntry("devices",','); | 80 | QStringList devs = cfg.readListEntry("devices",','); |
81 | if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; | 81 | if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; |
82 | modemdevice->insertStringList( devs ); | 82 | modemdevice->insertStringList( devs ); |
83 | tl->addWidget(modemdevice, 1, 1); | 83 | tl->addWidget(modemdevice, 1, 1); |
84 | 84 | ||
85 | // connect(modemdevice, SIGNAL(activated(int)), | 85 | // connect(modemdevice, SIGNAL(activated(int)), |
86 | // SLOT(setmodemdc(int))); | 86 | // SLOT(setmodemdc(int))); |
87 | // connect(modemdevice, SIGNAL(textChanged( const QString & ) ), | 87 | // connect(modemdevice, SIGNAL(textChanged(const QString&) ), |
88 | // SLOT( setmodemdc( const QString &) ) ); | 88 | // SLOT( setmodemdc(const QString&) ) ); |
89 | 89 | ||
90 | QString tmp = tr("This specifies the serial port your modem is attached \n" | 90 | QString tmp = tr("This specifies the serial port your modem is attached \n" |
91 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" | 91 | "to. On Linux/x86, typically this is either /dev/ttyS0 \n" |
92 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" | 92 | "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" |
93 | "\n" | 93 | "\n" |
94 | "If you have an internal ISDN card with AT command\n" | 94 | "If you have an internal ISDN card with AT command\n" |
95 | "emulation (most cards under Linux support this), you\n" | 95 | "emulation (most cards under Linux support this), you\n" |
96 | "should select one of the /dev/ttyIx devices."); | 96 | "should select one of the /dev/ttyIx devices."); |
97 | 97 | ||
98 | QWhatsThis::add(label1,tmp); | 98 | QWhatsThis::add(label1,tmp); |
99 | QWhatsThis::add(modemdevice,tmp); | 99 | QWhatsThis::add(modemdevice,tmp); |
100 | 100 | ||
101 | 101 | ||
102 | label1 = new QLabel(tr("&Flow control:"), this); | 102 | label1 = new QLabel(tr("&Flow control:"), this); |
103 | tl->addWidget(label1, 2, 0); | 103 | tl->addWidget(label1, 2, 0); |
104 | 104 | ||
105 | flowcontrol = new QComboBox(false, this); | 105 | flowcontrol = new QComboBox(false, this); |
106 | label1->setBuddy(flowcontrol); | 106 | label1->setBuddy(flowcontrol); |
107 | flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); | 107 | flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); |
108 | flowcontrol->insertItem(tr("Software [XON/XOFF]")); | 108 | flowcontrol->insertItem(tr("Software [XON/XOFF]")); |
109 | flowcontrol->insertItem(tr("None")); | 109 | flowcontrol->insertItem(tr("None")); |
110 | tl->addWidget(flowcontrol, 2, 1); | 110 | tl->addWidget(flowcontrol, 2, 1); |
111 | // connect(flowcontrol, SIGNAL(activated(int)), | 111 | // connect(flowcontrol, SIGNAL(activated(int)), |
112 | // SLOT(setflowcontrol(int))); | 112 | // SLOT(setflowcontrol(int))); |
113 | 113 | ||
114 | tmp = tr("<p>Specifies how the serial port and modem\n" | 114 | tmp = tr("<p>Specifies how the serial port and modem\n" |
115 | "communicate. You should not change this unless\n" | 115 | "communicate. You should not change this unless\n" |
116 | "you know what you are doing.\n" | 116 | "you know what you are doing.\n" |
117 | "\n" | 117 | "\n" |
118 | "<b>Default</b>: CRTSCTS"); | 118 | "<b>Default</b>: CRTSCTS"); |
119 | 119 | ||
120 | QWhatsThis::add(label1,tmp); | 120 | QWhatsThis::add(label1,tmp); |
121 | QWhatsThis::add(flowcontrol,tmp); | 121 | QWhatsThis::add(flowcontrol,tmp); |
122 | 122 | ||
123 | QLabel *labelenter = new QLabel(tr("&Line termination:"), this); | 123 | QLabel *labelenter = new QLabel(tr("&Line termination:"), this); |
124 | tl->addWidget(labelenter, 3, 0); | 124 | tl->addWidget(labelenter, 3, 0); |
125 | 125 | ||
126 | enter = new QComboBox(false, this); | 126 | enter = new QComboBox(false, this); |
127 | labelenter->setBuddy(enter); | 127 | labelenter->setBuddy(enter); |
128 | enter->insertItem("CR"); | 128 | enter->insertItem("CR"); |
129 | enter->insertItem("LF"); | 129 | enter->insertItem("LF"); |
130 | enter->insertItem("CR/LF"); | 130 | enter->insertItem("CR/LF"); |
131 | tl->addWidget(enter, 3, 1); | 131 | tl->addWidget(enter, 3, 1); |
132 | // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); | 132 | // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); |
133 | tmp = tr("<p>Specifies how AT commands are sent to your\n" | 133 | tmp = tr("<p>Specifies how AT commands are sent to your\n" |
134 | "modem. Most modems will work fine with the\n" | 134 | "modem. Most modems will work fine with the\n" |
135 | "default <i>CR/LF</i>. If your modem does not react\n" | 135 | "default <i>CR/LF</i>. If your modem does not react\n" |
136 | "to the init string, you should try different\n" | 136 | "to the init string, you should try different\n" |
137 | "settings here\n" | 137 | "settings here\n" |
138 | "\n" | 138 | "\n" |
139 | "<b>Default</b>: CR/LF"); | 139 | "<b>Default</b>: CR/LF"); |
140 | 140 | ||
141 | QWhatsThis::add(labelenter,tmp); | 141 | QWhatsThis::add(labelenter,tmp); |
142 | QWhatsThis::add(enter, tmp); | 142 | QWhatsThis::add(enter, tmp); |
143 | 143 | ||
144 | QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); | 144 | QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); |
145 | tl->addWidget(baud_label, 4, 0); | 145 | tl->addWidget(baud_label, 4, 0); |
146 | baud_c = new QComboBox(this); | 146 | baud_c = new QComboBox(this); |
147 | baud_label->setBuddy(baud_c); | 147 | baud_label->setBuddy(baud_c); |
148 | 148 | ||
149 | static const char *baudrates[] = | 149 | static const char *baudrates[] = |
150 | { | 150 | { |
151 | 151 | ||
152 | #ifdef B460800 | 152 | #ifdef B460800 |
153 | "460800", | 153 | "460800", |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | #ifdef B230400 | 156 | #ifdef B230400 |
157 | "230400", | 157 | "230400", |
158 | #endif | 158 | #endif |
159 | 159 | ||
160 | #ifdef B115200 | 160 | #ifdef B115200 |
161 | "115200", | 161 | "115200", |
162 | #endif | 162 | #endif |
163 | 163 | ||
164 | #ifdef B57600 | 164 | #ifdef B57600 |
165 | "57600", | 165 | "57600", |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | "38400", | 168 | "38400", |
169 | "19200", | 169 | "19200", |
170 | "9600", | 170 | "9600", |
171 | "2400", | 171 | "2400", |
172 | 0 | 172 | 0 |
173 | }; | 173 | }; |
174 | 174 | ||
175 | for(k = 0; baudrates[k]; k++) | 175 | for(k = 0; baudrates[k]; k++) |
176 | baud_c->insertItem(baudrates[k]); | 176 | baud_c->insertItem(baudrates[k]); |
177 | 177 | ||
178 | baud_c->setCurrentItem(3); | 178 | baud_c->setCurrentItem(3); |
179 | // connect(baud_c, SIGNAL(activated(int)), | 179 | // connect(baud_c, SIGNAL(activated(int)), |
180 | // this, SLOT(speed_selection(int))); | 180 | // this, SLOT(speed_selection(int))); |
181 | tl->addWidget(baud_c, 4, 1); | 181 | tl->addWidget(baud_c, 4, 1); |
182 | 182 | ||
183 | tmp = tr("Specifies the speed your modem and the serial\n" | 183 | tmp = tr("Specifies the speed your modem and the serial\n" |
184 | "port talk to each other. You should begin with\n" | 184 | "port talk to each other. You should begin with\n" |
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp index e466358..e21bbc7 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.cpp +++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp | |||
@@ -303,197 +303,197 @@ KPPPWidget::~KPPPWidget() | |||
303 | 303 | ||
304 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { | 304 | // bool KPPPWidget::eventFilter(QObject *o, QEvent *e) { |
305 | // if(e->type() == QEvent::User) { | 305 | // if(e->type() == QEvent::User) { |
306 | // switch(((SignalEvent*)e)->sigType()) { | 306 | // switch(((SignalEvent*)e)->sigType()) { |
307 | // case SIGINT: | 307 | // case SIGINT: |
308 | // qDebug( "Received a SIGINT" ); | 308 | // qDebug( "Received a SIGINT" ); |
309 | // interruptConnection(); | 309 | // interruptConnection(); |
310 | // break; | 310 | // break; |
311 | // case SIGCHLD: | 311 | // case SIGCHLD: |
312 | // sigChld(); | 312 | // sigChld(); |
313 | // break; | 313 | // break; |
314 | // case SIGUSR1: | 314 | // case SIGUSR1: |
315 | // sigPPPDDied(); | 315 | // sigPPPDDied(); |
316 | // break; | 316 | // break; |
317 | // } | 317 | // } |
318 | // return true; | 318 | // return true; |
319 | // } | 319 | // } |
320 | 320 | ||
321 | // if(o == connect_b) { | 321 | // if(o == connect_b) { |
322 | // if(e->type() == QEvent::KeyPress) { | 322 | // if(e->type() == QEvent::KeyPress) { |
323 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { | 323 | // if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) { |
324 | // beginConnect(); | 324 | // beginConnect(); |
325 | // return true; | 325 | // return true; |
326 | // } | 326 | // } |
327 | // } | 327 | // } |
328 | // } | 328 | // } |
329 | 329 | ||
330 | // return false; | 330 | // return false; |
331 | // } | 331 | // } |
332 | 332 | ||
333 | 333 | ||
334 | 334 | ||
335 | 335 | ||
336 | void KPPPWidget::enterPressedInID() { | 336 | void KPPPWidget::enterPressedInID() { |
337 | PW_Edit->setFocus(); | 337 | PW_Edit->setFocus(); |
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
341 | void KPPPWidget::enterPressedInPW() { | 341 | void KPPPWidget::enterPressedInPW() { |
342 | connect_b->setFocus(); | 342 | connect_b->setFocus(); |
343 | } | 343 | } |
344 | 344 | ||
345 | // triggered by the session manager | 345 | // triggered by the session manager |
346 | void KPPPWidget::saveMyself() { | 346 | void KPPPWidget::saveMyself() { |
347 | _pppdata->save(); | 347 | _pppdata->save(); |
348 | } | 348 | } |
349 | 349 | ||
350 | void KPPPWidget::shutDown() { | 350 | void KPPPWidget::shutDown() { |
351 | interruptConnection(); | 351 | interruptConnection(); |
352 | saveMyself(); | 352 | saveMyself(); |
353 | } | 353 | } |
354 | 354 | ||
355 | void KPPPWidget::log_window_toggled(bool on) { | 355 | void KPPPWidget::log_window_toggled(bool on) { |
356 | _pppdata->set_show_log_window(on); | 356 | _pppdata->set_show_log_window(on); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | 360 | ||
361 | 361 | ||
362 | // void KPPPWidget::resetaccounts() { | 362 | // void KPPPWidget::resetaccounts() { |
363 | // connectto_c->clear(); | 363 | // connectto_c->clear(); |
364 | 364 | ||
365 | // int count = _pppdata->count(); | 365 | // int count = _pppdata->count(); |
366 | 366 | ||
367 | // // enable/disable controls | 367 | // // enable/disable controls |
368 | // connectto_c->setEnabled(count > 0); | 368 | // connectto_c->setEnabled(count > 0); |
369 | // connect_b->setEnabled(count > 0); | 369 | // connect_b->setEnabled(count > 0); |
370 | // log->setEnabled(count > 0); | 370 | // log->setEnabled(count > 0); |
371 | // ID_Edit->setEnabled(count > 0); | 371 | // ID_Edit->setEnabled(count > 0); |
372 | // PW_Edit->setEnabled(count > 0); | 372 | // PW_Edit->setEnabled(count > 0); |
373 | 373 | ||
374 | // //load the accounts | 374 | // //load the accounts |
375 | // for(int i=0; i < count; i++) { | 375 | // for(int i=0; i < count; i++) { |
376 | // _pppdata->setAccountbyIndex(i); | 376 | // _pppdata->setAccountbyIndex(i); |
377 | // connectto_c->insertItem(_pppdata->accname()); | 377 | // connectto_c->insertItem(_pppdata->accname()); |
378 | // } | 378 | // } |
379 | 379 | ||
380 | // //set the default account | 380 | // //set the default account |
381 | // if(!_pppdata->defaultAccount().isEmpty()) { | 381 | // if(!_pppdata->defaultAccount().isEmpty()) { |
382 | // for(int i=0; i < count; i++) | 382 | // for(int i=0; i < count; i++) |
383 | // if(_pppdata->defaultAccount() == connectto_c->text(i)) { | 383 | // if(_pppdata->defaultAccount() == connectto_c->text(i)) { |
384 | // connectto_c->setCurrentItem(i); | 384 | // connectto_c->setCurrentItem(i); |
385 | // _pppdata->setAccountbyIndex(i); | 385 | // _pppdata->setAccountbyIndex(i); |
386 | 386 | ||
387 | // ID_Edit->setText(_pppdata->storedUsername()); | 387 | // ID_Edit->setText(_pppdata->storedUsername()); |
388 | // PW_Edit->setText(_pppdata->storedPassword()); | 388 | // PW_Edit->setText(_pppdata->storedPassword()); |
389 | // } | 389 | // } |
390 | // } | 390 | // } |
391 | // else | 391 | // else |
392 | // if(count > 0) { | 392 | // if(count > 0) { |
393 | // _pppdata->setDefaultAccount(connectto_c->text(0)); | 393 | // _pppdata->setDefaultAccount(connectto_c->text(0)); |
394 | // _pppdata->save(); | 394 | // _pppdata->save(); |
395 | // ID_Edit->setText(_pppdata->storedUsername()); | 395 | // ID_Edit->setText(_pppdata->storedUsername()); |
396 | // PW_Edit->setText(_pppdata->storedPassword()); | 396 | // PW_Edit->setText(_pppdata->storedPassword()); |
397 | // } | 397 | // } |
398 | 398 | ||
399 | // connect(ID_Edit, SIGNAL(textChanged(const QString &)), | 399 | // connect(ID_Edit, SIGNAL(textChanged(const QString&)), |
400 | // this, SLOT(usernameChanged(const QString &))); | 400 | // this, SLOT(usernameChanged(const QString&))); |
401 | 401 | ||
402 | // connect(PW_Edit, SIGNAL(textChanged(const QString &)), | 402 | // connect(PW_Edit, SIGNAL(textChanged(const QString&)), |
403 | // this, SLOT(passwordChanged(const QString &))); | 403 | // this, SLOT(passwordChanged(const QString&))); |
404 | 404 | ||
405 | // if (ID_Edit->text().isEmpty()) | 405 | // if (ID_Edit->text().isEmpty()) |
406 | // ID_Edit->setFocus(); | 406 | // ID_Edit->setFocus(); |
407 | // else if (PW_Edit->text().isEmpty()) | 407 | // else if (PW_Edit->text().isEmpty()) |
408 | // PW_Edit->setFocus(); | 408 | // PW_Edit->setFocus(); |
409 | // } | 409 | // } |
410 | 410 | ||
411 | 411 | ||
412 | void KPPPWidget::interruptConnection() { | 412 | void KPPPWidget::interruptConnection() { |
413 | // interrupt dial up | 413 | // interrupt dial up |
414 | // | 414 | // |
415 | 415 | ||
416 | if (con->isVisible()) | 416 | if (con->isVisible()) |
417 | emit con->cancelbutton(); | 417 | emit con->cancelbutton(); |
418 | 418 | ||
419 | // disconnect if online | 419 | // disconnect if online |
420 | if (_pppdata->pppdRunning()) | 420 | if (_pppdata->pppdRunning()) |
421 | emit disconnect(); | 421 | emit disconnect(); |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | void KPPPWidget::sigPPPDDied() { | 425 | void KPPPWidget::sigPPPDDied() { |
426 | qDebug( "Received a SIGUSR1" ); | 426 | qDebug( "Received a SIGUSR1" ); |
427 | 427 | ||
428 | // if we are not connected pppdpid is -1 so have have to check for that | 428 | // if we are not connected pppdpid is -1 so have have to check for that |
429 | // in the followin line to make sure that we don't raise a false alarm | 429 | // in the followin line to make sure that we don't raise a false alarm |
430 | // such as would be the case when the log file viewer exits. | 430 | // such as would be the case when the log file viewer exits. |
431 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { | 431 | if(_pppdata->pppdRunning() || _pppdata->pppdError()) { |
432 | qDebug( "It was pppd that died" ); | 432 | qDebug( "It was pppd that died" ); |
433 | 433 | ||
434 | // when we killpppd() on Cancel in ConnectWidget | 434 | // when we killpppd() on Cancel in ConnectWidget |
435 | // we set pppid to -1 so we won't | 435 | // we set pppid to -1 so we won't |
436 | // enter this block | 436 | // enter this block |
437 | 437 | ||
438 | // just to be sure | 438 | // just to be sure |
439 | 439 | ||
440 | Modem::modem->removeSecret(AUTH_PAP); | 440 | Modem::modem->removeSecret(AUTH_PAP); |
441 | Modem::modem->removeSecret(AUTH_CHAP); | 441 | Modem::modem->removeSecret(AUTH_CHAP); |
442 | 442 | ||
443 | _pppdata->setpppdRunning(false); | 443 | _pppdata->setpppdRunning(false); |
444 | 444 | ||
445 | qDebug( "Executing command on disconnect since pppd has died." ); | 445 | qDebug( "Executing command on disconnect since pppd has died." ); |
446 | QApplication::flushX(); | 446 | QApplication::flushX(); |
447 | execute_command(_pppdata->command_on_disconnect()); | 447 | execute_command(_pppdata->command_on_disconnect()); |
448 | 448 | ||
449 | // stopAccounting(); | 449 | // stopAccounting(); |
450 | 450 | ||
451 | con_win->stopClock(); | 451 | con_win->stopClock(); |
452 | // DockWidget::dock_widget->stop_stats(); | 452 | // DockWidget::dock_widget->stop_stats(); |
453 | // DockWidget::dock_widget->hide(); | 453 | // DockWidget::dock_widget->hide(); |
454 | 454 | ||
455 | if(!_pppdata->pppdError()) | 455 | if(!_pppdata->pppdError()) |
456 | _pppdata->setpppdError(E_PPPD_DIED); | 456 | _pppdata->setpppdError(E_PPPD_DIED); |
457 | removedns(); | 457 | removedns(); |
458 | Modem::modem->unlockdevice(); | 458 | Modem::modem->unlockdevice(); |
459 | // | 459 | // |
460 | con->pppdDied(); | 460 | con->pppdDied(); |
461 | 461 | ||
462 | if(!_pppdata->automatic_redial()) { | 462 | if(!_pppdata->automatic_redial()) { |
463 | quit_b->setFocus(); | 463 | quit_b->setFocus(); |
464 | show(); | 464 | show(); |
465 | con_win->stopClock(); | 465 | con_win->stopClock(); |
466 | //stopAccounting(); | 466 | //stopAccounting(); |
467 | con_win->hide(); | 467 | con_win->hide(); |
468 | con->hide(); | 468 | con->hide(); |
469 | 469 | ||
470 | _pppdata->setpppdRunning(false); | 470 | _pppdata->setpppdRunning(false); |
471 | // // not in a signal handler !!! KNotifyClient::beep(); | 471 | // // not in a signal handler !!! KNotifyClient::beep(); |
472 | QString msg; | 472 | QString msg; |
473 | if (_pppdata->pppdError() == E_IF_TIMEOUT) | 473 | if (_pppdata->pppdError() == E_IF_TIMEOUT) |
474 | msg = QObject::tr("Timeout expired while waiting for the PPP interface " | 474 | msg = QObject::tr("Timeout expired while waiting for the PPP interface " |
475 | "to come up!"); | 475 | "to come up!"); |
476 | else { | 476 | else { |
477 | msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>"); | 477 | msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>"); |
478 | Modem::modem->pppdExitStatus(); | 478 | Modem::modem->pppdExitStatus(); |
479 | if (Modem::modem->lastStatus != 99) {// more recent pppds only | 479 | if (Modem::modem->lastStatus != 99) {// more recent pppds only |
480 | msg += QObject::tr("<p>Exit status: %1").arg(Modem::modem->lastStatus); | 480 | msg += QObject::tr("<p>Exit status: %1").arg(Modem::modem->lastStatus); |
481 | msg += QObject::tr("</p><p>See 'man pppd' for an explanation of the error " | 481 | msg += QObject::tr("</p><p>See 'man pppd' for an explanation of the error " |
482 | "codes or take a look at the kppp FAQ on " | 482 | "codes or take a look at the kppp FAQ on " |
483 | " <a href=http://devel-home.kde.org/~kppp/index.html>" | 483 | " <a href=http://devel-home.kde.org/~kppp/index.html>" |
484 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); | 484 | "http://devel-home.kde.org/~kppp/index.html</a></p>"); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | // if(QMessageBox::warning(0, msg, QObject::tr("Error"), QObject::tr("&OK"), QObject::tr("&Details...")) == QMessageBox::No) | 488 | // if(QMessageBox::warning(0, msg, QObject::tr("Error"), QObject::tr("&OK"), QObject::tr("&Details...")) == QMessageBox::No) |
489 | // // PPPL_ShowLog(); | 489 | // // PPPL_ShowLog(); |
490 | // } else { /* reconnect on disconnect */ | 490 | // } else { /* reconnect on disconnect */ |
491 | if (false){ | 491 | if (false){ |
492 | qDebug( "Trying to reconnect... " ); | 492 | qDebug( "Trying to reconnect... " ); |
493 | 493 | ||
494 | if(_pppdata->authMethod() == AUTH_PAP || | 494 | if(_pppdata->authMethod() == AUTH_PAP || |
495 | _pppdata->authMethod() == AUTH_CHAP || | 495 | _pppdata->authMethod() == AUTH_CHAP || |
496 | _pppdata->authMethod() == AUTH_PAPCHAP) | 496 | _pppdata->authMethod() == AUTH_PAPCHAP) |
497 | Modem::modem->setSecret(_pppdata->authMethod(), | 497 | Modem::modem->setSecret(_pppdata->authMethod(), |
498 | encodeWord(_pppdata->storedUsername()), | 498 | encodeWord(_pppdata->storedUsername()), |
499 | encodeWord(_pppdata->password())); | 499 | encodeWord(_pppdata->password())); |
@@ -628,194 +628,194 @@ void KPPPWidget::disconnect() { | |||
628 | con->setCaption(QObject::tr("Disconnecting...")); | 628 | con->setCaption(QObject::tr("Disconnecting...")); |
629 | con->setMsg(QObject::tr("Executing command before disconnection.")); | 629 | con->setMsg(QObject::tr("Executing command before disconnection.")); |
630 | 630 | ||
631 | qApp->processEvents(); | 631 | qApp->processEvents(); |
632 | QApplication::flushX(); | 632 | QApplication::flushX(); |
633 | // pid_t id = | 633 | // pid_t id = |
634 | execute_command(_pppdata->command_before_disconnect()); | 634 | execute_command(_pppdata->command_before_disconnect()); |
635 | // int i, status; | 635 | // int i, status; |
636 | 636 | ||
637 | // do { | 637 | // do { |
638 | // kapp->processEvents(); | 638 | // kapp->processEvents(); |
639 | // i = waitpid(id, &status, WNOHANG); | 639 | // i = waitpid(id, &status, WNOHANG); |
640 | // usleep(500000); | 640 | // usleep(500000); |
641 | // } while (i == 0 && errno == 0); | 641 | // } while (i == 0 && errno == 0); |
642 | 642 | ||
643 | con->hide(); | 643 | con->hide(); |
644 | } | 644 | } |
645 | 645 | ||
646 | qApp->processEvents(); | 646 | qApp->processEvents(); |
647 | 647 | ||
648 | // statdlg->stop_stats(); | 648 | // statdlg->stop_stats(); |
649 | Modem::modem->killPPPDaemon(); | 649 | Modem::modem->killPPPDaemon(); |
650 | 650 | ||
651 | QApplication::flushX(); | 651 | QApplication::flushX(); |
652 | execute_command(_pppdata->command_on_disconnect()); | 652 | execute_command(_pppdata->command_on_disconnect()); |
653 | 653 | ||
654 | Modem::modem->removeSecret(AUTH_PAP); | 654 | Modem::modem->removeSecret(AUTH_PAP); |
655 | Modem::modem->removeSecret(AUTH_CHAP); | 655 | Modem::modem->removeSecret(AUTH_CHAP); |
656 | 656 | ||
657 | removedns(); | 657 | removedns(); |
658 | Modem::modem->unlockdevice(); | 658 | Modem::modem->unlockdevice(); |
659 | 659 | ||
660 | con_win->stopClock(); | 660 | con_win->stopClock(); |
661 | // p_kppp->stopAccounting(); | 661 | // p_kppp->stopAccounting(); |
662 | con_win->hide(); | 662 | con_win->hide(); |
663 | 663 | ||
664 | // DockWidget::dock_widget->stop_stats(); | 664 | // DockWidget::dock_widget->stop_stats(); |
665 | // DockWidget::dock_widget->hide(); | 665 | // DockWidget::dock_widget->hide(); |
666 | 666 | ||
667 | // if(m_bQuitOnDisconnect) | 667 | // if(m_bQuitOnDisconnect) |
668 | // kapp->exit(0); | 668 | // kapp->exit(0); |
669 | // else { | 669 | // else { |
670 | this->quit_b->setFocus(); | 670 | this->quit_b->setFocus(); |
671 | this->show(); | 671 | this->show(); |
672 | // } | 672 | // } |
673 | } | 673 | } |
674 | 674 | ||
675 | 675 | ||
676 | // void KPPPWidget::helpbutton() { | 676 | // void KPPPWidget::helpbutton() { |
677 | // kapp->invokeHelp(); | 677 | // kapp->invokeHelp(); |
678 | // } | 678 | // } |
679 | 679 | ||
680 | 680 | ||
681 | void KPPPWidget::quitbutton() { | 681 | void KPPPWidget::quitbutton() { |
682 | if(_pppdata->pppdRunning()) { | 682 | if(_pppdata->pppdRunning()) { |
683 | int ok = QMessageBox::warning(this, | 683 | int ok = QMessageBox::warning(this, |
684 | QObject::tr("Exiting kPPP will close your PPP Session."), | 684 | QObject::tr("Exiting kPPP will close your PPP Session."), |
685 | QObject::tr("Quit kPPP?")); | 685 | QObject::tr("Quit kPPP?")); |
686 | if(ok == QMessageBox::Yes) { | 686 | if(ok == QMessageBox::Yes) { |
687 | Modem::modem->killPPPDaemon(); | 687 | Modem::modem->killPPPDaemon(); |
688 | QApplication::flushX(); | 688 | QApplication::flushX(); |
689 | execute_command(_pppdata->command_on_disconnect()); | 689 | execute_command(_pppdata->command_on_disconnect()); |
690 | removedns(); | 690 | removedns(); |
691 | Modem::modem->unlockdevice(); | 691 | Modem::modem->unlockdevice(); |
692 | } | 692 | } |
693 | } else { | 693 | } else { |
694 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) | 694 | if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword()) |
695 | _pppdata->setStoredPassword(""); | 695 | _pppdata->setStoredPassword(""); |
696 | } | 696 | } |
697 | _pppdata->save(); | 697 | _pppdata->save(); |
698 | qApp->quit(); | 698 | qApp->quit(); |
699 | } | 699 | } |
700 | 700 | ||
701 | 701 | ||
702 | // void KPPPWidget::rulesetLoadError() { | 702 | // void KPPPWidget::rulesetLoadError() { |
703 | // QMessageBox::warning(this,"error", ruleset_load_errmsg); | 703 | // QMessageBox::warning(this,"error", ruleset_load_errmsg); |
704 | // } | 704 | // } |
705 | 705 | ||
706 | 706 | ||
707 | // void KPPPWidget::startAccounting() { | 707 | // void KPPPWidget::startAccounting() { |
708 | // // volume accounting | 708 | // // volume accounting |
709 | // stats->totalbytes = 0; | 709 | // stats->totalbytes = 0; |
710 | 710 | ||
711 | // kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl; | 711 | // kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl; |
712 | 712 | ||
713 | // // load the ruleset | 713 | // // load the ruleset |
714 | // if(!_pppdata->AcctEnabled()) | 714 | // if(!_pppdata->AcctEnabled()) |
715 | // return; | 715 | // return; |
716 | 716 | ||
717 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); | 717 | // QString d = AccountingBase::getAccountingFile(_pppdata->accountingFile()); |
718 | // // if(::access(d.data(), X_OK) != 0) | 718 | // // if(::access(d.data(), X_OK) != 0) |
719 | // acct = new Accounting(this, stats); | 719 | // acct = new Accounting(this, stats); |
720 | // // else | 720 | // // else |
721 | // // acct = new ExecutableAccounting(this); | 721 | // // acct = new ExecutableAccounting(this); |
722 | 722 | ||
723 | // // connect to the accounting object | 723 | // // connect to the accounting object |
724 | // connect(acct, SIGNAL(changed(QString, QString)), | 724 | // connect(acct, SIGNAL(changed(QString,QString)), |
725 | // con_win, SLOT(slotAccounting(QString, QString))); | 725 | // con_win, SLOT(slotAccounting(QString,QString))); |
726 | 726 | ||
727 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { | 727 | // // if(!acct->loadRuleSet(_pppdata->accountingFile())) { |
728 | // // QString s= QObject::tr("Can not load the accounting " | 728 | // // QString s= QObject::tr("Can not load the accounting " |
729 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); | 729 | // // "ruleset \"%1\"!").arg(_pppdata->accountingFile()); |
730 | 730 | ||
731 | // // starting the messagebox with a timer will prevent us | 731 | // // starting the messagebox with a timer will prevent us |
732 | // // from blocking the calling function ConnectWidget::timerEvent | 732 | // // from blocking the calling function ConnectWidget::timerEvent |
733 | // ruleset_load_errmsg = s; | 733 | // ruleset_load_errmsg = s; |
734 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); | 734 | // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); |
735 | // return; | 735 | // return; |
736 | // } | 736 | // } |
737 | // //else | 737 | // //else |
738 | // // acct->slotStart(); | 738 | // // acct->slotStart(); |
739 | // } | 739 | // } |
740 | 740 | ||
741 | // void KPPPWidget::stopAccounting() { | 741 | // void KPPPWidget::stopAccounting() { |
742 | // // store volume accounting | 742 | // // store volume accounting |
743 | // // if(stats->totalbytes != 0) | 743 | // // if(stats->totalbytes != 0) |
744 | // // _pppdata->setTotalBytes(stats->totalbytes); | 744 | // // _pppdata->setTotalBytes(stats->totalbytes); |
745 | 745 | ||
746 | // if(!_pppdata->AcctEnabled()) | 746 | // if(!_pppdata->AcctEnabled()) |
747 | // return; | 747 | // return; |
748 | 748 | ||
749 | // // if(acct != 0) { | 749 | // // if(acct != 0) { |
750 | // // acct->slotStop(); | 750 | // // acct->slotStop(); |
751 | // // delete acct; | 751 | // // delete acct; |
752 | // // acct = 0; | 752 | // // acct = 0; |
753 | // // } | 753 | // // } |
754 | // } | 754 | // } |
755 | 755 | ||
756 | 756 | ||
757 | // void KPPPWidget::showStats() { | 757 | // void KPPPWidget::showStats() { |
758 | // if(statdlg) { | 758 | // if(statdlg) { |
759 | // statdlg->show(); | 759 | // statdlg->show(); |
760 | // statdlg->raise(); | 760 | // statdlg->raise(); |
761 | // } | 761 | // } |
762 | // } | 762 | // } |
763 | 763 | ||
764 | 764 | ||
765 | void KPPPWidget::usernameChanged(const QString &) { | 765 | void KPPPWidget::usernameChanged(const QString &) { |
766 | // store username for later use | 766 | // store username for later use |
767 | _pppdata->setStoredUsername(ID_Edit->text()); | 767 | _pppdata->setStoredUsername(ID_Edit->text()); |
768 | } | 768 | } |
769 | 769 | ||
770 | 770 | ||
771 | void KPPPWidget::passwordChanged(const QString &) { | 771 | void KPPPWidget::passwordChanged(const QString &) { |
772 | // store the password if so requested | 772 | // store the password if so requested |
773 | if(_pppdata->storePassword()) | 773 | if(_pppdata->storePassword()) |
774 | _pppdata->setStoredPassword(PW_Edit->text()); | 774 | _pppdata->setStoredPassword(PW_Edit->text()); |
775 | else | 775 | else |
776 | _pppdata->setStoredPassword(""); | 776 | _pppdata->setStoredPassword(""); |
777 | } | 777 | } |
778 | 778 | ||
779 | 779 | ||
780 | void KPPPWidget::setPW_Edit(const QString &pw) { | 780 | void KPPPWidget::setPW_Edit(const QString &pw) { |
781 | PW_Edit->setText(pw); | 781 | PW_Edit->setText(pw); |
782 | } | 782 | } |
783 | 783 | ||
784 | 784 | ||
785 | // void KPPPWidget::resetCosts(const QString &s) { | 785 | // void KPPPWidget::resetCosts(const QString &s) { |
786 | // AccountingBase::resetCosts(s); | 786 | // AccountingBase::resetCosts(s); |
787 | // } | 787 | // } |
788 | 788 | ||
789 | 789 | ||
790 | // void KPPPWidget::resetVolume(const QString &s) { | 790 | // void KPPPWidget::resetVolume(const QString &s) { |
791 | // AccountingBase::resetVolume(s); | 791 | // AccountingBase::resetVolume(s); |
792 | // } | 792 | // } |
793 | 793 | ||
794 | /** | 794 | /** |
795 | * pppd's getword() function knows about escape characters. | 795 | * pppd's getword() function knows about escape characters. |
796 | * If we write the username and password to the secrets file | 796 | * If we write the username and password to the secrets file |
797 | * we'll therefore have to escape back slashes. | 797 | * we'll therefore have to escape back slashes. |
798 | */ | 798 | */ |
799 | QString KPPPWidget::encodeWord(const QString &s) { | 799 | QString KPPPWidget::encodeWord(const QString &s) { |
800 | QString r = s; | 800 | QString r = s; |
801 | r.replace(QRegExp("\\"), "\\\\"); | 801 | r.replace(QRegExp("\\"), "\\\\"); |
802 | return r; | 802 | return r; |
803 | } | 803 | } |
804 | 804 | ||
805 | // void KPPPWidget::setQuitOnDisconnect (bool b) | 805 | // void KPPPWidget::setQuitOnDisconnect (bool b) |
806 | // { | 806 | // { |
807 | // m_bQuitOnDisconnect = b; | 807 | // m_bQuitOnDisconnect = b; |
808 | // } | 808 | // } |
809 | 809 | ||
810 | void KPPPWidget::showNews() { | 810 | void KPPPWidget::showNews() { |
811 | #ifdef KPPP_SHOW_NEWS | 811 | #ifdef KPPP_SHOW_NEWS |
812 | /* | 812 | /* |
813 | * Introduce the QuickHelp feature to new users of this version | 813 | * Introduce the QuickHelp feature to new users of this version |
814 | */ | 814 | */ |
815 | #define QUICKHELP_HINT "Hint_QuickHelp" | 815 | #define QUICKHELP_HINT "Hint_QuickHelp" |
816 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { | 816 | if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { |
817 | QDialog dlg(0, 0, true); | 817 | QDialog dlg(0, 0, true); |
818 | dlg.setCaption(QObject::tr("Recent Changes in KPPP")); | 818 | dlg.setCaption(QObject::tr("Recent Changes in KPPP")); |
819 | 819 | ||
820 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); | 820 | QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); |
821 | QHBoxLayout *l1 = new QHBoxLayout(10); | 821 | QHBoxLayout *l1 = new QHBoxLayout(10); |
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp index 66a4d82..d6d8d88 100644 --- a/noncore/settings/networksettings/ppp/pppdargs.cpp +++ b/noncore/settings/networksettings/ppp/pppdargs.cpp | |||
@@ -1,151 +1,151 @@ | |||
1 | /* | 1 | /* |
2 | * kPPP: A pppd front end for the KDE project | 2 | * kPPP: A pppd front end for the KDE project |
3 | * | 3 | * |
4 | * $Id$ | 4 | * $Id$ |
5 | * | 5 | * |
6 | * Copyright (C) 1997 Bernd Johannes Wuebben | 6 | * Copyright (C) 1997 Bernd Johannes Wuebben |
7 | * wuebben@math.cornell.edu | 7 | * wuebben@math.cornell.edu |
8 | * | 8 | * |
9 | * based on EzPPP: | 9 | * based on EzPPP: |
10 | * Copyright (C) 1997 Jay Painter | 10 | * Copyright (C) 1997 Jay Painter |
11 | * | 11 | * |
12 | * | 12 | * |
13 | * This library is free software; you can redistribute it and/or | 13 | * This library is free software; you can redistribute it and/or |
14 | * modify it under the terms of the GNU Library General Public | 14 | * modify it under the terms of the GNU Library General Public |
15 | * License as published by the Free Software Foundation; either | 15 | * License as published by the Free Software Foundation; either |
16 | * version 2 of the License, or (at your option) any later version. | 16 | * version 2 of the License, or (at your option) any later version. |
17 | * | 17 | * |
18 | * This library is distributed in the hope that it will be useful, | 18 | * This library is distributed in the hope that it will be useful, |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
21 | * Library General Public License for more details. | 21 | * Library General Public License for more details. |
22 | * | 22 | * |
23 | * You should have received a copy of the GNU Library General Public | 23 | * You should have received a copy of the GNU Library General Public |
24 | * License along with this program; if not, write to the Free | 24 | * License along with this program; if not, write to the Free |
25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qbuttongroup.h> | 29 | #include <qbuttongroup.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | #include "pppdargs.h" | 31 | #include "pppdargs.h" |
32 | #include "pppdata.h" | 32 | #include "pppdata.h" |
33 | 33 | ||
34 | 34 | ||
35 | PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name) | 35 | PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name) |
36 | : QDialog(parent, name, TRUE), _pppdata(pd) | 36 | : QDialog(parent, name, TRUE), _pppdata(pd) |
37 | { | 37 | { |
38 | setCaption(tr("Customize pppd Arguments")); | 38 | setCaption(tr("Customize pppd Arguments")); |
39 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); | 39 | // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); |
40 | QVBoxLayout *l = new QVBoxLayout(this, 10, 10); | 40 | QVBoxLayout *l = new QVBoxLayout(this, 10, 10); |
41 | QHBoxLayout *tl = new QHBoxLayout(10); | 41 | QHBoxLayout *tl = new QHBoxLayout(10); |
42 | l->addLayout(tl); | 42 | l->addLayout(tl); |
43 | QVBoxLayout *l1 = new QVBoxLayout(); | 43 | QVBoxLayout *l1 = new QVBoxLayout(); |
44 | QVBoxLayout *l2 = new QVBoxLayout(); | 44 | QVBoxLayout *l2 = new QVBoxLayout(); |
45 | tl->addLayout(l1, 1); | 45 | tl->addLayout(l1, 1); |
46 | tl->addLayout(l2, 0); | 46 | tl->addLayout(l2, 0); |
47 | 47 | ||
48 | QHBoxLayout *l11 = new QHBoxLayout(10); | 48 | QHBoxLayout *l11 = new QHBoxLayout(10); |
49 | l1->addLayout(l11); | 49 | l1->addLayout(l11); |
50 | 50 | ||
51 | argument_label = new QLabel(tr("Argument:"), this); | 51 | argument_label = new QLabel(tr("Argument:"), this); |
52 | l11->addWidget(argument_label); | 52 | l11->addWidget(argument_label); |
53 | 53 | ||
54 | argument = new QLineEdit(this); | 54 | argument = new QLineEdit(this); |
55 | connect(argument, SIGNAL(returnPressed()), | 55 | connect(argument, SIGNAL(returnPressed()), |
56 | SLOT(addbutton())); | 56 | SLOT(addbutton())); |
57 | l11->addWidget(argument); | 57 | l11->addWidget(argument); |
58 | connect(argument, SIGNAL(textChanged(const QString &)), | 58 | connect(argument, SIGNAL(textChanged(const QString&)), |
59 | this, SLOT(textChanged(const QString &))); | 59 | this, SLOT(textChanged(const QString&))); |
60 | 60 | ||
61 | arguments = new QListBox(this); | 61 | arguments = new QListBox(this); |
62 | arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); | 62 | arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10); |
63 | connect(arguments, SIGNAL(highlighted(int)), | 63 | connect(arguments, SIGNAL(highlighted(int)), |
64 | this, SLOT(itemSelected(int))); | 64 | this, SLOT(itemSelected(int))); |
65 | l1->addWidget(arguments, 1); | 65 | l1->addWidget(arguments, 1); |
66 | 66 | ||
67 | add = new QPushButton(tr("Add"), this); | 67 | add = new QPushButton(tr("Add"), this); |
68 | connect(add, SIGNAL(clicked()), SLOT(addbutton())); | 68 | connect(add, SIGNAL(clicked()), SLOT(addbutton())); |
69 | l2->addWidget(add); | 69 | l2->addWidget(add); |
70 | l2->addStretch(1); | 70 | l2->addStretch(1); |
71 | 71 | ||
72 | remove = new QPushButton(tr("Remove"), this); | 72 | remove = new QPushButton(tr("Remove"), this); |
73 | connect(remove, SIGNAL(clicked()), SLOT(removebutton())); | 73 | connect(remove, SIGNAL(clicked()), SLOT(removebutton())); |
74 | l2->addWidget(remove); | 74 | l2->addWidget(remove); |
75 | 75 | ||
76 | defaults = new QPushButton(tr("Defaults"), this); | 76 | defaults = new QPushButton(tr("Defaults"), this); |
77 | connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); | 77 | connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton())); |
78 | l2->addWidget(defaults); | 78 | l2->addWidget(defaults); |
79 | 79 | ||
80 | l->addSpacing(5); | 80 | l->addSpacing(5); |
81 | 81 | ||
82 | 82 | ||
83 | //load info from gpppdata | 83 | //load info from gpppdata |
84 | init(); | 84 | init(); |
85 | 85 | ||
86 | add->setEnabled(false); | 86 | add->setEnabled(false); |
87 | remove->setEnabled(false); | 87 | remove->setEnabled(false); |
88 | argument->setFocus(); | 88 | argument->setFocus(); |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void PPPdArguments::addbutton() { | 92 | void PPPdArguments::addbutton() { |
93 | if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { | 93 | if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) { |
94 | arguments->insertItem(argument->text()); | 94 | arguments->insertItem(argument->text()); |
95 | argument->setText(""); | 95 | argument->setText(""); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void PPPdArguments::removebutton() { | 100 | void PPPdArguments::removebutton() { |
101 | if(arguments->currentItem() >= 0) | 101 | if(arguments->currentItem() >= 0) |
102 | arguments->removeItem(arguments->currentItem()); | 102 | arguments->removeItem(arguments->currentItem()); |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
106 | void PPPdArguments::defaultsbutton() { | 106 | void PPPdArguments::defaultsbutton() { |
107 | // all of this is a hack | 107 | // all of this is a hack |
108 | // save current list | 108 | // save current list |
109 | QStringList arglist(_pppdata->pppdArgument()); | 109 | QStringList arglist(_pppdata->pppdArgument()); |
110 | 110 | ||
111 | // get defaults | 111 | // get defaults |
112 | _pppdata->setpppdArgumentDefaults(); | 112 | _pppdata->setpppdArgumentDefaults(); |
113 | init(); | 113 | init(); |
114 | 114 | ||
115 | // restore old list | 115 | // restore old list |
116 | _pppdata->setpppdArgument(arglist); | 116 | _pppdata->setpppdArgument(arglist); |
117 | } | 117 | } |
118 | 118 | ||
119 | 119 | ||
120 | void PPPdArguments::accept() { | 120 | void PPPdArguments::accept() { |
121 | QStringList arglist; | 121 | QStringList arglist; |
122 | for(uint i=0; i < arguments->count(); i++) | 122 | for(uint i=0; i < arguments->count(); i++) |
123 | arglist.append(arguments->text(i)); | 123 | arglist.append(arguments->text(i)); |
124 | _pppdata->setpppdArgument(arglist); | 124 | _pppdata->setpppdArgument(arglist); |
125 | 125 | ||
126 | QDialog::accept(); | 126 | QDialog::accept(); |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | void PPPdArguments::init() { | 130 | void PPPdArguments::init() { |
131 | while(arguments->count()) | 131 | while(arguments->count()) |
132 | arguments->removeItem(0); | 132 | arguments->removeItem(0); |
133 | 133 | ||
134 | QStringList &arglist = _pppdata->pppdArgument(); | 134 | QStringList &arglist = _pppdata->pppdArgument(); |
135 | for ( QStringList::Iterator it = arglist.begin(); | 135 | for ( QStringList::Iterator it = arglist.begin(); |
136 | it != arglist.end(); | 136 | it != arglist.end(); |
137 | ++it ) | 137 | ++it ) |
138 | arguments->insertItem(*it); | 138 | arguments->insertItem(*it); |
139 | } | 139 | } |
140 | 140 | ||
141 | 141 | ||
142 | void PPPdArguments::textChanged(const QString &s) { | 142 | void PPPdArguments::textChanged(const QString &s) { |
143 | add->setEnabled(s.length() > 0); | 143 | add->setEnabled(s.length() > 0); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | void PPPdArguments::itemSelected(int idx) { | 147 | void PPPdArguments::itemSelected(int idx) { |
148 | remove->setEnabled(idx != -1); | 148 | remove->setEnabled(idx != -1); |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index 92339d6..dd1db28 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp | |||
@@ -1,153 +1,153 @@ | |||
1 | #include "wlanimp2.h" | 1 | #include "wlanimp2.h" |
2 | #include "keyedit.h" | 2 | #include "keyedit.h" |
3 | #include "interfacesetupimp.h" | 3 | #include "interfacesetupimp.h" |
4 | 4 | ||
5 | #include "../interfaces/interface.h" | 5 | #include "../interfaces/interface.h" |
6 | 6 | ||
7 | #include <assert.h> | 7 | #include <assert.h> |
8 | #include <errno.h> | 8 | #include <errno.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | 10 | ||
11 | #include <qapplication.h> | 11 | #include <qapplication.h> |
12 | #include <qfile.h> | 12 | #include <qfile.h> |
13 | #include <qdir.h> | 13 | #include <qdir.h> |
14 | #include <qdialog.h> | 14 | #include <qdialog.h> |
15 | #include <qtextstream.h> | 15 | #include <qtextstream.h> |
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | #include <qlineedit.h> | 17 | #include <qlineedit.h> |
18 | #include <qlabel.h> | 18 | #include <qlabel.h> |
19 | #include <qspinbox.h> | 19 | #include <qspinbox.h> |
20 | #include <qradiobutton.h> | 20 | #include <qradiobutton.h> |
21 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
22 | #include <qcheckbox.h> | 22 | #include <qcheckbox.h> |
23 | #include <qtabwidget.h> | 23 | #include <qtabwidget.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qprogressbar.h> | 27 | #include <qprogressbar.h> |
28 | 28 | ||
29 | #ifdef QWS | 29 | #ifdef QWS |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <opie2/oprocess.h> | 31 | #include <opie2/oprocess.h> |
32 | #include <opie2/onetwork.h> | 32 | #include <opie2/onetwork.h> |
33 | #include <opie2/opcap.h> | 33 | #include <opie2/opcap.h> |
34 | #else | 34 | #else |
35 | #define OProcess KProcess | 35 | #define OProcess KProcess |
36 | #include <kprocess.h> | 36 | #include <kprocess.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" | 39 | #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" |
40 | #define PREUP "/etc/network/if-pre-up.d/wireless-tools" | 40 | #define PREUP "/etc/network/if-pre-up.d/wireless-tools" |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Constructor, read in the wireless.opts file for parsing later. | 43 | * Constructor, read in the wireless.opts file for parsing later. |
44 | */ | 44 | */ |
45 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { | 45 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { |
46 | interfaces = new Interfaces(); | 46 | interfaces = new Interfaces(); |
47 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); | 47 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); |
48 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 48 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
49 | 49 | ||
50 | // Check sanity - the existance of the wireless-tools if-pre-up script | 50 | // Check sanity - the existance of the wireless-tools if-pre-up script |
51 | QFile file(QString(PREUP)); | 51 | QFile file(QString(PREUP)); |
52 | if (file.exists()) { | 52 | if (file.exists()) { |
53 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); | 53 | qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools")); |
54 | } | 54 | } |
55 | 55 | ||
56 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); | 56 | connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); |
57 | connect( netView, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectNetwork( QListViewItem* ) ) ); | 57 | connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); |
58 | netView->setColumnAlignment( col_chn, AlignCenter ); | 58 | netView->setColumnAlignment( col_chn, AlignCenter ); |
59 | netView->setItemMargin( 3 ); | 59 | netView->setItemMargin( 3 ); |
60 | netView->setAllColumnsShowFocus( true ); | 60 | netView->setAllColumnsShowFocus( true ); |
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
64 | WLANImp::~WLANImp() { | 64 | WLANImp::~WLANImp() { |
65 | //FIXME: delete interfaces; | 65 | //FIXME: delete interfaces; |
66 | } | 66 | } |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Change the profile for both wireless settings and network settings. | 69 | * Change the profile for both wireless settings and network settings. |
70 | */ | 70 | */ |
71 | void WLANImp::setProfile(const QString &profile){ | 71 | void WLANImp::setProfile(const QString &profile){ |
72 | interfaceSetup->setProfile(profile); | 72 | interfaceSetup->setProfile(profile); |
73 | parseOpts(); | 73 | parseOpts(); |
74 | } | 74 | } |
75 | 75 | ||
76 | void WLANImp::parseOpts() { | 76 | void WLANImp::parseOpts() { |
77 | bool error; | 77 | bool error; |
78 | QString opt; | 78 | QString opt; |
79 | 79 | ||
80 | if (! interfaces->isInterfaceSet()) | 80 | if (! interfaces->isInterfaceSet()) |
81 | return; | 81 | return; |
82 | 82 | ||
83 | 83 | ||
84 | opt = interfaces->getInterfaceOption("wireless_essid", error); | 84 | opt = interfaces->getInterfaceOption("wireless_essid", error); |
85 | if(opt == "any" || opt == "off" || opt.isNull()){ | 85 | if(opt == "any" || opt == "off" || opt.isNull()){ |
86 | essid->setEditText("any"); | 86 | essid->setEditText("any"); |
87 | } else { | 87 | } else { |
88 | essid->setEditText(opt); | 88 | essid->setEditText(opt); |
89 | } | 89 | } |
90 | 90 | ||
91 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); | 91 | opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); |
92 | 92 | ||
93 | for ( int i = 0; i < mode->count(); i++) | 93 | for ( int i = 0; i < mode->count(); i++) |
94 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); | 94 | if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); |
95 | 95 | ||
96 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); | 96 | opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); |
97 | if (! opt.isNull()) { | 97 | if (! opt.isNull()) { |
98 | specifyAp->setChecked(true); | 98 | specifyAp->setChecked(true); |
99 | macEdit->setText(opt); | 99 | macEdit->setText(opt); |
100 | } | 100 | } |
101 | 101 | ||
102 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); | 102 | opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); |
103 | if (! opt.isNull()) { | 103 | if (! opt.isNull()) { |
104 | specifyChan->setChecked(true); | 104 | specifyChan->setChecked(true); |
105 | networkChannel->setValue(opt.toInt()); | 105 | networkChannel->setValue(opt.toInt()); |
106 | } | 106 | } |
107 | 107 | ||
108 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); | 108 | opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); |
109 | if (opt.isNull()) | 109 | if (opt.isNull()) |
110 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); | 110 | opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); |
111 | parseKeyStr(opt); | 111 | parseKeyStr(opt); |
112 | } | 112 | } |
113 | 113 | ||
114 | void WLANImp::parseKeyStr(QString keystr) { | 114 | void WLANImp::parseKeyStr(QString keystr) { |
115 | int loc = 0; | 115 | int loc = 0; |
116 | int index = 1; | 116 | int index = 1; |
117 | QString key; | 117 | QString key; |
118 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); | 118 | QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); |
119 | int enc = -1; // encryption state | 119 | int enc = -1; // encryption state |
120 | 120 | ||
121 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { | 121 | for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { |
122 | if ((*it).left(3) == "off") { | 122 | if ((*it).left(3) == "off") { |
123 | // encryption disabled | 123 | // encryption disabled |
124 | enc = 0; | 124 | enc = 0; |
125 | } else if ((*it).left(2) == "on") { | 125 | } else if ((*it).left(2) == "on") { |
126 | // encryption enabled | 126 | // encryption enabled |
127 | enc = 1; | 127 | enc = 1; |
128 | } else if ((*it).left(4) == "open") { | 128 | } else if ((*it).left(4) == "open") { |
129 | // open mode, accept non encrypted packets | 129 | // open mode, accept non encrypted packets |
130 | acceptNonEnc->setChecked(true); | 130 | acceptNonEnc->setChecked(true); |
131 | } else if ((*it).left(10) == "restricted") { | 131 | } else if ((*it).left(10) == "restricted") { |
132 | // restricted mode, only accept encrypted packets | 132 | // restricted mode, only accept encrypted packets |
133 | rejectNonEnc->setChecked(true); | 133 | rejectNonEnc->setChecked(true); |
134 | } else if ((*it).left(3) == "key") { | 134 | } else if ((*it).left(3) == "key") { |
135 | // new set of options | 135 | // new set of options |
136 | } else if ((*it).left(1) == "[") { | 136 | } else if ((*it).left(1) == "[") { |
137 | index = (*it).mid(1, 1).toInt(); | 137 | index = (*it).mid(1, 1).toInt(); |
138 | // switch current key to index | 138 | // switch current key to index |
139 | switch (index) { | 139 | switch (index) { |
140 | case 1: | 140 | case 1: |
141 | keyRadio0->setChecked(true); | 141 | keyRadio0->setChecked(true); |
142 | break; | 142 | break; |
143 | case 2: | 143 | case 2: |
144 | keyRadio1->setChecked(true); | 144 | keyRadio1->setChecked(true); |
145 | break; | 145 | break; |
146 | case 3: | 146 | case 3: |
147 | keyRadio2->setChecked(true); | 147 | keyRadio2->setChecked(true); |
148 | break; | 148 | break; |
149 | case 4: | 149 | case 4: |
150 | keyRadio3->setChecked(true); | 150 | keyRadio3->setChecked(true); |
151 | break; | 151 | break; |
152 | } | 152 | } |
153 | } else { | 153 | } else { |
diff --git a/noncore/settings/packagemanager/filterdlg.cpp b/noncore/settings/packagemanager/filterdlg.cpp index 0da9d19..eeed398 100644 --- a/noncore/settings/packagemanager/filterdlg.cpp +++ b/noncore/settings/packagemanager/filterdlg.cpp | |||
@@ -1,167 +1,167 @@ | |||
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) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
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, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
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 "filterdlg.h" | 30 | #include "filterdlg.h" |
31 | 31 | ||
32 | FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name, | 32 | FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name, |
33 | const QString &server, const QString &destination, | 33 | const QString &server, const QString &destination, |
34 | OPackageManager::Status status, const QString &category ) | 34 | OPackageManager::Status status, const QString &category ) |
35 | : QDialog( parent, QString::null, true ) | 35 | : QDialog( parent, QString::null, true ) |
36 | { | 36 | { |
37 | setCaption( tr( "Filter packages" ) ); | 37 | setCaption( tr( "Filter packages" ) ); |
38 | 38 | ||
39 | QVBoxLayout *layout = new QVBoxLayout( this ); | 39 | QVBoxLayout *layout = new QVBoxLayout( this ); |
40 | QScrollView *sv = new QScrollView( this ); | 40 | QScrollView *sv = new QScrollView( this ); |
41 | layout->addWidget( sv, 0, 0 ); | 41 | layout->addWidget( sv, 0, 0 ); |
42 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 42 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
43 | sv->setFrameStyle( QFrame::NoFrame ); | 43 | sv->setFrameStyle( QFrame::NoFrame ); |
44 | QWidget *container = new QWidget( sv->viewport() ); | 44 | QWidget *container = new QWidget( sv->viewport() ); |
45 | sv->addChild( container ); | 45 | sv->addChild( container ); |
46 | layout = new QVBoxLayout( container, 4, 4 ); | 46 | layout = new QVBoxLayout( container, 4, 4 ); |
47 | 47 | ||
48 | // Category | 48 | // Category |
49 | m_categoryCB = new QCheckBox( tr( "Category:" ), container ); | 49 | m_categoryCB = new QCheckBox( tr( "Category:" ), container ); |
50 | connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) ); | 50 | connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) ); |
51 | m_category = new QComboBox( container ); | 51 | m_category = new QComboBox( container ); |
52 | m_category->insertStringList( pm->categories() ); | 52 | m_category->insertStringList( pm->categories() ); |
53 | initItem( m_category, m_categoryCB, category ); | 53 | initItem( m_category, m_categoryCB, category ); |
54 | layout->addWidget( m_categoryCB ); | 54 | layout->addWidget( m_categoryCB ); |
55 | layout->addWidget( m_category ); | 55 | layout->addWidget( m_category ); |
56 | 56 | ||
57 | // Package name | 57 | // Package name |
58 | m_nameCB = new QCheckBox( tr( "Names containing:" ), container ); | 58 | m_nameCB = new QCheckBox( tr( "Names containing:" ), container ); |
59 | connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) ); | 59 | connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) ); |
60 | m_name = new QLineEdit( name, container ); | 60 | m_name = new QLineEdit( name, container ); |
61 | if ( !name.isNull() ) | 61 | if ( !name.isNull() ) |
62 | m_nameCB->setChecked( true ); | 62 | m_nameCB->setChecked( true ); |
63 | m_name->setEnabled( !name.isNull() ); | 63 | m_name->setEnabled( !name.isNull() ); |
64 | layout->addWidget( m_nameCB ); | 64 | layout->addWidget( m_nameCB ); |
65 | layout->addWidget( m_name ); | 65 | layout->addWidget( m_name ); |
66 | 66 | ||
67 | // Status | 67 | // Status |
68 | m_statusCB = new QCheckBox( tr( "With the status:" ), container ); | 68 | m_statusCB = new QCheckBox( tr( "With the status:" ), container ); |
69 | connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) ); | 69 | connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) ); |
70 | m_status = new QComboBox( container ); | 70 | m_status = new QComboBox( container ); |
71 | connect( m_status, SIGNAL(activated(const QString &)), this, SLOT(slotStatusChanged(const QString &)) ); | 71 | connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) ); |
72 | QString currStatus; | 72 | QString currStatus; |
73 | switch ( status ) | 73 | switch ( status ) |
74 | { | 74 | { |
75 | case OPackageManager::All : currStatus = tr( "All" ); | 75 | case OPackageManager::All : currStatus = tr( "All" ); |
76 | break; | 76 | break; |
77 | case OPackageManager::Installed : currStatus = tr( "Installed" ); | 77 | case OPackageManager::Installed : currStatus = tr( "Installed" ); |
78 | break; | 78 | break; |
79 | case OPackageManager::NotInstalled : currStatus = tr( "Not installed" ); | 79 | case OPackageManager::NotInstalled : currStatus = tr( "Not installed" ); |
80 | break; | 80 | break; |
81 | case OPackageManager::Updated : currStatus = tr( "Updated" ); | 81 | case OPackageManager::Updated : currStatus = tr( "Updated" ); |
82 | break; | 82 | break; |
83 | default : currStatus = QString::null; | 83 | default : currStatus = QString::null; |
84 | }; | 84 | }; |
85 | m_status->insertItem( tr( "All" ) ); | 85 | m_status->insertItem( tr( "All" ) ); |
86 | m_status->insertItem( tr( "Installed" ) ); | 86 | m_status->insertItem( tr( "Installed" ) ); |
87 | m_status->insertItem( tr( "Not installed" ) ); | 87 | m_status->insertItem( tr( "Not installed" ) ); |
88 | m_status->insertItem( tr( "Updated" ) ); | 88 | m_status->insertItem( tr( "Updated" ) ); |
89 | initItem( m_status, m_statusCB, currStatus ); | 89 | initItem( m_status, m_statusCB, currStatus ); |
90 | layout->addWidget( m_statusCB ); | 90 | layout->addWidget( m_statusCB ); |
91 | layout->addWidget( m_status ); | 91 | layout->addWidget( m_status ); |
92 | 92 | ||
93 | // Server | 93 | // Server |
94 | m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container ); | 94 | m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container ); |
95 | connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) ); | 95 | connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) ); |
96 | m_server = new QComboBox( container ); | 96 | m_server = new QComboBox( container ); |
97 | m_server->insertStringList( *(pm->servers()) ); | 97 | m_server->insertStringList( *(pm->servers()) ); |
98 | initItem( m_server, m_serverCB, server ); | 98 | initItem( m_server, m_serverCB, server ); |
99 | layout->addWidget( m_serverCB ); | 99 | layout->addWidget( m_serverCB ); |
100 | layout->addWidget( m_server ); | 100 | layout->addWidget( m_server ); |
101 | 101 | ||
102 | // Destination | 102 | // Destination |
103 | m_destCB = new QCheckBox( tr( "Installed on device at:" ), container ); | 103 | m_destCB = new QCheckBox( tr( "Installed on device at:" ), container ); |
104 | connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) ); | 104 | connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) ); |
105 | m_destination = new QComboBox( container ); | 105 | m_destination = new QComboBox( container ); |
106 | m_destination->insertStringList( *(pm->destinations()) ); | 106 | m_destination->insertStringList( *(pm->destinations()) ); |
107 | initItem( m_destination, m_destCB, destination ); | 107 | initItem( m_destination, m_destCB, destination ); |
108 | layout->addWidget( m_destCB ); | 108 | layout->addWidget( m_destCB ); |
109 | layout->addWidget( m_destination ); | 109 | layout->addWidget( m_destination ); |
110 | 110 | ||
111 | //showMaximized(); | 111 | //showMaximized(); |
112 | } | 112 | } |
113 | 113 | ||
114 | void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ) | 114 | void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ) |
115 | { | 115 | { |
116 | if ( !selection.isNull() ) | 116 | if ( !selection.isNull() ) |
117 | { | 117 | { |
118 | checkBox->setChecked( true ); | 118 | checkBox->setChecked( true ); |
119 | 119 | ||
120 | for ( int i = 0; i < comboBox->count(); i++ ) | 120 | for ( int i = 0; i < comboBox->count(); i++ ) |
121 | { | 121 | { |
122 | if ( comboBox->text( i ) == selection ) | 122 | if ( comboBox->text( i ) == selection ) |
123 | { | 123 | { |
124 | comboBox->setCurrentItem( i ); | 124 | comboBox->setCurrentItem( i ); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | } | 127 | } |
128 | } | 128 | } |
129 | comboBox->setEnabled( !selection.isNull() ); | 129 | comboBox->setEnabled( !selection.isNull() ); |
130 | } | 130 | } |
131 | 131 | ||
132 | void FilterDlg::slotNameSelected( bool selected ) | 132 | void FilterDlg::slotNameSelected( bool selected ) |
133 | { | 133 | { |
134 | m_name->setEnabled( selected ); | 134 | m_name->setEnabled( selected ); |
135 | } | 135 | } |
136 | 136 | ||
137 | void FilterDlg::slotServerSelected( bool selected ) | 137 | void FilterDlg::slotServerSelected( bool selected ) |
138 | { | 138 | { |
139 | m_server->setEnabled( selected ); | 139 | m_server->setEnabled( selected ); |
140 | } | 140 | } |
141 | 141 | ||
142 | void FilterDlg::slotDestSelected( bool selected ) | 142 | void FilterDlg::slotDestSelected( bool selected ) |
143 | { | 143 | { |
144 | m_destination->setEnabled( selected ); | 144 | m_destination->setEnabled( selected ); |
145 | } | 145 | } |
146 | 146 | ||
147 | void FilterDlg::slotStatusSelected( bool selected ) | 147 | void FilterDlg::slotStatusSelected( bool selected ) |
148 | { | 148 | { |
149 | m_status->setEnabled( selected ); | 149 | m_status->setEnabled( selected ); |
150 | 150 | ||
151 | if ( !selected && !m_destCB->isEnabled() ) | 151 | if ( !selected && !m_destCB->isEnabled() ) |
152 | { | 152 | { |
153 | // If status check box has been deselected and destination option was previously deselected | 153 | // If status check box has been deselected and destination option was previously deselected |
154 | // (because status == "Not installed"), re-enable destination option | 154 | // (because status == "Not installed"), re-enable destination option |
155 | m_destCB->setEnabled( true ); | 155 | m_destCB->setEnabled( true ); |
156 | m_destination->setEnabled( true ); | 156 | m_destination->setEnabled( true ); |
157 | } | 157 | } |
158 | else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) ) | 158 | else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) ) |
159 | { | 159 | { |
160 | // If status check box has been selected and status == "Not installed", disable destination option | 160 | // If status check box has been selected and status == "Not installed", disable destination option |
161 | m_destCB->setEnabled( false ); | 161 | m_destCB->setEnabled( false ); |
162 | m_destCB->setChecked( false ); | 162 | m_destCB->setChecked( false ); |
163 | m_destination->setEnabled( false ); | 163 | m_destination->setEnabled( false ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | void FilterDlg::slotStatusChanged( const QString &category ) | 167 | void FilterDlg::slotStatusChanged( const QString &category ) |
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 8fd960f..b334bca 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp | |||
@@ -25,226 +25,226 @@ | |||
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 <qaction.h> | 30 | #include <qaction.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qtoolbar.h> | 38 | #include <qtoolbar.h> |
39 | #include <qwhatsthis.h> | 39 | #include <qwhatsthis.h> |
40 | 40 | ||
41 | #include <qpe/qcopenvelope_qws.h> | 41 | #include <qpe/qcopenvelope_qws.h> |
42 | #include <qpe/qpeapplication.h> | 42 | #include <qpe/qpeapplication.h> |
43 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
44 | 44 | ||
45 | #include "mainwindow.h" | 45 | #include "mainwindow.h" |
46 | #include "installdlg.h" | 46 | #include "installdlg.h" |
47 | #include "filterdlg.h" | 47 | #include "filterdlg.h" |
48 | #include "promptdlg.h" | 48 | #include "promptdlg.h" |
49 | #include "entrydlg.h" | 49 | #include "entrydlg.h" |
50 | #include "packageinfodlg.h" | 50 | #include "packageinfodlg.h" |
51 | 51 | ||
52 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) | 52 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) |
53 | : QMainWindow( parent, name, WStyle_ContextHelp ) | 53 | : QMainWindow( parent, name, WStyle_ContextHelp ) |
54 | , m_config( "packman" ) | 54 | , m_config( "packman" ) |
55 | , m_packman( &m_config, this ) | 55 | , m_packman( &m_config, this ) |
56 | , m_menuBar( this ) | 56 | , m_menuBar( this ) |
57 | , m_toolBar( this ) | 57 | , m_toolBar( this ) |
58 | , m_findBar( this ) | 58 | , m_findBar( this ) |
59 | , m_widgetStack( this ) | 59 | , m_widgetStack( this ) |
60 | , m_packageList( this ) | 60 | , m_packageList( this ) |
61 | , m_statusWidget( this ) | 61 | , m_statusWidget( this ) |
62 | , m_statusText( &m_statusWidget ) | 62 | , m_statusText( &m_statusWidget ) |
63 | , m_statusBar( &m_statusWidget ) | 63 | , m_statusBar( &m_statusWidget ) |
64 | , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) | 64 | , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) |
65 | , m_iconInstalled( Resource::loadPixmap( "installed" ) ) | 65 | , m_iconInstalled( Resource::loadPixmap( "installed" ) ) |
66 | , m_iconNull( m_iconUpdated.size() ) | 66 | , m_iconNull( m_iconUpdated.size() ) |
67 | , m_filterName( QString::null ) | 67 | , m_filterName( QString::null ) |
68 | , m_filterServer( QString::null ) | 68 | , m_filterServer( QString::null ) |
69 | , m_filterDest( QString::null ) | 69 | , m_filterDest( QString::null ) |
70 | , m_filterStatus( OPackageManager::NotDefined ) | 70 | , m_filterStatus( OPackageManager::NotDefined ) |
71 | , m_filterCategory( QString::null ) | 71 | , m_filterCategory( QString::null ) |
72 | 72 | ||
73 | { | 73 | { |
74 | // setCaption( tr( "Package Manager" ) ); | 74 | // setCaption( tr( "Package Manager" ) ); |
75 | 75 | ||
76 | m_iconNull.fill( colorGroup().base() ); | 76 | m_iconNull.fill( colorGroup().base() ); |
77 | 77 | ||
78 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); | 78 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); |
79 | 79 | ||
80 | // Initialize widget stack, package list and status widget | 80 | // Initialize widget stack, package list and status widget |
81 | initStatusWidget(); | 81 | initStatusWidget(); |
82 | initPackageList(); | 82 | initPackageList(); |
83 | 83 | ||
84 | m_widgetStack.addWidget( &m_statusWidget, 2 ); | 84 | m_widgetStack.addWidget( &m_statusWidget, 2 ); |
85 | m_widgetStack.addWidget( &m_packageList, 1 ); | 85 | m_widgetStack.addWidget( &m_packageList, 1 ); |
86 | setCentralWidget( &m_widgetStack ); | 86 | setCentralWidget( &m_widgetStack ); |
87 | 87 | ||
88 | // Initialize remaining user interface items | 88 | // Initialize remaining user interface items |
89 | initUI(); | 89 | initUI(); |
90 | 90 | ||
91 | // Initialize package information | 91 | // Initialize package information |
92 | QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); | 92 | QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); |
93 | } | 93 | } |
94 | 94 | ||
95 | void MainWindow::closeEvent( QCloseEvent *event ) | 95 | void MainWindow::closeEvent( QCloseEvent *event ) |
96 | { | 96 | { |
97 | // Close app only if either the package or status widgets are currently active | 97 | // Close app only if either the package or status widgets are currently active |
98 | bool close = m_widgetStack.visibleWidget() == &m_packageList || | 98 | bool close = m_widgetStack.visibleWidget() == &m_packageList || |
99 | m_widgetStack.visibleWidget() == &m_statusWidget; | 99 | m_widgetStack.visibleWidget() == &m_statusWidget; |
100 | if ( close ) | 100 | if ( close ) |
101 | { | 101 | { |
102 | // TODO - write out application configuration settings | 102 | // TODO - write out application configuration settings |
103 | 103 | ||
104 | // Write out package manager configuration settings | 104 | // Write out package manager configuration settings |
105 | m_packman.saveSettings(); | 105 | m_packman.saveSettings(); |
106 | event->accept(); | 106 | event->accept(); |
107 | } | 107 | } |
108 | else | 108 | else |
109 | { | 109 | { |
110 | delete m_widgetStack.visibleWidget(); | 110 | delete m_widgetStack.visibleWidget(); |
111 | m_widgetStack.raiseWidget( &m_packageList ); | 111 | m_widgetStack.raiseWidget( &m_packageList ); |
112 | event->ignore(); | 112 | event->ignore(); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | void MainWindow::initPackageList() | 116 | void MainWindow::initPackageList() |
117 | { | 117 | { |
118 | m_packageList.addColumn( tr( "Packages" ) ); | 118 | m_packageList.addColumn( tr( "Packages" ) ); |
119 | QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 119 | QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); |
120 | QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); | 120 | QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); |
121 | connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), | 121 | connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), |
122 | this, SLOT(slotDisplayPackageInfo(QListViewItem *)) ); | 122 | this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); |
123 | } | 123 | } |
124 | 124 | ||
125 | void MainWindow::initStatusWidget() | 125 | void MainWindow::initStatusWidget() |
126 | { | 126 | { |
127 | QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); | 127 | QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); |
128 | 128 | ||
129 | m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 129 | m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
130 | layout->addWidget( &m_statusText ); | 130 | layout->addWidget( &m_statusText ); |
131 | 131 | ||
132 | connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); | 132 | connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); |
133 | connect( &m_packman, SIGNAL(statusText(const QString &)), this, SLOT(slotStatusText(const QString &)) ); | 133 | connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); |
134 | connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); | 134 | connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); |
135 | 135 | ||
136 | layout->addWidget( &m_statusBar ); | 136 | layout->addWidget( &m_statusBar ); |
137 | } | 137 | } |
138 | 138 | ||
139 | void MainWindow::initUI() | 139 | void MainWindow::initUI() |
140 | { | 140 | { |
141 | // Build menu and tool bars | 141 | // Build menu and tool bars |
142 | setToolBarsMovable( false ); | 142 | setToolBarsMovable( false ); |
143 | 143 | ||
144 | m_menuBar.setHorizontalStretchable( true ); | 144 | m_menuBar.setHorizontalStretchable( true ); |
145 | QMenuBar *mb = new QMenuBar( &m_menuBar ); | 145 | QMenuBar *mb = new QMenuBar( &m_menuBar ); |
146 | mb->setMargin( 0 ); | 146 | mb->setMargin( 0 ); |
147 | 147 | ||
148 | // Find toolbar | 148 | // Find toolbar |
149 | addToolBar( &m_findBar, QMainWindow::Top, true ); | 149 | addToolBar( &m_findBar, QMainWindow::Top, true ); |
150 | m_findBar.setHorizontalStretchable( true ); | 150 | m_findBar.setHorizontalStretchable( true ); |
151 | m_findEdit = new QLineEdit( &m_findBar ); | 151 | m_findEdit = new QLineEdit( &m_findBar ); |
152 | QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); | 152 | QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); |
153 | m_findBar.setStretchableWidget( m_findEdit ); | 153 | m_findBar.setStretchableWidget( m_findEdit ); |
154 | connect( m_findEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotFindChanged(const QString &)) ); | 154 | connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); |
155 | 155 | ||
156 | // Packages menu | 156 | // Packages menu |
157 | QPopupMenu *popup = new QPopupMenu( this ); | 157 | QPopupMenu *popup = new QPopupMenu( this ); |
158 | 158 | ||
159 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); | 159 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); |
160 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 160 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
161 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); | 161 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); |
162 | a->addTo( popup ); | 162 | a->addTo( popup ); |
163 | a->addTo( &m_toolBar ); | 163 | a->addTo( &m_toolBar ); |
164 | 164 | ||
165 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); | 165 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); |
166 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 166 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
167 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); | 167 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); |
168 | actionUpgrade->addTo( popup ); | 168 | actionUpgrade->addTo( popup ); |
169 | actionUpgrade->addTo( &m_toolBar ); | 169 | actionUpgrade->addTo( &m_toolBar ); |
170 | 170 | ||
171 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); | 171 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); |
172 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); | 172 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); |
173 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 173 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
174 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 174 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
175 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); | 175 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); |
176 | actionDownload->addTo( popup ); | 176 | actionDownload->addTo( popup ); |
177 | actionDownload->addTo( &m_toolBar ); | 177 | actionDownload->addTo( &m_toolBar ); |
178 | 178 | ||
179 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); | 179 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); |
180 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 180 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
181 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); | 181 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); |
182 | a->addTo( popup ); | 182 | a->addTo( popup ); |
183 | a->addTo( &m_toolBar ); | 183 | a->addTo( &m_toolBar ); |
184 | 184 | ||
185 | popup->insertSeparator(); | 185 | popup->insertSeparator(); |
186 | 186 | ||
187 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 187 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
188 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 188 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
189 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); | 189 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); |
190 | a->addTo( popup ); | 190 | a->addTo( popup ); |
191 | mb->insertItem( tr( "Actions" ), popup ); | 191 | mb->insertItem( tr( "Actions" ), popup ); |
192 | 192 | ||
193 | // View menu | 193 | // View menu |
194 | popup = new QPopupMenu( this ); | 194 | popup = new QPopupMenu( this ); |
195 | 195 | ||
196 | m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 196 | m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
197 | m_actionShowNotInstalled->setToggleAction( true ); | 197 | m_actionShowNotInstalled->setToggleAction( true ); |
198 | m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 198 | m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
199 | connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); | 199 | connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); |
200 | m_actionShowNotInstalled->addTo( popup ); | 200 | m_actionShowNotInstalled->addTo( popup ); |
201 | 201 | ||
202 | m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 202 | m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
203 | m_actionShowInstalled->setToggleAction( true ); | 203 | m_actionShowInstalled->setToggleAction( true ); |
204 | m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 204 | m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
205 | connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); | 205 | connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); |
206 | m_actionShowInstalled->addTo( popup ); | 206 | m_actionShowInstalled->addTo( popup ); |
207 | 207 | ||
208 | m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 208 | m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
209 | m_actionShowUpdated->setToggleAction( true ); | 209 | m_actionShowUpdated->setToggleAction( true ); |
210 | m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 210 | m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
211 | connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); | 211 | connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); |
212 | m_actionShowUpdated->addTo( popup ); | 212 | m_actionShowUpdated->addTo( popup ); |
213 | 213 | ||
214 | popup->insertSeparator(); | 214 | popup->insertSeparator(); |
215 | 215 | ||
216 | m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), | 216 | m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), |
217 | QString::null, 0, this, 0 ); | 217 | QString::null, 0, this, 0 ); |
218 | m_actionFilter->setToggleAction( true ); | 218 | m_actionFilter->setToggleAction( true ); |
219 | m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) ); | 219 | m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) ); |
220 | connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); | 220 | connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); |
221 | m_actionFilter->addTo( popup ); | 221 | m_actionFilter->addTo( popup ); |
222 | 222 | ||
223 | a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); | 223 | a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); |
224 | a->setWhatsThis( tr( "Click here to change the package filter criteria." ) ); | 224 | a->setWhatsThis( tr( "Click here to change the package filter criteria." ) ); |
225 | connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); | 225 | connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); |
226 | a->addTo( popup ); | 226 | a->addTo( popup ); |
227 | 227 | ||
228 | popup->insertSeparator(); | 228 | popup->insertSeparator(); |
229 | 229 | ||
230 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 230 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
231 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 231 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
232 | connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); | 232 | connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); |
233 | a->addTo( popup ); | 233 | a->addTo( popup ); |
234 | 234 | ||
235 | m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 235 | m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
236 | m_actionFindNext->setEnabled( false ); | 236 | m_actionFindNext->setEnabled( false ); |
237 | m_actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 237 | m_actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
238 | connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); | 238 | connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); |
239 | m_actionFindNext->addTo( popup ); | 239 | m_actionFindNext->addTo( popup ); |
240 | m_actionFindNext->addTo( &m_findBar ); | 240 | m_actionFindNext->addTo( &m_findBar ); |
241 | 241 | ||
242 | mb->insertItem( tr( "View" ), popup ); | 242 | mb->insertItem( tr( "View" ), popup ); |
243 | 243 | ||
244 | // Finish find toolbar creation | 244 | // Finish find toolbar creation |
245 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 245 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
246 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 246 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
247 | connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); | 247 | connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); |
248 | a->addTo( &m_findBar ); | 248 | a->addTo( &m_findBar ); |
249 | m_findBar.hide(); | 249 | m_findBar.hide(); |
250 | } | 250 | } |
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 086e91b..1dc23a4 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -223,242 +223,242 @@ OPackageList *OIpkg::installedPackages( const QString &destName, const QString & | |||
223 | path.append( "/" ); | 223 | path.append( "/" ); |
224 | path.append( IPKG_STATUS_PATH ); | 224 | path.append( IPKG_STATUS_PATH ); |
225 | 225 | ||
226 | QFile f( path ); | 226 | QFile f( path ); |
227 | if ( !f.open( IO_ReadOnly ) ) | 227 | if ( !f.open( IO_ReadOnly ) ) |
228 | return NULL; | 228 | return NULL; |
229 | QTextStream t( &f ); | 229 | QTextStream t( &f ); |
230 | 230 | ||
231 | // Process all information in status file | 231 | // Process all information in status file |
232 | bool newPackage = false; | 232 | bool newPackage = false; |
233 | QString line = t.readLine(); | 233 | QString line = t.readLine(); |
234 | QString name; | 234 | QString name; |
235 | QString version; | 235 | QString version; |
236 | QString status; | 236 | QString status; |
237 | 237 | ||
238 | while ( !t.eof() ) | 238 | while ( !t.eof() ) |
239 | { | 239 | { |
240 | // Determine key/value pair | 240 | // Determine key/value pair |
241 | int pos = line.find( ':', 0 ); | 241 | int pos = line.find( ':', 0 ); |
242 | QString key; | 242 | QString key; |
243 | if ( pos > -1 ) | 243 | if ( pos > -1 ) |
244 | key = line.mid( 0, pos ); | 244 | key = line.mid( 0, pos ); |
245 | else | 245 | else |
246 | key = QString::null; | 246 | key = QString::null; |
247 | QString value = line.mid( pos+2, line.length()-pos ); | 247 | QString value = line.mid( pos+2, line.length()-pos ); |
248 | 248 | ||
249 | // Allocate new package and insert into list | 249 | // Allocate new package and insert into list |
250 | if ( newPackage && !key.isEmpty() ) | 250 | if ( newPackage && !key.isEmpty() ) |
251 | { | 251 | { |
252 | // Add to list only if it has a valid name and is installed | 252 | // Add to list only if it has a valid name and is installed |
253 | if ( !name.isNull() && status.contains( " installed" ) ) | 253 | if ( !name.isNull() && status.contains( " installed" ) ) |
254 | { | 254 | { |
255 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 255 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
256 | name = QString::null; | 256 | name = QString::null; |
257 | version = QString::null; | 257 | version = QString::null; |
258 | status = QString::null; | 258 | status = QString::null; |
259 | 259 | ||
260 | newPackage = false; | 260 | newPackage = false; |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | // Update package data | 264 | // Update package data |
265 | if ( key == "Package" ) | 265 | if ( key == "Package" ) |
266 | name = value; | 266 | name = value; |
267 | else if ( key == "Version" ) | 267 | else if ( key == "Version" ) |
268 | version = value; | 268 | version = value; |
269 | else if ( key == "Status" ) | 269 | else if ( key == "Status" ) |
270 | status = value; | 270 | status = value; |
271 | else if ( key.isEmpty() && value.isEmpty() ) | 271 | else if ( key.isEmpty() && value.isEmpty() ) |
272 | newPackage = true; | 272 | newPackage = true; |
273 | 273 | ||
274 | // Skip past all description lines | 274 | // Skip past all description lines |
275 | if ( key == "Description" ) | 275 | if ( key == "Description" ) |
276 | { | 276 | { |
277 | line = t.readLine(); | 277 | line = t.readLine(); |
278 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 278 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
279 | line = t.readLine(); | 279 | line = t.readLine(); |
280 | } | 280 | } |
281 | else | 281 | else |
282 | line = t.readLine(); | 282 | line = t.readLine(); |
283 | } | 283 | } |
284 | 284 | ||
285 | f.close(); | 285 | f.close(); |
286 | 286 | ||
287 | return pl; | 287 | return pl; |
288 | } | 288 | } |
289 | 289 | ||
290 | bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, | 290 | bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, |
291 | const QObject *receiver, const char *slotOutput, bool rawOutput ) | 291 | const QObject *receiver, const char *slotOutput, bool rawOutput ) |
292 | { | 292 | { |
293 | if ( command == OPackage::NotDefined ) | 293 | if ( command == OPackage::NotDefined ) |
294 | return false; | 294 | return false; |
295 | 295 | ||
296 | // Set ipkg run-time options/arguments | 296 | // Set ipkg run-time options/arguments |
297 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); | 297 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); |
298 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); | 298 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); |
299 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); | 299 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); |
300 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); | 300 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); |
301 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; | 301 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; |
302 | if ( m_ipkgArgs.dest ) | 302 | if ( m_ipkgArgs.dest ) |
303 | free( m_ipkgArgs.dest ); | 303 | free( m_ipkgArgs.dest ); |
304 | if ( !destination.isNull() ) | 304 | if ( !destination.isNull() ) |
305 | { | 305 | { |
306 | int len = destination.length() + 1; | 306 | int len = destination.length() + 1; |
307 | m_ipkgArgs.dest = (char *)malloc( len ); | 307 | m_ipkgArgs.dest = (char *)malloc( len ); |
308 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 308 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
309 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 309 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
310 | } | 310 | } |
311 | else | 311 | else |
312 | m_ipkgArgs.dest = 0x0; | 312 | m_ipkgArgs.dest = 0x0; |
313 | 313 | ||
314 | // Connect output signal to widget | 314 | // Connect output signal to widget |
315 | 315 | ||
316 | if ( rawOutput ) | 316 | if ( rawOutput ) |
317 | { | 317 | { |
318 | // if ( slotOutput ) | 318 | // if ( slotOutput ) |
319 | // connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 319 | // connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
320 | } | 320 | } |
321 | else | 321 | else |
322 | { | 322 | { |
323 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage | 323 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
324 | } | 324 | } |
325 | 325 | ||
326 | switch( command ) | 326 | switch( command ) |
327 | { | 327 | { |
328 | case OPackage::Update : { | 328 | case OPackage::Update : { |
329 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 329 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
330 | ipkg_lists_update( &m_ipkgArgs ); | 330 | ipkg_lists_update( &m_ipkgArgs ); |
331 | }; | 331 | }; |
332 | break; | 332 | break; |
333 | case OPackage::Upgrade : { | 333 | case OPackage::Upgrade : { |
334 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 334 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
335 | ipkg_packages_upgrade( &m_ipkgArgs ); | 335 | ipkg_packages_upgrade( &m_ipkgArgs ); |
336 | }; | 336 | }; |
337 | break; | 337 | break; |
338 | case OPackage::Install : { | 338 | case OPackage::Install : { |
339 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 339 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
340 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 340 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
341 | { | 341 | { |
342 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 342 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
343 | } | 343 | } |
344 | }; | 344 | }; |
345 | break; | 345 | break; |
346 | case OPackage::Remove : { | 346 | case OPackage::Remove : { |
347 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 347 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
348 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 348 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
349 | { | 349 | { |
350 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 350 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
351 | } | 351 | } |
352 | }; | 352 | }; |
353 | break; | 353 | break; |
354 | case OPackage::Download : { | 354 | case OPackage::Download : { |
355 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | 355 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
356 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 356 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
357 | { | 357 | { |
358 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 358 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
359 | } | 359 | } |
360 | }; | 360 | }; |
361 | break; | 361 | break; |
362 | case OPackage::Info : { | 362 | case OPackage::Info : { |
363 | connect( this, SIGNAL(signalIpkgStatus(char *)), receiver, slotOutput ); | 363 | connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); |
364 | ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); | 364 | ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); |
365 | }; | 365 | }; |
366 | break; | 366 | break; |
367 | case OPackage::Files : { | 367 | case OPackage::Files : { |
368 | connect( this, SIGNAL(signalIpkgList(char *)), receiver, slotOutput ); | 368 | connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); |
369 | ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); | 369 | ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); |
370 | }; | 370 | }; |
371 | break; | 371 | break; |
372 | default : break; | 372 | default : break; |
373 | }; | 373 | }; |
374 | 374 | ||
375 | return true; | 375 | return true; |
376 | } | 376 | } |
377 | 377 | ||
378 | void OIpkg::ipkgMessage( char *msg ) | 378 | void OIpkg::ipkgMessage( char *msg ) |
379 | { | 379 | { |
380 | emit signalIpkgMessage( msg ); | 380 | emit signalIpkgMessage( msg ); |
381 | } | 381 | } |
382 | 382 | ||
383 | void OIpkg::ipkgStatus( char *status ) | 383 | void OIpkg::ipkgStatus( char *status ) |
384 | { | 384 | { |
385 | emit signalIpkgStatus( status ); | 385 | emit signalIpkgStatus( status ); |
386 | } | 386 | } |
387 | 387 | ||
388 | void OIpkg::ipkgList( char *filelist ) | 388 | void OIpkg::ipkgList( char *filelist ) |
389 | { | 389 | { |
390 | emit signalIpkgList( filelist ); | 390 | emit signalIpkgList( filelist ); |
391 | } | 391 | } |
392 | 392 | ||
393 | void OIpkg::loadConfiguration() | 393 | void OIpkg::loadConfiguration() |
394 | { | 394 | { |
395 | if ( m_confInfo ) | 395 | if ( m_confInfo ) |
396 | delete m_confInfo; | 396 | delete m_confInfo; |
397 | 397 | ||
398 | // Load configuration item list | 398 | // Load configuration item list |
399 | m_confInfo = new OConfItemList(); | 399 | m_confInfo = new OConfItemList(); |
400 | 400 | ||
401 | QStringList confFiles; | 401 | QStringList confFiles; |
402 | QDir confDir( IPKG_CONF_DIR ); | 402 | QDir confDir( IPKG_CONF_DIR ); |
403 | if ( confDir.exists() ) | 403 | if ( confDir.exists() ) |
404 | { | 404 | { |
405 | confDir.setNameFilter( "*.conf" ); | 405 | confDir.setNameFilter( "*.conf" ); |
406 | confDir.setFilter( QDir::Files ); | 406 | confDir.setFilter( QDir::Files ); |
407 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 407 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
408 | confFiles << IPKG_CONF; | 408 | confFiles << IPKG_CONF; |
409 | 409 | ||
410 | for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it ) | 410 | for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it ) |
411 | { | 411 | { |
412 | // Create absolute file path if necessary | 412 | // Create absolute file path if necessary |
413 | QString absFile = (*it); | 413 | QString absFile = (*it); |
414 | if ( !absFile.startsWith( "/" ) ) | 414 | if ( !absFile.startsWith( "/" ) ) |
415 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 415 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
416 | 416 | ||
417 | // Read in file | 417 | // Read in file |
418 | QFile f( absFile ); | 418 | QFile f( absFile ); |
419 | if ( f.open( IO_ReadOnly ) ) | 419 | if ( f.open( IO_ReadOnly ) ) |
420 | { | 420 | { |
421 | QTextStream s( &f ); | 421 | QTextStream s( &f ); |
422 | while ( !s.eof() ) | 422 | while ( !s.eof() ) |
423 | { | 423 | { |
424 | 424 | ||
425 | QString line = s.readLine().simplifyWhiteSpace(); | 425 | QString line = s.readLine().simplifyWhiteSpace(); |
426 | 426 | ||
427 | // Parse line and save info to the conf options list | 427 | // Parse line and save info to the conf options list |
428 | if ( !line.isEmpty() ) | 428 | if ( !line.isEmpty() ) |
429 | { | 429 | { |
430 | if ( !line.startsWith( "#" ) || | 430 | if ( !line.startsWith( "#" ) || |
431 | line.startsWith( "#src" ) || | 431 | line.startsWith( "#src" ) || |
432 | line.startsWith( "#dest" ) || | 432 | line.startsWith( "#dest" ) || |
433 | line.startsWith( "#arch" ) || | 433 | line.startsWith( "#arch" ) || |
434 | line.startsWith( "#option" ) ) | 434 | line.startsWith( "#option" ) ) |
435 | { | 435 | { |
436 | int pos = line.find( ' ', 1 ); | 436 | int pos = line.find( ' ', 1 ); |
437 | 437 | ||
438 | // Type | 438 | // Type |
439 | QString typeStr = line.left( pos ); | 439 | QString typeStr = line.left( pos ); |
440 | OConfItem::Type type; | 440 | OConfItem::Type type; |
441 | if ( typeStr == "src" || typeStr == "#src" ) | 441 | if ( typeStr == "src" || typeStr == "#src" ) |
442 | type = OConfItem::Source; | 442 | type = OConfItem::Source; |
443 | else if ( typeStr == "dest" || typeStr == "#dest" ) | 443 | else if ( typeStr == "dest" || typeStr == "#dest" ) |
444 | type = OConfItem::Destination; | 444 | type = OConfItem::Destination; |
445 | else if ( typeStr == "option" || typeStr == "#option" ) | 445 | else if ( typeStr == "option" || typeStr == "#option" ) |
446 | type = OConfItem::Option; | 446 | type = OConfItem::Option; |
447 | else if ( typeStr == "arch" || typeStr == "#arch" ) | 447 | else if ( typeStr == "arch" || typeStr == "#arch" ) |
448 | type = OConfItem::Arch; | 448 | type = OConfItem::Arch; |
449 | else | 449 | else |
450 | type = OConfItem::NotDefined; | 450 | type = OConfItem::NotDefined; |
451 | ++pos; | 451 | ++pos; |
452 | int endpos = line.find( ' ', pos ); | 452 | int endpos = line.find( ' ', pos ); |
453 | 453 | ||
454 | // Name | 454 | // Name |
455 | QString name = line.mid( pos, endpos - pos ); | 455 | QString name = line.mid( pos, endpos - pos ); |
456 | 456 | ||
457 | // Value | 457 | // Value |
458 | QString value = ""; | 458 | QString value = ""; |
459 | if ( endpos > -1 ) | 459 | if ( endpos > -1 ) |
460 | value = line.right( line.length() - endpos - 1 ); | 460 | value = line.right( line.length() - endpos - 1 ); |
461 | 461 | ||
462 | // Active | 462 | // Active |
463 | bool active = !line.startsWith( "#" ); | 463 | bool active = !line.startsWith( "#" ); |
464 | 464 | ||
diff --git a/noncore/settings/sound/soundsettings.cpp b/noncore/settings/sound/soundsettings.cpp index 4bc86fa..8ad0a3f 100644 --- a/noncore/settings/sound/soundsettings.cpp +++ b/noncore/settings/sound/soundsettings.cpp | |||
@@ -18,202 +18,202 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // parts copyright 2002 L.J. Potter | 20 | // parts copyright 2002 L.J. Potter |
21 | 21 | ||
22 | #include "soundsettings.h" | 22 | #include "soundsettings.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 26 | #include <qpe/qcopenvelope_qws.h> |
27 | #include <qpe/storage.h> | 27 | #include <qpe/storage.h> |
28 | 28 | ||
29 | #include <qcheckbox.h> | 29 | #include <qcheckbox.h> |
30 | #include <qcombobox.h> | 30 | #include <qcombobox.h> |
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | 32 | ||
33 | #include <sys/utsname.h> | 33 | #include <sys/utsname.h> |
34 | #include <sys/time.h> | 34 | #include <sys/time.h> |
35 | #include <sys/types.h> | 35 | #include <sys/types.h> |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | #include <stdio.h> | 37 | #include <stdio.h> |
38 | #include <sys/stat.h> | 38 | #include <sys/stat.h> |
39 | 39 | ||
40 | 40 | ||
41 | SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl ) | 41 | SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl ) |
42 | : SoundSettingsBase( parent, objname, TRUE, fl ) | 42 | : SoundSettingsBase( parent, objname, TRUE, fl ) |
43 | { | 43 | { |
44 | keyReset=FALSE; | 44 | keyReset=FALSE; |
45 | noWarning=false; | 45 | noWarning=false; |
46 | Config config( "qpe"); | 46 | Config config( "qpe"); |
47 | config.setGroup( "Volume" ); | 47 | config.setGroup( "Volume" ); |
48 | Config cfg("Vmemo"); | 48 | Config cfg("Vmemo"); |
49 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 49 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
50 | AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); | 50 | AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); |
51 | 51 | ||
52 | cfg.setGroup("Record"); | 52 | cfg.setGroup("Record"); |
53 | int rate=config.readNumEntry("SampleRate", 22050); | 53 | int rate=config.readNumEntry("SampleRate", 22050); |
54 | if(rate == 8000) | 54 | if(rate == 8000) |
55 | sampleRate->setCurrentItem(0); | 55 | sampleRate->setCurrentItem(0); |
56 | else if(rate == 11025) | 56 | else if(rate == 11025) |
57 | sampleRate->setCurrentItem(1); | 57 | sampleRate->setCurrentItem(1); |
58 | else if(rate == 22050) | 58 | else if(rate == 22050) |
59 | sampleRate->setCurrentItem(2); | 59 | sampleRate->setCurrentItem(2); |
60 | else if(rate == 33075) | 60 | else if(rate == 33075) |
61 | sampleRate->setCurrentItem(3); | 61 | sampleRate->setCurrentItem(3); |
62 | else if(rate==44100) | 62 | else if(rate==44100) |
63 | sampleRate->setCurrentItem(4); | 63 | sampleRate->setCurrentItem(4); |
64 | 64 | ||
65 | stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); | 65 | stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); |
66 | //TODO hide if zaurus- mono only | 66 | //TODO hide if zaurus- mono only |
67 | 67 | ||
68 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) | 68 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) |
69 | //since ipaq and zaurus have particular | 69 | //since ipaq and zaurus have particular |
70 | //devices | 70 | //devices |
71 | bool systemZaurus=FALSE; | 71 | bool systemZaurus=FALSE; |
72 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 72 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
73 | if (uname(&name) != -1) {// TODO change this here,... | 73 | if (uname(&name) != -1) {// TODO change this here,... |
74 | QString release=name.release; | 74 | QString release=name.release; |
75 | if( release.find("embedix",0,TRUE) != -1) { | 75 | if( release.find("embedix",0,TRUE) != -1) { |
76 | qDebug("IS System Zaurus"); | 76 | qDebug("IS System Zaurus"); |
77 | systemZaurus=TRUE; | 77 | systemZaurus=TRUE; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | if(!systemZaurus) { | 80 | if(!systemZaurus) { |
81 | stereoCheckBox->setChecked(TRUE); | 81 | stereoCheckBox->setChecked(TRUE); |
82 | } | 82 | } |
83 | stereoCheckBox->setEnabled(FALSE); | 83 | stereoCheckBox->setEnabled(FALSE); |
84 | sixteenBitCheckBox->setEnabled(FALSE); | 84 | sixteenBitCheckBox->setEnabled(FALSE); |
85 | #else | 85 | #else |
86 | #endif | 86 | #endif |
87 | int sRate=cfg.readNumEntry("SizeLimit", 30); | 87 | int sRate=cfg.readNumEntry("SizeLimit", 30); |
88 | qDebug("%d",sRate); | 88 | qDebug("%d",sRate); |
89 | 89 | ||
90 | if(sRate ==30) | 90 | if(sRate ==30) |
91 | timeLimitComboBox->setCurrentItem(0); | 91 | timeLimitComboBox->setCurrentItem(0); |
92 | else if(sRate==20) | 92 | else if(sRate==20) |
93 | timeLimitComboBox->setCurrentItem(1); | 93 | timeLimitComboBox->setCurrentItem(1); |
94 | else if(sRate == 15) | 94 | else if(sRate == 15) |
95 | timeLimitComboBox->setCurrentItem(2); | 95 | timeLimitComboBox->setCurrentItem(2); |
96 | else if(sRate == 10) | 96 | else if(sRate == 10) |
97 | timeLimitComboBox->setCurrentItem(3); | 97 | timeLimitComboBox->setCurrentItem(3); |
98 | else if(sRate == 5) | 98 | else if(sRate == 5) |
99 | timeLimitComboBox->setCurrentItem(4); | 99 | timeLimitComboBox->setCurrentItem(4); |
100 | else | 100 | else |
101 | timeLimitComboBox->setCurrentItem(5); | 101 | timeLimitComboBox->setCurrentItem(5); |
102 | 102 | ||
103 | sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); | 103 | sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); |
104 | 104 | ||
105 | cfg.setGroup("Defaults"); | 105 | cfg.setGroup("Defaults"); |
106 | keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); | 106 | keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); |
107 | 107 | ||
108 | updateStorageCombo(); | 108 | updateStorageCombo(); |
109 | 109 | ||
110 | Config vmCfg("Vmemo"); | 110 | Config vmCfg("Vmemo"); |
111 | vmCfg.setGroup("Defaults"); | 111 | vmCfg.setGroup("Defaults"); |
112 | adpcmCheckBox->setChecked( vmCfg.readBoolEntry("use_ADPCM", 0)); | 112 | adpcmCheckBox->setChecked( vmCfg.readBoolEntry("use_ADPCM", 0)); |
113 | 113 | ||
114 | connect( LocationComboBox,SIGNAL(activated(const QString &)), this, | 114 | connect( LocationComboBox,SIGNAL(activated(const QString&)), this, |
115 | SLOT( setLocation(const QString &))); | 115 | SLOT( setLocation(const QString&))); |
116 | connect( keyComboBox,SIGNAL(activated( int)), this, | 116 | connect( keyComboBox,SIGNAL(activated(int)), this, |
117 | SLOT( setKeyButton( int))); | 117 | SLOT( setKeyButton(int))); |
118 | connect( timeLimitComboBox,SIGNAL(activated( const QString &)), this, | 118 | connect( timeLimitComboBox,SIGNAL(activated(const QString&)), this, |
119 | SLOT( setSizeLimitButton(const QString &))); | 119 | SLOT( setSizeLimitButton(const QString&))); |
120 | connect( restartCheckBox,SIGNAL( toggled( bool)), this, | 120 | connect( restartCheckBox,SIGNAL( toggled(bool)), this, |
121 | SLOT( restartOpie( bool))); | 121 | SLOT( restartOpie(bool))); |
122 | connect( adpcmCheckBox,SIGNAL( toggled( bool)), this, | 122 | connect( adpcmCheckBox,SIGNAL( toggled(bool)), this, |
123 | SLOT( slotAdpcm( bool))); | 123 | SLOT( slotAdpcm(bool))); |
124 | 124 | ||
125 | // connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 125 | // connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void SoundSettings::updateStorageCombo() { | 128 | void SoundSettings::updateStorageCombo() { |
129 | 129 | ||
130 | Config config( "Vmemo" ); | 130 | Config config( "Vmemo" ); |
131 | config.setGroup( "System" ); | 131 | config.setGroup( "System" ); |
132 | QString loc = config.readEntry("RecLocation","/"); | 132 | QString loc = config.readEntry("RecLocation","/"); |
133 | int i=0; | 133 | int i=0; |
134 | int set=0; | 134 | int set=0; |
135 | StorageInfo storageInfo; | 135 | StorageInfo storageInfo; |
136 | QString sName, sPath; | 136 | QString sName, sPath; |
137 | QStringList list; | 137 | QStringList list; |
138 | list << "Documents : "+QPEApplication::documentDir(); | 138 | list << "Documents : "+QPEApplication::documentDir(); |
139 | list << "tmp : /tmp"; | 139 | list << "tmp : /tmp"; |
140 | 140 | ||
141 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 141 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
142 | QListIterator<FileSystem> it ( fs ); | 142 | QListIterator<FileSystem> it ( fs ); |
143 | for( ; it.current(); ++it ){ | 143 | for( ; it.current(); ++it ){ |
144 | const QString name = (*it)->name(); | 144 | const QString name = (*it)->name(); |
145 | const QString path = (*it)->path(); | 145 | const QString path = (*it)->path(); |
146 | qDebug("storage name "+name +" storage path is "+path); | 146 | qDebug("storage name "+name +" storage path is "+path); |
147 | list << name + ": " +path; | 147 | list << name + ": " +path; |
148 | if( loc.find( path,0,TRUE) != -1) | 148 | if( loc.find( path,0,TRUE) != -1) |
149 | set = i; | 149 | set = i; |
150 | // if(dit.current()->file().find(path) != -1 ) storage=name; | 150 | // if(dit.current()->file().find(path) != -1 ) storage=name; |
151 | i++; | 151 | i++; |
152 | } | 152 | } |
153 | 153 | ||
154 | LocationComboBox->insertStringList(list); | 154 | LocationComboBox->insertStringList(list); |
155 | qDebug("set item %d", set); | 155 | qDebug("set item %d", set); |
156 | LocationComboBox->setCurrentItem(set); | 156 | LocationComboBox->setCurrentItem(set); |
157 | } | 157 | } |
158 | 158 | ||
159 | void SoundSettings::setLocation(const QString & string) { | 159 | void SoundSettings::setLocation(const QString & string) { |
160 | Config config( "Vmemo" ); | 160 | Config config( "Vmemo" ); |
161 | config.setGroup( "System" ); | 161 | config.setGroup( "System" ); |
162 | config.writeEntry("RecLocation",string); | 162 | config.writeEntry("RecLocation",string); |
163 | qDebug("set location "+string); | 163 | qDebug("set location "+string); |
164 | config.write(); | 164 | config.write(); |
165 | } | 165 | } |
166 | 166 | ||
167 | void SoundSettings::cleanUp() { | 167 | void SoundSettings::cleanUp() { |
168 | Config cfg("Vmemo"); | 168 | Config cfg("Vmemo"); |
169 | cfg.writeEntry("Alert",AlertCheckBox->isChecked()); | 169 | cfg.writeEntry("Alert",AlertCheckBox->isChecked()); |
170 | 170 | ||
171 | cfg.setGroup("Record"); | 171 | cfg.setGroup("Record"); |
172 | cfg.writeEntry("SampleRate",sampleRate->currentText()); | 172 | cfg.writeEntry("SampleRate",sampleRate->currentText()); |
173 | cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); | 173 | cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); |
174 | cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); | 174 | cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); |
175 | if(keyReset && noWarning) { | 175 | if(keyReset && noWarning) { |
176 | QCopEnvelope ("QPE/System", "restart()"); | 176 | QCopEnvelope ("QPE/System", "restart()"); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | void SoundSettings::setKeyButton( int index) { | 180 | void SoundSettings::setKeyButton( int index) { |
181 | Config cfg("Vmemo"); | 181 | Config cfg("Vmemo"); |
182 | cfg.setGroup("Defaults"); | 182 | cfg.setGroup("Defaults"); |
183 | cfg.writeEntry( "toggleKey", index ); | 183 | cfg.writeEntry( "toggleKey", index ); |
184 | keyReset = TRUE; | 184 | keyReset = TRUE; |
185 | if( index == 1) { | 185 | if( index == 1) { |
186 | cfg.writeEntry( "hideIcon", 0 ); | 186 | cfg.writeEntry( "hideIcon", 0 ); |
187 | keyLabel->setText(tr("Shows icon")); | 187 | keyLabel->setText(tr("Shows icon")); |
188 | } | 188 | } |
189 | else { | 189 | else { |
190 | cfg.writeEntry( "hideIcon", 1); | 190 | cfg.writeEntry( "hideIcon", 1); |
191 | keyLabel->setText(tr("Hides icon")); | 191 | keyLabel->setText(tr("Hides icon")); |
192 | } | 192 | } |
193 | cfg.write(); | 193 | cfg.write(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void SoundSettings::updateLocationCombo() { | 196 | void SoundSettings::updateLocationCombo() { |
197 | 197 | ||
198 | } | 198 | } |
199 | 199 | ||
200 | void SoundSettings::setSizeLimitButton(const QString &index) { | 200 | void SoundSettings::setSizeLimitButton(const QString &index) { |
201 | 201 | ||
202 | Config cfg("Vmemo"); | 202 | Config cfg("Vmemo"); |
203 | cfg.setGroup("Record"); | 203 | cfg.setGroup("Record"); |
204 | if(index.find("Unlimited",0,TRUE) != -1) | 204 | if(index.find("Unlimited",0,TRUE) != -1) |
205 | cfg.writeEntry("SizeLimit", -1); | 205 | cfg.writeEntry("SizeLimit", -1); |
206 | else | 206 | else |
207 | cfg.writeEntry("SizeLimit", index); | 207 | cfg.writeEntry("SizeLimit", index); |
208 | cfg.write(); | 208 | cfg.write(); |
209 | } | 209 | } |
210 | 210 | ||
211 | void SoundSettings::restartOpie(bool b) { | 211 | void SoundSettings::restartOpie(bool b) { |
212 | noWarning=b; | 212 | noWarning=b; |
213 | } | 213 | } |
214 | 214 | ||
215 | void SoundSettings::slotAdpcm(bool b) { | 215 | void SoundSettings::slotAdpcm(bool b) { |
216 | Config vmCfg("Vmemo"); | 216 | Config vmCfg("Vmemo"); |
217 | vmCfg.setGroup("Defaults"); | 217 | vmCfg.setGroup("Defaults"); |
218 | vmCfg.writeEntry("use_ADPCM", b); | 218 | vmCfg.writeEntry("use_ADPCM", b); |
219 | vmCfg.write(); | 219 | vmCfg.write(); |
diff --git a/noncore/settings/sysinfo/benchmarkinfo.cpp b/noncore/settings/sysinfo/benchmarkinfo.cpp index 0aeb251..d6ecec5 100644 --- a/noncore/settings/sysinfo/benchmarkinfo.cpp +++ b/noncore/settings/sysinfo/benchmarkinfo.cpp | |||
@@ -52,193 +52,193 @@ extern "C" | |||
52 | double dhry_main( int ); | 52 | double dhry_main( int ); |
53 | } | 53 | } |
54 | 54 | ||
55 | #define DHRYSTONE_RUNS 20000000 | 55 | #define DHRYSTONE_RUNS 20000000 |
56 | #define TEST_DURATION 3 | 56 | #define TEST_DURATION 3 |
57 | 57 | ||
58 | #define BUFF_SIZE 8192 | 58 | #define BUFF_SIZE 8192 |
59 | #define FILE_SIZE 1024 * 1024 // 1Mb | 59 | #define FILE_SIZE 1024 * 1024 // 1Mb |
60 | 60 | ||
61 | //=========================================================================== | 61 | //=========================================================================== |
62 | 62 | ||
63 | class BenchmarkPaintWidget : public QWidget | 63 | class BenchmarkPaintWidget : public QWidget |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) | 66 | BenchmarkPaintWidget() : QWidget( 0, "Benchmark Paint Widget", WStyle_Customize|WStyle_StaysOnTop|WPaintUnclipped|WPaintClever ) |
67 | { | 67 | { |
68 | resize( QApplication::desktop()->size() ); | 68 | resize( QApplication::desktop()->size() ); |
69 | show(); | 69 | show(); |
70 | p.begin( this ); | 70 | p.begin( this ); |
71 | }; | 71 | }; |
72 | 72 | ||
73 | ~BenchmarkPaintWidget() | 73 | ~BenchmarkPaintWidget() |
74 | { | 74 | { |
75 | p.end(); | 75 | p.end(); |
76 | hide(); | 76 | hide(); |
77 | }; | 77 | }; |
78 | 78 | ||
79 | QPainter p; | 79 | QPainter p; |
80 | }; | 80 | }; |
81 | 81 | ||
82 | //=========================================================================== | 82 | //=========================================================================== |
83 | 83 | ||
84 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) | 84 | BenchmarkInfo::BenchmarkInfo( QWidget *parent, const char *name, int wFlags ) |
85 | : QWidget( parent, name, wFlags ) | 85 | : QWidget( parent, name, wFlags ) |
86 | { | 86 | { |
87 | 87 | ||
88 | setMinimumSize( 200, 150 ); | 88 | setMinimumSize( 200, 150 ); |
89 | 89 | ||
90 | QVBoxLayout* vb = new QVBoxLayout( this ); | 90 | QVBoxLayout* vb = new QVBoxLayout( this ); |
91 | vb->setSpacing( 4 ); | 91 | vb->setSpacing( 4 ); |
92 | vb->setMargin( 4 ); | 92 | vb->setMargin( 4 ); |
93 | 93 | ||
94 | tests = new QListView( this ); | 94 | tests = new QListView( this ); |
95 | tests->setMargin( 0 ); | 95 | tests->setMargin( 0 ); |
96 | tests->addColumn( tr( "Tests" ) ); | 96 | tests->addColumn( tr( "Tests" ) ); |
97 | tests->addColumn( tr( "Results" ) ); | 97 | tests->addColumn( tr( "Results" ) ); |
98 | tests->addColumn( tr( "Comparison" ) ); | 98 | tests->addColumn( tr( "Comparison" ) ); |
99 | tests->setShowSortIndicator( true ); | 99 | tests->setShowSortIndicator( true ); |
100 | 100 | ||
101 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); | 101 | test_alu = new QCheckListItem( tests, tr( "1. Integer Arithmetic " ), QCheckListItem::CheckBox ); |
102 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); | 102 | test_fpu = new QCheckListItem( tests, tr( "2. Floating Point Unit " ), QCheckListItem::CheckBox ); |
103 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); | 103 | test_txt = new QCheckListItem( tests, tr( "3. Text Rendering " ), QCheckListItem::CheckBox ); |
104 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); | 104 | test_gfx = new QCheckListItem( tests, tr( "4. Gfx Rendering " ), QCheckListItem::CheckBox ); |
105 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); | 105 | test_ram = new QCheckListItem( tests, tr( "5. RAM Performance " ), QCheckListItem::CheckBox ); |
106 | test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox ); | 106 | test_sd = new QCheckListItem( tests, tr( "6. SD Card Performance " ), QCheckListItem::CheckBox ); |
107 | test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox ); | 107 | test_cf = new QCheckListItem( tests, tr( "7. CF Card Performance " ), QCheckListItem::CheckBox ); |
108 | 108 | ||
109 | test_alu->setText( 1, "n/a" ); | 109 | test_alu->setText( 1, "n/a" ); |
110 | test_fpu->setText( 1, "n/a" ); | 110 | test_fpu->setText( 1, "n/a" ); |
111 | test_txt->setText( 1, "n/a" ); | 111 | test_txt->setText( 1, "n/a" ); |
112 | test_gfx->setText( 1, "n/a" ); | 112 | test_gfx->setText( 1, "n/a" ); |
113 | test_ram->setText( 1, "n/a" ); | 113 | test_ram->setText( 1, "n/a" ); |
114 | test_sd->setText( 1, "n/a" ); | 114 | test_sd->setText( 1, "n/a" ); |
115 | test_cf->setText( 1, "n/a" ); | 115 | test_cf->setText( 1, "n/a" ); |
116 | 116 | ||
117 | test_alu->setText( 2, "n/a" ); | 117 | test_alu->setText( 2, "n/a" ); |
118 | test_fpu->setText( 2, "n/a" ); | 118 | test_fpu->setText( 2, "n/a" ); |
119 | test_txt->setText( 2, "n/a" ); | 119 | test_txt->setText( 2, "n/a" ); |
120 | test_gfx->setText( 2, "n/a" ); | 120 | test_gfx->setText( 2, "n/a" ); |
121 | test_ram->setText( 2, "n/a" ); | 121 | test_ram->setText( 2, "n/a" ); |
122 | test_sd->setText( 2, "n/a" ); | 122 | test_sd->setText( 2, "n/a" ); |
123 | test_cf->setText( 2, "n/a" ); | 123 | test_cf->setText( 2, "n/a" ); |
124 | 124 | ||
125 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); | 125 | startButton = new QPushButton( tr( "&Start Tests!" ), this ); |
126 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); | 126 | connect( startButton, SIGNAL( clicked() ), this, SLOT( run() ) ); |
127 | 127 | ||
128 | vb->addWidget( tests, 2 ); | 128 | vb->addWidget( tests, 2 ); |
129 | 129 | ||
130 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); | 130 | QFile f( QPEApplication::qpeDir() + "/share/sysinfo/results" ); |
131 | if ( f.open( IO_ReadOnly ) ) | 131 | if ( f.open( IO_ReadOnly ) ) |
132 | { | 132 | { |
133 | machineCombo = new QComboBox( this ); | 133 | machineCombo = new QComboBox( this ); |
134 | 134 | ||
135 | QTextStream ts( &f ); | 135 | QTextStream ts( &f ); |
136 | while( !ts.eof() ) | 136 | while( !ts.eof() ) |
137 | { | 137 | { |
138 | QString machline = ts.readLine(); | 138 | QString machline = ts.readLine(); |
139 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); | 139 | qDebug( "sysinfo: parsing benchmark results for '%s'", (const char*) machline ); |
140 | QString resline = ts.readLine(); | 140 | QString resline = ts.readLine(); |
141 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); | 141 | machines.insert( machline, new QStringList( QStringList::split( ",", resline ) ) ); |
142 | machineCombo->insertItem( machline ); | 142 | machineCombo->insertItem( machline ); |
143 | } | 143 | } |
144 | 144 | ||
145 | QHBoxLayout* hb = new QHBoxLayout( vb ); | 145 | QHBoxLayout* hb = new QHBoxLayout( vb ); |
146 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); | 146 | hb->addWidget( new QLabel( tr( "Compare To:" ), this ) ); |
147 | hb->addWidget( machineCombo, 2 ); | 147 | hb->addWidget( machineCombo, 2 ); |
148 | connect( machineCombo, SIGNAL( activated( int ) ), this, SLOT( machineActivated( int ) ) ); | 148 | connect( machineCombo, SIGNAL( activated(int) ), this, SLOT( machineActivated(int) ) ); |
149 | } | 149 | } |
150 | 150 | ||
151 | vb->addWidget( startButton, 2 ); | 151 | vb->addWidget( startButton, 2 ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | BenchmarkInfo::~BenchmarkInfo() | 155 | BenchmarkInfo::~BenchmarkInfo() |
156 | {} | 156 | {} |
157 | 157 | ||
158 | 158 | ||
159 | void BenchmarkInfo::machineActivated( int index ) | 159 | void BenchmarkInfo::machineActivated( int index ) |
160 | { | 160 | { |
161 | QStringList* results = machines[ machineCombo->text( index ) ]; | 161 | QStringList* results = machines[ machineCombo->text( index ) ]; |
162 | if ( !results ) | 162 | if ( !results ) |
163 | { | 163 | { |
164 | qDebug( "sysinfo: no results available." ); | 164 | qDebug( "sysinfo: no results available." ); |
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | QStringList::Iterator it = results->begin(); | 167 | QStringList::Iterator it = results->begin(); |
168 | test_alu->setText( 2, *(it++) ); | 168 | test_alu->setText( 2, *(it++) ); |
169 | test_fpu->setText( 2, *(it++) ); | 169 | test_fpu->setText( 2, *(it++) ); |
170 | test_txt->setText( 2, *(it++) ); | 170 | test_txt->setText( 2, *(it++) ); |
171 | test_gfx->setText( 2, *(it++) ); | 171 | test_gfx->setText( 2, *(it++) ); |
172 | test_ram->setText( 2, *(it++) ); | 172 | test_ram->setText( 2, *(it++) ); |
173 | test_sd->setText( 2, *(it++) ); | 173 | test_sd->setText( 2, *(it++) ); |
174 | test_cf->setText( 2, *(it++) ); | 174 | test_cf->setText( 2, *(it++) ); |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | void BenchmarkInfo::run() | 178 | void BenchmarkInfo::run() |
179 | { | 179 | { |
180 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); | 180 | startButton->setText( "> Don't touch! Running Tests! Don't touch! <" ); |
181 | qApp->processEvents(); | 181 | qApp->processEvents(); |
182 | QTime t; | 182 | QTime t; |
183 | 183 | ||
184 | if ( test_alu->isOn() ) | 184 | if ( test_alu->isOn() ) |
185 | { | 185 | { |
186 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); | 186 | int d = round( dhry_main( DHRYSTONE_RUNS ) ); |
187 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); | 187 | test_alu->setText( 1, QString( "%1 dhrys" ).arg( QString::number( d ) ) ); |
188 | test_alu->setOn( false ); | 188 | test_alu->setOn( false ); |
189 | } | 189 | } |
190 | 190 | ||
191 | if ( test_fpu->isOn() ) | 191 | if ( test_fpu->isOn() ) |
192 | { | 192 | { |
193 | t.start(); | 193 | t.start(); |
194 | BenchFFT(); | 194 | BenchFFT(); |
195 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); | 195 | test_fpu->setText( 1, QString( "%1 secs" ).arg( QString::number( t.elapsed() / 1000.0 ) ) ); |
196 | test_fpu->setOn( false ); | 196 | test_fpu->setOn( false ); |
197 | } | 197 | } |
198 | 198 | ||
199 | if ( test_txt->isOn() ) | 199 | if ( test_txt->isOn() ) |
200 | { | 200 | { |
201 | int value = textRendering( TEST_DURATION ); | 201 | int value = textRendering( TEST_DURATION ); |
202 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); | 202 | test_txt->setText( 1, QString( "%1 chars/sec" ).arg( QString::number( value / TEST_DURATION ) ) ); |
203 | test_txt->setOn( false ); | 203 | test_txt->setOn( false ); |
204 | } | 204 | } |
205 | 205 | ||
206 | if ( test_gfx->isOn() ) | 206 | if ( test_gfx->isOn() ) |
207 | { | 207 | { |
208 | int value = gfxRendering( TEST_DURATION ); | 208 | int value = gfxRendering( TEST_DURATION ); |
209 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests | 209 | test_gfx->setText( 1, QString( "%1 gops/sec" ).arg( QString::number( value / 4 / TEST_DURATION ) ) ); // 4 tests |
210 | test_gfx->setOn( false ); | 210 | test_gfx->setOn( false ); |
211 | } | 211 | } |
212 | 212 | ||
213 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA | 213 | if ( test_ram->isOn() ) // /tmp is supposed to be in RAM on a PDA |
214 | { | 214 | { |
215 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); | 215 | performFileTest( "/tmp/benchmarkFile.dat", test_ram ); |
216 | } | 216 | } |
217 | 217 | ||
218 | if ( test_cf->isOn() ) | 218 | if ( test_cf->isOn() ) |
219 | { | 219 | { |
220 | OStorageInfo storage; | 220 | OStorageInfo storage; |
221 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); | 221 | performFileTest( storage.cfPath() + "/benchmarkFile.dat", test_cf ); |
222 | } | 222 | } |
223 | 223 | ||
224 | if ( test_sd->isOn() ) | 224 | if ( test_sd->isOn() ) |
225 | { | 225 | { |
226 | OStorageInfo storage; | 226 | OStorageInfo storage; |
227 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); | 227 | performFileTest( storage.sdPath() + "/benchmarkFile.dat", test_sd ); |
228 | } | 228 | } |
229 | 229 | ||
230 | startButton->setText( tr( "&Start Tests!" ) ); | 230 | startButton->setText( tr( "&Start Tests!" ) ); |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | int BenchmarkInfo::textRendering( int seconds ) | 234 | int BenchmarkInfo::textRendering( int seconds ) |
235 | { | 235 | { |
236 | QTime t; | 236 | QTime t; |
237 | t.start(); | 237 | t.start(); |
238 | int stop = t.elapsed() + seconds * 1000; | 238 | int stop = t.elapsed() + seconds * 1000; |
239 | 239 | ||
240 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; | 240 | int rr[] = { 255, 255, 255, 0, 0, 0, 0, 128, 128 }; |
241 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; | 241 | int gg[] = { 0, 255, 0, 0, 255, 255, 0, 128, 128 }; |
242 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; | 242 | int bb[] = { 0, 0, 255, 0, 0, 255, 255, 128, 0 }; |
243 | const QString text( "Opie Benchmark Test" ); | 243 | const QString text( "Opie Benchmark Test" ); |
244 | 244 | ||
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 9cb8ad2..e688a29 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp | |||
@@ -1,154 +1,154 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ModulesInfo | 2 | ** ModulesInfo |
3 | ** | 3 | ** |
4 | ** Display Modules information | 4 | ** Display Modules information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Michael Lauer | 6 | ** Copyright (C) 2002, Michael Lauer |
7 | ** mickey@tm.informatik.uni-frankfurt.de | 7 | ** mickey@tm.informatik.uni-frankfurt.de |
8 | ** http://www.Vanille.de | 8 | ** http://www.Vanille.de |
9 | ** | 9 | ** |
10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> | 10 | ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> |
11 | ** | 11 | ** |
12 | ** This file may be distributed and/or modified under the terms of the | 12 | ** This file may be distributed and/or modified under the terms of the |
13 | ** GNU General Public License version 2 as published by the Free Software | 13 | ** GNU General Public License version 2 as published by the Free Software |
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" | 22 | #include "modulesinfo.h" |
23 | #include "detail.h" | 23 | #include "detail.h" |
24 | 24 | ||
25 | /* OPIE */ | 25 | /* OPIE */ |
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | 27 | ||
28 | /* QT */ | 28 | /* QT */ |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
34 | 34 | ||
35 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 35 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) |
36 | : QWidget( parent, name, fl ) | 36 | : QWidget( parent, name, fl ) |
37 | { | 37 | { |
38 | QGridLayout *layout = new QGridLayout( this ); | 38 | QGridLayout *layout = new QGridLayout( this ); |
39 | layout->setSpacing( 4 ); | 39 | layout->setSpacing( 4 ); |
40 | layout->setMargin( 4 ); | 40 | layout->setMargin( 4 ); |
41 | 41 | ||
42 | ModulesView = new QListView( this ); | 42 | ModulesView = new QListView( this ); |
43 | int colnum = ModulesView->addColumn( tr( "Module" ) ); | 43 | int colnum = ModulesView->addColumn( tr( "Module" ) ); |
44 | colnum = ModulesView->addColumn( tr( "Size" ) ); | 44 | colnum = ModulesView->addColumn( tr( "Size" ) ); |
45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 45 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
46 | colnum = ModulesView->addColumn( tr( "Use#" ) ); | 46 | colnum = ModulesView->addColumn( tr( "Use#" ) ); |
47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
48 | colnum = ModulesView->addColumn( tr( "Used by" ) ); | 48 | colnum = ModulesView->addColumn( tr( "Used by" ) ); |
49 | ModulesView->setAllColumnsShowFocus( TRUE ); | 49 | ModulesView->setAllColumnsShowFocus( TRUE ); |
50 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); | 50 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); |
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." ) ); | 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." ) ); |
52 | 52 | ||
53 | // 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 |
54 | if ( QFile::exists( "/sbin/modinfo" ) ) | 54 | if ( QFile::exists( "/sbin/modinfo" ) ) |
55 | { | 55 | { |
56 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); | 56 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); |
57 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 57 | connect( ModulesView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
58 | this, SLOT( viewModules( QListViewItem * ) ) ); | 58 | this, SLOT( viewModules(QListViewItem*) ) ); |
59 | } | 59 | } |
60 | 60 | ||
61 | CommandCB = new QComboBox( FALSE, this ); | 61 | CommandCB = new QComboBox( FALSE, this ); |
62 | CommandCB->insertItem( "modprobe -r" ); | 62 | CommandCB->insertItem( "modprobe -r" ); |
63 | CommandCB->insertItem( "rmmod" ); | 63 | CommandCB->insertItem( "rmmod" ); |
64 | // I can't think of other useful commands yet. Anyone? | 64 | // I can't think of other useful commands yet. Anyone? |
65 | layout->addWidget( CommandCB, 1, 0 ); | 65 | layout->addWidget( CommandCB, 1, 0 ); |
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." ) ); | 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." ) ); |
67 | 67 | ||
68 | QPushButton *btn = new QPushButton( this ); | 68 | QPushButton *btn = new QPushButton( this ); |
69 | btn->setMinimumSize( QSize( 50, 24 ) ); | 69 | btn->setMinimumSize( QSize( 50, 24 ) ); |
70 | btn->setMaximumSize( QSize( 50, 24 ) ); | 70 | btn->setMaximumSize( QSize( 50, 24 ) ); |
71 | btn->setText( tr( "Send" ) ); | 71 | btn->setText( tr( "Send" ) ); |
72 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 72 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
73 | layout->addWidget( btn, 1, 1 ); | 73 | layout->addWidget( btn, 1, 1 ); |
74 | 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." ) ); |
75 | 75 | ||
76 | QTimer *t = new QTimer( this ); | 76 | QTimer *t = new QTimer( this ); |
77 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 77 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
78 | t->start( 5000 ); | 78 | t->start( 5000 ); |
79 | 79 | ||
80 | updateData(); | 80 | updateData(); |
81 | 81 | ||
82 | ModulesDtl = new Detail(); | 82 | ModulesDtl = new Detail(); |
83 | 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." ) ); |
84 | } | 84 | } |
85 | 85 | ||
86 | ModulesInfo::~ModulesInfo() | 86 | ModulesInfo::~ModulesInfo() |
87 | {} | 87 | {} |
88 | 88 | ||
89 | void ModulesInfo::updateData() | 89 | void ModulesInfo::updateData() |
90 | { | 90 | { |
91 | char modname[64]; | 91 | char modname[64]; |
92 | char usage[200]; | 92 | char usage[200]; |
93 | int modsize, usecount; | 93 | int modsize, usecount; |
94 | 94 | ||
95 | QString selectedmod; | 95 | QString selectedmod; |
96 | QListViewItem *curritem = ModulesView->currentItem(); | 96 | QListViewItem *curritem = ModulesView->currentItem(); |
97 | if ( curritem ) | 97 | if ( curritem ) |
98 | { | 98 | { |
99 | selectedmod = curritem->text( 0 ); | 99 | selectedmod = curritem->text( 0 ); |
100 | } | 100 | } |
101 | 101 | ||
102 | ModulesView->clear(); | 102 | ModulesView->clear(); |
103 | 103 | ||
104 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 104 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
105 | 105 | ||
106 | if ( procfile ) | 106 | if ( procfile ) |
107 | { | 107 | { |
108 | QListViewItem *newitem; | 108 | QListViewItem *newitem; |
109 | QListViewItem *selecteditem = 0x0; | 109 | QListViewItem *selecteditem = 0x0; |
110 | while ( true ) | 110 | while ( true ) |
111 | { | 111 | { |
112 | modname[0] = '\0'; | 112 | modname[0] = '\0'; |
113 | usage[0] = '\0'; | 113 | usage[0] = '\0'; |
114 | 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 ); |
115 | 115 | ||
116 | if ( success == EOF ) | 116 | if ( success == EOF ) |
117 | break; | 117 | break; |
118 | 118 | ||
119 | QString qmodname = QString( modname ); | 119 | QString qmodname = QString( modname ); |
120 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 120 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
121 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 121 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
122 | QString qusage = QString( usage ); | 122 | QString qusage = QString( usage ); |
123 | 123 | ||
124 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 124 | newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
125 | if ( qmodname == selectedmod ) | 125 | if ( qmodname == selectedmod ) |
126 | { | 126 | { |
127 | selecteditem = newitem; | 127 | selecteditem = newitem; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | ModulesView->setCurrentItem( selecteditem ); | 130 | ModulesView->setCurrentItem( selecteditem ); |
131 | 131 | ||
132 | fclose( procfile ); | 132 | fclose( procfile ); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | void ModulesInfo::slotSendClicked() | 136 | void ModulesInfo::slotSendClicked() |
137 | { | 137 | { |
138 | if ( !ModulesView->currentItem() ) | 138 | if ( !ModulesView->currentItem() ) |
139 | { | 139 | { |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | 142 | ||
143 | 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() ); |
144 | 144 | ||
145 | QString modname = ModulesView->currentItem()->text( 0 ); | 145 | QString modname = ModulesView->currentItem()->text( 0 ); |
146 | 146 | ||
147 | if ( QMessageBox::warning( this, modname, capstr, | 147 | if ( QMessageBox::warning( this, modname, capstr, |
148 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 148 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
149 | { | 149 | { |
150 | QString command = "/sbin/"; | 150 | QString command = "/sbin/"; |
151 | command.append( CommandCB->currentText() ); | 151 | command.append( CommandCB->currentText() ); |
152 | command.append( " " ); | 152 | command.append( " " ); |
153 | command.append( modname ); | 153 | command.append( modname ); |
154 | 154 | ||
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 2a90b0f..69b4ab5 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -1,151 +1,151 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** ProcessInfo | 2 | ** ProcessInfo |
3 | ** | 3 | ** |
4 | ** Display process information | 4 | ** Display process information |
5 | ** | 5 | ** |
6 | ** Copyright (C) 2002, Dan Williams | 6 | ** Copyright (C) 2002, Dan Williams |
7 | ** williamsdr@acm.org | 7 | ** williamsdr@acm.org |
8 | ** http://draknor.net | 8 | ** http://draknor.net |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ** This file may be distributed and/or modified under the terms of the |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | ** GNU General Public License version 2 as published by the Free Software |
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" | 20 | #include "processinfo.h" |
21 | #include "detail.h" | 21 | #include "detail.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | 25 | ||
26 | /* QT */ | 26 | /* QT */ |
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | 32 | ||
33 | /* STD */ | 33 | /* STD */ |
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
35 | #include <signal.h> | 35 | #include <signal.h> |
36 | 36 | ||
37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | 37 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) |
38 | : QWidget( parent, name, fl ) | 38 | : QWidget( parent, name, fl ) |
39 | { | 39 | { |
40 | QGridLayout *layout = new QGridLayout( this ); | 40 | QGridLayout *layout = new QGridLayout( this ); |
41 | layout->setSpacing( 4 ); | 41 | layout->setSpacing( 4 ); |
42 | layout->setMargin( 4 ); | 42 | layout->setMargin( 4 ); |
43 | 43 | ||
44 | 44 | ||
45 | ProcessView = new QListView( this, "ProcessView" ); | 45 | ProcessView = new QListView( this, "ProcessView" ); |
46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); | 46 | int colnum = ProcessView->addColumn( tr( "PID" ) ); |
47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 47 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
48 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); | 48 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); |
49 | colnum = ProcessView->addColumn( tr( "Status" ) ); | 49 | colnum = ProcessView->addColumn( tr( "Status" ) ); |
50 | colnum = ProcessView->addColumn( tr( "Time" ) ); | 50 | colnum = ProcessView->addColumn( tr( "Time" ) ); |
51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
52 | ProcessView->setAllColumnsShowFocus( TRUE ); | 52 | ProcessView->setAllColumnsShowFocus( TRUE ); |
53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); | 53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); |
54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 54 | connect( ProcessView, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
55 | this, SLOT( viewProcess( QListViewItem * ) ) ); | 55 | this, SLOT( viewProcess(QListViewItem*) ) ); |
56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); | 56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); |
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." ) ); | 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." ) ); |
58 | 58 | ||
59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); | 59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); |
60 | SignalCB->insertItem( " 1: SIGHUP" ); | 60 | SignalCB->insertItem( " 1: SIGHUP" ); |
61 | SignalCB->insertItem( " 2: SIGINT" ); | 61 | SignalCB->insertItem( " 2: SIGINT" ); |
62 | SignalCB->insertItem( " 3: SIGQUIT" ); | 62 | SignalCB->insertItem( " 3: SIGQUIT" ); |
63 | SignalCB->insertItem( " 5: SIGTRAP" ); | 63 | SignalCB->insertItem( " 5: SIGTRAP" ); |
64 | SignalCB->insertItem( " 6: SIGABRT" ); | 64 | SignalCB->insertItem( " 6: SIGABRT" ); |
65 | SignalCB->insertItem( " 9: SIGKILL" ); | 65 | SignalCB->insertItem( " 9: SIGKILL" ); |
66 | SignalCB->insertItem( "14: SIGALRM" ); | 66 | SignalCB->insertItem( "14: SIGALRM" ); |
67 | SignalCB->insertItem( "15: SIGTERM" ); | 67 | SignalCB->insertItem( "15: SIGTERM" ); |
68 | SignalCB->insertItem( "18: SIGCONT" ); | 68 | SignalCB->insertItem( "18: SIGCONT" ); |
69 | SignalCB->insertItem( "19: SIGSTOP" ); | 69 | SignalCB->insertItem( "19: SIGSTOP" ); |
70 | layout->addWidget( SignalCB, 1, 0 ); | 70 | layout->addWidget( SignalCB, 1, 0 ); |
71 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); | 71 | QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); |
72 | 72 | ||
73 | SendButton = new QPushButton( this, "SendButton" ); | 73 | SendButton = new QPushButton( this, "SendButton" ); |
74 | SendButton->setMinimumSize( QSize( 50, 24 ) ); | 74 | SendButton->setMinimumSize( QSize( 50, 24 ) ); |
75 | SendButton->setMaximumSize( QSize( 50, 24 ) ); | 75 | SendButton->setMaximumSize( QSize( 50, 24 ) ); |
76 | SendButton->setText( tr( "Send" ) ); | 76 | SendButton->setText( tr( "Send" ) ); |
77 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 77 | connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
78 | layout->addWidget( SendButton, 1, 1 ); | 78 | layout->addWidget( SendButton, 1, 1 ); |
79 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); | 79 | QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); |
80 | 80 | ||
81 | QTimer *t = new QTimer( this ); | 81 | QTimer *t = new QTimer( this ); |
82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 82 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
83 | t->start( 5000 ); | 83 | t->start( 5000 ); |
84 | 84 | ||
85 | updateData(); | 85 | updateData(); |
86 | 86 | ||
87 | ProcessDtl = new Detail(); | 87 | ProcessDtl = new Detail(); |
88 | 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." ) ); |
89 | } | 89 | } |
90 | 90 | ||
91 | ProcessInfo::~ProcessInfo() | 91 | ProcessInfo::~ProcessInfo() |
92 | {} | 92 | {} |
93 | 93 | ||
94 | void ProcessInfo::updateData() | 94 | void ProcessInfo::updateData() |
95 | { | 95 | { |
96 | 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, |
97 | signal, blocked, sigignore, sigcatch; | 97 | signal, blocked, sigignore, sigcatch; |
98 | 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, |
99 | endcode, startstack, kstkesp, kstkeip, wchan; | 99 | endcode, startstack, kstkesp, kstkeip, wchan; |
100 | char state; | 100 | char state; |
101 | char comm[64]; | 101 | char comm[64]; |
102 | 102 | ||
103 | QString selectedpid; | 103 | QString selectedpid; |
104 | QListViewItem *curritem = ProcessView->currentItem(); | 104 | QListViewItem *curritem = ProcessView->currentItem(); |
105 | if ( curritem ) | 105 | if ( curritem ) |
106 | { | 106 | { |
107 | selectedpid = curritem->text( 0 ); | 107 | selectedpid = curritem->text( 0 ); |
108 | } | 108 | } |
109 | 109 | ||
110 | ProcessView->clear(); | 110 | ProcessView->clear(); |
111 | 111 | ||
112 | QListViewItem *newitem; | 112 | QListViewItem *newitem; |
113 | QListViewItem *selecteditem = 0x0; | 113 | QListViewItem *selecteditem = 0x0; |
114 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); | 114 | QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); |
115 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); | 115 | QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); |
116 | if ( proclist ) | 116 | if ( proclist ) |
117 | { | 117 | { |
118 | QFileInfoListIterator it(*proclist); | 118 | QFileInfoListIterator it(*proclist); |
119 | QFileInfo *f; | 119 | QFileInfo *f; |
120 | while ( ( f = it.current() ) != 0 ) | 120 | while ( ( f = it.current() ) != 0 ) |
121 | { | 121 | { |
122 | ++it; | 122 | ++it; |
123 | QString processnum = f->fileName(); | 123 | QString processnum = f->fileName(); |
124 | if ( processnum >= "1" && processnum <= "99999" ) | 124 | if ( processnum >= "1" && processnum <= "99999" ) |
125 | { | 125 | { |
126 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); | 126 | FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); |
127 | 127 | ||
128 | if ( procfile ) | 128 | if ( procfile ) |
129 | { | 129 | { |
130 | fscanf( procfile, | 130 | fscanf( procfile, |
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", | 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", |
132 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, | 132 | &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, |
133 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, | 133 | &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, |
134 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, | 134 | &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, |
135 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); | 135 | &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); |
136 | processnum = processnum.rightJustify( 5, ' ' ); | 136 | processnum = processnum.rightJustify( 5, ' ' ); |
137 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); | 137 | QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); |
138 | QString processstatus = QChar(state); | 138 | QString processstatus = QChar(state); |
139 | QString processtime = QString::number( ( utime + stime ) / 100 ); | 139 | QString processtime = QString::number( ( utime + stime ) / 100 ); |
140 | processtime = processtime.rightJustify( 9, ' ' ); | 140 | processtime = processtime.rightJustify( 9, ' ' ); |
141 | fclose( procfile ); | 141 | fclose( procfile ); |
142 | 142 | ||
143 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); | 143 | newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); |
144 | if ( processnum == selectedpid ) | 144 | if ( processnum == selectedpid ) |
145 | { | 145 | { |
146 | selecteditem = newitem; | 146 | selecteditem = newitem; |
147 | } | 147 | } |
148 | } | 148 | } |
149 | } | 149 | } |
150 | } | 150 | } |
151 | ProcessView->setCurrentItem( selecteditem ); | 151 | ProcessView->setCurrentItem( selecteditem ); |
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp index ff5957c..15aeaf5 100644 --- a/noncore/settings/tabmanager/tabmanager.cpp +++ b/noncore/settings/tabmanager/tabmanager.cpp | |||
@@ -1,135 +1,135 @@ | |||
1 | #include "tabmanager.h" | 1 | #include "tabmanager.h" |
2 | #include "app.h" | 2 | #include "app.h" |
3 | #include "wait.h" | 3 | #include "wait.h" |
4 | #include "tabapplnk.h" | 4 | #include "tabapplnk.h" |
5 | 5 | ||
6 | #include <qpe/applnk.h> | 6 | #include <qpe/applnk.h> |
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <qlistview.h> | 10 | #include <qlistview.h> |
11 | #include <qheader.h> | 11 | #include <qheader.h> |
12 | #include <qcombobox.h> | 12 | #include <qcombobox.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qlabel.h> | 14 | #include <qlabel.h> |
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <stdlib.h> | 16 | #include <stdlib.h> |
17 | #include <qpe/qcopenvelope_qws.h> | 17 | #include <qpe/qcopenvelope_qws.h> |
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | 20 | ||
21 | 21 | ||
22 | #define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" | 22 | #define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" |
23 | #define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" | 23 | #define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" |
24 | #define NEW_FOLDER "EmptyTab" | 24 | #define NEW_FOLDER "EmptyTab" |
25 | #define NEW_APPLICATION "NewApp" | 25 | #define NEW_APPLICATION "NewApp" |
26 | #define APPLICATION_EXTENSION ".desktop" | 26 | #define APPLICATION_EXTENSION ".desktop" |
27 | #define APPLICATION_EXTENSION_LENGTH 8 | 27 | #define APPLICATION_EXTENSION_LENGTH 8 |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Constructor. Sets up signals. Performs initial scan of applications | 30 | * Constructor. Sets up signals. Performs initial scan of applications |
31 | * and tabs | 31 | * and tabs |
32 | */ | 32 | */ |
33 | TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){ | 33 | TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){ |
34 | rescanFolder(HOME_APP_DIR); | 34 | rescanFolder(HOME_APP_DIR); |
35 | 35 | ||
36 | // Connect the signals and slots | 36 | // Connect the signals and slots |
37 | connect(tabList, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(editItem(QListViewItem*))); | 37 | connect(tabList, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(editItem(QListViewItem*))); |
38 | (tabList->header())->hide(); | 38 | (tabList->header())->hide(); |
39 | connect(tabList, SIGNAL(moveItem(QListViewItem *, QListViewItem *)), this, SLOT(moveApplication(QListViewItem *, QListViewItem *))); | 39 | connect(tabList, SIGNAL(moveItem(QListViewItem*,QListViewItem*)), this, SLOT(moveApplication(QListViewItem*,QListViewItem*))); |
40 | } | 40 | } |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * If anything in the tab's have been changed then update the system or alert | 43 | * If anything in the tab's have been changed then update the system or alert |
44 | * the user. | 44 | * the user. |
45 | */ | 45 | */ |
46 | TabManager::~TabManager(){ | 46 | TabManager::~TabManager(){ |
47 | if(changed){ | 47 | if(changed){ |
48 | // Prompt. | 48 | // Prompt. |
49 | //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 ); | 49 | //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 ); |
50 | //if (answer) | 50 | //if (answer) |
51 | // return; | 51 | // return; |
52 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 52 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
53 | QString link; //we'll just send an empty string | 53 | QString link; //we'll just send an empty string |
54 | e << link; | 54 | e << link; |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Scans root directory for any tabs or applications. Will recursivly go down, | 59 | * Scans root directory for any tabs or applications. Will recursivly go down, |
60 | * but will not follow symlinks. | 60 | * but will not follow symlinks. |
61 | * @param directory - the directory to look in. | 61 | * @param directory - the directory to look in. |
62 | * @param parent - the parent to place any new tabs or apps into. If parent is | 62 | * @param parent - the parent to place any new tabs or apps into. If parent is |
63 | * NULL then the item is a tab and should be placed as a child of the window. | 63 | * NULL then the item is a tab and should be placed as a child of the window. |
64 | */ | 64 | */ |
65 | void TabManager::rescanFolder(QString directory, QListViewItem* parent){ | 65 | void TabManager::rescanFolder(QString directory, QListViewItem* parent){ |
66 | //qDebug(QString("rescanFolder: ") + directory.latin1()); | 66 | //qDebug(QString("rescanFolder: ") + directory.latin1()); |
67 | 67 | ||
68 | QDir d; | 68 | QDir d; |
69 | d.setPath(directory); | 69 | d.setPath(directory); |
70 | // Show hidden files for .directories | 70 | // Show hidden files for .directories |
71 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); | 71 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); |
72 | 72 | ||
73 | const QFileInfoList *list = d.entryInfoList(); | 73 | const QFileInfoList *list = d.entryInfoList(); |
74 | QFileInfoListIterator it( *list ); // create list iterator | 74 | QFileInfoListIterator it( *list ); // create list iterator |
75 | QFileInfo *fi; // pointer for traversing | 75 | QFileInfo *fi; // pointer for traversing |
76 | 76 | ||
77 | while ( (fi=it.current()) ) { // for each file... | 77 | while ( (fi=it.current()) ) { // for each file... |
78 | // If it is a dir and not .. or . then add it as a tab and go down. | 78 | // If it is a dir and not .. or . then add it as a tab and go down. |
79 | if(fi->isDir()){ | 79 | if(fi->isDir()){ |
80 | if(fi->fileName() != ".." && fi->fileName() != ".") { | 80 | if(fi->fileName() != ".." && fi->fileName() != ".") { |
81 | QListViewItem* newItem; | 81 | QListViewItem* newItem; |
82 | if(!parent) | 82 | if(!parent) |
83 | newItem = new QListViewItem(tabList, fi->fileName()); | 83 | newItem = new QListViewItem(tabList, fi->fileName()); |
84 | else | 84 | else |
85 | newItem = new QListViewItem(parent, fi->fileName()); | 85 | newItem = new QListViewItem(parent, fi->fileName()); |
86 | itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" ); | 86 | itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" ); |
87 | rescanFolder(directory + "/" + fi->fileName(), newItem); | 87 | rescanFolder(directory + "/" + fi->fileName(), newItem); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | else{ | 90 | else{ |
91 | // it is a file, if not a .directory add to parent. | 91 | // it is a file, if not a .directory add to parent. |
92 | 92 | ||
93 | // Change parents name and icon to reflect icon. | 93 | // Change parents name and icon to reflect icon. |
94 | if(fi->fileName() == ".directory"){ | 94 | if(fi->fileName() == ".directory"){ |
95 | AppLnk app(directory + "/" + fi->fileName()); | 95 | AppLnk app(directory + "/" + fi->fileName()); |
96 | if(parent){ | 96 | if(parent){ |
97 | parent->setPixmap(0,app.pixmap()); | 97 | parent->setPixmap(0,app.pixmap()); |
98 | parent->setText(0, app.name()); | 98 | parent->setText(0, app.name()); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | else{ | 101 | else{ |
102 | // Add any desktop files found. | 102 | // Add any desktop files found. |
103 | QListViewItem* newItem; | 103 | QListViewItem* newItem; |
104 | if(directory != HOME_APP_DIR){ | 104 | if(directory != HOME_APP_DIR){ |
105 | if(!parent) | 105 | if(!parent) |
106 | newItem = new QListViewItem(tabList, fi->fileName()); | 106 | newItem = new QListViewItem(tabList, fi->fileName()); |
107 | else | 107 | else |
108 | newItem = new QListViewItem(parent, fi->fileName()); | 108 | newItem = new QListViewItem(parent, fi->fileName()); |
109 | if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){ | 109 | if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){ |
110 | AppLnk app(directory + "/" + fi->fileName()); | 110 | AppLnk app(directory + "/" + fi->fileName()); |
111 | newItem->setPixmap(0,app.pixmap()); | 111 | newItem->setPixmap(0,app.pixmap()); |
112 | newItem->setText(0, app.name()); | 112 | newItem->setText(0, app.name()); |
113 | itemList.insert(newItem, directory + "/" + fi->fileName()); | 113 | itemList.insert(newItem, directory + "/" + fi->fileName()); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
118 | ++it; // goto next list element | 118 | ++it; // goto next list element |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | /** | 122 | /** |
123 | * Create a new blank Tab. | 123 | * Create a new blank Tab. |
124 | * Create a physical folder with .directory file | 124 | * Create a physical folder with .directory file |
125 | * Create a item on the list | 125 | * Create a item on the list |
126 | */ | 126 | */ |
127 | void TabManager::newFolder(){ | 127 | void TabManager::newFolder(){ |
128 | QDir r; | 128 | QDir r; |
129 | r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER); | 129 | r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER); |
130 | system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); | 130 | system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); |
131 | system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); | 131 | system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); |
132 | 132 | ||
133 | QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory"; | 133 | QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory"; |
134 | QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER); | 134 | QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER); |
135 | itemList.insert(newItem, homeLocation ); | 135 | itemList.insert(newItem, homeLocation ); |
diff --git a/noncore/settings/usermanager/usermanager.cpp b/noncore/settings/usermanager/usermanager.cpp index 5411995..a1130d4 100644 --- a/noncore/settings/usermanager/usermanager.cpp +++ b/noncore/settings/usermanager/usermanager.cpp | |||
@@ -1,176 +1,176 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | #include "usermanager.h" | 10 | #include "usermanager.h" |
11 | 11 | ||
12 | #include <qlayout.h> | 12 | #include <qlayout.h> |
13 | 13 | ||
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | #include <qfile.h> | 15 | #include <qfile.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | 17 | ||
18 | #include <qregexp.h> | 18 | #include <qregexp.h> |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * The mainwindow constructor. | 21 | * The mainwindow constructor. |
22 | * | 22 | * |
23 | * @param QWidget *parent | 23 | * @param QWidget *parent |
24 | * @param const char *name | 24 | * @param const char *name |
25 | * @ param WFlags fl | 25 | * @ param WFlags fl |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { | 28 | UserConfig::UserConfig(QWidget* parent, const char* name, WFlags fl) : QMainWindow(parent, name, fl) { |
29 | setCaption(tr("Opie User Manager")); | 29 | setCaption(tr("Opie User Manager")); |
30 | 30 | ||
31 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. | 31 | // Create an instance of the global object 'accounts'. This holds all user/group info, and functions to modify them. |
32 | accounts=new Passwd(); | 32 | accounts=new Passwd(); |
33 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. | 33 | accounts->open();// This actually loads the files /etc/passwd & /etc/group into memory. |
34 | 34 | ||
35 | // Create the toolbar. | 35 | // Create the toolbar. |
36 | QToolBar *toolbar = new QToolBar(this,"Toolbar"); | 36 | QToolBar *toolbar = new QToolBar(this,"Toolbar"); |
37 | toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? | 37 | toolbar->setHorizontalStretchable(1); // Is there any other way to get the toolbar to stretch of the full screen!? |
38 | adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); | 38 | adduserToolButton = new QToolButton(Resource::loadPixmap("usermanager/adduser"),"Add User",0,this,SLOT(addUser()),toolbar,"Add User"); |
39 | edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); | 39 | edituserToolButton = new QToolButton(Resource::loadPixmap("usermanager/edituser"),"Edit User",0,this,SLOT(editUser()),toolbar,"Edit User"); |
40 | deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); | 40 | deleteuserToolButton = new QToolButton(Resource::loadPixmap("usermanager/deleteuser"),"Delete User",0,this,SLOT(delUser()),toolbar,"Delete User"); |
41 | QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); | 41 | QToolButton *userstext = new QToolButton(0,"User",0,0,0,toolbar,"User"); |
42 | userstext->setUsesTextLabel(true); | 42 | userstext->setUsesTextLabel(true); |
43 | toolbar->addSeparator(); | 43 | toolbar->addSeparator(); |
44 | addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); | 44 | addgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/addgroup"),"Add Group",0,this,SLOT(addGroup()),toolbar,"Add Group"); |
45 | editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); | 45 | editgroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/editgroup"),"Edit Group",0,this,SLOT(editGroup()),toolbar,"Edit Group"); |
46 | deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); | 46 | deletegroupToolButton = new QToolButton(Resource::loadPixmap("usermanager/deletegroup"),"Delete Group",0,this,SLOT(delGroup()),toolbar,"Delete Group"); |
47 | QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); | 47 | QToolButton *groupstext = new QToolButton(0,"Group",0,0,0,toolbar,"Group"); |
48 | groupstext->setUsesTextLabel(true); | 48 | groupstext->setUsesTextLabel(true); |
49 | addToolBar(toolbar,"myToolBar"); | 49 | addToolBar(toolbar,"myToolBar"); |
50 | 50 | ||
51 | // Add a tabwidget and all the tabs. | 51 | // Add a tabwidget and all the tabs. |
52 | myTabWidget = new QTabWidget(this,"My Tab Widget"); | 52 | myTabWidget = new QTabWidget(this,"My Tab Widget"); |
53 | setupTabAccounts(); | 53 | setupTabAccounts(); |
54 | setupTabAllUsers(); | 54 | setupTabAllUsers(); |
55 | setupTabAllGroups(); | 55 | setupTabAllGroups(); |
56 | userPopupMenu.insertItem("Copy",0); | 56 | userPopupMenu.insertItem("Copy",0); |
57 | 57 | ||
58 | getUsers(); // Fill out the iconview & listview with all users. | 58 | getUsers(); // Fill out the iconview & listview with all users. |
59 | getGroups(); // Fill out the group listview with all groups. | 59 | getGroups(); // Fill out the group listview with all groups. |
60 | 60 | ||
61 | setCentralWidget(myTabWidget); | 61 | setCentralWidget(myTabWidget); |
62 | } | 62 | } |
63 | 63 | ||
64 | UserConfig::~UserConfig() { | 64 | UserConfig::~UserConfig() { |
65 | accounts->close(); | 65 | accounts->close(); |
66 | delete accounts; | 66 | delete accounts; |
67 | } | 67 | } |
68 | 68 | ||
69 | void UserConfig::setupTabAccounts() { | 69 | void UserConfig::setupTabAccounts() { |
70 | QWidget *tabpage = new QWidget(this); | 70 | QWidget *tabpage = new QWidget(this); |
71 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 71 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
72 | layout->setMargin(5); | 72 | layout->setMargin(5); |
73 | 73 | ||
74 | usersIconView=new QListView(tabpage,"users"); | 74 | usersIconView=new QListView(tabpage,"users"); |
75 | usersIconView->addColumn("Icon"); | 75 | usersIconView->addColumn("Icon"); |
76 | usersIconView->addColumn("Username"); | 76 | usersIconView->addColumn("Username"); |
77 | usersIconView->setAllColumnsShowFocus(true); | 77 | usersIconView->setAllColumnsShowFocus(true); |
78 | layout->addWidget(usersIconView); | 78 | layout->addWidget(usersIconView); |
79 | 79 | ||
80 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem *)),this,SLOT(showUserMenu(QListViewItem *))); | 80 | connect(usersIconView,SIGNAL(returnPressed(QListViewItem*)),this,SLOT(showUserMenu(QListViewItem*))); |
81 | 81 | ||
82 | myTabWidget->addTab(tabpage,"Users"); | 82 | myTabWidget->addTab(tabpage,"Users"); |
83 | } | 83 | } |
84 | 84 | ||
85 | void UserConfig::setupTabAllUsers() { | 85 | void UserConfig::setupTabAllUsers() { |
86 | QWidget *tabpage = new QWidget(this); | 86 | QWidget *tabpage = new QWidget(this); |
87 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 87 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
88 | layout->setMargin(5); | 88 | layout->setMargin(5); |
89 | 89 | ||
90 | usersListView=new QListView(tabpage,"allusers"); | 90 | usersListView=new QListView(tabpage,"allusers"); |
91 | usersListView->addColumn("UID"); | 91 | usersListView->addColumn("UID"); |
92 | usersListView->addColumn("Login"); | 92 | usersListView->addColumn("Login"); |
93 | usersListView->addColumn("Username"); | 93 | usersListView->addColumn("Username"); |
94 | layout->addWidget(usersListView); | 94 | layout->addWidget(usersListView); |
95 | usersListView->setSorting(1,1); | 95 | usersListView->setSorting(1,1); |
96 | usersListView->setAllColumnsShowFocus(true); | 96 | usersListView->setAllColumnsShowFocus(true); |
97 | 97 | ||
98 | myTabWidget->addTab(tabpage,"All Users"); | 98 | myTabWidget->addTab(tabpage,"All Users"); |
99 | } | 99 | } |
100 | 100 | ||
101 | void UserConfig::setupTabAllGroups() { | 101 | void UserConfig::setupTabAllGroups() { |
102 | QWidget *tabpage = new QWidget(this); | 102 | QWidget *tabpage = new QWidget(this); |
103 | QVBoxLayout *layout = new QVBoxLayout(tabpage); | 103 | QVBoxLayout *layout = new QVBoxLayout(tabpage); |
104 | layout->setMargin(5); | 104 | layout->setMargin(5); |
105 | 105 | ||
106 | groupsListView=new QListView(tabpage,"groups"); | 106 | groupsListView=new QListView(tabpage,"groups"); |
107 | groupsListView->addColumn("GID"); | 107 | groupsListView->addColumn("GID"); |
108 | groupsListView->addColumn("Groupname"); | 108 | groupsListView->addColumn("Groupname"); |
109 | layout->addWidget(groupsListView); | 109 | layout->addWidget(groupsListView); |
110 | groupsListView->setSorting(1,1); | 110 | groupsListView->setSorting(1,1); |
111 | groupsListView->setAllColumnsShowFocus(true); | 111 | groupsListView->setAllColumnsShowFocus(true); |
112 | 112 | ||
113 | myTabWidget->addTab(tabpage,"All Groups"); | 113 | myTabWidget->addTab(tabpage,"All Groups"); |
114 | } | 114 | } |
115 | void UserConfig::getUsers() { | 115 | void UserConfig::getUsers() { |
116 | QString mytext; | 116 | QString mytext; |
117 | QPixmap mypixmap; | 117 | QPixmap mypixmap; |
118 | QListViewItem *listviewitem; | 118 | QListViewItem *listviewitem; |
119 | 119 | ||
120 | // Empty the iconview & the listview. | 120 | // Empty the iconview & the listview. |
121 | usersIconView->clear(); | 121 | usersIconView->clear(); |
122 | usersListView->clear(); | 122 | usersListView->clear(); |
123 | 123 | ||
124 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. | 124 | // availableUID is used as a deposite for the next available UID on the system, this should start at an ID over 500. |
125 | availableUID=500; | 125 | availableUID=500; |
126 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { | 126 | for(QStringList::Iterator it=accounts->passwdStringList.begin(); it!=accounts->passwdStringList.end(); ++it) { |
127 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) | 127 | accounts->splitPasswdEntry(*it); // Split the string into it's components and store in variables in the accounts object. ("pr_name" and so on.) |
128 | if(accounts->pw_name.find(QRegExp("^#"),0)) {// Skip commented lines. | 128 | if(accounts->pw_name.find(QRegExp("^#"),0)) {// Skip commented lines. |
129 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); | 129 | new QListViewItem(usersListView,QString::number(accounts->pw_uid),accounts->pw_name,accounts->pw_gecos); |
130 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? | 130 | if((accounts->pw_uid>=500) && (accounts->pw_uid<65000)) {// Is this user a "normal" user ? |
131 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. | 131 | mytext=QString(accounts->pw_name)+" - ("+QString(accounts->pw_gecos)+")"; // The string displayed next to the icon. |
132 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work. | 132 | if(!(mypixmap.load("/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"))) { // Is there an icon for this user? Resource::loadPixmap is caching, doesn't work. |
133 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. | 133 | mypixmap=Resource::loadPixmap(QString("usermanager/usericon"));// If this user has no icon, load the default icon. |
134 | } | 134 | } |
135 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. | 135 | listviewitem=new QListViewItem(usersIconView,"",mytext);// Add the icon+text to the qiconview. |
136 | listviewitem->setPixmap(0,mypixmap); | 136 | listviewitem->setPixmap(0,mypixmap); |
137 | } | 137 | } |
138 | if((accounts->pw_uid>=availableUID) && (accounts->pw_uid<65000)) availableUID=accounts->pw_uid+1; // Increase 1 to the latest know UID to get a free uid. | 138 | if((accounts->pw_uid>=availableUID) && (accounts->pw_uid<65000)) availableUID=accounts->pw_uid+1; // Increase 1 to the latest know UID to get a free uid. |
139 | } | 139 | } |
140 | } | 140 | } |
141 | usersIconView->sort(); | 141 | usersIconView->sort(); |
142 | } | 142 | } |
143 | 143 | ||
144 | void UserConfig::addUser() { | 144 | void UserConfig::addUser() { |
145 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. | 145 | if(UserDialog::addUser(availableUID,availableGID)) {// Add the user to the system, also send next available UID and GID. |
146 | getUsers(); // Update users views. | 146 | getUsers(); // Update users views. |
147 | getGroups(); // Update groups view. | 147 | getGroups(); // Update groups view. |
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | void UserConfig::editUser() { | 151 | void UserConfig::editUser() { |
152 | QString username; | 152 | QString username; |
153 | if(myTabWidget->currentPageIndex()==0) {// Users | 153 | if(myTabWidget->currentPageIndex()==0) {// Users |
154 | if(usersIconView->currentItem()) {// Any icon selected? | 154 | if(usersIconView->currentItem()) {// Any icon selected? |
155 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. | 155 | username=usersIconView->currentItem()->text(1);// Get the text associated with the icon. |
156 | username=username.left(username.find(" - (",0,true));// Strip out the username. | 156 | username=username.left(username.find(" - (",0,true));// Strip out the username. |
157 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 157 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
158 | // If there were any changed also update the views. | 158 | // If there were any changed also update the views. |
159 | getUsers(); | 159 | getUsers(); |
160 | getGroups(); | 160 | getGroups(); |
161 | } | 161 | } |
162 | } else { | 162 | } else { |
163 | QMessageBox::information(this,"No selection.","No user has been selected."); | 163 | QMessageBox::information(this,"No selection.","No user has been selected."); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | if(myTabWidget->currentPageIndex()==1) {// All users | 166 | if(myTabWidget->currentPageIndex()==1) {// All users |
167 | if(usersListView->currentItem()) {// Anything changed!? | 167 | if(usersListView->currentItem()) {// Anything changed!? |
168 | username=usersListView->currentItem()->text(1);// Get the username. | 168 | username=usersListView->currentItem()->text(1);// Get the username. |
169 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. | 169 | if(UserDialog::editUser(username)) {// Bring up the userinfo dialog. |
170 | // And again update the views if there were any changes. | 170 | // And again update the views if there were any changes. |
171 | getUsers(); | 171 | getUsers(); |
172 | getGroups(); | 172 | getGroups(); |
173 | } | 173 | } |
174 | } else { | 174 | } else { |
175 | QMessageBox::information(this,"No selection.","No user has been selected."); | 175 | QMessageBox::information(this,"No selection.","No user has been selected."); |
176 | } | 176 | } |