1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

Automatically clear old icons and VACUUM database every 20 runs

This commit is contained in:
David Rosca 2016-12-24 11:32:48 +01:00
parent 5d2ffc30d1
commit b5b2bf6a0b
2 changed files with 27 additions and 2 deletions

View File

@ -677,7 +677,7 @@ void MainApplication::postLaunch()
QtWin::createJumpList();
QTimer::singleShot(1000, this, SLOT(checkDefaultWebBrowser()));
QTimer::singleShot(5000, this, &MainApplication::runDeferredPostLaunchActions);
}
void MainApplication::saveSession()
@ -828,6 +828,12 @@ void MainApplication::onFocusChanged()
}
}
void MainApplication::runDeferredPostLaunchActions()
{
checkDefaultWebBrowser();
checkOptimizeDatabase();
}
void MainApplication::downloadRequested(QWebEngineDownloadItem *download)
{
downloadManager()->download(download);
@ -1067,6 +1073,22 @@ void MainApplication::checkDefaultWebBrowser()
#endif
}
void MainApplication::checkOptimizeDatabase()
{
Settings settings;
settings.beginGroup(QSL("Browser"));
const int numberOfRuns = settings.value(QSL("RunsWithoutOptimizeDb"), 0).toInt();
settings.setValue(QSL("RunsWithoutOptimizeDb"), numberOfRuns + 1);
if (numberOfRuns > 20) {
std::cout << "Optimizing database..." << std::endl;
IconProvider::instance()->clearOldIconsInDatabase();
settings.setValue(QSL("RunsWithoutOptimizeDb"), 0);
}
settings.endGroup();
}
void MainApplication::setUserStyleSheet(const QString &filePath)
{
QString userCss;

View File

@ -129,7 +129,7 @@ private slots:
void messageReceived(const QString &message);
void windowDestroyed(QObject* window);
void onFocusChanged();
void checkDefaultWebBrowser();
void runDeferredPostLaunchActions();
void downloadRequested(QWebEngineDownloadItem *download);
@ -148,6 +148,9 @@ private:
void setUserStyleSheet(const QString &filePath);
void checkDefaultWebBrowser();
void checkOptimizeDatabase();
bool m_isPrivate;
bool m_isPortable;
bool m_isClosing;