File indexing completed on 2024-04-21 16:22:50

0001 /*
0002  *   SPDX-FileCopyrightText: 2009 Ben Cooksley <bcooksley@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef BASEDATA_H
0008 #define BASEDATA_H
0009 
0010 #include <QObject>
0011 
0012 #include "systemsettingsview_export.h"
0013 
0014 class QString;
0015 class MenuItem;
0016 class KConfigGroup;
0017 
0018 /**
0019  * @brief Provides a interface sharing common data between modules in System Settings
0020  *
0021  * BaseData is a standard interface in System Settings to retrieve information that is shared between all modules.
0022  * It is a singleton, and will be automatically cleaned up.
0023  *
0024  * @author Ben Cooksley <bcooksley@kde.org>
0025  */
0026 class SYSTEMSETTINGSVIEW_EXPORT BaseData : public QObject
0027 {
0028     Q_OBJECT
0029     Q_DISABLE_COPY(BaseData)
0030 
0031 private:
0032     explicit BaseData();
0033 
0034 public:
0035     /**
0036      * Provides a pointer to access the shared BaseData instance in order to retrieve data.
0037      *
0038      * @returns Access to the shared instance of BaseData.
0039      */
0040     static BaseData *instance();
0041 
0042     /**
0043      * Normal destructor that handles cleanup. Any objects created through BaseData must be assumed
0044      * to be invalid afterwards.
0045      */
0046     ~BaseData() override;
0047 
0048     /**
0049      * Provides the shared MenuItem which lists all categories and modules, for use with MenuModel.
0050      *
0051      * @returns the shared MenuItem.
0052      */
0053     MenuItem *menuItem();
0054 
0055     /**
0056      * Sets the MenuItem which the Singleton will return.
0057      * For internal use only.
0058      *
0059      * @param item A pointer to the MenuItem object
0060      */
0061     void setMenuItem(MenuItem *item);
0062 
0063     /**
0064      * Provides the shared MenuItem that corresponds to a KCM which should be used as startup page.
0065      *
0066      * @returns the shared MenuItem. It may be nullptr.
0067      */
0068     MenuItem *homeItem();
0069 
0070     /**
0071      * Sets the homescreen MenuItem which the Singleton will return.
0072      * For internal use only.
0073      *
0074      * @param item A pointer to the MenuItem object
0075      */
0076     void setHomeItem(MenuItem *item);
0077 
0078     /**
0079      * Returns the configuration group by the name provided in the current applications configuration file.
0080      *
0081      * @param pluginName the name of the group that is required.
0082      * @returns The configuration group that is required.
0083      */
0084     KConfigGroup configGroup(const QString &pluginName);
0085 
0086 private:
0087     MenuItem *rootMenu;
0088     MenuItem *m_homeItem;
0089 };
0090 
0091 #endif