diff --git a/src/lib/other/clearprivatedata.cpp b/src/lib/other/clearprivatedata.cpp index c627bcbe2..4fd9ba004 100644 --- a/src/lib/other/clearprivatedata.cpp +++ b/src/lib/other/clearprivatedata.cpp @@ -29,7 +29,6 @@ #include "qztools.h" #include "cookiemanager.h" #include "desktopnotificationsfactory.h" -#include "html5permissions/html5permissionsdialog.h" #include #include @@ -39,6 +38,7 @@ #include #include #include +#include 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; } diff --git a/src/lib/other/clearprivatedata.h b/src/lib/other/clearprivatedata.h index 4070acaab..eaed5ecae 100644 --- a/src/lib/other/clearprivatedata.h +++ b/src/lib/other/clearprivatedata.h @@ -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); diff --git a/src/lib/other/clearprivatedata.ui b/src/lib/other/clearprivatedata.ui index 934e93eda..851869819 100644 --- a/src/lib/other/clearprivatedata.ui +++ b/src/lib/other/clearprivatedata.ui @@ -7,20 +7,13 @@ 0 0 377 - 342 + 374 Clear Recent History - - - - <b>Clear Recent History</b> - - - @@ -37,20 +30,17 @@ - - + + - Checked items will be cleared upon clicking the Clear button. + <b>Clear Recent History</b> - - + + - Visited pages history from: - - - false + Edit cookies @@ -81,13 +71,20 @@ - - + + - Web databases + Visited pages history from: - true + false + + + + + + + Checked items will be cleared upon clicking the Clear button. @@ -101,6 +98,42 @@ + + + + + 90 + 0 + + + + Clear + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel + + + false + + + + + + + Web databases + + + true + + + @@ -111,6 +144,13 @@ + + + + Optimize database + + + @@ -121,97 +161,32 @@ - - - - Edit cookies - - - - - - - Icons - - - false - - - - - - - HTML5 notifications data - - - - - - - Edit permissions - - - - - - - HTML5 geolocation data - - - - - - - Edit permissions - - - - - - - Optimize database - - - - - - - Database - - - - + Qt::Horizontal - - - - - 90 - 0 - - + + - Clear + Database - - + + - Qt::Horizontal + Qt::Vertical - - QDialogButtonBox::Cancel + + + 20 + 40 + - - false - - + diff --git a/src/lib/tools/iconprovider.cpp b/src/lib/tools/iconprovider.cpp index 43f5b5451..df69a9890 100644 --- a/src/lib/tools/iconprovider.cpp +++ b/src/lib/tools/iconprovider.cpp @@ -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) diff --git a/src/lib/tools/iconprovider.h b/src/lib/tools/iconprovider.h index b33fcd97d..5d77cb176 100644 --- a/src/lib/tools/iconprovider.h +++ b/src/lib/tools/iconprovider.h @@ -70,7 +70,7 @@ public: public slots: void saveIconsToDatabase(); - void clearIconsDatabase(); + void clearOldIconsInDatabase(); private: typedef QPair BufferedIcon;