The app is now fullscreen
[ghostsoverboard] / mainwindow.cpp
1 /**************************************************************************
2         Ghosts Overboard - a game for Maemo 5
3
4         Copyright (C) 2011  Heli Hyvättinen
5
6         This file is part of Ghosts Overboard
7
8         Ghosts Overboard is free software: you can redistribute it and/or modify
9         it under the terms of the GNU General Public License as published by
10         the Free Software Foundation, either version 2 of the License, or
11         (at your option) any later version.
12
13         This program is distributed in the hope that it will be useful,
14         but WITHOUT ANY WARRANTY; without even the implied warranty of
15         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16         GNU General Public License for more details.
17
18         You should have received a copy of the GNU General Public License
19         along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21 **************************************************************************/
22
23 #include "mainwindow.h"
24 #include <QPixmap>
25 #include <QTimer>
26 #include <QDebug>
27 #include <QAction>
28 #include <QMenuBar>
29 #include <QMessageBox>
30 #include <QApplication>
31 #include <QLabel>
32 #include <QPushButton>
33 #include <QVBoxLayout>
34
35
36
37 MainWindow::MainWindow(QWidget *parent)
38     : QMainWindow(parent)
39 {
40     setWindowIcon(QIcon(":/pix/laiva_3aave.png"));
41     setWindowTitle("Ghosts Overboard");
42
43     pScene_ = new SeaScene ();
44     connect(pScene_,SIGNAL(allGhostsPicked()),pScene_,SLOT(nextLevel()));
45
46     pView_  = new SeaView ();
47
48
49     pView_->setScene(pScene_);
50     setCentralWidget(pView_);
51
52     connect(pView_,SIGNAL(screenTapped()),pScene_,SLOT(handleScreenTapped()));
53     connect(pView_,SIGNAL(goingBackgroung()),pScene_,SLOT(forcePause()));
54     connect(pView_,SIGNAL(goingForeground()),pScene_,SLOT(softContinue()));
55
56     showFullScreen();
57
58
59
60     //the boundaries of the scene are set to match the size of the view window, which is not
61     //available in the constructor --> timer needed
62     QTimer::singleShot(100,this,SLOT(initializeBoundaries()));
63
64
65 }
66
67 MainWindow::~MainWindow()
68 {
69
70 }
71
72 void MainWindow::initializeBoundaries()
73 {
74         //the boundaries of the scene are set to match the size of the view window, and
75         //the view is set to show exactly the whole scene area
76
77     //this occasionally gives a tiny scene, so using a fixed size fit for N900/Maemo5 until a fix is found
78
79 //    QPoint topleft (0,0);
80 //    QSize windowsize = pView_->size();
81 //    QRectF rectangle (topleft,windowsize);
82
83     QRectF rectangle(0,0,800,480);
84
85     pScene_->setSceneRect(rectangle);
86     pView_->setSceneRect(rectangle);
87
88 //     qDebug() << "Initialized boundaries" << rectangle.right() << rectangle.bottom() << pView_->width() << pView_->height();
89
90     pScene_->restartLevel();
91 }
92