File indexing completed on 2024-05-12 04:02:40

0001 /*
0002     SPDX-FileCopyrightText: 2009 Mathias Kraus <k.hias@gmx.de>
0003     SPDX-FileCopyrightText: 2006 Mauricio Piacentini <mauricio@tabuleiro.com>
0004     SPDX-FileCopyrightText: 2007 Matt Williams <matt@milliams.com>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef ARENASELECTOR_H
0010 #define ARENASELECTOR_H
0011 
0012 #include <QWidget>
0013 
0014 class KConfigSkeleton; 
0015 class ArenaSelectorPrivate;
0016 
0017 /**
0018  * \class ArenaSelector arenaselector.h <ArenaSelector>
0019  * 
0020  * @short A widget used to select the game's arena
0021  *
0022  * The most common way to use the arena selector is to add it as page to a KConfigDialog
0023  * \code
0024  * KConfigDialog *dialog = new KConfigDialog(this, "settings", Settings::self());
0025  * dialog->addPage(new ArenaSelector(dialog, Settings::self()), i18n("Arena"), "game_arena");
0026  * dialog->show();
0027  * \endcode
0028  * This will create a page in your KConfigDialog with the title "Arena" and using the 
0029  * "game_arena" icon. By default, the widget will search in the share/apps/appname/arenas 
0030  * directory for .desktop files with a group called "Arena".
0031  *
0032  * @author Mauricio Piacentini
0033  **/
0034 class ArenaSelector : public QWidget
0035 {
0036 Q_OBJECT
0037 public:
0038     ///Flags which control the behavior of ArenaSelector.
0039     enum Option {
0040         DefaultBehavior = 0,
0041         ///Enable downloading of additional themes with KNewStuff3.
0042         ///This requires a KNS3 config file to be installed for this app.
0043         EnableNewStuffDownload = 1 << 0
0044     };
0045     Q_DECLARE_FLAGS(Options, Option)
0046     
0047     /**
0048     * Load a specific arena file.
0049     * @param parent the parent widget
0050     * @param aconfig the KConfigSceleton
0051     * @param randomArenaModeArenaList the arena mode list
0052     * @param options the options
0053     * @param groupName the title of the config group in the arena .desktop file
0054     * @param directory subdirectory (of share/apps/appname) to search in
0055     * @return true if the arena files and properties could be loaded
0056     */
0057     ArenaSelector(QWidget* parent, KConfigSkeleton* aconfig, QStringList* randomArenaModeArenaList, Options options = DefaultBehavior, const QString& groupName = QStringLiteral("Arena"), const QString& directory = QStringLiteral("arenas"));
0058     ~ArenaSelector() override;
0059     
0060 protected:
0061     /**
0062     * Resizes the items when the view is resized.
0063     * @param p_event the resize event
0064     */
0065     void resizeEvent(QResizeEvent* p_event) override;
0066     
0067     /**
0068     * Resizes the items when the view is showed.
0069     * @param p_event the resize event
0070     */
0071     void showEvent(QShowEvent* p_event) override;
0072 
0073 private:
0074     class Private;
0075     Private* const d;
0076 
0077     Q_DISABLE_COPY(ArenaSelector)
0078 
0079     Q_PRIVATE_SLOT(d, void _k_updatePreview(QListWidgetItem* currentItem = NULL))
0080     Q_PRIVATE_SLOT(d, void _k_updateArenaList(const QString&))
0081     Q_PRIVATE_SLOT(d, void _k_setRandomArenaMode(bool randomModeEnabled))
0082     Q_PRIVATE_SLOT(d, void _k_updateRandomArenaModeArenaList(QListWidgetItem* item))
0083 };
0084 
0085 #endif