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

Whitelisting/blacklisting cookies in Cookies Manager.

- closes #240
This commit is contained in:
nowrep 2012-02-17 18:55:34 +01:00
parent 02563035b3
commit 164166282c
16 changed files with 567 additions and 314 deletions

View File

@ -1142,7 +1142,9 @@ void QupZilla::showCookieManager()
{
CookieManager* m = mApp->cookieManager();
m->refreshTable();
m->show();
m->raise();
}
void QupZilla::showHistoryManager()

View File

@ -218,6 +218,7 @@ void AutoFillModel::completePage(WebPage* page)
if (element.attribute("type") != "text" && element.attribute("type") != "password" && element.attribute("type") != "") {
continue;
}
if (key == element.attribute("name")) {
element.setAttribute("value", value);
}

View File

@ -21,7 +21,27 @@
#include "settings.h"
//#define COOKIE_DEBUG
//TODO: black/white listing
bool containsDomain(QString string, QString domain)
{
string.prepend(".");
if (domain.startsWith("www.")) {
domain = domain.mid(4);
}
return string.contains(domain);
}
bool listContainsDomain(const QStringList &list, const QString &domain)
{
foreach(const QString & d, list) {
if (containsDomain(d, domain)) {
return true;
}
}
return false;
}
CookieJar::CookieJar(QupZilla* mainClass, QObject* parent)
: QNetworkCookieJar(parent)
, p_QupZilla(mainClass)
@ -33,11 +53,14 @@ CookieJar::CookieJar(QupZilla* mainClass, QObject* parent)
void CookieJar::loadSettings()
{
Settings settings;
settings.beginGroup("Web-Browser-Settings");
settings.beginGroup("Cookie-Settings");
m_allowCookies = settings.value("allowCookies", true).toBool();
m_allowCookiesFromDomain = settings.value("allowCookiesFromVisitedDomainOnly", false).toBool();
m_filterTrackingCookie = settings.value("filterTrackingCookie", false).toBool();
m_deleteOnClose = settings.value("deleteCookiesOnClose", false).toBool();
m_whitelist = settings.value("whitelist", QStringList()).toStringList();
m_blacklist = settings.value("blacklist", QStringList()).toStringList();
settings.endGroup();
}
void CookieJar::setAllowCookies(bool allow)
@ -47,29 +70,42 @@ void CookieJar::setAllowCookies(bool allow)
bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url)
{
if (!m_allowCookies) {
return QNetworkCookieJar::setCookiesFromUrl(QList<QNetworkCookie>(), url);
}
QList<QNetworkCookie> newList = cookieList;
foreach(const QNetworkCookie & cok, newList) {
if (m_allowCookiesFromDomain && !QString("." + url.host()).contains(cok.domain().remove("www."))) {
foreach(const QNetworkCookie & cookie, newList) {
if (!m_allowCookies && !listContainsDomain(m_whitelist, cookie.domain())) {
#ifdef COOKIE_DEBUG
qDebug() << "purged for domain mismatch" << cok;
qDebug() << "not in whitelist" << cookie;
#endif
newList.removeOne(cok);
newList.removeOne(cookie);
continue;
}
if (m_filterTrackingCookie && cok.name().startsWith("__utm")) {
if (m_allowCookies && listContainsDomain(m_blacklist, cookie.domain())) {
#ifdef COOKIE_DEBUG
qDebug() << "purged as tracking " << cok;
qDebug() << "found in blacklist" << cookie;
#endif
newList.removeOne(cok);
newList.removeOne(cookie);
continue;
}
if (m_allowCookiesFromDomain && !containsDomain(cookie.domain(), url.host())) {
#ifdef COOKIE_DEBUG
qDebug() << "purged for domain mismatch" << cookie;
#endif
newList.removeOne(cookie);
continue;
}
if (m_filterTrackingCookie && cookie.name().startsWith("__utm")) {
#ifdef COOKIE_DEBUG
qDebug() << "purged as tracking " << cookie;
#endif
newList.removeOne(cookie);
continue;
}
}
return QNetworkCookieJar::setCookiesFromUrl(newList, url);
}
@ -94,7 +130,12 @@ void CookieJar::saveCookies()
stream << count;
for (int i = 0; i < count; i++) {
stream << allCookies.at(i).toRawForm();
const QNetworkCookie &cookie = allCookies.at(i);
if (cookie.isSessionCookie()) {
continue;
}
stream << cookie.toRawForm();
}
file.close();
@ -117,14 +158,17 @@ void CookieJar::restoreCookies()
for (int i = 0; i < count; i++) {
QByteArray rawForm;
stream >> rawForm;
QNetworkCookie cok = QNetworkCookie::parseCookies(rawForm).at(0);
if (cok.expirationDate() < now) {
const QList<QNetworkCookie> &cookieList = QNetworkCookie::parseCookies(rawForm);
if (cookieList.isEmpty()) {
continue;
}
if (cok.isSessionCookie()) {
const QNetworkCookie &cookie = cookieList.at(0);
if (cookie.expirationDate() < now) {
continue;
}
restoredCookies.append(cok);
restoredCookies.append(cookie);
}
file.close();

View File

@ -21,6 +21,7 @@
#include <QNetworkCookieJar>
#include <QDebug>
#include <QFile>
#include <QStringList>
class QupZilla;
class CookieJar : public QNetworkCookieJar
@ -47,6 +48,9 @@ private:
bool m_allowCookiesFromDomain;
bool m_deleteOnClose;
QStringList m_whitelist;
QStringList m_blacklist;
QString m_activeProfil;
QList<QNetworkCookie> m_tempList;
};

View File

@ -21,30 +21,37 @@
#include "cookiejar.h"
#include "mainapplication.h"
#include "globalfunctions.h"
#include "settings.h"
CookieManager::CookieManager(QWidget* parent)
: QWidget(parent)
, ui(new Ui::CookieManager)
, m_refreshCookieJar(true)
{
setWindowModality(Qt::WindowModal);
ui->setupUi(this);
qz_centerWidgetOnScreen(this);
// Stored Cookies
connect(ui->cookieTree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
connect(ui->removeAll, SIGNAL(clicked()), this, SLOT(removeAll()));
connect(ui->removeOne, SIGNAL(clicked()), this, SLOT(removeCookie()));
connect(ui->close, SIGNAL(clicked(QAbstractButton*)), this, SLOT(hide()));
connect(ui->search, SIGNAL(returnPressed()), this, SLOT(search()));
connect(ui->close, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close()));
connect(ui->close2, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close()));
connect(ui->search, SIGNAL(textChanged(QString)), ui->cookieTree, SLOT(filterString(QString)));
// Cookie Filtering
connect(ui->whiteAdd, SIGNAL(clicked()), this, SLOT(addWhitelist()));
connect(ui->whiteRemove, SIGNAL(clicked()), this, SLOT(removeWhitelist()));
connect(ui->blackAdd, SIGNAL(clicked()), this, SLOT(addBlacklist()));
connect(ui->blackRemove, SIGNAL(clicked()), this, SLOT(removeBlacklist()));
ui->search->setInactiveText(tr("Search"));
ui->cookieTree->setDefaultItemShowMode(TreeWidget::ItemsCollapsed);
ui->cookieTree->sortItems(0, Qt::AscendingOrder);
ui->cookieTree->header()->setDefaultSectionSize(220);
ui->cookieTree->setFocus();
QShortcut* removeShortcut = new QShortcut(QKeySequence("Del"), this);
connect(removeShortcut, SIGNAL(activated()), this, SLOT(removeCookie()));
connect(removeShortcut, SIGNAL(activated()), this, SLOT(deletePressed()));
}
void CookieManager::removeAll()
@ -69,8 +76,6 @@ void CookieManager::removeCookie()
QList<QNetworkCookie> allCookies = mApp->cookieJar()->getAllCookies();
int indexToNavigate = -1;
if (current->text(1).isEmpty()) { //Remove whole cookie group
QString domain = current->whatsThis(0);
foreach(const QNetworkCookie & cookie, allCookies) {
@ -79,30 +84,21 @@ void CookieManager::removeCookie()
}
}
indexToNavigate = ui->cookieTree->indexOfTopLevelItem(current) - 1;
ui->cookieTree->deleteItem(current);
}
else {
const QNetworkCookie &cookie = qvariant_cast<QNetworkCookie>(current->data(0, Qt::UserRole + 10));
allCookies.removeOne(cookie);
indexToNavigate = ui->cookieTree->indexOfTopLevelItem(current->parent());
QTreeWidgetItem* parentItem = current->parent();
ui->cookieTree->deleteItem(current);
}
mApp->cookieJar()->setAllCookies(allCookies);
if (indexToNavigate > 0 && ui->cookieTree->topLevelItemCount() >= indexToNavigate) {
QTreeWidgetItem* scrollItem = ui->cookieTree->topLevelItem(indexToNavigate);
if (scrollItem) {
ui->cookieTree->setCurrentItem(scrollItem);
ui->cookieTree->scrollToItem(scrollItem);
if (parentItem->childCount() == 0) {
ui->cookieTree->deleteItem(parentItem);
}
}
if (!ui->search->text().isEmpty()) {
search();
}
mApp->cookieJar()->setAllCookies(allCookies);
}
void CookieManager::currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* parent)
@ -139,6 +135,7 @@ void CookieManager::currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem
void CookieManager::refreshTable()
{
QTimer::singleShot(0, this, SLOT(slotRefreshTable()));
QTimer::singleShot(0, this, SLOT(slotRefreshFilters()));
}
void CookieManager::slotRefreshTable()
@ -189,34 +186,93 @@ void CookieManager::slotRefreshTable()
QApplication::restoreOverrideCursor();
}
void CookieManager::search()
void CookieManager::slotRefreshFilters()
{
ui->cookieTree->filterString(ui->search->text());
// QString searchText = ui->search->text();
// if (searchText.isEmpty()) {
// refreshTable(false);
// return;
// }
Settings settings;
settings.beginGroup("Cookie-Settings");
QStringList whiteList = settings.value("whitelist", QStringList()).toStringList();
QStringList blackList = settings.value("blacklist", QStringList()).toStringList();
settings.endGroup();
// refreshTable(false);
// ui->cookieTree->setUpdatesEnabled(false);
ui->whiteList->addItems(whiteList);
ui->blackList->addItems(blackList);
}
// QList<QTreeWidgetItem*> items = ui->cookieTree->findItems(".*"+searchText+"*", Qt::MatchRecursive | Qt::MatchWildcard);
void CookieManager::addWhitelist()
{
const QString &server = QInputDialog::getText(this, tr("Add to whitelist"), tr("Server:"));
if (server.isEmpty()) {
return;
}
// QList<QTreeWidgetItem*> foundItems;
// foreach(QTreeWidgetItem* fitem, items) {
// if (!fitem->text(0).startsWith("."))
// continue;
// QTreeWidgetItem* item = new QTreeWidgetItem();
// item->setText(0, fitem->text(0));
// item->setText(1, fitem->text(1));
// item->setWhatsThis(1, fitem->whatsThis(1));
// foundItems.append(item);
// }
ui->whiteList->addItem(server);
}
// ui->cookieTree->clear();
// ui->cookieTree->addTopLevelItems(foundItems);
// ui->cookieTree->setUpdatesEnabled(true);
void CookieManager::removeWhitelist()
{
QListWidgetItem* current = ui->whiteList->currentItem();
if (!current) {
return;
}
delete current;
}
void CookieManager::addBlacklist()
{
const QString &server = QInputDialog::getText(this, tr("Add to blacklist"), tr("Server:"));
if (server.isEmpty()) {
return;
}
ui->blackList->addItem(server);
}
void CookieManager::removeBlacklist()
{
QListWidgetItem* current = ui->blackList->currentItem();
if (!current) {
return;
}
delete current;
}
void CookieManager::deletePressed()
{
if (ui->cookieTree->hasFocus()) {
removeCookie();
}
else if (ui->whiteList->hasFocus()) {
removeWhitelist();
}
else if (ui->blackList->hasFocus()) {
removeBlacklist();
}
}
void CookieManager::closeEvent(QCloseEvent* e)
{
QStringList whitelist;
QStringList blacklist;
for (int i = 0; i < ui->whiteList->count(); ++i) {
whitelist.append(ui->whiteList->item(i)->text());
}
for (int i = 0; i < ui->blackList->count(); ++i) {
blacklist.append(ui->blackList->item(i)->text());
}
Settings settings;
settings.beginGroup("Cookie-Settings");
settings.setValue("whitelist", whitelist);
settings.setValue("blacklist", blacklist);
settings.endGroup();
mApp->cookieJar()->loadSettings();
e->accept();
}
CookieManager::~CookieManager()

View File

@ -24,6 +24,7 @@
#include <QTreeWidgetItem>
#include <QShortcut>
#include <QHash>
#include <QInputDialog>
namespace Ui
{
@ -45,11 +46,20 @@ private slots:
void currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* parent);
void removeCookie();
void removeAll();
void search();
void slotRefreshTable();
void slotRefreshFilters();
void addWhitelist();
void removeWhitelist();
void addBlacklist();
void removeBlacklist();
void deletePressed();
private:
void closeEvent(QCloseEvent* e);
Ui::CookieManager* ui;
bool m_refreshCookieJar;

View File

@ -13,228 +13,352 @@
<property name="windowTitle">
<string>Cookies</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Find: </string>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>4</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="LineEdit" name="search"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>These cookies are stored on your computer:</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="TreeWidget" name="cookieTree">
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>true</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerMinimumSectionSize">
<number>22</number>
</attribute>
<column>
<property name="text">
<string>Server</string>
</property>
</column>
<column>
<property name="text">
<string>Cookie name</string>
</property>
</column>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Value:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Server:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Secure:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Expiration:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SqueezeLabelV2" name="name">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SqueezeLabelV2" name="value">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SqueezeLabelV2" name="server">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="path">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="SqueezeLabelV2" name="secure">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="SqueezeLabelV2" name="expiration">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="removeAll">
<property name="text">
<string>Remove all cookies</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeOne">
<property name="text">
<string>Remove cookie</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="close">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Stored Cookies</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Find: </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="LineEdit" name="search"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>These cookies are stored on your computer:</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="TreeWidget" name="cookieTree">
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>Server</string>
</property>
</column>
<column>
<property name="text">
<string>Cookie name</string>
</property>
</column>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<property name="verticalSpacing">
<number>3</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Value:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Server:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Path:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Secure:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Expiration:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="SqueezeLabelV2" name="name">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="SqueezeLabelV2" name="value">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="SqueezeLabelV2" name="server">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="path">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="SqueezeLabelV2" name="secure">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="SqueezeLabelV2" name="expiration">
<property name="text">
<string>&lt;cookie not selected&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="removeAll">
<property name="text">
<string>Remove all cookies</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeOne">
<property name="text">
<string>Remove cookies</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="close">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Cookie Filtering</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>&lt;b&gt;Cookie whitelist&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Cookies from these servers will ALWAYS be accepted (even if you have disabled saving cookies)</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<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="whiteAdd">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="whiteRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QListWidget" name="whiteList"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>&lt;b&gt;Cookie blacklist&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Cookies from these servers will NEVER be accepted</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QListWidget" name="blackList"/>
</item>
<item row="5" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<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="blackAdd">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="blackRemove">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0" colspan="2">
<widget class="QDialogButtonBox" name="close2">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View File

@ -242,6 +242,7 @@ void HistoryManager::slotRefreshTable()
query.exec("SELECT title, url, id, date FROM history ORDER BY date DESC");
int counter = 0;
QHash<QString, QTreeWidgetItem*> hash;
while (query.next()) {
const QString &title = query.value(0).toString();
const QUrl &url = query.value(1).toUrl();
@ -262,16 +263,18 @@ void HistoryManager::slotRefreshTable()
localDate = QString("%1 %2").arg(HistoryModel::titleCaseLocalizedMonth(date.month()), QString::number(date.year()));
}
QTreeWidgetItem* item = new QTreeWidgetItem();
const QList<QTreeWidgetItem*>& findParent = ui->historyTree->findItems(localDate, 0);
if (findParent.count() == 1) {
item = new QTreeWidgetItem(findParent.at(0));
QTreeWidgetItem* item;
QTreeWidgetItem* findParent = hash[localDate];
if (findParent) {
item = new QTreeWidgetItem(findParent);
}
else {
QTreeWidgetItem* newParent = new QTreeWidgetItem(ui->historyTree);
newParent->setText(0, localDate);
newParent->setIcon(0, QIcon(":/icons/menu/history_entry.png"));
ui->historyTree->addTopLevelItem(newParent);
hash[localDate] = newParent;
item = new QTreeWidgetItem(newParent);
}

View File

@ -22,6 +22,7 @@
#include <QTreeWidgetItem>
#include <QWeakPointer>
#include <QClipboard>
#include <QHash>
#include "historymodel.h"

View File

@ -185,10 +185,10 @@ QString QupZillaSchemeReply::aboutPage()
aPage.replace("%VERSION-INFO%",
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Version"), QupZilla::VERSION
#ifdef GIT_REVISION
+ " (" + GIT_REVISION + ")"
#endif
) +
#ifdef GIT_REVISION
+ " (" + GIT_REVISION + ")"
#endif
) +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("WebKit version"), QupZilla::WEBKITVERSION));
aPage.replace("%MAIN-DEVELOPER%", tr("Main developer"));
aPage.replace("%MAIN-DEVELOPER-TEXT%", authorString(QupZilla::AUTHOR.toUtf8(), "nowrep@gmail.com"));
@ -199,7 +199,7 @@ QString QupZillaSchemeReply::aboutPage()
authorString("Mariusz Fik", "fisiu@opensuse.org") + "<br/>" +
authorString("Jan Rajnoha", "honza.rajny@hotmail.com") + "<br/>" +
authorString("Daniele Cocca", "jmc@chakra-project.org")
);
);
aPage.replace("%TRANSLATORS%", tr("Translators"));
aPage.replace("%TRANSLATORS-TEXT%",
authorString("Heimen Stoffels", "vistausss@gmail.com") + " (Dutch)<br/>" +
@ -220,7 +220,7 @@ QString QupZillaSchemeReply::aboutPage()
authorString("Mladen Pejaković", "pejakm@gmail.com") + " (Serbian)<br/>" +
authorString("Unink-Lio", "unink4451@163.com") + " (Chinese)<br/>" +
authorString("Wu Cheng-Hong", "stu2731652@gmail.com") + " (Traditional Chinese)"
);
);
}
return aPage;
@ -318,10 +318,10 @@ QString QupZillaSchemeReply::configPage()
cPage.replace("%VERSION-INFO%",
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Application version"), QupZilla::VERSION
#ifdef GIT_REVISION
+ " (" + GIT_REVISION + ")"
#endif
) +
#ifdef GIT_REVISION
+ " (" + GIT_REVISION + ")"
#endif
) +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Qt version"), QT_VERSION_STR) +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("WebKit version"), QupZilla::WEBKITVERSION) +
QString("<dt>%1</dt><dd>%2<dd>").arg(tr("Build time"), QupZilla::BUILDTIME) +
@ -372,7 +372,7 @@ QString QupZillaSchemeReply::configPage()
break;
default:
keyString = keyValue.toString();
keyString = keyValue.toString();
}
if (keyString.isEmpty()) {

View File

@ -253,7 +253,13 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
connect(ui->changeUserAgent, SIGNAL(toggled(bool)), this, SLOT(changeUserAgentChanged(bool)));
changeUserAgentChanged(ui->changeUserAgent->isChecked());
//CSS Style
ui->userStyleSheet->setText(settings.value("userStyleSheet", "").toString());
connect(ui->chooseUserStylesheet, SIGNAL(clicked()), this, SLOT(chooseUserStyleClicked()));
settings.endGroup();
//Cookies
settings.beginGroup("Cookie-Settings");
ui->saveCookies->setChecked(settings.value("allowCookies", true).toBool());
if (!ui->saveCookies->isChecked()) {
ui->deleteCookiesOnClose->setEnabled(false);
@ -262,10 +268,6 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
ui->deleteCookiesOnClose->setChecked(settings.value("deleteCookiesOnClose", false).toBool());
ui->matchExactly->setChecked(settings.value("allowCookiesFromVisitedDomainOnly", false).toBool());
ui->filterTracking->setChecked(settings.value("filterTrackingCookie", false).toBool());
//CSS Style
ui->userStyleSheet->setText(settings.value("userStyleSheet", "").toString());
connect(ui->chooseUserStylesheet, SIGNAL(clicked()), this, SLOT(chooseUserStyleClicked()));
settings.endGroup();
//DOWNLOADS
@ -549,9 +551,11 @@ void Preferences::allowHtml5storageChanged(bool stat)
void Preferences::showCookieManager()
{
CookieManager* m = new CookieManager();
CookieManager* m = mApp->cookieManager();
m->refreshTable();
m->show();
m->raise();
}
void Preferences::openSslManager()
@ -800,8 +804,10 @@ void Preferences::saveSettings()
settings.setValue("HTML5StorageEnabled", ui->html5storage->isChecked());
settings.setValue("deleteHTML5StorageOnClose", ui->deleteHtml5storageOnClose->isChecked());
settings.setValue("SendReferer", ui->sendReferer->isChecked());
settings.endGroup();
//Cookies
settings.beginGroup("Cookie-Settings");
settings.setValue("allowCookies", ui->saveCookies->isChecked());
settings.setValue("deleteCookiesOnClose", ui->deleteCookiesOnClose->isChecked());
settings.setValue("allowCookiesFromVisitedDomainOnly", ui->matchExactly->isChecked());

View File

@ -26,7 +26,6 @@ SSLManager::SSLManager(QWidget* parent)
: QDialog(parent)
, ui(new Ui::SSLManager)
{
// setWindowModality(Qt::WindowModal);
setAttribute(Qt::WA_DeleteOnClose);
ui->setupUi(this);

View File

@ -264,7 +264,6 @@ void BookmarksSideBar::refreshTable()
item->setText(0, title);
item->setText(1, url.toEncoded());
item->setToolTip(0, url.toEncoded());
// item->setToolTip(1, url.toEncoded());
item->setWhatsThis(0, QString::number(id));
item->setIcon(0, icon);

View File

@ -177,6 +177,7 @@ void HistorySideBar::slotRefreshTable()
query.exec("SELECT title, url, id, date FROM history ORDER BY date DESC");
int counter = 0;
QHash<QString, QTreeWidgetItem*> hash;
while (query.next()) {
const QString &title = query.value(0).toString();
const QUrl &url = query.value(1).toUrl();
@ -198,15 +199,17 @@ void HistorySideBar::slotRefreshTable()
}
QTreeWidgetItem* item;
const QList<QTreeWidgetItem*>& findParent = ui->historyTree->findItems(localDate, 0);
if (findParent.count() == 1) {
item = new QTreeWidgetItem(findParent.at(0));
QTreeWidgetItem* findParent = hash[localDate];
if (findParent) {
item = new QTreeWidgetItem(findParent);
}
else {
QTreeWidgetItem* newParent = new QTreeWidgetItem(ui->historyTree);
newParent->setText(0, localDate);
newParent->setIcon(0, QIcon(":/icons/menu/history_entry.png"));
ui->historyTree->addTopLevelItem(newParent);
hash[localDate] = newParent;
item = new QTreeWidgetItem(newParent);
}

View File

@ -22,6 +22,7 @@
#include <QTreeWidgetItem>
#include <QShortcut>
#include <QClipboard>
#include <QHash>
#include "historymodel.h"

View File

@ -221,18 +221,18 @@ void WebPage::handleUnsupportedContent(QNetworkReply* reply)
return;
}
case QNetworkReply::ProtocolUnknownError:
case QNetworkReply::ProtocolUnknownError: {
qDebug() << "WebPage::UnsupportedContent" << url << "ProtocolUnknowError";
// We are not going to end in endless new tab opening loop in case
// user has QupZilla as default provider for http / https urls
if (!url.scheme().startsWith("http")) {
// We will open only known url schemes that we cannot handle
const QString &urlScheme = url.scheme();
if (urlScheme == "ftp" || urlScheme == "mailto") {
QDesktopServices::openUrl(url);
}
reply->deleteLater();
return;
}
default:
break;
}
@ -250,7 +250,7 @@ void WebPage::downloadRequested(const QNetworkRequest &request)
void WebPage::setSSLCertificate(const QSslCertificate &cert)
{
// if (cert != m_SslCert)
// if (cert != m_SslCert)
m_SslCert = cert;
}