• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

libkdegames

Public Slots | Signals | Public Member Functions | Properties | List of all members
KgThemeProvider Class Reference

#include <KgThemeProvider>

Inheritance diagram for KgThemeProvider:
Inheritance graph
[legend]

Public Slots

void setCurrentTheme (const KgTheme *theme)
 

Signals

void currentThemeChanged (const KgTheme *theme)
 
void currentThemeNameChanged (const QString &themeName)
 
void nameChanged (const QString &name)
 

Public Member Functions

 KgThemeProvider (const QByteArray &configKey=QByteArray("Theme"), QObject *parent=0)
 
virtual ~KgThemeProvider ()
 
void addTheme (KgTheme *theme)
 
const KgTheme * currentTheme () const
 
QString currentThemeName () const
 
const KgTheme * defaultTheme () const
 
void discoverThemes (const QByteArray &resource, const QString &directory, const QString &defaultThemeName=QLatin1String("default"), const QMetaObject *themeClass=0)
 
virtual QPixmap generatePreview (const KgTheme *theme, const QSize &size)
 
QString name () const
 
void rediscoverThemes ()
 
void setDeclarativeEngine (const QString &name, QDeclarativeEngine *engine)
 
void setDefaultTheme (const KgTheme *theme)
 
QList< const KgTheme * > themes () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Properties

const KgTheme currentTheme
 
QString currentThemeName
 
QString name
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 

Detailed Description

A theme provider manages KgTheme instances, and maintains a selection of the currentTheme().

It can automatically coordinate its selection with a KGameRenderer instance.

Note
KgThemeProvider instances store selections in the application config, in the group [KgTheme]. This is documented here because this information is relevant for kconfig_

Definition at line 39 of file kgthemeprovider.h.

Constructor & Destructor Documentation

KgThemeProvider::KgThemeProvider ( const QByteArray &  configKey = QByteArray("Theme"),
QObject *  parent = 0 
)
explicit

Constructor.

If you don't want KgThemeProvider to store the current theme selection in the application config file automatically, set configKey to an empty QByteArray.

If there are multiple KgThemeProvider instances, make sure they use different config keys to avoid collisions.

Definition at line 56 of file kgthemeprovider.cpp.

KgThemeProvider::~KgThemeProvider ( )
virtual

Destructor.

Definition at line 65 of file kgthemeprovider.cpp.

Member Function Documentation

void KgThemeProvider::addTheme ( KgTheme *  theme)

Adds a theme to this instance.

The theme provider takes ownership of theme.

Definition at line 98 of file kgthemeprovider.cpp.

const KgTheme* KgThemeProvider::currentTheme ( ) const
Returns
the currently selected theme, or 0 if the provider does not contain any themes

After the KgThemeProvider instance has been created, the current theme will not be determined until this method is called for the first time. This allows the application developer to set up the theme provider before it restores the theme selection from the configuration file.

void KgThemeProvider::currentThemeChanged ( const KgTheme *  theme)
signal

Emitted when the current theme changes.

See also
setCurrentTheme
QString KgThemeProvider::currentThemeName ( ) const
Returns
the name of the current theme
Since
4.11
void KgThemeProvider::currentThemeNameChanged ( const QString &  themeName)
signal

Emitts the new theme name when the current theme changes.

Since
4.11
const KgTheme * KgThemeProvider::defaultTheme ( ) const
Returns
the default theme, or 0 if the provider does not contain any themes

Definition at line 113 of file kgthemeprovider.cpp.

void KgThemeProvider::discoverThemes ( const QByteArray &  resource,
const QString &  directory,
const QString &  defaultThemeName = QLatin1String("default"),
const QMetaObject *  themeClass = 0 
)

This method reads theme description files from a standard location.

The first two arguments are passed to KStandardDirs like this:

KGlobal::dirs()->findAllResources(resource, directory + "/*.desktop");
*

The typical usage is to install theme description files in

${DATA_INSTALL_DIR}/themes

and then call:

themeProvider.discoverThemes("appdata", QLatin1String("themes"));

If a themeClass's QMetaObject is given, the created themes will be instances of this KgTheme subclass. The themeClass must export (with the Q_INVOKABLE marker) a constructor with the same signature as the KgTheme constructor.

Definition at line 170 of file kgthemeprovider.cpp.

QPixmap KgThemeProvider::generatePreview ( const KgTheme *  theme,
const QSize &  size 
)
virtual

Generate a preview pixmap for the given theme.

The application will typically want to reimplement this to load the given theme into a KGameRenderer and then arrange some sprites into a preview.

size is the maximal allowed size.

The default implementation tries to load a preview image from KgTheme::previewPath(), and resizes the result to fit in size.

Definition at line 261 of file kgthemeprovider.cpp.

QString KgThemeProvider::name ( ) const
Returns
the name of the KgThemeProvider object. This name can be used as QML element ID to reference the object inside QML.
Since
4.11
void KgThemeProvider::nameChanged ( const QString &  name)
signal

Emitted when the name of the provider changes.

Since
4.11
void KgThemeProvider::rediscoverThemes ( )

After this provider has been set up with discoverThemes(), this method may be used to read additional themes which were added since the discoverThemes() call.

This is esp. useful for KNewStuff integration.

Definition at line 179 of file kgthemeprovider.cpp.

void KgThemeProvider::setCurrentTheme ( const KgTheme *  theme)
slot

Select a new theme.

The given theme must already have been added to this instance.

Definition at line 155 of file kgthemeprovider.cpp.

void KgThemeProvider::setDeclarativeEngine ( const QString &  name,
QDeclarativeEngine *  engine 
)

Registers this KgThemeProvider with.

Parameters
engine'sroot context with ID
nameand constructs a KgImageProvider corresponding to this KgThemeProvider and adds it to the QML engine, also with
name,whichwill receive sprite requests
Since
4.11

Definition at line 266 of file kgthemeprovider.cpp.

void KgThemeProvider::setDefaultTheme ( const KgTheme *  theme)
See also
defaultTheme()

Usually this will be set automatically by discoverThemes(). Call this before the first call to currentTheme(), it won't have any effect afterwards. theme must already have been added to this instance.

Definition at line 118 of file kgthemeprovider.cpp.

QList< const KgTheme * > KgThemeProvider::themes ( ) const
Returns
the themes in this provider

Definition at line 93 of file kgthemeprovider.cpp.

Property Documentation

const KgTheme * KgThemeProvider::currentTheme
readwrite

Definition at line 42 of file kgthemeprovider.h.

QString KgThemeProvider::currentThemeName
read

Definition at line 44 of file kgthemeprovider.h.

QString KgThemeProvider::name
read

Definition at line 43 of file kgthemeprovider.h.


The documentation for this class was generated from the following files:
  • kgthemeprovider.h
  • kgthemeprovider.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdegames

Skip menu "libkdegames"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal