Root/gottet/patches/001-qtopia.patch

1diff --git a/src/board.cpp b/src/board.cpp
2index 4b1888f..db17c0a 100644
3--- a/src/board.cpp
4+++ b/src/board.cpp
5@@ -54,10 +54,6 @@ Board::Board(QWidget* parent)
6     m_done(false),
7     m_paused(false)
8 {
9-#if !defined(QTOPIA_PHONE)
10- setMinimumSize(201, 401);
11- setFocusPolicy(Qt::StrongFocus);
12-#endif
13     setFocus();
14 
15     m_shift_timer = new QTimer(this);
16@@ -174,7 +170,7 @@ void Board::pauseGame()
17     }
18 
19     update();
20- emit showMessage(tr("<big><b>Paused</b></big><br>Click to resume playing."));
21+ emit showMessage(tr("<big><b>Paused</b></big><br>Press P to resume playing."));
22 
23     unsetCursor();
24     emit pauseAvailable(false);
25@@ -206,7 +202,20 @@ void Board::keyPressEvent(QKeyEvent* event)
26         return;
27 
28     switch (event->key()) {
29- case Qt::Key_Left:
30+ case Qt::Key_A:
31+ m_piece->moveLeft();
32+ break;
33+ case Qt::Key_S:
34+ m_piece->moveRight();
35+ break;
36+ case Qt::Key_K:
37+ m_piece->rotate();
38+ break;
39+ case Qt::Key_Space:
40+ m_piece->drop();
41+ landPiece();
42+ break;
43+ case Qt::Key_Left:
44         m_piece->moveLeft();
45         break;
46     case Qt::Key_Right:
47@@ -283,9 +292,9 @@ void Board::focusOutEvent(QFocusEvent*)
48 void Board::resizeEvent(QResizeEvent* event)
49 {
50     m_piece_size = qMin(event->size().width() / 10, event->size().height() / 20);
51- int w = m_piece_size * 10 + 1;
52- int h = m_piece_size * 20 + 1;
53- m_background = QRect((width() - w) / 2, (height() - h) / 2, w, h);
54+ int w = m_piece_size * 10 + 1;
55+ int h = m_piece_size * 20 + 1;
56+ m_background = QRect((width() - w) / 2, (height() - h) / 2, w, h);
57 
58     QPainter painter;
59 
60@@ -402,7 +411,7 @@ void Board::gameOver()
61     m_piece = 0;
62     m_done = true;
63     unsetCursor();
64- emit showMessage(tr("<big><b>Game Over!</b></big><br>Click to start a new game."));
65+ emit showMessage(tr("<big><b>Game Over!</b></big><br>Ctrl+N to start a new game."));
66     emit gameOver(m_level, m_removed_lines, m_score);
67 }
68 
69@@ -495,11 +504,7 @@ QPixmap Board::renderPiece(int type) const
70             painter.drawRoundRect(piece[i].x * 20, piece[i].y * 20, 19, 19);
71         }
72     }
73-
74-#if defined(QTOPIA_PHONE)
75     result = result.scaled(30,50, Qt::KeepAspectRatio);
76-#endif
77-
78     return result;
79 }
80 
81diff --git a/src/main.cpp b/src/main.cpp
82index bc3c73a..4d475ed 100644
83--- a/src/main.cpp
84+++ b/src/main.cpp
85@@ -19,15 +19,11 @@
86 
87 #include "window.h"
88 
89-#if defined(QTOPIA_PHONE)
90-#include <QtopiaApplication>
91-QTOPIA_ADD_APPLICATION(QTOPIA_TARGET,Window)
92-QTOPIA_MAIN
93-#else
94-
95 #include <QApplication>
96-#include <QLocale>
97-#include <QTranslator>
98+
99+#if defined(Q_WS_QWS)
100+#include <QtGui/QWSServer>
101+#endif
102 
103 int main(int argc, char** argv)
104 {
105@@ -35,18 +31,11 @@ int main(int argc, char** argv)
106     app.setApplicationName("Gottet");
107     app.setOrganizationDomain("gottcode.org");
108     app.setOrganizationName("GottCode");
109-
110- QTranslator qt_translator;
111- qt_translator.load("qt_" + QLocale::system().name());
112- app.installTranslator(&qt_translator);
113-
114- QTranslator gottet_translator;
115- gottet_translator.load("gottet_" + QLocale::system().name());
116- app.installTranslator(&gottet_translator);
117-
118+ #if defined(Q_WS_QWS)
119+ QWSServer::setCursorVisible(false);
120+ #endif
121     Window window;
122     window.show();
123 
124     return app.exec();
125 }
126-#endif
127diff --git a/src/window.cpp b/src/window.cpp
128index c691ae5..3af8c53 100644
129--- a/src/window.cpp
130+++ b/src/window.cpp
131@@ -30,16 +30,11 @@
132 #include <QGridLayout>
133 #include <QLabel>
134 #include <QMenu>
135+#include <QPushButton>
136 #include <QMessageBox>
137 #include <QPixmap>
138 #include <QSettings>
139 
140-#if defined(QTOPIA_PHONE)
141-#include <QSoftMenuBar>
142-#else
143-#include <QMenuBar>
144-#endif
145-
146 /*****************************************************************************/
147 
148 Window::Window(QWidget *parent, Qt::WindowFlags wf)
149@@ -53,11 +48,7 @@ Window::Window(QWidget *parent, Qt::WindowFlags wf)
150 
151     // Create preview
152     m_preview = new QLabel(contents);
153-#if !defined(QTOPIA_PHONE)
154- m_preview->setFixedSize(80, 100);
155-#else
156- m_preview->setFixedSize(30, 40);
157-#endif
158+ m_preview->setFixedSize(30, 40);
159     m_preview->setAutoFillBackground(true);
160     {
161         QPalette palette = m_preview->palette();
162@@ -99,7 +90,7 @@ Window::Window(QWidget *parent, Qt::WindowFlags wf)
163     connect(m_board, SIGNAL(gameStarted()), this, SLOT(newGame()));
164 
165     // Create overlay message
166- QLabel* message = new QLabel(tr("Click to start a new game."), contents);
167+ QLabel* message = new QLabel(tr("Ctrl+N to start a new game."), contents);
168     message->setAttribute(Qt::WA_TransparentForMouseEvents);
169     message->setAlignment(Qt::AlignCenter);
170     message->setStyleSheet(
171@@ -117,19 +108,7 @@ Window::Window(QWidget *parent, Qt::WindowFlags wf)
172     connect(m_board, SIGNAL(hideMessage()), message, SLOT(clear()));
173 
174     // Create menus
175-#if defined(QTOPIA_PHONE)
176- QMenu* menu = QSoftMenuBar::menuFor(this);
177- menu->addAction(tr("&About"), this, SLOT(about()));
178- menu->addSeparator();
179- menu->addAction(tr("&Scores"), m_score_board, SLOT(show()));
180- menu->addSeparator();
181- m_resume_action = menu->addAction(tr("&Resume"), m_board, SLOT(resumeGame()));
182- m_resume_action->setVisible(false);
183- m_pause_action = menu->addAction(tr("&Pause"), m_board, SLOT(pauseGame()));
184- m_pause_action->setEnabled(false);
185- QAction* action = menu->addAction(tr("&New Game"), m_board, SLOT(newGame()));
186- connect(action, SIGNAL(triggered(bool)), this, SLOT(newGame()));
187-#else
188+ /*
189     QMenu* menu = menuBar()->addMenu(tr("&Game"));
190     menu->addAction(tr("&New"), m_board, SLOT(newGame()), tr("Ctrl+N"));
191     m_pause_action = menu->addAction(tr("&Pause"), m_board, SLOT(pauseGame()), tr("P"));
192@@ -143,31 +122,56 @@ Window::Window(QWidget *parent, Qt::WindowFlags wf)
193     menu = menuBar()->addMenu(tr("&Help"));
194     menu->addAction(tr("&About"), this, SLOT(about()));
195     menu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
196-#endif
197+ */
198+ QPushButton* game_button = new QPushButton(this);
199+ QMenu* game_menu = new QMenu(this);
200+ game_menu->addAction(tr("&New"), m_board, SLOT(newGame()), tr("Ctrl+N"));
201+ m_pause_action = game_menu->addAction(tr("&Pause"), m_board, SLOT(pauseGame()), tr("P"));
202+ m_pause_action->setEnabled(false);
203+ m_resume_action = game_menu->addAction(tr("&Resume"), m_board, SLOT(resumeGame()), tr("P"));
204+ m_resume_action->setVisible(false);
205+ game_menu->addSeparator();
206+ game_menu->addAction(tr("&Scores"), m_score_board, SLOT(show()));
207+ game_menu->addSeparator();
208+ game_menu->addAction(tr("&Quit"), this, SLOT(close()), tr("Ctrl+Q"));
209+ game_button->setText(tr("&Game"));
210+ game_button->setMenu(game_menu);
211+ game_button->setFocusPolicy(Qt::NoFocus);
212+
213+ QPushButton* help_button = new QPushButton(this);
214+ QMenu* help_menu = new QMenu(this);
215+ help_menu->addAction(tr("&About"), this, SLOT(about()));
216+ help_menu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
217+ help_button->setText(tr("&Help"));
218+ help_button->setMenu(help_menu);
219+ help_button->setFocusPolicy(Qt::NoFocus);
220 
221     // Layout window
222     QGridLayout* layout = new QGridLayout(contents);
223- layout->setMargin(12);
224+ layout->setMargin(0);
225     layout->setSpacing(0);
226     layout->setColumnStretch(0, 1);
227- layout->setColumnMinimumWidth(1, 12);
228- layout->setRowStretch(11, 1);
229- layout->setRowMinimumHeight(2, 24);
230+ layout->setColumnMinimumWidth(1, 100);
231+ layout->setRowStretch(11, 1);
232+ layout->setRowMinimumHeight(2, 24);
233     layout->setRowMinimumHeight(5, 24);
234- layout->setRowMinimumHeight(8, 24);
235- layout->addWidget(m_board, 0, 0, 12, 1);
236- layout->addWidget(message, 0, 0, 12, 1, Qt::AlignCenter);
237- layout->addWidget(new QLabel(tr("Next Piece"), contents), 0, 2, 1, 1, Qt::AlignCenter);
238- layout->addWidget(m_preview, 1, 2, Qt::AlignCenter);
239- layout->addWidget(new QLabel(tr("Level"), contents), 3, 2, 1, 1, Qt::AlignCenter);
240- layout->addWidget(m_level, 4, 2);
241- layout->addWidget(new QLabel(tr("Removed Lines"), contents), 6, 2, 1, 1, Qt::AlignCenter);
242- layout->addWidget(m_lines, 7, 2);
243- layout->addWidget(new QLabel(tr("Score"), contents), 9, 2, 1, 1, Qt::AlignCenter);
244- layout->addWidget(m_score, 10, 2);
245+ layout->setRowMinimumHeight(8, 24);
246+ layout->addWidget(m_board, 0, 0, 12, 1);
247+ layout->addWidget(message, 0, 0, 12, 1, Qt::AlignCenter);
248+ layout->addWidget(new QLabel(tr("Next Piece"), contents), 0, 1, 1, 1, Qt::AlignCenter);
249+ layout->addWidget(m_preview, 1, 1, Qt::AlignCenter);
250+ layout->addWidget(new QLabel(tr("Level"), contents), 3, 2, 1, 1, Qt::AlignCenter);
251+ layout->addWidget(m_level, 4, 2);
252+ layout->addWidget(new QLabel(tr("Removed Lines"), contents), 6, 2, 1, 1, Qt::AlignCenter);
253+ layout->addWidget(m_lines, 7, 2);
254+ layout->addWidget(new QLabel(tr("Score"), contents), 9, 2, 1, 1, Qt::AlignCenter);
255+ layout->addWidget(m_score, 10, 2);
256+ layout->addWidget(game_button, 0, 2);
257+ layout->addWidget(help_button, 1, 2);
258 
259     // Restore window
260- restoreGeometry(QSettings().value("Geometry").toByteArray());
261+ //restoreGeometry(QSettings().value("Geometry").toByteArray());
262+ resize(320, 240);
263 }
264 
265 /*****************************************************************************/
266

Archive Download this file



interactive