blob: 7499c089c9d62cedf704cbf8546e19049069c031 (
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
|
#include "plugin_katehelloworld.h"
#include "plugin_katehelloworld.moc"
#include <kaction.h>
#include <klocale.h>
#include <kgenericfactory.h>
K_EXPORT_COMPONENT_FACTORY( katehelloworldplugin, KGenericFactory<KatePluginHelloWorld>( "katehelloworld" ) )
class PluginView : public KXMLGUIClient
{
friend class KatePluginHelloWorld;
public:
Kate::MainWindow *win;
};
KatePluginHelloWorld::KatePluginHelloWorld( QObject* parent, const char* name, const QStringList& )
: Kate::Plugin ( (Kate::Application*)parent, name )
{
}
KatePluginHelloWorld::~KatePluginHelloWorld()
{
}
void KatePluginHelloWorld::addView(Kate::MainWindow *win)
{
// TODO: doesn't this have to be deleted?
PluginView *view = new PluginView ();
(void) new KAction ( i18n("Insert Hello World"), 0, this,
SLOT( slotInsertHello() ), view->actionCollection(),
"edit_insert_helloworld" );
view->setInstance (new KInstance("kate"));
view->setXMLFile("plugins/katehelloworld/ui.rc");
win->guiFactory()->addClient (view);
view->win = win;
m_views.append (view);
}
void KatePluginHelloWorld::removeView(Kate::MainWindow *win)
{
for (uint z=0; z < m_views.count(); z++)
if (m_views.at(z)->win == win)
{
PluginView *view = m_views.at(z);
m_views.remove (view);
win->guiFactory()->removeClient (view);
delete view;
}
}
void KatePluginHelloWorld::slotInsertHello()
{
if (!application()->activeMainWindow())
return;
Kate::View *kv = application()->activeMainWindow()->viewManager()->activeView();
if (kv)
kv->insertText ("Hello World");
}
|