Commit b0317c8c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Adapt code

parent a8d3512d
......@@ -41,26 +41,6 @@ void GravatarConfigureSettingsDialogTest::shouldHaveDefaultValue()
QVBoxLayout *topLayout = dlg.findChild<QVBoxLayout *>(QStringLiteral("toplayout"));
QVERIFY(topLayout);
QLabel *lab = dlg.findChild<QLabel *>(QStringLiteral("gravatarcachesizelabel"));
QVERIFY(lab);
KPluralHandlingSpinBox *gravatarCacheSize = dlg.findChild<KPluralHandlingSpinBox *>(QStringLiteral("gravatarcachesize"));
QVERIFY(gravatarCacheSize);
QCheckBox *useLibravatar = dlg.findChild<QCheckBox *>(QStringLiteral("uselibravatarcheckbox"));
QVERIFY(useLibravatar);
QVERIFY(useLibravatar->isEnabled());
QCheckBox *fallbackGravatar = dlg.findChild<QCheckBox *>(QStringLiteral("fallbackgravatar"));
QVERIFY(fallbackGravatar);
QVERIFY(!fallbackGravatar->isEnabled());
KSeparator *separator = dlg.findChild<KSeparator *>(QStringLiteral("separator"));
QVERIFY(separator);
KSeparator *separator2 = dlg.findChild<KSeparator *>(QStringLiteral("separator2"));
QVERIFY(separator2);
}
QTEST_MAIN(GravatarConfigureSettingsDialogTest)
......@@ -23,6 +23,8 @@
#include <PimCommon/ConfigureImmutableWidgetUtils>
#include <KLocalizedString>
#include <KPluralHandlingSpinBox>
#include <KSeparator>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QPushButton>
......@@ -37,6 +39,11 @@ GravatarConfigureSettingsDialog::GravatarConfigureSettingsDialog(QWidget *parent
setWindowTitle(i18nc("@title:window", "Configure Gravatar"));
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setObjectName(QStringLiteral("toplayout"));
mGravatarConfigureSettings = new GravatarConfigureSettingsWidget(this);
mGravatarConfigureSettings->setObjectName(QStringLiteral("gravatarconfiguresettings"));
topLayout->addWidget(mGravatarConfigureSettings);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::RestoreDefaults, this);
buttonBox->setObjectName(QStringLiteral("buttonbox"));
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
......@@ -46,50 +53,6 @@ GravatarConfigureSettingsDialog::GravatarConfigureSettingsDialog(QWidget *parent
connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, &GravatarConfigureSettingsDialog::slotRestoreDefault);
okButton->setDefault(true);
mUseDefaultPixmap = new QCheckBox(i18n("Use Default Image"), this);
mUseDefaultPixmap->setObjectName(QStringLiteral("usedefaultimage"));
topLayout->addWidget(mUseDefaultPixmap);
mUseLibravatar = new QCheckBox(i18n("Use Libravatar"), this);
mUseLibravatar->setObjectName(QStringLiteral("uselibravatarcheckbox"));
topLayout->addWidget(mUseLibravatar);
mFallbackGravatar = new QCheckBox(i18n("Fallback to Gravatar"), this);
mFallbackGravatar->setObjectName(QStringLiteral("fallbackgravatar"));
topLayout->addWidget(mFallbackGravatar);
connect(mUseLibravatar, &QCheckBox::toggled, mFallbackGravatar, &QCheckBox::setEnabled);
mFallbackGravatar->setEnabled(false);
QHBoxLayout *cacheSizeLayout = new QHBoxLayout;
topLayout->addLayout(cacheSizeLayout);
QLabel *lab = new QLabel(i18n("Gravatar Cache Size:"), this);
lab->setObjectName(QStringLiteral("gravatarcachesizelabel"));
cacheSizeLayout->addWidget(lab);
mGravatarCacheSize = new KPluralHandlingSpinBox(this);
mGravatarCacheSize->setMinimum(1);
mGravatarCacheSize->setMaximum(9999);
mGravatarCacheSize->setSuffix(ki18ncp("add space before image", " image", " images"));
mGravatarCacheSize->setObjectName(QStringLiteral("gravatarcachesize"));
cacheSizeLayout->addWidget(mGravatarCacheSize);
cacheSizeLayout->addStretch();
KSeparator *separator = new KSeparator(this);
separator->setObjectName(QStringLiteral("separator"));
topLayout->addWidget(separator);
QHBoxLayout *buttonLayout = new QHBoxLayout;
topLayout->addLayout(buttonLayout);
mClearGravatarCache = new QPushButton(i18n("Clear Gravatar Cache"), this);
mClearGravatarCache->setObjectName(QStringLiteral("cleargravatarcachebutton"));
buttonLayout->addWidget(mClearGravatarCache);
buttonLayout->addStretch();
separator = new KSeparator(this);
separator->setObjectName(QStringLiteral("separator2"));
topLayout->addWidget(separator);
connect(mClearGravatarCache, &QAbstractButton::clicked, this, &GravatarConfigureSettingsDialog::slotClearGravatarCache);
topLayout->addWidget(buttonBox);
load();
}
......
......@@ -43,6 +43,17 @@ GravatarConfigureSettingsWidget::GravatarConfigureSettingsWidget(QWidget *parent
mUseDefaultPixmap->setObjectName(QStringLiteral("usedefaultimage"));
topLayout->addWidget(mUseDefaultPixmap);
mUseLibravatar = new QCheckBox(i18n("Use Libravatar"), this);
mUseLibravatar->setObjectName(QStringLiteral("uselibravatarcheckbox"));
topLayout->addWidget(mUseLibravatar);
mFallbackGravatar = new QCheckBox(i18n("Fallback to Gravatar"), this);
mFallbackGravatar->setObjectName(QStringLiteral("fallbackgravatar"));
topLayout->addWidget(mFallbackGravatar);
connect(mUseLibravatar, &QCheckBox::toggled, mFallbackGravatar, &QCheckBox::setEnabled);
mFallbackGravatar->setEnabled(false);
QHBoxLayout *cacheSizeLayout = new QHBoxLayout;
topLayout->addLayout(cacheSizeLayout);
QLabel *lab = new QLabel(i18n("Gravatar Cache Size:"), this);
......@@ -95,6 +106,8 @@ void GravatarConfigureSettingsWidget::slotRestoreDefault()
void GravatarConfigureSettingsWidget::save()
{
saveCheckBox(mUseDefaultPixmap, Gravatar::GravatarSettings::self()->gravatarUseDefaultImageItem());
saveCheckBox(mUseLibravatar, Gravatar::GravatarSettings::self()->libravatarSupportEnabledItem());
saveCheckBox(mFallbackGravatar, Gravatar::GravatarSettings::self()->fallbackToGravatarItem());
saveSpinBox(mGravatarCacheSize, Gravatar::GravatarSettings::self()->gravatarCacheSizeItem());
}
......@@ -102,4 +115,6 @@ void GravatarConfigureSettingsWidget::load()
{
loadWidget(mUseDefaultPixmap, Gravatar::GravatarSettings::self()->gravatarUseDefaultImageItem());
loadWidget(mGravatarCacheSize, Gravatar::GravatarSettings::self()->gravatarCacheSizeItem());
loadWidget(mUseLibravatar, Gravatar::GravatarSettings::self()->libravatarSupportEnabledItem());
loadWidget(mFallbackGravatar, Gravatar::GravatarSettings::self()->fallbackToGravatarItem());
}
......@@ -43,6 +43,8 @@ private:
QCheckBox *mUseDefaultPixmap = nullptr;
QPushButton *mClearGravatarCache = nullptr;
KPluralHandlingSpinBox *mGravatarCacheSize = nullptr;
QCheckBox *mUseLibravatar = nullptr;
QCheckBox *mFallbackGravatar = nullptr;
};
}
......
......@@ -25,6 +25,7 @@
class QLabel;
class QLineEdit;
class QPushButton;
class QCheckBox;
namespace Gravatar {
class GravatarResolvUrlJob;
......
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