2 Copyright (c) 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "proxywidget.h"
23 #include <kapplication.h>
25 #include <kservicegroup.h>
26 #include <k3process.h>
28 #include <kstandarddirs.h>
29 #include <kauthorized.h>
30 #include <kservicetypetrader.h>
31 #include <kcmoduleloader.h>
35 #include <QVBoxLayout>
41 #include <QX11EmbedWidget>
44 #include <sys/types.h>
46 #include "modules.moc"
48 ConfigModule::ConfigModule(const KService::Ptr
&s
) :
49 KCModuleInfo(s
), _module(0) {
52 ConfigModule::~ConfigModule() {
56 ProxyWidget
*ConfigModule::module() {
60 kDebug() << "Finding proxy..." << endl
;
62 KCModule
*modWidget
= 0;
64 modWidget
= KCModuleLoader::loadModule(*this,/*KCModuleLoader::None*/(KCModuleLoader::ErrorReporting
)NULL
);
66 if (modWidget
==NULL
) {
68 kWarning() << "Unable to load KCM Module" << endl
;
72 _module
= new ProxyWidget(modWidget
);
77 QPixmap
ConfigModule::realIcon(KIconLoader::StdSizes size
) {
78 //The next line is identical as SmallIcon(module->icon()), but is able to return a isNull() QPixmap
79 QPixmap providedIcon
= KIconLoader::global()->loadIcon(icon(), KIconLoader::Small
, size
, KIconLoader::DefaultState
, QStringList(), 0L, true);
80 if (providedIcon
.isNull()) {
81 kDebug() << "Icon is null" << icon() << endl
;
82 return SmallIcon("computer", size
);
89 void ConfigModule::deleteClient() {
98 const KAboutData
*ConfigModule::aboutData() const {
101 return _module
->aboutData();
104 ConfigModuleList::ConfigModuleList() {
105 foreach(ConfigModule
* configModule
, *this) {
112 bool ConfigModuleList::readDesktopEntries() {
113 KService::List list
= KServiceTypeTrader::self()->query("KCModule", "[X-KDE-ParentApp] == 'kinfocenter'");
115 if (list
.isEmpty()) {
119 foreach(const KService::Ptr
&s
, list
) {
120 if (s
->isType(KST_KService
) == false) {
124 if (!KAuthorized::authorizeControlModule(s
->menuId())) {
128 ConfigModule
*module
= new ConfigModule(s
);
129 if (module
->library().isEmpty()) {