diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | bd9e6617827818fd043452c08c606f07b78014a0 (patch) | |
tree | 425bb4c3168f9c02f10150f235d2cb998dcc6108 /kapptemplate/kpartplugin | |
download | tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.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/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kapptemplate/kpartplugin')
-rw-r--r-- | kapptemplate/kpartplugin/Makefile.am | 5 | ||||
-rw-r--r-- | kapptemplate/kpartplugin/hi16-action-plugin.png | 2 | ||||
-rw-r--r-- | kapptemplate/kpartplugin/hi22-action-plugin.png | 2 | ||||
-rw-r--r-- | kapptemplate/kpartplugin/no-exe/Makefile.am | 2 | ||||
-rw-r--r-- | kapptemplate/kpartplugin/no-exe/hi16-action-plugin.png | bin | 0 -> 292 bytes | |||
-rw-r--r-- | kapptemplate/kpartplugin/no-exe/hi22-action-plugin.png | bin | 0 -> 1151 bytes | |||
-rw-r--r-- | kapptemplate/kpartplugin/plugin-Makefile.am | 20 | ||||
-rw-r--r-- | kapptemplate/kpartplugin/plugin_app.cpp | 81 | ||||
-rw-r--r-- | kapptemplate/kpartplugin/plugin_app.h | 20 | ||||
-rw-r--r-- | kapptemplate/kpartplugin/plugin_app.rc | 13 |
10 files changed, 145 insertions, 0 deletions
diff --git a/kapptemplate/kpartplugin/Makefile.am b/kapptemplate/kpartplugin/Makefile.am new file mode 100644 index 00000000..abbef9fb --- /dev/null +++ b/kapptemplate/kpartplugin/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS=no-exe + +kpartplugindir = $(kde_datadir)/kapptemplate/kpartplugin +kpartplugin_DATA = plugin-Makefile.am plugin_app.cpp plugin_app.h \ + plugin_app.rc hi16-action-plugin.png hi22-action-plugin.png diff --git a/kapptemplate/kpartplugin/hi16-action-plugin.png b/kapptemplate/kpartplugin/hi16-action-plugin.png new file mode 100644 index 00000000..f40bc9c5 --- /dev/null +++ b/kapptemplate/kpartplugin/hi16-action-plugin.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/hi16-action-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kpartplugin/no-exe/hi16-action-plugin.png $LOCATION_ROOT/$APP_NAME_LC/hi16-action-$APP_NAME_LC.png diff --git a/kapptemplate/kpartplugin/hi22-action-plugin.png b/kapptemplate/kpartplugin/hi22-action-plugin.png new file mode 100644 index 00000000..8e1a7616 --- /dev/null +++ b/kapptemplate/kpartplugin/hi22-action-plugin.png @@ -0,0 +1,2 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/hi22-action-$APP_NAME_LC.png..."; +cp $SHARE_DIR/kpartplugin/no-exe/hi22-action-plugin.png $LOCATION_ROOT/$APP_NAME_LC/hi22-action-$APP_NAME_LC.png diff --git a/kapptemplate/kpartplugin/no-exe/Makefile.am b/kapptemplate/kpartplugin/no-exe/Makefile.am new file mode 100644 index 00000000..95586248 --- /dev/null +++ b/kapptemplate/kpartplugin/no-exe/Makefile.am @@ -0,0 +1,2 @@ +kpartplugindir = $(kde_datadir)/kapptemplate/kpartplugin/no-exe +kpartplugin_DATA = hi16-action-plugin.png hi22-action-plugin.png diff --git a/kapptemplate/kpartplugin/no-exe/hi16-action-plugin.png b/kapptemplate/kpartplugin/no-exe/hi16-action-plugin.png Binary files differnew file mode 100644 index 00000000..e2d7bab8 --- /dev/null +++ b/kapptemplate/kpartplugin/no-exe/hi16-action-plugin.png diff --git a/kapptemplate/kpartplugin/no-exe/hi22-action-plugin.png b/kapptemplate/kpartplugin/no-exe/hi22-action-plugin.png Binary files differnew file mode 100644 index 00000000..4082bf10 --- /dev/null +++ b/kapptemplate/kpartplugin/no-exe/hi22-action-plugin.png diff --git a/kapptemplate/kpartplugin/plugin-Makefile.am b/kapptemplate/kpartplugin/plugin-Makefile.am new file mode 100644 index 00000000..cdb7d510 --- /dev/null +++ b/kapptemplate/kpartplugin/plugin-Makefile.am @@ -0,0 +1,20 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/Makefile.am..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/Makefile.am +INCLUDES = \$(all_includes) +METASOURCES = AUTO + +KDE_ICON = ${APP_NAME_LC} + +# Install this plugin in the KDE modules directory +kde_module_LTLIBRARIES = lib${APP_NAME_LC}plugin.la + +# This is all standard. Remove the LIB_KHTML reference if you are not +# using the KHTML Part +lib${APP_NAME_LC}plugin_la_SOURCES = plugin_${APP_NAME_LC}.cpp +lib${APP_NAME_LC}plugin_la_LIBADD = \$(LIB_KPARTS) \$(LIB_KHTML) +lib${APP_NAME_LC}plugin_la_LDFLAGS = -module \$(KDE_PLUGIN) \$(all_libraries) + +# Install the .rc file in the Part's directory (in this case, the part +# is KHTMLPart) +pluginsdir = \$(kde_datadir)/khtml/kpartplugins +plugins_DATA = plugin_${APP_NAME_LC}.rc diff --git a/kapptemplate/kpartplugin/plugin_app.cpp b/kapptemplate/kpartplugin/plugin_app.cpp new file mode 100644 index 00000000..71c68bc7 --- /dev/null +++ b/kapptemplate/kpartplugin/plugin_app.cpp @@ -0,0 +1,81 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.cpp..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.cpp +#include "plugin_${APP_NAME_LC}.h" + +#include <khtml_part.h> +#include <kaction.h> +#include <kinstance.h> +#include <kmessagebox.h> +#include <klocale.h> +#include <kgenericfactory.h> + +typedef KGenericFactory<Plugin${APP_NAME}> ${APP_NAME}Factory; +K_EXPORT_COMPONENT_FACTORY( lib${APP_NAME_LC}plugin, + ${APP_NAME}Factory( "${APP_NAME_LC}" ) ); + +Plugin${APP_NAME}::Plugin${APP_NAME}( QObject* parent, const char* name, + const QStringList & /*args*/ ) + : Plugin( parent, name ) +{ + // Instantiate all of your actions here. These will appear in + // Konqueror's menu and toolbars. + (void) new KAction( i18n("&Plugin Action"), "${APP_NAME_LC}", 0, + this, SLOT(slotAction()), + actionCollection(), "plugin_action" ); +} + +Plugin${APP_NAME}::~Plugin${APP_NAME}() +{ +} + +void Plugin${APP_NAME}::slotAction() +{ + // This plugin assumes KHTMLPart. If your plugin can handle more + // than this or a different Part than this, simply delete or + // change the following block. + if ( !parent()->inherits("KHTMLPart") ) + { + QString title( i18n( "Cannot Translate Source" ) ); + QString text( i18n( "You cannot translate anything except web pages " + "with this plugin." ) ); + + KMessageBox::sorry( 0, text, title ); + return; + } + + // Get a handle on our parent so we may get the necessary data for + // processing + KHTMLPart *part = dynamic_cast<KHTMLPart *>(parent()); + + // This plugin only uses the URL. You may use whatever data you + // need. + KURL url( part->url() ); + + // This is a standard check to make sure we are dealing with a + // valid URL + if ( !url.isValid() ) + { + QString title( i18n( "Malformed URL" ) ); + QString text( i18n( "The URL you entered is not valid, please " + "correct it and try again." ) ); + + KMessageBox::sorry( 0, text, title ); + return; + } + +// The following block is very plugin specific. In this example, we +// translate the current page with AltaVista's BabelFish. You will +// definitely want to change this. +// BEGIN + KURL work( "http://babel.altavista.com/translate.dyn" ); + + QString query( "urltext=" ); + query += KURL::encode_string( url.url() ); + work.setQuery( query ); +// END + + // Finally, execute the request + part->openURL( work ); +} + +#include <plugin_${APP_NAME_LC}.moc> diff --git a/kapptemplate/kpartplugin/plugin_app.h b/kapptemplate/kpartplugin/plugin_app.h new file mode 100644 index 00000000..3e651499 --- /dev/null +++ b/kapptemplate/kpartplugin/plugin_app.h @@ -0,0 +1,20 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.h..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.h +#ifndef PLUGIN_${APP_NAME_UC}_H +#define PLUGIN_${APP_NAME_UC}_H + +#include <kparts/plugin.h> + +class Plugin${APP_NAME} : public KParts::Plugin +{ + Q_OBJECT +public: + Plugin${APP_NAME}( QObject* parent = 0, const char* name = 0, + const QStringList &args = QStringList() ); + virtual ~Plugin${APP_NAME}(); + +public slots: + void slotAction(); +}; + +#endif // PLUGIN_${APP_NAME_UC}_H diff --git a/kapptemplate/kpartplugin/plugin_app.rc b/kapptemplate/kpartplugin/plugin_app.rc new file mode 100644 index 00000000..9d42f3b6 --- /dev/null +++ b/kapptemplate/kpartplugin/plugin_app.rc @@ -0,0 +1,13 @@ +echo "Creating $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.rc..."; +cat << EOF > $LOCATION_ROOT/$APP_NAME_LC/plugin_${APP_NAME_LC}.rc +<!DOCTYPE kpartgui> +<kpartplugin name="${APP_NAME_LC}" library="lib${APP_NAME_LC}plugin" version="1"> +<MenuBar> + <Menu name="tools"><Text>&Tools</Text> + <Action name="plugin_action"/> + </Menu> +</MenuBar> +<ToolBar name="extraToolBar"> + <Action name="plugin_action"/> +</ToolBar> +</kpartplugin> |