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

Add 'Remove and block domain' button to the cookie manager

This commit is contained in:
Zsombor Gegesy 2015-01-20 11:00:16 +01:00
parent 80dd3a8f85
commit e81cbb167a
3 changed files with 27 additions and 0 deletions

View File

@ -56,6 +56,7 @@ CookieManager::CookieManager(QWidget* parent)
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->blockDomain, SIGNAL(clicked()), this, SLOT(blockCurrentHostAndRemoveCookie()));
connect(ui->close, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close()));
connect(ui->close2, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close()));
connect(ui->close3, SIGNAL(clicked(QAbstractButton*)), this, SLOT(close()));
@ -142,6 +143,19 @@ void CookieManager::removeCookie()
mApp->cookieJar()->setAllCookies(allCookies);
}
void CookieManager::blockCurrentHostAndRemoveCookie()
{
QTreeWidgetItem* current = ui->cookieTree->currentItem();
if (!current) {
return;
}
const QString domain = (current->text(1).isEmpty()) ? current->data(0, Qt::UserRole + 10).toString() :
qvariant_cast<QNetworkCookie>(current->data(0, Qt::UserRole + 10)).domain();
removeCookie();
addBlacklist(domain);
}
void CookieManager::currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* parent)
{
Q_UNUSED(parent);
@ -277,7 +291,11 @@ void CookieManager::removeWhitelist()
void CookieManager::addBlacklist()
{
const QString server = QInputDialog::getText(this, tr("Add to blacklist"), tr("Server:"));
addBlacklist(server);
}
void CookieManager::addBlacklist(const QString &server)
{
if (server.isEmpty()) {
return;
}

View File

@ -45,6 +45,7 @@ private slots:
void currentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* parent);
void removeCookie();
void removeAll();
void blockCurrentHostAndRemoveCookie();
void slotRefreshTable();
void slotRefreshFilters();
@ -62,6 +63,7 @@ private slots:
private:
void closeEvent(QCloseEvent* e);
void keyPressEvent(QKeyEvent* e);
void addBlacklist(const QString &server);
Ui::CookieManager* ui;

View File

@ -225,6 +225,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="blockDomain">
<property name="text">
<string>Remove and block domain</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="close">
<property name="sizePolicy">