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

Plugins API

Anmol Gautam edited this page Feb 26, 2018 · 13 revisions

Page translations: АПИ прикључака

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 will have to register your plugin as an event handler for a specific event type.

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

QZ_REGISTER_EVENT_HANDLER(PluginProxy::EventHandlerType)

This table shows the 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
WheelEventHandler wheelEvent yes yes no
KeyPressHandler keyPress yes no yes
KeyReleaseHandler keyRelease yes no yes

Of course you can just install event filters, but if you want to use only these events, please use them for performance reasons.

Scheme handlers

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

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

QZ_REGISTER_SCHEME_HANDLER("scheme", SchemeHandler*)

SchemeHandler* has to be a 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 a 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