KgThemeProvider

Search for usage in LXR

#include <KgThemeProvider>

Inheritance diagram for KgThemeProvider:

Properties

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

Signals

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

Public Slots

void setCurrentTheme (const KgTheme *theme)
 

Public Member Functions

 KgThemeProvider (const QByteArray &configKey=QByteArray("Theme"), QObject *parent=nullptr)
 
 ~KgThemeProvider () override
 
void addTheme (KgTheme *theme)
 
const KgThemecurrentTheme () const
 
QString currentThemeName () const
 
const KgThemedefaultTheme () const
 
void discoverThemes (const char *resource, const QString &directory, const QString &defaultThemeName=QStringLiteral("default"), const QMetaObject *themeClass=nullptr)
 
void discoverThemes (const QByteArray &resource, const QString &directory, const QString &defaultThemeName=QStringLiteral("default"), const QMetaObject *themeClass=nullptr)
 
void discoverThemes (const QString &directory, const QString &defaultThemeName=QStringLiteral("default"), const QMetaObject *themeClass=nullptr)
 
virtual QPixmap generatePreview (const KgTheme *theme, const QSize &size)
 
QString name () const
 
void rediscoverThemes ()
 
void setDeclarativeEngine (const QString &name, QQmlEngine *engine)
 
void setDefaultTheme (const KgTheme *theme)
 
QList< const KgTheme * > themes () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
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)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

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 30 of file kgthemeprovider.h.

Constructor & Destructor Documentation

◆ KgThemeProvider()

KgThemeProvider::KgThemeProvider ( const QByteArray configKey = QByteArray("Theme"),
QObject parent = nullptr 
)
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::~KgThemeProvider ( )
override

Destructor.

Definition at line 67 of file kgthemeprovider.cpp.

Member Function Documentation

◆ addTheme()

void KgThemeProvider::addTheme ( KgTheme theme)

Adds a theme to this instance.

The theme provider takes ownership of theme.

Definition at line 96 of file kgthemeprovider.cpp.

◆ currentTheme()

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.

◆ currentThemeChanged

void KgThemeProvider::currentThemeChanged ( const KgTheme theme)
signal

Emitted when the current theme changes.

See also
setCurrentTheme

◆ currentThemeName()

QString KgThemeProvider::currentThemeName ( ) const
Returns
the name of the current theme
Since
4.11

◆ currentThemeNameChanged

void KgThemeProvider::currentThemeNameChanged ( const QString themeName)
signal

Emitted when the name of the current theme changes.

Since
4.11

◆ defaultTheme()

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

Definition at line 108 of file kgthemeprovider.cpp.

◆ discoverThemes() [1/2]

void KgThemeProvider::discoverThemes ( const QByteArray resource,
const QString directory,
const QString defaultThemeName = QStringLiteral("default"),
const QMetaObject themeClass = nullptr 
)

This method reads theme description files from a standard location.

The resource argument is ignored, no longer matters. The directory argument is passed to QStandardPaths like this:

The typical usage is to install theme description files in

${KDE_INSTALL_DATADIR}/<appname>/themes

and then call:

themeProvider.discoverThemes("appdata", QStringLiteral("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.

Deprecated:
Since 7.4, use discoverThemes(const QString& , const QString&, const QMetaObject*)

Definition at line 160 of file kgthemeprovider.cpp.

◆ discoverThemes() [2/2]

void KgThemeProvider::discoverThemes ( const QString directory,
const QString defaultThemeName = QStringLiteral("default"),
const QMetaObject themeClass = nullptr 
)

This method reads theme description files from a standard location.

The directory argument is passed to QStandardPaths like this:

The typical usage is to install theme description files in

${KDE_INSTALL_DATADIR}/<appname>/themes

and then call:

themeProvider.discoverThemes(QStringLiteral("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.

Since
7.4

Definition at line 167 of file kgthemeprovider.cpp.

◆ generatePreview()

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 265 of file kgthemeprovider.cpp.

◆ name()

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

◆ nameChanged

void KgThemeProvider::nameChanged ( const QString name)
signal

Emitted when the name of the provider changes.

Since
4.11

◆ rediscoverThemes()

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 193 of file kgthemeprovider.cpp.

◆ setCurrentTheme

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 145 of file kgthemeprovider.cpp.

◆ setDeclarativeEngine()

void KgThemeProvider::setDeclarativeEngine ( const QString name,
QQmlEngine engine 
)

Registers this KgThemeProvider with engine's root context with ID name and constructs a KgImageProvider corresponding to this KgThemeProvider and adds it to the QML engine, also with name, which will receive sprite requests.

Since
4.11

Definition at line 277 of file kgthemeprovider.cpp.

◆ setDefaultTheme()

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 113 of file kgthemeprovider.cpp.

◆ themes()

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

Definition at line 91 of file kgthemeprovider.cpp.


The documentation for this class was generated from the following files:
QList< const KgTheme * > themes() const
QStringList locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 04:05:14 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.