author | zecke <zecke> | 2003-05-14 12:08:54 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-05-14 12:08:54 (UTC) |
commit | c480b91a5afe1f259287c3c4173ec02f2b4854cb (patch) (unidiff) | |
tree | ffe59a2fc544f6067fd96065d94a877188f1ef88 | |
parent | 415a300230e10e29660b2af26a23798fd0b12e03 (diff) | |
download | opie-c480b91a5afe1f259287c3c4173ec02f2b4854cb.zip opie-c480b91a5afe1f259287c3c4173ec02f2b4854cb.tar.gz opie-c480b91a5afe1f259287c3c4173ec02f2b4854cb.tar.bz2 |
patch by Scott Bronson
kill the duplicated config.cpp and config.h file
add proper default values so that kpacman actually works
out of the box
Config wanted to read kpacman.conf but this file did only exist
globally
-rw-r--r-- | noncore/games/kpacman/config.cpp | 394 | ||||
-rw-r--r-- | noncore/games/kpacman/config.h | 74 | ||||
-rw-r--r-- | noncore/games/kpacman/keys.cpp | 4 | ||||
-rw-r--r-- | noncore/games/kpacman/kpacman.cpp | 18 | ||||
-rw-r--r-- | noncore/games/kpacman/kpacman.pro | 2 | ||||
-rw-r--r-- | noncore/games/kpacman/kpacmanwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/games/kpacman/painter.cpp | 2 | ||||
-rw-r--r-- | noncore/games/kpacman/referee.cpp | 2 | ||||
-rw-r--r-- | noncore/games/kpacman/status.cpp | 4 |
9 files changed, 19 insertions, 483 deletions
diff --git a/noncore/games/kpacman/config.cpp b/noncore/games/kpacman/config.cpp deleted file mode 100644 index b9e3607..0000000 --- a/noncore/games/kpacman/config.cpp +++ b/dev/null | |||
@@ -1,394 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qt Palmtop Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | ** $Id$ | ||
20 | ** | ||
21 | **********************************************************************/ | ||
22 | |||
23 | #include "config.h" | ||
24 | |||
25 | #include <qfile.h> | ||
26 | #include <qdir.h> | ||
27 | #include <qfileinfo.h> | ||
28 | #include <qtextstream.h> | ||
29 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | ||
30 | #include <qtextcodec.h> | ||
31 | #endif | ||
32 | #include <stdlib.h> | ||
33 | #include <sys/stat.h> | ||
34 | #include <sys/types.h> | ||
35 | #include <fcntl.h> | ||
36 | #include <unistd.h> | ||
37 | |||
38 | /*! | ||
39 | \internal | ||
40 | */ | ||
41 | QString Config::configFilename(const QString& name, Domain d) | ||
42 | { | ||
43 | switch (d) { | ||
44 | case File: | ||
45 | return name; | ||
46 | case User: { | ||
47 | QDir dir = (QString(getenv("HOME")) + "/Settings"); | ||
48 | if ( !dir.exists() ) | ||
49 | mkdir(dir.path().local8Bit(),0700); | ||
50 | return dir.path() + "/" + name + ".conf"; | ||
51 | } | ||
52 | } | ||
53 | return name; | ||
54 | } | ||
55 | |||
56 | /*! | ||
57 | \class Config config.h | ||
58 | \brief The Config class provides for saving application cofniguration state. | ||
59 | |||
60 | You should keep a Config in existence only while you do not want others | ||
61 | to be able to change the state. There is no locking currently, but there | ||
62 | may be in the future. | ||
63 | */ | ||
64 | |||
65 | /*! | ||
66 | \enum Config::ConfigGroup | ||
67 | \internal | ||
68 | */ | ||
69 | |||
70 | /*! | ||
71 | \enum Config::Domain | ||
72 | |||
73 | \value File | ||
74 | \value User | ||
75 | |||
76 | See Config for details. | ||
77 | */ | ||
78 | |||
79 | /*! | ||
80 | Constructs a config that will load or create a configuration with the | ||
81 | given \a name in the given \a domain. | ||
82 | |||
83 | You must call setGroup() before doing much else with the Config. | ||
84 | |||
85 | In the default Domain, \e User, | ||
86 | the configuration is user-specific. \a name should not contain "/" in | ||
87 | this case, and in general should be the name of the C++ class that is | ||
88 | primarily responsible for maintaining the configuration. | ||
89 | |||
90 | In the File Domain, \a name is an absolute filename. | ||
91 | */ | ||
92 | Config::Config( const QString &name, Domain domain ) | ||
93 | : filename( configFilename(name,domain) ) | ||
94 | { | ||
95 | git = groups.end(); | ||
96 | read(); | ||
97 | |||
98 | lang = getenv("LANG"); | ||
99 | int i = lang.find("."); | ||
100 | if ( i > 0 ) | ||
101 | lang = lang.left( i ); | ||
102 | i = lang.find( "_" ); | ||
103 | if ( i > 0 ) | ||
104 | glang = lang.left(i); | ||
105 | } | ||
106 | |||
107 | /*! | ||
108 | Writes any changes to disk and destroys the in-memory object. | ||
109 | */ | ||
110 | Config::~Config() | ||
111 | { | ||
112 | if ( changed ) | ||
113 | write(); | ||
114 | } | ||
115 | |||
116 | /*! | ||
117 | Returns whether the current group has an entry called \a key. | ||
118 | */ | ||
119 | bool Config::hasKey( const QString &key ) const | ||
120 | { | ||
121 | if ( groups.end() == git ) | ||
122 | return FALSE; | ||
123 | ConfigGroup::ConstIterator it = ( *git ).find( key ); | ||
124 | return it != ( *git ).end(); | ||
125 | } | ||
126 | |||
127 | /*! | ||
128 | Sets the current group for subsequent reading and writing of | ||
129 | entries to \a gname. Grouping allows the application to partition the namespace. | ||
130 | |||
131 | This function must be called prior to any reading or writing | ||
132 | of entries. | ||
133 | |||
134 | The \a gname must not be empty. | ||
135 | */ | ||
136 | void Config::setGroup( const QString &gname ) | ||
137 | { | ||
138 | QMap< QString, ConfigGroup>::Iterator it = groups.find( gname ); | ||
139 | if ( it == groups.end() ) { | ||
140 | ConfigGroup *grp = new ConfigGroup; | ||
141 | git = groups.insert( gname, *grp ); | ||
142 | changed = TRUE; | ||
143 | return; | ||
144 | } | ||
145 | git = it; | ||
146 | } | ||
147 | |||
148 | /*! | ||
149 | Writes a (\a key, \a value) entry to the current group. | ||
150 | |||
151 | \sa readEntry() | ||
152 | */ | ||
153 | void Config::writeEntry( const QString &key, const QString &value ) | ||
154 | { | ||
155 | if ( git == groups.end() ) { | ||
156 | qWarning( "no group set" ); | ||
157 | return; | ||
158 | } | ||
159 | if ( (*git)[key] != value ) { | ||
160 | ( *git ).insert( key, value ); | ||
161 | changed = TRUE; | ||
162 | } | ||
163 | } | ||
164 | |||
165 | /*! | ||
166 | Writes a (\a key, \a num) entry to the current group. | ||
167 | |||
168 | \sa readNumEntry() | ||
169 | */ | ||
170 | void Config::writeEntry( const QString &key, int num ) | ||
171 | { | ||
172 | QString s; | ||
173 | s.setNum( num ); | ||
174 | writeEntry( key, s ); | ||
175 | } | ||
176 | |||
177 | #ifdef Q_HAS_BOOL_TYPE | ||
178 | /*! | ||
179 | Writes a (\a key, \a b) entry to the current group. | ||
180 | |||
181 | \sa readBoolEntry() | ||
182 | */ | ||
183 | void Config::writeEntry( const QString &key, bool b ) | ||
184 | { | ||
185 | QString s; | ||
186 | s.setNum( ( int )b ); | ||
187 | writeEntry( key, s ); | ||
188 | } | ||
189 | #endif | ||
190 | |||
191 | /*! | ||
192 | Writes a (\a key, \a lst) entry to the current group. The list | ||
193 | is separated by \a sep, so the strings must not contain that character. | ||
194 | |||
195 | \sa readListEntry() | ||
196 | */ | ||
197 | void Config::writeEntry( const QString &key, const QStringList &lst, const QChar &sep ) | ||
198 | { | ||
199 | QString s; | ||
200 | QStringList::ConstIterator it = lst.begin(); | ||
201 | for ( ; it != lst.end(); ++it ) | ||
202 | s += *it + sep; | ||
203 | writeEntry( key, s ); | ||
204 | } | ||
205 | |||
206 | |||
207 | |||
208 | /*! | ||
209 | Reads a string entry stored with \a key, defaulting to \a deflt if there is no entry. | ||
210 | */ | ||
211 | QString Config::readEntry( const QString &key, const QString &deflt ) | ||
212 | { | ||
213 | QString res = readEntryDirect( key+"["+lang+"]" ); | ||
214 | if ( !res.isNull() ) | ||
215 | return res; | ||
216 | if ( !glang.isEmpty() ) { | ||
217 | res = readEntryDirect( key+"["+glang+"]" ); | ||
218 | if ( !res.isNull() ) | ||
219 | return res; | ||
220 | } | ||
221 | return readEntryDirect( key, deflt ); | ||
222 | } | ||
223 | |||
224 | /*! | ||
225 | \internal | ||
226 | */ | ||
227 | QString Config::readEntryDirect( const QString &key, const QString &deflt ) | ||
228 | { | ||
229 | if ( git == groups.end() ) { | ||
230 | //qWarning( "no group set" ); | ||
231 | return deflt; | ||
232 | } | ||
233 | ConfigGroup::Iterator it = ( *git ).find( key ); | ||
234 | if ( it != ( *git ).end() ) | ||
235 | return *it; | ||
236 | else | ||
237 | return deflt; | ||
238 | } | ||
239 | |||
240 | /*! | ||
241 | Reads a numeric entry stored with \a key, defaulting to \a deflt if there is no entry. | ||
242 | */ | ||
243 | int Config::readNumEntry( const QString &key, int deflt ) | ||
244 | { | ||
245 | QString s = readEntry( key ); | ||
246 | if ( s.isEmpty() ) | ||
247 | return deflt; | ||
248 | else | ||
249 | return s.toInt(); | ||
250 | } | ||
251 | |||
252 | /*! | ||
253 | Reads a bool entry stored with \a key, defaulting to \a deflt if there is no entry. | ||
254 | */ | ||
255 | bool Config::readBoolEntry( const QString &key, bool deflt ) | ||
256 | { | ||
257 | QString s = readEntry( key ); | ||
258 | if ( s.isEmpty() ) | ||
259 | return deflt; | ||
260 | else | ||
261 | return (bool)s.toInt(); | ||
262 | } | ||
263 | |||
264 | /*! | ||
265 | Reads a string list entry stored with \a key, and with \a sep as the separator. | ||
266 | */ | ||
267 | QStringList Config::readListEntry( const QString &key, const QChar &sep ) | ||
268 | { | ||
269 | QString s = readEntry( key ); | ||
270 | if ( s.isEmpty() ) | ||
271 | return QStringList(); | ||
272 | else | ||
273 | return QStringList::split( sep, s ); | ||
274 | } | ||
275 | |||
276 | /*! | ||
277 | Removes all entries from the current group. | ||
278 | */ | ||
279 | void Config::clearGroup() | ||
280 | { | ||
281 | if ( git == groups.end() ) { | ||
282 | qWarning( "no group set" ); | ||
283 | return; | ||
284 | } | ||
285 | if ( !(*git).isEmpty() ) { | ||
286 | ( *git ).clear(); | ||
287 | changed = TRUE; | ||
288 | } | ||
289 | } | ||
290 | |||
291 | /*! | ||
292 | \internal | ||
293 | */ | ||
294 | void Config::write( const QString &fn ) | ||
295 | { | ||
296 | if ( !fn.isEmpty() ) | ||
297 | filename = fn; | ||
298 | |||
299 | QFile f( filename ); | ||
300 | if ( !f.open( IO_WriteOnly ) ) { | ||
301 | qWarning( "could not open for writing `%s'", filename.latin1() ); | ||
302 | git = groups.end(); | ||
303 | return; | ||
304 | } | ||
305 | |||
306 | QTextStream s( &f ); | ||
307 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | ||
308 | // The below should work, but doesn't in Qt 2.3.0 | ||
309 | s.setCodec( QTextCodec::codecForMib( 106 ) ); | ||
310 | #else | ||
311 | s.setEncoding( QTextStream::UnicodeUTF8 ); | ||
312 | #endif | ||
313 | QMap< QString, ConfigGroup >::Iterator g_it = groups.begin(); | ||
314 | for ( ; g_it != groups.end(); ++g_it ) { | ||
315 | s << "[" << g_it.key() << "]" << "\n"; | ||
316 | ConfigGroup::Iterator e_it = ( *g_it ).begin(); | ||
317 | for ( ; e_it != ( *g_it ).end(); ++e_it ) | ||
318 | s << e_it.key() << " = " << *e_it << "\n"; | ||
319 | } | ||
320 | |||
321 | f.close(); | ||
322 | } | ||
323 | |||
324 | /*! | ||
325 | Returns whether the Config is in a valid state. | ||
326 | */ | ||
327 | bool Config::isValid() const | ||
328 | { | ||
329 | return groups.end() != git; | ||
330 | } | ||
331 | |||
332 | /*! | ||
333 | \internal | ||
334 | */ | ||
335 | void Config::read() | ||
336 | { | ||
337 | changed = FALSE; | ||
338 | |||
339 | if ( !QFileInfo( filename ).exists() ) { | ||
340 | git = groups.end(); | ||
341 | return; | ||
342 | } | ||
343 | |||
344 | QFile f( filename ); | ||
345 | if ( !f.open( IO_ReadOnly ) ) { | ||
346 | git = groups.end(); | ||
347 | return; | ||
348 | } | ||
349 | |||
350 | QTextStream s( &f ); | ||
351 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | ||
352 | // The below should work, but doesn't in Qt 2.3.0 | ||
353 | s.setCodec( QTextCodec::codecForMib( 106 ) ); | ||
354 | #else | ||
355 | s.setEncoding( QTextStream::UnicodeUTF8 ); | ||
356 | #endif | ||
357 | |||
358 | QString line; | ||
359 | while ( !s.atEnd() ) { | ||
360 | line = s.readLine(); | ||
361 | if ( !parse( line ) ) { | ||
362 | git = groups.end(); | ||
363 | return; | ||
364 | } | ||
365 | } | ||
366 | |||
367 | f.close(); | ||
368 | } | ||
369 | |||
370 | /*! | ||
371 | \internal | ||
372 | */ | ||
373 | bool Config::parse( const QString &l ) | ||
374 | { | ||
375 | QString line = l.stripWhiteSpace(); | ||
376 | if ( line[ 0 ] == QChar( '[' ) ) { | ||
377 | QString gname = line; | ||
378 | gname = gname.remove( 0, 1 ); | ||
379 | if ( gname[ (int)gname.length() - 1 ] == QChar( ']' ) ) | ||
380 | gname = gname.remove( gname.length() - 1, 1 ); | ||
381 | ConfigGroup *grp = new ConfigGroup; | ||
382 | git = groups.insert( gname, *grp ); | ||
383 | } else if ( !line.isEmpty() ) { | ||
384 | if ( git == groups.end() ) | ||
385 | return FALSE; | ||
386 | int eq = line.find( '=' ); | ||
387 | if ( eq == -1 ) | ||
388 | return FALSE; | ||
389 | QString key = line.left(eq).stripWhiteSpace(); | ||
390 | QString value = line.mid(eq+1).stripWhiteSpace(); | ||
391 | ( *git ).insert( key, value ); | ||
392 | } | ||
393 | return TRUE; | ||
394 | } | ||
diff --git a/noncore/games/kpacman/config.h b/noncore/games/kpacman/config.h deleted file mode 100644 index 3c26b5d..0000000 --- a/noncore/games/kpacman/config.h +++ b/dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qt Designer. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef CONFIG_H | ||
22 | #define CONFIG_H | ||
23 | |||
24 | // ##### could use QSettings with Qt 3.0 | ||
25 | |||
26 | #include <qmap.h> | ||
27 | #include <qstringlist.h> | ||
28 | |||
29 | class ConfigPrivate; | ||
30 | class Config | ||
31 | { | ||
32 | public: | ||
33 | typedef QMap< QString, QString > ConfigGroup; | ||
34 | |||
35 | enum Domain { File, User }; | ||
36 | Config( const QString &name, Domain domain=User ); | ||
37 | ~Config(); | ||
38 | |||
39 | bool isValid() const; | ||
40 | bool hasKey( const QString &key ) const; | ||
41 | |||
42 | void setGroup( const QString &gname ); | ||
43 | void writeEntry( const QString &key, const QString &value ); | ||
44 | void writeEntry( const QString &key, int num ); | ||
45 | #ifdef Q_HAS_BOOL_TYPE | ||
46 | void writeEntry( const QString &key, bool b ); | ||
47 | #endif | ||
48 | void writeEntry( const QString &key, const QStringList &lst, const QChar &sep ); | ||
49 | |||
50 | QString readEntry( const QString &key, const QString &deflt = QString::null ); | ||
51 | QString readEntryDirect( const QString &key, const QString &deflt = QString::null ); | ||
52 | int readNumEntry( const QString &key, int deflt = -1 ); | ||
53 | bool readBoolEntry( const QString &key, bool deflt = FALSE ); | ||
54 | QStringList readListEntry( const QString &key, const QChar &sep ); | ||
55 | |||
56 | void clearGroup(); | ||
57 | |||
58 | void write( const QString &fn = QString::null ); | ||
59 | |||
60 | protected: | ||
61 | void read(); | ||
62 | bool parse( const QString &line ); | ||
63 | |||
64 | QMap< QString, ConfigGroup > groups; | ||
65 | QMap< QString, ConfigGroup >::Iterator git; | ||
66 | QString filename; | ||
67 | QString lang; | ||
68 | QString glang; | ||
69 | bool changed; | ||
70 | ConfigPrivate *d; | ||
71 | static QString configFilename(const QString& name, Domain); | ||
72 | }; | ||
73 | |||
74 | #endif | ||
diff --git a/noncore/games/kpacman/keys.cpp b/noncore/games/kpacman/keys.cpp index 8b17785..07ce135 100644 --- a/noncore/games/kpacman/keys.cpp +++ b/noncore/games/kpacman/keys.cpp | |||
@@ -10,13 +10,13 @@ | |||
10 | 10 | ||
11 | #include <keys.h> | 11 | #include <keys.h> |
12 | #include <keys.moc> | 12 | #include <keys.moc> |
13 | #elif defined( QPE_PORT ) | 13 | #elif defined( QPE_PORT ) |
14 | #include <qaccel.h> | 14 | #include <qaccel.h> |
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | #include "config.h" | 16 | #include <qpe/config.h> |
17 | #include "keys.h" | 17 | #include "keys.h" |
18 | #endif | 18 | #endif |
19 | 19 | ||
20 | #include <qpushbt.h> | 20 | #include <qpushbt.h> |
21 | #include <qlabel.h> | 21 | #include <qlabel.h> |
22 | #include <qframe.h> | 22 | #include <qframe.h> |
@@ -190,14 +190,16 @@ void Keys::init() | |||
190 | labels[3]->setText(right); | 190 | labels[3]->setText(right); |
191 | APP_CONFIG_END( cfg ); | 191 | APP_CONFIG_END( cfg ); |
192 | } | 192 | } |
193 | 193 | ||
194 | void Keys::ok() | 194 | void Keys::ok() |
195 | { | 195 | { |
196 | /* | ||
196 | APP_CONFIG_BEGIN( cfg ); | 197 | APP_CONFIG_BEGIN( cfg ); |
197 | cfg->writeEntry("upKey", (const char*) labels[0]->text() ); | 198 | cfg->writeEntry("upKey", (const char*) labels[0]->text() ); |
198 | cfg->writeEntry("downKey", (const char*) labels[1]->text() ); | 199 | cfg->writeEntry("downKey", (const char*) labels[1]->text() ); |
199 | cfg->writeEntry("leftKey", (const char*) labels[2]->text() ); | 200 | cfg->writeEntry("leftKey", (const char*) labels[2]->text() ); |
200 | cfg->writeEntry("rightKey",(const char*) labels[3]->text() ); | 201 | cfg->writeEntry("rightKey",(const char*) labels[3]->text() ); |
201 | APP_CONFIG_END( cfg ); | 202 | APP_CONFIG_END( cfg ); |
203 | */ | ||
202 | accept(); | 204 | accept(); |
203 | } | 205 | } |
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp index aee8eea..812e9ea 100644 --- a/noncore/games/kpacman/kpacman.cpp +++ b/noncore/games/kpacman/kpacman.cpp | |||
@@ -4,13 +4,13 @@ | |||
4 | #if defined( KDE2_PORT ) | 4 | #if defined( KDE2_PORT ) |
5 | #include <kpacman.h> | 5 | #include <kpacman.h> |
6 | #include <kpacman.moc> | 6 | #include <kpacman.moc> |
7 | #include <kcolordlg.h> | 7 | #include <kcolordlg.h> |
8 | #elif defined( QPE_PORT ) | 8 | #elif defined( QPE_PORT ) |
9 | #include <qmenubar.h> | 9 | #include <qmenubar.h> |
10 | #include "config.h" | 10 | #include <qpe/config.h> |
11 | #include <qapplication.h> | 11 | #include <qapplication.h> |
12 | #include "kpacman.h" | 12 | #include "kpacman.h" |
13 | #endif | 13 | #endif |
14 | 14 | ||
15 | #include <qkeycode.h> | 15 | #include <qkeycode.h> |
16 | #include <qcolor.h> | 16 | #include <qcolor.h> |
@@ -67,17 +67,18 @@ Kpacman::Kpacman(QWidget *parent, const char *name) | |||
67 | 67 | ||
68 | setCentralWidget( m_view ); | 68 | setCentralWidget( m_view ); |
69 | } | 69 | } |
70 | 70 | ||
71 | Kpacman::~Kpacman() | 71 | Kpacman::~Kpacman() |
72 | { | 72 | { |
73 | APP_CONFIG_BEGIN( cfg ); | 73 | /* APP_CONFIG_BEGIN( cfg ); |
74 | cfg->writeEntry("FocusOutPause", focusOutPause); | 74 | cfg->writeEntry("FocusOutPause", focusOutPause); |
75 | cfg->writeEntry("FocusInContinue", focusInContinue); | 75 | cfg->writeEntry("FocusInContinue", focusInContinue); |
76 | cfg->writeEntry("HideMouseCursor", hideMouseCursor); | 76 | cfg->writeEntry("HideMouseCursor", hideMouseCursor); |
77 | APP_CONFIG_END( cfg ); | 77 | APP_CONFIG_END( cfg ); |
78 | */ | ||
78 | delete _menuBar; | 79 | delete _menuBar; |
79 | } | 80 | } |
80 | 81 | ||
81 | void Kpacman::menu() | 82 | void Kpacman::menu() |
82 | { | 83 | { |
83 | gamePopup = new QPopupMenu(); | 84 | gamePopup = new QPopupMenu(); |
@@ -140,24 +141,26 @@ void Kpacman::menu() | |||
140 | #endif | 141 | #endif |
141 | } | 142 | } |
142 | 143 | ||
143 | int Kpacman::lookupSchemes() | 144 | int Kpacman::lookupSchemes() |
144 | { | 145 | { |
145 | APP_CONFIG_BEGIN( cfg ); | 146 | APP_CONFIG_BEGIN( cfg ); |
146 | int ModeCount = cfg->readNumEntry("ModeCount", -1); | 147 | int ModeCount = cfg->readNumEntry("ModeCount", 0); |
147 | int Mode = cfg->readNumEntry("Mode", -1); | 148 | int Mode = cfg->readNumEntry("Mode", 0); |
148 | int SchemeCount = cfg->readNumEntry("SchemeCount"); | 149 | int SchemeCount = cfg->readNumEntry("SchemeCount", 0); |
149 | int Scheme = cfg->readNumEntry("Scheme", -1); | 150 | int Scheme = cfg->readNumEntry("Scheme", 0); |
150 | 151 | ||
152 | /* | ||
151 | if (SchemeCount == 0 || Scheme == -1) { | 153 | if (SchemeCount == 0 || Scheme == -1) { |
152 | QMessageBox::warning(this, tr("Configuration Error"), | 154 | QMessageBox::warning(this, tr("Configuration Error"), |
153 | tr("There are no schemes defined,\n" | 155 | tr("There are no schemes defined,\n" |
154 | "or no scheme is selected.")); | 156 | "or no scheme is selected.")); |
155 | APP_CONFIG_END( cfg ); | 157 | APP_CONFIG_END( cfg ); |
156 | return 0; | 158 | return 0; |
157 | } | 159 | } |
160 | */ | ||
158 | 161 | ||
159 | connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); | 162 | connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int))); |
160 | modeID.resize(ModeCount > 0 ? ModeCount : 0); | 163 | modeID.resize(ModeCount > 0 ? ModeCount : 0); |
161 | 164 | ||
162 | if (!schemesPopup->isEmpty()) | 165 | if (!schemesPopup->isEmpty()) |
163 | schemesPopup->clear(); | 166 | schemesPopup->clear(); |
@@ -346,17 +349,18 @@ void Kpacman::schemeChecked(int id) | |||
346 | modesPopup->setItemChecked(schemeID[s], schemeID[s] == id); | 349 | modesPopup->setItemChecked(schemeID[s], schemeID[s] == id); |
347 | } else { | 350 | } else { |
348 | modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode); | 351 | modesPopup->setItemChecked(modeID[schemeMode[s]], schemeMode[s] == mode); |
349 | schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id); | 352 | schemesPopup->at(schemeMode[s])->setItemChecked(schemeID[s], schemeID[s] == id); |
350 | } | 353 | } |
351 | } | 354 | } |
352 | 355 | /* | |
353 | APP_CONFIG_BEGIN( cfg ); | 356 | APP_CONFIG_BEGIN( cfg ); |
354 | cfg->writeEntry("Scheme", scheme); | 357 | cfg->writeEntry("Scheme", scheme); |
355 | cfg->writeEntry("Mode", mode); | 358 | cfg->writeEntry("Mode", mode); |
356 | APP_CONFIG_END( cfg ); | 359 | APP_CONFIG_END( cfg ); |
360 | */ | ||
357 | 361 | ||
358 | view->setScheme(scheme, mode); | 362 | view->setScheme(scheme, mode); |
359 | view->updateGeometry(); | 363 | view->updateGeometry(); |
360 | updateGeometry(); | 364 | updateGeometry(); |
361 | update(); | 365 | update(); |
362 | repaint(TRUE); | 366 | repaint(TRUE); |
diff --git a/noncore/games/kpacman/kpacman.pro b/noncore/games/kpacman/kpacman.pro index e193ebc..81d369a 100644 --- a/noncore/games/kpacman/kpacman.pro +++ b/noncore/games/kpacman/kpacman.pro | |||
@@ -14,13 +14,12 @@ HEADERS = kpacmanwidget.h \ | |||
14 | energizer.h \ | 14 | energizer.h \ |
15 | board.h \ | 15 | board.h \ |
16 | bitfont.h \ | 16 | bitfont.h \ |
17 | kpacman.h \ | 17 | kpacman.h \ |
18 | bitmaps.h \ | 18 | bitmaps.h \ |
19 | colors.h \ | 19 | colors.h \ |
20 | config.h \ | ||
21 | portable.h | 20 | portable.h |
22 | SOURCES = kpacmanwidget.cpp \ | 21 | SOURCES = kpacmanwidget.cpp \ |
23 | referee.cpp \ | 22 | referee.cpp \ |
24 | status.cpp \ | 23 | status.cpp \ |
25 | painter.cpp \ | 24 | painter.cpp \ |
26 | score.cpp \ | 25 | score.cpp \ |
@@ -29,13 +28,12 @@ SOURCES = kpacmanwidget.cpp \ | |||
29 | keys.cpp \ | 28 | keys.cpp \ |
30 | fruit.cpp \ | 29 | fruit.cpp \ |
31 | energizer.cpp \ | 30 | energizer.cpp \ |
32 | board.cpp \ | 31 | board.cpp \ |
33 | bitfont.cpp \ | 32 | bitfont.cpp \ |
34 | kpacman.cpp \ | 33 | kpacman.cpp \ |
35 | config.cpp \ | ||
36 | main.cpp | 34 | main.cpp |
37 | INCLUDEPATH+= $(OPIEDIR)/include | 35 | INCLUDEPATH+= $(OPIEDIR)/include |
38 | DEPENDPATH+= $(OPIEDIR)/include | 36 | DEPENDPATH+= $(OPIEDIR)/include |
39 | LIBS += -lqpe | 37 | LIBS += -lqpe |
40 | DESTDIR = $(OPIEDIR)/bin | 38 | DESTDIR = $(OPIEDIR)/bin |
41 | TARGET = kpacman | 39 | TARGET = kpacman |
diff --git a/noncore/games/kpacman/kpacmanwidget.cpp b/noncore/games/kpacman/kpacmanwidget.cpp index cf2aed9..823d2bf 100644 --- a/noncore/games/kpacman/kpacmanwidget.cpp +++ b/noncore/games/kpacman/kpacmanwidget.cpp | |||
@@ -6,13 +6,13 @@ | |||
6 | #include <kconfig.h> | 6 | #include <kconfig.h> |
7 | #include <kstddirs.h> | 7 | #include <kstddirs.h> |
8 | #include <kpacmanwidget.h> | 8 | #include <kpacmanwidget.h> |
9 | #include <kpacmanwidget.moc> | 9 | #include <kpacmanwidget.moc> |
10 | #elif defined( QPE_PORT ) | 10 | #elif defined( QPE_PORT ) |
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | #include "config.h" | 12 | #include <qpe/config.h> |
13 | #include "kpacmanwidget.h" | 13 | #include "kpacmanwidget.h" |
14 | #endif | 14 | #endif |
15 | 15 | ||
16 | #include <qmessagebox.h> | 16 | #include <qmessagebox.h> |
17 | 17 | ||
18 | #include "bitfont.h" | 18 | #include "bitfont.h" |
diff --git a/noncore/games/kpacman/painter.cpp b/noncore/games/kpacman/painter.cpp index 80aeab0..d8c7460 100644 --- a/noncore/games/kpacman/painter.cpp +++ b/noncore/games/kpacman/painter.cpp | |||
@@ -4,13 +4,13 @@ | |||
4 | #if defined( KDE2_PORT ) | 4 | #if defined( KDE2_PORT ) |
5 | #include <kapp.h> | 5 | #include <kapp.h> |
6 | #include <kconfig.h> | 6 | #include <kconfig.h> |
7 | #include <kstddirs.h> | 7 | #include <kstddirs.h> |
8 | #elif defined( QPE_PORT ) | 8 | #elif defined( QPE_PORT ) |
9 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
10 | #include "config.h" | 10 | #include <qpe/config.h> |
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | #include <qcolor.h> | 13 | #include <qcolor.h> |
14 | #include <qpainter.h> | 14 | #include <qpainter.h> |
15 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
16 | #include <qbitmap.h> | 16 | #include <qbitmap.h> |
diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp index 6d8f3fb..1b810d8 100644 --- a/noncore/games/kpacman/referee.cpp +++ b/noncore/games/kpacman/referee.cpp | |||
@@ -8,13 +8,13 @@ | |||
8 | #include <kaccel.h> | 8 | #include <kaccel.h> |
9 | #include <referee.h> | 9 | #include <referee.h> |
10 | #include <referee.moc> | 10 | #include <referee.moc> |
11 | #elif defined( QPE_PORT ) | 11 | #elif defined( QPE_PORT ) |
12 | #include <qaccel.h> | 12 | #include <qaccel.h> |
13 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
14 | #include "config.h" | 14 | #include <qpe/config.h> |
15 | #include "referee.h" | 15 | #include "referee.h" |
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | #include <qdatetm.h> | 18 | #include <qdatetm.h> |
19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
20 | #include <qtimer.h> | 20 | #include <qtimer.h> |
diff --git a/noncore/games/kpacman/status.cpp b/noncore/games/kpacman/status.cpp index 1ef910d..2a17c21 100644 --- a/noncore/games/kpacman/status.cpp +++ b/noncore/games/kpacman/status.cpp | |||
@@ -6,13 +6,13 @@ | |||
6 | #include <klocale.h> | 6 | #include <klocale.h> |
7 | #include <kstddirs.h> | 7 | #include <kstddirs.h> |
8 | #include <status.h> | 8 | #include <status.h> |
9 | #include <status.moc> | 9 | #include <status.moc> |
10 | #elif defined( QPE_PORT ) | 10 | #elif defined( QPE_PORT ) |
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | #include "config.h" | 12 | #include <qpe/config.h> |
13 | #include "status.h" | 13 | #include "status.h" |
14 | #endif | 14 | #endif |
15 | 15 | ||
16 | #include <qpixmap.h> | 16 | #include <qpixmap.h> |
17 | #include <qbitmap.h> | 17 | #include <qbitmap.h> |
18 | #include <qstring.h> | 18 | #include <qstring.h> |
@@ -244,13 +244,13 @@ void Status::confMisc(bool defGroup) | |||
244 | 244 | ||
245 | if (defGroup || cfg->hasKey("LifesPixmapName")) | 245 | if (defGroup || cfg->hasKey("LifesPixmapName")) |
246 | fillStrList(lifesPixmapName, | 246 | fillStrList(lifesPixmapName, |
247 | cfg->readEntry("LifesPixmapName", "lifes.xpm"), maxLevel+1); | 247 | cfg->readEntry("LifesPixmapName", "lifes.xpm"), maxLevel+1); |
248 | if (defGroup || cfg->hasKey("LevelPixmapName")) | 248 | if (defGroup || cfg->hasKey("LevelPixmapName")) |
249 | fillStrList(levelPixmapName, | 249 | fillStrList(levelPixmapName, |
250 | cfg->readEntry("LevelPixmapName", "level.xpm"), maxLevel+1); | 250 | cfg->readEntry("LevelPixmapName", "fruit.xpm"), maxLevel+1); |
251 | APP_CONFIG_END( cfg ); | 251 | APP_CONFIG_END( cfg ); |
252 | } | 252 | } |
253 | 253 | ||
254 | void Status::confScheme() | 254 | void Status::confScheme() |
255 | { | 255 | { |
256 | APP_CONFIG_BEGIN( cfg ); | 256 | APP_CONFIG_BEGIN( cfg ); |