File indexing completed on 2024-04-28 04:05:05
0001 /* 0002 SPDX-FileCopyrightText: 2012 Stefan Majewsky <majewsky@gmx.net> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #ifndef KGAMETHEMESELECTOR_H 0008 #define KGAMETHEMESELECTOR_H 0009 0010 // own 0011 #include "kdegames_export.h" 0012 #include "kgamethemeprovider.h" 0013 // Qt 0014 #include <QWidget> 0015 // Std 0016 #include <memory> 0017 0018 /** 0019 * @class KGameThemeSelector kgamethemeselector.h <KGameThemeSelector> 0020 * @brief Theme selection widget. 0021 * 0022 * This widget allows the user to change the theme selection of a 0023 * KGameThemeProvider. Selections are immediately applied to allow the user 0024 * to quickly preview themes. In simple cases, the widget can be used 0025 * standalone with the showAsDialog() method. 0026 * 0027 * @code 0028 * K_GLOBAL_STATIC_WITH_ARGS(KGameThemeSelector, selector, (provider)) 0029 * ... 0030 * selector->showAsDialog(); 0031 * @endcode 0032 */ 0033 class KDEGAMES_EXPORT KGameThemeSelector : public QWidget 0034 { 0035 Q_OBJECT 0036 Q_DISABLE_COPY(KGameThemeSelector) 0037 0038 public: 0039 /// Flags which control the behavior of KGameThemeSelector. 0040 enum Option { 0041 DefaultBehavior = 0, 0042 /// Enable downloading of additional themes with KNewStuff3. 0043 /// This requires a KNS3 config file to be installed for this app. 0044 EnableNewStuffDownload = 1 << 0 0045 }; 0046 /** 0047 * Stores a combination of #Option values. 0048 */ 0049 Q_DECLARE_FLAGS(Options, Option) 0050 0051 explicit KGameThemeSelector(KGameThemeProvider *provider, Options options = DefaultBehavior, QWidget *parent = nullptr); 0052 ~KGameThemeSelector() override; 0053 0054 void setNewStuffConfigFileName(const QString &configFileName); 0055 0056 public Q_SLOTS: 0057 /// Create and show a non-modal dialog which displays this selector. 0058 /// The dialog will be automatically cleaned up when it's closed, but it 0059 /// is ensured that the selector is not deleted. 0060 /// 0061 /// This method does nothing if the selector widget is already visible. 0062 void showAsDialog(const QString &caption = QString()); 0063 0064 private: 0065 class Dialog; 0066 std::unique_ptr<class KGameThemeSelectorPrivate> const d_ptr; 0067 Q_DECLARE_PRIVATE(KGameThemeSelector) 0068 }; 0069 0070 Q_DECLARE_OPERATORS_FOR_FLAGS(KGameThemeSelector::Options) 0071 0072 #endif // KGAMETHEMESELECTOR_H