File indexing completed on 2024-09-08 13:24:51
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 BaseMode::~BaseMode() 0054 { 0055 delete d; 0056 } 0057 0058 void BaseMode::init(const KPluginMetaData &metaData) 0059 { 0060 d->rootItem = BaseData::instance()->menuItem(); 0061 d->homeItem = BaseData::instance()->homeItem(); 0062 d->metaData = metaData; 0063 d->config = BaseData::instance()->configGroup(metaData.pluginId()); 0064 initEvent(); 0065 connect(moduleView(), &ModuleView::moduleChanged, this, &BaseMode::viewChanged); 0066 } 0067 0068 void BaseMode::initEvent() 0069 { 0070 } 0071 0072 QWidget *BaseMode::mainWidget() 0073 { 0074 return nullptr; 0075 } 0076 0077 KAboutData *BaseMode::aboutData() 0078 { 0079 return nullptr; 0080 } 0081 0082 BaseMode::ApplicationMode BaseMode::applicationMode() const 0083 { 0084 return d->applicationMode; 0085 } 0086 0087 ModuleView *BaseMode::moduleView() const 0088 { 0089 return nullptr; 0090 } 0091 0092 QList<QAction *> &BaseMode::actionsList() const 0093 { 0094 return d->actionsList; 0095 } 0096 0097 const KPluginMetaData &BaseMode::metaData() const 0098 { 0099 return d->metaData; 0100 } 0101 0102 void BaseMode::setStartupModule(const QString &startupModule) 0103 { 0104 d->startupModule = startupModule; 0105 } 0106 0107 QString BaseMode::startupModule() const 0108 { 0109 return d->startupModule; 0110 } 0111 0112 void BaseMode::setStartupModuleArgs(const QStringList &startupModuleArgs) 0113 { 0114 d->startupModuleArgs = startupModuleArgs; 0115 } 0116 0117 QStringList BaseMode::startupModuleArgs() const 0118 { 0119 return d->startupModuleArgs; 0120 } 0121 0122 void BaseMode::searchChanged(const QString &text) 0123 { 0124 Q_UNUSED(text); 0125 } 0126 0127 void BaseMode::saveState() 0128 { 0129 } 0130 0131 void BaseMode::leaveModuleView() 0132 { 0133 } 0134 0135 void BaseMode::giveFocus() 0136 { 0137 } 0138 0139 void BaseMode::addConfiguration(KConfigDialog *config) 0140 { 0141 Q_UNUSED(config); 0142 } 0143 0144 void BaseMode::loadConfiguration() 0145 { 0146 } 0147 0148 void BaseMode::saveConfiguration() 0149 { 0150 } 0151 0152 MenuItem *BaseMode::rootItem() const 0153 { 0154 return d->rootItem; 0155 } 0156 0157 MenuItem *BaseMode::homeItem() const 0158 { 0159 return d->homeItem; 0160 } 0161 0162 KConfigGroup &BaseMode::config() const 0163 { 0164 return d->config; 0165 } 0166 0167 QList<QAbstractItemView *> BaseMode::views() const 0168 { 0169 return QList<QAbstractItemView *>(); 0170 } 0171 0172 bool BaseMode::defaultsIndicatorsVisible() const 0173 { 0174 return false; 0175 } 0176 0177 void BaseMode::toggleDefaultsIndicatorsVisibility() 0178 { 0179 }