Diffstat (limited to 'noncore/games/solitaire/canvascardwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/solitaire/canvascardwindow.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp index dec5591..c12344a 100644 --- a/noncore/games/solitaire/canvascardwindow.cpp +++ b/noncore/games/solitaire/canvascardwindow.cpp | |||
@@ -32,25 +32,26 @@ | |||
32 | #include <qstyle.h> | 32 | #include <qstyle.h> |
33 | 33 | ||
34 | 34 | ||
35 | CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : | 35 | CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : |
36 | QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), | 36 | QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), |
37 | cardGame(NULL) | 37 | cardGame(NULL) |
38 | { | 38 | { |
39 | setIcon( Resource::loadPixmap( "cards" ) ); | 39 | setIcon( Resource::loadPixmap( "cards" ) ); |
40 | setCaption(tr("Patience")); | ||
40 | 41 | ||
41 | // Create Playing Area for Games | 42 | // Create Playing Area for Games |
42 | if ( QPixmap::defaultDepth() < 12 ) { | 43 | if ( QPixmap::defaultDepth() < 12 ) { |
43 | // canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); | 44 | // canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); |
44 | // canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); | 45 | // canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); |
45 | canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); | 46 | canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); |
46 | } else { | 47 | } else { |
47 | QPixmap bg; | 48 | QPixmap bg; |
48 | bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); | 49 | bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); |
49 | canvas.setBackgroundPixmap(bg); | 50 | canvas.setBackgroundPixmap(bg); |
50 | } | 51 | } |
51 | 52 | ||
52 | #if defined( QT_QWS_CASSIOPEIA ) | 53 | #if defined( QT_QWS_CASSIOPEIA ) |
53 | canvas.setAdvancePeriod(70); | 54 | canvas.setAdvancePeriod(70); |
54 | #else | 55 | #else |
55 | canvas.setAdvancePeriod(30); | 56 | canvas.setAdvancePeriod(30); |
56 | #endif | 57 | #endif |
@@ -61,17 +62,17 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
61 | 62 | ||
62 | QPopupMenu* file = new QPopupMenu; | 63 | QPopupMenu* file = new QPopupMenu; |
63 | file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); | 64 | file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); |
64 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); | 65 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); |
65 | file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); | 66 | file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); |
66 | file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); | 67 | file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); |
67 | file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); | 68 | file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); |
68 | menu->insertItem(tr("&Game"), file); | 69 | menu->insertItem(tr("&Game"), file); |
69 | 70 | ||
70 | menu->insertSeparator(); | 71 | menu->insertSeparator(); |
71 | 72 | ||
72 | settings = new QPopupMenu; | 73 | settings = new QPopupMenu; |
73 | settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2); | 74 | settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2); |
74 | snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3); | 75 | snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3); |
75 | settings->setCheckable(TRUE); | 76 | settings->setCheckable(TRUE); |
76 | menu->insertItem(tr("&Settings"),settings); | 77 | menu->insertItem(tr("&Settings"),settings); |
77 | 78 | ||
@@ -86,17 +87,17 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
86 | 87 | ||
87 | QPopupMenu* file = new QPopupMenu; | 88 | QPopupMenu* file = new QPopupMenu; |
88 | file->insertItem(tr("Patience"), this, SLOT(initPatience())); | 89 | file->insertItem(tr("Patience"), this, SLOT(initPatience())); |
89 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); | 90 | file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); |
90 | file->insertItem(tr("Chicane"), this, SLOT(initChicane())); | 91 | file->insertItem(tr("Chicane"), this, SLOT(initChicane())); |
91 | file->insertItem(tr("Harp"), this, SLOT(initHarp())); | 92 | file->insertItem(tr("Harp"), this, SLOT(initHarp())); |
92 | file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); | 93 | file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); |
93 | menu->insertItem(tr("Play"), file); | 94 | menu->insertItem(tr("Play"), file); |
94 | 95 | ||
95 | menu->insertSeparator(); | 96 | menu->insertSeparator(); |
96 | 97 | ||
97 | settings = new QPopupMenu; | 98 | settings = new QPopupMenu; |
98 | settings->setCheckable(TRUE); | 99 | settings->setCheckable(TRUE); |
99 | settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks())); | 100 | settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks())); |
100 | snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle())); | 101 | snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle())); |
101 | QString m; | 102 | QString m; |
102 | 103 | ||
@@ -113,17 +114,17 @@ CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) | |||
113 | snapOn = cfg.readBoolEntry( "SnapOn", TRUE); | 114 | snapOn = cfg.readBoolEntry( "SnapOn", TRUE); |
114 | settings->setItemChecked(snap_id, snapOn); | 115 | settings->setItemChecked(snap_id, snapOn); |
115 | 116 | ||
116 | gameType = cfg.readNumEntry( "GameType", -1 ); | 117 | gameType = cfg.readNumEntry( "GameType", -1 ); |
117 | drawThree = cfg.readBoolEntry( "DrawThree", FALSE); | 118 | drawThree = cfg.readBoolEntry( "DrawThree", FALSE); |
118 | if ( gameType == 0 ) { | 119 | if ( gameType == 0 ) { |
119 | cardGame = new PatienceCardGame( &canvas, snapOn, this ); | 120 | cardGame = new PatienceCardGame( &canvas, snapOn, this ); |
120 | cardGame->setNumberToDraw(drawThree ? 3 : 1); | 121 | cardGame->setNumberToDraw(drawThree ? 3 : 1); |
121 | 122 | ||
122 | setCaption(tr("Patience")); | 123 | setCaption(tr("Patience")); |
123 | setCentralWidget(cardGame); | 124 | setCentralWidget(cardGame); |
124 | cardGame->readConfig( cfg ); | 125 | cardGame->readConfig( cfg ); |
125 | setCardBacks(); | 126 | setCardBacks(); |
126 | } else if ( gameType == 1 ) { | 127 | } else if ( gameType == 1 ) { |
127 | cardGame = new FreecellCardGame( &canvas, snapOn, this ); | 128 | cardGame = new FreecellCardGame( &canvas, snapOn, this ); |
128 | setCaption(tr("Freecell")); | 129 | setCaption(tr("Freecell")); |
129 | setCentralWidget(cardGame); | 130 | setCentralWidget(cardGame); |
@@ -181,17 +182,17 @@ void CanvasCardWindow::resizeEvent(QResizeEvent *) | |||
181 | QSize s = centralWidget()->size(); | 182 | QSize s = centralWidget()->size(); |
182 | int fw = style().defaultFrameWidth(); | 183 | int fw = style().defaultFrameWidth(); |
183 | canvas.resize( s.width() - fw - 2, s.height() - fw - 2); | 184 | canvas.resize( s.width() - fw - 2, s.height() - fw - 2); |
184 | } | 185 | } |
185 | 186 | ||
186 | 187 | ||
187 | void CanvasCardWindow::initPatience() | 188 | void CanvasCardWindow::initPatience() |
188 | { | 189 | { |
189 | // Create New Game | 190 | // Create New Game |
190 | if ( cardGame ) | 191 | if ( cardGame ) |
191 | delete cardGame; | 192 | delete cardGame; |
192 | cardGame = new PatienceCardGame( &canvas, snapOn, this ); | 193 | cardGame = new PatienceCardGame( &canvas, snapOn, this ); |
193 | cardGame->setNumberToDraw(drawThree ? 3 : 1); | 194 | cardGame->setNumberToDraw(drawThree ? 3 : 1); |
194 | gameType = 0; | 195 | gameType = 0; |
195 | setCaption(tr("Patience")); | 196 | setCaption(tr("Patience")); |
196 | setCentralWidget(cardGame); | 197 | setCentralWidget(cardGame); |
197 | cardGame->newGame(); | 198 | cardGame->newGame(); |
@@ -248,23 +249,23 @@ void CanvasCardWindow::initHarp() | |||
248 | 249 | ||
249 | void CanvasCardWindow::initTeeclub() | 250 | void CanvasCardWindow::initTeeclub() |
250 | { | 251 | { |
251 | // Create New Game | 252 | // Create New Game |
252 | if ( cardGame ) { | 253 | if ( cardGame ) { |
253 | delete cardGame; | 254 | delete cardGame; |
254 | } | 255 | } |
255 | cardGame = new TeeclubCardGame( &canvas, snapOn, this ); | 256 | cardGame = new TeeclubCardGame( &canvas, snapOn, this ); |
256 | cardGame->setNumberToDraw(1); | 257 | cardGame->setNumberToDraw(1); |
257 | gameType = 4; | 258 | gameType = 4; |
258 | setCaption(tr("Teeclub")); | 259 | setCaption(tr("Teeclub")); |
259 | setCentralWidget(cardGame); | 260 | setCentralWidget(cardGame); |
260 | cardGame->newGame(); | 261 | cardGame->newGame(); |
261 | setCardBacks(); | 262 | setCardBacks(); |
262 | } | 263 | } |
263 | 264 | ||
264 | 265 | ||
265 | void CanvasCardWindow::snapToggle() | 266 | void CanvasCardWindow::snapToggle() |
266 | { | 267 | { |
267 | snapOn = !snapOn; | 268 | snapOn = !snapOn; |
268 | settings->setItemChecked(snap_id, snapOn); | 269 | settings->setItemChecked(snap_id, snapOn); |
269 | cardGame->toggleSnap(); | 270 | cardGame->toggleSnap(); |
270 | } | 271 | } |