1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-22 10:12:10 +02:00
falkonOfficial/src/other/clearprivatedata.cpp

93 lines
3.4 KiB
C++
Raw Normal View History

2011-03-03 18:29:20 +01:00
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2011 nowrep
*
* 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/>.
* ============================================================ */
2011-03-02 16:57:41 +01:00
#include "clearprivatedata.h"
#include "qupzilla.h"
#include "cookiejar.h"
#include "mainapplication.h"
#include "networkmanager.h"
#include "clickablelabel.h"
#include "ui_clearprivatedata.h"
2011-03-02 16:57:41 +01:00
2011-03-17 17:03:04 +01:00
ClearPrivateData::ClearPrivateData(QupZilla* mainClass, QWidget* parent) :
2011-03-02 16:57:41 +01:00
QDialog(parent)
,p_QupZilla(mainClass)
{
setWindowTitle(tr("Clear Recent History"));
setWindowIcon(QIcon(":/icons/qupzilla.png"));
m_layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
m_label = new QLabel(this);
m_buttonBox = new QDialogButtonBox(this);
m_buttonBox->addButton(QDialogButtonBox::Ok);
m_buttonBox->addButton(QDialogButtonBox::Cancel);
connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(dialogAccepted()));
connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(close()));
m_layout->addWidget(m_label);
m_label->setText(tr("Choose what you want to delete:"));
m_layout->addWidget(m_buttonBox);
m_clearHistory = new QCheckBox(tr("Clear history"), this);
m_clearCookies = new QCheckBox(tr("Clear cookies"), this);
m_clearCache = new QCheckBox(tr("Clear cache"), this);
m_clearIcons = new QCheckBox(tr("Clear icons"), this);
m_clearFlashCookies = new ClickableLabel(this);
m_clearFlashCookies->setText(tr("Clear cookies from Adobe Flash Player"));
m_clearHistory->setChecked(true);
m_clearCookies->setChecked(true);
m_clearCache->setChecked(true);
m_clearIcons->setChecked(true);
m_clearFlashCookies->setStyleSheet("color: blue; text-decoration: underline;");
m_clearFlashCookies->setCursor(Qt::PointingHandCursor);
m_layout->addWidget(m_clearHistory);
m_layout->addWidget(m_clearCookies);
m_layout->addWidget(m_clearCache);
m_layout->addWidget(m_clearIcons);
m_layout->addWidget(m_clearFlashCookies);
m_layout->addWidget(m_buttonBox);
connect(m_clearFlashCookies, SIGNAL(clicked(QPoint)), this, SLOT(clearFlash()));
}
void ClearPrivateData::clearFlash()
{
p_QupZilla->loadAddress(QUrl("http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager07.html"));
}
void ClearPrivateData::dialogAccepted()
{
if (m_clearHistory->isChecked()) {
QSqlQuery query;
query.exec("DELETE FROM history");
query.exec("VACUUM");
}
if (m_clearCookies->isChecked()) {
QList<QNetworkCookie> cookies;
2011-03-04 13:59:07 +01:00
mApp->cookieJar()->setAllCookies(cookies);
2011-03-02 16:57:41 +01:00
}
if (m_clearCache->isChecked()) {
2011-03-04 13:59:07 +01:00
mApp->webSettings()->clearMemoryCaches();
mApp->networkManager()->cache()->clear();
2011-03-02 16:57:41 +01:00
}
if (m_clearIcons->isChecked()) {
2011-03-04 13:59:07 +01:00
mApp->webSettings()->clearIconDatabase();
2011-03-02 16:57:41 +01:00
}
close();
}