• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

Public Types | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Static Protected Member Functions | List of all members
KCardDialog Class Reference

#include <kcarddialog.h>

Inherits KDialogBase.

Public Types

enum  CardFlags { Both =0, NoDeck =0x01, NoCards =0x02 }
 

Public Member Functions

 KCardDialog (TQWidget *parent=NULL, const char *name=NULL, CardFlags flags=Both)
 
 ~KCardDialog ()
 
void showRandomDeckBox (bool s)
 
void showRandomCardDirBox (bool s)
 
const TQString & deck () const
 
void setDeck (const TQString &file)
 
const TQString & cardDir () const
 
void setCardDir (const TQString &dir)
 
CardFlags flags () const
 
void setupDialog (bool showResizeBox=false)
 
bool isRandomDeck () const
 
bool isRandomCardDir () const
 
bool isGlobalDeck () const
 
bool isGlobalCardDir () const
 
double cardScale () const
 
void loadConfig (TDEConfig *conf)
 
void saveConfig (TDEConfig *conf)
 

Static Public Member Functions

static int getCardDeck (TQString &deck, TQString &carddir, TQWidget *parent=0, CardFlags flags=Both, bool *randomDeck=0, bool *randomCardDir=0, double *scale=0, TDEConfig *conf=0)
 
static void getConfigCardDeck (TDEConfig *conf, TQString &deck, TQString &cardDir, double &scale)
 
static TQString getDefaultDeck ()
 
static TQString getDefaultCardDir ()
 
static TQString getCardPath (const TQString &carddir, int index)
 
static TQString getRandomDeck ()
 
static TQString getRandomCardDir ()
 

Protected Slots

void slotDeckClicked (TQIconViewItem *)
 
void slotCardClicked (TQIconViewItem *)
 
void slotRandomCardDirToggled (bool on)
 
void slotRandomDeckToggled (bool on)
 
void slotCardResized (int)
 
void slotDefaultSize ()
 
void slotSetGlobalDeck ()
 
void slotSetGlobalCardDir ()
 

Protected Member Functions

void insertCardIcons ()
 
void insertDeckIcons ()
 

Static Protected Member Functions

static void getGlobalDeck (TQString &cardDir, bool &random)
 
static void getGlobalCardDir (TQString &deck, bool &random)
 
static TQString getDeckName (const TQString &desktop)
 
static TQString group ()
 

Detailed Description

A carddeck selection dialog for card games.

The KCardDialog provides a dialog for interactive carddeck selection. It gives cardgames an easy to use interface to select front and back of the card sets. As card sets the KDE default cardsets are offered as well as used specified ones.

In most cases, the simplest use of this class is the static method KCardDialog::getCardDeck, which pops up the dialog, allows the user to select a carddeck, and returns when the dialog is closed. Only if you really need some specific behaviour or if you overwrite the dialog you need all the other access functions.

Example:

TQString deck,card;
int result = KCardDialog::getCardDeck(deck,card );
if ( result == KCardDialog::Accepted )
...

Here you can see a card dialog in action

kcarddialog.png
KCarddialog

KCardDialog::getCardDeck takes a lot of different parameters which are probably very useful. You can e.g. use the parameters randomDeck and randomCardDir to give the end-user the ability to choose a random deck/carddir. You have to save the value of those parameters in your config file - that's why the parameters are needed.

You can also provide a TDEConfig pointer (usually kapp->config()). This pointer is used to store information about the dialog in an own group ("KCardDailog"). So you can just ignore the randomCardDir and randomDeck values and call KCardDialog::getConfigCardDeck instead. The only reson for this function is to read a previously written configuration and give you the information about it. This way you don't have to save any configuration on your own - KCardDialog does this for you.

Another Parameter for KCardDialog::getCardDeck is scale. This pointer to a double variable contains the scaling factor the user has chosen in the dialog (the scale box won't be shown if you don't provide this parameter). You might want to check out TQPixmap::xFrom which gives you access to scaling. You can e.g. use

TQWMatrix m;
m.scale(s,s);
pixmap.xForm(m);

to scale your pixmap.

Author
Martin Heni marti.nosp@m.n@he.nosp@m.ni-on.nosp@m.line.nosp@m..de
Version
$Id$

Definition at line 90 of file kcarddialog.h.

Member Enumeration Documentation

◆ CardFlags

enum KCardDialog::CardFlags
  • Both - both are shown
  • NoDeck - The deck (back) selection is not shown
  • NoCards - The cards (front) selection is not shown

Definition at line 102 of file kcarddialog.h.

Constructor & Destructor Documentation

◆ KCardDialog()

KCardDialog::KCardDialog ( TQWidget *  parent = NULL,
const char *  name = NULL,
CardFlags  flags = Both 
)

Constructs a card deck selection dialog.

Parameters
parentThe parent widget of the dialog, if any.
nameThe name of the dialog.
flagsSpecifies whether the dialog is modal or not.

Definition at line 531 of file kcarddialog.cpp.

◆ ~KCardDialog()

KCardDialog::~KCardDialog ( )

Destructs a card deck selection dialog.

Definition at line 524 of file kcarddialog.cpp.

Member Function Documentation

◆ cardDir()

const TQString & KCardDialog::cardDir ( ) const
Returns
The chosen card directory

Definition at line 249 of file kcarddialog.cpp.

◆ cardScale()

double KCardDialog::cardScale ( ) const
Returns
The scaling factor of the card pixmap

Definition at line 252 of file kcarddialog.cpp.

◆ deck()

const TQString & KCardDialog::deck ( ) const

Returns the chosen deck, which is a valid path to a imagefile.

Returns
The deck

Definition at line 247 of file kcarddialog.cpp.

◆ flags()

KCardDialog::CardFlags KCardDialog::flags ( ) const
Returns
the flags set to the dialog

Definition at line 251 of file kcarddialog.cpp.

◆ getCardDeck()

int KCardDialog::getCardDeck ( TQString &  deck,
TQString &  carddir,
TQWidget *  parent = 0,
CardFlags  flags = Both,
bool *  randomDeck = 0,
bool *  randomCardDir = 0,
double *  scale = 0,
TDEConfig *  conf = 0 
)
static

Creates a modal carddeck dialog, lets the user choose a deck, and returns when the dialog is closed.

Parameters
decka reference to the filename used as backside of the cards. It is an absolute path and can directly be loaded as pixmap.
carddira reference to the directory name used as front of the cards. The directory contains the card images as 1.png to 52.png
parentan optional pointer to the parent window of the dialog
flagswhat to show
randomDeckif this pointer is non-zero, *ok is set to true if the user wants a random deck otherwise to false. Use this in the config file of your game to load a random deck on startup. See getRandomDeck()
randomCardDirif this pointer is non-zero, *ok is set to true if the user wants a random card otherwise to false. Use this in the config file of your game to load a random card foregrounds on startup. See getRandomCardDir()
scaleIf non-zero a box is shown which provides the possibility to change the size of the cards. The desired scaling factor is returned to the game in this variable.
confIf non-zero KCardDialog reads the initial settings for this dialog from the applications config file and stores them there when the dialog is closed. You can just use getConfigCardDeck to get the deck/carddir the user selected before. Note that the parameters randomDeck and randomCardDir overwrite the initial settings from the config file.
Returns
TQDialog::result().

Definition at line 112 of file kcarddialog.cpp.

◆ getCardPath()

TQString KCardDialog::getCardPath ( const TQString &  carddir,
int  index 
)
static

Returns the path to the card frontside specified in dir carddir.

Parameters
indexthe card to open
carddirThe carddir which's path shall be searched for
Returns
returns the path to the card

Definition at line 232 of file kcarddialog.cpp.

◆ getConfigCardDeck()

void KCardDialog::getConfigCardDeck ( TDEConfig *  conf,
TQString &  deck,
TQString &  cardDir,
double &  scale 
)
static

Read the configuration from the applications rc file and put the previously chosen deck/frontside in the parameter deck and carddir.

You probably want to use this function on startup of your program so that the user gets exactly the card/frontside he/she chose before. Note that you don't have to care whether the user wants to get a random carddeck or not as this function takes care of this.

Parameters
confThe config file to read from
deckThis will contain the chosen deck from the config file (or a random deck if this is desired according to the config)
cardDirThis will contain the chosen cardDir from the config file (or a random cardDir if this is desired according to the config)
scaleThe scaling factor (usually 1)

Definition at line 179 of file kcarddialog.cpp.

◆ getDefaultCardDir()

TQString KCardDialog::getDefaultCardDir ( )
static

Returns the default path to the card frontsides.

You want to use this usually before the user used the card dialog the first time to get an default deck. You can assume that

getCardPath(getDefaultCardPath(), *)

are valid cards for * from 1 to 52.

Returns
returns the path to the card directory

Definition at line 224 of file kcarddialog.cpp.

◆ getDefaultDeck()

TQString KCardDialog::getDefaultDeck ( )
static

Returns the default path to the card deck backsides.

You want to use this usually before the user used the card dialog the first time to get a default deck. You can assume that

getDefaultDeckPath()

is a valid deck.

Returns
The default path

Definition at line 218 of file kcarddialog.cpp.

◆ getRandomCardDir()

TQString KCardDialog::getRandomCardDir ( )
static

Returns a random directory of cards.

Returns
A random card dir

Definition at line 586 of file kcarddialog.cpp.

◆ getRandomDeck()

TQString KCardDialog::getRandomDeck ( )
static

Returns a random deck in deckPath()

Returns
A random deck

Definition at line 574 of file kcarddialog.cpp.

◆ group()

static TQString KCardDialog::group ( )
staticprotected
Returns
the groupname used by functions like saveConfig and loadConfig.

◆ isGlobalCardDir()

bool KCardDialog::isGlobalCardDir ( ) const
Returns
true if the global checkbox was selected

Definition at line 259 of file kcarddialog.cpp.

◆ isGlobalDeck()

bool KCardDialog::isGlobalDeck ( ) const
Returns
true if the global checkbox was selected

Definition at line 257 of file kcarddialog.cpp.

◆ isRandomCardDir()

bool KCardDialog::isRandomCardDir ( ) const
Returns
true if the selected carddir is a random dir (i.e. the user checked the random checkbox) otherwise false

Definition at line 255 of file kcarddialog.cpp.

◆ isRandomDeck()

bool KCardDialog::isRandomDeck ( ) const
Returns
true if the selected deck is a random deck (i.e. the user checked the random checkbox) otherwise false

Definition at line 253 of file kcarddialog.cpp.

◆ loadConfig()

void KCardDialog::loadConfig ( TDEConfig *  conf)

Load the default settings into the dialog (e.g.

whether the "use random deck" checkbox is checked or not).

Definition at line 646 of file kcarddialog.cpp.

◆ saveConfig()

void KCardDialog::saveConfig ( TDEConfig *  conf)

Saves the KCardDialog config into a config file.

This should be the applications config file - KCardDialog creates an own group ("KCardDialog"). These settings are used by loadConfig and getConfigCardDeck.

Definition at line 720 of file kcarddialog.cpp.

◆ setCardDir()

void KCardDialog::setCardDir ( const TQString &  dir)

Sets the default card directory.

Parameters
dirThe full path to an card directory

Definition at line 250 of file kcarddialog.cpp.

◆ setDeck()

void KCardDialog::setDeck ( const TQString &  file)

Sets the default deck.

Parameters
fileThe full path to an image file

Definition at line 248 of file kcarddialog.cpp.

◆ setupDialog()

void KCardDialog::setupDialog ( bool  showResizeBox = false)

Creates the default widgets in the dialog.

Must be called after all flags are set. This is only needed if you do NOT use the getCardDeck static function which provides all calls for you.

Definition at line 262 of file kcarddialog.cpp.

◆ showRandomCardDirBox()

void KCardDialog::showRandomCardDirBox ( bool  s)

Show or hides the "random foreside" checkbox.

Parameters
sShows the checkbox if true otherwise hides it

Definition at line 610 of file kcarddialog.cpp.

◆ showRandomDeckBox()

void KCardDialog::showRandomDeckBox ( bool  s)

Show or hides the "random backside" checkbox.

Parameters
sShows the checkbox if true otherwise hides it

Definition at line 599 of file kcarddialog.cpp.


The documentation for this class was generated from the following files:
  • kcarddialog.h
  • kcarddialog.cpp

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.8.13
This website is maintained by Timothy Pearson.