Falkon Develop
Cross-platform Qt-based web browser
PIM_plugin.cpp
Go to the documentation of this file.
1/* ============================================================
2* Personal Information Manager plugin for Falkon
3* Copyright (C) 2012-2014 David Rosca <nowrep@gmail.com>
4* Copyright (C) 2012-2014 Mladen Pejaković <pejakm@autistici.org>
5*
6* This program is free software: you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation, either version 3 of the License, or
9* (at your option) any later version.
10*
11* This program is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with this program. If not, see <http://www.gnu.org/licenses/>.
18* ============================================================ */
19#include "PIM_plugin.h"
20#include "PIM_handler.h"
21#include "PIM_settings.h"
22#include "mainapplication.h"
23#include "pluginproxy.h"
24#include "browserwindow.h"
25#include "webview.h"
26#include "../config.h"
27
29 : QObject()
30 , m_handler(nullptr)
31{
32}
33
34void PIM_Plugin::init(InitState state, const QString &settingsPath)
35{
36 Q_UNUSED(state)
37
38 m_handler = new PIM_Handler(settingsPath, this);
39
40 mApp->plugins()->registerAppEventHandler(PluginProxy::KeyPressHandler, this);
41
42 connect(mApp->plugins(), SIGNAL(webPageCreated(WebPage*)), m_handler, SLOT(webPageCreated(WebPage*)));
43}
44
46{
47 m_handler->unloadPlugin();
48 m_handler->deleteLater();
49}
50
52{
53 // Require the version that the plugin was built with
54 return (QString::fromLatin1(Qz::VERSION) == QLatin1String(FALKON_VERSION));
55}
56
57void PIM_Plugin::showSettings(QWidget* parent)
58{
59 m_handler->showSettings(parent);
60}
61
63{
64 m_handler->populateWebViewMenu(menu, view, r);
65}
66
67bool PIM_Plugin::keyPress(Qz::ObjectName type, QObject* obj, QKeyEvent* event)
68{
69 if (type == Qz::ON_WebView) {
70 auto* view = qobject_cast<WebView*>(obj);
71 return m_handler->keyPress(view, event);
72 }
73
74 return false;
75}
bool keyPress(WebView *view, QKeyEvent *event)
void showSettings(QWidget *parent=nullptr)
Definition: PIM_handler.cpp:89
void unloadPlugin()
void populateWebViewMenu(QMenu *menu, WebView *view, const WebHitTestResult &hitTest)
bool keyPress(Qz::ObjectName type, QObject *obj, QKeyEvent *event) override
Definition: PIM_plugin.cpp:67
void populateWebViewMenu(QMenu *menu, WebView *view, const WebHitTestResult &r) override
Definition: PIM_plugin.cpp:62
void showSettings(QWidget *parent) override
Definition: PIM_plugin.cpp:57
bool testPlugin() override
Definition: PIM_plugin.cpp:51
void unload() override
Definition: PIM_plugin.cpp:45
void init(InitState state, const QString &settingsPath) override
Definition: PIM_plugin.cpp:34
#define mApp
ObjectName
Definition: qzcommon.h:89
@ ON_WebView
Definition: qzcommon.h:90
FALKON_EXPORT const char * VERSION
Definition: qzcommon.cpp:26
State state