summaryrefslogtreecommitdiffstats
path: root/kopete/kopete/config/plugins/kopetepluginconfig.cpp
blob: 7f790a0b581e11865522b62e5fdf4243fdb85646 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
    kopetepluginconfig.cpp - Configure the Kopete plugins

    Copyright (c) 2003      by Martijn Klingens      <klingens@kde.org>

    Kopete    (c) 2001-2003 by the Kopete developers <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include "kopetepluginconfig.h"

#include <tqlayout.h>
#include <tqtimer.h>

#include <kdebug.h>
#include <klocale.h>
#include <kpluginselector.h>
#include <ksettings/dispatcher.h>

#include "kopetepluginmanager.h"

class KopetePluginConfigPrivate
{
public:
	KPluginSelector *pluginSelector;
	bool isChanged;
};

KopetePluginConfig::~KopetePluginConfig()
{
	delete d;
}

KopetePluginConfig::KopetePluginConfig( TQWidget *parent, const char *name )
: KDialogBase( Plain, i18n( "Configure Plugins" ), /*Help |*/ Cancel | Apply | Ok | User1,
	Ok, parent, name, false, true, KGuiItem( i18n( "&Reset" ), "undo" ) )
{
	d = new KopetePluginConfigPrivate;
	showButton( User1, false );
	setChanged( false );

	// FIXME: Implement this - Martijn
	enableButton( KDialogBase::Help, false );

	setInitialSize( TQSize( 640, 480 ) );

	( new TQVBoxLayout( plainPage(), 0, 0 ) )->setAutoAdd( true );
	d->pluginSelector = new KPluginSelector( plainPage() );
	setMainWidget( d->pluginSelector );
	connect( d->pluginSelector, TQT_SIGNAL( changed( bool ) ), this, TQT_SLOT( setChanged( bool ) ) );
	connect( d->pluginSelector, TQT_SIGNAL( configCommitted( const TQCString & ) ),
		KSettings::Dispatcher::self(), TQT_SLOT( reparseConfiguration( const TQCString & ) ) );

	d->pluginSelector->addPlugins( Kopete::PluginManager::self()->availablePlugins( "Plugins" ), i18n( "General Plugins" ), "Plugins" );
}

void KopetePluginConfig::setChanged( bool c )
{
	d->isChanged = c;
	enableButton( Apply, c );
}

void KopetePluginConfig::slotDefault()
{
	d->pluginSelector->defaults();
	setChanged( false );
}

void KopetePluginConfig::slotUser1()
{
	d->pluginSelector->load();
	setChanged( false );
}

void KopetePluginConfig::apply()
{
	if( d->isChanged )
	{
		d->pluginSelector->save();
		Kopete::PluginManager::self()->loadAllPlugins();
		setChanged( false );
	}
}

void KopetePluginConfig::slotApply()
{
	apply();
}

void KopetePluginConfig::slotOk()
{
	emit okClicked();
	apply();
	accept();
}

void KopetePluginConfig::slotHelp()
{
	kdWarning() << k_funcinfo << "FIXME: Implement!" << endl;
}

void KopetePluginConfig::show()
{
	d->pluginSelector->load();

	KDialogBase::show();
}

#include "kopetepluginconfig.moc"

// vim: set noet ts=4 sts=4 sw=4: