File indexing completed on 2024-05-19 09:32:17

0001 /*
0002  *   SPDX-FileCopyrightText: 2009 Ben Cooksley <bcooksley@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "BaseMode.h"
0008 
0009 #include <QAbstractItemView>
0010 #include <QAction>
0011 #include <QList>
0012 
0013 #include <KConfigDialog>
0014 #include <KConfigGroup>
0015 
0016 #include "BaseData.h"
0017 #include "MenuItem.h"
0018 #include "ModuleView.h"
0019 
0020 class BaseMode::Private
0021 {
0022 public:
0023     Private()
0024     {
0025     }
0026 
0027     QList<QAction *> actionsList;
0028     KPluginMetaData metaData;
0029     MenuItem *rootItem = nullptr;
0030     MenuItem *homeItem = nullptr;
0031     QString startupModule;
0032     QStringList startupModuleArgs;
0033     KConfigGroup config;
0034     bool showToolTips = true;
0035     BaseMode::ApplicationMode applicationMode = BaseMode::SystemSettings;
0036 };
0037 
0038 BaseMode::BaseMode(QObject *parent, const QVariantList &args)
0039     : QObject(parent)
0040     , d(new Private())
0041 {
0042     if (args.count() >= 1 && args.first().canConvert<ApplicationMode>()) {
0043         d->applicationMode = args.first().value<ApplicationMode>();
0044     }
0045     if (args.count() >= 2 && args[1].canConvert<QString>()) {
0046         d->startupModule = args[1].toString();
0047     }
0048     if (args.count() >= 3 && args[2].canConvert<QStringList>()) {
0049         d->startupModuleArgs = args[2].toStringList();
0050     }
0051 }
0052 
0053 void BaseMode::init()
0054 {
0055     d->rootItem = BaseData::instance()->menuItem();
0056     d->homeItem = BaseData::instance()->homeItem();
0057     d->config = BaseData::instance()->configGroup(QStringLiteral("systemsettings_sidebar_mode"));
0058     initEvent();
0059     connect(moduleView(), &ModuleView::moduleChanged, this, &BaseMode::viewChanged);
0060 }
0061 
0062 BaseMode::~BaseMode()
0063 {
0064     delete d;
0065 }
0066 
0067 void BaseMode::initEvent()
0068 {
0069 }
0070 
0071 QWidget *BaseMode::mainWidget()
0072 {
0073     return nullptr;
0074 }
0075 
0076 BaseMode::ApplicationMode BaseMode::applicationMode() const
0077 {
0078     return d->applicationMode;
0079 }
0080 
0081 ModuleView *BaseMode::moduleView() const
0082 {
0083     return nullptr;
0084 }
0085 
0086 QList<QAction *> &BaseMode::actionsList() const
0087 {
0088     return d->actionsList;
0089 }
0090 
0091 const KPluginMetaData &BaseMode::metaData() const
0092 {
0093     return d->metaData;
0094 }
0095 
0096 void BaseMode::setStartupModule(const QString &startupModule)
0097 {
0098     d->startupModule = startupModule;
0099 }
0100 
0101 QString BaseMode::startupModule() const
0102 {
0103     return d->startupModule;
0104 }
0105 
0106 void BaseMode::setStartupModuleArgs(const QStringList &startupModuleArgs)
0107 {
0108     d->startupModuleArgs = startupModuleArgs;
0109 }
0110 
0111 QStringList BaseMode::startupModuleArgs() const
0112 {
0113     return d->startupModuleArgs;
0114 }
0115 
0116 void BaseMode::searchChanged(const QString & /*text*/)
0117 {
0118 }
0119 
0120 void BaseMode::saveState()
0121 {
0122 }
0123 
0124 void BaseMode::giveFocus()
0125 {
0126 }
0127 
0128 void BaseMode::addConfiguration(KConfigDialog * /*config**/)
0129 {
0130 }
0131 
0132 void BaseMode::loadConfiguration()
0133 {
0134 }
0135 
0136 void BaseMode::saveConfiguration()
0137 {
0138 }
0139 
0140 MenuItem *BaseMode::rootItem() const
0141 {
0142     return d->rootItem;
0143 }
0144 
0145 MenuItem *BaseMode::homeItem() const
0146 {
0147     return d->homeItem;
0148 }
0149 
0150 KConfigGroup &BaseMode::config() const
0151 {
0152     return d->config;
0153 }
0154 
0155 QList<QAbstractItemView *> BaseMode::views() const
0156 {
0157     return {};
0158 }
0159 
0160 bool BaseMode::defaultsIndicatorsVisible() const
0161 {
0162     return false;
0163 }
0164 
0165 void BaseMode::toggleDefaultsIndicatorsVisibility()
0166 {
0167 }
0168 
0169 #include "moc_BaseMode.cpp"