File indexing completed on 2024-04-21 04:05:22
0001 /* 0002 This file is part of the KDE games library 0003 SPDX-FileCopyrightText: 2008 Andreas Pakulat <apaku@gmx.de> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only 0006 */ 0007 0008 #ifndef KCARDDIALOG_H 0009 #define KCARDDIALOG_H 0010 0011 #include <QDialog> 0012 #include <QWidget> 0013 0014 #include <KConfig> 0015 0016 class KCardWidgetPrivate; 0017 class KCardWidget; 0018 0019 /** 0020 * \class KCardDialog kcarddialog.h <KCardDialog> 0021 * 0022 * @short A convenience class to display a standalone card selection dialog. 0023 * 0024 * This is a simple convenience class to embed the @ref KCardWidget into a 0025 * QDialog that has an OK and Cancel button and an appropriate caption. 0026 * 0027 * Usage Example: 0028 * \code 0029 * KConfigGroup(KSharedConfig::openConfig(),"CardOptions"); 0030 * KCardWidget *cardwiget = new KCardwidget(); 0031 * cardwidget->readSettings(configGroup); 0032 * KCardDialog dlg(cardwidget); 0033 * if (dlg.exec() == QDialog::Accepted) 0034 * { 0035 * cardwidget->saveSettings(configGroup); 0036 * configGroup.sync(); 0037 * //now update the graphics 0038 * } 0039 * \endcode 0040 * 0041 */ 0042 class KCardDialog : public QDialog 0043 { 0044 Q_OBJECT 0045 public: 0046 explicit KCardDialog(KCardWidget *widget); 0047 }; 0048 0049 /** 0050 * \class KCardWidget kcarddialog.h <KCardDialog> 0051 * 0052 * @short A card deck selection widget for card games. 0053 * 0054 * The KCardWidget provides a widget for interactive card deck selection. 0055 * It gives card games an easy to use interface to select front and 0056 * back of the card sets. As card sets the KDE default card sets are 0057 * offered as well as used specified ones. 0058 * 0059 * This class can be used in two ways: Embedding it into an existing 0060 * dialog or creating a small QDialog just for the card deck selection. 0061 * 0062 * Card sets (front and back) are identified by their (translated) names. 0063 * 0064 * You can use a KConfigGroup to initialize the state of the widget or 0065 * let the widget store its current state to a config group. 0066 * 0067 * For an example usage see @ref KCardDialog. 0068 * 0069 */ 0070 class KCardWidget : public QWidget 0071 { 0072 Q_OBJECT 0073 0074 public: 0075 /** 0076 * Constructs a card deck selection widget. 0077 * 0078 * @param parent The parent widget of the widget, if any. 0079 */ 0080 explicit KCardWidget (QWidget *parent = nullptr); 0081 0082 /** 0083 * Read the settings from a config file 0084 * @param group the configuration group 0085 */ 0086 void readSettings(const KConfigGroup &group); 0087 0088 /** 0089 * Destructs a card deck selection dialog. 0090 */ 0091 ~KCardWidget() override; 0092 0093 /** 0094 * Saves the KCardWidget config into a config file. 0095 * These settings are used by @ref KCardWidget. 0096 */ 0097 void saveSettings(KConfigGroup &group) const; 0098 0099 /** 0100 * set the name of the card set (front side) 0101 * @param name the new name to select as front side 0102 */ 0103 void setDeckName(const QString &name); 0104 0105 /** 0106 * Retrieve the name of the card set (front side) from the dialog. 0107 * @return The card set name. 0108 */ 0109 QString deckName() const; 0110 0111 protected: 0112 void insertCardIcons(); 0113 0114 /** 0115 * Configure the dialog GUI. 0116 */ 0117 void setupGUI(); 0118 0119 protected Q_SLOTS: 0120 /** 0121 * Called by the card set list view when a new item was selected. 0122 */ 0123 void updateSelection(); 0124 0125 private: 0126 /** The dialog data. */ 0127 KCardWidgetPrivate *const d; 0128 }; 0129 0130 #endif