2 Extension Manager for Konqueror
4 Copyright (c) 2003 by Martijn Klingens <klingens@kde.org>
5 Copyright (c) 2004 by Arend van Beelen jr. <arend@auton.nl>
7 *************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 *************************************************************************
18 #include "konqextensionmanager.h"
21 #include <QtGui/QLayout>
22 #include <QtCore/QTimer>
25 #include <kxmlguifactory.h>
29 #include <kcomponentdata.h>
30 #include <kparts/componentfactory.h>
31 #include <kparts/plugin.h>
32 #include <kplugininfo.h>
33 #include <kpluginselector.h>
34 #include <ksettings/dispatcher.h>
35 #include <kstandardguiitem.h>
39 #include "konqmainwindow.h"
42 class KonqExtensionManagerPrivate
45 KPluginSelector
*pluginSelector
;
46 KonqMainWindow
*mainWindow
;
47 KParts::ReadOnlyPart
* activePart
;
51 KonqExtensionManager::KonqExtensionManager(QWidget
*parent
, KonqMainWindow
*mainWindow
, KParts::ReadOnlyPart
* activePart
)
54 setCaption( i18n("Configure") );
55 setButtons( Default
| Cancel
| Apply
| Ok
| User1
);
56 setButtonGuiItem( User1
, KStandardGuiItem::reset() );
57 setObjectName( "extensionmanager" );
58 showButtonSeparator( true );
60 d
= new KonqExtensionManagerPrivate
;
61 showButton(User1
, false);
64 setInitialSize(QSize(640, 480)); // FIXME: hard-coded values ?
66 d
->pluginSelector
= new KPluginSelector(this);
67 setMainWidget(d
->pluginSelector
);
68 connect(d
->pluginSelector
, SIGNAL(changed(bool)), this, SLOT(setChanged(bool)));
69 connect(d
->pluginSelector
, SIGNAL(configCommitted(const QByteArray
&)),
70 this, SLOT(reparseConfiguration(const QByteArray
&)));
72 d
->mainWindow
= mainWindow
;
73 d
->activePart
= activePart
;
75 d
->pluginSelector
->addPlugins("konqueror", i18n("Extensions"), "Extensions", KGlobal::config());
77 KComponentData componentData
= activePart
->componentData();
78 d
->pluginSelector
->addPlugins(componentData
.componentName(), i18n("Extensions"), "Tools", componentData
.config());
79 d
->pluginSelector
->addPlugins(componentData
.componentName(), i18n("Extensions"), "Statusbar", componentData
.config());
82 connect( this, SIGNAL( okClicked() ), SLOT( slotOk() ) );
83 connect( this, SIGNAL( applyClicked() ), SLOT( slotApply() ) );
84 connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) );
85 connect( this, SIGNAL( user1Clicked() ), SLOT( slotUser1() ) );
88 KonqExtensionManager::~KonqExtensionManager()
93 void KonqExtensionManager::reparseConfiguration(const QByteArray
&conf
)
95 KSettings::Dispatcher::reparseConfiguration(conf
);
98 void KonqExtensionManager::setChanged(bool c
)
101 enableButton(Apply
, c
);
104 void KonqExtensionManager::apply()
108 d
->pluginSelector
->save();
113 KParts::Plugin::loadPlugins(d
->mainWindow
, d
->mainWindow
, KGlobal::mainComponent());
114 QList
<KParts::Plugin
*> plugins
= KParts::Plugin::pluginObjects(d
->mainWindow
);
116 for (int i
= 0; i
< plugins
.size(); ++i
) {
117 d
->mainWindow
->factory()->addClient(plugins
.at(i
));
123 KParts::Plugin::loadPlugins( d
->activePart
, d
->activePart
, d
->activePart
->componentData() );
124 QList
<KParts::Plugin
*> plugins
= KParts::Plugin::pluginObjects( d
->activePart
);
126 for (int i
= 0; i
< plugins
.size(); ++i
) {
127 d
->activePart
->factory()->addClient(plugins
.at(i
));
133 void KonqExtensionManager::slotOk()
139 void KonqExtensionManager::slotApply()
144 void KonqExtensionManager::slotDefault()
146 d
->pluginSelector
->defaults();
149 void KonqExtensionManager::slotUser1()
151 d
->pluginSelector
->load();
155 void KonqExtensionManager::showEvent(QShowEvent
*event
)
157 d
->pluginSelector
->load();
158 KDialog::showEvent(event
);
161 #include "konqextensionmanager.moc"