KQuickAddons::ManagedConfigModule

KQuickAddons::ManagedConfigModule Class Reference

#include <KQuickAddons/ManagedConfigModule>

Inheritance diagram for KQuickAddons::ManagedConfigModule:

Public Slots

void defaults () override
 
void load () override
 
void save () override
 
- Public Slots inherited from KQuickAddons::ConfigModule
virtual void defaults ()
 
virtual void load ()
 
void pop ()
 
void push (const QString &fileName, const QVariantMap &propertyMap=QVariantMap())
 
void push (QQuickItem *item)
 
virtual void save ()
 
void showPassiveNotification (const QString &message, const QVariant &timeout=QVariant(), const QString &actionText=QString(), const QJSValue &callBack=QJSValue())
 

Public Member Functions

 ManagedConfigModule (const KAboutData *aboutData, QObject *parent=nullptr, const QVariantList &args=QVariantList())
 
 ManagedConfigModule (const KPluginMetaData &metaData, QObject *parent=nullptr, const QVariantList &args=QVariantList())
 
 ManagedConfigModule (QObject *parent=nullptr, const QVariantList &args=QVariantList())
 
 ~ManagedConfigModule ()
 
- Public Member Functions inherited from KQuickAddons::ConfigModule
 ConfigModule (const KAboutData *aboutData, QObject *parent=nullptr, const QVariantList &args=QVariantList())
 
 ConfigModule (const KPluginMetaData &metaData, QObject *parent=nullptr, const QVariantList &args=QVariantList())
 
 ConfigModule (QObject *parent=nullptr, const QVariantList &args=QVariantList())
 
 ~ConfigModule ()
 
const KAboutDataaboutData () const
 
QString authActionName () const
 
Buttons buttons () const
 
int columnWidth () const
 
int currentIndex () const
 
int depth () const
 
QString description () const
 
QQmlEngineengine () const
 
QString errorString () const
 
QQuickItemmainUi ()
 
QString name () const
 
bool needsAuthorization () const
 
bool needsSave ()
 
QString quickHelp () const
 
bool representsDefaults ()
 
QString rootOnlyMessage () const
 
void setAboutData (const KAboutData *about)
 
void setAuthActionName (const QString &action)
 
void setButtons (const Buttons btn)
 
void setColumnWidth (int width)
 
void setCurrentIndex (int index)
 
void setNeedsAuthorization (bool needsAuth)
 
void setNeedsSave (bool needs)
 
void setQuickHelp (const QString &help)
 
void setRepresentsDefaults (bool defaults)
 
void setRootOnlyMessage (const QString &message)
 
void setUseRootOnlyMessage (bool on)
 
QQmlComponent::Status status () const
 
bool useRootOnlyMessage () 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 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
 
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 (QObject *object)
 
qobject_cast (const 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
 

Protected Slots

void registerSettings (KCoreConfigSkeleton *skeleton)
 
void settingsChanged ()
 

Additional Inherited Members

- Public Types inherited from KQuickAddons::ConfigModule
enum  Button { NoAdditionalButton = 0, Help = 1, Default = 2, Apply = 4 }
 
typedef QFlags< ButtonButtons
 
- Properties inherited from KQuickAddons::ConfigModule
KQuickAddons::ConfigModule::Buttons buttons
 
int columnWidth
 
int currentIndex
 
int depth
 
QString description
 
QQuickItem mainUi
 
QString name
 
bool needsAuthorization
 
bool needsSave
 
QString quickHelp
 
bool representsDefaults
 
QString rootOnlyMessage
 
bool useRootOnlyMessage
 
- Properties inherited from QObject
 objectName
 
- Signals inherited from KQuickAddons::ConfigModule
void authActionNameChanged ()
 
void buttonsChanged ()
 
void columnWidthChanged (int width)
 
void currentIndexChanged (int index)
 
void depthChanged (int index)
 
void needsAuthorizationChanged ()
 
void needsSaveChanged ()
 
void pagePushed (QQuickItem *page)
 
void pageRemoved ()
 
void passiveNotificationRequested (const QString &message, const QVariant &timeout, const QString &actionText, const QJSValue &callBack)
 
void quickHelpChanged ()
 
void representsDefaultsChanged ()
 
void rootOnlyMessageChanged ()
 
void useRootOnlyMessageChanged ()
 
- Static Public Member Functions inherited from KQuickAddons::ConfigModule
static ConfigModuleqmlAttachedProperties (QObject *object)
 
- 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 *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
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, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction 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)
 
- 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

The base class for configuration modules using KConfigXT settings.

Configuration modules are realized as plugins that are loaded only when needed.

The module in principle is a simple widget displaying the item to be changed. The module has a very small interface.

All the necessary glue logic and the GUI bells and whistles are provided by the control center and must not concern the module author.

To write a config module, you have to create a C++ library and an accompaning QML user interface. The library must contain a factory function like the following:

#include <KPluginFactory>
K_PLUGIN_FACTORY(MyConfigModuleFactory, registerPlugin<MyConfigModule>() )

The constructor of the ConfigModule then looks like this:

YourConfigModule::YourConfigModule( QObject* parent )
: ManagedConfigModule( parent ),
SettingsObject( this )
{
KAboutData *about = new KAboutData(
<kcm name>, i18n( "..." ),
KDE_VERSION_STRING, QString(), KAboutLicense::GPL,
i18n( "Copyright 2006 ..." ) );
about->addAuthor( i18n(...) );
setAboutData( about );
.
.
.
}

We are assuming here that SettingsObject is a class generated from a kcfg file and that it will be somehow exposed as a constant property to be used from the QML side. It will be automatically discovered by ManagedConfigModule which will update the saveNeeded and defaults inherited properties by itself. Thus by inheriting from this class you shall not try to manage those properties yourselves.

The QML part must be in the KPackage format, installed under share/kpackage/kcms.

See also
KPackage::Package The package must have the same name as the KAboutData componentName, to be installed by CMake with the command: kpackage_install_package(package kcm_componentName kcms) given "package" is the subdirectory in the source tree where the package sources are located, and "kcm_componentName" is the componentname passed to the KAboutData in the C++ part. The main config dialog UI will be the file ui/main.qml from the package (or what X-KPackage-MainScript value is in the package metadata desktop file).

The QML part can access all the properties of ManagedConfigModule (together with the properties defined in its subclass) by accessing to the global object "kcm", or with the import of "org.kde.kcm 1.0" the ConfigModule attached property.

import QtQuick 2.1
import QtQuick.Controls 1.0 as QtControls
import org.kde.kcm 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
//implicitWidth and implicitHeight will be used as initial size
//when loaded in kcmshell5
implicitWidth: units.gridUnit * 20
implicitHeight: units.gridUnit * 20
text: kcm.needsSave
}
}

See https://techbase.kde.org/Development/Tutorials/KCM_HowTo for more detailed documentation.

Since
5.65

Definition at line 123 of file managedconfigmodule.h.

Constructor & Destructor Documentation

KQuickAddons::ManagedConfigModule::ManagedConfigModule ( const KAboutData aboutData,
QObject parent = nullptr,
const QVariantList &  args = QVariantList() 
)
explicit

Base class for all modules which manage automatically some of their state.

Parameters
aboutDatabecomes owned by the ManagedConfigModule

Definition at line 46 of file managedconfigmodule.cpp.

KQuickAddons::ManagedConfigModule::ManagedConfigModule ( const KPluginMetaData metaData,
QObject parent = nullptr,
const QVariantList &  args = QVariantList() 
)
explicit
Parameters
metaDatadescription for the plugin: it will generate a KAboutData from that

Definition at line 52 of file managedconfigmodule.cpp.

KQuickAddons::ManagedConfigModule::ManagedConfigModule ( QObject parent = nullptr,
const QVariantList &  args = QVariantList() 
)
explicit

Base class for all KControlModules.

Note
do not emit changed signals here, since they are not yet connected to any slot.

Definition at line 58 of file managedconfigmodule.cpp.

KQuickAddons::ManagedConfigModule::~ManagedConfigModule ( )

Destroys the module.

Definition at line 64 of file managedconfigmodule.cpp.

Member Function Documentation

void KQuickAddons::ManagedConfigModule::defaults ( )
overrideslot

Sets the configuration to sensible default values.

This method is called when the user clicks the "Default" button. It should set the display to useful values.

By default this will reset to defaults the child setting objects of this module.

Definition at line 87 of file managedconfigmodule.cpp.

void KQuickAddons::ManagedConfigModule::load ( )
overrideslot

Load the configuration data into the module.

This method is invoked whenever the module should read its configuration (most of the times from a config file) and update the user interface. This happens when the user clicks the "Reset" button in the control center, to undo all of his changes and restore the currently valid settings. It is also called right after construction.

By default this will load the settings from the child setting objects of this module.

Definition at line 69 of file managedconfigmodule.cpp.

void KQuickAddons::ManagedConfigModule::registerSettings ( KCoreConfigSkeleton skeleton)
protectedslot

Allow to register manually settings class generated from a kcfg file.

Used by derived class when automatic discovery is not possible. After skeleton is registered it will automatically call settingsChanged().

Since
5.67

Definition at line 137 of file managedconfigmodule.cpp.

void KQuickAddons::ManagedConfigModule::save ( )
overrideslot

Save the configuration data.

The save method stores the config information as shown in the user interface in the config files. It is called when the user clicks "Apply" or "Ok".

By default this will save the child setting objects of this module.

Definition at line 78 of file managedconfigmodule.cpp.

void KQuickAddons::ManagedConfigModule::settingsChanged ( )
protectedslot

Forces the module to reevaluate the saveNeeded and representsDefault state.

This is required for some modules which might have some settings managed outside of KConfigXT objects.

Definition at line 114 of file managedconfigmodule.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jul 13 2020 22:38:37 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.