kutils: format and indent

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-30 09:44:43 +03:00
parent 833951fbc3
commit 48e591141b
10 changed files with 670 additions and 662 deletions

View file

@ -42,155 +42,146 @@
/***********************************************************************/ /***********************************************************************/
class KCModuleContainer::KCModuleContainerPrivate class KCModuleContainer::KCModuleContainerPrivate
{ {
public: public:
KCModuleContainerPrivate( const QStringList& mods ) KCModuleContainerPrivate(const QStringList &mods)
: modules( mods ) : modules(mods),
, tabWidget( 0 ) tabWidget(nullptr),
, topLayout( 0 ) topLayout(nullptr)
{} {
}
QStringList modules;
KTabWidget *tabWidget;
KCModule::Buttons buttons;
QVBoxLayout *topLayout;
QStringList modules;
KTabWidget *tabWidget;
KCModule::Buttons buttons;
QVBoxLayout *topLayout;
}; };
/***********************************************************************/ /***********************************************************************/
// The KCModuleContainer is only a wrapper around real KCModules. Therefore it doesn't need a // The KCModuleContainer is only a wrapper around real KCModules. Therefore it doesn't need a
// special KComponentData and can just use the global instance. The contained KCModules create their own // special KComponentData and can just use the global instance. The contained KCModules create their own
// KComponentData objects when needed. // KComponentData objects when needed.
/***********************************************************************/ /***********************************************************************/
KCModuleContainer::KCModuleContainer( QWidget* parent, const QString& mods ) KCModuleContainer::KCModuleContainer(QWidget *parent, const QString &mods)
: KCModule( KGlobal::mainComponent(), parent ), : KCModule( KGlobal::mainComponent(), parent ),
d(new KCModuleContainerPrivate( QString(mods).remove( ' ' ).split( ',', QString::SkipEmptyParts ) )) d(new KCModuleContainerPrivate(QString(mods).remove(' ').split(',', QString::SkipEmptyParts)))
{ {
init(); init();
} }
KCModuleContainer::KCModuleContainer( QWidget* parent, const QStringList& mods ) KCModuleContainer::KCModuleContainer(QWidget *parent, const QStringList &mods)
: KCModule( KGlobal::mainComponent(), parent ), : KCModule( KGlobal::mainComponent(), parent),
d( new KCModuleContainerPrivate( mods ) ) d(new KCModuleContainerPrivate(mods))
{ {
init(); init();
} }
void KCModuleContainer::init() void KCModuleContainer::init()
{ {
d->topLayout = new QVBoxLayout( this ); d->topLayout = new QVBoxLayout(this);
d->topLayout->setMargin( 0 ); d->topLayout->setMargin(0);
d->topLayout->setObjectName( "topLayout" ); d->topLayout->setObjectName("topLayout");
d->tabWidget = new KTabWidget(this); d->tabWidget = new KTabWidget(this);
d->tabWidget->setObjectName( "tabWidget"); d->tabWidget->setObjectName("tabWidget");
connect( d->tabWidget, SIGNAL(currentChanged(int)), SLOT(tabSwitched(int))); connect(d->tabWidget, SIGNAL(currentChanged(int)), SLOT(tabSwitched(int)));
d->topLayout->addWidget( d->tabWidget ); d->topLayout->addWidget(d->tabWidget);
if ( !d->modules.isEmpty() ) if (!d->modules.isEmpty()) {
{ /* Add our modules */
/* Add our modules */ foreach (const QString it, d->modules) {
foreach (const QString it, d->modules ) addModule(it);
addModule( it ); }
} }
} }
void KCModuleContainer::addModule( const QString& module ) void KCModuleContainer::addModule(const QString &module)
{ {
/* In case it doesn't exist we just silently drop it. /* In case it doesn't exist we just silently drop it.
* This allows people to easily extend containers. * This allows people to easily extend containers.
* For example, KCM monitor gamma can be in kdegraphics. * For example, KCM monitor gamma can be in kdegraphics.
*/ */
KService::Ptr service = KService::serviceByDesktopName( module ); KService::Ptr service = KService::serviceByDesktopName(module);
if ( !service ) if (!service) {
{ kDebug(713) << "KCModuleContainer: module '"
kDebug(713) << "KCModuleContainer: module '" << << module << "' was not found and thus not loaded";
module << "' was not found and thus not loaded"; return;
return; }
}
if ( service->noDisplay() ) if (service->noDisplay()) {
return; return;
}
KCModuleProxy* proxy = new KCModuleProxy( service, d->tabWidget ); KCModuleProxy* proxy = new KCModuleProxy(service, d->tabWidget);
allModules.append( proxy ); allModules.append(proxy);
proxy->setObjectName( module.toLatin1() ); proxy->setObjectName(module.toLatin1());
d->tabWidget->addTab( proxy, KIcon( proxy->moduleInfo().icon() ), d->tabWidget->addTab(
/* Qt eats ampersands for dinner. But not this time. */ proxy, KIcon(proxy->moduleInfo().icon()),
proxy->moduleInfo().moduleName().replace( '&', "&&" )); /* Katie eats ampersands for dinner. But not this time. */
proxy->moduleInfo().moduleName().replace('&', "&&")
);
d->tabWidget->setTabToolTip( d->tabWidget->indexOf( proxy ), proxy->moduleInfo().comment() ); d->tabWidget->setTabToolTip(d->tabWidget->indexOf(proxy), proxy->moduleInfo().comment());
connect( proxy, SIGNAL(changed(KCModuleProxy*)), SLOT(moduleChanged(KCModuleProxy*))); connect(proxy, SIGNAL(changed(KCModuleProxy*)), SLOT(moduleChanged(KCModuleProxy*)));
/* Collect our buttons - we go for the common deliminator */ /* Collect our buttons - we go for the common deliminator */
setButtons( buttons() | proxy->realModule()->buttons() ); setButtons(buttons() | proxy->realModule()->buttons());
} }
void KCModuleContainer::tabSwitched(int index) void KCModuleContainer::tabSwitched(int index)
{ {
KCModuleProxy* mod = static_cast<KCModuleProxy *>(d->tabWidget->widget(index)); KCModuleProxy* mod = static_cast<KCModuleProxy*>(d->tabWidget->widget(index));
setQuickHelp( mod->quickHelp() ); setQuickHelp(mod->quickHelp());
setAboutData( mod->aboutData() ); setAboutData(mod->aboutData());
} }
void KCModuleContainer::save() void KCModuleContainer::save()
{ {
ModuleList list = changedModules; ModuleList list = changedModules;
ModuleList::iterator it; ModuleList::iterator it;
for ( it = list.begin() ; it !=list.end() ; ++it ) for ( it = list.begin() ; it !=list.end() ; ++it ) {
{ (*it)->save();
(*it)->save(); }
}
emit changed( false ); emit changed( false );
} }
void KCModuleContainer::load() void KCModuleContainer::load()
{ {
ModuleList list = allModules; ModuleList list = allModules;
ModuleList::iterator it; ModuleList::iterator it;
for ( it = list.begin() ; it !=list.end() ; ++it ) for ( it = list.begin() ; it !=list.end() ; ++it ) {
{ (*it)->load();
(*it)->load(); }
}
emit changed( false ); emit changed( false );
} }
void KCModuleContainer::defaults() void KCModuleContainer::defaults()
{ {
ModuleList list = allModules; ModuleList list = allModules;
ModuleList::iterator it; ModuleList::iterator it;
for ( it = list.begin() ; it !=list.end() ; ++it ) for (it = list.begin() ; it !=list.end() ; ++it) {
{ (*it)->defaults();
(*it)->defaults(); }
}
emit changed( true ); emit changed( true );
} }
void KCModuleContainer::moduleChanged(KCModuleProxy *proxy)
void KCModuleContainer::moduleChanged(KCModuleProxy * proxy)
{ {
changedModules.append( proxy ); changedModules.append(proxy);
if( changedModules.isEmpty() ) if (changedModules.isEmpty()) {
return; return;
}
emit changed(true); emit changed(true);
} }
KCModuleContainer::~KCModuleContainer() KCModuleContainer::~KCModuleContainer()
{ {
delete d; delete d;
} }
/***********************************************************************/

View file

@ -33,14 +33,19 @@
class KCModuleInfo::Private class KCModuleInfo::Private
{ {
public: public:
Private(); Private();
Private( KService::Ptr ); Private(KService::Ptr s);
QStringList keywords; QStringList keywords;
QString name, icon, lib, fileName, doc, comment; QString name;
bool allLoaded; QString icon;
int weight; QString lib;
QString fileName;
QString doc;
QString comment;
bool allLoaded;
int weight;
KService::Ptr service; KService::Ptr service;
@ -55,131 +60,130 @@ KCModuleInfo::Private::Private()
{ {
} }
KCModuleInfo::Private::Private( KService::Ptr s ) KCModuleInfo::Private::Private(KService::Ptr s)
: allLoaded( false ) : allLoaded(false),
, service( s ) service(s)
{ {
if ( !service ) if (!service) {
{ kDebug(712) << "Could not find the service.";
kDebug(712) << "Could not find the service."; return;
return; }
}
// set the modules simple attributes // set the modules simple attributes
name = service->name(); name = service->name();
comment = service->comment(); comment = service->comment();
icon = service->icon(); icon = service->icon();
fileName = service->entryPath(); fileName = service->entryPath();
lib = service->library(); lib = service->library();
keywords = service->keywords(); keywords = service->keywords();
} }
KCModuleInfo::KCModuleInfo() KCModuleInfo::KCModuleInfo()
: d(new Private())
{ {
d = new Private;
} }
KCModuleInfo::KCModuleInfo(const QString& desktopFile) KCModuleInfo::KCModuleInfo(const QString &desktopFile)
: d(new Private(KService::serviceByStorageId(desktopFile)))
{ {
d = new Private( KService::serviceByStorageId(desktopFile) );
} }
KCModuleInfo::KCModuleInfo( KService::Ptr moduleInfo ) KCModuleInfo::KCModuleInfo(KService::Ptr moduleInfo)
: d(new Private(moduleInfo))
{ {
d = new Private( moduleInfo );
} }
KCModuleInfo::KCModuleInfo( const KCModuleInfo &rhs ) KCModuleInfo::KCModuleInfo(const KCModuleInfo &rhs)
: d(new Private())
{ {
d = new Private; (*this) = rhs;
( *this ) = rhs;
} }
KCModuleInfo &KCModuleInfo::operator=( const KCModuleInfo &rhs ) KCModuleInfo &KCModuleInfo::operator=(const KCModuleInfo &rhs)
{ {
*d = *(rhs.d); *d = *(rhs.d);
return *this; return *this;
} }
bool KCModuleInfo::operator==( const KCModuleInfo & rhs ) const bool KCModuleInfo::operator==(const KCModuleInfo &rhs) const
{ {
return ( ( d->name == rhs.d->name ) && ( d->lib == rhs.d->lib ) && ( d->fileName == rhs.d->fileName ) ); return ((d->name == rhs.d->name) && (d->lib == rhs.d->lib) && (d->fileName == rhs.d->fileName));
} }
bool KCModuleInfo::operator!=( const KCModuleInfo & rhs ) const bool KCModuleInfo::operator!=(const KCModuleInfo &rhs) const
{ {
return ! operator==( rhs ); return !operator==(rhs);
} }
KCModuleInfo::~KCModuleInfo() KCModuleInfo::~KCModuleInfo()
{ {
delete d; delete d;
} }
void KCModuleInfo::Private::loadAll() void KCModuleInfo::Private::loadAll()
{ {
allLoaded = true; allLoaded = true;
if( !service ) /* We have a bogus service. All get functions will return empty/zero values */ if (!service) {
return; /* We have a bogus service. All get functions will return empty/zero values */
return;
}
// get the documentation path // get the documentation path
doc = service->property( "X-DocPath", QVariant::String ).toString(); doc = service->property("X-DocPath", QVariant::String).toString();
// read weight // read weight
QVariant tmp = service->property( "X-KDE-Weight", QVariant::Int ); QVariant tmp = service->property("X-KDE-Weight", QVariant::Int);
weight = tmp.isValid() ? tmp.toInt() : 100; weight = tmp.isValid() ? tmp.toInt() : 100;
} }
QString KCModuleInfo::fileName() const QString KCModuleInfo::fileName() const
{ {
return d->fileName; return d->fileName;
} }
QStringList KCModuleInfo::keywords() const QStringList KCModuleInfo::keywords() const
{ {
return d->keywords; return d->keywords;
} }
QString KCModuleInfo::moduleName() const QString KCModuleInfo::moduleName() const
{ {
return d->name; return d->name;
} }
KService::Ptr KCModuleInfo::service() const KService::Ptr KCModuleInfo::service() const
{ {
return d->service; return d->service;
} }
QString KCModuleInfo::comment() const QString KCModuleInfo::comment() const
{ {
return d->comment; return d->comment;
} }
QString KCModuleInfo::icon() const QString KCModuleInfo::icon() const
{ {
return d->icon; return d->icon;
} }
QString KCModuleInfo::library() const QString KCModuleInfo::library() const
{ {
return d->lib; return d->lib;
} }
QString KCModuleInfo::docPath() const QString KCModuleInfo::docPath() const
{ {
if (!d->allLoaded) if (!d->allLoaded) {
d->loadAll(); d->loadAll();
}
return d->doc; return d->doc;
} }
int KCModuleInfo::weight() const int KCModuleInfo::weight() const
{ {
if (!d->allLoaded) if (!d->allLoaded) {
d->loadAll(); d->loadAll();
}
return d->weight; return d->weight;
} }
// vim: ts=2 sw=2 et

View file

@ -44,114 +44,110 @@
* @author Daniel Molkentin <molkentin@kde.org> * @author Daniel Molkentin <molkentin@kde.org>
* *
*/ */
class KCMUTILS_EXPORT KCModuleInfo // krazy:exclude=dpointer (implicitly shared) class KCMUTILS_EXPORT KCModuleInfo
{ {
public: public:
/**
* Constructs a KCModuleInfo.
* @note a KCModuleInfo object will have to be manually deleted, it is not
* done automatically for you.
* @param desktopFile the desktop file representing the module, or
* the name of the module.
*/
KCModuleInfo(const QString &desktopFile);
/** /**
* Constructs a KCModuleInfo. * Same as above but takes a KService::Ptr as argument.
* @note a KCModuleInfo object will have to be manually deleted, it is not *
* done automatically for you. * @note @p moduleInfo must be a valid pointer.
* @param desktopFile the desktop file representing the module, or *
* the name of the module. * @param moduleInfo specifies the module
*/ */
KCModuleInfo(const QString& desktopFile); KCModuleInfo(KService::Ptr moduleInfo);
/**
* Same as above but takes a KService::Ptr as argument.
*
* @note @p moduleInfo must be a valid pointer.
*
* @param moduleInfo specifies the module
*/
KCModuleInfo( KService::Ptr moduleInfo );
/** /**
* Same as above but takes a KCModuleInfo as argument. * Same as above but takes a KCModuleInfo as argument.
* *
* @param rhs specifies the module * @param rhs specifies the module
*/ */
KCModuleInfo( const KCModuleInfo &rhs ); KCModuleInfo(const KCModuleInfo &rhs);
/** /**
* Same as above but creates an empty KCModuleInfo. * Same as above but creates an empty KCModuleInfo.
* You should not normally call this. * You should not normally call this.
*/ */
KCModuleInfo(); KCModuleInfo();
/** /**
* Assignment operator * Assignment operator
*/ */
KCModuleInfo &operator=( const KCModuleInfo &rhs ); KCModuleInfo &operator=(const KCModuleInfo &rhs);
/** /**
* Returns true if @p rhs describes the same KCModule as this object. * Returns true if @p rhs describes the same KCModule as this object.
*/ */
bool operator==( const KCModuleInfo &rhs ) const; bool operator==(const KCModuleInfo &rhs) const;
/** /**
* @return true if @p rhs is not equal itself * @return true if @p rhs is not equal itself
*/ */
bool operator!=( const KCModuleInfo &rhs ) const; bool operator!=(const KCModuleInfo &rhs) const;
/** /**
* Default destructor. * Default destructor.
*/ */
~KCModuleInfo(); ~KCModuleInfo();
/** /**
* @return the filename of the .desktop file that describes the KCM * @return the filename of the .desktop file that describes the KCM
*/ */
QString fileName() const; QString fileName() const;
/** /**
* @return the keywords associated with this KCM. * @return the keywords associated with this KCM.
*/ */
QStringList keywords() const; QStringList keywords() const;
/** /**
* @return the module\'s (translated) name * @return the module\'s (translated) name
*/ */
QString moduleName() const; QString moduleName() const;
/** /**
* @return a KSharedPtr to KService created from the modules .desktop file * @return a KSharedPtr to KService created from the modules .desktop file
*/ */
KService::Ptr service() const; KService::Ptr service() const;
/** /**
* @return the module's (translated) comment field * @return the module's (translated) comment field
*/ */
QString comment() const; QString comment() const;
/** /**
* @return the module's icon name * @return the module's icon name
*/ */
QString icon() const; QString icon() const;
/** /**
* @return the path of the module's documentation * @return the path of the module's documentation
*/ */
QString docPath() const; QString docPath() const;
/** /**
* @return the library name * @return the library name
*/ */
QString library() const; QString library() const;
/** /**
* @return the weight of the module which determines the order of the pages in * @return the weight of the module which determines the order of the pages in
* the KCMultiDialog. It's set by the X-KDE-Weight field. * the KCMultiDialog. It's set by the X-KDE-Weight field.
*/ */
int weight() const; int weight() const;
private: private:
class Private; class Private;
Private * d; Private *d;
}; };
#endif // KCMODULEINFO_H #endif // KCMODULEINFO_H
// vim: ts=2 sw=2 et

View file

@ -41,44 +41,60 @@ using namespace KCModuleLoader;
class KCMError : public KCModule class KCMError : public KCModule
{ {
public: public:
KCMError( const QString& msg, const QString& details, QWidget* parent ) KCMError(const QString &msg, const QString &details, QWidget *parent)
: KCModule( KGlobal::mainComponent(), parent ) : KCModule(KGlobal::mainComponent(), parent)
{ {
QVBoxLayout* topLayout = new QVBoxLayout( this ); QVBoxLayout* topLayout = new QVBoxLayout(this);
QLabel *lab = new QLabel( msg, this ); QLabel *lab = new QLabel(msg, this);
lab->setWordWrap(true); lab->setWordWrap(true);
topLayout->addWidget( lab ); topLayout->addWidget(lab);
lab = new QLabel(details, this ); lab = new QLabel(details, this);
lab->setWordWrap(true); lab->setWordWrap(true);
topLayout->addWidget( lab ); topLayout->addWidget(lab);
} }
}; };
/***************************************************************/ /***************************************************************/
KCModule *KCModuleLoader::loadModule(const QString &module, ErrorReporting report, QWidget *parent, const QStringList &args) KCModule *KCModuleLoader::loadModule(const QString &module, ErrorReporting report,
QWidget *parent, const QStringList &args)
{ {
return loadModule( KCModuleInfo( module ), report, parent, args ); return loadModule(KCModuleInfo(module), report, parent, args);
} }
KCModule* KCModuleLoader::loadModule(const KCModuleInfo& mod, ErrorReporting report, QWidget* parent, const QStringList& args ) KCModule* KCModuleLoader::loadModule(const KCModuleInfo &mod, ErrorReporting report,
QWidget *parent, const QStringList &args)
{ {
/* /*
* Simple libraries as modules are the easiest case: * Simple libraries as modules are the easiest case:
* We just have to load the library and get the module * We just have to load the library and get the module
* from the factory. * from the factory.
*/ */
if ( !mod.service() ) if (!mod.service()) {
return reportError( report, return reportError(
i18n("The module %1 could not be found.", report,
mod.moduleName() ), i18n("<qt><p>The diagnosis is:<br />The desktop file %1 could not be found.</p></qt>", mod.fileName()), parent ); i18n(
if( mod.service()->noDisplay() ) "The module %1 could not be found.",
return reportError( report, i18n( "The module %1 is disabled.", mod.moduleName() ), mod.moduleName()
i18n( "<qt><p>Either the hardware/software the module configures is not available or the module has been disabled by the administrator.</p></qt>" ), ),
parent ); i18n(
"<qt><p>The diagnosis is:<br />The desktop file %1 could not be found.</p></qt>", mod.fileName()
),
parent
);
}
if (mod.service()->noDisplay()) {
return reportError(
report,
i18n("The module %1 is disabled.", mod.moduleName()),
i18n(
"<qt><p>Either the hardware/software the module configures is not available or the module has been disabled by the administrator.</p></qt>"
),
parent
);
}
if (!mod.library().isEmpty()) if (!mod.library().isEmpty()) {
{
QString error; QString error;
QVariantList args2; QVariantList args2;
foreach (const QString &arg, args) { foreach (const QString &arg, args) {
@ -89,31 +105,36 @@ KCModule* KCModuleLoader::loadModule(const KCModuleInfo& mod, ErrorReporting rep
return module; return module;
} }
return reportError(report, error, QString(), parent); return reportError(report, error, QString(), parent);
} }
/* /*
* Ok, we could not load the library. * Ok, we could not load the library.
* Try to run it as an executable. * Try to run it as an executable.
* This must not be done when calling from kcmshell, or you'll * This must not be done when calling from kcmshell, or you'll
* have infinite recursion * have infinite recursion
* (startService calls kcmshell which calls modloader which calls startService...) * (startService calls kcmshell which calls modloader which calls startService...)
* *
*/ */
return reportError( report, return reportError(
i18n("The module %1 is not a valid configuration module.", mod.moduleName() ), report,
i18n("<qt>The diagnosis is:<br />The desktop file %1 does not specify a library.</qt>", mod.fileName()), parent ); i18n("The module %1 is not a valid configuration module.", mod.moduleName()),
i18n("<qt>The diagnosis is:<br />The desktop file %1 does not specify a library.</qt>", mod.fileName()),
parent
);
} }
KCModule* KCModuleLoader::reportError( ErrorReporting report, const QString & text, KCModule* KCModuleLoader::reportError(ErrorReporting report, const QString &text,
const QString &details, QWidget * parent ) const QString &details, QWidget *parent)
{ {
QString realDetails = details; QString realDetails = details;
if (realDetails.isNull()) { if (realDetails.isNull()) {
realDetails = i18n("<qt><p>Possible reasons:<ul><li>An error occurred during your last " realDetails = i18n(
"KDE upgrade leaving an orphaned control module</li><li>You have old third party " "<qt><p>Possible reasons:<ul><li>An error occurred during your last "
"modules lying around.</li></ul></p><p>Check these points carefully and try to remove " "KDE upgrade leaving an orphaned control module</li><li>You have old third party "
"the module mentioned in the error message. If this fails, consider contacting " "modules lying around.</li></ul></p><p>Check these points carefully and try to remove "
"your distributor or packager.</p></qt>"); "the module mentioned in the error message. If this fails, consider contacting "
"your distributor or packager.</p></qt>"
);
} }
if (report & KCModuleLoader::Dialog) { if (report & KCModuleLoader::Dialog) {
KMessageBox::detailedError(parent, text, realDetails); KMessageBox::detailedError(parent, text, realDetails);
@ -121,7 +142,5 @@ KCModule* KCModuleLoader::reportError( ErrorReporting report, const QString & te
if (report & KCModuleLoader::Inline) { if (report & KCModuleLoader::Inline) {
return new KCMError(text, realDetails, parent); return new KCMError(text, realDetails, parent);
} }
return 0; return nullptr;
} }
// vim: ts=4

View file

@ -46,23 +46,23 @@ namespace KCModuleLoader
* Determines the way errors are reported * Determines the way errors are reported
*/ */
enum ErrorReporting { enum ErrorReporting {
/** /**
* no error reporting is done * no error reporting is done
* */ */
None = 0, None = 0,
/** /**
* the error report is shown instead of the * the error report is shown instead of the
* KCModule that should have been loaded * KCModule that should have been loaded
*/ */
Inline = 1, Inline = 1,
/** /**
* shows a dialog with the error report * shows a dialog with the error report
*/ */
Dialog = 2, Dialog = 2,
/** /**
* does both Inline and Dialog * does both Inline and Dialog
*/ */
Both = 3 Both = 3
}; };
/** /**
@ -72,8 +72,8 @@ namespace KCModuleLoader
* *
* @return a pointer to the loaded @ref KCModule * @return a pointer to the loaded @ref KCModule
*/ */
KCMUTILS_EXPORT KCModule *loadModule(const KCModuleInfo &module, ErrorReporting KCMUTILS_EXPORT KCModule* loadModule(const KCModuleInfo &module, ErrorReporting report,
report, QWidget * parent = 0, const QStringList& args = QStringList() ); QWidget *parent = nullptr, const QStringList &args = QStringList());
/** /**
* Loads a @ref KCModule. If loading fails a zero pointer is returned. * Loads a @ref KCModule. If loading fails a zero pointer is returned.
@ -83,8 +83,8 @@ namespace KCModuleLoader
* *
* @return a pointer to the loaded @ref KCModule * @return a pointer to the loaded @ref KCModule
*/ */
KCMUTILS_EXPORT KCModule *loadModule( const QString &module, ErrorReporting report, KCMUTILS_EXPORT KCModule* loadModule(const QString &module, ErrorReporting report,
QWidget *parent = 0, const QStringList& args = QStringList() ); QWidget *parent = nullptr, const QStringList &args = QStringList());
/** /**
* Returns a KCModule containing the messages @p report and @p text. * Returns a KCModule containing the messages @p report and @p text.
@ -95,9 +95,8 @@ namespace KCModuleLoader
* *
* @internal * @internal
*/ */
KCMUTILS_EXPORT KCModule* reportError( ErrorReporting report, const QString & text, KCMUTILS_EXPORT KCModule* reportError(ErrorReporting report, const QString &text,
const QString &details, QWidget * parent ); const QString &details, QWidget *parent);
} }
// vim: ts=2 sw=2 et
#endif // KCMODULELOADER_H #endif // KCMODULELOADER_H

View file

@ -44,123 +44,136 @@
TODO: TODO:
- Two Layout problems in runAsRoot: - Two Layout problems in runAsRoot:
* lblBusy doesn't show * lblBusy doesn't show
* d->kcm/d->rootInfo doesn't get it right when the user * d->kcm/d->rootInfo doesn't get it right when the user presses cancel in the kdesudo dialog
presses cancel in the kdesudo dialog
- Resizing horizontally is contrained; minimum size is set somewhere. - Resizing horizontally is contrained; minimum size is set somewhere.
It appears to be somehow derived from the module's size. It appears to be somehow derived from the module's size.
- Prettify: set icon in KCMultiDialog. - Prettify: set icon in KCMultiDialog.
*/ */
/***************************************************************/ /***************************************************************/
KCModule* KCModuleProxy::realModule() const KCModule* KCModuleProxy::realModule() const
{ {
Q_D(const KCModuleProxy); Q_D(const KCModuleProxy);
/* /*
* Note, don't call any function that calls realModule() since * Note, don't call any function that calls realModule() since
* that leads to an infinite loop. * that leads to an infinite loop.
*/ */
/* Already loaded */ /* Already loaded */
if( !d->kcm ) if (!d->kcm) {
{ QApplication::setOverrideCursor(Qt::WaitCursor);
QApplication::setOverrideCursor( Qt::WaitCursor ); const_cast<KCModuleProxyPrivate*>(d)->loadModule();
const_cast<KCModuleProxyPrivate *>(d)->loadModule(); QApplication::restoreOverrideCursor();
QApplication::restoreOverrideCursor(); }
} return d->kcm;
return d->kcm;
} }
void KCModuleProxyPrivate::loadModule() void KCModuleProxyPrivate::loadModule()
{ {
if( !topLayout ) if (!topLayout) {
{ topLayout = new QVBoxLayout(parent);
topLayout = new QVBoxLayout( parent ); topLayout->setMargin(0);
topLayout->setMargin( 0 );
QString name = modInfo.library(); QString name = modInfo.library();
name.replace("-", "_"); //hyphen is not allowed in dbus, only [A-Z][a-z][0-9]_ name.replace("-", "_"); //hyphen is not allowed in dbus, only [A-Z][a-z][0-9]_
dbusPath = QLatin1String("/internal/KSettingsWidget/") + name; dbusPath = QLatin1String("/internal/KSettingsWidget/") + name;
dbusService = QLatin1String("org.kde.internal.KSettingsWidget_") + name; dbusService = QLatin1String("org.kde.internal.KSettingsWidget_") + name;
} }
if( QDBusConnection::sessionBus().registerService( dbusService ) || bogusOccupier ) if (QDBusConnection::sessionBus().registerService(dbusService) || bogusOccupier) {
{ /* We got the name we requested, because no one was before us, /* We got the name we requested, because no one was before us,
* or, it was an random application which had picked that name */ * or, it was an random application which had picked that name
kDebug(711) << "Module not already loaded, loading module " << modInfo.moduleName() << " from library " << modInfo.library(); */
kDebug(711) << "Module not already loaded, loading module " << modInfo.moduleName()
<< " from library " << modInfo.library();
kcm = KCModuleLoader::loadModule( modInfo, KCModuleLoader::Inline, parent, args ); kcm = KCModuleLoader::loadModule(modInfo, KCModuleLoader::Inline, parent, args);
QObject::connect(kcm, SIGNAL(changed(bool)), parent, SLOT(_k_moduleChanged(bool))); QObject::connect(kcm, SIGNAL(changed(bool)), parent, SLOT(_k_moduleChanged(bool)));
QObject::connect(kcm, SIGNAL(destroyed()), parent, SLOT(_k_moduleDestroyed())); QObject::connect(kcm, SIGNAL(destroyed()), parent, SLOT(_k_moduleDestroyed()));
QObject::connect( kcm, SIGNAL(quickHelpChanged()), parent, SIGNAL(quickHelpChanged()) ); QObject::connect(kcm, SIGNAL(quickHelpChanged()), parent, SIGNAL(quickHelpChanged()));
parent->setWhatsThis( kcm->quickHelp() ); parent->setWhatsThis(kcm->quickHelp());
if ( kcm->layout() ) { if (kcm->layout()) {
kcm->layout()->setMargin( 0 ); kcm->layout()->setMargin(0);
} }
topLayout->addWidget( kcm ); topLayout->addWidget( kcm );
if( !modInfo.library().isEmpty() ) if (!modInfo.library().isEmpty()) {
QDBusConnection::sessionBus().registerObject(dbusPath, new KSettingsWidgetAdaptor(parent), QDBusConnection::ExportAllSlots); QDBusConnection::sessionBus().registerObject(
dbusPath, new KSettingsWidgetAdaptor(parent), QDBusConnection::ExportAllSlots
);
}
if ( !rootInfo && /* If it's not already done */ if (!rootInfo && /* If it's not already done */
kcm->useRootOnlyMessage() && /* kcm wants root message */ kcm->useRootOnlyMessage() && /* kcm wants root message */
!KUser().isSuperUser() ) /* Not necessary if we're root */ !KUser().isSuperUser() ) /* Not necessary if we're root */
{ {
/*rootInfo = new QLabel( parent ); #if 0
topLayout->insertWidget( 0, rootInfo ); rootInfo = new QLabel(parent);
topLayout->insertWidget(0, rootInfo);
QPalette palette = rootInfo->palette();
KStatefulBrush stbrush(KColorScheme::Window, KColorScheme::NeutralBackground);
qDebug() << stbrush.brush(rootInfo);
palette.setBrush(QPalette::Window, stbrush.brush(rootInfo));
rootInfo->setPalette(palette);
rootInfo->setAutoFillBackground(true);
const QString message = kcm->rootOnlyMessage(); QPalette palette = rootInfo->palette();
if( message.isEmpty() ) KStatefulBrush stbrush(KColorScheme::Window, KColorScheme::NeutralBackground);
rootInfo->setText( i18n( qDebug() << stbrush.brush(rootInfo);
"<b>Changes in this section require root access.</b><br />" palette.setBrush(QPalette::Window, stbrush.brush(rootInfo));
"On applying your changes you will have to supply your root " rootInfo->setPalette(palette);
"password." ) ); rootInfo->setAutoFillBackground(true);
else
rootInfo->setText(message);
rootInfo->setWhatsThis( i18n( const QString message = kcm->rootOnlyMessage();
"This section requires special permissions, probably " if (message.isEmpty() )
"for system-wide changes; therefore, it is " rootInfo->setText(
"required that you provide the root password to be " i18n(
"able to change the module's properties. If " "<b>Changes in this section require root access.</b><br />"
"you cannot provide the password, the changes of the " "On applying your changes you will have to supply your root "
"module cannot be saved " ) );*/ "password." )
} );
} } else {
else rootInfo->setText(message);
{ }
kDebug(711) << "Module already loaded, loading KCMError";
/* Figure out the name of where the module is already loaded */ rootInfo->setWhatsThis(
QDBusInterface proxy( dbusService, dbusPath, "org.kde.internal.KSettingsWidget" ); i18n(
QDBusReply<QString> reply = proxy.call("applicationName"); "This section requires special permissions, probably "
"for system-wide changes; therefore, it is "
"required that you provide the root password to be "
"able to change the module's properties. If "
"you cannot provide the password, the changes of the "
"module cannot be saved "
)
);
#endif
}
} else {
kDebug(711) << "Module already loaded, loading KCMError";
if( reply.isValid() ) /* Figure out the name of where the module is already loaded */
{ QDBusInterface proxy(dbusService, dbusPath, "org.kde.internal.KSettingsWidget");
QObject::connect( QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)), QDBusReply<QString> reply = proxy.call("applicationName");
parent, SLOT(_k_ownerChanged(QString,QString,QString)));
kcm = KCModuleLoader::reportError( KCModuleLoader::Inline, if (reply.isValid()) {
i18nc( "Argument is application name", "This configuration section is " QObject::connect(
"already opened in %1" , reply.value() ), " ", parent ); QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
topLayout->addWidget( kcm ); parent, SLOT(_k_ownerChanged(QString,QString,QString))
} );
else kcm = KCModuleLoader::reportError(
{ KCModuleLoader::Inline,
kDebug(711) << "Calling KCModuleProxy's DBus interface for fetching the name failed."; i18nc(
bogusOccupier = true; "Argument is application name", "This configuration section is "
loadModule(); "already opened in %1", reply.value()
} ),
} " ",
parent
);
topLayout->addWidget(kcm);
} else {
kDebug(711) << "Calling KCModuleProxy's DBus interface for fetching the name failed.";
bogusOccupier = true;
loadModule();
}
}
} }
void KCModuleProxyPrivate::_k_ownerChanged(const QString &service, const QString &oldOwner, const QString &) void KCModuleProxyPrivate::_k_ownerChanged(const QString &service, const QString &oldOwner, const QString &)
@ -169,7 +182,7 @@ void KCModuleProxyPrivate::_k_ownerChanged(const QString &service, const QString
// Violence: Get rid of KCMError & CO, so that // Violence: Get rid of KCMError & CO, so that
// realModule() attempts to reload the module // realModule() attempts to reload the module
delete kcm; delete kcm;
kcm = 0; kcm = nullptr;
Q_Q(KCModuleProxy); Q_Q(KCModuleProxy);
q->realModule(); q->realModule();
@ -178,33 +191,32 @@ void KCModuleProxyPrivate::_k_ownerChanged(const QString &service, const QString
} }
} }
void KCModuleProxy::showEvent( QShowEvent * ev ) void KCModuleProxy::showEvent(QShowEvent *ev)
{ {
Q_D(KCModuleProxy); Q_D(KCModuleProxy);
( void )realModule(); (void)realModule();
/* We have no kcm, if we're in root mode */ /* We have no kcm, if we're in root mode */
if( d->kcm ) { if( d->kcm ) {
d->kcm->showEvent(ev); d->kcm->showEvent(ev);
} }
QWidget::showEvent( ev ); QWidget::showEvent(ev);
} }
KCModuleProxy::~KCModuleProxy() KCModuleProxy::~KCModuleProxy()
{ {
deleteClient(); deleteClient();
delete d_ptr;
delete d_ptr;
} }
void KCModuleProxy::deleteClient() void KCModuleProxy::deleteClient()
{ {
Q_D(KCModuleProxy); Q_D(KCModuleProxy);
delete d->kcm; delete d->kcm;
d->kcm = 0; d->kcm = nullptr;
if (qApp) { if (qApp) {
qApp->syncX(); qApp->syncX();
@ -213,7 +225,7 @@ void KCModuleProxy::deleteClient()
void KCModuleProxyPrivate::_k_moduleChanged(bool c) void KCModuleProxyPrivate::_k_moduleChanged(bool c)
{ {
if(changed == c) { if (changed == c) {
return; return;
} }
@ -225,112 +237,114 @@ void KCModuleProxyPrivate::_k_moduleChanged(bool c)
void KCModuleProxyPrivate::_k_moduleDestroyed() void KCModuleProxyPrivate::_k_moduleDestroyed()
{ {
kcm = 0; kcm = nullptr;
} }
KCModuleProxy::KCModuleProxy( const KService::Ptr& service, QWidget * parent, KCModuleProxy::KCModuleProxy(const KService::Ptr &service, QWidget *parent,
const QStringList& args ) const QStringList &args)
: QWidget(parent), d_ptr(new KCModuleProxyPrivate(this, KCModuleInfo(service), args)) : QWidget(parent),
d_ptr(new KCModuleProxyPrivate(this, KCModuleInfo(service), args))
{ {
d_ptr->q_ptr = this; d_ptr->q_ptr = this;
} }
KCModuleProxy::KCModuleProxy( const KCModuleInfo& info, QWidget * parent, KCModuleProxy::KCModuleProxy(const KCModuleInfo &info, QWidget *parent,
const QStringList& args ) const QStringList &args)
: QWidget(parent), d_ptr(new KCModuleProxyPrivate(this, info, args)) : QWidget(parent),
d_ptr(new KCModuleProxyPrivate(this, info, args))
{ {
d_ptr->q_ptr = this; d_ptr->q_ptr = this;
} }
KCModuleProxy::KCModuleProxy( const QString& serviceName, QWidget * parent, KCModuleProxy::KCModuleProxy(const QString &serviceName, QWidget *parent,
const QStringList& args ) const QStringList &args)
: QWidget(parent), d_ptr(new KCModuleProxyPrivate(this, KCModuleInfo(serviceName), args)) : QWidget(parent),
d_ptr(new KCModuleProxyPrivate(this, KCModuleInfo(serviceName), args))
{ {
d_ptr->q_ptr = this; d_ptr->q_ptr = this;
} }
void KCModuleProxy::load() void KCModuleProxy::load()
{ {
Q_D(KCModuleProxy); Q_D(KCModuleProxy);
if( realModule() ) if (realModule()) {
{ d->kcm->load();
d->kcm->load();
d->_k_moduleChanged(false); d->_k_moduleChanged(false);
} }
} }
void KCModuleProxy::save() void KCModuleProxy::save()
{ {
Q_D(KCModuleProxy); Q_D(KCModuleProxy);
if( d->changed && realModule() ) if (d->changed && realModule()) {
{ d->kcm->save();
d->kcm->save();
d->_k_moduleChanged(false); d->_k_moduleChanged(false);
} }
} }
void KCModuleProxy::defaults() void KCModuleProxy::defaults()
{ {
Q_D(KCModuleProxy); Q_D(KCModuleProxy);
if( realModule() ) if (realModule()) {
d->kcm->defaults(); d->kcm->defaults();
}
} }
QString KCModuleProxy::quickHelp() const QString KCModuleProxy::quickHelp() const
{ {
return realModule() ? realModule()->quickHelp() : QString(); return realModule() ? realModule()->quickHelp() : QString();
} }
const KAboutData * KCModuleProxy::aboutData() const const KAboutData* KCModuleProxy::aboutData() const
{ {
return realModule() ? realModule()->aboutData() : 0; return realModule() ? realModule()->aboutData() : nullptr;
} }
KCModule::Buttons KCModuleProxy::buttons() const KCModule::Buttons KCModuleProxy::buttons() const
{ {
if( realModule() ) if (realModule()) {
return realModule()->buttons(); return realModule()->buttons();
return KCModule::Buttons( KCModule::Help | KCModule::Default | KCModule::Apply ); }
return KCModule::Buttons(KCModule::Help | KCModule::Default | KCModule::Apply);
} }
QString KCModuleProxy::rootOnlyMessage() const QString KCModuleProxy::rootOnlyMessage() const
{ {
return realModule() ? realModule()->rootOnlyMessage() : QString(); return realModule() ? realModule()->rootOnlyMessage() : QString();
} }
bool KCModuleProxy::useRootOnlyMessage() const bool KCModuleProxy::useRootOnlyMessage() const
{ {
return realModule() ? realModule()->useRootOnlyMessage() : true; return realModule() ? realModule()->useRootOnlyMessage() : true;
} }
KComponentData KCModuleProxy::componentData() const KComponentData KCModuleProxy::componentData() const
{ {
return realModule() ? realModule()->componentData() : KComponentData(); return realModule() ? realModule()->componentData() : KComponentData();
} }
bool KCModuleProxy::changed() const bool KCModuleProxy::changed() const
{ {
Q_D(const KCModuleProxy); Q_D(const KCModuleProxy);
return d->changed; return d->changed;
} }
KCModuleInfo KCModuleProxy::moduleInfo() const KCModuleInfo KCModuleProxy::moduleInfo() const
{ {
Q_D(const KCModuleProxy); Q_D(const KCModuleProxy);
return d->modInfo; return d->modInfo;
} }
QString KCModuleProxy::dbusService() const QString KCModuleProxy::dbusService() const
{ {
Q_D(const KCModuleProxy); Q_D(const KCModuleProxy);
return d->dbusService; return d->dbusService;
} }
QString KCModuleProxy::dbusPath() const QString KCModuleProxy::dbusPath() const
{ {
Q_D(const KCModuleProxy); Q_D(const KCModuleProxy);
return d->dbusPath; return d->dbusPath;
} }
//X void KCModuleProxy::emitQuickHelpChanged() //X void KCModuleProxy::emitQuickHelpChanged()
@ -340,5 +354,3 @@ QString KCModuleProxy::dbusPath() const
/***************************************************************/ /***************************************************************/
#include "moc_kcmoduleproxy.cpp" #include "moc_kcmoduleproxy.cpp"
// vim: ts=4

View file

@ -63,184 +63,173 @@ class KCModuleProxyPrivate;
*/ */
class KCMUTILS_EXPORT KCModuleProxy : public QWidget class KCMUTILS_EXPORT KCModuleProxy : public QWidget
{ {
Q_DECLARE_PRIVATE(KCModuleProxy) Q_DECLARE_PRIVATE(KCModuleProxy)
Q_OBJECT Q_OBJECT
public: public:
/** /**
* Constructs a KCModuleProxy from a KCModuleInfo class. * Constructs a KCModuleProxy from a KCModuleInfo class.
* *
* @param info The KCModuleInfo to construct the module from. * @param info The KCModuleInfo to construct the module from.
* @param parent the parent QWidget. * @param parent the parent QWidget.
* @param args This is used in the implementation and is internal. * @param args This is used in the implementation and is internal. Use the default.
* Use the default. */
*/ explicit KCModuleProxy(const KCModuleInfo &info, QWidget *parent = nullptr,
explicit KCModuleProxy( const KCModuleInfo& info, QWidget* parent = 0, const QStringList &args = QStringList());
const QStringList& args = QStringList() );
/** /**
* Constructs a KCModuleProxy from a module's service name, which is * Constructs a KCModuleProxy from a module's service name, which is
* equivalent to the desktop file for the kcm without the ".desktop" part. * equivalent to the desktop file for the kcm without the ".desktop" part.
* Otherwise equal to the one above. * Otherwise equal to the one above.
* *
* @param serviceName The module's service name to construct from. * @param serviceName The module's service name to construct from.
* @param parent the parent QWidget. * @param parent the parent QWidget.
* @param args This is used in the implementation and is internal. * @param args This is used in the implementation and is internal. Use the default.
* Use the default. */
*/ explicit KCModuleProxy(const QString &serviceName, QWidget *parent = nullptr,
explicit KCModuleProxy( const QString& serviceName, QWidget* parent = 0, const QStringList &args = QStringList());
const QStringList& args = QStringList() );
/** /**
* Constructs a KCModuleProxy from KService. Otherwise equal to the one above. * Constructs a KCModuleProxy from KService. Otherwise equal to the one above.
* *
* @param service The KService to construct from. * @param service The KService to construct from.
* @param parent the parent QWidget. * @param parent the parent QWidget.
* @param args This is used in the implementation and is internal. * @param args This is used in the implementation and is internal. Use the default.
* Use the default. */
*/ explicit KCModuleProxy(const KService::Ptr &service, QWidget *parent = nullptr,
explicit KCModuleProxy( const KService::Ptr& service, QWidget* parent = 0, const QStringList &args = QStringList());
const QStringList& args = QStringList() );
/** /**
* Default destructor * Default destructor
*/ */
~KCModuleProxy(); ~KCModuleProxy();
/** /**
* Calling it will cause the contained module to * Calling it will cause the contained module to run its load() routine.
* run its load() routine. */
*/ void load();
void load();
/** /**
* Calling it will cause the contained module to * Calling it will cause the contained module to run its save() routine.
* run its save() routine. *
* * If the module was not modified, it will not be asked to save.
* If the module was not modified, it will not be asked */
* to save. void save();
*/
void save();
/** /**
* @return the module's quickHelp(); * @return the module's quickHelp();
*/ */
QString quickHelp() const; QString quickHelp() const;
/** /**
* @return the module's aboutData() * @return the module's aboutData()
*/ */
const KAboutData * aboutData() const; const KAboutData* aboutData() const;
/** /**
* @return what buttons the module * @return what buttons the module
* needs * needs
*/ */
KCModule::Buttons buttons() const; KCModule::Buttons buttons() const;
/** /**
* @return The module's custom root * @return The module's custom root message, if it has one
* message, if it has one * @deprecated
* @deprecated */
*/ QString rootOnlyMessage() const;
QString rootOnlyMessage() const; //KDE4 remove. There's a limit for convenience functions,
//KDE4 remove. There's a limit for convenience functions, // this one's available via realModule()->
// this one's available via realModule()->
/** /**
* @return If the module is a root module. * @return If the module is a root module.
* @deprecated * @deprecated
*/ */
bool useRootOnlyMessage() const; bool useRootOnlyMessage() const;
//KDE4 remove. There's a limit for convenience functions, //KDE4 remove. There's a limit for convenience functions,
// this one's available via realModule()-> // this one's available via realModule()->
/** /**
* Returns the embedded KCModule's KComponentData. * Returns the embedded KCModule's KComponentData.
* @return The module's KComponentData. * @return The module's KComponentData.
* @deprecated * @deprecated
*/ */
KComponentData componentData() const; KComponentData componentData() const;
//KDE4 remove. There's a limit for convenience functions, //KDE4 remove. There's a limit for convenience functions,
// this one's available via realModule() // this one's available via realModule()
/** /**
* @return true if the module is modified * @return true if the module is modified
* and needs to be saved. * and needs to be saved.
*/ */
bool changed() const; bool changed() const;
/** /**
* Access to the actual module. However, if the module is * Access to the actual module. However, if the module is
* running in root mode, see rootMode(), this function returns * running in root mode, see rootMode(), this function returns
* a NULL pointer, since the module is in another process. It may also * a NULL pointer, since the module is in another process. It may also
* return NULL if anything goes wrong. * return NULL if anything goes wrong.
* *
* @return the encapsulated module. * @return the encapsulated module.
*/ */
KCModule* realModule() const; KCModule* realModule() const;
/** /**
* @return a KCModuleInfo for the encapsulated * @return a KCModuleInfo for the encapsulated module
* module */
*/ KCModuleInfo moduleInfo() const;
KCModuleInfo moduleInfo() const;
/** /**
* Returns the DBUS Service name * Returns the DBUS Service name
*/ */
QString dbusService() const; QString dbusService() const;
/** /**
* Returns the DBUS Path * Returns the DBUS Path
*/ */
QString dbusPath() const; QString dbusPath() const;
public Q_SLOTS: public Q_SLOTS:
/**
* Calling it will cause the contained module to
* load its default values.
*/
void defaults();
/** /**
* Calling it will cause the contained module to * Calling this, results in deleting the contained
* load its default values. * module, and unregistering from DCOP. A similar result is achieved
*/ * by deleting the KCModuleProxy itself.
void defaults(); */
void deleteClient();
/**
* Calling this, results in deleting the contained
* module, and unregistering from DCOP. A similar result is achieved
* by deleting the KCModuleProxy itself.
*/
void deleteClient();
Q_SIGNALS: Q_SIGNALS:
/*
* This signal is emitted when the contained module is changed.
*/
void changed(bool state);
/* /**
* This signal is emitted when the contained module is changed. * This is emitted in the same situations as in the one above. Practical
*/ * when several KCModuleProxys are loaded.
void changed( bool state ); */
void changed(KCModuleProxy *mod);
/** /**
* This is emitted in the same situations as in the one above. Practical * When a module running with root privileges and exits, returns to normal mode, the
* when several KCModuleProxys are loaded. * childClosed() signal is emitted.
*/ */
void changed( KCModuleProxy* mod ); void childClosed();
/** /*
* When a module running with root privileges and exits, returns to normal mode, the * This signal is relayed from the encapsulated module, and
* childClosed() signal is emitted. * is equivalent to the module's own quickHelpChanged() signal.
*/ */
void childClosed(); void quickHelpChanged();
/*
* This signal is relayed from the encapsulated module, and
* is equivalent to the module's own quickHelpChanged() signal.
*/
void quickHelpChanged();
protected: protected:
/**
/** * Reimplemented for internal purposes. Makes sure the encapsulated
* Reimplemented for internal purposes. Makes sure the encapsulated * module is loaded before the show event is taken care of.
* module is loaded before the show event is taken care of. */
*/ void showEvent(QShowEvent *);
void showEvent( QShowEvent * );
protected: protected:
KCModuleProxyPrivate *const d_ptr; KCModuleProxyPrivate *const d_ptr;

View file

@ -28,50 +28,49 @@
class KCModuleProxyPrivate class KCModuleProxyPrivate
{ {
Q_DECLARE_PUBLIC(KCModuleProxy) Q_DECLARE_PUBLIC(KCModuleProxy)
protected: protected:
KCModuleProxyPrivate(KCModuleProxy *_parent, const KCModuleInfo &info, const QStringList &_args) KCModuleProxyPrivate(KCModuleProxy *_parent, const KCModuleInfo &info, const QStringList &_args)
: args(_args), kcm(0), topLayout(0), rootInfo(0), modInfo(info), : args(_args), kcm(0), topLayout(0), rootInfo(0), modInfo(info),
changed(false), bogusOccupier(false), parent(_parent) changed(false), bogusOccupier(false), parent(_parent)
{ {
} }
~KCModuleProxyPrivate() ~KCModuleProxyPrivate()
{ {
delete rootInfo; // Delete before embedWidget! delete rootInfo; // Delete before embedWidget!
delete kcm; delete kcm;
} }
void loadModule(); void loadModule();
/** /**
* Makes sure the proper variables is set and signals are emitted. * Makes sure the proper variables is set and signals are emitted.
*/ */
void _k_moduleChanged(bool); void _k_moduleChanged(bool);
/** /**
* Zeroes d->kcm * Zeroes d->kcm
*/ */
void _k_moduleDestroyed(); void _k_moduleDestroyed();
/** /**
* Gets called by DCOP when an application closes. * Gets called by DCOP when an application closes.
* Is used to (try to) reload a KCM which previously * Is used to (try to) reload a KCM which previously
* was loaded. * was loaded.
*/ */
void _k_ownerChanged(const QString &service, const QString &oldOwner, const QString &newOwner); void _k_ownerChanged(const QString &service, const QString &oldOwner, const QString &newOwner);
QStringList args; QStringList args;
KCModule *kcm; KCModule *kcm;
QVBoxLayout *topLayout; /* Contains QScrollView view, and root stuff */ QVBoxLayout *topLayout; /* Contains QScrollView view, and root stuff */
QLabel *rootInfo; QLabel *rootInfo;
QString dbusService; QString dbusService;
QString dbusPath; QString dbusPath;
KCModuleInfo modInfo; KCModuleInfo modInfo;
bool changed; bool changed;
bool bogusOccupier; bool bogusOccupier;
KCModuleProxy *parent; KCModuleProxy *parent;
KCModuleProxy *q_ptr; KCModuleProxy *q_ptr;
}; };
#endif // KCMUTILS_KCMODULEPROXY_P_H #endif // KCMUTILS_KCMODULEPROXY_P_H
// vim: sw=4 sts=4 et tw=100

View file

@ -36,22 +36,22 @@ class KCMultiDialogPrivate;
*/ */
class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
{ {
Q_OBJECT Q_OBJECT
Q_DECLARE_PRIVATE(KCMultiDialog) Q_DECLARE_PRIVATE(KCMultiDialog)
public: public:
/** /**
* Constructs a new KCMultiDialog * Constructs a new KCMultiDialog
* *
* @param parent The parent widget * @param parent The parent widget
**/ **/
KCMultiDialog( QWidget *parent = 0 ); KCMultiDialog(QWidget *parent = nullptr);
/** /**
* Destructor * Destructor
**/ **/
virtual ~KCMultiDialog(); virtual ~KCMultiDialog();
/** /**
* Add a module. * Add a module.
@ -66,8 +66,7 @@ class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
* *
* @returns The @see KPageWidgetItem associated with the new dialog page. * @returns The @see KPageWidgetItem associated with the new dialog page.
**/ **/
KPageWidgetItem* addModule( const QString& module, const QStringList& KPageWidgetItem* addModule(const QString &module, const QStringList &args = QStringList());
args = QStringList() );
/** /**
* Add a module. * Add a module.
@ -80,12 +79,12 @@ class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
* to the list of modules the dialog will show. * to the list of modules the dialog will show.
* *
* @param parent The @see KPageWidgetItem that should appear as parents * @param parent The @see KPageWidgetItem that should appear as parents
* in the tree view or a 0 pointer if there is no parent. * in the tree view or a null pointer if there is no parent.
* *
* @param args The arguments that should be given to the KCModule when it is created * @param args The arguments that should be given to the KCModule when it is created
**/ **/
KPageWidgetItem* addModule( const KCModuleInfo& moduleinfo, KPageWidgetItem *parent = 0, KPageWidgetItem* addModule(const KCModuleInfo &moduleinfo, KPageWidgetItem *parent = nullptr,
const QStringList& args = QStringList() ); const QStringList &args = QStringList());
/** /**
* Removes all modules from the dialog. * Removes all modules from the dialog.
@ -97,7 +96,7 @@ class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
*/ */
void setButtons(ButtonCodes buttonMask); void setButtons(ButtonCodes buttonMask);
Q_SIGNALS: Q_SIGNALS:
/** /**
* Emitted after all KCModules have been told to save their configuration. * Emitted after all KCModules have been told to save their configuration.
* *
@ -121,16 +120,16 @@ class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
* @param componentName The name of the instance that needs to reload its * @param componentName The name of the instance that needs to reload its
* configuration. * configuration.
*/ */
void configCommitted( const QByteArray & componentName ); void configCommitted(const QByteArray &componentName);
protected: protected:
/** /**
* This constructor can be used by subclasses to provide a custom KPageWidget. * This constructor can be used by subclasses to provide a custom KPageWidget.
*/ */
KCMultiDialog(KPageWidget *pageWidget, QWidget *parent, Qt::WindowFlags flags = 0); KCMultiDialog(KPageWidget *pageWidget, QWidget *parent, Qt::WindowFlags flags = 0);
KCMultiDialog(KCMultiDialogPrivate &dd, KPageWidget *pageWidget, QWidget *parent, Qt::WindowFlags flags = 0); KCMultiDialog(KCMultiDialogPrivate &dd, KPageWidget *pageWidget, QWidget *parent, Qt::WindowFlags flags = 0);
protected Q_SLOTS: protected Q_SLOTS:
/** /**
* This slot is called when the user presses the "Default" Button. * This slot is called when the user presses the "Default" Button.
* You can reimplement it if needed. * You can reimplement it if needed.
@ -175,11 +174,11 @@ class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
**/ **/
void slotHelpClicked(); void slotHelpClicked();
private: private:
Q_PRIVATE_SLOT(d_func(), void _k_slotCurrentPageChanged(KPageWidgetItem *, KPageWidgetItem *)) Q_PRIVATE_SLOT(d_func(), void _k_slotCurrentPageChanged(KPageWidgetItem *, KPageWidgetItem *))
Q_PRIVATE_SLOT(d_func(), void _k_clientChanged()) Q_PRIVATE_SLOT(d_func(), void _k_clientChanged())
Q_PRIVATE_SLOT(d_func(), void _k_dialogClosed()) Q_PRIVATE_SLOT(d_func(), void _k_dialogClosed())
Q_PRIVATE_SLOT(d_func(), void _k_updateHeader(bool use, const QString &message)) Q_PRIVATE_SLOT(d_func(), void _k_updateHeader(bool use, const QString &message))
}; };
#endif #endif

View file

@ -28,7 +28,7 @@ KSettingsWidgetAdaptor::KSettingsWidgetAdaptor(QObject *parent)
QString KSettingsWidgetAdaptor::applicationName() QString KSettingsWidgetAdaptor::applicationName()
{ {
return KGlobal::caption(); return KGlobal::caption();
} }
#include "moc_ksettingswidgetadaptor.cpp" #include "moc_ksettingswidgetadaptor.cpp"