KColorSchemeManager

Search for usage in LXR

KColorSchemeManager Class Reference

#include <KColorSchemeManager>

Inheritance diagram for KColorSchemeManager:

Public Slots

void activateScheme (const QModelIndex &index)
 

Public Member Functions

 KColorSchemeManager (QObject *parent=nullptr)
 
QString activeSchemeId () const
 
KActionMenucreateSchemeSelectionMenu (const QIcon &icon, const QString &text, const QString &selectedSchemeName, QObject *parent)
 
KActionMenucreateSchemeSelectionMenu (const QString &selectedSchemeName, QObject *parent)
 
KActionMenucreateSchemeSelectionMenu (const QString &text, const QString &selectedSchemeName, QObject *parent)
 
KActionMenucreateSchemeSelectionMenu (QObject *parent)
 
QModelIndex indexForScheme (const QString &name) const
 
QAbstractItemModelmodel () const
 
void saveSchemeToConfigFile (const QString &schemeName) const
 
void setAutosaveChanges (bool autosaveChanges)
 
- 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

- Properties inherited from QObject
 objectName
 
- 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 small helper to get access to all available color schemes and activating a scheme in the QApplication. This is useful for applications which want to provide a selection of custom color schemes to their user. For example it is very common for photo and painting applications to use a dark color scheme even if the default is a light scheme. Since version 5.67 it also allows going back to following the system color scheme.

The KColorSchemeManager provides access to a QAbstractItemModel which holds all the available schemes. A possible usage looks like the following:

QListView *view = new QListView(this);
view->setModel(schemes->model());

In addition the KColorSchemeManager also provides the possibility to create a KActionMenu populated with all the available color schemes in an action group. If one of the actions is selected the scheme is applied instantly:

QToolButton *button = new QToolButton();
KActionMenu *menu = schemes->createSchemeSelectionMenu(QStringLiteral("Oxygen"), button);
button->setMenu(menu->menu());
Since
5.0

Definition at line 55 of file kcolorschememanager.h.

Member Function Documentation

◆ activateScheme

void KColorSchemeManager::activateScheme ( const QModelIndex index)
slot

Activates the KColorScheme identified by the provided index.

Installs the KColorScheme as the QApplication's QPalette.

Parameters
indexThe index for the KColorScheme to activate. The index must reference the QAbstractItemModel provided by model. Since version 5.67 passing an invalid index activates the system scheme.
See also
model()

Definition at line 206 of file kcolorschememanager.cpp.

◆ activeSchemeId()

QString KColorSchemeManager::activeSchemeId ( ) const

Returns the id of the currently active scheme or an empty string if the default scheme is active.

Since
5.107

Definition at line 233 of file kcolorschememanager.cpp.

◆ createSchemeSelectionMenu() [1/4]

KActionMenu * KColorSchemeManager::createSchemeSelectionMenu ( const QIcon icon,
const QString text,
const QString selectedSchemeName,
QObject parent 
)

Creates a KActionMenu populated with all the available color schemes.

All actions are in an action group and when one of the actions is triggered the scheme referenced by this action is activated.

The color scheme with the same name as selectedSchemeName will be checked. If none of the available color schemes has the same name, the system theme entry will be checked.

The KActionMenu will not be updated in case the installed color schemes change. It's the task of the user of the KActionMenu to monitor for changes if required.

Parameters
iconThe icon to use for the KActionMenu
textThe text to use for the KActionMenu
selectedSchemeNameThe name of the color scheme to select
parentThe parent of the KActionMenu
Returns
KActionMenu populated with all available color schemes.
See also
activateScheme
Deprecated:
since 5.107, use KColorSchemeMenu::createMenu and set the text and icon manually and check an action of the returned menu

Definition at line 173 of file kcolorschememanager.cpp.

◆ createSchemeSelectionMenu() [2/4]

KActionMenu * KColorSchemeManager::createSchemeSelectionMenu ( const QString selectedSchemeName,
QObject parent 
)

Overload for createSchemeSelectionMenu(const QIcon &icon, const QString &text, const QString &selectedSchemeName, QObject *parent).

Since 5.67 sets the icon to theme id "preferences-desktop-color" and the text to "Color Scheme", before set a null icon and an empty string.

Deprecated:
since 5.107, use KColorSchemeMenu::createMenu and check an action manually

Definition at line 187 of file kcolorschememanager.cpp.

◆ createSchemeSelectionMenu() [3/4]

KActionMenu * KColorSchemeManager::createSchemeSelectionMenu ( const QString text,
const QString selectedSchemeName,
QObject parent 
)

Overload for createSchemeSelectionMenu(const QIcon &icon, const QString &text, const QString &selectedSchemeName, QObject *parent).

Since 5.67 sets the icon to theme id "preferences-desktop-color", before set a null icon.

Deprecated:
since 5.107, use KColorSchemeMenu::createMenu and set the text and check an action manually

Definition at line 180 of file kcolorschememanager.cpp.

◆ createSchemeSelectionMenu() [4/4]

KActionMenu * KColorSchemeManager::createSchemeSelectionMenu ( QObject parent)

Overload for createSchemeSelectionMenu(const QIcon &icon, const QString &text, const QString &selectedSchemeName, QObject *parent).

Sets the icon to theme id "preferences-desktop-color" and the text to "Color Scheme". Since 5.93 the selectedSchemeName is set to the value previously saved (if any). Before that it was set to an empty string.

Since
5.67
Deprecated:
since 5.107, use KColorSchemeMenu::createMenu

Definition at line 200 of file kcolorschememanager.cpp.

◆ indexForScheme()

QModelIndex KColorSchemeManager::indexForScheme ( const QString name) const

Returns the model index for the scheme with the given name.

If no such scheme exists an invalid index is returned. If you pass an empty string the index that is equivalent to going back to following the system scheme is returned for versions 5.67 and newer.

See also
model

Definition at line 157 of file kcolorschememanager.cpp.

◆ model()

QAbstractItemModel * KColorSchemeManager::model ( ) const

A QAbstractItemModel of all available color schemes.

The model provides the name of the scheme in Qt::DisplayRole, a preview in Qt::DelegateRole and the full path to the scheme file in Qt::UserRole. The system theme has an empty Qt::UserRole.

Returns
Model of all available color schemes.

Definition at line 136 of file kcolorschememanager.cpp.

◆ saveSchemeToConfigFile()

void KColorSchemeManager::saveSchemeToConfigFile ( const QString schemeName) const

Saves the color scheme to config file.

The scheme is saved by default whenever it's changed. Use this method when autosaving is turned off, see setAutosaveChanges().

Since
5.89

Definition at line 225 of file kcolorschememanager.cpp.

◆ setAutosaveChanges()

void KColorSchemeManager::setAutosaveChanges ( bool  autosaveChanges)

Sets color scheme autosaving.

Default value is true. If this is set to false, the scheme is not going to be remembered when the application is restarted.

Parameters
autosaveChangesEnables/Disables autosaving of the color scheme.
Since
5.89

Definition at line 152 of file kcolorschememanager.cpp.


The documentation for this class was generated from the following files:
QAbstractItemModel * model() const
A QAbstractItemModel of all available color schemes.
void setMenu(QMenu *menu)
virtual void setModel(QAbstractItemModel *model)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
KActionMenu * createSchemeSelectionMenu(const QIcon &icon, const QString &text, const QString &selectedSchemeName, QObject *parent)
Creates a KActionMenu populated with all the available color schemes.
QMenu * menu() const const
void activated(const QModelIndex &index)
void activateScheme(const QModelIndex &index)
Activates the KColorScheme identified by the provided index.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 22 2023 03:48:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.