2012-03-04 18:30:34 +01:00
|
|
|
/* ============================================================
|
|
|
|
* Access Keys Navigation plugin for QupZilla
|
2013-03-11 17:45:48 +01:00
|
|
|
* Copyright (C) 2012-2013 David Rosca <nowrep@gmail.com>
|
2012-03-04 18:30:34 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
* ============================================================ */
|
|
|
|
#include "akn_plugin.h"
|
|
|
|
#include "akn_handler.h"
|
|
|
|
#include "akn_settings.h"
|
2012-03-21 15:05:04 +01:00
|
|
|
#include "mainapplication.h"
|
2012-03-04 18:30:34 +01:00
|
|
|
#include "pluginproxy.h"
|
|
|
|
#include "qupzilla.h"
|
|
|
|
|
|
|
|
#include <QTranslator>
|
|
|
|
|
|
|
|
AKN_Plugin::AKN_Plugin()
|
|
|
|
: QObject()
|
2012-03-05 11:30:18 +01:00
|
|
|
, m_handler(0)
|
2012-03-04 18:30:34 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginSpec AKN_Plugin::pluginSpec()
|
|
|
|
{
|
|
|
|
PluginSpec spec;
|
|
|
|
spec.name = "Access Keys Navigation";
|
|
|
|
spec.info = "Access keys navigation for QupZilla";
|
|
|
|
spec.description = "Provides support for navigating in webpages by keyboard shortcuts";
|
2012-09-11 11:31:28 +02:00
|
|
|
spec.version = "0.4.2";
|
2012-03-04 18:30:34 +01:00
|
|
|
spec.author = "David Rosca <nowrep@gmail.com>";
|
|
|
|
spec.icon = QPixmap(":/accesskeysnavigation/data/icon.png");
|
|
|
|
spec.hasSettings = true;
|
|
|
|
|
|
|
|
return spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AKN_Plugin::init(const QString &sPath)
|
|
|
|
{
|
|
|
|
m_handler = new AKN_Handler(sPath, this);
|
|
|
|
|
|
|
|
QZ_REGISTER_EVENT_HANDLER(PluginProxy::KeyPressHandler);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AKN_Plugin::unload()
|
|
|
|
{
|
2012-09-11 11:31:28 +02:00
|
|
|
delete m_settings.data();
|
|
|
|
|
2012-03-04 18:30:34 +01:00
|
|
|
m_handler->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AKN_Plugin::testPlugin()
|
|
|
|
{
|
|
|
|
// Let's be sure, require latest version of QupZilla
|
|
|
|
|
2013-03-11 17:45:48 +01:00
|
|
|
return (QupZilla::VERSION == QLatin1String("1.4.0"));
|
2012-03-04 18:30:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QTranslator* AKN_Plugin::getTranslator(const QString &locale)
|
|
|
|
{
|
2012-04-01 16:36:38 +02:00
|
|
|
QTranslator* translator = new QTranslator(this);
|
2012-04-04 18:48:54 +02:00
|
|
|
translator->load(locale, ":/accesskeysnavigation/locale/");
|
2012-03-04 18:30:34 +01:00
|
|
|
return translator;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AKN_Plugin::showSettings(QWidget* parent)
|
|
|
|
{
|
2012-09-11 11:31:28 +02:00
|
|
|
if (!m_settings) {
|
|
|
|
m_settings = new AKN_Settings(m_handler, parent);
|
|
|
|
}
|
2012-03-04 18:30:34 +01:00
|
|
|
|
2012-09-11 11:31:28 +02:00
|
|
|
m_settings.data()->show();
|
|
|
|
m_settings.data()->raise();
|
2012-03-04 18:30:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AKN_Plugin::keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event)
|
|
|
|
{
|
|
|
|
if (type == Qz::ON_WebView) {
|
|
|
|
return m_handler->handleKeyPress(obj, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-01-16 14:53:17 +01:00
|
|
|
#if QT_VERSION < 0x050000
|
2012-03-04 18:30:34 +01:00
|
|
|
Q_EXPORT_PLUGIN2(AccessKeysNavigation, AKN_Plugin)
|
2013-01-16 14:53:17 +01:00
|
|
|
#endif
|