File indexing completed on 2024-05-19 05:00:54

0001 /*
0002     This file is part of the KDE project.
0003 
0004     SPDX-FileCopyrightText: 2020 Stefano Crocco <stefano.crocco@alice.it>
0005 
0006     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0007 */
0008 
0009 #ifndef CACHE_H
0010 #define CACHE_H
0011 
0012 #include <KCModule>
0013 #include <KSharedConfig>
0014 
0015 #include <QDialog>
0016 #include <QScopedPointer>
0017 
0018 namespace Ui
0019 {
0020 class Cache;
0021 }
0022 
0023 /**
0024  * KCM which allows the user to configure the use of cache
0025  */
0026 class Cache: public KCModule
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     //TODO KF6: when dropping compatibility with KF5, remove QVariantList argument
0032     /**
0033      * @brief Constructor
0034      *
0035      * @param parent the parent widget
0036      * @param md as in `KCModule` constructor
0037      * @param args as in `KCModule` constructor
0038      */
0039     Cache(QObject *parent, const KPluginMetaData &md={}, const QVariantList &args={});
0040 
0041     /**
0042      * @brief Destructor
0043      */
0044     ~Cache();
0045 
0046     /**
0047      * @brief Loads the settings from the configuration files
0048      */
0049     void load() override;
0050 
0051     /**
0052      * @brief Resets the KCM to its default values
0053      */
0054     void defaults() override;
0055 
0056     /**
0057      * @brief Saves the user settings
0058      *
0059      */
0060     void save() override;
0061 
0062 #if QT_VERSION_MAJOR < 6
0063     void setNeedsSave(bool needs) {emit changed(needs);}
0064 #endif
0065 
0066 private slots:
0067 
0068     /**
0069      * @brief Slot called when the user toggles the "Don't store memory on disk" checkbox
0070      *
0071      * It enables or disables the "Use custom cache path" widgets
0072      * @param on whether memory cache was enabled or disabled
0073      */
0074     void toggleMemoryCache(bool on);
0075 
0076 private:
0077     /**
0078      * @brief The UI object
0079      */
0080     QScopedPointer<Ui::Cache> m_ui;
0081 
0082     /**
0083      * @brief The main config object
0084      */
0085     KSharedConfig::Ptr m_config;
0086 };
0087 
0088 #endif // CACHE_H