You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.7 KiB
67 lines
1.7 KiB
|
|
#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( TQObject* tqparent, const char* name, const TQStringList& )
|
|
: Kate::Plugin ( (Kate::Application*)tqparent, 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,
|
|
TQT_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");
|
|
}
|