author | imm <imm> | 2002-09-21 12:24:59 (UTC) |
---|---|---|
committer | imm <imm> | 2002-09-21 12:24:59 (UTC) |
commit | 99d546ce72f40e28b04f09201d92d58294401591 (patch) (unidiff) | |
tree | 4589ba17c622a114efb4811334e0adce02cedeca | |
parent | 279f025b03efdade9c211dd9441eec0c2a91ad94 (diff) | |
download | opie-99d546ce72f40e28b04f09201d92d58294401591.zip opie-99d546ce72f40e28b04f09201d92d58294401591.tar.gz opie-99d546ce72f40e28b04f09201d92d58294401591.tar.bz2 |
center widget
-rw-r--r-- | noncore/games/kpacman/kpacman.cpp | 23 | ||||
-rw-r--r-- | noncore/games/kpacman/kpacman.h | 18 | ||||
-rw-r--r-- | noncore/games/kpacman/kpacmanwidget.cpp | 9 | ||||
-rw-r--r-- | noncore/games/kpacman/referee.cpp | 4 | ||||
-rw-r--r-- | noncore/games/kpacman/score.cpp | 61 |
5 files changed, 14 insertions, 101 deletions
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp index 7df6ef0..d9d2d69 100644 --- a/noncore/games/kpacman/kpacman.cpp +++ b/noncore/games/kpacman/kpacman.cpp | |||
@@ -25,15 +25,17 @@ Kpacman::Kpacman(QWidget *parent, const char *name) | |||
25 | schemesPopup->setAutoDelete(TRUE); | 25 | schemesPopup->setAutoDelete(TRUE); |
26 | 26 | ||
27 | menu(); | 27 | menu(); |
28 | 28 | ||
29 | view = new KpacmanWidget( this, QString(name)+"widget"); | 29 | m_view = new QWidget( this, "m_view" ); |
30 | m_view->setBackgroundColor( black ); | ||
31 | m_layout = new QGridLayout( m_view ); | ||
32 | m_layout->setMargin( 7 ); | ||
30 | 33 | ||
31 | #ifndef QWS | 34 | view = new KpacmanWidget( this, QString(name)+"widget"); |
32 | setFixedSize(view->width(), view->height()); | 35 | m_layout->addWidget( view, 0, 0 ); |
33 | #else | 36 | |
34 | setCaption( "Kpacman" ); | 37 | setCaption( "KPacman" ); |
35 | #endif | ||
36 | 38 | ||
37 | view->referee->setFocus(); | 39 | view->referee->setFocus(); |
38 | 40 | ||
39 | connect(view->referee, SIGNAL(setScore(int, int)), | 41 | connect(view->referee, SIGNAL(setScore(int, int)), |
@@ -62,16 +64,9 @@ Kpacman::Kpacman(QWidget *parent, const char *name) | |||
62 | toggleFocusOutPause(); | 64 | toggleFocusOutPause(); |
63 | toggleFocusInContinue(); | 65 | toggleFocusInContinue(); |
64 | toggleHideMouseCursor(); | 66 | toggleHideMouseCursor(); |
65 | 67 | ||
66 | #ifndef QWS | 68 | setCentralWidget( m_view ); |
67 | menuBar->show(); | ||
68 | view->show(); | ||
69 | setMenu(menuBar); | ||
70 | setView(view); | ||
71 | #else | ||
72 | setCentralWidget( view ); | ||
73 | #endif | ||
74 | } | 69 | } |
75 | 70 | ||
76 | Kpacman::~Kpacman() | 71 | Kpacman::~Kpacman() |
77 | { | 72 | { |
diff --git a/noncore/games/kpacman/kpacman.h b/noncore/games/kpacman/kpacman.h index d7de9de..2c1de70 100644 --- a/noncore/games/kpacman/kpacman.h +++ b/noncore/games/kpacman/kpacman.h | |||
@@ -6,38 +6,24 @@ | |||
6 | #endif | 6 | #endif |
7 | 7 | ||
8 | #include "portable.h" | 8 | #include "portable.h" |
9 | 9 | ||
10 | #if defined( KDE2_PORT ) | ||
11 | #include <kapp.h> | ||
12 | #include <klocale.h> | ||
13 | #include <ktmainwindow.h> | ||
14 | #include <kmenubar.h> | ||
15 | #elif defined( QPE_PORT ) | ||
16 | #include <qmainwindow.h> | 10 | #include <qmainwindow.h> |
17 | class QMenuBar; | 11 | class QMenuBar; |
18 | #endif | ||
19 | |||
20 | #include <qregexp.h> | 12 | #include <qregexp.h> |
21 | 13 | ||
22 | #include "kpacmanwidget.h" | 14 | #include "kpacmanwidget.h" |
23 | 15 | ||
24 | #include <qpopmenu.h> | 16 | #include <qpopmenu.h> |
25 | 17 | ||
26 | #include <qlist.h> | 18 | #include <qlist.h> |
27 | #include <qfileinf.h> | 19 | #include <qfileinf.h> |
20 | #include <qlayout.h> | ||
28 | 21 | ||
29 | #if defined( KDE2_PORT ) | ||
30 | #include <referee.h> | ||
31 | #include <status.h> | ||
32 | #include <score.h> | ||
33 | #include <keys.h> | ||
34 | #elif defined( QPE_PORT ) | ||
35 | #include "referee.h" | 22 | #include "referee.h" |
36 | #include "status.h" | 23 | #include "status.h" |
37 | #include "score.h" | 24 | #include "score.h" |
38 | #include "keys.h" | 25 | #include "keys.h" |
39 | #endif | ||
40 | 26 | ||
41 | class Kpacman : public KTMainWindow | 27 | class Kpacman : public KTMainWindow |
42 | { | 28 | { |
43 | Q_OBJECT | 29 | Q_OBJECT |
@@ -70,8 +56,10 @@ private: | |||
70 | void menu(); | 56 | void menu(); |
71 | 57 | ||
72 | int lookupSchemes(); | 58 | int lookupSchemes(); |
73 | 59 | ||
60 | QGridLayout *m_layout; | ||
61 | QWidget *m_view; | ||
74 | KMenuBar *_menuBar; | 62 | KMenuBar *_menuBar; |
75 | QPopupMenu *gamePopup; | 63 | QPopupMenu *gamePopup; |
76 | QPopupMenu *optionsPopup; | 64 | QPopupMenu *optionsPopup; |
77 | QPopupMenu *modesPopup; | 65 | QPopupMenu *modesPopup; |
diff --git a/noncore/games/kpacman/kpacmanwidget.cpp b/noncore/games/kpacman/kpacmanwidget.cpp index 215dcda..feb782c 100644 --- a/noncore/games/kpacman/kpacmanwidget.cpp +++ b/noncore/games/kpacman/kpacmanwidget.cpp | |||
@@ -32,13 +32,9 @@ KpacmanWidget::KpacmanWidget( QWidget *parent, const char *name) | |||
32 | score = new Score(this, name, scheme, mode, bitfont); | 32 | score = new Score(this, name, scheme, mode, bitfont); |
33 | referee = new Referee( this, name, scheme, mode, bitfont); | 33 | referee = new Referee( this, name, scheme, mode, bitfont); |
34 | status = new Status(this, name, scheme, mode); | 34 | status = new Status(this, name, scheme, mode); |
35 | 35 | ||
36 | #ifndef QWS | ||
37 | setFixedSize(referee->width(), bitfont->height()*3 + referee->height() + status->height()); | ||
38 | #else | ||
39 | setBackgroundColor( black ); | 36 | setBackgroundColor( black ); |
40 | #endif | ||
41 | } | 37 | } |
42 | 38 | ||
43 | KpacmanWidget::~KpacmanWidget() | 39 | KpacmanWidget::~KpacmanWidget() |
44 | { | 40 | { |
@@ -137,13 +133,8 @@ void KpacmanWidget::setScheme(int Scheme, int Mode) | |||
137 | score->setScheme(Scheme, Mode, bitfont); | 133 | score->setScheme(Scheme, Mode, bitfont); |
138 | referee->setScheme(Scheme, Mode, bitfont); | 134 | referee->setScheme(Scheme, Mode, bitfont); |
139 | status->setScheme(Scheme, Mode); | 135 | status->setScheme(Scheme, Mode); |
140 | 136 | ||
141 | #ifndef QWS | ||
142 | setFixedSize(referee->width(), | ||
143 | bitfont->height()*3 + referee->height() + status->height()); | ||
144 | #endif | ||
145 | |||
146 | score->repaint(FALSE); | 137 | score->repaint(FALSE); |
147 | referee->repaint(FALSE); | 138 | referee->repaint(FALSE); |
148 | status->repaint(FALSE); | 139 | status->repaint(FALSE); |
149 | } | 140 | } |
diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp index 70916f0..81f331b 100644 --- a/noncore/games/kpacman/referee.cpp +++ b/noncore/games/kpacman/referee.cpp | |||
@@ -730,12 +730,12 @@ void Referee::keyPressEvent( QKeyEvent *k ) | |||
730 | // "OK" => new game | 730 | // "OK" => new game |
731 | if ( key == Key_F33 || key == Key_F2 || key == Key_Enter ) | 731 | if ( key == Key_F33 || key == Key_F2 || key == Key_Enter ) |
732 | play(); | 732 | play(); |
733 | else if ( !gameState.testBit(Playing) && | 733 | else if ( !gameState.testBit(Playing) && |
734 | key == Key_Up || | 734 | ( key == Key_Up || |
735 | key == Key_Down || | 735 | key == Key_Down || |
736 | key == Key_Right || | 736 | key == Key_Right || |
737 | key == Key_Left ) | 737 | key == Key_Left )) |
738 | play(); | 738 | play(); |
739 | // "Space" => pause | 739 | // "Space" => pause |
740 | //else if ( key == Key_Space || key == Key_F3 ) | 740 | //else if ( key == Key_Space || key == Key_F3 ) |
741 | // pause(); | 741 | // pause(); |
diff --git a/noncore/games/kpacman/score.cpp b/noncore/games/kpacman/score.cpp index 17dbf0a..b3ff3d9 100644 --- a/noncore/games/kpacman/score.cpp +++ b/noncore/games/kpacman/score.cpp | |||
@@ -477,36 +477,8 @@ void Score::read() | |||
477 | } | 477 | } |
478 | 478 | ||
479 | void Score::write() | 479 | void Score::write() |
480 | { | 480 | { |
481 | #ifndef QWS | ||
482 | if (!highscoreFile.exists() && highscoreFile.name() == systemHighscoreFileInfo.filePath()) | ||
483 | KMessageBox::information(0, | ||
484 | tr("You're going to create the highscore-file\n" | ||
485 | "'%1'\n" | ||
486 | "for your maschine, that should be used systemwide.\n" | ||
487 | "\n" | ||
488 | "To grant access to the other users, set the appropriate rights (a+w)\n" | ||
489 | "on that file or ask your systemadministator for that favor.\n" | ||
490 | "\n" | ||
491 | "To use a different directory or filename for the highscores," | ||
492 | "specify them in the configfile (kpacmanrc:highscoreFilePath)." | ||
493 | ).arg(systemHighscoreFileInfo.filePath())); | ||
494 | |||
495 | if (highscoreFile.name() == privateHighscoreFileInfo.filePath()) | ||
496 | KMessageBox::information(0, | ||
497 | tr("You're using a private highscore-file, that's mostly because of\n" | ||
498 | "missing write-access to the systemwide file\n" | ||
499 | "'%1' .\n" | ||
500 | "\n" | ||
501 | "Ask your systemadministrator for granting you access to that file,\n" | ||
502 | "by setting the appropriate rights (a+w) on it.\n" | ||
503 | "\n" | ||
504 | "To use a different directory or filename for the highscores," | ||
505 | "specify them in the configfile (kpacmanrc:highscoreFilePath)." | ||
506 | ).arg(systemHighscoreFileInfo.filePath()), | ||
507 | QString::null, "PrivateHighscore"); | ||
508 | #endif | ||
509 | if (highscoreFile.open(IO_WriteOnly)) { | 481 | if (highscoreFile.open(IO_WriteOnly)) { |
510 | QDataStream s(&highscoreFile); | 482 | QDataStream s(&highscoreFile); |
511 | for (int i = 0; i < 10; i++) | 483 | for (int i = 0; i < 10; i++) |
512 | s << hallOfFame[i].points << hallOfFame[i].levels << hallOfFame[i].duration << | 484 | s << hallOfFame[i].points << hallOfFame[i].levels << hallOfFame[i].duration << |
@@ -604,39 +576,6 @@ int Score::y(float row) | |||
604 | * privaten Datei gearbeitet. | 576 | * privaten Datei gearbeitet. |
605 | */ | 577 | */ |
606 | QFileInfo Score::locateHighscoreFilePath() | 578 | QFileInfo Score::locateHighscoreFilePath() |
607 | { | 579 | { |
608 | #ifndef QWS | ||
609 | QFileInfo systemHighscoreDirPath; | ||
610 | QStringList systemHighscoreDirs; | ||
611 | |||
612 | // Schreibfähige "private" highscore-Datei ermitteln für den fallback. | ||
613 | privateHighscoreFileInfo.setFile(KGlobal::dirs()->saveLocation("appdata")+highscoreName); | ||
614 | |||
615 | // FilePath aus der Konfigurationsdatei benutzen | ||
616 | systemHighscoreFileInfo.setFile(cfg->readEntry("HighscoreFilePath")); | ||
617 | |||
618 | // Kein Wert aus der Konfiguration erhalten, dann die "system"-Datei suchen. | ||
619 | if (systemHighscoreFileInfo.filePath().isEmpty()) | ||
620 | systemHighscoreDirs = KGlobal::dirs()->resourceDirs("appdata"); | ||
621 | else | ||
622 | systemHighscoreDirs = QStringList(systemHighscoreFileInfo.filePath()); | ||
623 | |||
624 | for (QStringList::Iterator i = systemHighscoreDirs.begin(); i != systemHighscoreDirs.end(); ++i) { | ||
625 | |||
626 | systemHighscoreFileInfo.setFile(*i); | ||
627 | if (systemHighscoreFileInfo.fileName().isEmpty()) | ||
628 | systemHighscoreFileInfo.setFile(systemHighscoreFileInfo.dirPath()+"/"+highscoreName); | ||
629 | |||
630 | // privateHighscoreFileInfo für die "system" Suche ignorieren | ||
631 | if (systemHighscoreFileInfo.filePath() != privateHighscoreFileInfo.filePath()) | ||
632 | if (!systemHighscoreFileInfo.exists()) { | ||
633 | systemHighscoreDirPath.setFile(systemHighscoreFileInfo.dirPath()); | ||
634 | if (systemHighscoreDirPath.exists() && systemHighscoreDirPath.isWritable()) | ||
635 | return systemHighscoreFileInfo; | ||
636 | } else | ||
637 | if (systemHighscoreFileInfo.isWritable()) | ||
638 | return systemHighscoreFileInfo; | ||
639 | } | ||
640 | #endif | ||
641 | return privateHighscoreFileInfo; | 580 | return privateHighscoreFileInfo; |
642 | } | 581 | } |