File indexing completed on 2024-11-24 04:49:03

0001 /*
0002    SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "gravatar_export.h"
0010 
0011 #include <QPixmap>
0012 
0013 #include <memory>
0014 
0015 namespace Gravatar
0016 {
0017 class GravatarCachePrivate;
0018 class Hash;
0019 
0020 /** Cache for both positive and negative avatar lookups. */
0021 class GRAVATAR_EXPORT GravatarCache
0022 {
0023 public:
0024     static GravatarCache *self();
0025 
0026     GravatarCache();
0027     ~GravatarCache();
0028 
0029     void saveGravatarPixmap(const Hash &hash, const QPixmap &pixmap);
0030     void saveMissingGravatar(const Hash &hash);
0031 
0032     [[nodiscard]] QPixmap loadGravatarPixmap(const Hash &hash, bool &gravatarStored);
0033 
0034     [[nodiscard]] int maximumSize() const;
0035     void setMaximumSize(int maximumSize);
0036 
0037     void clear();
0038     void clearAllCache();
0039 
0040 private:
0041     Q_DISABLE_COPY(GravatarCache)
0042     std::unique_ptr<GravatarCachePrivate> const d;
0043 };
0044 }