mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Cleanup in Clear Recent History dialog
Also adjust paths to QtWebEngine
This commit is contained in:
parent
d68840a32b
commit
6117f468f4
@ -29,7 +29,6 @@
|
||||
#include "qztools.h"
|
||||
#include "cookiemanager.h"
|
||||
#include "desktopnotificationsfactory.h"
|
||||
#include "html5permissions/html5permissionsdialog.h"
|
||||
|
||||
#include <QNetworkCookie>
|
||||
#include <QMessageBox>
|
||||
@ -39,6 +38,7 @@
|
||||
#include <QSqlQuery>
|
||||
#include <QCloseEvent>
|
||||
#include <QFileInfo>
|
||||
#include <QWebEngineProfile>
|
||||
|
||||
ClearPrivateData::ClearPrivateData(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
@ -52,8 +52,6 @@ ClearPrivateData::ClearPrivateData(QWidget* parent)
|
||||
connect(ui->clear, SIGNAL(clicked(bool)), this, SLOT(dialogAccepted()));
|
||||
connect(ui->optimizeDb, SIGNAL(clicked(bool)), this, SLOT(optimizeDb()));
|
||||
connect(ui->editCookies, SIGNAL(clicked()), this, SLOT(showCookieManager()));
|
||||
connect(ui->editNotifs, SIGNAL(clicked()), this, SLOT(showNotifsPerms()));
|
||||
connect(ui->editGeoloc, SIGNAL(clicked()), this, SLOT(showGeolocPerms()));
|
||||
|
||||
Settings settings;
|
||||
settings.beginGroup("ClearPrivateData");
|
||||
@ -77,17 +75,17 @@ void ClearPrivateData::clearWebDatabases()
|
||||
{
|
||||
const QString profile = DataPaths::currentProfilePath();
|
||||
|
||||
QzTools::removeDir(profile + "/Databases");
|
||||
QzTools::removeDir(profile + "/IndexedDB");
|
||||
QzTools::removeDir(profile + "/databases");
|
||||
}
|
||||
|
||||
void ClearPrivateData::clearCache()
|
||||
{
|
||||
QFile::remove(DataPaths::currentProfilePath() + "/ApplicationCache.db");
|
||||
}
|
||||
const QString profile = DataPaths::currentProfilePath();
|
||||
|
||||
void ClearPrivateData::clearIcons()
|
||||
{
|
||||
IconProvider::instance()->clearIconsDatabase();
|
||||
QzTools::removeDir(profile + "/GPUCache");
|
||||
|
||||
mApp->webProfile()->clearHttpCache();
|
||||
}
|
||||
|
||||
void ClearPrivateData::closeEvent(QCloseEvent* e)
|
||||
@ -151,10 +149,6 @@ void ClearPrivateData::dialogAccepted()
|
||||
clearLocalStorage();
|
||||
}
|
||||
|
||||
if (ui->icons->isChecked()) {
|
||||
clearIcons();
|
||||
}
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
ui->clear->setEnabled(false);
|
||||
@ -170,16 +164,7 @@ void ClearPrivateData::optimizeDb()
|
||||
const QString profilePath = DataPaths::currentProfilePath();
|
||||
QString sizeBefore = QzTools::fileSizeToString(QFileInfo(profilePath + "/browsedata.db").size());
|
||||
|
||||
// Delete icons for entries older than 6 months
|
||||
const QDateTime date = QDateTime::currentDateTime().addMonths(-6);
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare(QSL("DELETE FROM icons WHERE id IN (SELECT id FROM history WHERE date < ?)"));
|
||||
query.addBindValue(date.toMSecsSinceEpoch());
|
||||
query.exec();
|
||||
|
||||
query.clear();
|
||||
query.exec(QSL("VACUUM"));
|
||||
IconProvider::instance()->clearOldIconsInDatabase();
|
||||
|
||||
QString sizeAfter = QzTools::fileSizeToString(QFileInfo(profilePath + "/browsedata.db").size());
|
||||
|
||||
@ -194,20 +179,6 @@ void ClearPrivateData::showCookieManager()
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void ClearPrivateData::showNotifsPerms()
|
||||
{
|
||||
HTML5PermissionsDialog* dialog = new HTML5PermissionsDialog(this);
|
||||
dialog->showFeaturePermissions(QWebEnginePage::Notifications);
|
||||
dialog->open();
|
||||
}
|
||||
|
||||
void ClearPrivateData::showGeolocPerms()
|
||||
{
|
||||
HTML5PermissionsDialog* dialog = new HTML5PermissionsDialog(this);
|
||||
dialog->showFeaturePermissions(QWebEnginePage::Geolocation);
|
||||
dialog->open();
|
||||
}
|
||||
|
||||
static const int stateDataVersion = 0x0001;
|
||||
|
||||
void ClearPrivateData::restoreState(const QByteArray &state)
|
||||
@ -247,7 +218,6 @@ void ClearPrivateData::restoreState(const QByteArray &state)
|
||||
ui->localStorage->setChecked(localStorage);
|
||||
ui->cache->setChecked(cache);
|
||||
ui->cookies->setChecked(cookies);
|
||||
ui->icons->setChecked(icons);
|
||||
}
|
||||
|
||||
QByteArray ClearPrivateData::saveState()
|
||||
@ -269,7 +239,6 @@ QByteArray ClearPrivateData::saveState()
|
||||
stream << ui->localStorage->isChecked();
|
||||
stream << ui->cache->isChecked();
|
||||
stream << ui->cookies->isChecked();
|
||||
stream << ui->icons->isChecked();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -36,15 +36,12 @@ public:
|
||||
static void clearLocalStorage();
|
||||
static void clearWebDatabases();
|
||||
static void clearCache();
|
||||
static void clearIcons();
|
||||
|
||||
private slots:
|
||||
void historyClicked(bool state);
|
||||
void dialogAccepted();
|
||||
void optimizeDb();
|
||||
void showCookieManager();
|
||||
void showNotifsPerms();
|
||||
void showGeolocPerms();
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent* e);
|
||||
|
@ -7,20 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>377</width>
|
||||
<height>342</height>
|
||||
<height>374</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Clear Recent History</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string><b>Clear Recent History</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="icon">
|
||||
<property name="sizePolicy">
|
||||
@ -37,20 +30,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Checked items will be cleared upon clicking the Clear button.</string>
|
||||
<string><b>Clear Recent History</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="history">
|
||||
<item row="6" column="1">
|
||||
<widget class="QPushButton" name="editCookies">
|
||||
<property name="text">
|
||||
<string>Visited pages history from:</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
<string>Edit cookies</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -81,13 +71,20 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="databases">
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="history">
|
||||
<property name="text">
|
||||
<string>Web databases</string>
|
||||
<string>Visited pages history from:</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Checked items will be cleared upon clicking the Clear button.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -101,6 +98,42 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QPushButton" name="clear">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="databases">
|
||||
<property name="text">
|
||||
<string>Web databases</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="cache">
|
||||
<property name="text">
|
||||
@ -111,6 +144,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QPushButton" name="optimizeDb">
|
||||
<property name="text">
|
||||
<string>Optimize database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="cookies">
|
||||
<property name="text">
|
||||
@ -121,97 +161,32 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QPushButton" name="editCookies">
|
||||
<property name="text">
|
||||
<string>Edit cookies</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="icons">
|
||||
<property name="text">
|
||||
<string>Icons</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>HTML5 notifications data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QPushButton" name="editNotifs">
|
||||
<property name="text">
|
||||
<string>Edit permissions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>HTML5 geolocation data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QPushButton" name="editGeoloc">
|
||||
<property name="text">
|
||||
<string>Edit permissions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<widget class="QPushButton" name="optimizeDb">
|
||||
<property name="text">
|
||||
<string>Optimize database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="2">
|
||||
<item row="9" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QPushButton" name="clear">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>90</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
<string>Database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<item row="7" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel</set>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -259,13 +259,18 @@ void IconProvider::saveIconsToDatabase()
|
||||
m_iconBuffer.clear();
|
||||
}
|
||||
|
||||
void IconProvider::clearIconsDatabase()
|
||||
void IconProvider::clearOldIconsInDatabase()
|
||||
{
|
||||
QSqlQuery query;
|
||||
query.exec("DELETE FROM icons");
|
||||
query.exec("VACUUM");
|
||||
// Delete icons for entries older than 6 months
|
||||
const QDateTime date = QDateTime::currentDateTime().addMonths(-6);
|
||||
|
||||
m_iconBuffer.clear();
|
||||
QSqlQuery query;
|
||||
query.prepare(QSL("DELETE FROM icons WHERE url IN (SELECT url FROM history WHERE date < ?)"));
|
||||
query.addBindValue(date.toMSecsSinceEpoch());
|
||||
query.exec();
|
||||
|
||||
query.clear();
|
||||
query.exec(QSL("VACUUM"));
|
||||
}
|
||||
|
||||
QIcon IconProvider::iconFromImage(const QImage &image)
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void saveIconsToDatabase();
|
||||
void clearIconsDatabase();
|
||||
void clearOldIconsInDatabase();
|
||||
|
||||
private:
|
||||
typedef QPair<QUrl, QImage> BufferedIcon;
|
||||
|
Loading…
Reference in New Issue
Block a user