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,107 +42,106 @@
/***********************************************************************/
class KCModuleContainer::KCModuleContainerPrivate
{
public:
KCModuleContainerPrivate( const QStringList& mods )
: modules( mods )
, tabWidget( 0 )
, topLayout( 0 )
{}
public:
KCModuleContainerPrivate(const QStringList &mods)
: modules(mods),
tabWidget(nullptr),
topLayout(nullptr)
{
}
QStringList modules;
KTabWidget *tabWidget;
KCModule::Buttons buttons;
QVBoxLayout *topLayout;
};
/***********************************************************************/
// 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
// KComponentData objects when needed.
/***********************************************************************/
KCModuleContainer::KCModuleContainer( QWidget* parent, const QString& mods )
KCModuleContainer::KCModuleContainer(QWidget *parent, const QString &mods)
: KCModule( KGlobal::mainComponent(), parent ),
d(new KCModuleContainerPrivate( QString(mods).remove( ' ' ).split( ',', QString::SkipEmptyParts ) ))
d(new KCModuleContainerPrivate(QString(mods).remove(' ').split(',', QString::SkipEmptyParts)))
{
init();
}
KCModuleContainer::KCModuleContainer( QWidget* parent, const QStringList& mods )
: KCModule( KGlobal::mainComponent(), parent ),
d( new KCModuleContainerPrivate( mods ) )
KCModuleContainer::KCModuleContainer(QWidget *parent, const QStringList &mods)
: KCModule( KGlobal::mainComponent(), parent),
d(new KCModuleContainerPrivate(mods))
{
init();
}
void KCModuleContainer::init()
{
d->topLayout = new QVBoxLayout( this );
d->topLayout->setMargin( 0 );
d->topLayout->setObjectName( "topLayout" );
d->topLayout = new QVBoxLayout(this);
d->topLayout->setMargin(0);
d->topLayout->setObjectName("topLayout");
d->tabWidget = new KTabWidget(this);
d->tabWidget->setObjectName( "tabWidget");
connect( d->tabWidget, SIGNAL(currentChanged(int)), SLOT(tabSwitched(int)));
d->topLayout->addWidget( d->tabWidget );
d->tabWidget->setObjectName("tabWidget");
connect(d->tabWidget, SIGNAL(currentChanged(int)), SLOT(tabSwitched(int)));
d->topLayout->addWidget(d->tabWidget);
if ( !d->modules.isEmpty() )
{
if (!d->modules.isEmpty()) {
/* Add our modules */
foreach (const QString it, d->modules )
addModule( it );
foreach (const QString it, d->modules) {
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.
* This allows people to easily extend containers.
* For example, KCM monitor gamma can be in kdegraphics.
*/
KService::Ptr service = KService::serviceByDesktopName( module );
if ( !service )
{
kDebug(713) << "KCModuleContainer: module '" <<
module << "' was not found and thus not loaded";
KService::Ptr service = KService::serviceByDesktopName(module);
if (!service) {
kDebug(713) << "KCModuleContainer: module '"
<< module << "' was not found and thus not loaded";
return;
}
if ( service->noDisplay() )
if (service->noDisplay()) {
return;
}
KCModuleProxy* proxy = new KCModuleProxy( service, d->tabWidget );
allModules.append( proxy );
KCModuleProxy* proxy = new KCModuleProxy(service, d->tabWidget);
allModules.append(proxy);
proxy->setObjectName( module.toLatin1() );
proxy->setObjectName(module.toLatin1());
d->tabWidget->addTab( proxy, KIcon( proxy->moduleInfo().icon() ),
/* Qt eats ampersands for dinner. But not this time. */
proxy->moduleInfo().moduleName().replace( '&', "&&" ));
d->tabWidget->addTab(
proxy, KIcon(proxy->moduleInfo().icon()),
/* 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 */
setButtons( buttons() | proxy->realModule()->buttons() );
setButtons(buttons() | proxy->realModule()->buttons());
}
void KCModuleContainer::tabSwitched(int index)
{
KCModuleProxy* mod = static_cast<KCModuleProxy *>(d->tabWidget->widget(index));
setQuickHelp( mod->quickHelp() );
setAboutData( mod->aboutData() );
KCModuleProxy* mod = static_cast<KCModuleProxy*>(d->tabWidget->widget(index));
setQuickHelp(mod->quickHelp());
setAboutData(mod->aboutData());
}
void KCModuleContainer::save()
{
ModuleList list = changedModules;
ModuleList::iterator it;
for ( it = list.begin() ; it !=list.end() ; ++it )
{
for ( it = list.begin() ; it !=list.end() ; ++it ) {
(*it)->save();
}
@ -154,8 +153,7 @@ void KCModuleContainer::load()
{
ModuleList list = allModules;
ModuleList::iterator it;
for ( it = list.begin() ; it !=list.end() ; ++it )
{
for ( it = list.begin() ; it !=list.end() ; ++it ) {
(*it)->load();
}
@ -166,20 +164,19 @@ void KCModuleContainer::defaults()
{
ModuleList list = allModules;
ModuleList::iterator it;
for ( it = list.begin() ; it !=list.end() ; ++it )
{
for (it = list.begin() ; it !=list.end() ; ++it) {
(*it)->defaults();
}
emit changed( true );
}
void KCModuleContainer::moduleChanged(KCModuleProxy * proxy)
void KCModuleContainer::moduleChanged(KCModuleProxy *proxy)
{
changedModules.append( proxy );
if( changedModules.isEmpty() )
changedModules.append(proxy);
if (changedModules.isEmpty()) {
return;
}
emit changed(true);
}
@ -188,9 +185,3 @@ KCModuleContainer::~KCModuleContainer()
{
delete d;
}
/***********************************************************************/

View file

@ -33,12 +33,17 @@
class KCModuleInfo::Private
{
public:
public:
Private();
Private( KService::Ptr );
Private(KService::Ptr s);
QStringList keywords;
QString name, icon, lib, fileName, doc, comment;
QString name;
QString icon;
QString lib;
QString fileName;
QString doc;
QString comment;
bool allLoaded;
int weight;
@ -55,12 +60,11 @@ KCModuleInfo::Private::Private()
{
}
KCModuleInfo::Private::Private( KService::Ptr s )
: allLoaded( false )
, service( s )
KCModuleInfo::Private::Private(KService::Ptr s)
: allLoaded(false),
service(s)
{
if ( !service )
{
if (!service) {
kDebug(712) << "Could not find the service.";
return;
}
@ -75,40 +79,40 @@ KCModuleInfo::Private::Private( KService::Ptr s )
}
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);
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()
@ -120,14 +124,16 @@ void KCModuleInfo::Private::loadAll()
{
allLoaded = true;
if( !service ) /* We have a bogus service. All get functions will return empty/zero values */
if (!service) {
/* We have a bogus service. All get functions will return empty/zero values */
return;
}
// get the documentation path
doc = service->property( "X-DocPath", QVariant::String ).toString();
doc = service->property("X-DocPath", QVariant::String).toString();
// 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;
}
@ -168,18 +174,16 @@ QString KCModuleInfo::library() const
QString KCModuleInfo::docPath() const
{
if (!d->allLoaded)
if (!d->allLoaded) {
d->loadAll();
}
return d->doc;
}
int KCModuleInfo::weight() const
{
if (!d->allLoaded)
if (!d->allLoaded) {
d->loadAll();
}
return d->weight;
}
// vim: ts=2 sw=2 et

View file

@ -44,11 +44,9 @@
* @author Daniel Molkentin <molkentin@kde.org>
*
*/
class KCMUTILS_EXPORT KCModuleInfo // krazy:exclude=dpointer (implicitly shared)
class KCMUTILS_EXPORT KCModuleInfo
{
public:
/**
* Constructs a KCModuleInfo.
* @note a KCModuleInfo object will have to be manually deleted, it is not
@ -56,7 +54,7 @@ public:
* @param desktopFile the desktop file representing the module, or
* the name of the module.
*/
KCModuleInfo(const QString& desktopFile);
KCModuleInfo(const QString &desktopFile);
/**
* Same as above but takes a KService::Ptr as argument.
@ -65,7 +63,7 @@ public:
*
* @param moduleInfo specifies the module
*/
KCModuleInfo( KService::Ptr moduleInfo );
KCModuleInfo(KService::Ptr moduleInfo);
/**
@ -73,7 +71,7 @@ public:
*
* @param rhs specifies the module
*/
KCModuleInfo( const KCModuleInfo &rhs );
KCModuleInfo(const KCModuleInfo &rhs);
/**
* Same as above but creates an empty KCModuleInfo.
@ -84,17 +82,17 @@ public:
/**
* Assignment operator
*/
KCModuleInfo &operator=( const KCModuleInfo &rhs );
KCModuleInfo &operator=(const KCModuleInfo &rhs);
/**
* 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
*/
bool operator!=( const KCModuleInfo &rhs ) const;
bool operator!=(const KCModuleInfo &rhs) const;
/**
* Default destructor.
@ -149,9 +147,7 @@ public:
private:
class Private;
Private * d;
Private *d;
};
#endif // KCMODULEINFO_H
// vim: ts=2 sw=2 et

View file

@ -41,26 +41,28 @@ using namespace KCModuleLoader;
class KCMError : public KCModule
{
public:
KCMError( const QString& msg, const QString& details, QWidget* parent )
: KCModule( KGlobal::mainComponent(), parent )
KCMError(const QString &msg, const QString &details, QWidget *parent)
: KCModule(KGlobal::mainComponent(), parent)
{
QVBoxLayout* topLayout = new QVBoxLayout( this );
QLabel *lab = new QLabel( msg, this );
QVBoxLayout* topLayout = new QVBoxLayout(this);
QLabel *lab = new QLabel(msg, this);
lab->setWordWrap(true);
topLayout->addWidget( lab );
lab = new QLabel(details, this );
topLayout->addWidget(lab);
lab = new QLabel(details, this);
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:
@ -68,17 +70,31 @@ KCModule* KCModuleLoader::loadModule(const KCModuleInfo& mod, ErrorReporting rep
* from the factory.
*/
if ( !mod.service() )
return reportError( report,
i18n("The module %1 could not be found.",
mod.moduleName() ), 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.service()) {
return reportError(
report,
i18n(
"The module %1 could not be found.",
mod.moduleName()
),
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;
QVariantList args2;
foreach (const QString &arg, args) {
@ -99,21 +115,26 @@ KCModule* KCModuleLoader::loadModule(const KCModuleInfo& mod, ErrorReporting rep
* (startService calls kcmshell which calls modloader which calls startService...)
*
*/
return reportError( report,
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 );
return reportError(
report,
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,
const QString &details, QWidget * parent )
KCModule* KCModuleLoader::reportError(ErrorReporting report, const QString &text,
const QString &details, QWidget *parent)
{
QString realDetails = details;
if (realDetails.isNull()) {
realDetails = i18n("<qt><p>Possible reasons:<ul><li>An error occurred during your last "
realDetails = i18n(
"<qt><p>Possible reasons:<ul><li>An error occurred during your last "
"KDE upgrade leaving an orphaned control module</li><li>You have old third party "
"modules lying around.</li></ul></p><p>Check these points carefully and try to remove "
"the module mentioned in the error message. If this fails, consider contacting "
"your distributor or packager.</p></qt>");
"your distributor or packager.</p></qt>"
);
}
if (report & KCModuleLoader::Dialog) {
KMessageBox::detailedError(parent, text, realDetails);
@ -121,7 +142,5 @@ KCModule* KCModuleLoader::reportError( ErrorReporting report, const QString & te
if (report & KCModuleLoader::Inline) {
return new KCMError(text, realDetails, parent);
}
return 0;
return nullptr;
}
// vim: ts=4

View file

@ -48,7 +48,7 @@ namespace KCModuleLoader
enum ErrorReporting {
/**
* no error reporting is done
* */
*/
None = 0,
/**
* the error report is shown instead of the
@ -72,8 +72,8 @@ namespace KCModuleLoader
*
* @return a pointer to the loaded @ref KCModule
*/
KCMUTILS_EXPORT KCModule *loadModule(const KCModuleInfo &module, ErrorReporting
report, QWidget * parent = 0, const QStringList& args = QStringList() );
KCMUTILS_EXPORT KCModule* loadModule(const KCModuleInfo &module, ErrorReporting report,
QWidget *parent = nullptr, const QStringList &args = QStringList());
/**
* 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
*/
KCMUTILS_EXPORT KCModule *loadModule( const QString &module, ErrorReporting report,
QWidget *parent = 0, const QStringList& args = QStringList() );
KCMUTILS_EXPORT KCModule* loadModule(const QString &module, ErrorReporting report,
QWidget *parent = nullptr, const QStringList &args = QStringList());
/**
* Returns a KCModule containing the messages @p report and @p text.
@ -95,9 +95,8 @@ namespace KCModuleLoader
*
* @internal
*/
KCMUTILS_EXPORT KCModule* reportError( ErrorReporting report, const QString & text,
const QString &details, QWidget * parent );
KCMUTILS_EXPORT KCModule* reportError(ErrorReporting report, const QString &text,
const QString &details, QWidget *parent);
}
// vim: ts=2 sw=2 et
#endif // KCMODULELOADER_H

View file

@ -45,15 +45,14 @@
- Two Layout problems in runAsRoot:
* lblBusy doesn't show
* d->kcm/d->rootInfo doesn't get it right when the user
presses cancel in the kdesudo dialog
* d->kcm/d->rootInfo doesn't get it right when the user presses cancel in the kdesudo dialog
- Resizing horizontally is contrained; minimum size is set somewhere.
It appears to be somehow derived from the module's size.
- Prettify: set icon in KCMultiDialog.
*/
*/
/***************************************************************/
KCModule* KCModuleProxy::realModule() const
{
@ -64,10 +63,9 @@ KCModule* KCModuleProxy::realModule() const
*/
/* Already loaded */
if( !d->kcm )
{
QApplication::setOverrideCursor( Qt::WaitCursor );
const_cast<KCModuleProxyPrivate *>(d)->loadModule();
if (!d->kcm) {
QApplication::setOverrideCursor(Qt::WaitCursor);
const_cast<KCModuleProxyPrivate*>(d)->loadModule();
QApplication::restoreOverrideCursor();
}
return d->kcm;
@ -75,10 +73,9 @@ KCModule* KCModuleProxy::realModule() const
void KCModuleProxyPrivate::loadModule()
{
if( !topLayout )
{
topLayout = new QVBoxLayout( parent );
topLayout->setMargin( 0 );
if (!topLayout) {
topLayout = new QVBoxLayout(parent);
topLayout->setMargin(0);
QString name = modInfo.library();
name.replace("-", "_"); //hyphen is not allowed in dbus, only [A-Z][a-z][0-9]_
@ -86,31 +83,37 @@ void KCModuleProxyPrivate::loadModule()
dbusService = QLatin1String("org.kde.internal.KSettingsWidget_") + name;
}
if( QDBusConnection::sessionBus().registerService( dbusService ) || bogusOccupier )
{ /* We got the name we requested, because no one was before us,
* 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();
if (QDBusConnection::sessionBus().registerService(dbusService) || bogusOccupier) {
/* We got the name we requested, because no one was before us,
* 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();
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(destroyed()), parent, SLOT(_k_moduleDestroyed()));
QObject::connect( kcm, SIGNAL(quickHelpChanged()), parent, SIGNAL(quickHelpChanged()) );
parent->setWhatsThis( kcm->quickHelp() );
QObject::connect(kcm, SIGNAL(quickHelpChanged()), parent, SIGNAL(quickHelpChanged()));
parent->setWhatsThis(kcm->quickHelp());
if ( kcm->layout() ) {
kcm->layout()->setMargin( 0 );
if (kcm->layout()) {
kcm->layout()->setMargin(0);
}
topLayout->addWidget( kcm );
if( !modInfo.library().isEmpty() )
QDBusConnection::sessionBus().registerObject(dbusPath, new KSettingsWidgetAdaptor(parent), QDBusConnection::ExportAllSlots);
if (!modInfo.library().isEmpty()) {
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 */
!KUser().isSuperUser() ) /* Not necessary if we're root */
{
/*rootInfo = new QLabel( parent );
topLayout->insertWidget( 0, rootInfo );
#if 0
rootInfo = new QLabel(parent);
topLayout->insertWidget(0, rootInfo);
QPalette palette = rootInfo->palette();
KStatefulBrush stbrush(KColorScheme::Window, KColorScheme::NeutralBackground);
@ -120,42 +123,52 @@ void KCModuleProxyPrivate::loadModule()
rootInfo->setAutoFillBackground(true);
const QString message = kcm->rootOnlyMessage();
if( message.isEmpty() )
rootInfo->setText( i18n(
if (message.isEmpty() )
rootInfo->setText(
i18n(
"<b>Changes in this section require root access.</b><br />"
"On applying your changes you will have to supply your root "
"password." ) );
else
"password." )
);
} else {
rootInfo->setText(message);
}
rootInfo->setWhatsThis( i18n(
rootInfo->setWhatsThis(
i18n(
"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 " ) );*/
"module cannot be saved "
)
);
#endif
}
}
else
{
} else {
kDebug(711) << "Module already loaded, loading KCMError";
/* Figure out the name of where the module is already loaded */
QDBusInterface proxy( dbusService, dbusPath, "org.kde.internal.KSettingsWidget" );
QDBusInterface proxy(dbusService, dbusPath, "org.kde.internal.KSettingsWidget");
QDBusReply<QString> reply = proxy.call("applicationName");
if( reply.isValid() )
{
QObject::connect( QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
parent, SLOT(_k_ownerChanged(QString,QString,QString)));
kcm = KCModuleLoader::reportError( KCModuleLoader::Inline,
i18nc( "Argument is application name", "This configuration section is "
"already opened in %1" , reply.value() ), " ", parent );
topLayout->addWidget( kcm );
}
else
{
if (reply.isValid()) {
QObject::connect(
QDBusConnection::sessionBus().interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
parent, SLOT(_k_ownerChanged(QString,QString,QString))
);
kcm = KCModuleLoader::reportError(
KCModuleLoader::Inline,
i18nc(
"Argument is application name", "This configuration section is "
"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();
@ -169,7 +182,7 @@ void KCModuleProxyPrivate::_k_ownerChanged(const QString &service, const QString
// Violence: Get rid of KCMError & CO, so that
// realModule() attempts to reload the module
delete kcm;
kcm = 0;
kcm = nullptr;
Q_Q(KCModuleProxy);
q->realModule();
@ -178,25 +191,24 @@ void KCModuleProxyPrivate::_k_ownerChanged(const QString &service, const QString
}
}
void KCModuleProxy::showEvent( QShowEvent * ev )
void KCModuleProxy::showEvent(QShowEvent *ev)
{
Q_D(KCModuleProxy);
( void )realModule();
(void)realModule();
/* We have no kcm, if we're in root mode */
if( d->kcm ) {
d->kcm->showEvent(ev);
}
QWidget::showEvent( ev );
QWidget::showEvent(ev);
}
KCModuleProxy::~KCModuleProxy()
{
deleteClient();
delete d_ptr;
}
@ -204,7 +216,7 @@ void KCModuleProxy::deleteClient()
{
Q_D(KCModuleProxy);
delete d->kcm;
d->kcm = 0;
d->kcm = nullptr;
if (qApp) {
qApp->syncX();
@ -213,7 +225,7 @@ void KCModuleProxy::deleteClient()
void KCModuleProxyPrivate::_k_moduleChanged(bool c)
{
if(changed == c) {
if (changed == c) {
return;
}
@ -225,36 +237,37 @@ void KCModuleProxyPrivate::_k_moduleChanged(bool c)
void KCModuleProxyPrivate::_k_moduleDestroyed()
{
kcm = 0;
kcm = nullptr;
}
KCModuleProxy::KCModuleProxy( const KService::Ptr& service, QWidget * parent,
const QStringList& args )
: QWidget(parent), d_ptr(new KCModuleProxyPrivate(this, KCModuleInfo(service), args))
KCModuleProxy::KCModuleProxy(const KService::Ptr &service, QWidget *parent,
const QStringList &args)
: QWidget(parent),
d_ptr(new KCModuleProxyPrivate(this, KCModuleInfo(service), args))
{
d_ptr->q_ptr = this;
}
KCModuleProxy::KCModuleProxy( const KCModuleInfo& info, QWidget * parent,
const QStringList& args )
: QWidget(parent), d_ptr(new KCModuleProxyPrivate(this, info, args))
KCModuleProxy::KCModuleProxy(const KCModuleInfo &info, QWidget *parent,
const QStringList &args)
: QWidget(parent),
d_ptr(new KCModuleProxyPrivate(this, info, args))
{
d_ptr->q_ptr = this;
}
KCModuleProxy::KCModuleProxy( const QString& serviceName, QWidget * parent,
const QStringList& args )
: QWidget(parent), d_ptr(new KCModuleProxyPrivate(this, KCModuleInfo(serviceName), args))
KCModuleProxy::KCModuleProxy(const QString &serviceName, QWidget *parent,
const QStringList &args)
: QWidget(parent),
d_ptr(new KCModuleProxyPrivate(this, KCModuleInfo(serviceName), args))
{
d_ptr->q_ptr = this;
}
void KCModuleProxy::load()
{
Q_D(KCModuleProxy);
if( realModule() )
{
if (realModule()) {
d->kcm->load();
d->_k_moduleChanged(false);
}
@ -263,8 +276,7 @@ void KCModuleProxy::load()
void KCModuleProxy::save()
{
Q_D(KCModuleProxy);
if( d->changed && realModule() )
{
if (d->changed && realModule()) {
d->kcm->save();
d->_k_moduleChanged(false);
}
@ -273,8 +285,9 @@ void KCModuleProxy::save()
void KCModuleProxy::defaults()
{
Q_D(KCModuleProxy);
if( realModule() )
if (realModule()) {
d->kcm->defaults();
}
}
QString KCModuleProxy::quickHelp() const
@ -282,16 +295,17 @@ QString KCModuleProxy::quickHelp() const
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
{
if( realModule() )
if (realModule()) {
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
@ -340,5 +354,3 @@ QString KCModuleProxy::dbusPath() const
/***************************************************************/
#include "moc_kcmoduleproxy.cpp"
// vim: ts=4

View file

@ -63,19 +63,18 @@ class KCModuleProxyPrivate;
*/
class KCMUTILS_EXPORT KCModuleProxy : public QWidget
{
Q_DECLARE_PRIVATE(KCModuleProxy)
Q_OBJECT
Q_DECLARE_PRIVATE(KCModuleProxy)
Q_OBJECT
public:
/**
* Constructs a KCModuleProxy from a KCModuleInfo class.
*
* @param info The KCModuleInfo to construct the module from.
* @param parent the parent QWidget.
* @param args This is used in the implementation and is internal.
* Use the default.
* @param args This is used in the implementation and is internal. Use the default.
*/
explicit KCModuleProxy( const KCModuleInfo& info, QWidget* parent = 0,
const QStringList& args = QStringList() );
explicit KCModuleProxy(const KCModuleInfo &info, QWidget *parent = nullptr,
const QStringList &args = QStringList());
/**
* Constructs a KCModuleProxy from a module's service name, which is
@ -84,22 +83,20 @@ public:
*
* @param serviceName The module's service name to construct from.
* @param parent the parent QWidget.
* @param args This is used in the implementation and is internal.
* Use the default.
* @param args This is used in the implementation and is internal. Use the default.
*/
explicit KCModuleProxy( const QString& serviceName, QWidget* parent = 0,
const QStringList& args = QStringList() );
explicit KCModuleProxy(const QString &serviceName, QWidget *parent = nullptr,
const QStringList &args = QStringList());
/**
* Constructs a KCModuleProxy from KService. Otherwise equal to the one above.
*
* @param service The KService to construct from.
* @param parent the parent QWidget.
* @param args This is used in the implementation and is internal.
* Use the default.
* @param args This is used in the implementation and is internal. Use the default.
*/
explicit KCModuleProxy( const KService::Ptr& service, QWidget* parent = 0,
const QStringList& args = QStringList() );
explicit KCModuleProxy(const KService::Ptr &service, QWidget *parent = nullptr,
const QStringList &args = QStringList());
/**
* Default destructor
@ -107,17 +104,14 @@ public:
~KCModuleProxy();
/**
* Calling it will cause the contained module to
* run its load() routine.
* Calling it will cause the contained module to run its load() routine.
*/
void load();
/**
* Calling it will cause the contained module to
* run its save() routine.
* Calling it will cause the contained module to 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();
@ -129,7 +123,7 @@ public:
/**
* @return the module's aboutData()
*/
const KAboutData * aboutData() const;
const KAboutData* aboutData() const;
/**
* @return what buttons the module
@ -138,8 +132,7 @@ public:
KCModule::Buttons buttons() const;
/**
* @return The module's custom root
* message, if it has one
* @return The module's custom root message, if it has one
* @deprecated
*/
QString rootOnlyMessage() const;
@ -180,8 +173,7 @@ public:
KCModule* realModule() const;
/**
* @return a KCModuleInfo for the encapsulated
* module
* @return a KCModuleInfo for the encapsulated module
*/
KCModuleInfo moduleInfo() const;
@ -195,7 +187,6 @@ public:
QString dbusPath() const;
public Q_SLOTS:
/**
* Calling it will cause the contained module to
* load its default values.
@ -210,17 +201,16 @@ public Q_SLOTS:
void deleteClient();
Q_SIGNALS:
/*
* This signal is emitted when the contained module is changed.
*/
void changed( bool state );
void changed(bool state);
/**
* This is emitted in the same situations as in the one above. Practical
* when several KCModuleProxys are loaded.
*/
void changed( KCModuleProxy* mod );
void changed(KCModuleProxy *mod);
/**
* When a module running with root privileges and exits, returns to normal mode, the
@ -235,12 +225,11 @@ Q_SIGNALS:
void quickHelpChanged();
protected:
/**
* Reimplemented for internal purposes. Makes sure the encapsulated
* module is loaded before the show event is taken care of.
*/
void showEvent( QShowEvent * );
void showEvent(QShowEvent *);
protected:
KCModuleProxyPrivate *const d_ptr;

View file

@ -28,7 +28,7 @@
class KCModuleProxyPrivate
{
Q_DECLARE_PUBLIC(KCModuleProxy)
protected:
protected:
KCModuleProxyPrivate(KCModuleProxy *_parent, const KCModuleInfo &info, const QStringList &_args)
: args(_args), kcm(0), topLayout(0), rootInfo(0), modInfo(info),
changed(false), bogusOccupier(false), parent(_parent)
@ -74,4 +74,3 @@ class KCModuleProxyPrivate
};
#endif // KCMUTILS_KCMODULEPROXY_P_H
// vim: sw=4 sts=4 et tw=100

View file

@ -39,13 +39,13 @@ class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
Q_OBJECT
Q_DECLARE_PRIVATE(KCMultiDialog)
public:
public:
/**
* Constructs a new KCMultiDialog
*
* @param parent The parent widget
**/
KCMultiDialog( QWidget *parent = 0 );
KCMultiDialog(QWidget *parent = nullptr);
/**
@ -66,8 +66,7 @@ class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
*
* @returns The @see KPageWidgetItem associated with the new dialog page.
**/
KPageWidgetItem* addModule( const QString& module, const QStringList&
args = QStringList() );
KPageWidgetItem* addModule(const QString &module, const QStringList &args = QStringList());
/**
* Add a module.
@ -80,12 +79,12 @@ class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
* to the list of modules the dialog will show.
*
* @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
**/
KPageWidgetItem* addModule( const KCModuleInfo& moduleinfo, KPageWidgetItem *parent = 0,
const QStringList& args = QStringList() );
KPageWidgetItem* addModule(const KCModuleInfo &moduleinfo, KPageWidgetItem *parent = nullptr,
const QStringList &args = QStringList());
/**
* Removes all modules from the dialog.
@ -97,7 +96,7 @@ class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
*/
void setButtons(ButtonCodes buttonMask);
Q_SIGNALS:
Q_SIGNALS:
/**
* 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
* 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.
*/
KCMultiDialog(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.
* You can reimplement it if needed.
@ -175,7 +174,7 @@ class KCMUTILS_EXPORT KCMultiDialog : public KPageDialog
**/
void slotHelpClicked();
private:
private:
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_dialogClosed())