1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

New dialog in preferences: HTML5 Permissions

Show all sites that will have permanent permissions (be always
blocked) to show desktop notifications / use geolocation.
This commit is contained in:
nowrep 2013-01-28 18:20:36 +01:00
parent c727245d2a
commit eb583d429b
11 changed files with 498 additions and 8 deletions

View File

@ -199,8 +199,9 @@ SOURCES += \
bookmarks/bookmarkstree.cpp \
tools/html5permissions/html5permissionsmanager.cpp \
tools/html5permissions/html5permissionsnotification.cpp \
tools/html5permissions/html5permissionsdialog.cpp \
autofill/pageformcompleter.cpp \
autofill/autofill.cpp
autofill/autofill.cpp \
HEADERS += \
webview/tabpreview.h \
@ -362,8 +363,9 @@ HEADERS += \
bookmarks/bookmarkstree.h \
tools/html5permissions/html5permissionsmanager.h \
tools/html5permissions/html5permissionsnotification.h \
tools/html5permissions/html5permissionsdialog.h \
autofill/pageformcompleter.h \
autofill/autofill.h
autofill/autofill.h \
FORMS += \
preferences/autofillmanager.ui \
@ -410,7 +412,8 @@ FORMS += \
adblock/adblockaddsubscriptiondialog.ui \
preferences/useragentdialog.ui \
session/recoverywidget.ui \
tools/html5permissions/html5permissionsnotification.ui
tools/html5permissions/html5permissionsnotification.ui \
tools/html5permissions/html5permissionsdialog.ui \
RESOURCES += \
data/icons.qrc \

View File

@ -45,6 +45,7 @@
#include "clearprivatedata.h"
#include "useragentdialog.h"
#include "registerqappassociation.h"
#include "html5permissions/html5permissionsdialog.h"
#include <QSettings>
#include <QInputDialog>
@ -438,6 +439,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
//CONNECTS
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
connect(ui->cookieManagerBut, SIGNAL(clicked()), this, SLOT(showCookieManager()));
connect(ui->html5permissions, SIGNAL(clicked()), this, SLOT(showHtml5Permissions()));
connect(ui->sslManagerButton, SIGNAL(clicked()), this, SLOT(openSslManager()));
connect(ui->preferredLanguages, SIGNAL(clicked()), this, SLOT(showAcceptLanguage()));
connect(ui->deleteHtml5storage, SIGNAL(clicked()), this, SLOT(deleteHtml5storage()));
@ -454,6 +456,10 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
ui->caretBrowsing->setHidden(true);
ui->animateScrolling->setHidden(true);
#endif
#if QTWEBKIT_TO_2_2
ui->html5permissions->setDisabled(true);
#endif
}
void Preferences::showStackedPage(QListWidgetItem* item)
@ -611,6 +617,12 @@ void Preferences::showCookieManager()
m->raise();
}
void Preferences::showHtml5Permissions()
{
HTML5PermissionsDialog dialog(this);
dialog.exec();
}
void Preferences::openSslManager()
{
SSLManager* m = new SSLManager(this);

View File

@ -53,6 +53,7 @@ private slots:
void chooseDownPath();
void showCookieManager();
void showHtml5Permissions();
void useActualHomepage();
void useActualNewTab();
void openSslManager();

View File

@ -2036,7 +2036,7 @@
</widget>
<widget class="QWidget" name="privacyPage">
<layout class="QGridLayout" name="gridLayout_12">
<item row="21" column="1" colspan="3">
<item row="24" column="1" colspan="3">
<widget class="QCheckBox" name="sendReferer">
<property name="text">
<string>Send Referer header to servers</string>
@ -2050,14 +2050,14 @@
</property>
</widget>
</item>
<item row="22" column="1" colspan="3">
<item row="25" column="1" colspan="3">
<widget class="QCheckBox" name="doNotTrack">
<property name="text">
<string>Send Do Not Track header to servers</string>
</property>
</widget>
</item>
<item row="19" column="0" colspan="4">
<item row="22" column="0" colspan="4">
<widget class="QLabel" name="label_50">
<property name="text">
<string>&lt;b&gt;Other&lt;/b&gt;</string>
@ -2074,7 +2074,7 @@
</property>
</widget>
</item>
<item row="27" column="0" colspan="4">
<item row="30" column="0" colspan="4">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -2153,7 +2153,7 @@
</property>
</widget>
</item>
<item row="21" column="0">
<item row="24" column="0">
<spacer name="horizontalSpacer_20">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -2189,6 +2189,33 @@
</property>
</spacer>
</item>
<item row="20" column="0" colspan="4">
<widget class="QLabel" name="label_62">
<property name="text">
<string>&lt;b&gt;HTML5 Permissions&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="21" column="0" colspan="3">
<widget class="QLabel" name="label_63">
<property name="text">
<string>Manage HTML5 permissions</string>
</property>
</widget>
</item>
<item row="21" column="3">
<widget class="QPushButton" name="html5permissions">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>HTML5 Permisions</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="notificationsPage">

View File

@ -0,0 +1,143 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2013 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 "html5permissionsdialog.h"
#include "ui_html5permissionsdialog.h"
#include "settings.h"
#include "mainapplication.h"
#include "html5permissionsmanager.h"
HTML5PermissionsDialog::HTML5PermissionsDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::HTML5PermissionsDialog)
{
ui->setupUi(this);
loadSettings();
foreach(const QString & site, m_notificationsGranted) {
QTreeWidgetItem* item = new QTreeWidgetItem(ui->notifTree);
item->setText(0, site);
item->setText(1, tr("Allow"));
item->setData(0, Qt::UserRole + 10, Allow);
ui->notifTree->addTopLevelItem(item);
}
foreach(const QString & site, m_notificationsDenied) {
QTreeWidgetItem* item = new QTreeWidgetItem(ui->notifTree);
item->setText(0, site);
item->setText(1, tr("Deny"));
item->setData(0, Qt::UserRole + 10, Deny);
ui->notifTree->addTopLevelItem(item);
}
foreach(const QString & site, m_geolocationGranted) {
QTreeWidgetItem* item = new QTreeWidgetItem(ui->geoTree);
item->setText(0, site);
item->setText(1, tr("Allow"));
item->setData(0, Qt::UserRole + 10, Allow);
ui->geoTree->addTopLevelItem(item);
}
foreach(const QString & site, m_geolocationDenied) {
QTreeWidgetItem* item = new QTreeWidgetItem(ui->geoTree);
item->setText(0, site);
item->setText(1, tr("Deny"));
item->setData(0, Qt::UserRole + 10, Deny);
ui->geoTree->addTopLevelItem(item);
}
ui->notifTree->header()->resizeSection(0, 220);
ui->geoTree->header()->resizeSection(0, 220);
connect(ui->notifRemove, SIGNAL(clicked()), this, SLOT(removeNotifEntry()));
connect(ui->geoRemove, SIGNAL(clicked()), this, SLOT(removeGeoEntry()));
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveSettings()));
}
void HTML5PermissionsDialog::removeNotifEntry()
{
QTreeWidgetItem* item = ui->notifTree->currentItem();
if (!item) {
return;
}
Role role = static_cast<Role>(item->data(0, Qt::UserRole + 10).toInt());
QString site = item->text(0);
if (role == Allow) {
m_notificationsGranted.removeOne(site);
}
else {
m_notificationsDenied.removeOne(site);
}
delete item;
}
void HTML5PermissionsDialog::removeGeoEntry()
{
QTreeWidgetItem* item = ui->geoTree->currentItem();
if (!item) {
return;
}
Role role = static_cast<Role>(item->data(0, Qt::UserRole + 10).toInt());
QString site = item->text(0);
if (role == Allow) {
m_geolocationGranted.removeOne(site);
}
else {
m_geolocationDenied.removeOne(site);
}
delete item;
}
void HTML5PermissionsDialog::loadSettings()
{
Settings settings;
settings.beginGroup("HTML5Notifications");
m_notificationsGranted = settings.value("NotificationsGranted", QStringList()).toStringList();
m_notificationsDenied = settings.value("NotificationsDenied", QStringList()).toStringList();
m_geolocationGranted = settings.value("GeolocationGranted", QStringList()).toStringList();
m_geolocationDenied = settings.value("GeolocationDenied", QStringList()).toStringList();
settings.endGroup();
}
void HTML5PermissionsDialog::saveSettings()
{
Settings settings;
settings.beginGroup("HTML5Notifications");
settings.setValue("NotificationsGranted", m_notificationsGranted);
settings.setValue("NotificationsDenied", m_notificationsDenied);
settings.setValue("GeolocationGranted", m_geolocationGranted);
settings.setValue("GeolocationDenied", m_geolocationDenied);
settings.endGroup();
mApp->html5permissions()->loadSettings();
}
HTML5PermissionsDialog::~HTML5PermissionsDialog()
{
delete ui;
}

View File

@ -0,0 +1,57 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2013 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 HTML5PERMISSIONSDIALOG_H
#define HTML5PERMISSIONSDIALOG_H
#include <QDialog>
#include <QStringList>
namespace Ui
{
class HTML5PermissionsDialog;
}
class HTML5PermissionsDialog : public QDialog
{
Q_OBJECT
public:
explicit HTML5PermissionsDialog(QWidget* parent = 0);
~HTML5PermissionsDialog();
private slots:
void removeNotifEntry();
void removeGeoEntry();
void saveSettings();
private:
enum Role { Allow, Deny };
void loadSettings();
Ui::HTML5PermissionsDialog* ui;
QStringList m_notificationsGranted;
QStringList m_notificationsDenied;
QStringList m_geolocationGranted;
QStringList m_geolocationDenied;
};
#endif // HTML5PERMISSIONSDIALOG_H

View File

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>HTML5PermissionsDialog</class>
<widget class="QDialog" name="HTML5PermissionsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>483</width>
<height>332</height>
</rect>
</property>
<property name="windowTitle">
<string>HTML5 Permissions</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Notifications</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QTreeWidget" name="notifTree">
<property name="indentation">
<number>0</number>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Site</string>
</property>
</column>
<column>
<property name="text">
<string>Behavior</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="notifRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Geolocation</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTreeWidget" name="geoTree">
<property name="indentation">
<number>0</number>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Site</string>
</property>
</column>
<column>
<property name="text">
<string>Behavior</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="geoRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<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>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>HTML5PermissionsDialog</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>HTML5PermissionsDialog</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

@ -1,3 +1,20 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2013 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 "html5permissionsmanager.h"
#include "html5permissionsnotification.h"
#include "settings.h"

View File

@ -1,3 +1,20 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2013 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 HTML5PERMISSIONSMANAGER_H
#define HTML5PERMISSIONSMANAGER_H

View File

@ -1,3 +1,20 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2013 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 "ui_html5permissionsnotification.h"
#include "html5permissionsnotification.h"
#include "html5permissionsmanager.h"

View File

@ -1,3 +1,20 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2013 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 HTML5PERMISSIONSNOTIFICATION_H
#define HTML5PERMISSIONSNOTIFICATION_H