summaryrefslogtreecommitdiffstats
path: root/languages/cpp/app_templates/kateplugin2/plugin_app.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/cpp/app_templates/kateplugin2/plugin_app.cpp
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/cpp/app_templates/kateplugin2/plugin_app.cpp')
-rw-r--r--languages/cpp/app_templates/kateplugin2/plugin_app.cpp140
1 files changed, 140 insertions, 0 deletions
diff --git a/languages/cpp/app_templates/kateplugin2/plugin_app.cpp b/languages/cpp/app_templates/kateplugin2/plugin_app.cpp
new file mode 100644
index 00000000..99d78eff
--- /dev/null
+++ b/languages/cpp/app_templates/kateplugin2/plugin_app.cpp
@@ -0,0 +1,140 @@
+%{CPP_TEMPLATE}
+
+#include "plugin_%{APPNAMELC}.h"
+
+#include <kaction.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kfiledialog.h>
+
+#include <qlayout.h>
+#include <qlabel.h>
+
+class PluginView : public KXMLGUIClient
+{
+ friend class KatePlugin%{APPNAME};
+
+public:
+ Kate::MainWindow *win;
+};
+
+extern "C"
+{
+ void* init_lib%{APPNAMELC}plugin()
+ {
+ KGlobal::locale()->insertCatalogue("kate%{APPNAMELC}");
+ return new KatePluginFactory;
+ }
+}
+
+KatePluginFactory::KatePluginFactory()
+{
+ s_instance = new KInstance( "kate" );
+}
+
+KatePluginFactory::~KatePluginFactory()
+{
+ delete s_instance;
+}
+
+QObject* KatePluginFactory::createObject( QObject* parent, const char* name, const char*, const QStringList & )
+{
+ return new KatePlugin%{APPNAME}( parent, name );
+}
+
+KInstance* KatePluginFactory::s_instance = 0L;
+
+KatePlugin%{APPNAME}::KatePlugin%{APPNAME}( QObject* parent, const char* name )
+ : Kate::Plugin ( (Kate::Application*)parent, name )
+{
+}
+
+KatePlugin%{APPNAME}::~KatePlugin%{APPNAME}()
+{
+}
+
+void KatePlugin%{APPNAME}::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_%{APPNAMELC}" );
+
+ view->setInstance (new KInstance("kate"));
+ view->setXMLFile("plugins/%{APPNAMELC}/plugin_%{APPNAMELC}.rc");
+ win->guiFactory()->addClient (view);
+ view->win = win;
+
+ m_views.append (view);
+}
+
+void KatePlugin%{APPNAME}::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 KatePlugin%{APPNAME}::slotInsertHello()
+{
+ Kate::View *kv = application()->activeMainWindow()->viewManager()->activeView();
+
+ if (kv)
+ kv->insertText ("Hello World");
+}
+
+Kate::PluginConfigPage* KatePlugin%{APPNAME}::configPage (uint, QWidget *w, const char* name)
+{
+ %{APPNAME}ConfigPage* p = new %{APPNAME}ConfigPage(this, w);
+ initConfigPage( p );
+ connect( p, SIGNAL(configPageApplyRequest(%{APPNAME}ConfigPage*)), this, SLOT(slotApplyConfig(%{APPNAME}ConfigPage*)) );
+ return (Kate::PluginConfigPage*)p;
+}
+
+void KatePlugin%{APPNAME}::initConfigPage( %{APPNAME}ConfigPage* p )
+{
+ // TODO: initialize %{APPNAME}ConfigPage here
+ // NOTE: KatePlugin%{APPNAME} is friend of %{APPNAME}ConfigPage
+}
+
+void KatePlugin%{APPNAME}::slotApplyConfig( %{APPNAME}ConfigPage* p )
+{
+ // TODO: save %{APPNAME}ConfigPage here
+ // NOTE: KatePlugin%{APPNAME} is friend of %{APPNAME}ConfigPage
+}
+
+
+/**
+ * %{APPNAME}ConfigPage
+ */
+%{APPNAME}ConfigPage::%{APPNAME}ConfigPage (QObject* parent /*= 0L*/, QWidget *parentWidget /*= 0L*/)
+ : Kate::PluginConfigPage( parentWidget )
+{
+ QVBoxLayout* lo = new QVBoxLayout( this, 0, 0, "config_page_layout" );
+ lo->setSpacing(KDialogBase::spacingHint());
+
+ QLabel* lab = new QLabel("KatePlugin%{APPNAME}'s config page", this);
+
+ lo->addWidget(lab);
+
+ // TODO: add connection to emit SLOT( changed() )
+}
+
+%{APPNAME}ConfigPage::~%{APPNAME}ConfigPage()
+{
+}
+
+void %{APPNAME}ConfigPage::apply()
+{
+ emit configPageApplyRequest( this );
+}
+
+#include "plugin_%{APPNAMELC}.moc"
+