Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 0e4a7e6b authored by Laurent Montel's avatar Laurent Montel 😁

Allow to specify cache size

parent bb85baeb
......@@ -196,6 +196,9 @@ xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/sta
<entry name="GravatarUseDefaultImage" type="Bool">
<default>false</default>
</entry>
<entry name="GravatarCacheSize" type="Int">
<default>20</default>
</entry>
</group>
<group name="TextIndex">
......
......@@ -17,7 +17,9 @@
#include "gravatarconfigwidgettest.h"
#include "../widgets/gravatarconfigwidget.h"
#include <KIntNumInput>
#include <QCheckBox>
#include <QLabel>
#include <QPushButton>
#include <qtest_kde.h>
......@@ -43,6 +45,13 @@ void GravatarConfigWidgetTest::shouldHaveDefaultValue()
QPushButton *clearGravatarCache = qFindChild<QPushButton *>(&w, QLatin1String("cleargravatarcachebutton"));
QVERIFY(clearGravatarCache);
QLabel *lab = qFindChild<QLabel *>(&w, QLatin1String("gravatarcachesizelabel"));
QVERIFY(lab);
KIntSpinBox *gravatarCacheSize = qFindChild<KIntSpinBox *>(&w, QLatin1String("gravatarcachesize"));
QVERIFY(gravatarCacheSize);
}
QTEST_KDEMAIN(GravatarConfigWidgetTest, GUI)
......@@ -24,7 +24,9 @@
#include <QCheckBox>
#include <QPushButton>
#include <KGlobal>
#include <QLabel>
#include <QDir>
#include <KIntNumInput>
#include "settings/globalsettings.h"
#include "pimcommon/widgets/configureimmutablewidgetutils.h"
......@@ -48,6 +50,21 @@ GravatarConfigWidget::GravatarConfigWidget(QWidget *parent)
mUseDefaultPixmap->setObjectName(QLatin1String("usedefaultimage"));
mainLayout->addWidget(mUseDefaultPixmap);
//KF5 add i18n
QHBoxLayout *cacheSizeLayout = new QHBoxLayout;
mainLayout->addLayout(cacheSizeLayout);
QLabel *lab = new QLabel(QLatin1String("Gravatar Cache Size:"));
lab->setObjectName(QLatin1String("gravatarcachesizelabel"));
cacheSizeLayout->addWidget(lab);
mGravatarCacheSize = new KIntSpinBox;
mGravatarCacheSize->setMinimum(1);
mGravatarCacheSize->setMaximum(9999);
mGravatarCacheSize->setObjectName(QLatin1String("gravatarcachesize"));
connect(mGravatarCacheSize, SIGNAL(valueChanged(int)), this, SLOT(slotGravatarCacheSizeChanged()));
cacheSizeLayout->addWidget(mGravatarCacheSize);
cacheSizeLayout->addStretch();
//KF5 add i18n
QHBoxLayout *buttonLayout = new QHBoxLayout;
mainLayout->addLayout(buttonLayout);
......@@ -56,6 +73,7 @@ GravatarConfigWidget::GravatarConfigWidget(QWidget *parent)
buttonLayout->addWidget(mClearGravatarCache);
buttonLayout->addStretch();
connect(mClearGravatarCache, SIGNAL(clicked(bool)), this, SLOT(slotClearGravatarCache()));
connect(mUseDefaultPixmap, SIGNAL(clicked(bool)), SIGNAL(configChanged(bool)));
connect(mEnableGravatarSupport, SIGNAL(clicked(bool)), SIGNAL(configChanged(bool)));
......@@ -70,12 +88,14 @@ void GravatarConfigWidget::save()
{
saveCheckBox(mEnableGravatarSupport, MessageViewer::GlobalSettings::self()->gravatarSupportEnabledItem());
saveCheckBox(mUseDefaultPixmap, MessageViewer::GlobalSettings::self()->gravatarUseDefaultImageItem());
saveSpinBox(mGravatarCacheSize, MessageViewer::GlobalSettings::self()->gravatarCacheSizeItem());
}
void GravatarConfigWidget::doLoadFromGlobalSettings()
{
loadWidget(mEnableGravatarSupport, MessageViewer::GlobalSettings::self()->gravatarSupportEnabledItem());
loadWidget(mUseDefaultPixmap, MessageViewer::GlobalSettings::self()->gravatarUseDefaultImageItem());
loadWidget(mGravatarCacheSize, MessageViewer::GlobalSettings::self()->gravatarCacheSizeItem());
}
void GravatarConfigWidget::doResetToDefaultsOther()
......@@ -100,3 +120,9 @@ void GravatarConfigWidget::slotClearGravatarCache()
}
PimCommon::GravatarCache::self()->clear();
}
void GravatarConfigWidget::slotGravatarCacheSizeChanged()
{
Q_EMIT configChanged(true);
}
......@@ -22,6 +22,7 @@
#include "messageviewer_export.h"
class QCheckBox;
class QPushButton;
class KIntSpinBox;
namespace MessageViewer {
class MESSAGEVIEWER_EXPORT GravatarConfigWidget : public QWidget
{
......@@ -39,11 +40,13 @@ Q_SIGNALS:
private Q_SLOTS:
void slotClearGravatarCache();
void slotGravatarCacheSizeChanged();
private:
QCheckBox *mEnableGravatarSupport;
QCheckBox *mUseDefaultPixmap;
QPushButton *mClearGravatarCache;
KIntSpinBox *mGravatarCacheSize;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment