KDEGames

kgametheme.h
1 /*
2  SPDX-FileCopyrightText: 2007 Mauricio Piacentini <[email protected]>
3  SPDX-FileCopyrightText: 2007 Matt Williams <[email protected]>
4 
5  SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #ifndef KGAMETHEME_H
9 #define KGAMETHEME_H
10 
11 // own
12 #include "libkdegamesprivate_export.h"
13 // Qt
14 #include <QString>
15 #include <QLoggingCategory>
16 // Std
17 #include <memory>
18 
19 Q_DECLARE_LOGGING_CATEGORY(GAMES_LIB)
20 
21 class KGameThemePrivate;
22 class QPixmap;
23 
24 #if KDEGAMESPRIVATE_ENABLE_DEPRECATED_SINCE(4, 9)
25 
26 /**
27  * \class KGameTheme kgametheme.h <KGameTheme>
28  *
29  * @short Class for loading theme files
30  *
31  * Essentially just a wrapper around a .desktop theme file. Load a file with
32  * load() and then access its properties.
33  *
34  * For more advanced features like dynamic themes or custom game rules, it
35  * will likely be necessary to derive from this class
36  *
37  * @author Mauricio Piacentini
38  * @deprecated Since 4.9, use KgTheme instead.
39  **/
40 class KDEGAMESPRIVATE_EXPORT KGameTheme
41 {
42  public:
43  KDEGAMESPRIVATE_DEPRECATED_VERSION(4, 9, "Use KgTheme")
44  explicit KGameTheme(const QString &themeGroup = QStringLiteral("KGameTheme"));
45  virtual ~KGameTheme();
46 
47  /**
48  * Load the default theme file. Called "default.desktop"
49  * @return true if the theme files and properties could be loaded
50  */
51  virtual bool loadDefault();
52  /**
53  * Load a specific theme file.
54  * Note that although theme could be successfully loaded,
55  * no check on the validity of theme's SVG file contents is done.
56  * Application writers will need to perform this check manually
57  * e.g. by calling QSvgRenderer::isValid()
58  * @param file the name of the theme file relative to the share/apps/appname
59  * directory. e.g. "themes/classic.desktop"
60  * @return true if the theme files and properties could be loaded
61  */
62  virtual bool load(const QString &file);
63  /// @return the full path of the .desktop file
64  QString path() const;
65  /// @return the path of the theme
66  QString prefix() const;
67  /// @return just the "*.desktop" part
68  QString fileName() const;
69  /// @return the full path of the svg file which is specified in "FileName" key
70  virtual QString graphics() const;
71  /// @return a property directly from the .desktop file
72  QString property(const QString &key) const;
73  /// @return a preview pixmap
74  QPixmap preview() const;
75  /**
76  * Possible keys:
77  * - Name
78  * - Author
79  * - Description
80  * - AuthorEmail
81  * @param key the key of the wanted property
82  * @return the data related to 'key'
83  */
84  virtual QString themeProperty(const QString &key) const;
85 
86  private:
87  friend class KGameThemePrivate;
88  std::unique_ptr<KGameThemePrivate> const d;
89 };
90 
91 #endif
92 
93 #endif
Class for loading theme files.
Definition: kgametheme.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Dec 7 2021 22:34:15 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.