KWin4App Class Reference

The base class for Kwin4 application. More...

#include <kwin4.h>

Collaboration diagram for KWin4App:

Collaboration graph
[legend]
List of all members.

Public Slots

void serverTypeChanged (int t)
 The server type was changed (KGame).
void remoteChanged (int who)
 The remote player changed (GUI signal).
void slotGameOver (int status, KPlayer *p, KGame *me)
 The game is over indication.
void moveDone (int playerNumber)
 A move has been performed.
void networkBroken (int id, int oldstatus, KGame *game)
 The network connection has been lost.
void gameRun ()
 Being noticed by KGAme that a new game started.
void updateStatusNames ()
 Update the names in the status bar.
void configureNetwork ()
 Show the network configuration dialog.
void configureChat ()
 Show the network chat dialog.
void debugKGame ()
 Show the debug a KGame dialog.
void menuNewGame ()
 The New game menu is selected.
void menuOpenGame ()
 The Load game menu is selected.
void menuSaveGame ()
 The Save game menu is selected.
void endGame ()
 Called when the game is to be ended, e.g.
void showStatistics ()
 Shows the statistics dialog.
void askForHint ()
 A game hint is asked via the menu.
void changeTheme (const QString &name)
 A new theme is selected from the menu.
void undoMove ()
 A move undo request is given via the menu.
void redoMove ()
 A move redo request is given via the menu.
void displayStatusbarMover (const QString &text)
 Display the current player to move in the statusbar.
void displayStatusMessage (const QString &text)
 Display a message in the status bar.
void configureSettings ()
 Show the settings dialog.

Public Member Functions

 KWin4App (QWidget *parent=0)
 Construct the application.
 ~KWin4App ()
 Destruct the application.

Protected Types

enum  CheckFlags { All = 0, CheckFileMenu = 1, CheckEditMenu = 2 }
 Flags which menus should be checked and set by below functions. More...

Protected Member Functions

void EndGame (TABLE mode)
 The game is ended.
void changeAction (const char *action, bool enable)
 Enable or disable an action depending on the boolean parameter.
void enableAction (const char *action)
 Enable oactions that is menu/toolbar items.
void disableAction (const char *action)
 Disable actions that is menu/toolbar items.
void checkMenus (CheckFlags menu=All)
 Checks all menues and depening on the game status enables or disables them.
void initGUI ()
 Setup all actions (menus and toolbar items).
void initStatusBar ()
 Setup the statusbar.
void initDocument ()
 Prepare the game engine (document) and connect its signals.
virtual void saveProperties (KConfigGroup &cfg)
 Save the properties of the application.
virtual void readProperties (const KConfigGroup &cfg)
 Read the properties of the application.

Detailed Description

The base class for Kwin4 application.

Definition at line 45 of file kwin4.h.


Member Enumeration Documentation

enum KWin4App::CheckFlags [protected]
 

Flags which menus should be checked and set by below functions.

Enumerator:
All 
CheckFileMenu 
CheckEditMenu 

Definition at line 69 of file kwin4.h.


Constructor & Destructor Documentation

KWin4App::KWin4App QWidget *  parent = 0  ) 
 

Construct the application.

Parameters:
parent The parent

Definition at line 68 of file kwin4.cpp.

References checkMenus(), initDocument(), initGUI(), KWin4Doc::initPlayers(), initStatusBar(), KWin4Doc::readConfig(), KWin4Doc::setView(), and SRC_DIR.

Here is the call graph for this function:

KWin4App::~KWin4App  ) 
 

Destruct the application.

Definition at line 112 of file kwin4.cpp.


Member Function Documentation

void KWin4App::askForHint  )  [slot]
 

A game hint is asked via the menu.

The game will give a movement tip.

Definition at line 380 of file kwin4.cpp.

References KWin4Doc::calculateHint().

Referenced by initGUI().

void KWin4App::changeAction const char *  action,
bool  enable
[protected]
 

Enable or disable an action depending on the boolean parameter.

Parameters:
action The action to affect
enable True if the action should be enabled, false otherwise.

Definition at line 293 of file kwin4.cpp.

Referenced by checkMenus(), disableAction(), and enableAction().

void KWin4App::changeTheme const QString &  name  )  [slot]
 

A new theme is selected from the menu.

Parameters:
name The theme name

Definition at line 254 of file kwin4.cpp.

References ThemeManager::updateTheme().

Referenced by initGUI().

void KWin4App::checkMenus CheckFlags  menu = All  )  [protected]
 

Checks all menues and depening on the game status enables or disables them.

This is usually done on program init.

Parameters:
menu Which menu to check, default all menus

Definition at line 128 of file kwin4.cpp.

References changeAction(), CheckEditMenu, CheckFileMenu, disableAction(), KWin4Doc::getCurrentMove(), and KWin4Doc::getHistoryCnt().

Referenced by EndGame(), gameRun(), KWin4App(), menuOpenGame(), moveDone(), redoMove(), slotGameOver(), and undoMove().

Here is the call graph for this function:

void KWin4App::configureChat  )  [slot]
 

Show the network chat dialog.

Definition at line 609 of file kwin4.cpp.

References KWin4Doc::getPlayer(), Red, ChatDlg::setPlayer(), and Yellow.

Referenced by initGUI().

void KWin4App::configureNetwork  )  [slot]
 

Show the network configuration dialog.

Definition at line 552 of file kwin4.cpp.

Referenced by initGUI().

void KWin4App::configureSettings  )  [slot]
 

Show the settings dialog.

Definition at line 639 of file kwin4.cpp.

References Prefs::self(), and Ui_Settings::setupUi().

Referenced by initGUI().

void KWin4App::debugKGame  )  [slot]
 

Show the debug a KGame dialog.

Definition at line 631 of file kwin4.cpp.

Referenced by initGUI().

void KWin4App::disableAction const char *  action  )  [inline, protected]
 

Disable actions that is menu/toolbar items.

Parameters:
action The action to affect

Definition at line 85 of file kwin4.h.

References changeAction().

Referenced by checkMenus().

Here is the call graph for this function:

void KWin4App::displayStatusbarMover const QString &  text  )  [slot]
 

Display the current player to move in the statusbar.

Parameters:
text The text to display

Definition at line 453 of file kwin4.cpp.

References ID_STATUS_MOVER.

Referenced by initStatusBar(), and updateStatusNames().

void KWin4App::displayStatusMessage const QString &  text  )  [slot]
 

Display a message in the status bar.

Parameters:
text The message to display

Definition at line 444 of file kwin4.cpp.

References ID_STATUS_MSG.

Referenced by initStatusBar(), menuNewGame(), moveDone(), and slotGameOver().

void KWin4App::enableAction const char *  action  )  [inline, protected]
 

Enable oactions that is menu/toolbar items.

Parameters:
action The action to affect

Definition at line 80 of file kwin4.h.

References changeAction().

Here is the call graph for this function:

void KWin4App::endGame  )  [slot]
 

Called when the game is to be ended, e.g.

via the abort game menu.

Definition at line 373 of file kwin4.cpp.

Referenced by initGUI().

void KWin4App::EndGame TABLE  mode  )  [protected]
 

The game is ended.

Either because it is finised or because it is aborted by the player.

Parameters:
mode Result of the game

Definition at line 462 of file kwin4.cpp.

References checkMenus(), KWin4Doc::endGame(), KWin4Doc::switchStartPlayer(), and updateStatusNames().

Referenced by slotGameOver().

Here is the call graph for this function:

void KWin4App::gameRun  )  [slot]
 

Being noticed by KGAme that a new game started.

Definition at line 365 of file kwin4.cpp.

References All, checkMenus(), and updateStatusNames().

Referenced by initDocument().

void KWin4App::initDocument  )  [protected]
 

Prepare the game engine (document) and connect its signals.

Definition at line 276 of file kwin4.cpp.

References gameRun(), moveDone(), networkBroken(), and slotGameOver().

Referenced by KWin4App().

void KWin4App::initGUI  )  [protected]
 

Setup all actions (menus and toolbar items).

Definition at line 179 of file kwin4.cpp.

References ACTION, askForHint(), changeTheme(), configureChat(), configureNetwork(), configureSettings(), debugKGame(), endGame(), global_debug, menuNewGame(), menuOpenGame(), menuSaveGame(), redoMove(), showStatistics(), and undoMove().

Referenced by KWin4App().

void KWin4App::initStatusBar  )  [protected]
 

Setup the statusbar.

Definition at line 264 of file kwin4.cpp.

References displayStatusbarMover(), displayStatusMessage(), ID_STATUS_MOVER, and ID_STATUS_MSG.

Referenced by KWin4App().

void KWin4App::menuNewGame  )  [slot]
 

The New game menu is selected.

Definition at line 351 of file kwin4.cpp.

References displayStatusMessage().

Referenced by initGUI().

void KWin4App::menuOpenGame  )  [slot]
 

The Load game menu is selected.

Definition at line 327 of file kwin4.cpp.

References checkMenus(), and global_debug.

Referenced by initGUI().

void KWin4App::menuSaveGame  )  [slot]
 

The Save game menu is selected.

Definition at line 339 of file kwin4.cpp.

References global_debug.

Referenced by initGUI().

void KWin4App::moveDone int  playerNumber  )  [slot]
 

A move has been performed.

Update the status etc.

Parameters:
playerNumber Number of the next player to move

Definition at line 512 of file kwin4.cpp.

References CheckEditMenu, checkMenus(), displayStatusMessage(), and updateStatusNames().

Referenced by initDocument().

void KWin4App::networkBroken int  id,
int  oldstatus,
KGame *  game
[slot]
 

The network connection has been lost.

Parameters:
id Game id
oldstatus Previous game status
game Our game

Definition at line 487 of file kwin4.cpp.

References KWin4Doc::getCurrentPlayer(), KWin4Doc::getPlayer(), KWin4Doc::playedBy(), Red, KWin4Doc::setPlayedBy(), and Yellow.

Referenced by initDocument().

void KWin4App::readProperties const KConfigGroup &  cfg  )  [protected, virtual]
 

Read the properties of the application.

Parameters:
cfg Load from this config group

Definition at line 316 of file kwin4.cpp.

void KWin4App::redoMove  )  [slot]
 

A move redo request is given via the menu.

Definition at line 430 of file kwin4.cpp.

References CheckEditMenu, checkMenus(), KWin4Doc::getCurrentPlayer(), KWin4Doc::playedBy(), KWin4Doc::redoMove(), and updateStatusNames().

Referenced by initGUI().

void KWin4App::remoteChanged int  who  )  [slot]
 

The remote player changed (GUI signal).

Parameters:
who The remote player is 0:y ellow, 1: red

Definition at line 593 of file kwin4.cpp.

References KWin4Doc::getPlayer(), Red, and Yellow.

void KWin4App::saveProperties KConfigGroup &  cfg  )  [protected, virtual]
 

Save the properties of the application.

Parameters:
cfg Save to this config group

Definition at line 309 of file kwin4.cpp.

void KWin4App::serverTypeChanged int  t  )  [slot]
 

The server type was changed (KGame).

Parameters:
t The server type

Definition at line 586 of file kwin4.cpp.

void KWin4App::showStatistics  )  [slot]
 

Shows the statistics dialog.

Definition at line 387 of file kwin4.cpp.

References KWin4Doc::getName(), KWin4Doc::getStatistic(), Ui_Statistics::p1_aborted, Ui_Statistics::p1_drawn, Ui_Statistics::p1_lost, Ui_Statistics::p1_name, Ui_Statistics::p1_sum, Ui_Statistics::p1_won, Ui_Statistics::p2_aborted, Ui_Statistics::p2_drawn, Ui_Statistics::p2_lost, Ui_Statistics::p2_name, Ui_Statistics::p2_sum, Ui_Statistics::p2_won, Red, KWin4Doc::resetStatistic(), Ui_Statistics::setupUi(), TBrk, TLost, TRemis, TSum, TWin, and Yellow.

Referenced by initGUI().

void KWin4App::slotGameOver int  status,
KPlayer *  p,
KGame *  me
[slot]
 

The game is over indication.

Parameters:
status -1: remis, 1: won/loss 2: abort
p The player who made the last move
me The game

Definition at line 520 of file kwin4.cpp.

References CheckEditMenu, checkMenus(), displayStatusMessage(), EndGame(), KWin4Doc::getName(), TBrk, TLost, TRemis, TWin, and Yellow.

Referenced by initDocument().

void KWin4App::undoMove  )  [slot]
 

A move undo request is given via the menu.

Definition at line 415 of file kwin4.cpp.

References CheckEditMenu, checkMenus(), KWin4Doc::getCurrentPlayer(), KWin4Doc::playedBy(), KWin4Doc::undoMove(), and updateStatusNames().

Referenced by initGUI().

void KWin4App::updateStatusNames  )  [slot]
 

Update the names in the status bar.

Definition at line 472 of file kwin4.cpp.

References displayStatusbarMover(), KWin4Doc::getCurrentPlayer(), KWin4Doc::getName(), Red, and Yellow.

Referenced by EndGame(), gameRun(), moveDone(), redoMove(), and undoMove().


The documentation for this class was generated from the following files:
Generated on Sun Mar 4 10:56:43 2007 for KWin4 by  doxygen 1.4.6