KCardDialog Class Reference
A carddeck selection dialog for card games. More...
#include <kcarddialog.h>
Public Types | |
enum | CardFlags { Both = 0, NoDeck = 0x01, NoCards = 0x02 } |
Public Member Functions | |
KCardDialog (QWidget *parent=NULL, const char *name=NULL, CardFlags flags=Both) | |
~KCardDialog () | |
void | showRandomDeckBox (bool s) |
void | showRandomCardDirBox (bool s) |
const QString & | deck () const |
void | setDeck (const QString &file) |
const QString & | cardDir () const |
void | setCardDir (const QString &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 (KConfig *conf) |
void | saveConfig (KConfig *conf) |
Static Public Member Functions | |
static int | getCardDeck (QString &deck, QString &carddir, QWidget *parent=0, CardFlags flags=Both, bool *randomDeck=0, bool *randomCardDir=0, double *scale=0, KConfig *conf=0) |
static void | getConfigCardDeck (KConfig *conf, QString &deck, QString &cardDir, double &scale) |
static QString | getDefaultDeck () |
static QString | getDefaultCardDir () |
static QString | getCardPath (const QString &carddir, int index) |
static QString | getRandomDeck () |
static QString | getRandomCardDir () |
Protected Slots | |
void | slotDeckClicked (QIconViewItem *) |
void | slotCardClicked (QIconViewItem *) |
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 (QString &cardDir, bool &random) |
static void | getGlobalCardDir (QString &deck, bool &random) |
static QString | getDeckName (const QString &desktop) |
static QString | 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:
QString deck,card; int result = KCardDialog::getCardDeck(deck,card ); if ( result == KCardDialog::Accepted ) ...
Here you can see a card dialog in action

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 KConfig 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 QPixmap::xFrom which gives you access to scaling. You can e.g. use
QWMatrix m; m.scale(s,s); pixmap.xForm(m);
- Author:
- Martin Heni <martin@heni-online.de>
- Version:
- Id
- kcarddialog.h,v 1.16 2005/01/11 12:51:21 mlaurent Exp
Definition at line 90 of file kcarddialog.h.
Member Enumeration Documentation
|
Definition at line 101 of file kcarddialog.h. |
Constructor & Destructor Documentation
|
Constructs a card deck selection dialog.
Definition at line 531 of file kcarddialog.cpp. |
|
Destructs a card deck selection dialog.
Definition at line 524 of file kcarddialog.cpp. |
Member Function Documentation
|
Creates a modal carddeck dialog, lets the user choose a deck, and returns when the dialog is closed.
Definition at line 112 of file kcarddialog.cpp. References cardDir(), cardScale(), deck(), isGlobalCardDir(), isGlobalDeck(), isRandomCardDir(), isRandomDeck(), loadConfig(), saveConfig(), setCardDir(), setDeck(), setupDialog(), showRandomCardDirBox(), and showRandomDeckBox(). |
|
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.
Definition at line 179 of file kcarddialog.cpp. References getRandomCardDir(), getRandomDeck(), and group(). |
|
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()
Definition at line 218 of file kcarddialog.cpp. Referenced by setupDialog(). |
|
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(), *)
Definition at line 224 of file kcarddialog.cpp. |
|
Returns the path to the card frontside specified in dir carddir.
Definition at line 232 of file kcarddialog.cpp. |
|
Returns a random deck in deckPath().
Definition at line 574 of file kcarddialog.cpp. Referenced by getConfigCardDeck(). |
|
Returns a random directory of cards.
Definition at line 586 of file kcarddialog.cpp. Referenced by getConfigCardDeck(). |
|
Show or hides the "random backside" checkbox.
Definition at line 599 of file kcarddialog.cpp. Referenced by getCardDeck(). |
|
Show or hides the "random foreside" checkbox.
Definition at line 610 of file kcarddialog.cpp. Referenced by getCardDeck(). |
|
Returns the chosen deck, which is a valid path to a imagefile.
Definition at line 247 of file kcarddialog.cpp. Referenced by getCardDeck(), saveConfig(), and setupDialog(). |
|
Sets the default deck.
Definition at line 248 of file kcarddialog.cpp. Referenced by getCardDeck(), and loadConfig(). |
|
Definition at line 249 of file kcarddialog.cpp. Referenced by getCardDeck(), saveConfig(), and setupDialog(). |
|
Sets the default card directory.
Definition at line 250 of file kcarddialog.cpp. Referenced by getCardDeck(), and loadConfig(). |
|
Definition at line 251 of file kcarddialog.cpp. Referenced by loadConfig(), saveConfig(), and setupDialog(). |
|
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. References cardDir(), deck(), flags(), and getDefaultDeck(). Referenced by getCardDeck(). |
|
Definition at line 253 of file kcarddialog.cpp. Referenced by getCardDeck(), and saveConfig(). |
|
Definition at line 255 of file kcarddialog.cpp. Referenced by getCardDeck(), and saveConfig(). |
|
Definition at line 257 of file kcarddialog.cpp. Referenced by getCardDeck(). |
|
Definition at line 259 of file kcarddialog.cpp. Referenced by getCardDeck(). |
|
Definition at line 252 of file kcarddialog.cpp. Referenced by getCardDeck(). |
|
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. References flags(), setCardDir(), and setDeck(). Referenced by getCardDeck(). |
|
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. References cardDir(), deck(), flags(), isRandomCardDir(), and isRandomDeck(). Referenced by getCardDeck(). |
|
Referenced by getConfigCardDeck(). |
The documentation for this class was generated from the following files: