Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Plugins API

nowrep edited this page Apr 1, 2012 · 13 revisions

###Event handling In your subclass of PluginInterface class, some functions will be called from QupZilla. I will now explain how event handling works.
If you want your plugin to receive events from main QupZilla objects, you need to register your plugin as an event handler for specific event type.

#include "mainapplication.h"
#include "pluginproxy.h"

QZ_REGISTER_EVENT_HANDLER(PluginProxy::EventHandlerType)

This table shows availability of event types according to object types:

EventHandlerType Event WebView TabBar QupZilla
MouseDoubleClickHandler mouseDoubleClick no yes no
MousePressHandler mousePress yes yes no
MouseReleaseHandler mouseRelease yes yes no
MouseMoveHandler mouseMove yes yes no
KeyPressHandler wheelEvent yes yes no
KeyReleaseHandler keyPress yes no yes
WheelEventHandler keyRelease yes no yes

You can ofcourse just install event filter, but if you need to use only these events, please use them (for performance reasons).

###Scheme handlers You can register your plugin as a handler for specific url scheme.

#include "mainapplication.h"
#include "networkmanager.h"

QZ_REGISTER_SCHEME_HANDLER("scheme", SchemeHandler*)

SchemeHandler* has to be subclass of SchemeHandler (defined in schemehandler.h).

###Plugin signals You can connect to signals emitted on creation/deletion of WebPage and MainWindow objects.

#include "mainapplication.h"
#include "pluginproxy.h"

connect(mApp->pluginProxy(), SIGNAL( .... );

webPageCreated(WebPage page)* - emitted when WebPage is assigned to WebView (it can occur more than once for single WebView)
webPageDeleted(WebPage page)* - emitted before WebPage deletion

mainWindowCreated(QupZilla window)* - emitted when newly created window is created
mainWindowDeleted(QupZilla window)* - emitted before window deletion

###Adding Sidebar You need to implement subclass of SideBarInterface class (defined in sidebarinterface.h)

#include "sidebar.h"

// call this, preferably in init()
SideBarManager::addSidebar("your-unique-id", SideBarInterface*);

// remove sidebar, preferably in unload()
SideBarManager::removeSidebar("your-unique-id");

Available pages:

Clone this wiki locally