1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

Added option to choose where to store network cache.

This commit is contained in:
nowrep 2013-02-10 14:50:18 +01:00
parent 06b582a37e
commit a1a8fb90f5
7 changed files with 94 additions and 48 deletions

View File

@ -14,6 +14,7 @@ Version 1.4.0
* option to hide reload/stop buttons in navigationbar
* option to disable alt/ctrl + numbers shortcuts
* option to switch to tab from locationbar popup completer
* option to set where to store network cache
* use .qupzilla/tmp instead of /tmp for temporary data
* saving passwords should now work for much more sites
* don't steal Ctrl+B/U/I shortcuts from page

View File

@ -855,9 +855,13 @@ SearchEnginesManager* MainApplication::searchEnginesManager()
QNetworkDiskCache* MainApplication::networkCache()
{
if (!m_networkCache) {
const QString &cachePath = "networkcache/" + qWebKitVersion() + "/";
Settings settings;
const QString &basePath = settings.value("Web-Browser-Settings/CachePath",
QString("%1networkcache/").arg(m_activeProfil)).toString();
const QString &cachePath = basePath + "/" + qWebKitVersion() + "/";
m_networkCache = new QNetworkDiskCache(this);
m_networkCache->setCacheDirectory(m_activeProfil + cachePath);
m_networkCache->setCacheDirectory(cachePath);
}
return m_networkCache;

View File

@ -88,14 +88,14 @@ NetworkManager::NetworkManager(QupZilla* mainClass, QObject* parent)
void NetworkManager::loadSettings()
{
Settings settings;
settings.beginGroup("Web-Browser-Settings");
if (settings.value("AllowLocalCache", true).toBool() && !mApp->isPrivateSession()) {
if (settings.value("Web-Browser-Settings/AllowLocalCache", true).toBool() && !mApp->isPrivateSession()) {
QNetworkDiskCache* cache = mApp->networkCache();
cache->setMaximumCacheSize(settings.value("MaximumCacheSize", 50).toInt() * 1024 * 1024); //MegaBytes
setCache(cache);
}
settings.beginGroup("Web-Browser-Settings");
m_doNotTrack = settings.value("DoNotTrack", false).toBool();
m_sendReferer = settings.value("SendReferer", true).toBool();
settings.endGroup();

View File

@ -262,8 +262,10 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
ui->allowCache->setChecked(settings.value("AllowLocalCache", true).toBool());
ui->cacheMB->setValue(settings.value("LocalCacheSize", 50).toInt());
ui->MBlabel->setText(settings.value("LocalCacheSize", 50).toString() + " MB");
ui->cachePath->setText(settings.value("CachePath", QString("%1networkcache/").arg(mApp->currentProfilePath())).toString());
connect(ui->allowCache, SIGNAL(clicked(bool)), this, SLOT(allowCacheChanged(bool)));
connect(ui->cacheMB, SIGNAL(valueChanged(int)), this, SLOT(cacheValueChanged(int)));
connect(ui->changeCachePath, SIGNAL(clicked()), this, SLOT(changeCachePathClicked()));
allowCacheChanged(ui->allowCache->isChecked());
//PASSWORD MANAGER
@ -520,6 +522,9 @@ void Preferences::allowCacheChanged(bool state)
{
ui->cacheFrame->setEnabled(state);
ui->cacheMB->setEnabled(state);
ui->storeCacheLabel->setEnabled(state);
ui->cachePath->setEnabled(state);
ui->changeCachePath->setEnabled(state);
}
void Preferences::useActualHomepage()
@ -534,7 +539,7 @@ void Preferences::useActualNewTab()
void Preferences::chooseDownPath()
{
QString userFileName = QFileDialog::getExistingDirectory(p_QupZilla, tr("Choose download location..."), QDir::homePath());
QString userFileName = QFileDialog::getExistingDirectory(this, tr("Choose download location..."), QDir::homePath());
if (userFileName.isEmpty()) {
return;
}
@ -548,7 +553,7 @@ void Preferences::chooseDownPath()
void Preferences::chooseUserStyleClicked()
{
QString file = QFileDialog::getOpenFileName(p_QupZilla, tr("Choose stylesheet location..."), QDir::homePath(), "*.css");
QString file = QFileDialog::getOpenFileName(this, tr("Choose stylesheet location..."), QDir::homePath(), "*.css");
if (file.isEmpty()) {
return;
}
@ -565,7 +570,7 @@ void Preferences::deleteHtml5storage()
void Preferences::chooseExternalDownloadManager()
{
QString path = QFileDialog::getOpenFileName(p_QupZilla, tr("Choose executable location..."), QDir::homePath());
QString path = QFileDialog::getOpenFileName(this, tr("Choose executable location..."), QDir::homePath());
if (path.isEmpty()) {
return;
}
@ -654,14 +659,6 @@ void Preferences::afterLaunchChanged(int value)
void Preferences::cacheValueChanged(int value)
{
ui->MBlabel->setText(QString::number(value) + " MB");
if (value == 0) {
ui->allowCache->setChecked(false);
allowCacheChanged(false);
}
else if (!ui->allowCache->isChecked()) {
ui->allowCache->setChecked(true);
allowCacheChanged(true);
}
}
void Preferences::pageCacheValueChanged(int value)
@ -689,6 +686,16 @@ void Preferences::showTabPreviewsChanged(bool state)
ui->animatedTabPreviews->setEnabled(state);
}
void Preferences::changeCachePathClicked()
{
QString path = QFileDialog::getExistingDirectory(this, tr("Choose cache path..."), ui->cachePath->text());
if (path.isEmpty()) {
return;
}
ui->cachePath->setText(path);
}
void Preferences::showPassManager(bool state)
{
m_autoFillManager->setVisible(state);
@ -905,6 +912,7 @@ void Preferences::saveSettings()
settings.setValue("maximumCachedPages", ui->pagesInCache->value());
settings.setValue("AllowLocalCache", ui->allowCache->isChecked());
settings.setValue("LocalCacheSize", ui->cacheMB->value());
settings.setValue("CachePath", ui->cachePath->text());
//CSS Style
settings.setValue("userStyleSheet", ui->userStyleSheet->text());

View File

@ -73,6 +73,7 @@ private slots:
void useExternalDownManagerChanged(bool state);
void useDifferentProxyForHttpsChanged(bool state);
void showTabPreviewsChanged(bool state);
void changeCachePathClicked();
void newTabChanged(int value);
void afterLaunchChanged(int value);

View File

@ -1200,32 +1200,6 @@
<layout class="QGridLayout" name="gridLayout_19">
<item row="0" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Maximum pages in cache: </string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="pageCacheLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QFrame" name="frame_2">
<property name="frameShape">
@ -1260,13 +1234,6 @@
</layout>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QCheckBox" name="allowCache">
<property name="text">
<string>Allow storing network cache on disk</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QFrame" name="cacheFrame">
<layout class="QHBoxLayout" name="horizontalLayout_5">
@ -1300,6 +1267,63 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="pageCacheLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Maximum pages in cache: </string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QCheckBox" name="allowCache">
<property name="text">
<string>Allow storing network cache on disk</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="storeCacheLabel">
<property name="text">
<string>Store cache in:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QLineEdit" name="cachePath"/>
</item>
<item>
<widget class="QToolButton" name="changeCachePath">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">

View File

@ -2824,6 +2824,14 @@
<source>Address Bar behaviour</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Store cache in:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Choose cache path...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>