2 This file is part of the KDE games library
3 Copyright 2008 Andreas Pakulat <apaku@gmx.de>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
19 #ifndef __KCARDDIALOG_H_
20 #define __KCARDDIALOG_H_
22 #include <QtGui/QWidget>
26 #include <libkdegames_export.h>
28 class QListWidgetItem
;
29 class KCardWidgetPrivate
;
33 * \class KCardDialog kcarddialog.h <KCardDialog>
35 * @short A convenience class to display a standalone card selection dialog.
37 * This is a simple convenience class to embed the @ref KCardWidget into a
38 * KDialog that has an Ok and Cancel button and an appropriate caption.
42 * KConfigGroup(KGlobal::config(),"CardOptions");
43 * KCardWidget* cardwiget = new KCardwidget();
44 * cardwidget->readSettings(configGroup);
45 * KCardDialog dlg(cardwidget);
46 * if(dlg.exec() == QDialog::Accepted)
48 * cardwidget->saveSettings(configGroup);
50 * //now update the graphics
55 class KDEGAMES_EXPORT KCardDialog
: public KDialog
59 KCardDialog(KCardWidget
* widget
);
63 * \class KCardWidget kcarddialog.h <KCardDialog>
65 * @short A carddeck selection widget for card games.
67 * The KCardWidget provides a widget for interactive carddeck selection.
68 * It gives cardgames an easy to use interface to select front and
69 * back of the card sets. As card sets the KDE default cardsets are
70 * offered as well as used specified ones.
72 * This class can be used in two ways: Embedding it into an existing
73 * dialog or creating a small KDialog just for the carddeck selection.
75 * Card sets (front and back) are identified by their (translated) names.
77 * Here you can see a card widget in action
78 * @image html "kcarddialog.png" KCardwidget
80 * You can use a KConfigGroup to initialize the state of the widget or
81 * let the widget store its current state to a config group.
83 * For an example usage see @ref KCardDialog.
86 class KDEGAMES_EXPORT KCardWidget
: public QWidget
93 * Constructs a card deck selection widget.
95 * @param parent The parent widget of the widget, if any.
97 KCardWidget (QWidget
* parent
= NULL
);
100 * Read the settings from a config file
101 * @param group the configuration group
103 void readSettings(const KConfigGroup
& group
);
106 * Destructs a card deck selection dialog.
111 * Saves the KCardWidget config into a config file.
112 * These settings are used by @ref KCardWidget.
114 void saveSettings(KConfigGroup
& group
) const;
117 * set the name of the card deck (back side)
118 * @param name the new name to select as back side
120 void setBackName(const QString
& name
);
123 * Retrieve the name of the card deck (back side) from the widget.
124 * @return The deck name.
126 QString
backName() const;
129 * Retrieve the locking status
130 * @return true if the backside selection is locked to the frontside
132 bool isLocked() const;
135 * Retrieve the current state of the "Show old style decks" checkbox
136 * @return whether or not fixed size card decks are shown in the list
138 bool isFixedSizeAllowed() const;
141 * set the name of the card set (front side)
142 * @param name the new name to select as front side
144 void setFrontName(const QString
& name
);
147 * Retrieve the name of the card set (front side) from the dialog.
148 * @return The card set name.
150 QString
frontName() const;
154 * Allow the user to select fixed size cards
155 * @param fixedSizeAllowed if set to true will show scalable and also fixed
156 * size card decks in the dialog
158 void setFixedSizeAllowed(bool fixedSizeAllowed
);
161 * enable or disable locked selection, when locking is enabled the user
162 * can only choose the front sides and the backside will be determined
164 * @param locked whether to lock the front and backside selection
166 void setLocked(bool locked
);
169 void insertCardIcons();
172 * Insert the back sides into the list view.
174 void insertDeckIcons();
177 * Configure the dialog GUI.
183 * Called by the card set list view when a new item was selected.
188 * Called by the card deck list view when a new item was selected.
189 * @param current The newly selected item.
190 * @param last The previously selected item.
198 KCardWidgetPrivate
* const d
;