KColorSchemeManager
#include <KColorSchemeManager>

Public Slots | |
void | activateScheme (const QModelIndex &index) |
Public Member Functions | |
KColorSchemeManager (QObject *parent=nullptr) | |
QString | activeSchemeId () const |
KActionMenu * | createSchemeSelectionMenu (const QIcon &icon, const QString &text, const QString &selectedSchemeName, QObject *parent) |
KActionMenu * | createSchemeSelectionMenu (const QString &selectedSchemeName, QObject *parent) |
KActionMenu * | createSchemeSelectionMenu (const QString &text, const QString &selectedSchemeName, QObject *parent) |
KActionMenu * | createSchemeSelectionMenu (QObject *parent) |
QModelIndex | indexForScheme (const QString &name) const |
QAbstractItemModel * | model () const |
void | saveSchemeToConfigFile (const QString &schemeName) const |
void | setAutosaveChanges (bool autosaveChanges) |
![]() | |
QObject (QObject *parent) | |
bool | blockSignals (bool block) |
const QObjectList & | children () 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< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, 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 QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () 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 | |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
T | qobject_cast (const QObject *object) |
T | 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) |
QThread * | thread () const const |
Additional Inherited Members | |
![]() | |
objectName | |
![]() | |
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) |
![]() | |
typedef | QObjectList |
![]() | |
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 |
QObject * | sender () 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:
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:
- Since
- 5.0
Definition at line 55 of file kcolorschememanager.h.
Member Function Documentation
◆ activateScheme
|
slot |
Activates the KColorScheme identified by the provided index
.
Installs the KColorScheme as the QApplication's QPalette.
- Parameters
-
index The 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
-
icon The icon to use for the KActionMenu text The text to use for the KActionMenu selectedSchemeName The name of the color scheme to select parent The 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
-
autosaveChanges Enables/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:
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.