KDEGames

kgthemeprovider.h
1 /***************************************************************************
2  * Copyright 2012 Stefan Majewsky <[email protected]> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU Library General Public License *
6  * version 2 as published by the Free Software Foundation *
7  * *
8  * This program is distributed in the hope that it will be useful, *
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11  * GNU Library General Public License for more details. *
12  * *
13  * You should have received a copy of the GNU Library General Public *
14  * License along with this program; if not, write to the *
15  * Free Software Foundation, Inc., *
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
17  ***************************************************************************/
18 
19 #ifndef KGTHEMEPROVIDER_H
20 #define KGTHEMEPROVIDER_H
21 
22 #include <QObject>
23 #include <QQmlEngine>
24 #include <QQmlContext>
25 #include <QDir>
26 #include <QPointer>
27 
28 #include <kgtheme.h>
29 #include <libkdegames_export.h>
30 
42 class KDEGAMES_EXPORT KgThemeProvider : public QObject
43 {
44  Q_OBJECT
45  Q_PROPERTY(const KgTheme* currentTheme READ currentTheme WRITE setCurrentTheme NOTIFY currentThemeChanged)
46  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
47  Q_PROPERTY(QString currentThemeName READ currentThemeName NOTIFY currentThemeNameChanged)
49  public:
56  explicit KgThemeProvider(const QByteArray& configKey = QByteArray("Theme"), QObject* parent = nullptr);
58  virtual ~KgThemeProvider();
59 
63  QString name() const;
64 
66  QList<const KgTheme*> themes() const;
69  const KgTheme* defaultTheme() const;
75  void setDefaultTheme(const KgTheme* theme);
84  const KgTheme* currentTheme() const;
85 
88  QString currentThemeName() const;
89 
92  void addTheme(KgTheme* theme);
107  void discoverThemes(const QByteArray& resource, const QString& directory, const QString& defaultThemeName = QStringLiteral("default"), const QMetaObject* themeClass = nullptr);
112  void rediscoverThemes();
113 
122  virtual QPixmap generatePreview(const KgTheme* theme, const QSize& size);
123 
129  void setDeclarativeEngine(const QString& name, QQmlEngine* engine);
130  Q_SIGNALS:
132  void currentThemeChanged(const KgTheme* theme);
135  void nameChanged(const QString& name);
138  void currentThemeNameChanged(const QString& themeName);
139  public Q_SLOTS:
142  void setCurrentTheme(const KgTheme* theme);
143  private:
144  class Private;
145  Private* const d;
146  Q_PRIVATE_SLOT(d, void updateThemeName());
147 };
148 
149 Q_DECLARE_METATYPE(KgThemeProvider*)
150 QML_DECLARE_TYPE(KgThemeProvider*)
151 
152 #endif // KGTHEMEPROVIDER_H
A theme provider manages KgTheme instances, and maintains a selection of the currentTheme().
Q_PROPERTY(...)
Q_DISABLE_COPY(Class)
A theme describes the visual appearance of a game.
Definition: kgtheme.h:72
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Nov 26 2020 22:36:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.