summaryrefslogtreecommitdiff
path: root/noncore/games/fifteen
Unidiff
Diffstat (limited to 'noncore/games/fifteen') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/fifteen/fifteen.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/noncore/games/fifteen/fifteen.cpp b/noncore/games/fifteen/fifteen.cpp
index bb57ee1..c41c0a4 100644
--- a/noncore/games/fifteen/fifteen.cpp
+++ b/noncore/games/fifteen/fifteen.cpp
@@ -2,110 +2,102 @@
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "fifteen.h" 21#include "fifteen.h"
22 22
23#include "fifteenconfigdialog.h" 23#include "fifteenconfigdialog.h"
24 24
25#include <opie2/ofileselector.h> 25#include <opie2/ofileselector.h>
26#include <opie2/oresource.h>
26 27
27#include <qtopia/resource.h>
28#include <qtopia/config.h> 28#include <qtopia/config.h>
29#include <qtopia/qpeapplication.h> 29#include <qtopia/qpeapplication.h>
30 30
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qaction.h> 32#include <qaction.h>
33#include <qpainter.h> 33#include <qpainter.h>
34#include <qmessagebox.h> 34#include <qmessagebox.h>
35#include <qtoolbar.h> 35#include <qtoolbar.h>
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qimage.h> 37#include <qimage.h>
38 38
39#include <stdlib.h> 39#include <stdlib.h>
40#include <time.h> 40#include <time.h>
41 41
42FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name, WFlags fl) 42FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name, WFlags fl)
43 : QMainWindow( parent, name, fl ) 43 : QMainWindow( parent, name, fl )
44{ 44{
45 45
46 // random seed 46 // random seed
47 srand(time(0)); 47 srand(time(0));
48 setCaption( tr("Fifteen Pieces") ); 48 setCaption( tr("Fifteen Pieces") );
49 49
50 QToolBar *toolbar = new QToolBar(this); 50 QToolBar *toolbar = new QToolBar(this);
51 toolbar->setHorizontalStretchable( FALSE ); 51 toolbar->setHorizontalStretchable( FALSE );
52 QMenuBar *menubar = new QMenuBar( toolbar ); 52 QMenuBar *menubar = new QMenuBar( toolbar );
53 menubar->setMargin(0); 53 menubar->setMargin(0);
54 QPopupMenu *game = new QPopupMenu( this ); 54 QPopupMenu *game = new QPopupMenu( this );
55 menubar->insertItem( tr( "Game" ), game );
55 56
56 QWidget *spacer = new QWidget( toolbar ); 57 QWidget *spacer = new QWidget( toolbar );
57 spacer->setBackgroundMode( PaletteButton ); 58 spacer->setBackgroundMode( PaletteButton );
58 toolbar->setStretchableWidget( spacer ); 59 toolbar->setStretchableWidget( spacer );
59 60
60 61
61 setToolBarsMovable( FALSE ); 62 setToolBarsMovable( FALSE );
62 QVBox *vbox = new QVBox( this ); 63 QVBox *vbox = new QVBox( this );
63 PiecesTable *table = new PiecesTable( vbox ); 64 PiecesTable *table = new PiecesTable( vbox );
64 setCentralWidget(vbox); 65 setCentralWidget(vbox);
65 66
66 67
67 68
68 QAction *a = new QAction( tr( "Randomize" ), Resource::loadPixmap( "new" ), 69 QAction *a = new QAction( tr( "Randomize" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
69 QString::null, 0, this, 0 ); 70 QString::null, 0, this, 0 );
70 connect( a, SIGNAL( activated() ), table, SLOT( slotRandomize() ) ); 71 connect( a, SIGNAL( activated() ), table, SLOT( slotRandomize() ) );
71 a->addTo( game ); 72 a->addTo( game );
72 a->addTo( toolbar ); 73 a->addTo( toolbar );
73 74
74 75
75 a = new QAction( tr("Configure"), Resource::loadPixmap( "SettingsIcon" ), 76 a = new QAction( tr("Configure"), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ),
76 QString::null, 0, this, 0 ); 77 QString::null, 0, this, 0 );
77 connect( a, SIGNAL( activated()), table, SLOT( slotConfigure()) ); 78 connect( a, SIGNAL( activated()), table, SLOT( slotConfigure()) );
78 a->addTo( game ); 79 a->addTo( game );
79
80 /* This is pointless and confusing.
81 a = new QAction( tr( "Solve" ), Resource::loadIconSet( "repeat" ),
82 QString::null, 0, this, 0 );
83 connect( a, SIGNAL( activated() ), table, SLOT( slotReset() ) );
84 a->addTo( game );
85 a->addTo( toolbar );
86 */
87 menubar->insertItem( tr( "Game" ), game );
88} 80}
89 81
90 82
91 83
92 84
93/////////////// 85///////////////
94/////// Pieces table Implementation 86/////// Pieces table Implementation
95/////// 87///////
96PiecesTable::PiecesTable(QWidget* parent, const char* name ) 88PiecesTable::PiecesTable(QWidget* parent, const char* name )
97 : QTableView(parent, name), _menu(0), _randomized(false), 89 : QTableView(parent, name), _menu(0), _randomized(false),
98 _dialog( 0l ) 90 _dialog( 0l )
99{ 91{
100 // setup table view 92 // setup table view
101 setFrameStyle(StyledPanel | Sunken); 93 setFrameStyle(StyledPanel | Sunken);
102 setBackgroundMode(NoBackground); 94 setBackgroundMode(NoBackground);
103 setMouseTracking(true); 95 setMouseTracking(true);
104 96
105 setNumRows(4); 97 setNumRows(4);
106 setNumCols(4); 98 setNumCols(4);
107 99
108 // init arrays 100 // init arrays
109 readConfig(); 101 readConfig();
110 initColors(); 102 initColors();
111 103