add more spacing
[personal-kdebase.git] / apps / konqueror / src / konqextensionmanager.cpp
blobc0b757cf34df23bf2ea572456445f05fbbf122a0
1 /*
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 *************************************************************************
8 * *
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. *
13 * *
14 *************************************************************************
17 // Own
18 #include "konqextensionmanager.h"
20 // Qt
21 #include <QtGui/QLayout>
22 #include <QtCore/QTimer>
24 // KDE
25 #include <kxmlguifactory.h>
26 #include <kconfig.h>
27 #include <kdebug.h>
28 #include <klocale.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>
37 // Local
38 #include "konqview.h"
39 #include "konqmainwindow.h"
42 class KonqExtensionManagerPrivate
44 public:
45 KPluginSelector *pluginSelector;
46 KonqMainWindow *mainWindow;
47 KParts::ReadOnlyPart* activePart;
48 bool isChanged;
51 KonqExtensionManager::KonqExtensionManager(QWidget *parent, KonqMainWindow *mainWindow, KParts::ReadOnlyPart* activePart)
52 : KDialog( parent )
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);
62 setChanged(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());
76 if ( activePart ) {
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()
90 delete d;
93 void KonqExtensionManager::reparseConfiguration(const QByteArray &conf)
95 KSettings::Dispatcher::reparseConfiguration(conf);
98 void KonqExtensionManager::setChanged(bool c)
100 d->isChanged = c;
101 enableButton(Apply, c);
104 void KonqExtensionManager::apply()
106 if(d->isChanged)
108 d->pluginSelector->save();
109 setChanged(false);
111 if( d->mainWindow )
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));
121 if ( d->activePart )
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()
135 apply();
136 accept();
139 void KonqExtensionManager::slotApply()
141 apply();
144 void KonqExtensionManager::slotDefault()
146 d->pluginSelector->defaults();
149 void KonqExtensionManager::slotUser1()
151 d->pluginSelector->load();
152 setChanged(false);
155 void KonqExtensionManager::showEvent(QShowEvent *event)
157 d->pluginSelector->load();
158 KDialog::showEvent(event);
161 #include "konqextensionmanager.moc"