You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
221 lines
5.1 KiB
221 lines
5.1 KiB
15 years ago
|
/*
|
||
|
This file is part of the KDE libraries
|
||
|
|
||
13 years ago
|
<<<Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
|
||
15 years ago
|
Copyright (C) 2004 Frans Englich <frans.englich@telia.com>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
|
||
|
*/
|
||
|
|
||
14 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
|
||
|
#include <kaboutdata.h>
|
||
|
#include <kconfigskeleton.h>
|
||
|
#include <kconfigdialogmanager.h>
|
||
|
#include <kdebug.h>
|
||
|
#include <kglobal.h>
|
||
|
#include <kinstance.h>
|
||
|
#include <klocale.h>
|
||
|
|
||
|
#include "kcmodule.h"
|
||
|
#include "kcmodule.moc"
|
||
|
|
||
|
class KCModulePrivate
|
||
|
{
|
||
|
public:
|
||
|
KCModulePrivate():
|
||
|
_about( 0 ),
|
||
|
_useRootOnlyMsg( false ),
|
||
|
_hasOwnInstance( true ),
|
||
|
_unmanagedWidgetChangeState( false )
|
||
|
{ }
|
||
|
|
||
|
KInstance *_instance;
|
||
|
KAboutData *_about;
|
||
14 years ago
|
TQString _rootOnlyMsg;
|
||
15 years ago
|
bool _useRootOnlyMsg;
|
||
|
bool _hasOwnInstance;
|
||
14 years ago
|
TQPtrList<KConfigDialogManager> managers;
|
||
|
TQString _quickHelp;
|
||
15 years ago
|
|
||
|
// this member is used to record the state on non-automatically
|
||
|
// managed widgets, allowing for mixed KConfigXT-drive and manual
|
||
|
// widgets to coexist peacefully and do the correct thing with
|
||
|
// the changed(bool) signal
|
||
|
bool _unmanagedWidgetChangeState;
|
||
|
};
|
||
|
|
||
14 years ago
|
KCModule::KCModule(TQWidget *parent, const char *name, const TQStringList &)
|
||
|
: TQWidget(parent, name)
|
||
15 years ago
|
{
|
||
|
init();
|
||
|
if (name && strlen(name)) {
|
||
|
d->_instance = new KInstance(name);
|
||
|
KGlobal::locale()->insertCatalogue(name);
|
||
|
} else
|
||
|
d->_instance = new KInstance("kcmunnamed");
|
||
|
KGlobal::setActiveInstance(this->instance());
|
||
|
|
||
|
d->managers.setAutoDelete( true );
|
||
|
|
||
|
}
|
||
|
|
||
14 years ago
|
KCModule::KCModule(KInstance *instance, TQWidget *parent, const TQStringList & )
|
||
|
: TQWidget(parent, instance ? instance->instanceName().data() : 0)
|
||
15 years ago
|
{
|
||
|
init();
|
||
|
d->_instance = instance;
|
||
|
|
||
|
if (instance)
|
||
|
{
|
||
|
KGlobal::locale()->insertCatalogue(instance->instanceName());
|
||
|
}
|
||
|
|
||
|
d->_hasOwnInstance = false;
|
||
|
KGlobal::setActiveInstance(this->instance());
|
||
|
}
|
||
|
|
||
|
void KCModule::init()
|
||
|
{
|
||
|
d = new KCModulePrivate;
|
||
|
_btn = Help|Default|Apply;
|
||
|
}
|
||
|
|
||
14 years ago
|
KConfigDialogManager* KCModule::addConfig( KConfigSkeleton *config, TQWidget* widget )
|
||
15 years ago
|
{
|
||
|
KConfigDialogManager* manager = new KConfigDialogManager( widget, config, name() );
|
||
14 years ago
|
connect( manager, TQT_SIGNAL( widgetModified() ), TQT_SLOT( widgetChanged() ));
|
||
15 years ago
|
d->managers.append( manager );
|
||
|
return manager;
|
||
|
}
|
||
|
|
||
|
KCModule::~KCModule()
|
||
|
{
|
||
|
if (d->_hasOwnInstance)
|
||
|
delete d->_instance;
|
||
|
delete d->_about;
|
||
|
delete d;
|
||
|
}
|
||
|
|
||
|
void KCModule::load()
|
||
|
{
|
||
|
KConfigDialogManager* manager;
|
||
|
for( manager = d->managers.first(); manager; manager = d->managers.next() )
|
||
|
manager->updateWidgets();
|
||
|
}
|
||
|
|
||
|
void KCModule::save()
|
||
|
{
|
||
|
KConfigDialogManager* manager;
|
||
|
for( manager = d->managers.first(); manager; manager = d->managers.next() )
|
||
|
manager->updateSettings();
|
||
|
emit( changed( false ));
|
||
|
}
|
||
|
|
||
|
void KCModule::defaults()
|
||
|
{
|
||
|
KConfigDialogManager* manager;
|
||
|
for( manager = d->managers.first(); manager; manager = d->managers.next() )
|
||
|
manager->updateWidgetsDefault();
|
||
|
}
|
||
|
|
||
|
void KCModule::widgetChanged()
|
||
|
{
|
||
|
emit changed(d->_unmanagedWidgetChangeState || managedWidgetChangeState());
|
||
|
}
|
||
|
|
||
|
bool KCModule::managedWidgetChangeState() const
|
||
|
{
|
||
|
KConfigDialogManager* manager;
|
||
|
for( manager = d->managers.first(); manager; manager = d->managers.next() )
|
||
|
{
|
||
|
if ( manager->hasChanged() )
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
void KCModule::unmanagedWidgetChangeState(bool changed)
|
||
|
{
|
||
|
d->_unmanagedWidgetChangeState = changed;
|
||
|
widgetChanged();
|
||
|
}
|
||
|
|
||
|
const KAboutData *KCModule::aboutData() const
|
||
|
{
|
||
|
return d->_about;
|
||
|
}
|
||
|
|
||
|
void KCModule::setAboutData( KAboutData* about )
|
||
|
{
|
||
|
delete d->_about;
|
||
|
d->_about = about;
|
||
|
}
|
||
|
|
||
14 years ago
|
void KCModule::setRootOnlyMsg(const TQString& msg)
|
||
15 years ago
|
{
|
||
|
d->_rootOnlyMsg = msg;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString KCModule::rootOnlyMsg() const
|
||
15 years ago
|
{
|
||
|
return d->_rootOnlyMsg;
|
||
|
}
|
||
|
|
||
|
void KCModule::setUseRootOnlyMsg(bool on)
|
||
|
{
|
||
|
d->_useRootOnlyMsg = on;
|
||
|
}
|
||
|
|
||
|
bool KCModule::useRootOnlyMsg() const
|
||
|
{
|
||
|
return d->_useRootOnlyMsg;
|
||
|
}
|
||
|
|
||
|
void KCModule::changed()
|
||
|
{
|
||
|
emit changed(true);
|
||
|
}
|
||
|
|
||
|
KInstance *KCModule::instance() const
|
||
|
{
|
||
|
return d->_instance;
|
||
|
}
|
||
|
|
||
14 years ago
|
void KCModule::setQuickHelp( const TQString& help )
|
||
15 years ago
|
{
|
||
|
d->_quickHelp = help;
|
||
|
emit( quickHelpChanged() );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString KCModule::quickHelp() const
|
||
15 years ago
|
{
|
||
|
return d->_quickHelp;
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
const TQPtrList<KConfigDialogManager>& KCModule::configs() const
|
||
15 years ago
|
{
|
||
|
return d->managers;
|
||
|
}
|
||
|
|
||
|
void KCModule::virtual_hook( int, void* )
|
||
|
{ /*BASE::virtual_hook( id, data );*/ }
|
||
|
|
||
|
// vim: sw=4 et sts=4
|