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.
208 lines
6.5 KiB
208 lines
6.5 KiB
15 years ago
|
/* This file is part of the KDE libraries
|
||
|
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.
|
||
|
*/
|
||
|
|
||
|
#ifndef KCMODULECONTAINER_H
|
||
|
#define KCMODULECONTAINER_H
|
||
|
|
||
14 years ago
|
#include <tqvaluelist.h>
|
||
|
#include <tqstring.h>
|
||
|
#include <tqstringlist.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdecmodule.h>
|
||
|
#include <tdecmoduleloader.h>
|
||
15 years ago
|
|
||
14 years ago
|
class TQTabWidget;
|
||
|
class TQWidget;
|
||
|
class TQVBoxLayout;
|
||
15 years ago
|
|
||
12 years ago
|
class TDECModuleProxy;
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* @ingroup tdecmodule
|
||
12 years ago
|
* @brief TDECModuleContainer is a convenience class encapsulating several TDECModules.
|
||
15 years ago
|
*
|
||
12 years ago
|
* The TDECModuleContainer class is a convenience class for organizing a multiple set
|
||
|
* of TDECModule. TDECModuleContainer is a sub class of TDECModule and builds an interface mainly
|
||
14 years ago
|
* consisting of a tab widget where each tab contains one of the modules specified via one of the
|
||
12 years ago
|
* constructors. TDECModuleContainer can handle modules which requires root permissions. What you
|
||
15 years ago
|
* most likely want is the KCMODULECONTAINER macro. \n
|
||
|
* Sometimes it is of interest to detect in runtime whether a module should be loaded or not. This
|
||
12 years ago
|
* can be achieved by sub classing TDECModuleContainer, doing the probing/testing checks and then manually
|
||
15 years ago
|
* call addModule for each module which should be displayed. When all calls to addModule is done, call
|
||
|
* finalize() which performs some necessary final steps.
|
||
|
*
|
||
|
* @author Frans Englich <frans.englich@telia.com>
|
||
|
* @since 3.4
|
||
|
*/
|
||
12 years ago
|
class KUTILS_EXPORT TDECModuleContainer : public TDECModule
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
/**
|
||
12 years ago
|
* Creates a TDECModuleContainer with tabs, each one containing one of the
|
||
15 years ago
|
* specified modules in @p mods.
|
||
|
*
|
||
14 years ago
|
* @param parent the parent TQWidget.
|
||
15 years ago
|
* @param name the module's name.
|
||
12 years ago
|
* @param mods The list of TDECModules to be loaded. The name of each
|
||
|
* TDECModule is its service name, that is the name of the desktop file without
|
||
15 years ago
|
* the ".desktop" part
|
||
|
*
|
||
|
*/
|
||
12 years ago
|
TDECModuleContainer( TQWidget* parent, const char* name, const TQStringList& mods );
|
||
15 years ago
|
|
||
|
/**
|
||
14 years ago
|
* This is a convenience function, instead of building a TQStringList you
|
||
|
* can specify the modules in a comma separated TQString. For example;
|
||
15 years ago
|
* \code
|
||
12 years ago
|
* TDECModuleContainer* cont = TDECModuleContainer( this, "kcm_misc", TQString("kcm_energy, kcm_keyboard ,kcm_useraccount, kcm_mouse") );
|
||
15 years ago
|
* \endcode
|
||
|
* The other constructor takes its modules in a QStringlist which also can be constructed from a
|
||
|
* string and thus you will have to be explicit on the data type.
|
||
|
*
|
||
12 years ago
|
* What you probably want is the KCMODULECONTAINER macro which builds an TDECModule
|
||
15 years ago
|
* for you, taking the modules you want as argument.
|
||
|
*
|
||
|
* @param parent The parent widget
|
||
|
* @param name The service name
|
||
|
* @param mods The modules to load
|
||
12 years ago
|
* @return The TDECModule containing the requested modules.
|
||
15 years ago
|
*/
|
||
12 years ago
|
TDECModuleContainer( TQWidget *parent, const char* name, const TQString& mods = TQString() );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Adds the specified module to the tab widget. Setting the tab icon, text,
|
||
|
* tool tip, connecting the signals is what it does.
|
||
|
*
|
||
|
* @param module the name of the module to add. The name is the desktop file's name
|
||
|
* without the ".desktop" part.
|
||
|
*/
|
||
14 years ago
|
void addModule( const TQString& module );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Default destructor.
|
||
|
*/
|
||
12 years ago
|
virtual ~TDECModuleContainer();
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Reimplemented for internal purposes.
|
||
|
* @internal
|
||
|
*/
|
||
|
void save();
|
||
|
|
||
|
/**
|
||
|
* Reimplemented for internal purposes.
|
||
|
* @internal
|
||
|
*/
|
||
|
void load();
|
||
|
|
||
|
/**
|
||
|
* Reimplemented for internal purposes.
|
||
|
* @internal
|
||
|
*/
|
||
|
void defaults();
|
||
|
|
||
|
protected:
|
||
|
|
||
|
/**
|
||
|
* Sets this KCM's buttons and adds a AdminMode button
|
||
12 years ago
|
* if necessary. If TDECModuleContainer is subclassed finalize()
|
||
15 years ago
|
* should be called in the constructor after all calls to addModule
|
||
|
* have been done. Call it once.
|
||
|
*/
|
||
|
void finalize();
|
||
|
|
||
12 years ago
|
typedef TQValueList<TDECModuleProxy*> ModuleList;
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* A list containing TDECModuleProxy objects which
|
||
15 years ago
|
* have changed and must be saved.
|
||
|
*/
|
||
|
ModuleList changedModules;
|
||
|
|
||
|
/**
|
||
|
* A list of all modules which are encapsulated.
|
||
|
*/
|
||
|
ModuleList allModules; // KDE 4 put in the Private class and abstract with getter
|
||
|
|
||
|
private slots:
|
||
|
|
||
|
/**
|
||
|
* Enables/disables the Admin Mode button, as appropriate.
|
||
|
*/
|
||
14 years ago
|
void tabSwitched( TQWidget * module );
|
||
15 years ago
|
|
||
12 years ago
|
void moduleChanged(TDECModuleProxy *proxy);
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Called when the user clicks our custom root button.
|
||
|
*/
|
||
|
void runAsRoot();
|
||
|
|
||
|
/**
|
||
|
* Enables the admin mode button
|
||
|
*/
|
||
|
void rootExited();
|
||
|
|
||
|
private:
|
||
|
|
||
|
void init();
|
||
|
|
||
12 years ago
|
class TDECModuleContainerPrivate;
|
||
|
TDECModuleContainerPrivate *d;
|
||
15 years ago
|
|
||
|
};
|
||
|
|
||
|
/**
|
||
12 years ago
|
* @ingroup tdecmodule
|
||
12 years ago
|
* This macro creates an factory declaration which when run creates an TDECModule with specified
|
||
15 years ago
|
* modules. For example:
|
||
|
* \code
|
||
|
* KCMODULECONTAINER( "kcm_fonts, kcm_keyboard,kcm_fonts", misc_modules)
|
||
|
* \endcode
|
||
12 years ago
|
* would create a TDECModule with three tabs, each containing one of the specified KCMs. Each
|
||
15 years ago
|
* use of the macro must be accompanied by a desktop file where the factory name equals
|
||
|
* the second argument in the macro(in this example, misc_modules). \n
|
||
|
* The module container takes care of testing the contained modules when being shown, as well
|
||
|
* as when the module itself is asked whether it should be shown.
|
||
|
*
|
||
|
* @param modules the modules to put in the container
|
||
|
* @param factoryName what factory name the module should have
|
||
|
*/
|
||
|
#define KCMODULECONTAINER( modules, factoryName ) \
|
||
|
extern "C" \
|
||
|
{ \
|
||
12 years ago
|
TDECModule *create_## factoryName(TQWidget *parent, const char *name) \
|
||
15 years ago
|
{ \
|
||
12 years ago
|
return new TDECModuleContainer( parent, name, TQString( modules ) ); \
|
||
15 years ago
|
} \
|
||
|
\
|
||
|
bool test_## factoryName() \
|
||
|
{ \
|
||
14 years ago
|
TQStringList modList = TQStringList::split( ",", TQString(modules).remove( " " )); \
|
||
|
for ( TQStringList::Iterator it = modList.begin(); it != modList.end(); ++it ) \
|
||
12 years ago
|
if ( TDECModuleLoader::testModule( *it ) ) \
|
||
15 years ago
|
return true; \
|
||
|
return false; \
|
||
|
} \
|
||
|
}
|
||
|
|
||
|
#endif // KCMODULECONTAINER_H
|
||
|
|