#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:
Here you can see a card dialog in action

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
to scale your pixmap.
- Version
- $Id$
Definition at line 90 of file kcarddialog.h.
Member Enumeration Documentation
◆ CardFlags
Both
- both are shownNoDeck
- The deck (back) selection is not shownNoCards
- 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
-
parent The parent widget of the dialog, if any. name The name of the dialog. flags Specifies 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()
|
static |
Creates a modal carddeck dialog, lets the user choose a deck, and returns when the dialog is closed.
- Parameters
-
deck a reference to the filename used as backside of the cards. It is an absolute path and can directly be loaded as pixmap. carddir a reference to the directory name used as front of the cards. The directory contains the card images as 1.png to 52.png parent an optional pointer to the parent window of the dialog flags what to show randomDeck if 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() randomCardDir if 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() scale If 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. conf If 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()
|
static |
Returns the path to the card frontside specified in dir carddir.
- Parameters
-
index the card to open carddir The carddir which's path shall be searched for
- Returns
- returns the path to the card
Definition at line 232 of file kcarddialog.cpp.
◆ getConfigCardDeck()
|
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
-
conf The config file to read from deck This will contain the chosen deck from the config file (or a random deck if this is desired according to the config) cardDir This will contain the chosen cardDir from the config file (or a random cardDir if this is desired according to the config) scale The scaling factor (usually 1)
Definition at line 179 of file kcarddialog.cpp.
◆ getDeckName()
|
staticprotected |
Definition at line 562 of file kcarddialog.cpp.
◆ 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
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()
|
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
is a valid deck.
- Returns
- The default path
Definition at line 218 of file kcarddialog.cpp.
◆ getGlobalCardDir()
|
staticprotected |
Definition at line 781 of file kcarddialog.cpp.
◆ getGlobalDeck()
|
staticprotected |
Definition at line 765 of file kcarddialog.cpp.
◆ getRandomCardDir()
|
static |
Returns a random directory of cards.
- Returns
- A random card dir
Definition at line 586 of file kcarddialog.cpp.
◆ getRandomDeck()
|
static |
Returns a random deck in deckPath()
- Returns
- A random deck
Definition at line 574 of file kcarddialog.cpp.
◆ group()
|
staticprotected |
- Returns
- the groupname used by functions like saveConfig and loadConfig.
◆ insertCardIcons()
|
protected |
Definition at line 453 of file kcarddialog.cpp.
◆ insertDeckIcons()
|
protected |
Definition at line 489 of file kcarddialog.cpp.
◆ 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
-
dir The 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
-
file The 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
-
s Shows 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
-
s Shows the checkbox if true otherwise hides it
Definition at line 599 of file kcarddialog.cpp.
◆ slotCardClicked
|
protectedslot |
Definition at line 550 of file kcarddialog.cpp.
◆ slotCardResized
|
protectedslot |
Definition at line 691 of file kcarddialog.cpp.
◆ slotDeckClicked
|
protectedslot |
Definition at line 540 of file kcarddialog.cpp.
◆ slotDefaultSize
|
protectedslot |
Definition at line 712 of file kcarddialog.cpp.
◆ slotRandomCardDirToggled
|
protectedslot |
Definition at line 632 of file kcarddialog.cpp.
◆ slotRandomDeckToggled
|
protectedslot |
Definition at line 621 of file kcarddialog.cpp.
◆ slotSetGlobalCardDir
|
protectedslot |
Definition at line 754 of file kcarddialog.cpp.
◆ slotSetGlobalDeck
|
protectedslot |
Definition at line 743 of file kcarddialog.cpp.
The documentation for this class was generated from the following files: