1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Added Access Keys Navigation plugin. Closes #288

This commit is contained in:
nowrep 2012-03-04 18:30:34 +01:00
parent aba444259a
commit e5e5cec7a5
28 changed files with 1092 additions and 30 deletions

View File

@ -4,5 +4,7 @@ lupdate ../src/plugins/TestPlugin/TestPlugin.pro -no-obsolete
lupdate ../src/plugins/MouseGestures/MouseGestures.pro -no-obsolete
lupdate ../src/plugins/AccessKeysNavigation/AccessKeysNavigation.pro -no-obsolete
read -p "Press [ENTER] to close terminal"
exit

View File

@ -1416,7 +1416,13 @@ void QupZilla::searchOnPage()
void QupZilla::openFile()
{
const QString &filePath = QFileDialog::getOpenFileName(this, tr("Open file..."), QDir::homePath(), "(*.html *.htm *.jpg *.png)");
const QString &fileTypes = QString("%1(*.html *.htm *.shtml *.shtm);;"
"%2(*.txt);;"
"%3(*.png *.jpg *.jpeg *.bmp *.gif *.svg);;"
"%4(*.*)").arg(tr("HTML files"), tr("Image files"), tr("Text files"), tr("All files"));
const QString &filePath = QFileDialog::getOpenFileName(this, tr("Open file..."), QDir::homePath(), fileTypes);
if (!filePath.isEmpty()) {
loadAddress(QUrl::fromLocalFile(filePath));
}

View File

@ -163,7 +163,8 @@ SOURCES += \
webview/webview.cpp \
webview/webviewsettings.cpp \
preferences/pluginlistdelegate.cpp \
popupwindow/popupstatusbarmessage.cpp
popupwindow/popupstatusbarmessage.cpp \
other/licenseviewer.cpp
HEADERS += \
3rdparty/qtwin.h \
@ -298,7 +299,8 @@ HEADERS += \
app/qz_namespace.h \
webview/webviewsettings.h \
preferences/pluginlistdelegate.h \
popupwindow/popupstatusbarmessage.h
popupwindow/popupstatusbarmessage.h \
other/licenseviewer.h
FORMS += \
preferences/autofillmanager.ui \

View File

@ -0,0 +1,35 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
*
* 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 "licenseviewer.h"
#include "globalfunctions.h"
LicenseViewer::LicenseViewer(QWidget *parent)
: QTextBrowser()
{
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(tr("License Viewer"));
resize(450, 500);
qz_centerWidgetToParent(this, parent);
}
void LicenseViewer::setLicenseFile(const QString &fileName)
{
setText(qz_readAllFileContents(fileName));
}

View File

@ -0,0 +1,33 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
*
* 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/>.
* ============================================================ */
#ifndef LICENSEVIEWER_H
#define LICENSEVIEWER_H
#include <QTextBrowser>
class LicenseViewer : public QTextBrowser
{
Q_OBJECT
public:
explicit LicenseViewer(QWidget *parent = 0);
void setLicenseFile(const QString &fileName);
};
#endif // LICENSEVIEWER_H

View File

@ -146,7 +146,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
startProfileIndexChanged(ui->startProfile->currentText());
//APPEREANCE
m_themesManager = new ThemeManager(ui->themesWidget);
m_themesManager = new ThemeManager(ui->themesWidget, this);
settings.beginGroup("Browser-View-Settings");
ui->showStatusbar->setChecked(settings.value("showStatusBar", true).toBool());
ui->showBookmarksToolbar->setChecked(p_QupZilla->bookmarksToolbar()->isVisible());

View File

@ -20,6 +20,8 @@
#include "mainapplication.h"
#include "globalfunctions.h"
#include "settings.h"
#include "licenseviewer.h"
#include "preferences.h"
#include <QTextBrowser>
#include <QDir>
@ -30,9 +32,10 @@
#define DEFAULT_THEME_NAME "linux"
#endif
ThemeManager::ThemeManager(QWidget* parent)
ThemeManager::ThemeManager(QWidget* parent, Preferences *preferences)
: QWidget()
, ui(new Ui::ThemeManager)
, m_preferences(preferences)
{
ui->setupUi(parent);
ui->license->hide();
@ -78,14 +81,9 @@ void ThemeManager::showLicense()
Theme currentTheme = m_themeHash[currentItem->data(Qt::UserRole).toString()];
QTextBrowser* b = new QTextBrowser();
b->setAttribute(Qt::WA_DeleteOnClose);
b->setWindowTitle(tr("License Viewer"));
// b->move(mapToGlobal(parent()->pos()));
b->resize(450, 500);
b->setText(currentTheme.license);
qz_centerWidgetOnScreen(b);
b->show();
LicenseViewer* v = new LicenseViewer(m_preferences);
v->setText(currentTheme.license);
v->show();
}
void ThemeManager::currentChanged()

View File

@ -30,12 +30,14 @@ namespace Ui
class ThemeManager;
}
class Preferences;
class QT_QUPZILLA_EXPORT ThemeManager : public QWidget
{
Q_OBJECT
public:
explicit ThemeManager(QWidget* parent);
explicit ThemeManager(QWidget *parent, Preferences *preferences);
~ThemeManager();
void save();
@ -58,6 +60,8 @@ private:
Theme parseTheme(const QString &name);
Ui::ThemeManager* ui;
Preferences* m_preferences;
QString m_activeTheme;
QHash<QString, Theme> m_themeHash;
};

View File

@ -0,0 +1,21 @@
QT += webkit
TARGET = AccessKeysNavigation
SOURCES = \
akn_plugin.cpp \
akn_handler.cpp \
akn_settings.cpp
HEADERS = \
akn_plugin.h \
akn_handler.h \
akn_settings.h
FORMS += \
akn_settings.ui
RESOURCES = akn_res.qrc
TRANSLATIONS = translations/cs_CZ.ts \
include(../../plugins.pri)

View File

@ -0,0 +1,325 @@
/* ============================================================
* Access Keys Navigation plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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/>.
* ============================================================ */
/*
* Copyright 2008-2009 Benjamin C. Meyer <ben@meyerhome.net>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/
#include "akn_handler.h"
#include "webview.h"
#include <QApplication>
#include <QSettings>
#include <QWebPage>
#include <QWebFrame>
#include <QLabel>
#include <QTimer>
#include <QToolTip>
Qt::Key keyFromCode(int code)
{
switch (code) {
case 0:
return Qt::Key_Control;
case 1:
return Qt::Key_Alt;
case 2:
return Qt::Key_Shift;
default:
// Using default shortcut
return Qt::Key_Control;
}
}
AKN_Handler::AKN_Handler(const QString &sPath, QObject* parent)
: QObject(parent)
, m_view(0)
, m_settingsPath(sPath)
{
loadSettings();
}
QString AKN_Handler::settingsPath()
{
return m_settingsPath;
}
void AKN_Handler::loadSettings()
{
QSettings settings(m_settingsPath, QSettings::IniFormat);
settings.beginGroup("AccessKeysNavigation");
m_key = keyFromCode(settings.value("Key", 0).toInt());
m_isDoublePress = settings.value("DoublePress", true).toBool();
settings.endGroup();
}
bool AKN_Handler::handleKeyPress(QObject* obj, QKeyEvent* event)
{
WebView* view = qobject_cast<WebView*>(obj);
if (!view) {
return false;
}
if (m_accessKeysVisible) {
handleAccessKey(event);
return true;
}
if (event->key() != m_key) {
return false;
}
m_view = view;
if (!m_isDoublePress) {
triggerShowAccessKeys();
}
else {
if (!m_lastKeyPressTime.isValid()) {
// It is the first press of our button
m_lastKeyPressTime = QTime::currentTime();
}
else {
// It is the second press of our button
if (QTime(m_lastKeyPressTime).addMSecs(500) >= QTime::currentTime()) {
triggerShowAccessKeys();
}
else {
m_lastKeyPressTime = QTime::currentTime();
}
}
}
return false;
}
bool AKN_Handler::eventFilter(QObject* obj, QEvent* event)
{
if (obj != m_view) {
return false;
}
switch (event->type()) {
case QEvent::FocusOut:
case QEvent::Wheel:
hideAccessKeys();
break;
default:
break;
}
return false;
}
void AKN_Handler::triggerShowAccessKeys()
{
if (m_accessKeysVisible) {
hideAccessKeys();
}
else {
QTimer::singleShot(0, this, SLOT(showAccessKeys()));
}
}
void AKN_Handler::handleAccessKey(QKeyEvent* event)
{
if (event->key() == m_key) {
hideAccessKeys();
return;
}
QString text = event->text();
if (text.isEmpty()) {
return;
}
QChar key = text.at(0).toUpper();
if (m_accessKeyNodes.contains(key)) {
QWebElement element = m_accessKeyNodes[key];
QPoint p = element.geometry().center();
QWebFrame* frame = element.webFrame();
if (!frame) {
return;
}
do {
p -= frame->scrollPosition();
frame = frame->parentFrame();
}
while (frame && frame != m_view->page()->mainFrame());
QMouseEvent pevent(QEvent::MouseButtonPress, p, Qt::LeftButton, 0, 0);
qApp->sendEvent(m_view, &pevent);
QMouseEvent revent(QEvent::MouseButtonRelease, p, Qt::LeftButton, 0, 0);
qApp->sendEvent(m_view, &revent);
hideAccessKeys();
}
}
void AKN_Handler::showAccessKeys()
{
QWebPage* page = m_view->page();
// Install event filter and connect loadStarted
m_accessKeysVisible = true;
qApp->installEventFilter(this);
connect(m_view, SIGNAL(loadStarted()), this, SLOT(hideAccessKeys()));
QStringList supportedElement;
supportedElement << QLatin1String("input")
<< QLatin1String("a")
<< QLatin1String("area")
<< QLatin1String("button")
<< QLatin1String("label")
<< QLatin1String("legend")
<< QLatin1String("textarea");
QList<QChar> unusedKeys;
for (char c = 'A'; c <= 'Z'; ++c) {
unusedKeys << QLatin1Char(c);
}
for (char c = '0'; c <= '9'; ++c) {
unusedKeys << QLatin1Char(c);
}
QRect viewport = QRect(page->mainFrame()->scrollPosition(), page->viewportSize());
// Priority first goes to elements with accesskey attributes
QList<QWebElement> alreadyLabeled;
foreach(const QString & elementType, supportedElement) {
QList<QWebElement> result = page->mainFrame()->findAllElements(elementType).toList();
foreach(const QWebElement & element, result) {
const QRect geometry = element.geometry();
if (geometry.size().isEmpty()
|| !viewport.contains(geometry.topLeft())) {
continue;
}
QString accessKeyAttribute = element.attribute(QLatin1String("accesskey")).toUpper();
if (accessKeyAttribute.isEmpty()) {
continue;
}
QChar accessKey;
for (int i = 0; i < accessKeyAttribute.count(); i += 2) {
const QChar &possibleAccessKey = accessKeyAttribute[i];
if (unusedKeys.contains(possibleAccessKey)) {
accessKey = possibleAccessKey;
break;
}
}
if (accessKey.isNull()) {
continue;
}
unusedKeys.removeOne(accessKey);
makeAccessKeyLabel(accessKey, element);
alreadyLabeled.append(element);
}
}
// Pick an access key first from the letters in the text and then from the
// list of unused access keys
foreach(const QString & elementType, supportedElement) {
QWebElementCollection result = page->mainFrame()->findAllElements(elementType);
foreach(const QWebElement & element, result) {
const QRect geometry = element.geometry();
if (unusedKeys.isEmpty()
|| alreadyLabeled.contains(element)
|| geometry.size().isEmpty()
|| !viewport.contains(geometry.topLeft())) {
continue;
}
QChar accessKey;
QString text = element.toPlainText().toUpper();
for (int i = 0; i < text.count(); ++i) {
const QChar &c = text.at(i);
if (unusedKeys.contains(c)) {
accessKey = c;
break;
}
}
if (accessKey.isNull()) {
accessKey = unusedKeys.takeFirst();
}
unusedKeys.removeOne(accessKey);
makeAccessKeyLabel(accessKey, element);
}
}
}
void AKN_Handler::hideAccessKeys()
{
if (!m_accessKeyLabels.isEmpty()) {
for (int i = 0; i < m_accessKeyLabels.count(); ++i) {
QLabel* label = m_accessKeyLabels[i];
label->hide();
label->deleteLater();
}
m_accessKeyLabels.clear();
m_accessKeyNodes.clear();
m_view->update();
// Uninstall event filter and disconnect loadStarted
qApp->removeEventFilter(this);
disconnect(m_view, SIGNAL(loadStarted()), this, SLOT(hideAccessKeys()));
}
m_accessKeysVisible = false;
}
void AKN_Handler::makeAccessKeyLabel(const QChar &accessKey, const QWebElement &element)
{
QLabel* label = new QLabel(m_view);
label->setText(QString(QLatin1String("<b>%1</b>")).arg(accessKey));
QPalette p = QToolTip::palette();
QColor color = QColor(220, 243, 253);
color.setAlpha(175);
p.setColor(QPalette::Window, color);
label->setPalette(p);
label->setAutoFillBackground(true);
label->setFrameStyle(QFrame::Box | QFrame::Plain);
QPoint point = element.geometry().center();
point -= m_view->page()->mainFrame()->scrollPosition();
label->move(point);
label->show();
point.setX(point.x() - label->width() / 2);
label->move(point);
m_accessKeyLabels.append(label);
m_accessKeyNodes[accessKey] = element;
}

View File

@ -0,0 +1,71 @@
/* ============================================================
* Access Keys Navigation plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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/>.
* ============================================================ */
#ifndef AKN_HANDLER_H
#define AKN_HANDLER_H
#include <QObject>
#include <QTime>
#include <QHash>
#include <QWebElement>
class QKeyEvent;
class QWebElement;
class QTime;
class QLabel;
class WebView;
class AKN_Handler : public QObject
{
Q_OBJECT
public:
explicit AKN_Handler(const QString &sPath, QObject* parent = 0);
QString settingsPath();
void loadSettings();
bool handleKeyPress(QObject* obj, QKeyEvent* event);
bool eventFilter(QObject* obj, QEvent* event);
signals:
public slots:
private slots:
void showAccessKeys();
void hideAccessKeys();
private:
void triggerShowAccessKeys();
void makeAccessKeyLabel(const QChar &accessKey, const QWebElement &element);
void handleAccessKey(QKeyEvent* event);
WebView* m_view;
QList<QLabel*> m_accessKeyLabels;
QHash<QChar, QWebElement> m_accessKeyNodes;
bool m_accessKeysVisible;
Qt::Key m_key;
bool m_isDoublePress;
QTime m_lastKeyPressTime;
QString m_settingsPath;
};
#endif // AKN_HANDLER_H

View File

@ -0,0 +1,88 @@
/* ============================================================
* Access Keys Navigation plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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"
#include "pluginproxy.h"
#include "qupzilla.h"
#include <QTranslator>
AKN_Plugin::AKN_Plugin()
: QObject()
{
}
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";
spec.version = "0.1.0";
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()
{
m_handler->deleteLater();
}
bool AKN_Plugin::testPlugin()
{
// Let's be sure, require latest version of QupZilla
return (QupZilla::VERSION == "1.1.8");
}
QTranslator* AKN_Plugin::getTranslator(const QString &locale)
{
QTranslator* translator = new QTranslator();
translator->load(":/accesskeysnavigation/locale/" + locale);
return translator;
}
void AKN_Plugin::showSettings(QWidget* parent)
{
AKN_Settings* settings = new AKN_Settings(m_handler, parent);
settings->setAttribute(Qt::WA_DeleteOnClose);
settings->show();
}
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;
}
Q_EXPORT_PLUGIN2(AccessKeysNavigation, AKN_Plugin)

View File

@ -0,0 +1,47 @@
/* ============================================================
* Access Keys Navigation plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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/>.
* ============================================================ */
#ifndef AKN_PLUGIN_H
#define AKN_PLUGIN_H
#include "plugininterface.h"
class AKN_Handler;
class AKN_Plugin : public QObject, public PluginInterface
{
Q_OBJECT
Q_INTERFACES(PluginInterface)
public:
AKN_Plugin();
PluginSpec pluginSpec();
void init(const QString &sPath);
void unload();
bool testPlugin();
QTranslator* getTranslator(const QString &locale);
void showSettings(QWidget* parent = 0);
bool keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
private:
AKN_Handler* m_handler;
};
#endif // AKN_PLUGIN_H

View File

@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/accesskeysnavigation">
<file>data/icon.png</file>
<file>data/copyright</file>
</qresource>
</RCC>

View File

@ -0,0 +1,66 @@
/* ============================================================
* Access Keys Navigation plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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_settings.h"
#include "ui_akn_settings.h"
#include "akn_handler.h"
#include "licenseviewer.h"
#include <QSettings>
#include <QTextBrowser>
AKN_Settings::AKN_Settings(AKN_Handler *handler, QWidget *parent)
: QDialog(parent)
, ui(new Ui::AKN_Settings)
, m_handler(handler)
, m_settingsPath(handler->settingsPath())
{
ui->setupUi(this);
QSettings settings(m_settingsPath, QSettings::IniFormat);
settings.beginGroup("AccessKeysNavigation");
ui->key->setCurrentIndex(settings.value("Key", 0).toInt());
ui->doubleClick->setChecked(settings.value("DoublePress", true).toBool());
settings.endGroup();
connect(ui->licence, SIGNAL(clicked()), this, SLOT(showLicence()));
connect(this, SIGNAL(accepted()), this, SLOT(dialogAccepted()));
}
AKN_Settings::~AKN_Settings()
{
delete ui;
}
void AKN_Settings::dialogAccepted()
{
QSettings settings(m_settingsPath, QSettings::IniFormat);
settings.beginGroup("AccessKeysNavigation");
settings.setValue("Key", ui->key->currentIndex());
settings.setValue("DoublePress", ui->doubleClick->isChecked());
settings.endGroup();
m_handler->loadSettings();
}
void AKN_Settings::showLicence()
{
LicenseViewer* v = new LicenseViewer(this);
v->setLicenseFile(":accesskeysnavigation/data/copyright");
v->show();
}

View File

@ -0,0 +1,48 @@
/* ============================================================
* Access Keys Navigation plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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/>.
* ============================================================ */
#ifndef AKN_SETTINGS_H
#define AKN_SETTINGS_H
#include <QDialog>
namespace Ui {
class AKN_Settings;
}
class AKN_Handler;
class AKN_Settings : public QDialog
{
Q_OBJECT
public:
explicit AKN_Settings(AKN_Handler* handler, QWidget *parent = 0);
~AKN_Settings();
private slots:
void dialogAccepted();
void showLicence();
private:
Ui::AKN_Settings *ui;
AKN_Handler* m_handler;
QString m_settingsPath;
};
#endif // AKN_SETTINGS_H

View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AKN_Settings</class>
<widget class="QDialog" name="AKN_Settings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>470</width>
<height>146</height>
</rect>
</property>
<property name="windowTitle">
<string>Access Keys Navigation</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;h1&gt;Access Keys Navigation&lt;/h1&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<widget class="QComboBox" name="key">
<item>
<property name="text">
<string>Ctrl</string>
</property>
</item>
<item>
<property name="text">
<string>Alt</string>
</property>
</item>
<item>
<property name="text">
<string>Shift</string>
</property>
</item>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="doubleClick">
<property name="text">
<string>Double press</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Key for showing access keys:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="licence">
<property name="text">
<string>Licence</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AKN_Settings</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AKN_Settings</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -0,0 +1,20 @@
Access Keys showing function is under following license:
/*
* Copyright 2008-2009 Benjamin C. Meyer <ben@meyerhome.net>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 656 B

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="cs_CZ">
<context>
<name>AKN_Settings</name>
<message>
<location filename="../akn_settings.ui" line="14"/>
<source>Access Keys Navigation</source>
<translation>Klávesové zkratky</translation>
</message>
<message>
<location filename="../akn_settings.ui" line="20"/>
<source>&lt;h1&gt;Access Keys Navigation&lt;/h1&gt;</source>
<translation>&lt;h1&gt;Klávesové zkratky&lt;/h1&gt;</translation>
</message>
<message>
<location filename="../akn_settings.ui" line="33"/>
<source>Ctrl</source>
<translation>Ctrl</translation>
</message>
<message>
<location filename="../akn_settings.ui" line="38"/>
<source>Alt</source>
<translation>Alt</translation>
</message>
<message>
<location filename="../akn_settings.ui" line="43"/>
<source>Shift</source>
<translation>Shift</translation>
</message>
<message>
<location filename="../akn_settings.ui" line="51"/>
<source>Double press</source>
<translation>Dvojitý stisk</translation>
</message>
<message>
<location filename="../akn_settings.ui" line="58"/>
<source>Key for showing access keys:</source>
<translation>Klávesa pro zobrazení zkratek:</translation>
</message>
<message>
<location filename="../akn_settings.ui" line="103"/>
<source>Licence</source>
<translation>Licence</translation>
</message>
</context>
</TS>

View File

@ -19,6 +19,9 @@ HEADERS = \
mousegesturesplugin.h \
mousegesturessettingsdialog.h
FORMS += \
mousegesturessettingsdialog.ui
RESOURCES = mousegestures.qrc
TRANSLATIONS = translations/cs_CZ.ts \
@ -28,6 +31,3 @@ TRANSLATIONS = translations/cs_CZ.ts \
translations/zh_TW.ts \
include(../../plugins.pri)
FORMS += \
mousegesturessettingsdialog.ui

View File

@ -1,11 +1,29 @@
/* ============================================================
* Mouse Gestures plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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 "mousegestures.h"
#include "QjtMouseGestureFilter.h"
#include "QjtMouseGesture.h"
#include "webview.h"
#include "mainapplication.h"
#include "qupzilla.h"
#include "mousegesturessettingsdialog.h"
#include "QjtMouseGestureFilter.h"
#include "QjtMouseGesture.h"
MouseGestures::MouseGestures(QObject* parent) :
QObject(parent)
{

View File

@ -1,7 +1,23 @@
/* ============================================================
* Mouse Gestures plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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/>.
* ============================================================ */
#ifndef MOUSEGESTURES_H
#define MOUSEGESTURES_H
#include <QDebug>
#include <QObject>
#include <QMouseEvent>

View File

@ -1,3 +1,20 @@
/* ============================================================
* Mouse Gestures plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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 "mousegesturesplugin.h"
#include "pluginproxy.h"
#include "mousegestures.h"
@ -16,7 +33,7 @@ PluginSpec MouseGesturesPlugin::pluginSpec()
PluginSpec spec;
spec.name = "Mouse Gestures";
spec.info = "Mouse gestures for QupZilla";
spec.description = "Provides support for navigating by mouse gestures through webpages";
spec.description = "Provides support for navigating in webpages by mouse gestures";
spec.version = "0.1.0";
spec.author = "David Rosca <nowrep@gmail.com>";
spec.icon = QPixmap(":/mousegestures/data/icon.png");

View File

@ -1,3 +1,20 @@
/* ============================================================
* Mouse Gestures plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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/>.
* ============================================================ */
#ifndef MOUSEGESTURESPLUGIN_H
#define MOUSEGESTURESPLUGIN_H

View File

@ -1,6 +1,23 @@
/* ============================================================
* Mouse Gestures plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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 "mousegesturessettingsdialog.h"
#include "ui_mousegesturessettingsdialog.h"
#include "globalfunctions.h"
#include "licenseviewer.h"
MouseGesturesSettingsDialog::MouseGesturesSettingsDialog(QWidget* parent)
: QDialog(parent)
@ -19,11 +36,8 @@ MouseGesturesSettingsDialog::~MouseGesturesSettingsDialog()
void MouseGesturesSettingsDialog::showLicense()
{
QTextBrowser* b = new QTextBrowser();
b->setAttribute(Qt::WA_DeleteOnClose);
b->setWindowTitle(tr("License Viewer"));
b->resize(450, 500);
b->setText(qz_readAllFileContents(":mousegestures/data/copyright"));
qz_centerWidgetOnScreen(b);
b->show();
LicenseViewer* v = new LicenseViewer(this);
v->setLicenseFile(":mousegestures/data/copyright");
v->show();
}

View File

@ -1,3 +1,20 @@
/* ============================================================
* Mouse Gestures plugin for QupZilla
* Copyright (C) 2012 David Rosca <nowrep@gmail.com>
*
* 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/>.
* ============================================================ */
#ifndef MOUSEGESTURESSETTINGSDIALOG_H
#define MOUSEGESTURESSETTINGSDIALOG_H

View File

@ -1,5 +1,5 @@
TEMPLATE = subdirs
SUBDIRS = MouseGestures
SUBDIRS = MouseGestures AccessKeysNavigation
# TestPlugin only in debug build
CONFIG(debug, debug|release): SUBDIRS += TestPlugin