File indexing completed on 2024-06-16 05:11:34

0001 /*
0002  *   SPDX-FileCopyrightText: 2009 Ben Cooksley <bcooksley@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "BaseData.h"
0008 
0009 #include "MenuItem.h"
0010 
0011 #include <KConfigGroup>
0012 #include <KSharedConfig>
0013 
0014 #include <QQmlEngine>
0015 
0016 class DataHelper
0017 {
0018 public:
0019     DataHelper()
0020     {
0021     }
0022     ~DataHelper()
0023     {
0024         delete object;
0025     }
0026     BaseData *object = nullptr;
0027 };
0028 
0029 Q_GLOBAL_STATIC(DataHelper, internalInstance)
0030 
0031 BaseData::BaseData()
0032 {
0033     internalInstance->object = this;
0034 }
0035 
0036 BaseData::~BaseData()
0037 {
0038 }
0039 
0040 BaseData *BaseData::instance()
0041 {
0042     if (!internalInstance->object) {
0043         new BaseData();
0044     }
0045     return internalInstance->object;
0046 }
0047 
0048 MenuItem *BaseData::menuItem()
0049 {
0050     return rootMenu;
0051 }
0052 
0053 void BaseData::setMenuItem(MenuItem *item)
0054 {
0055     rootMenu = item;
0056 }
0057 
0058 MenuItem *BaseData::homeItem()
0059 {
0060     return m_homeItem;
0061 }
0062 
0063 void BaseData::setHomeItem(MenuItem *item)
0064 {
0065     m_homeItem = item;
0066 }
0067 
0068 KConfigGroup BaseData::configGroup(const QString &pluginName)
0069 {
0070     return KSharedConfig::openConfig()->group(pluginName);
0071 }
0072 
0073 std::shared_ptr<QQmlEngine> BaseData::qmlEngine()
0074 {
0075     if (!m_engine) {
0076         m_engine.reset(new QQmlEngine(this));
0077     }
0078     return m_engine;
0079 }
0080 
0081 #include "moc_BaseData.cpp"